How to write custom commands (not plugins)

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
waskinbas
Posts: 16
Joined: Wed Jun 02, 2021 1:59 pm

How to write custom commands (not plugins)

Post 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.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: How to write custom commands (not plugins)

Post 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:
waskinbas
Posts: 16
Joined: Wed Jun 02, 2021 1:59 pm

Re: How to write custom commands (not plugins)

Post 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!
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: How to write custom commands (not plugins)

Post by ssax »

That's great to hear! Let us know when we're okay to lock this up and mark it as resolved.
waskinbas
Posts: 16
Joined: Wed Jun 02, 2021 1:59 pm

Re: How to write custom commands (not plugins)

Post 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-)
User avatar
vtrac
Posts: 903
Joined: Tue Oct 27, 2020 1:35 pm

Re: How to write custom commands (not plugins)

Post by vtrac »

Great!! ... locking thread ... :-)
Locked