UpTime Update
parent
60c4cbcc6c
commit
82ae327a4f
|
|
@ -7,7 +7,10 @@ import { classToPlain } from 'class-transformer';
|
||||||
export class EventsService {
|
export class EventsService {
|
||||||
async CompareStatus(parameter: MetricK2) : Promise <any>{
|
async CompareStatus(parameter: MetricK2) : Promise <any>{
|
||||||
let diff = Math.floor(Math.random() * (2)) + 1;
|
let diff = Math.floor(Math.random() * (2)) + 1;
|
||||||
console.log(diff);
|
// let testStr: string = '2685 ч 44 мин 30 сек';
|
||||||
|
// let tstspl: string[] = testStr.split(' ');
|
||||||
|
// let uptime: number = (+tstspl[0])*3600+(+tstspl[2])*60+(+tstspl[4]);
|
||||||
|
// console.log(tstspl[0],tstspl[2],tstspl[4],uptime);
|
||||||
if(parameter.status != (parameter.status + diff) ){
|
if(parameter.status != (parameter.status + diff) ){
|
||||||
await this.RecordChangedMetricToClicHouse(parameter.id, parameter.name, parameter.value, parameter, parameter.status, parameter.status + diff);
|
await this.RecordChangedMetricToClicHouse(parameter.id, parameter.name, parameter.value, parameter, parameter.status, parameter.status + diff);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -59,11 +59,14 @@ var prev: K2Metrics; //Prevous K2
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class ZvksmetricsService {
|
export class ZvksmetricsService {
|
||||||
async useStatusModel(inputData: any): Promise<any> {
|
async useStatusModel(inputData: any): Promise<any> {
|
||||||
|
|
||||||
|
// inputData = inputData.replace('\\','0');
|
||||||
|
|
||||||
let inp: K2Metrics = new K2Metrics();
|
let inp: K2Metrics = new K2Metrics();
|
||||||
inp = inputData;
|
inp = inputData;
|
||||||
|
|
||||||
let complex: K2Metrics = new K2Metrics();
|
let complex: K2Metrics = new K2Metrics();
|
||||||
complex.service_name = inputData.service_name;
|
complex.service_name = inp.service_name;
|
||||||
complex.metrics = [];
|
complex.metrics = [];
|
||||||
|
|
||||||
let model: ComplexMetricsCalculation[] = [];
|
let model: ComplexMetricsCalculation[] = [];
|
||||||
|
|
@ -84,10 +87,11 @@ export class ZvksmetricsService {
|
||||||
let copmplexParameterBody: string = JSON.stringify(ctp);
|
let copmplexParameterBody: string = JSON.stringify(ctp);
|
||||||
let rtp: any = classToPlain(inp);
|
let rtp: any = classToPlain(inp);
|
||||||
let rawParameterBody: string = JSON.stringify(rtp);
|
let rawParameterBody: string = JSON.stringify(rtp);
|
||||||
|
// rawParameterBody = rawParameterBody.replace('\\', '0');
|
||||||
// console.log(rawParameterBody);
|
// console.log(rawParameterBody);
|
||||||
let abc = new ClickhouseService();
|
let recordToDB = new ClickhouseService();
|
||||||
await abc.ClickHouseAddRecords('raw', rawParameterBody);
|
await recordToDB.ClickHouseAddRecords('raw', rawParameterBody);
|
||||||
await abc.ClickHouseAddRecords('complex', copmplexParameterBody);
|
await recordToDB.ClickHouseAddRecords('complex', copmplexParameterBody);
|
||||||
|
|
||||||
|
|
||||||
// const val = JSON.parse(JSON.stringify(model[0].values));
|
// const val = JSON.parse(JSON.stringify(model[0].values));
|
||||||
|
|
@ -136,7 +140,14 @@ export class ZvksmetricsService {
|
||||||
let compare = new EventsService();
|
let compare = new EventsService();
|
||||||
|
|
||||||
// const jsonData = require('../conf/devices.json');
|
// const jsonData = require('../conf/devices.json');
|
||||||
// console.log(jsonData);
|
// console.log(jsonData);
|
||||||
|
let uptimeElements = inputData.metrics.filter(element=> element.name == 'upTime');
|
||||||
|
if(uptimeElements){
|
||||||
|
for(let uptime of uptimeElements){
|
||||||
|
let uptStr: any = uptime?.value.toString().split(' ');
|
||||||
|
uptime.value = (+uptStr[0])*3600+(uptStr[2])*60+(+uptStr[4]);
|
||||||
|
}
|
||||||
|
}
|
||||||
for (let d = 0; d < device_len; d++) {
|
for (let d = 0; d < device_len; d++) {
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
let metr = { "source": "" };
|
let metr = { "source": "" };
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue