Open NubeDev opened 11 months ago
let groups = RQL.GetAllHostsStatus();
let hostList = [];
for (let group of groups) {
for (let host of group.Hosts) {
let newHost = {};
newHost["name"] = host.Name;
newHost["uuid"] = host.UUID;
newHost["failCount"] = host.PingFailCount;
hostList.push(newHost);
}
}
let alertsAdded = {
count: 0,
};
let alertCount = 0;
for (let host of hostList) {
if (host.failCount >= 0) {
let body = {
hostUUID: host.uuid,
entityType: "gateway",
type: "ping",
status: "active",
severity: "crucial",
body: `host-name: ${host.name} fail count: ${host.failCount}`,
};
let newAlert = RQL.AddAlert(host.uuid, body);
alertsAdded.count = alertCount = alertCount + 1;
if (newAlert != null) {
if (newAlert.UUID == null) {
alertsAdded.body = body;
alertsAdded.error = newAlert.toString();
} else {
alertsAdded.result = newAlert;
}
}
}
}
if (alertsAdded.count >= 1) {
// RQL.Email();
}
RQL.Return = alertsAdded;