forked from khoi01/NodejsRequestExample
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.js
More file actions
36 lines (27 loc) · 783 Bytes
/
app.js
File metadata and controls
36 lines (27 loc) · 783 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
const request = require('request')
var username = "nagiosadmin";
var password = "1234";
var options = {
url: "http://192.168.1.111/nagios/cgi-bin/statusjson.cgi?query=hostcount&parenthost=none&childhost=none&hostgroup=linux-servers",
auth: {
user: username,
password: password
}
}
setInterval(() => {
//method get called
GetData()
}, 5000);
function GetData(){
request(options, function (err, res, body) {
if (err) {
console.dir(err)
return
}
if (!err && res.statusCode == 200) {
var data = JSON.parse(body);
//display data
console.log(data.result.user)
}
})
}