Page 1 of 1

add service with API

Posted: Fri Apr 19, 2019 7:21 am
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,

Re: add service with API

Posted: Fri Apr 19, 2019 1:43 pm
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"

Re: add service with API

Posted: Mon Apr 22, 2019 5:22 am
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

Re: add service with API

Posted: Mon Apr 22, 2019 12:49 pm
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.

Re: add service with API

Posted: Tue Apr 23, 2019 2:37 am
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

Re: add service with API

Posted: Tue Apr 23, 2019 3:56 pm
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.

Re: add service with API

Posted: Thu Apr 25, 2019 2:21 am
by abderrahim
thank you it work :D :D

Re: add service with API

Posted: Thu Apr 25, 2019 11:04 am
by benjaminsmith
Great!. Are ok to lock this one up?