Need Help with SNMPTT and NAGIOS config - working, but not quite ;)
Linux - SoftwareThis forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
Need Help with SNMPTT and NAGIOS config - working, but not quite ;)
Okay so I am officially stuck- I've tried everything I can think of, so I'm hoping you guys can jump in and provide some help.
I have setup a service in nagios that acts as an snmp trap receiver for a switch on our network. It shows up in the web interface as a service running under the switch that is being monitored.
I can send a trap from the switch to my nagios server, and here is what I get:
Code:
tail /var/log/snmptt/snmptt.log
Tue Nov 23 17:04:50 2010 .1.3.6.1.6.3.1.1.5.3 Normal "Status Events" extreme400 - Link down on interface 12. Admin state: up. Operational state: down
Tue Nov 23 17:04:55 2010 .1.3.6.1.6.3.1.1.5.4 Normal "Status Events" extreme400 - Link up on interface 12. Admin state: up. Operational state: up
The exact same output also shows up in /var/log/messages
However, I never get the email alert or see the color change in the web interface?
Also, it should be noted before moving on, that my nagios setup does indeed send mail correctly for other monitored services when they alarm, and that the other services running under this host also send email correctly when they alarm- just not this one service, so I'm thinking SNMPTT is not actually ever passing it to nagios correctly.
EVENT enterpriseSpecific .1.3.6.* "Status Events Normal"
FORMAT Wildcard Test Trap from $r.
EXEC /usr/local/nagios/libexec/eventhandlers/submit_check_result $r TRAP 1 "Wildcard trap received"
SDESC
A generic wildcard test trap received
EDESC
Does anyone have any idea why the trap is not making that last short leg of the journey to nagios?
Okay, so I think I've found what is causing the problem, and have also fixed it:
After running the command in my snmptt.conf file straight from the command line (this command can be found in several tutorials on the net, but it doesn't seem to work as is):
And the command runs successfully, but here is what /var/log/messages has to say about it:
Code:
Nov 24 05:49:37 ubuntu nagios: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;TRAP;1;Wildcard received;
Nov 24 05:49:37 ubuntu nagios: Warning: Passive check result was received for service '1' on host 'TRAP', but the host could not be found!
So I'm thinking it was a problem with the way the snmptt.conf command is being run.
It says a check was received for service 1 on host TRAP, which is not correct, so I changed the command to this and ran it again:
And now it works like a charm- email notification came through right away
However, I am still very curious as to why the $r variable is not holding my hostname correctly- could it be the fact that my hostname has a pound sign in it (extreme400#2) ? Any ideas or easy ways to check? I already echoed the "$r" variable after running the command to see its contents and it is indeed an empty variable- which is why the original command erroneously though my hostname was TRAP.
Okay, so maybe I didn't fix the problem completely-
I've setup snmptt to translate any traps that I receive into Nagios alerts. I get the traps just fine, and when I run /usr/local/nagios/libexec/eventhandlers/submit_check_result extreme400-2 TRAP 1 "Wildcard trap received" (same command from my snmptt.conf file) at the command line, I soon after get the email notification (so I know the .cfg's are good), and when I cat /var/log/messages everything looks good:
Nov 24 06:38:00 ubuntu nagios: EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;extreme400-2;TRAP;1;Wildcard received
Nov 24 06:38:05 ubuntu nagios: PASSIVE SERVICE CHECK: extreme400-2;TRAP;1;Wildcard received
Nov 24 06:38:05 ubuntu nagios: SERVICE ALERT: extreme400-2;TRAP;WARNING;HARD;1;Wildcard received
Nov 24 06:38:05 ubuntu nagios: SERVICE NOTIFICATION: nagiosadmin;extreme400-2;TRAP;WARNING;notify-service-by-email;Wildcard received
Nov 24 06:38:05 ubuntu nagios: SERVICE ALERT: extreme400-2;TRAP;OK;HARD;1;PING OK - Packet loss = 0%, RTA = 0.68 ms
Nov 24 06:38:05 ubuntu nagios: SERVICE NOTIFICATION: nagiosadmin;extreme400-2;TRAP;OK;notify-service-by-email;PING OK - Packet loss = 0%, RTA = 0.68 ms
The problem comes when I don't issue the above command locally- instead I generate a trap from the extreme400-2 to the Nagios server, and I can see the trap arrive at the Nagios server from cat /var/log/messages:
Nov 24 06:48:06 ubuntu snmptt[0]: .1.3.6.1.6.3.1.1.5.3 Normal "Status Events" extreme400-2 - Link down on interface 12. Admin state: down. Operational state: down
Nov 24 06:48:12 ubuntu snmptt[0]: .1.3.6.1.6.3.1.1.5.4 Normal "Status Events" extreme400-2 - Link up on interface 12. Admin state: up. Operational state: up
However, that's as far as the trap ever gets- it doesn't go on to process the trap and send the process service check result up to Nagios so it can generate an alert or send out an email notification.
My snmptt.conf file is setup to execute the submit_check_result eventhandler command whenever it receives a trap from .1.3.6.* so I'm not really sure why its not passing it up to nagios and generating an alert. Here is my snmptt.conf file:
EVENT enterpriseSpecific .1.3.6.* "Status Events Normal"
FORMAT Wildcard Test Trap from $r.
EXEC /usr/local/nagios/libexec/eventhandlers/submit_check_result extreme400-2 TRAP 1 "Wildcard test trap received"
SDESC
A generic wildcard test trap received
EDESC
Any advice or direction will be greatly appreciated.
Okay, so more progress has been made- I turned on debugging in the snmptt.ini file, sent a trap from the switch to the nagios server, the looked at the snmptt.debug log - here is what it said:
Code:
tail /var/log/snmptt/snmptt.debug
OID of received trap: .1.3.6.1.6.3.1.1.5.4. Will attempt to translate to text
Translated to linkUp
Link up on interface 12. Admin state: up. Operational state: up
.1.3.6.1.6.3.1.1.5.4 Normal "Status Events" extreme400-2 - Link up on interface 12. Admin state: up. Operational state: up
EXEC line(s):
EXEC line not defined
So snmptt is translating the trap correctly, and it is trying to run the EXEC command in snmptt.conf which notifies Nagios, but it says that the EXEC line is not defined?? Here is my snmptt.conf file -
Code:
EVENT enterpriseSpecific .1.3.6.* Normal "Status Events"
FORMAT Wildcard Test Trap from $R.
EXEC /usr/local/nagios/libexec/eventhandlers/submit_check_result $R TRAP 1 "Wildcard test trap received"
SDESC
A generic wildcard test trap received
EDESC
I can run submit_check_result manually, so I know it is there and working - does anybody know why it cannot find the EXEC statement in my snmptt.conf file?
I post in this old thread because I found a solution for my similar case which, hopefully, could help others and spare some days in troubleshooting.
In my case I successfully had managed to have some hosts (HP switches) service TRAPs end up 'in red' in Nagios, but not other hosts (a Websense appliance and some VMWare ESX hosts).
What lead me to the solution was the log:
Quote:
/var/log/nagios3/nagios.log
I sent a couple of test traps from the Websense appliance and took a look at the log:
Code:
[1432897516] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;websense-wcg.domain.loc.domain.loc;TRAP;2; Websense Alert: this event is for testing use
[1432897516] Warning: Passive check result was received for service 'TRAP' on host 'websense-wcg.domain.loc.domain.loc', but the host could not be found!
[1432897526] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;ws02faiv-wcg.domain.loc;TRAP;2; Websense Alert: this event is for testing use
[1432897526] Warning: Passive check result was received for service 'TRAP' on host 'websense-wcg.domain.loc', but the host could not be found!
Where did it took those hostnames, websense-wcg.domain.loc.domain.loc and websense-wcg.domain.loc, from?
Of course from DNS! The Websense test trap was doing a reverse query to my DNS and using the hostnames in the traps instead of IPs.
So I deleted both RRs in DNS and added a single RR for the IP of the appliance: proxy.domain.loc
Then I had to define a Nagios host definition matching the exact FQDN hostname that the trap was sending:
[1432897531] EXTERNAL COMMAND: PROCESS_SERVICE_CHECK_RESULT;proxy.domain.loc;TRAP;2; Websense Alert: this event is for testing use
[1432897536] PASSIVE SERVICE CHECK: proxy.domain.loc;TRAP;2;Websense Alert: this event is for testing use
[1432897536] SERVICE ALERT: proxy.domain.loc;TRAP;CRITICAL;SOFT;1; Websense Alert: this event is for testing use
Hope that above could help someone.
--
rob
Last edited by robcar; 05-30-2015 at 02:31 AM.
Reason: wrong hostname
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.