Page 1 of 2
Update status in Nagios Xi
Posted: Mon Nov 11, 2019 6:51 am
by Saha
I want to update the status of the service/host (ex. from critical to OK after running a script in the server or want to keep the status as OK all the time)
do we have rest api for that , please help!
Is there any way we can create a new status fro certain service/host?
Re: Update status in Nagios Xi
Posted: Mon Nov 11, 2019 8:36 am
by scottwilkerson
Yes you can do this via the API
Help -> API Docs -> System Reference -> system/corecommand
The format of the commands would follow either of these external commands
Services
https://assets.nagios.com/downloads/nag ... and_id=114
Hosts
https://assets.nagios.com/downloads/nag ... and_id=115
Re: Update status in Nagios Xi
Posted: Mon Nov 11, 2019 9:16 am
by Saha
Thanks scottwilkerson for the quick response
Tried system/corecommand and got this response "
{"cmd":"PROCESS_SERVICE_CHECK_RESULT;localhost:HTTP;0;nagiosadmin;OK- Everything Looks Great\\n","success":"Command submitted"}"
but it is not reflecting in the service Status of Nagios GUI.
Re: Update status in Nagios Xi
Posted: Mon Nov 11, 2019 9:30 am
by scottwilkerson
I just tested the following on my system
Code: Select all
[root@localhost nagiosxi]# ccurl -XPOST "http://192.168.5.XXX/nagiosxi/api/v1/system/corecommand?apikey=APIKEY" -d "cmd=PROCESS_SERVICE_CHECK_RESULT;localhost;HTTP;0;OK- Everything Looks Great\n"
{"cmd":"PROCESS_SERVICE_CHECK_RESULT;localhost;HTTP;0;OK- Everything Looks Great\\n","success":"Command submitted"}
when I go look at HTTP on localhost I see
OK- Everything Looks Great
Re: Update status in Nagios Xi
Posted: Mon Nov 11, 2019 9:31 am
by scottwilkerson
It is worth noting that the state will only last until the next check result comes in.
Re: Update status in Nagios Xi
Posted: Tue Nov 12, 2019 1:46 am
by Saha
scottwilkerson , it is not working for me.
Do i need to enable any parameter in cfg file.
Re: Update status in Nagios Xi
Posted: Tue Nov 12, 2019 7:51 am
by scottwilkerson
You do need the following in the nagios.cfg
Code: Select all
accept_passive_host_checks=1
accept_passive_service_checks=1
Also, you need to make sure you didn't specifically disable passive checks in the service .cfg with the
passive_checks_enabled directive
Re: change status in Nagios Xi
Posted: Tue Nov 12, 2019 8:11 am
by Saha
Hi scottwilkerson,
already
passive_checks_enabled = 1 in file /usr/local/nagios/etc/servicetemplates.cfg
and
accept_passive_host_checks=1
accept_passive_service_checks=1 in file /usr/local/nagios/etc/nagios.cfg
(not able to find service.cfg)
still system/corecommand are not updating status in nagios Gui.
please help!
Thanks in advance
Re: Update status in Nagios Xi
Posted: Tue Nov 12, 2019 8:24 am
by scottwilkerson
Lets run the following:
Code: Select all
tail -f /usr/local/nagios/var/nagios.log
While that is running, submit the command again from the API and see if you see any errors of note
Re: Update status in Nagios Xi
Posted: Tue Nov 12, 2019 8:41 am
by Saha
Thanks scottwilkerson ;
it helped, now i am able to update it.
i was not getting it because the order of argument was wrong
Thanks a lot
