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?
nagios cgi-bin
-
benjaminsmith
- Posts: 5324
- Joined: Wed Aug 22, 2018 4:39 pm
- Location: saint paul
Re: nagios cgi-bin
Hello,
If you're using Nagios XI, I would recommend using the Backend API. Go to Help > API Docs for documentation.
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!
Be sure to check out our Knowledgebase for helpful articles and solutions!
Re: nagios cgi-bin
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"
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
You can get them from the XI API
Help -> Objects Reference -> objects/hostgroupmembers
The call would look something like this
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=HOSTGROUPRe: nagios cgi-bin
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.
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
You would then need to make another call to objects/hoststatus with something like the following extracting the host names from the previous call
current_state=nin:0 means NOT 0 (not UP)
name=in:HOST1,HOST2,HOST3 means only show the hosts in the comma separated list
Code: Select all
http://xxx.xxx.xxx.xxx/nagiosxi/api/v1/objects/hoststatus?apikey=APIKEY&pretty=1¤t_state=nin:0&name=in:HOST1,HOST2,HOST3current_state=nin:0 means NOT 0 (not UP)
name=in:HOST1,HOST2,HOST3 means only show the hosts in the comma separated list
Re: nagios cgi-bin
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.
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
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.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.