Dockerfile added
parent
d8e5c9af6a
commit
7dfb9fa4a2
|
|
@ -0,0 +1,16 @@
|
||||||
|
FROM node:20
|
||||||
|
|
||||||
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
|
COPY package*.json ./
|
||||||
|
|
||||||
|
RUN npm install
|
||||||
|
|
||||||
|
COPY . .
|
||||||
|
|
||||||
|
RUN npm run build
|
||||||
|
|
||||||
|
EXPOSE 9999
|
||||||
|
|
||||||
|
CMD ["npm", "run", "start:dev"]
|
||||||
|
|
||||||
|
|
@ -1,20 +1,260 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "CPU usage",
|
"id": "10001",
|
||||||
"values": "{\"arr\":[191, 192, 193]}",
|
"name": "cpu_utilization",
|
||||||
"formula": "arr[1]+arr[2]+arr[3]"
|
"values": {"arr":["cpurawidle", "cpurawuser", "cpurawnice", "cpurawsystem", "cpurawwait", "cpurawinterrupt"],"prevarr":["cpurawidle", "cpurawuser", "cpurawnice", "cpurawsystem", "cpurawwait", "cpurawinterrupt"]},
|
||||||
|
"formula": "((arr[2]-prevarr[2])+(arr[3]-prevarr[3])+(arr[4]-prevarr[4])+(arr[6]-prevarr[6]))/((arr[1]-prevarr[1])+(arr[2]-prevarr[2])+(arr[3]-prevarr[3])+(arr[4]-prevarr[4])+(arr[5]-prevarr[5])+(arr[6]-prevarr[6]))*100"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "RAM usage",
|
"id": "10002",
|
||||||
"values": "{\"arr\":[191, 192, 193]}",
|
"name": "cpu_load_average_1",
|
||||||
"formula": "arr[1]+arr[2]+arr[3]"
|
"values": {"arr":["cpu1min"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Hard disks usage",
|
"id": "10003",
|
||||||
"values": "{\"arr\":[191, 192, 193]}",
|
"name": "cpu_load_average_5",
|
||||||
"formula": "arr[1]+arr[2]+arr[3]"
|
"values": {"arr":["cpu5min"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10004",
|
||||||
|
"name": "cpu_load_average_15",
|
||||||
|
"values": {"arr":["cpu15min"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10005",
|
||||||
|
"name": "ram_usage",
|
||||||
|
"values": {"arr":["totalMemory", "totalMemoryAvail"]},
|
||||||
|
"formula": "(arr[1]-arr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10006",
|
||||||
|
"name": "disk_usage",
|
||||||
|
"values": {"arr":["totalDiskSize", "useDiskSize"]},
|
||||||
|
"formula": "(arr[1]-arr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10007",
|
||||||
|
"name": "disk_read_rate",
|
||||||
|
"values": {"arr":["diskReadAccess"], "prevarr":["diskReadAccess"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10008",
|
||||||
|
"name": "disk_write_rate",
|
||||||
|
"values": {"arr":["diskWriteAccess"], "prevarr":["diskWriteAccess"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10009",
|
||||||
|
"name": "network_interface_rx_Eth_1",
|
||||||
|
"values": {"arr":["speed1", "ifInOctets1"], "prevarr":["speed1", "ifInOctets1"]},
|
||||||
|
"formula": "(arr[2]-prevarr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10010",
|
||||||
|
"name": "network_interface_tx_Eth_1",
|
||||||
|
"values": {"arr":["speed1", "ifOutOctets1"], "prevarr":["speed1", "ifOutOctets1"]},
|
||||||
|
"formula": "(arr[2]-prevarr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10011",
|
||||||
|
"name": "network_interface_rx_Eth_2",
|
||||||
|
"values": {"arr":["speed2", "ifInOctets2"], "prevarr":["speed2", "ifInOctets2"]},
|
||||||
|
"formula": "(arr[2]-prevarr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10012",
|
||||||
|
"name": "network_interface_tx_Eth_2",
|
||||||
|
"values": {"arr":["speed2", "ifOutOctets2"], "prevarr":["speed2", "ifOutOctets2"]},
|
||||||
|
"formula": "(arr[2]-prevarr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10013",
|
||||||
|
"name": "network_interface_rx_Eth_3",
|
||||||
|
"values": {"arr":["speed3", "ifInOctets3"], "prevarr":["speed3", "ifInOctets3"]},
|
||||||
|
"formula": "(arr[2]-prevarr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10014",
|
||||||
|
"name": "network_interface_tx_Eth_3",
|
||||||
|
"values": {"arr":["speed3", "ifOutOctets3"], "prevarr":["speed3", "ifOutOctets3"]},
|
||||||
|
"formula": "(arr[2]-prevarr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10015",
|
||||||
|
"name": "network_interface_rx_Eth_4",
|
||||||
|
"values": {"arr":["speed4", "ifInOctets4"], "prevarr":["speed4", "ifInOctets4"]},
|
||||||
|
"formula": "(arr[2]-prevarr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10016",
|
||||||
|
"name": "network_interface_tx_Eth_4",
|
||||||
|
"values": {"arr":["speed4", "ifOutOctets4"], "prevarr":["speed4", "ifOutOctets4"]},
|
||||||
|
"formula": "(arr[2]-prevarr[2])/arr[1]*100"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10017",
|
||||||
|
"name": "network_interfaces_read_packets_errors_Eth_1",
|
||||||
|
"values": {"arr":["ifInErrors1"], "prevarr":["ifInErrors1"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10018",
|
||||||
|
"name": "network_interfaces_write_packets_errors_Eth_1",
|
||||||
|
"values": {"arr":["ifOutErrors1"], "prevarr":["ifOutErrors1"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10019",
|
||||||
|
"name": "network_interfaces_read_packets_errors_Eth_2",
|
||||||
|
"values": {"arr":["ifInErrors2"], "prevarr":["ifInErrors2"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10020",
|
||||||
|
"name": "network_interfaces_write_packets_errors_Eth_2",
|
||||||
|
"values": {"arr":["ifOutErrors2"], "prevarr":["ifOutErrors2"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10021",
|
||||||
|
"name": "network_interfaces_read_packets_errors_Eth_3",
|
||||||
|
"values": {"arr":["ifInErrors3"], "prevarr":["ifInErrors3"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10022",
|
||||||
|
"name": "network_interfaces_write_packets_errors_Eth_3",
|
||||||
|
"values": {"arr":["ifOutErrors3"], "prevarr":["ifOutErrors3"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10023",
|
||||||
|
"name": "network_interfaces_read_packets_errors_Eth_4",
|
||||||
|
"values": {"arr":["ifInErrors4"], "prevarr":["ifInErrors4"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10024",
|
||||||
|
"name": "network_interfaces_write_packets_errors_Eth_4",
|
||||||
|
"values": {"arr":["ifOutErrors4"], "prevarr":["ifOutErrors4"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10025",
|
||||||
|
"name": "network_interfaces_read_packets_discarded_Eth_1",
|
||||||
|
"values": {"arr":["ifInDiscard1"], "prevarr":["ifInDiscard1"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10026",
|
||||||
|
"name": "network_interfaces_write_packets_discarded_Eth_1",
|
||||||
|
"values": {"arr":["ifOutDiscard1"], "prevarr":["ifOutDiscard1"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10027",
|
||||||
|
"name": "network_interfaces_read_packets_discarded_Eth_2",
|
||||||
|
"values": {"arr":["ifInDiscard2"], "prevarr":["ifInDiscard2"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10028",
|
||||||
|
"name": "network_interfaces_write_packets_discarded_Eth_2",
|
||||||
|
"values": {"arr":["ifOutDiscard2"], "prevarr":["ifOutDiscard2"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10029",
|
||||||
|
"name": "network_interfaces_read_packets_discarded_Eth_3",
|
||||||
|
"values": {"arr":["ifInDiscard3"], "prevarr":["ifInDiscard3"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10030",
|
||||||
|
"name": "network_interfaces_write_packets_discarded_Eth_3",
|
||||||
|
"values": {"arr":["ifOutDiscard3"], "prevarr":["ifOutDiscard3"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10031",
|
||||||
|
"name": "network_interfaces_read_packets_discarded_Eth_4",
|
||||||
|
"values": {"arr":["ifInDiscard4"], "prevarr":["ifInDiscard4"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10032",
|
||||||
|
"name": "network_interfaces_write_packets_discarded_Eth_4",
|
||||||
|
"values": {"arr":["ifOutDiscard4"], "prevarr":["ifOutDiscard4"]},
|
||||||
|
"formula": "(arr[1]-prevarr[1])"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10033",
|
||||||
|
"name": "response_icmp",
|
||||||
|
"values": {"arr":["ping_check"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10034",
|
||||||
|
"name": "server_uptime",
|
||||||
|
"values": {"arr":["upTime"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10035",
|
||||||
|
"name": "total_participants",
|
||||||
|
"values": {"arr":["TotalParticipants"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10036",
|
||||||
|
"name": "registered_abonents",
|
||||||
|
"values": {"arr":["RegisteredAbonents"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10037",
|
||||||
|
"name": "webcasts_HLS_clients",
|
||||||
|
"values": {"arr":["WebcastsHLSclients"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10038",
|
||||||
|
"name": "total_P2P_rooms",
|
||||||
|
"values": {"arr":["TotalP2Prooms"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10039",
|
||||||
|
"name": "conferences_total",
|
||||||
|
"values": {"arr":["Conferencestotal"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10040",
|
||||||
|
"name": "conferences_active",
|
||||||
|
"values": {"arr":["ConferencesActive"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10041",
|
||||||
|
"name": "records_active",
|
||||||
|
"values": {"arr":["RecordsActive"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10042",
|
||||||
|
"name": "number_of_records_saved",
|
||||||
|
"values": {"arr":["NumberRecordsSaved"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id": "10043",
|
||||||
|
"name": "replication_status",
|
||||||
|
"values": {"arr":["replicationStatus"]},
|
||||||
|
"formula": "arr[1]"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
]
|
]
|
||||||
|
|
@ -1,20 +1,385 @@
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
"name": "measure_190", "_comment":"Загрузка процессора за 1 минуту",
|
"name": "cpu_utilization",
|
||||||
"ranges": [
|
"ranges": [
|
||||||
{"min": 0, "max": 0, "status": 3},
|
{"min": 0, "max": 60, "status": 1},
|
||||||
{"min": 0, "max": 0.1, "status": 0},
|
{"min": 61, "max": 80, "status": 2},
|
||||||
{"min": 0.11, "max": 0.12, "status": 1},
|
{"min": 81, "max": 90, "status": 3},
|
||||||
{"min": 0.13, "max": 1, "status": 2},
|
{"min": 91, "max": 100, "status": 4}
|
||||||
{"min": 0.5, "max": 0.8, "status": 1}
|
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "measure_191", "_comment":"Загрузка процессора за 5 минут",
|
"name": "cpu_load_average_1",
|
||||||
"ranges": [
|
"ranges": [
|
||||||
{"min": 0, "max": 0.2, "status": 0},
|
{"min": 0, "max": 60, "status": 1},
|
||||||
{"min": 0.21, "max": 0.32, "status": 1},
|
{"min": 61, "max": 80, "status": 2},
|
||||||
{"min": 0.33, "max": 1, "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": 60, "status": 1},
|
||||||
|
{"min": 61, "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}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
|
|
@ -1,26 +1,26 @@
|
||||||
import { Body, ConfigurableModuleBuilder, Controller, Get, Options, Param, ParseIntPipe, Post} from '@nestjs/common';
|
import { Body, ConfigurableModuleBuilder, Controller, Get, Options, Param, ParseIntPipe, Post } from '@nestjs/common';
|
||||||
import { ZvksmetricsService } from './zvksmetrics.service';
|
import { ZvksmetricsService } from './zvksmetrics.service';
|
||||||
|
|
||||||
@Controller('api')
|
@Controller('api')
|
||||||
export class ZvksmetricsController {
|
export class ZvksmetricsController {
|
||||||
constructor(private readonly metricsService: ZvksmetricsService) {}
|
constructor(private readonly metricsService: ZvksmetricsService) { }
|
||||||
|
|
||||||
@Get('ranges')
|
@Get('ranges')
|
||||||
async getHello(): Promise<any> {
|
async getHello(): Promise<any> {
|
||||||
let a: number = 7;
|
let a: number = 7;
|
||||||
let b: number = 9;
|
let b: number = 9;
|
||||||
let sum: any = {value: (a+b)/4*b+a};
|
let sum: any = { value: (a + b) / 4 * b + a };
|
||||||
|
await this.metricsService.useStatusModel(1);
|
||||||
// let a = await this.metricsService.showStatus();
|
// let a = await this.metricsService.showStatus();
|
||||||
console.log(sum.value);
|
// console.log(sum.value);
|
||||||
return sum.value;
|
return sum.value;
|
||||||
}
|
}
|
||||||
|
|
||||||
//Заглушка для будующей API под граничные значения
|
//Заглушка для будующей API под граничные значения
|
||||||
@Options('ranges/:code')
|
@Options('ranges/:code')
|
||||||
async showRanges (@Param('code', ParseIntPipe) code: number): Promise<JSON>{
|
async showRanges(@Param('code', ParseIntPipe) code: number): Promise<JSON> {
|
||||||
let ret : JSON = JSON.parse('{"result":"null"}');
|
let ret: JSON = JSON.parse('{"result":"null"}');
|
||||||
if(code === 9999){
|
if (code === 9999) {
|
||||||
return await this.metricsService.showRangesOptions('File Name');
|
return await this.metricsService.showRangesOptions('File Name');
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
|
@ -28,17 +28,19 @@ export class ZvksmetricsController {
|
||||||
|
|
||||||
//Заглушка для будующей 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> {
|
||||||
let ret : JSON = JSON.parse('{"result":"null"}');
|
let ret: JSON = JSON.parse('{"result":"null"}');
|
||||||
if(code === 5555){
|
if (code === 5555) {
|
||||||
return await this.metricsService.showComplexMetricsConfig('File Name');
|
return await this.metricsService.showComplexMetricsConfig('File Name');
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Post('input')
|
@Post('input')
|
||||||
async getPostMessage (@Body() inputMetrics : any) : Promise<string> {
|
async getPostMessage(@Body() inputMetrics: any): Promise<string> {
|
||||||
//console.log(inputMetrics);
|
// console.log(inputMetrics);
|
||||||
|
// console.log(23+12);
|
||||||
|
console.log(inputMetrics);
|
||||||
let out: any = await this.metricsService.useStatusModel(inputMetrics);
|
let out: any = await this.metricsService.useStatusModel(inputMetrics);
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -3,24 +3,27 @@ import axios, { Axios, AxiosResponse } from 'axios';
|
||||||
import { readFile } from 'node:fs/promises';
|
import { readFile } 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 } from 'mathjs'
|
import math, { create, all, evaluate, number, random, complex, string } from 'mathjs'
|
||||||
|
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MetricK2 {
|
export class MetricK2 {
|
||||||
id : string;
|
id: string;
|
||||||
type : string;
|
name: string;
|
||||||
addr : string;
|
type: string;
|
||||||
value : number;
|
addr: string;
|
||||||
|
value: number;
|
||||||
description: string;
|
description: string;
|
||||||
status: number;
|
status: number;
|
||||||
|
device: number;
|
||||||
|
source: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class K2Metrics {
|
export class K2Metrics {
|
||||||
service_name: string;
|
service_name: string;
|
||||||
endpoint_name: string;
|
//endpoint_name: string;
|
||||||
metrics: MetricK2 [];
|
metrics: MetricK2[];
|
||||||
};
|
};
|
||||||
|
|
||||||
@Injectable()
|
@Injectable()
|
||||||
|
|
@ -33,21 +36,57 @@ export class RangeValues {
|
||||||
@Injectable()
|
@Injectable()
|
||||||
export class MetricsRanges {
|
export class MetricsRanges {
|
||||||
name: string;
|
name: string;
|
||||||
ranges: RangeValues [];
|
ranges: RangeValues[];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class ComplexMetricsCalculation {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
values: string;
|
||||||
|
formula: string;
|
||||||
|
};
|
||||||
|
|
||||||
|
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> {
|
||||||
let inp : K2Metrics = new K2Metrics();
|
let inp: K2Metrics = new K2Metrics();
|
||||||
inp = inputData;
|
inp = inputData;
|
||||||
|
|
||||||
let scope : MetricsRanges [] = [];
|
let complex: K2Metrics = new K2Metrics();
|
||||||
scope = await this.setMetricsRanges ();
|
complex.service_name = inputData.service_name;
|
||||||
|
complex.metrics = [];
|
||||||
|
|
||||||
|
let model: ComplexMetricsCalculation[] = [];
|
||||||
|
model = await this.setComplexMetrics();
|
||||||
|
|
||||||
|
let scope: MetricsRanges[] = [];
|
||||||
|
scope = await this.setMetricsRanges();
|
||||||
|
|
||||||
|
if (!prev) {
|
||||||
|
prev = inp;
|
||||||
|
}
|
||||||
|
// console.log(prev);
|
||||||
|
|
||||||
|
let intermediate = await this.getComplexMetricsValues(inp, prev, complex, model, scope);
|
||||||
|
console.log(inp);
|
||||||
|
|
||||||
|
// console.log(inp.metrics[20], complex.metrics[2]);
|
||||||
|
|
||||||
|
const val = JSON.parse(JSON.stringify(model[0].values));
|
||||||
|
// console.log(val.arr[1]);
|
||||||
|
// console.log(val);
|
||||||
|
|
||||||
|
// const reif = JSON.parse(comlexCalc[1].values);
|
||||||
|
// console.log(reif);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// console.log(inp);
|
||||||
// let rng: any = {val: [{x:3}, {x:4}, {x:5}, {x:9}]};
|
// let rng: any = {val: [{x:3}, {x:4}, {x:5}, {x:9}]};
|
||||||
// console.log(rng.val[0].x);
|
// console.log(rng.val[0].x);
|
||||||
// let testFormula: string = (rng.val[0].x + rng.val[1].x - rng.val[2].x + rng.val[3].x).toString();
|
// let testFormula: string = (rng.val[0].x + rng.val[1].x - rng.val[2].x + rng.val[3].x).toString();
|
||||||
|
|
@ -58,23 +97,30 @@ export class ZvksmetricsService {
|
||||||
|
|
||||||
// console.log(JSON.stringify("arr:[191, 192, 193]"));
|
// console.log(JSON.stringify("arr:[191, 192, 193]"));
|
||||||
|
|
||||||
// let x: any = {arr:[191, 192, 193], sum: 'arr[1]+arr[2]+arr[3]'};
|
let x: any = { arr: ["191", "192", "193"], prev: ["1", "1"], abb: ["1", "34"] };
|
||||||
// let x: any = JSON.parse(scope[0].ranges[0].values);
|
//let k = JSON.parse(scope[0].ranges[0].values); //
|
||||||
// let y: string = scope[0].ranges[0].formula;
|
//let y: string = scope[0].ranges[0].formula;
|
||||||
|
let y = "arr[1]/prev[1]*abb[1]+arr[2]*prev[2]+arr[3]+prev[1]/prev[2]";
|
||||||
// console.log(y, x);
|
// console.log(y, x);
|
||||||
// console.log(evaluate(y, x));
|
// console.log(evaluate(y, x));
|
||||||
|
|
||||||
let editedMetrics : K2Metrics = await this.getMetrics (inp, scope);
|
// let editedMetrics : K2Metrics = await this.getMetrics (inp, comlexCalc, scope);
|
||||||
let responseFromExporter : any = await this.sendMetrics (editedMetrics);
|
let responseFromExporter: any = await this.sendMetrics(intermediate);
|
||||||
|
let responseFromExporter1: any = await this.sendMetrics(inp);
|
||||||
|
|
||||||
|
// console.log(inp.metrics[200].device);
|
||||||
|
|
||||||
|
prev = inp;
|
||||||
|
|
||||||
return responseFromExporter;
|
return responseFromExporter;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async getMetrics(inputData : K2Metrics, scope: MetricsRanges []): Promise<K2Metrics> {
|
async getMetrics(inputData: K2Metrics, comlexCalc: ComplexMetricsCalculation[], scope: MetricsRanges[]): Promise<K2Metrics> {
|
||||||
let arr : MetricK2 [] = inputData.metrics;
|
let arr: MetricK2[] = inputData.metrics;
|
||||||
let length : number = arr.length;
|
let length: number = arr.length;
|
||||||
|
|
||||||
for(let i=0; i<length; i++){
|
for (let i = 0; i < length; i++) {
|
||||||
arr[i].status = await this.setMetricsStatus(arr[i], scope);
|
arr[i].status = await this.setMetricsStatus(arr[i], scope);
|
||||||
}
|
}
|
||||||
inputData.metrics = arr;
|
inputData.metrics = arr;
|
||||||
|
|
@ -82,8 +128,57 @@ export class ZvksmetricsService {
|
||||||
return inputData;
|
return inputData;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMetricsStatus( metric : MetricK2, scope: MetricsRanges []) : Promise<number> {
|
async getComplexMetricsValues(inputData: K2Metrics, prevousData: K2Metrics, complexData: K2Metrics, complexCalc: ComplexMetricsCalculation[], scope: MetricsRanges[]): Promise<K2Metrics> {
|
||||||
if (metric && scope){
|
let length: number = complexCalc.length;
|
||||||
|
let metrics: MetricK2[] = complexData.metrics;
|
||||||
|
|
||||||
|
// let val = await this.setComplexMetricValue(complexCalc[0].values, complexCalc[0].formula, inputData.metrics, prevousData.metrics);
|
||||||
|
// let status = 3;
|
||||||
|
|
||||||
|
for (let i = 0; i < length; i++) {
|
||||||
|
let val = await this.setComplexMetricValue(complexCalc[i].values, complexCalc[i].formula, inputData.metrics, prevousData.metrics);
|
||||||
|
let status = 3;
|
||||||
|
let complexMetric = new MetricK2();
|
||||||
|
complexMetric.id = complexCalc[i].id;
|
||||||
|
complexMetric.name = complexCalc[i].name;
|
||||||
|
complexMetric.type = inputData.metrics[0].type;
|
||||||
|
complexMetric.addr = inputData.metrics[0].addr;
|
||||||
|
complexMetric.value = val;
|
||||||
|
complexMetric.description = complexCalc[i].name;
|
||||||
|
complexMetric.status = status;
|
||||||
|
// complexMetric.device = number(inputData.metrics.find(el => el.name == complexMetric.name)?.device);
|
||||||
|
// complexMetric.device = inputData.metrics[0].device;
|
||||||
|
// complexMetric.source = string(inputData.metrics.find(elem => elem.name == complexMetric.name)?.source);
|
||||||
|
metrics.push(complexMetric);
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log(complexData);
|
||||||
|
|
||||||
|
return complexData;
|
||||||
|
}
|
||||||
|
|
||||||
|
async setComplexMetricValue(value: string, formula: string, currMetrics: MetricK2[], prevMetrics: MetricK2[]): Promise<number> {
|
||||||
|
const val = JSON.parse(JSON.stringify(value));
|
||||||
|
let arr = val.arr;
|
||||||
|
let arr_len: number = arr.length;
|
||||||
|
for (let i = 0; i < arr_len; i++) {
|
||||||
|
arr[i] = currMetrics.find(element => element.name == arr[i])?.value;
|
||||||
|
}
|
||||||
|
let prevarr = val.prevarr;
|
||||||
|
if (prevarr) {
|
||||||
|
let prevarr_len: number = prevarr.length;
|
||||||
|
for (let i = 0; i < prevarr_len; i++) {
|
||||||
|
prevarr[i] = prevMetrics.find(element => element.name == prevarr[i])?.value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// console.log(val);
|
||||||
|
let result: number = evaluate(formula, val);
|
||||||
|
// console.log(result);
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
async setMetricsStatus(metric: MetricK2, scope: MetricsRanges[]): Promise<number> {
|
||||||
|
if (metric && scope) {
|
||||||
return await this.showStatus(scope, metric.id, metric.value);
|
return await this.showStatus(scope, metric.id, metric.value);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -91,58 +186,73 @@ export class ZvksmetricsService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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:9049/update';
|
let path: string = 'http://192.168.2.34:9050/update';
|
||||||
let body : any = inputData;
|
let body: any = inputData;
|
||||||
let options : any = {
|
let options: any = {
|
||||||
headers: {'Content-Type' : 'application/json'}
|
headers: { 'Content-Type': 'application/json' }
|
||||||
};
|
};
|
||||||
|
|
||||||
await axios.post(path, body, options).then((response)=>{
|
await axios.post(path, body, options).then((response) => {
|
||||||
resp = response.status + ' ' + response.data;
|
resp = response.status + ' ' + response.data;
|
||||||
// console.log(resp);
|
// console.log(resp);
|
||||||
}).catch((error)=>{
|
}).catch((error) => {
|
||||||
resp = error;
|
resp = error;
|
||||||
});
|
});
|
||||||
|
|
||||||
return resp;
|
return resp;
|
||||||
}
|
}
|
||||||
|
|
||||||
async showStatus(scope: MetricsRanges [], metricName: string, metricValue: number) : Promise<number> {
|
async showStatus(scope: MetricsRanges[], metricName: string, metricValue: number): Promise<number> {
|
||||||
let status : number = 0;
|
let status: number = 0;
|
||||||
let test : any = scope.find(element => element.name == metricName);
|
let test: any = scope.find(element => element.name == metricName);
|
||||||
if (test){
|
if (test) {
|
||||||
let range : MetricsRanges = test;
|
let range: MetricsRanges = test;
|
||||||
let transit : any = range.ranges.find(element => element.min <= metricValue && metricValue <= element.max)?.status;
|
let transit: any = range.ranges.find(element => element.min <= metricValue && metricValue <= element.max)?.status;
|
||||||
if(transit){
|
if (transit) {
|
||||||
status = transit;
|
status = transit;
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
return 4;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
async setMetricsRanges (@Body() rangesData : any = null) : Promise<MetricsRanges []> {
|
async setMetricsRanges(@Body() rangesData: any = null): Promise<MetricsRanges[]> {
|
||||||
let url : string = 'http://192.168.2.39:9999/api/ranges/9999';
|
let url: string = 'http://192.168.2.39:9999/api/ranges/9999';
|
||||||
let options : any = {
|
let options: any = {
|
||||||
headers: {'Content-Type' : 'application/json'}
|
headers: { 'Content-Type': 'application/json' }
|
||||||
};
|
};
|
||||||
|
|
||||||
await axios.options(url, options).then((response) => {
|
await axios.options(url, options).then((response) => {
|
||||||
rangesData = response.data;
|
rangesData = response.data;
|
||||||
}).catch((error)=>{
|
}).catch((error) => {
|
||||||
rangesData = error;
|
rangesData = error;
|
||||||
});
|
});
|
||||||
|
// console.log(rangesData);
|
||||||
return rangesData;
|
return rangesData;
|
||||||
}
|
}
|
||||||
|
|
||||||
async showRangesOptions(filePath: string) : Promise<JSON> {
|
async setComplexMetrics(@Body() complexData: any = null): Promise<ComplexMetricsCalculation[]> {
|
||||||
let content : JSON = JSON.parse('{"name":"name"}');
|
let url: string = 'http://192.168.2.39:9999/api/complex/5555';
|
||||||
|
let options: any = {
|
||||||
|
headers: { 'Content-Type': 'application/json' }
|
||||||
|
};
|
||||||
|
|
||||||
|
await axios.options(url, options).then((response) => {
|
||||||
|
complexData = response.data;
|
||||||
|
}).catch((error) => {
|
||||||
|
complexData = error;
|
||||||
|
});
|
||||||
|
// console.log(rangesData);
|
||||||
|
return complexData;
|
||||||
|
}
|
||||||
|
|
||||||
|
async showRangesOptions(filePath: string): Promise<JSON> {
|
||||||
|
let content: JSON = JSON.parse('{"name":"name"}');
|
||||||
filePath = './src/zvksmetrics/conf/ranges.json';
|
filePath = './src/zvksmetrics/conf/ranges.json';
|
||||||
try {
|
try {
|
||||||
content = JSON.parse(await readFile(filePath, { encoding: 'utf8' }));
|
content = JSON.parse(await readFile(filePath, { encoding: 'utf8' }));
|
||||||
|
|
@ -154,8 +264,8 @@ export class ZvksmetricsService {
|
||||||
return content;
|
return content;
|
||||||
}
|
}
|
||||||
|
|
||||||
async showComplexMetricsConfig(filePath: string) : Promise<JSON> {
|
async showComplexMetricsConfig(filePath: string): Promise<JSON> {
|
||||||
let content : JSON = JSON.parse('{"name":"name"}');
|
let content: JSON = JSON.parse('{"name":"name"}');
|
||||||
filePath = './src/zvksmetrics/conf/complex.json';
|
filePath = './src/zvksmetrics/conf/complex.json';
|
||||||
try {
|
try {
|
||||||
content = JSON.parse(await readFile(filePath, { encoding: 'utf8' }));
|
content = JSON.parse(await readFile(filePath, { encoding: 'utf8' }));
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue