SNMP GET ISSUE

"Aoutir, Nabil" <[email protected]> Wed, 22 May 2019 16:43:42 +0000
Newsgroups gmane.network.nagios.plugins
Message-ID <CY4PR0101MB288879427BC5D7A635563A8F98000__22237.5400642463$1558543900$gmane$org@CY4PR0101MB2888.prod.exchangelabs.com>
--_000_CY4PR0101MB288879427BC5D7A635563A8F98000CY4PR0101MB2888_
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: quoted-printable

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_CY4PR0101MB288879427BC5D7A635563A8F98000CY4PR0101MB2888_
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:"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;}
/* 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:#0563C1;
	text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
	{mso-style-priority:99;
	color:#954F72;
	text-decoration:underline;}
span.EmailStyle17
	{mso-style-type:personal;
	font-family:"Calibri",sans-serif;
	color:windowtext;}
span.EmailStyle18
	{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:612.0pt 792.0pt;
	margin:72.0pt 72.0pt 72.0pt 72.0pt;}
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"FR" link=3D"#0563C1" vlink=3D"#954F72">
<div class=3D"WordSection1">
<p class=3D"MsoNormal"><span lang=3D"EN-US">Dear team,<o:p></o:p></span></p=
>
<p class=3D"MsoNormal"><b><i><span lang=3D"EN-US" style=3D"font-size:10.0pt=
;color:black;mso-fareast-language:FR"><o:p>&nbsp;</o:p></span></i></b></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">I have two machines A and B, th=
e A is snmp manager with centreon installed on it.<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal">The B machine is the client machine that I need to m=
onitor. <span lang=3D"EN-US">
In the client machine, i have a script that calculate the number of files o=
n <span style=3D"color:black">
a</span> specific directory ( the output of the script is a number). The pa=
th of this script has been added to the snmpd configuration file ( etc/snmp=
/snmpd.conf) on the client machine and generated an OID for this script.
<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">what happens is that every 5 mi=
nutes, this script is requested remotly by centreon machine via snmp<span s=
tyle=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></span></p>
<p class=3D"MsoNormal">/usr/lib/nagios/plugins/check_snmp -H client_IP_Adre=
ss -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<o:p></o=
:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">where -w is for warning<span st=
yle=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><=
/span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">This has been working really fi=
ne until now<span style=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></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US" style=3D"color:black">I</span><=
span lang=3D"EN-US"> don't know where to change the timeout, so what i did =
is modifying the script that counts files, this modifications intend to sto=
p the the command th<span style=3D"color: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"co=
lor:black">s</span> more than
<span style=3D"color:black">4 </span>seconds<o:p></o:p></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal">This is the previous version :<o:p></o:p></p>
<p class=3D"MsoNormal">#!/bin/bash<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">if [[ &quot;$1&quot; =3D &quot;PROD&quot; ]]; then<o=
:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; received=
=3D&quot;/mnt/sftpdata/vpod/repository/received/PROD&quot;<o:p></o:p></p>
<p class=3D"MsoNormal">else<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; received=
=3D&quot;/mnt/sftpdata/vpodpp/repository/received/PRE&quot;<o:p></o:p></p>
<p class=3D"MsoNormal">fi<o:p></o:p></p>
<p class=3D"MsoNormal">echo $(find $received \( -path /mnt/sftpdata/vpod/re=
pository/received/$1/FHU2/v1app2omniaboprd \) -prune -o -type f -mmin &#43;=
45 -print 2&gt;&amp;1 | wc -l)<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">And this the modified new version :<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">#! /bin/bash<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">if [[ &quot;$1&quot; =3D &quot;PROD&quot; ]]; then<o=
:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; received=
=3D&quot;/mnt/sftpdata/vpod/repository/received/PROD&quot;<o:p></o:p></p>
<p class=3D"MsoNormal">else<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; received=
=3D&quot;/mnt/sftpdata/vpodpp/repository/received/PRE&quot;<o:p></o:p></p>
<p class=3D"MsoNormal">fi<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">f=3D$(timeout 4 bash -c &quot;find $received \( -pat=
h /mnt/sftpdata/vpod/repository/received/$1/FHU2/v1app2omniaboprd \) -prune=
 -o -type f -mmin &#43;45 -print 2&gt;&amp;1 | wc -l&quot;)<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal">if [[ &quot;${#f}&quot; -eq 0 ]]<o:p></o:p></p>
<p class=3D"MsoNormal">then<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo '3'<=
o:p></o:p></p>
<p class=3D"MsoNormal">else<o:p></o:p></p>
<p class=3D"MsoNormal">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; echo $f<o=
:p></o:p></p>
<p class=3D"MsoNormal">fi<o:p></o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><o:p>&nbsp;</o:p></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US">With the new version, normaly w=
hen i execute the check 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></span></p>
<p class=3D"MsoNormal"><span lang=3D"EN-US"><o:p>&nbsp;</o:p></span></p>
<p class=3D"MsoNormal">Can you please help me with this issue, im really bl=
ocked :/<o:p></o:p></p>
<p class=3D"MsoNormal"><span style=3D"font-size:12.0pt;font-family:&quot;Ti=
mes 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_CY4PR0101MB288879427BC5D7A635563A8F98000CY4PR0101MB2888_--