adding command. looking for internal community value

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
dfmco
Posts: 257
Joined: Wed Dec 04, 2013 11:05 am

adding command. looking for internal community value

Post 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?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: adding command. looking for internal community value

Post by lmiltchev »

You can set the macro in the "/usr/local/nagios/etc/resource.cfg" file, for example:

Code: Select all

$USER9$=<your community string>
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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
dfmco
Posts: 257
Joined: Wed Dec 04, 2013 11:05 am

Re: adding command. looking for internal community value

Post 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?
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: adding command. looking for internal community value

Post 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.
dfmco
Posts: 257
Joined: Wed Dec 04, 2013 11:05 am

Re: adding command. looking for internal community value

Post 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!
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: adding command. looking for internal community value

Post 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.
Be sure to check out our Knowledgebase for helpful articles and solutions!
dfmco
Posts: 257
Joined: Wed Dec 04, 2013 11:05 am

Re: adding command. looking for internal community value

Post 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?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: adding command. looking for internal community value

Post 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
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked