<html>
<head>
<meta content="text/html; charset=ISO-8859-1"
http-equiv="Content-Type">
</head>
<body bgcolor="#FFFFFF" text="#000000">
<div class="moz-cite-prefix">On 9/5/12 1:00 AM, Marco Borsani wrote:<br>
</div>
<blockquote cite="mid:005901cd8b3c$9225c5a0$b67150e0$@it.net"
type="cite">
<meta http-equiv="Content-Type" content="text/html;
charset=ISO-8859-1">
<meta name="Generator" content="Microsoft Word 14 (filtered
medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0cm;
margin-bottom:.0001pt;
font-size:11.0pt;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
{mso-style-priority:99;
color:purple;
text-decoration:underline;}
span.StileMessaggioDiPostaElettronica17
{mso-style-type:personal-compose;
font-family:"Calibri","sans-serif";
color:windowtext;}
.MsoChpDefault
{mso-style-type:export-only;
font-family:"Calibri","sans-serif";
mso-fareast-language:EN-US;}
@page WordSection1
{size:612.0pt 792.0pt;
margin:70.85pt 2.0cm 2.0cm 2.0cm;}
div.WordSection1
{page:WordSection1;}
--></style><span lang="EN-GB"><o:p> <br>
</o:p></span>
<div class="WordSection1">
<p class="MsoNormal"><span lang="EN-GB">I read many docs, but I
still have problem to configure nagios 3.x to receive the
traps.<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">May someone explain the
steps to follow to configure correctly this issue ?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB">Is it necessary other SW
?<o:p></o:p></span></p>
<p class="MsoNormal"><span lang="EN-GB"><o:p> </o:p></span><br>
</p>
</div>
</blockquote>
<br>
You'll need to ensure that snmptrapd is enabled on your Nagios
poller, and the typical route from there to get snmp traps submitted
into Nagios is to install SNMPTT.<br>
<br>
<a class="moz-txt-link-freetext" href="http://snmptt.sourceforge.net/">http://snmptt.sourceforge.net/</a><br>
<br>
I recommend reading the docs for these, but, a very basic
snmptrapd.conf would be:<br>
###### snmptrapd.conf<br>
snmpTrapdAddr <a class="moz-txt-link-freetext" href="udp:localhost,udp:YOUR_IP_HERE,tcp:YOUR_IP_HERE">udp:localhost,udp:YOUR_IP_HERE,tcp:YOUR_IP_HERE</a><br>
<br>
authCommunity log,execute public<br>
logOption f/var/log/snmptrapd.log<br>
traphandle default /usr/sbin/snmptt -i
/usr/local/share/snmp/snmptt.ini<br>
######<br>
<br>
And then in the TrapFiles section of snmptt.ini you might have:<br>
######<br>
[TrapFiles]<br>
snmptt_conf_files = <<END<br>
/usr/local/share/snmp/snmptt/asyncos.conf<br>
END<br>
######<br>
<br>
In the included config file you map trap oids to script executions,
like so:<br>
###### asyncos.conf<br>
# snmptt.conf file for AsyncOS traps.<br>
# <br>
# All of these are stateless so the handler script needs to set and
clear the service.<br>
# The service entry must have 0 retries set and be volatile.<br>
# <br>
# .1.3.6.1.4.1.15497<br>
#<br>
<br>
# powerSupplyStatusChange<br>
# Status: .1.3.6.1.4.1.15497.1.1.1.8.1.2<br>
EVENT powerSupplyStatusChange .1.3.6.1.4.1.15497.1.1.2.0.2 "asyncos"
Critical<br>
FORMAT $N trap from $r<br>
EXEC /usr/local/nagios/customplugins/submit_trap $r
AsyncOS-Trap_Alert $s 0 "$N: $*"<br>
#<br>
#####<br>
<br>
Your submit_trap script takes that, and hands it off to Nagios. You
can submit through NSCA, or you can create a result file in the
checkresult directory, or you can submit through the external
command pipe.<br>
<br>
I do it through NSCA:<br>
##### submit_trap<br>
#!/usr/local/bin/bash<br>
<br>
PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/nagios/customplugins:/usr/local/nagios/bin<br>
CONFIG=/usr/local/nagios/etc/send_nsca.cfg<br>
NSCA=`hostname`<br>
<br>
HOST=$1<br>
SERVICE=$2<br>
STATUS=$3<br>
STATEFUL=$4<br>
MESSAGE=$5<br>
case $STATUS in<br>
"Critical")<br>
CODE=2<br>
;;<br>
"Warning")<br>
CODE=1<br>
;;<br>
"Normal")<br>
CODE=0<br>
;;<br>
*)<br>
CODE=3<br>
;;<br>
esac<br>
<br>
printf "%s\t%s\t%s\t%s\n" "$HOST" "$SERVICE" $CODE "$MESSAGE" |
send_nsca -H $NSCA -c $CONFIG<br>
if [[ "$STATEFUL" == "0" ]] && [[ "$STATUS" != "0" ]]<br>
then<br>
# Clear Nagios via delayed at now that the volatile ticket's
gone through.<br>
echo "/usr/local/nagios/customplugins/clear.sh $HOST
\"$SERVICE\" \"$MESSAGE\"" | at now + 15 minutes<br>
<br>
fi<br>
#####<br>
<br>
... and clear.sh for clearing stateless alerts.<br>
<br>
#####<br>
#!/usr/local/bin/bash<br>
<br>
PATH=/bin:/usr/bin:/usr/local/bin:/usr/local/nagios/bin:/usr/local/ironport/nagios/bin<br>
HOST=$1<br>
SVC=$2<br>
OUT=$3<br>
<br>
if [[ "$HOST" == "" ]] || [[ "$SVC" == "" ]]<br>
then<br>
echo "Need host, service, optional message."<br>
exit 3<br>
fi<br>
<br>
# Clear it<br>
printf "%b" "$HOST\t$SVC\t0\tWas:$OUT\n" | send_nsca -H `hostname`
-c /usr/local/nagios/etc/send_nsca.cfg<br>
<br>
fi<br>
#####<br>
<br>
If you're using the auto-clear bits, your Nagios user will need to
be able to add items to the at queue, you'll need to look at your
distribution's documentation on how that's managed. This is just
one way of getting snmp traps working. Unfortunately none of them
that I know of overly straightforward.<br>
<br>
Even if this doesn't work for you, it should give enough of an
insight so that you've got a better idea on what to google for.
Good luck.<br>
<pre class="moz-signature" cols="72">--
Mike Lindsey</pre>
</body>
</html>