<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=iso-8859-1">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY style="MARGIN: 4px 4px 1px; FONT: 10pt Tahoma">
<DIV>I may be missing something here, but why not use perl to do the whole thing. Just use the Net::SNMP module and use "get_table()".</DIV>
<DIV> </DIV>
<DIV><A href="http://search.cpan.org/~dtown/Net-SNMP-5.2.0/lib/Net/SNMP.pm">http://search.cpan.org/~dtown/Net-SNMP-5.2.0/lib/Net/SNMP.pm</A></DIV>
<DIV> </DIV>
<DIV>Just my $0.02</DIV>
<DIV> </DIV>
<DIV>Marlo<BR><BR>>>> <Ralph.Grothe@itdz-berlin.de> 11/10/2006 1:34 AM >>><BR>If it's a deep snmpwalk I would avoid the push on @result<BR>but do the parsing already in the while loop over the open pipe.<BR><BR>> -----Original Message-----<BR>> From: <U><A href="mailto:nagiosplug-help-bounces@lists.sourceforge.net">nagiosplug-help-bounces@lists.sourceforge.net</A></U> <BR>> <U><A href="mailto:[mailto:nagiosplug-help-bounces@lists.sourceforge.net]On">[mailto:nagiosplug-help-bounces@lists.sourceforge.net]On</A></U> Behalf<BR>Of<BR>> Andreas Baetz<BR>> Sent: Friday, November 10, 2006 7:22 AM<BR>> To: <U><A href="mailto:nagiosplug-help@lists.sourceforge.net">nagiosplug-help@lists.sourceforge.net</A></U> <BR>> Subject: Re: [Nagiosplug-help] Avoiding tmp-files for<BR>SNMP-check<BR>> <BR>> <BR>> On Thursday 09 November 2006 20:33, Ingo Lantschner wrote:<BR>> > Hello,<BR>> > I wrote a plugin to check the fanstatus in !
FuSi Se
rvers. <BR>> The complete <BR>> > script is attached at the end of this email.<BR>> > <BR>> > The plugin works, but what I dont like so much ist this part:<BR>> > OUTPUT=/tmp/$1-fancheck.tmp<BR>> > snmpwalk -mAll -v1 -c $2 $1 <BR>> 1.3.6.1.4.1.231.2.10.2.2.5.2.2.1 > $OUTPUT<BR>> > <BR>> > Using tempfile is not recommended according to the<BR>guidelines for <BR>> > nagiosplugins. But how can I store a "multiline-variable" <BR>> and "grep" <BR>> > single lines of it later on?<BR>> > <BR>> > For the moment I do it like this:<BR>> > FANSPRESENT=$(grep fanStatus $OUTPUT | grep -v unknown | \<BR>> > cut -d " " -f1 | cut -d \. -f2-3)<BR>> > for FID in $FANSPRESENT; do<BR>> > FNAME=$(cat $OUTPUT | grep fans.16.$FID | cut<BR>-d: -f4)<BR>> > ...<BR>> > <BR>> > May be some of you already came over this prblem - thanks for<BR>any <BR>> > hint! Ingo.<BR>> <BR>&!
gt; You
could use perl like that:<BR>> <BR>> --------------------------------------------------------------<BR>> -----------------<BR>> /usr/bin/perl -w<BR>> my cmd="/path/command";<BR>> my @result; # holds the output of your command<BR>> open IN, "$command |" or die "Can't run $command: $!";<BR>> while (<IN>) {<BR>> # $_ holds the lines of output of the command<BR>> # remove CR/LF<BR>> chomp;<BR>> push (@result, $_);<BR>> }<BR>> <BR>> # do something with the output:<BR>> foreach (@result) { <BR>> # $_ holds the lines of output of the command<BR>> if (/searchstring/i) {<BR>> # etc, etc<BR>> }<BR>> }<BR>> --------------------------------------------------------------<BR>> -----------------<BR>> <BR>> Andreas<BR>> <BR>> <BR>><BR>*****************************************************************<BR>*****<BR>> This email and any files transmitted with it are confidential<BR>and<BR>> intended !
solely
for the use of the individual or entity to whom<BR>they<BR>> are addressed. If you have received this email in error please<BR>notify<BR>> the system manager.<BR>><BR>*****************************************************************<BR>*****<BR>> <BR>> <BR>> --------------------------------------------------------------<BR>> -----------<BR>> Using Tomcat but need to do more? Need to support web <BR>> services, security?<BR>> Get stuff done quickly with pre-integrated technology to make <BR>> your job easier<BR>> Download IBM WebSphere Application Server v.1.0.1 based on <BR>> Apache Geronimo<BR>> <U></U><A href="about:blank"></A><BR>dat=121642<BR>_______________________________________________<BR>Nagiosplug-help mailing list<BR><U><A href="mailto:Nagiosplug-help@lists.sourceforge.net">Nagiosplug-help@lists.sourceforge.net</A></U> <BR><U><A href="https://lists.sourceforge.net/lists/listinfo/nagiosplug-help">https://lists.sourceforge.n!
et/list
s/listinfo/nagiosplug-help</A></U> <BR>::: Please include plugins version (-v) and OS when reporting any<BR>issue. <BR>::: Messages without supporting info will risk being sent to<BR>/dev/null<BR><BR>-------------------------------------------------------------------------<BR>Using Tomcat but need to do more? Need to support web services, security?<BR>Get stuff done quickly with pre-integrated technology to make your job easier<BR>Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo<BR><U><A href="http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642">http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642</A></U> <BR>_______________________________________________<BR>Nagiosplug-help mailing list<BR><U><A href="mailto:Nagiosplug-help@lists.sourceforge.net">Nagiosplug-help@lists.sourceforge.net</A></U> <BR><U><A href="https://lists.sourceforge.net/lists/listinfo/nagiosplug-help">https://lists.so!
urcefor
ge.net/lists/listinfo/nagiosplug-help</A></U> <BR>::: Please include plugins version (-v) and OS when reporting any issue. <BR>::: Messages without supporting info will risk being sent to /dev/null<BR></DIV>
<HR>NOTICE: This email message is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. If you are not the intended recipient, please contact the sender by reply email and destroy all copies of the original message.<BR>
</BODY></HTML>