What is the best practice using commands?

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
Locked
00_kl250
Posts: 63
Joined: Tue Apr 16, 2013 7:26 am

What is the best practice using commands?

Post by 00_kl250 »

Hey all,

Trying to figure out what is the best practice in regards to commands.

For example, i'm using nagios3 in the etc directory under the conf.d directory and have my cfg_dir=/etc/nagios/conf.d enabled to so i can have multiple .d directories because i have so many different locations that i'm monitoring. For now, my commands.cfg file in the /etc/nagios3 directory houses all my commands.

I'm using the check_snmp command to check many different things and devices. Right now my check command is defined in the top structure, /etc/nagios3/commands.cfg file:

define command {
command_name check_snmp
command_line $USER1$/check_snmp -P $ARG1$ -H $HOSTADDRESS$ -C $ARG2$ -o $ARG3$ -w $ARG4$ -c $ARG5$
}

All my sub directories in conf.d have their service definition reference this check_snmp command. Now that i've added multiple devices i realized that some of the snmp checks I don't need warning or critical thresholds.

Can I have multiple check_commands in many different directories using a SINGLE check command called check_snmp command, but maybe doesn't need to use all the arugments such asARG4/ARG5? Or do I need to create another check_snmp command somewhere else in another .cfg file. I tried doing this already and nagios yells at me saying check_snmp is already define or something like that, so i'm guessing the way to go is probably find a way to pass null values somehow to the arguments that I don't need in my command.

Here are two service checks for reference, each in a different sub directory under the conf.d/

define service {
use generic-service
host_name xxxxxxx.xxxxx.xxxxxx.x,xxxxxxxx.x.xxxxxx.xxx.xx
service_description Signal
check_command check_snmp!1!xxxx!.1.3.6.1.4.1.12394.1.1.11.10.0
notification_interval 0;
}
As you can see in this one I don't need anything in my check_command for -c or -w thresholds.

In this one I do:
define service {
use generic-service
host_name xxxxx.xxxx.xxxx.x,xxxxx.xxxx.xxxx.x
service_description Data In
check_command check_snmp!1!xxxxx!.1.3.6.1.2.1.2.2.1.10.1!100!200
}

Thanks so much!
User avatar
Box293
Too Basu
Posts: 5126
Joined: Sun Feb 07, 2010 10:55 pm
Location: Deniliquin, Australia
Contact:

Re: What is the best practice using commands?

Post by Box293 »

00_kl250 wrote:Can I have multiple check_commands in many different directories using a SINGLE check command called check_snmp command
No

However you could use custom variables stored in the service object.

So your command would be something like:

Code: Select all

define command {
command_name check_snmp_custom
command_line $USER1$/check_snmp -P $ARG1$ -H $HOSTADDRESS$ -C $ARG2$ -o $ARG3$ $_SERVICESNMP_OPTIONS$
}
And your services

Code: Select all

define service {
use generic-service
host_name xxxxx.xxxx.xxxx.x,xxxxx.xxxx.xxxx.x
service_description Data In
check_command check_snmp_custom!1!xxxxx!.1.3.6.1.2.1.2.2.1.10.1
_snmp_options '-w 100 -c 200'
}

Code: Select all

define service {
use generic-service
host_name xxxxxxx.xxxxx.xxxxxx.x,xxxxxxxx.x.xxxxxx.xxx.xx
service_description Signal
check_command check_snmp_custom!1!xxxx!.1.3.6.1.4.1.12394.1.1.11.10.0
notification_interval 0;
_snmp_options ''
}
Here is some reading material on custom object variables:
http://nagios.sourceforge.net/docs/3_0/ ... tvars.html

Does this help?
As of May 25th, 2018, all communications with Nagios Enterprises and its employees are covered under our new Privacy Policy.
00_kl250
Posts: 63
Joined: Tue Apr 16, 2013 7:26 am

Re: What is the best practice using commands?

Post by 00_kl250 »

Yes this helps tremendously. Thank you!
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

Re: What is the best practice using commands?

Post by abrist »

Alright, lets us know if you have further issues.
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
Locked