Page 1 of 1
adding command. looking for internal community value
Posted: Tue Feb 11, 2014 3:58 pm
by dfmco
I would like to use the Nagios $HOSTNAME% variable and the SNMP variable for that host for a command. I was able the find the hostname variable but I can't find any documentation on the SNMP variable. Here is my command:
$USER1$/check_eigrp -H $HOSTADDRESS$ -C $COMMUNITY$ -n $ARG1$ -a $ARG2$
$COMMUNITY$ should equal the host SNMP string. Is there a variable already reserved?
Also, $ARG1$ is the EIGRP AS number and will be the same for all devices. Is there a way to set that locally? What is best practice?
Re: adding command. looking for internal community value
Posted: Tue Feb 11, 2014 4:41 pm
by lmiltchev
You can set the macro in the "/usr/local/nagios/etc/resource.cfg" file, for example:
Then, you can set your command as:
Code: Select all
$USER1$/check_eigrp -H $HOSTADDRESS$ -C "$USER9$" -n $ARG1$ -a $ARG2$
Let us know if you have any more questions or if you run into some difficulties setting this up.
Re: adding command. looking for internal community value
Posted: Wed Feb 12, 2014 9:36 pm
by dfmco
I was hoping to use the community string that Nagios already has configured for the host. This would allow the command to be portable across installs. What would be the variable that Nagios is using for each host? Can that be used?
Re: adding command. looking for internal community value
Posted: Thu Feb 13, 2014 10:17 am
by slansing
Nagios should not have configured a community string for you, this is something you, or your networking team need to see up on your networking equipment, or really anything you want to actively check with SNMP.
Re: adding command. looking for internal community value
Posted: Thu Feb 13, 2014 7:09 pm
by dfmco
I think you misunderstood the question. I have hosts configured as well as services for those hosts. The services are using SNMP to read information from the router/switch. What I was wanting to do is pull the existing SNMP string out of the existing service for a host and reuse that to configure another service that I am creating. This may not be possible and I fully understand the user9 solution you provided and I know that will work. I am just trying to avoid any modifications to the base tool if an existing option exists to get the string that I have input already. If not, no worries.
Thanks!
Re: adding command. looking for internal community value
Posted: Fri Feb 14, 2014 10:16 am
by lmiltchev
What I was wanting to do is pull the existing SNMP string out of the existing service for a host and reuse that to configure another service that I am creating.
If you are using the same community string on the other device, why not reuse the $USER9$? I am not sure I understand the questions.
Re: adding command. looking for internal community value
Posted: Mon Feb 17, 2014 9:12 am
by dfmco
So let's say I add 10 more devices to monitor. Those 10 use a different string. If I am inputting these devices with a community string already, is there a way to reuse this information without having to now create a $user10$ variable and a whole new service definition. I am trying to keep this as modular and streamlined as possible. Here is the workflow:
Add new host to monitor > Add new service using SNMP string > add my custom service and use the string entered on the 1st service without having to retype.
Does that help?
Re: adding command. looking for internal community value
Posted: Mon Feb 17, 2014 1:00 pm
by lmiltchev
If you don't want to set up many different macros in the resource.cfg file ($USER9$, $USER10$, etc.), you can do the following:
Add new host to monitor > Add new service using SNMP string > add my custom service by cloning and modifying an old service with the correct community string
Check the "Copying Hosts" section in the document below - it is the same procedure with services. When you create your custom service, you will have give it the proper config name, and assign it to the correct host.
http://assets.nagios.com/downloads/nagi ... gement.pdf