Rangers Method
parent
d15244b635
commit
20ad29c649
|
|
@ -3,16 +3,16 @@
|
||||||
"name": "cpu_utilization",
|
"name": "cpu_utilization",
|
||||||
"ranges": [
|
"ranges": [
|
||||||
{"min": 0, "max": 60, "status": 1},
|
{"min": 0, "max": 60, "status": 1},
|
||||||
{"min": 61, "max": 80, "status": 2},
|
{"min": 60, "max": 80, "status": 2},
|
||||||
{"min": 81, "max": 90, "status": 3},
|
{"min": 80, "max": 90, "status": 3},
|
||||||
{"min": 91, "max": 100, "status": 4}
|
{"min": 90, "max": 100, "status": 4}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "cpu_load_average_1",
|
"name": "cpu_load_average_1",
|
||||||
"ranges": [
|
"ranges": [
|
||||||
{"min": 0, "max": 60, "status": 1},
|
{"min": 0, "max": 60, "status": 1},
|
||||||
{"min": 61, "max": 80, "status": 2},
|
{"min": 60, "max": 80, "status": 2},
|
||||||
{"min": 81, "max": 90, "status": 3},
|
{"min": 81, "max": 90, "status": 3},
|
||||||
{"min": 91, "max": 100, "status": 4}
|
{"min": 91, "max": 100, "status": 4}
|
||||||
]
|
]
|
||||||
|
|
@ -38,8 +38,8 @@
|
||||||
{
|
{
|
||||||
"name": "ram_usage",
|
"name": "ram_usage",
|
||||||
"ranges": [
|
"ranges": [
|
||||||
{"min": 0, "max": 60, "status": 1},
|
{"min": 0, "max": 30, "status": 1},
|
||||||
{"min": 61, "max": 80, "status": 2},
|
{"min": 30, "max": 80, "status": 2},
|
||||||
{"min": 81, "max": 90, "status": 3},
|
{"min": 81, "max": 90, "status": 3},
|
||||||
{"min": 91, "max": 100, "status": 4}
|
{"min": 91, "max": 100, "status": 4}
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,385 @@
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"name": "cpu_utilization",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 60, "status": 1},
|
||||||
|
{"min": 60, "max": 80, "status": 2},
|
||||||
|
{"min": 80, "max": 90, "status": 3},
|
||||||
|
{"min": 90, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cpu_load_average_1",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 60, "status": 1},
|
||||||
|
{"min": 60, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cpu_load_average_5",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 60, "status": 1},
|
||||||
|
{"min": 61, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "cpu_load_average_15",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 60, "status": 1},
|
||||||
|
{"min": 61, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "ram_usage",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 30, "status": 1},
|
||||||
|
{"min": 30, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "disk_usage",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "disk_read_rate",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 100, "status": 1},
|
||||||
|
{"min": 101, "max": 300, "status": 2},
|
||||||
|
{"min": 301, "max": 500, "status": 3},
|
||||||
|
{"min": 501, "max": 5000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "disk_write_rate",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 100, "status": 1},
|
||||||
|
{"min": 101, "max": 300, "status": 2},
|
||||||
|
{"min": 301, "max": 500, "status": 3},
|
||||||
|
{"min": 501, "max": 5000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interface_rx_Eth_1",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interface_tx_Eth_1",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interface_rx_Eth_2",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interface_tx_Eth_2",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interface_rx_Eth_3",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interface_tx_Eth_3",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interface_rx_Eth_4",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interface_tx_Eth_4",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 70, "status": 1},
|
||||||
|
{"min": 71, "max": 80, "status": 2},
|
||||||
|
{"min": 81, "max": 90, "status": 3},
|
||||||
|
{"min": 91, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_read_packets_errors_Eth_1",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_write_packets_errors_Eth_1",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_read_packets_errors_Eth_2",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_write_packets_errors_Eth_2",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_read_packets_errors_Eth_3",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_write_packets_errors_Eth_3",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_read_packets_errors_Eth_4",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_write_packets_errors_Eth_4",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_read_packets_discarded_Eth_1",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_write_packets_discarded_Eth_1",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_read_packets_discarded_Eth_2",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_write_packets_discarded_Eth_2",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_read_packets_discarded_Eth_3",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_write_packets_discarded_Eth_3",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_read_packets_discarded_Eth_4",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "network_interfaces_write_packets_discarded_Eth_4",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 1, "status": 1},
|
||||||
|
{"min": 2, "max": 10, "status": 2},
|
||||||
|
{"min": 11, "max": 20, "status": 3},
|
||||||
|
{"min": 21, "max": 100, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "response_icmp",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 100, "status": 1},
|
||||||
|
{"min": 101, "max": 200, "status": 2},
|
||||||
|
{"min": 201, "max": 300, "status": 3},
|
||||||
|
{"min": 301, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "server_uptime",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 0, "status": 4},
|
||||||
|
{"min": 1, "max": 1000, "status": 1}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "total_participants",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 10, "status": 1},
|
||||||
|
{"min": 11, "max": 30, "status": 2},
|
||||||
|
{"min": 31, "max": 50, "status": 3},
|
||||||
|
{"min": 51, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "registered_abonents",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 10, "status": 1},
|
||||||
|
{"min": 11, "max": 30, "status": 2},
|
||||||
|
{"min": 31, "max": 50, "status": 3},
|
||||||
|
{"min": 51, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "webcasts_HLS_clients",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 10, "status": 1},
|
||||||
|
{"min": 11, "max": 30, "status": 2},
|
||||||
|
{"min": 31, "max": 50, "status": 3},
|
||||||
|
{"min": 51, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "total_P2P_rooms",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 10, "status": 1},
|
||||||
|
{"min": 11, "max": 30, "status": 2},
|
||||||
|
{"min": 31, "max": 50, "status": 3},
|
||||||
|
{"min": 51, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "conferences_total",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 10, "status": 1},
|
||||||
|
{"min": 11, "max": 30, "status": 2},
|
||||||
|
{"min": 31, "max": 50, "status": 3},
|
||||||
|
{"min": 51, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "conferences_active",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 10, "status": 1},
|
||||||
|
{"min": 11, "max": 30, "status": 2},
|
||||||
|
{"min": 31, "max": 50, "status": 3},
|
||||||
|
{"min": 51, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "records_active",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 10, "status": 1},
|
||||||
|
{"min": 11, "max": 30, "status": 2},
|
||||||
|
{"min": 31, "max": 50, "status": 3},
|
||||||
|
{"min": 51, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "number_of_records_saved",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 10, "status": 1},
|
||||||
|
{"min": 11, "max": 30, "status": 2},
|
||||||
|
{"min": 31, "max": 50, "status": 3},
|
||||||
|
{"min": 51, "max": 1000, "status": 4}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "replication_status",
|
||||||
|
"ranges": [
|
||||||
|
{"min": 0, "max": 0, "status": 4},
|
||||||
|
{"min": 1, "max": 1, "status": 1}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
|
@ -26,6 +26,16 @@ export class ZvksmetricsController {
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Заглушка для будующей API под граничные значения
|
||||||
|
@Post('ranges/:code')
|
||||||
|
async setRanges(@Body() inputRanges: any, @Param('code', ParseIntPipe) code: number): Promise<string> {
|
||||||
|
let ret: string = "Controller Error";
|
||||||
|
if (code === 9999) {
|
||||||
|
return await this.metricsService.saveRanges(inputRanges);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
//Заглушка для будующей API под комплексные значения метрик
|
//Заглушка для будующей API под комплексные значения метрик
|
||||||
@Options('complex/:code')
|
@Options('complex/:code')
|
||||||
async showComplexMetrics(@Param('code', ParseIntPipe) code: number): Promise<JSON> {
|
async showComplexMetrics(@Param('code', ParseIntPipe) code: number): Promise<JSON> {
|
||||||
|
|
@ -38,7 +48,7 @@ export class ZvksmetricsController {
|
||||||
|
|
||||||
@Post('input')
|
@Post('input')
|
||||||
async getPostMessage(@Body() inputMetrics: any): Promise<string> {
|
async getPostMessage(@Body() inputMetrics: any): Promise<string> {
|
||||||
console.log(inputMetrics);
|
// console.log(inputMetrics);
|
||||||
let out: any = await this.metricsService.useStatusModel(inputMetrics);
|
let out: any = await this.metricsService.useStatusModel(inputMetrics);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import { Body, Injectable } from '@nestjs/common';
|
import { Body, Injectable } from '@nestjs/common';
|
||||||
import axios, { Axios, AxiosResponse } from 'axios';
|
import axios, { Axios, AxiosResponse } from 'axios';
|
||||||
import { readFile } from 'node:fs/promises';
|
import { readFile, writeFile } from 'node:fs/promises';
|
||||||
import { response } from 'express';
|
import { response } from 'express';
|
||||||
import { json } from 'node:stream/consumers';
|
import { json } from 'node:stream/consumers';
|
||||||
import math, { create, all, evaluate, number, random, complex, string } from 'mathjs'
|
import math, { create, all, evaluate, number, random, complex, string } from 'mathjs'
|
||||||
|
|
@ -22,8 +22,8 @@ export class MetricK2 {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class K2Metrics {
|
export class K2Metrics {
|
||||||
service_name: string;
|
service_name: string;
|
||||||
device: number;
|
// device: number;
|
||||||
source: string;
|
// source: string;
|
||||||
//endpoint_name: string;
|
//endpoint_name: string;
|
||||||
metrics: MetricK2[];
|
metrics: MetricK2[];
|
||||||
};
|
};
|
||||||
|
|
@ -74,10 +74,11 @@ export class ZvksmetricsService {
|
||||||
// console.log(prev);
|
// console.log(prev);
|
||||||
|
|
||||||
let intermediate = await this.getComplexMetricsValues(inp, prev, complex, model, scope);
|
let intermediate = await this.getComplexMetricsValues(inp, prev, complex, model, scope);
|
||||||
|
|
||||||
// console.log(intermediate);
|
// console.log(intermediate);
|
||||||
|
|
||||||
|
|
||||||
const val = JSON.parse(JSON.stringify(model[0].values));
|
// const val = JSON.parse(JSON.stringify(model[0].values));
|
||||||
|
|
||||||
// let editedMetrics : K2Metrics = await this.getMetrics (inp, comlexCalc, scope);
|
// let editedMetrics : K2Metrics = await this.getMetrics (inp, comlexCalc, scope);
|
||||||
let responseFromExporter: any = await this.sendMetrics(intermediate);
|
let responseFromExporter: any = await this.sendMetrics(intermediate);
|
||||||
|
|
@ -89,7 +90,7 @@ export class ZvksmetricsService {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMetrics(inputData: K2Metrics, comlexCalc: ComplexMetricsCalculation[], scope: MetricsRanges[]): Promise<K2Metrics> {
|
async getMetrics(inputData: K2Metrics, scope: MetricsRanges[]): Promise<K2Metrics> {
|
||||||
let arr: MetricK2[] = inputData.metrics;
|
let arr: MetricK2[] = inputData.metrics;
|
||||||
let length: number = arr.length;
|
let length: number = arr.length;
|
||||||
|
|
||||||
|
|
@ -101,6 +102,18 @@ export class ZvksmetricsService {
|
||||||
return inputData;
|
return inputData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// async getComplexMetrics(complexData: K2Metrics, scope: MetricsRanges[]): Promise<K2Metrics> {
|
||||||
|
// let arr: MetricK2[] = complexData.metrics;
|
||||||
|
// let length: number = arr.length;
|
||||||
|
|
||||||
|
// for (let i = 0; i < length; i++) {
|
||||||
|
// arr[i].status = await this.setMetricsStatus(arr[i], scope);
|
||||||
|
// }
|
||||||
|
// complexData.metrics = arr;
|
||||||
|
|
||||||
|
// return complexData;
|
||||||
|
// }
|
||||||
|
|
||||||
async getComplexMetricsValues(inputData: K2Metrics, prevousData: K2Metrics, complexData: K2Metrics, complexCalc: ComplexMetricsCalculation[], scope: MetricsRanges[]): Promise<K2Metrics> {
|
async getComplexMetricsValues(inputData: K2Metrics, prevousData: K2Metrics, complexData: K2Metrics, complexCalc: ComplexMetricsCalculation[], scope: MetricsRanges[]): Promise<K2Metrics> {
|
||||||
let length: number = complexCalc.length;
|
let length: number = complexCalc.length;
|
||||||
let metrics: MetricK2[] = complexData.metrics;
|
let metrics: MetricK2[] = complexData.metrics;
|
||||||
|
|
@ -114,7 +127,7 @@ export class ZvksmetricsService {
|
||||||
for (let i = 0; i < length; i++) {
|
for (let i = 0; i < length; i++) {
|
||||||
let metr = {"source": ""};
|
let metr = {"source": ""};
|
||||||
let val = await this.setComplexMetricValue(complexCalc[i].values, complexCalc[i].formula, inputData.metrics, prevousData.metrics, devices[d], metr);
|
let val = await this.setComplexMetricValue(complexCalc[i].values, complexCalc[i].formula, inputData.metrics, prevousData.metrics, devices[d], metr);
|
||||||
let status = 3;
|
if(val){
|
||||||
let complexMetric = new MetricK2();
|
let complexMetric = new MetricK2();
|
||||||
complexMetric.id = complexCalc[i].id;
|
complexMetric.id = complexCalc[i].id;
|
||||||
complexMetric.name = complexCalc[i].name;
|
complexMetric.name = complexCalc[i].name;
|
||||||
|
|
@ -122,14 +135,15 @@ export class ZvksmetricsService {
|
||||||
complexMetric.addr = inputData.metrics[0].addr;
|
complexMetric.addr = inputData.metrics[0].addr;
|
||||||
complexMetric.value = val;
|
complexMetric.value = val;
|
||||||
complexMetric.description = complexCalc[i].name;
|
complexMetric.description = complexCalc[i].name;
|
||||||
complexMetric.status = status;
|
complexMetric.status = await this.showStatus(scope, complexMetric.name, val);
|
||||||
complexMetric.device = devices[d];
|
complexMetric.device = devices[d];
|
||||||
complexMetric.source = metr.source;
|
complexMetric.source = metr.source;
|
||||||
metrics.push(complexMetric);
|
metrics.push(complexMetric);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
console.log(complexData);
|
console.log(complexData.metrics);
|
||||||
|
|
||||||
return complexData;
|
return complexData;
|
||||||
}
|
}
|
||||||
|
|
@ -160,17 +174,17 @@ export class ZvksmetricsService {
|
||||||
|
|
||||||
async setMetricsStatus(metric: MetricK2, scope: MetricsRanges[]): Promise<number> {
|
async setMetricsStatus(metric: MetricK2, scope: MetricsRanges[]): Promise<number> {
|
||||||
if (metric && scope) {
|
if (metric && scope) {
|
||||||
return await this.showStatus(scope, metric.id, metric.value);
|
return await this.showStatus(scope, metric.name, metric.value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return 4;
|
return 5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async sendMetrics(inputData: K2Metrics): Promise<string> {
|
async sendMetrics(inputData: K2Metrics): Promise<string> {
|
||||||
let resp: any;
|
let resp: any;
|
||||||
let path: string = 'http://192.168.2.34:9050/update';
|
let path: string = 'http://192.168.2.34:9050/update';
|
||||||
let body: any = inputData;
|
let body: any = JSON.stringify(inputData);
|
||||||
let options: any = {
|
let options: any = {
|
||||||
headers: { 'Content-Type': 'application/json' }
|
headers: { 'Content-Type': 'application/json' }
|
||||||
};
|
};
|
||||||
|
|
@ -217,6 +231,20 @@ export class ZvksmetricsService {
|
||||||
return rangesData;
|
return rangesData;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async saveRanges(inputRanges: any): Promise<any> {
|
||||||
|
let ret: any;
|
||||||
|
let filePath = './src/zvksmetrics/conf/ranges123.json';
|
||||||
|
console.log(inputRanges);
|
||||||
|
try{
|
||||||
|
ret = await writeFile(filePath, inputRanges, 'utf8');
|
||||||
|
}
|
||||||
|
catch{
|
||||||
|
ret = "Error write file";
|
||||||
|
console.log(ret);
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
async setComplexMetrics(@Body() complexData: any = null): Promise<ComplexMetricsCalculation[]> {
|
async setComplexMetrics(@Body() complexData: any = null): Promise<ComplexMetricsCalculation[]> {
|
||||||
let url: string = 'http://192.168.2.39:9999/api/complex/5555';
|
let url: string = 'http://192.168.2.39:9999/api/complex/5555';
|
||||||
let options: any = {
|
let options: any = {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue