Hello,
is it possible to count the devices over the API?
In a similar way that the circle diagram on the Overview Page of Genieacs work.
Unfortunately, I could not find an API function for that.
I would need this, to trigger events when some numbers hit a special value. E.g. Informs in Last 5 Minutes goes below x will trigger an alarm.
found a solution, when data is requested with the HTTP method HEAD, it will return an empty list and in the headers the header total with the number of devices. If it is 0, the header will not be added.
This would be a bug but I was not able to reproduce. Do you have the API sitting behind a proxy that might be stripping out the header?
I was able to find the query where I had this result. My query was encoded the wrong way or malformed. There where now proxy between the acs and my client.
That is the snipped that I use now:
var options = { method: 'HEAD', host: acsURL.hostname, port: acsURL.port, path: '/' };
let checkDate = new Date(Date.now() - 300020);
console.log(checkDate.toISOString())
let query = {
"_lastInform": {
"$gt": checkDate.toISOString()
}
};
var q = querystring.escape(JSON.stringify(query));
console.log(q);
var reqACS = http.request(Object.assign(options, {
path: "/devices/?query=" + q
}), function(erg) {
console.log(erg.headers);
let statusCode = 201;
let message = "ERROR, Number out of range"
if (erg.headers['total']) {
let c = parseInt(erg.headers['total'], 10);
if (c > 200 && c < 1000) {
statusCode = 200;
message = "OK " + c;
}
}
res.status(statusCode);
res.send(message);
});
reqACS.end();
This snipped is working. The snipped is used with a monitoring solution to trigger an alarm if to many or not enough devices inform within 5 minutes.
If that happens, ether the ACS server is down or other key components in our network.