Page 1 of 1

How to write custom commands (not plugins)

Posted: Tue Jul 06, 2021 2:59 pm
by waskinbas
Hello pros,

Is there a guide on writing custom commands? Not plugins! I found tons of guides on writing plugins. For example, I have this command, pulled from the Monitoring tab of the Reconfigure Service option beneath the Service Status Detail page:
check_xi_service_snmp! -p 161 -o 'Ups_Time_Remaining' -P 3 --seclevel=authPriv --secname='My_SNMP_Accout' --authproto=SHA --authpasswd='Strong_Password_Here' --privpasswd='Strong_Password_2_Here' -x aes -l 'Battery Runtime Remaining' -m Correct-MIB-Table -w 360000 -c 180000
That command uses SNMP to monitor my UPS. The way it works now that if the Runtime Remaining timeticks are over 360,000 I will get a warning email, and if timeticks go over 180,000, I will get a critical warning. What I want is the opposite. If the Runtime Remaining timeticks drop below 360,000 (1 hour), I will get a warning. If the remaining time drops below 30mins, I'll get a critical warning. I feel like there should be a flag that reverses the checks such that they test a value against "lesser than" boundaries rather than "greater than" boundaries.

I looked on the Knowledge Base, but I didn't see anything there.

Re: How to write custom commands (not plugins)

Posted: Wed Jul 07, 2021 9:35 am
by ssax
This has a bit of documentation on defining commands:

https://assets.nagios.com/downloads/nag ... ios-XI.pdf

See here for thresholds that it supports:

https://nagios-plugins.org/doc/guidelin ... HOLDFORMAT

Try this:

Code: Select all

-w 360000: -c 180000:

Re: How to write custom commands (not plugins)

Posted: Wed Jul 07, 2021 10:04 am
by waskinbas
Excellent links, ssax! Your suggestions appears to have worked, I'll create some intentional fail states to make sure it is warning correctly, then turn the thresholds to where they should be normally.

Also, thanks for the links. I guess I misunderstood what a plugin was, I was thinking they would let me create my own entire wizards, which is not what I want. I'll read through those documents today.

Thank you!

Re: How to write custom commands (not plugins)

Posted: Wed Jul 07, 2021 4:07 pm
by ssax
That's great to hear! Let us know when we're okay to lock this up and mark it as resolved.

Re: How to write custom commands (not plugins)

Posted: Thu Jul 08, 2021 8:45 am
by waskinbas
Close it up! I did some work yesterday afternoon and everything appears to be working the way I was hoping. I'm going to be doing a lot of tuning and revising next week... 8-) 8-) 8-)

Re: How to write custom commands (not plugins)

Posted: Thu Jul 08, 2021 2:33 pm
by vtrac
Great!! ... locking thread ... :-)