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?
Nagios Subinstances 2
Re: Nagios Subinstances 2
I think I know what you mean now. Something like this will help query status info from the CLI in Core 4+:
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.
Code: Select all
QUERY_STRING="host=all&servicestatustypes=28" REMOTE_USER="nagiosadmin" /usr/local/nagios/sbin/status-json.cgi
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.
Former Nagios employee
-
- Posts: 85
- Joined: Fri Mar 28, 2014 6:18 am
Re: Nagios Subinstances 2
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.
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
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.
Former Nagios employee
-
- Posts: 85
- Joined: Fri Mar 28, 2014 6:18 am
Re: Nagios Subinstances 2
When I type the below command
I suppose I should get OK services for Host NIC002.
Instead what i get is syntax of json format,see file attached.
Please advise.
Code: Select all
REQUEST_METHOD="GET" QUERY_STRING="host=NIC0002&servicestatustypes=2" REMOTE_USER="paynet" /usr/local/nagios/sbin/statusjson.cgi > test2
Instead what i get is syntax of json format,see file attached.
Please advise.
- Attachments
-
- statusjson.docx
- (30.07 KiB) Downloaded 137 times
Re: Nagios Subinstances 2
Your syntax is incorrect, but really close. Try:
Note: I added "details=true", this is not necessary, but nice to have for verbosity while you are troubleshooting the query.
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
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
-
- Posts: 85
- Joined: Fri Mar 28, 2014 6:18 am
Re: Nagios Subinstances 2
Tried that,this is the output that i got:
Please advise.
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": {
}
}
}
Re: Nagios Subinstances 2
Actually, I get that too. The query works fine from the jsonquery.html utility page, through ajax, and through curl:
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
curl -k "http://<user>:<pass>@localhost/nagios/cgi-bin/statusjson.cgi?query=servicelist&hostname=<hostname>"
Code: Select all
REQUEST_METHOD="GET" QUERY_STRING="query=host&hostname=<hostname>" REMOTE_USER="nagiosamdin" /usr/local/nagios/sbin/statusjson.cgi
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.