Page 2 of 2
Re: Nagios Subinstances 2
Posted: Mon Jul 21, 2014 1:20 am
by tariqondego
I mean the status of ATM,which the customer will want to see.This would require me to use NSCA at my nagios server for it to forward this information to customerhost.And NSCA takes input as text file.
How would I pull this information from my nagios server and give it to NSCA?
Re: Nagios Subinstances 2
Posted: Mon Jul 21, 2014 4:33 pm
by tmcdonald
I think I know what you mean now. Something like this will help query status info from the CLI in Core 4+:
Code: Select all
QUERY_STRING="host=all&servicestatustypes=28" REMOTE_USER="nagiosadmin" /usr/local/nagios/sbin/status-json.cgi
Reference page:
http://roshamboot.org/main/guide-nagios-statuscgi/
Then it is just a matter or parsing the JSON and calling send_nsca with the required values. You do not need to use a text file for send_nsca - standard input will work just fine.
Re: Nagios Subinstances 2
Posted: Wed Aug 20, 2014 8:25 am
by tariqondego
Thanks,atleast now we are on the same page.This information has helped alot.
So lets say i pass this to send_nsca.Wouldnt this be received as html on the command file of the recepient machine?
Assuming its written to the command file,would nagios be able to read this information correctly?
Please advise.
Re: Nagios Subinstances 2
Posted: Wed Aug 20, 2014 9:58 am
by tmcdonald
Not as HTML, but as JSON which is very easy to parse using just about any language, especially if there is a library or module for JSON. Running the command I posted will only display data, it does not write anything to the command file. Your script will need to parse the JSON and write it in the proper format to the command file.
Re: Nagios Subinstances 2
Posted: Fri Aug 29, 2014 7:38 am
by tariqondego
When I type the below command
Code: Select all
REQUEST_METHOD="GET" QUERY_STRING="host=NIC0002&servicestatustypes=2" REMOTE_USER="paynet" /usr/local/nagios/sbin/statusjson.cgi > test2
I suppose I should get OK services for Host NIC002.
Instead what i get is syntax of json format,see file attached.
Please advise.
Re: Nagios Subinstances 2
Posted: Tue Sep 02, 2014 3:30 pm
by abrist
Your syntax is incorrect, but really close. Try:
Code: Select all
REQUEST_METHOD="GET" QUERY_STRING="query=servicelist&details=true&hostname=NIC0002&servicestatus=critical" REMOTE_USER="paynet" /usr/local/nagios/sbin/statusjson.cgi
Note: I added "details=true", this is not necessary, but nice to have for verbosity while you are troubleshooting the query.
Re: Nagios Subinstances 2
Posted: Wed Sep 10, 2014 5:30 am
by tariqondego
Tried that,this is the output that i got:
Code: Select all
Cache-Control: no-store
Pragma: no-cache
Last-Modified: Wed, 10 Sep 2014 10:26:49 GMT
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-type: application/json; charset=utf-8
{
"format_version": 0,
"result": {
"query_time": 1410344809000,
"cgi": "statusjson.cgi",
"user": "paynet",
"query": "servicelist",
"query_status": "beta",
"program_start": 1410334154000,
"last_data_update": 1410344808000,
"type_code": 0,
"type_text": "Success",
"message": ""
},
"data": {
"selectors": {
"service_status": 16
},
"servicelist": {
}
}
}
Please advise.
Re: Nagios Subinstances 2
Posted: Thu Sep 11, 2014 5:14 pm
by abrist
Actually, I get that too. The query works fine from the jsonquery.html utility page, through ajax, and through curl:
Code: Select all
curl -k "http://<user>:<pass>@localhost/nagios/cgi-bin/statusjson.cgi?query=servicelist&hostname=<hostname>"
This could be a limitation of calling the cgi directly, or it could be an issue with specific queries as the following works correctly on my box:
Code: Select all
REQUEST_METHOD="GET" QUERY_STRING="query=host&hostname=<hostname>" REMOTE_USER="nagiosamdin" /usr/local/nagios/sbin/statusjson.cgi