RE: SNMP GET ISSUE

<andrew.ford-SWCg6hSX5lit/[email protected]> Wed, 22 May 2019 17:21:54 +0000
Newsgroups gmane.network.nagios.plugins
Message-ID <b854cc7376804b3384ca4f05e1d08772__16142.4323961668$1558545741$gmane$org@wellsfargo.com>
--_000_b854cc7376804b3384ca4f05e1d08772wellsfargocom_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

check_snmp has wealth of options, including a timeout option.
You can explore them by taking a look at the output from "check_snmp -help.=
"

Andrew Ford
Information Security Engineer - Network Security Solutions & Design
Tel: 314-348-4937 | Email: andrew.ford-SWCg6hSX5lit/[email protected]<mailto:andrew.ford@we=
llsfargo.com>

From: Help <help-bounces+andrew.ford=3Dwellsfargo.com-BzZFE/mEuEFXl34HfRtyeBQPam/[email protected]=
g> On Behalf Of Aoutir, Nabil
Sent: Wednesday, May 22, 2019 11:44 AM
To: help-BzZFE/[email protected]
Subject: SNMP GET ISSUE

Dear team,

I have two machines A and B, the A is snmp manager with centreon installed =
on it.

The B machine is the client machine that I need to monitor. In the client m=
achine, i have a script that calculate the number of files on a specific di=
rectory ( the output of the script is a number). The path of this script ha=
s been added to the snmpd configuration file ( etc/snmp/snmpd.conf) on the =
client machine and generated an OID for this script.

what happens is that every 5 minutes, this script is requested remotly by c=
entreon machine via snmp with this  command launched each 5 minutes from Ce=
ntreon machine :
/usr/lib/nagios/plugins/check_snmp -H client_IP_Adress -C All -P 2c -o .1.3=
.6.1.4.1.8072.1.3.2.3.1.2.22.99.104.101.99.107.95.98.108.111.99.107.101.100=
.95.102.105.108.101.115.95.112.112 -w 1 -c 2

where -w is for warning if 1 files found  and -c for critical if 2  or more=
s files are found

This has been working really fine until now. The problem is that the script=
 that counts the files takes sometimes more than 5 seconds because there is=
 a lot of files to count, and what happens is that if the script doesn't gi=
ve a result within 5 seconds, the command above get a timeout error.

I don't know where to change the timeout, so what i did is modifying the sc=
ript that counts files, this modifications intend to stop the the command t=
hat counts files (inside the script)  if it takes more than 4 seconds

This is the previous version :
#!/bin/bash

if [[ "$1" =3D "PROD" ]]; then
        received=3D"/mnt/sftpdata/vpod/repository/received/PROD"
else
        received=3D"/mnt/sftpdata/vpodpp/repository/received/PRE"
fi
echo $(find $received \( -path /mnt/sftpdata/vpod/repository/received/$1/FH=
U2/v1app2omniaboprd \) -prune -o -type f -mmin +45 -print 2>&1 | wc -l)

And this the modified new version :

#! /bin/bash

if [[ "$1" =3D "PROD" ]]; then
        received=3D"/mnt/sftpdata/vpod/repository/received/PROD"
else
        received=3D"/mnt/sftpdata/vpodpp/repository/received/PRE"
fi

f=3D$(timeout 4 bash -c "find $received \( -path /mnt/sftpdata/vpod/reposit=
ory/received/$1/FHU2/v1app2omniaboprd \) -prune -o -type f -mmin +45 -print=
 2>&1 | wc -l")

if [[ "${#f}" -eq 0 ]]
then
        echo '3'
else
        echo $f
fi


