nagios cgi-bin

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
gad314
Posts: 6
Joined: Wed Jul 17, 2019 4:02 pm

nagios cgi-bin

Post by gad314 »

Hello,

I was trying to access nagios cgi-bin throw https://nagios-ip/nagios/cgi-bin/statusjson.cgi?
by providing credentials, sometimes it works others doesn't work.
it's weird .
can anyone help?
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: nagios cgi-bin

Post by benjaminsmith »

Hello,

If you're using Nagios XI, I would recommend using the Backend API. Go to Help > API Docs for documentation.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.

Be sure to check out our Knowledgebase for helpful articles and solutions!
gad314
Posts: 6
Joined: Wed Jul 17, 2019 4:02 pm

Re: nagios cgi-bin

Post by gad314 »

Thanks Benjamin for your reply.

So how can I get a list of down host in a specific host_group using API. this is the main point.

this is what I was using (but it's not reliable way, as you said it's better using API)

curl -u nagiosadm:$(cat /path-to-password) "http://nagios_IP/nagios/cgi-bin/statusjson.cgi?query=hostlist&formatoptions=duration&details=true&hostgroup=specific_host_group&hoststatus=down"
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: nagios cgi-bin

Post by scottwilkerson »

You can get them from the XI API
Help -> Objects Reference -> objects/hostgroupmembers

The call would look something like this

Code: Select all

http://xxx.xxx.xxx.xxx/nagiosxi/api/v1/objects/hostgroupmembers?apikey=APIKEY&pretty=1&hostgroup_name=HOSTGROUP
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
gad314
Posts: 6
Joined: Wed Jul 17, 2019 4:02 pm

Re: nagios cgi-bin

Post by gad314 »

Thanks scott,

but this will give me all hostgroup members.

I only need the host in down state only in that hostgroup.

Thanks and regards.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: nagios cgi-bin

Post by scottwilkerson »

You would then need to make another call to objects/hoststatus with something like the following extracting the host names from the previous call

Code: Select all

http://xxx.xxx.xxx.xxx/nagiosxi/api/v1/objects/hoststatus?apikey=APIKEY&pretty=1&current_state=nin:0&name=in:HOST1,HOST2,HOST3

current_state=nin:0 means NOT 0 (not UP)

name=in:HOST1,HOST2,HOST3 means only show the hosts in the comma separated list
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
gad314
Posts: 6
Joined: Wed Jul 17, 2019 4:02 pm

Re: nagios cgi-bin

Post by gad314 »

Thanks very much Scott for those valuable info.

but how could we gather the two conditions. I still need host list in specific host_group and their status is down.

Regards.
scottwilkerson
DevOps Engineer
Posts: 19396
Joined: Tue Nov 15, 2011 3:11 pm
Location: Nagios Enterprises
Contact:

Re: nagios cgi-bin

Post by scottwilkerson »

gad314 wrote:Thanks very much Scott for those valuable info.

but how could we gather the two conditions. I still need host list in specific host_group and their status is down.

Regards.
You would need to make a call to the objects/hostgroupmembers API end-point, parse the JSON results in your script, and then use that to make the second call.
Former Nagios employee
Creator:
Human Design Website
Get Your Human Design Chart
Locked