add service with API

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
abderrahim
Posts: 6
Joined: Wed Apr 17, 2019 1:44 am

add service with API

Post by abderrahim »

Hello;

i have an API curl -XGET "http://192.150.30.230:3030/ ... tAudiJobs" that give this result :

Code: Select all

 "DICONSULT-Message-Execution-System state:",
  "systemd: running ready(6477)",
  "A1MA_avbl: running ready(6493)",
  "A1MA_adt: running ready(6509)",
  "A1MA_adtclt: running ready(6525)",
  "A1MA_export: running ready(6541)",
  "A1MA_DFU: running ready(6557)",
  "A1MA_qeu: running ready(6573)",
  "A1MA_gw: running ready(6589)",
  "A1MA_xpps: running ready(2395)",
  "A1MA_jit: running ready(6621)",
  "DICONSULT-Message-Execution-System state:",
  "A1MA_ADM: running ready(4576)",
  "A1MA_AFT: running ready(4596)",
  "A1MA_ART: running ready(4621)",
  "A1MA_APL: running ready(4638)",
  "A1MA_HHL: running ready(4654)",
  "A1MA_JIT: running ready(4693)",
  "A1MA_LGV: running ready(4711)",
  "A1MA_ZSB: running ready(4729)",
  "A1MA_ZUP: running ready(5226)",
  "A1MA_SKT: running ready(5638)",
  "A1MA_ENA: running ready(6024)",
  "A1MA_LDL: running ready(6228)",
  "A1MA_LGR: running ready(6343)",
  "A1MA_UML: running ready(6359)",
  "A1MA_KMA: running ready(6376)",
  "A1MA_TFE: running ready(6397)",
  "A1MA_QUE: running ready(6413)",
  "A1MA_KTE: running ready(6429)",
  "A1MA_LSS: running ready(6445)",
  "A1MA_PER: running ready(6461)",
i want to add this result to my nagios XI monitoring services,
Last edited by abderrahim on Thu Apr 25, 2019 2:21 am, edited 1 time in total.
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: add service with API

Post by cdienger »

You can make sure that the state of a process is "running ready" using the check_http plugin:

Code: Select all

/usr/local/nagios/libexec/check_http -H 192.150.30.230 -p 3030 -u /api/Pls/getAudiJobs -r "A1MA_PER: running ready"
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
abderrahim
Posts: 6
Joined: Wed Apr 17, 2019 1:44 am

Re: add service with API

Post by abderrahim »

@cdienger; thank you for your reply,
this method works, but it gives me the result of one service, then I have to create many check cmd :shock:, and i have a lot of services, I want to see if all services are "running ready" at one check
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: add service with API

Post by cdienger »

What is displayed if a service isn't running? You could change the regex pattern to match when a "not running" message is found in the output.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
abderrahim
Posts: 6
Joined: Wed Apr 17, 2019 1:44 am

Re: add service with API

Post by abderrahim »

hello;
i hve try with this code :

Code: Select all

 /usr/local/nagios/libexec/check_http -H 192.150.30.230 -p 3030 -u /api/Pls/getAudiJobs -r "A1MA_PER: running ready" -r "A1MA_ZSB: running ready"
it return ok if the last argument is correct "-r "A1MA_ZSB: running ready", it don't check the first argument. for exemple if the first argument is not running and the second one is running the output will be : OK. and if the first is running and the second is killed the output will be : NOK
User avatar
cdienger
Support Tech
Posts: 5045
Joined: Tue Feb 07, 2017 11:26 am

Re: add service with API

Post by cdienger »

Try something like:

Code: Select all

/usr/local/nagios/libexec/check_http -H 192.150.30.230 -p 3030 -u /api/Pls/getAudiJobs -r "not running" --invert-regex
replacing "not running" with whatever text is seen when a service is not running. This command will return a CRITICAL if the "not running" text is found.
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
abderrahim
Posts: 6
Joined: Wed Apr 17, 2019 1:44 am

Re: add service with API

Post by abderrahim »

thank you it work :D :D
benjaminsmith
Posts: 5324
Joined: Wed Aug 22, 2018 4:39 pm
Location: saint paul

Re: add service with API

Post by benjaminsmith »

Great!. Are ok to lock this one up?
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!
Locked