With the new version, normaly when i execute the check snmp command from ce=
ntreon machine (/usr/lib/nagios/plugins/check_snmp -H client_IP_Adress -C A=
ll -P 2c -o .1.3.6.1.4.1.8072.1.3.2.3.1.2.22.99.104.101.99.107.95.98.108.11=
1.99.107.101.100.95.102.105.108.101.115.95.112.112 -w 1 -c 2), i should hav=
e the number 3 as a resulat from the external script if the find doesn't an=
swer within 4 seconds, but this is not the case, instead of having 3, i hav=
e this message : external command error timeout. and the snmp deamon is kil=
led automaticaly oh the client machine ( inactive (dead)).

Can you please help me with this issue, im really blocked :/


DXC Technology Company -- This message is transmitted to you by or on behal=
f of DXC Technology Company or one of its affiliates. It is intended exclus=
ively for the addressee. The substance of this message, along with any atta=
chments, may contain proprietary, confidential or privileged information or=
 information that is otherwise legally exempt from disclosure. Any unauthor=
ized review, use, disclosure or distribution is prohibited. If you are not =
the intended recipient of this message, you are not authorized to read, pri=
nt, retain, copy or disseminate any part of this message. If you have recei=
ved this message in error, please destroy and delete all copies and notify =
the sender by return e-mail. Regardless of content, this e-mail shall not o=
perate to bind DXC Technology Company or any of its affiliates to any order=
 or other contract unless pursuant to explicit written agreement or governm=
ent initiative expressly permitting the use of e-mail for such purpose. --.

--_000_b854cc7376804b3384ca4f05e1d08772wellsfargocom_
Content-Type: text/html; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

<html xmlns:v=3D"urn:schemas-microsoft-com:vml" xmlns:o=3D"urn:schemas-micr=
osoft-com:office:office" xmlns:w=3D"urn:schemas-microsoft-com:office:word" =
xmlns:m=3D"http://schemas.microsoft.com/office/2004/12/omml" xmlns=3D"http:=
//www.w3.org/TR/REC-html40">
<head>
<meta http-equiv=3D"Content-Type" content=3D"text/html; charset=3Dus-ascii"=
>
<meta name=3D"Generator" content=3D"Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
	{font-family:"MS Mincho";
	panose-1:2 2 6 9 4 2 5 8 3 4;}
@font-face
	{font-family:"Cambria Math";
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:Calibri;
	panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
	{font-family:Cambria;
	panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
	{font-family:"\@MS Mincho";
	panose-1:2 2 6 9 4 2 5 8 3 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
	{margin:0in;
	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:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
p.msonormal0, li.msonormal0, div.msonormal0
	{mso-style-name:msonormal;
	mso-margin-top-alt:auto;
	margin-right:0in;
	mso-margin-bottom-alt:auto;
	margin-left:0in;
	font-size:12.0pt;
	font-family:"Times New Roman",serif;}
span.EmailStyle18
	{mso-style-type:personal;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
span.EmailStyle19
	{mso-style-type:personal;
	font-family:"Calibri",sans-serif;
	color:#1F497D;}
span.EmailStyle20
	{mso-style-type:personal-reply;
	font-family:"Calibri",sans-serif;
	color:#1F497D;}
.MsoChpDefault
	{mso-style-type:export-only;
	font-size:10.0pt;}
@page WordSection1
	{size:8.5in 11.0in;
	margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
	{page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext=3D"edit" spidmax=3D"1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext=3D"edit">
<o:idmap v:ext=3D"edit" data=3D"1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang=3D"EN-US" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span style=3D"color:#1F497D;mso-fareast-language:JA=
">check_snmp has wealth of options, including a timeout option.<o:p></o:p><=
/span></p>
<p class=3D"MsoNormal"><span style=3D"color:#1F497D;mso-fareast-language:JA=
">You can explore them by taking a look at the output from &#8220;check_snm=
p &#8211;help.&#8221;<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"color:#1F497D;mso-fareast-language:JA=
"><o:p>&nbsp;</o:p></span></p>
<div>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;font-family:&quot;Ca=
mbria&quot;,serif;color:#1F497D;mso-fareast-language:JA">Andrew Ford<o:p></=
o:p></span></p>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;font-family:&quot;Ca=
mbria&quot;,serif;color:#1F497D;mso-fareast-language:JA">Information Securi=
ty Engineer &#8211; Network Security Solutions &amp; Design<o:p></o:p></spa=
n></p>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;font-family:&quot;Ca=
mbria&quot;,serif;color:#7F7F7F;mso-fareast-language:JA">Tel: 314-348-4937 =
| Email:&nbsp;</span><span style=3D"font-size:12.0pt;font-family:&quot;Camb=
ria&quot;,serif;color:#1F497D;mso-fareast-language:JA"><a href=3D"mailto:an=
drew.ford-SWCg6hSX5lit/[email protected]"><span style=3D"color:blue">andrew.ford@wellsfargo=
.com</span></a><o:p></o:p></span></p>
</div>
<p class=3D"MsoNormal"><span style=3D"color:#1F497D;mso-fareast-language:JA=
"><o:p>&nbsp;</o:p></span></p>
<div>
<div style=3D"border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in =
0in 0in">
<p class=3D"MsoNormal"><b><span style=3D"mso-fareast-language:JA">From:</sp=
an></b><span style=3D"mso-fareast-language:JA"> Help &lt;help-bounces&#43;a=
ndrew.ford=3Dwellsfargo.com-BzZFE/[email protected]&gt;
<b>On Behalf Of </b>Aoutir, Nabil<br>
<b>Sent:</b> Wednesday, May 22, 2019 11:44 AM<br>
<b>To:</b> help-BzZFE/[email protected]<br>
<b>Subject:</b> SNMP GET ISSUE<o:p></o:p></span></p>
</div>
</div>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">Dear team,<o:p></o:p></p>
<p class=3D"MsoNormal"><b><i><span style=3D"font-size:10.0pt;color:black;ms=
o-fareast-language:FR"><o:p>&nbsp;</o:p></span></i></b></p>
<p class=3D"MsoNormal">I have two machines A and B, the A is snmp manager w=
ith centreon installed on it.<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span lang=3D"FR">The B machine is the client machin=
e that I need to monitor.
</span>In the client machine, i have a script that calculate the number of =
files on
<span style=3D"color:black">a</span> specific directory ( the output of the=
 script is a number). The path of this script has been added to the snmpd c=
onfiguration file ( etc/snmp/snmpd.conf) on the client machine and generate=
d an OID for this script.
<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">what happens is that every 5 minutes, this script is=
 requested remotly by centreon machine via snmp<span style=3D"color:black">=
 with this</span> &nbsp;command launched each
<span style=3D"color:black">5 minutes</span> from Centreon machine :<o:p></=
o:p></p>
<p class=3D"MsoNormal"><span lang=3D"FR">/usr/lib/nagios/plugins/check_snmp=
 -H client_IP_Adress -C All -P 2c -o .1.3.6.1.4.1.8072.1.3.2.3.1.2.22.99.10=
4.101.99.107.95.98.108.111.99.107.101.100.95.102.105.108.101.115.95.112.112=
 -w 1 -c 2<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal">where -w is for warning<span style=3D"color:black"> =
if 1 files found
</span>&nbsp;a<span style=3D"color:black">n</span>d -c for critical<span st=
yle=3D"color:black"> if 2&nbsp; or mores files are found</span><o:p></o:p><=
/p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">This has been working really fine until now<span sty=
le=3D"color:black">.
</span>The problem is that the script that counts the files take<span style=
=3D"color:black">s sometimes</span> more tha<span style=3D"color:black">n</=
span> 5 seconds because there is a lot of files<span style=3D"color:black">=
 to count</span>, and what happens is
 that if the script doe<span style=3D"color:black">sn</span>'t give a resu<=
span style=3D"color:black">l</span>t within 5 seconds, the command above ge=
t a timeout error.
<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span style=3D"color:black">I</span> don't know wher=
e to change the timeout, so what i did is modifying the script that counts =
files, this modifications intend to stop the the command th<span style=3D"c=
olor:black">at</span> count<span style=3D"color:black">s</span>
 files<span style=3D"color:black"> (inside the script) </span>&nbsp;i<span =
style=3D"color:black">f</span> it take<span style=3D"color:black">s</span> =
more than
<span style=3D"color:black">4 </span>seconds<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span lang=3D"FR">This is the previous version :<o:p=
></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">#!/bin/bash<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">if [[ &quot;$1&quot; =3D &quot;PRO=
D&quot; ]]; then<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; received=3D&quot;/mnt/sftpdata/vpod/repository/received/PROD&quot;=
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">else<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; received=3D&quot;/mnt/sftpdata/vpodpp/repository/received/PRE&quot=
;<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">fi<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">echo $(find $received \( -path /mn=
t/sftpdata/vpod/repository/received/$1/FHU2/v1app2omniaboprd \) -prune -o -=
type f -mmin &#43;45 -print 2&gt;&amp;1 | wc -l)<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">And this the modified new version =
:<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">#! /bin/bash<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">if [[ &quot;$1&quot; =3D &quot;PRO=
D&quot; ]]; then<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; received=3D&quot;/mnt/sftpdata/vpod/repository/received/PROD&quot;=
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">else<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; received=3D&quot;/mnt/sftpdata/vpodpp/repository/received/PRE&quot=
;<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">fi<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">f=3D$(timeout 4 bash -c &quot;find=
 $received \( -path /mnt/sftpdata/vpod/repository/received/$1/FHU2/v1app2om=
niaboprd \) -prune -o -type f -mmin &#43;45 -print 2&gt;&amp;1 | wc -l&quot=
;)<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">if [[ &quot;${#f}&quot; -eq 0 ]]<o=
:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">then<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; echo '3'<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">else<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; echo $f<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR">fi<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal">With the new version, normaly when i execute the che=
ck snmp command from centreon machine (/usr/lib/nagios/plugins/check_snmp -=
H client_IP_Adress -C All -P 2c -o .1.3.6.1.4.1.8072.1.3.2.3.1.2.22.99.104.=
101.99.107.95.98.108.111.99.107.101.100.95.102.105.108.101.115.95.112.112
 -w 1 -c 2), i should have the number 3 as a resulat from the external scri=
pt if the find doesn't answer with<span style=3D"color:black">in</span> 4 s=
econds, but this is not the case, instead of having 3, i have this message =
: external command error timeout.
 and the snmp deamon is killed automaticaly oh the client machine ( inactiv=
e (dead)).<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span lang=3D"FR">Can you please help me with this i=
ssue, im really blocked :/<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"FR" style=3D"font-size:12.0pt;font-fam=
ily:&quot;Times New Roman&quot;,serif;mso-fareast-language:FR"><br>
<br>
DXC Technology Company -- This message is transmitted to you by or on behal=
f of DXC Technology Company or one of its affiliates. It is intended exclus=
ively for the addressee. The substance of this message, along with any atta=
chments, may contain proprietary,
 confidential or privileged information or information that is otherwise le=
gally exempt from disclosure. Any unauthorized review, use, disclosure or d=
istribution is prohibited. If you are not the intended recipient of this me=
ssage, you are not authorized to
 read, print, retain, copy or disseminate any part of this message. If you =
have received this message in error, please destroy and delete all copies a=
nd notify the sender by return e-mail. Regardless of content, this e-mail s=
hall not operate to bind DXC Technology
 Company or any of its affiliates to any order or other contract unless pur=
suant to explicit written agreement or government initiative expressly perm=
itting the use of e-mail for such purpose. --.
<o:p></o:p></span></p>
</div>
</body>
</html>

--_000_b854cc7376804b3384ca4f05e1d08772wellsfargocom_--