[Nagiosplug-help] Avoiding tmp-files for SNMP-check

Marlo Bell BellMR at ldschurch.org
Fri Nov 10 17:06:40 CET 2006


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()".
 
http://search.cpan.org/~dtown/Net-SNMP-5.2.0/lib/Net/SNMP.pm 
 
Just my $0.02
 
Marlo

>>> <Ralph.Grothe at itdz-berlin.de> 11/10/2006 1:34 AM >>>
If it's a deep snmpwalk I would avoid the push on @result
but do the parsing already in the while loop over the open pipe.

> -----Original Message-----
> From: nagiosplug-help-bounces at lists.sourceforge.net 
> [mailto:nagiosplug-help-bounces at lists.sourceforge.net]On Behalf
Of
> Andreas Baetz
> Sent: Friday, November 10, 2006 7:22 AM
> To: nagiosplug-help at lists.sourceforge.net 
> Subject: Re: [Nagiosplug-help] Avoiding tmp-files for
SNMP-check
> 
> 
> On Thursday 09 November 2006 20:33, Ingo Lantschner wrote:
> > Hello,
> > I wrote a plugin to check the fanstatus in FuSi Servers. 
> The complete 
> > script is attached at the end of this email.
> > 
> > The plugin works, but what I dont like so much ist this part:
> > OUTPUT=/tmp/$1-fancheck.tmp
> > snmpwalk -mAll -v1 -c $2 $1 
> 1.3.6.1.4.1.231.2.10.2.2.5.2.2.1 > $OUTPUT
> > 
> > Using tempfile is not recommended according to the
guidelines for 
> > nagiosplugins. But how can I store a "multiline-variable" 
> and "grep" 
> > single lines of it later on?
> > 
> > For the moment I do it like this:
> > FANSPRESENT=$(grep fanStatus $OUTPUT | grep -v unknown | \
> > cut -d " " -f1 | cut -d \. -f2-3)
> > for FID in $FANSPRESENT; do
> > FNAME=$(cat $OUTPUT | grep fans.16.$FID | cut
-d: -f4)
> > ...
> > 
> > May be some of you already came over this prblem - thanks for
any 
> > hint! Ingo.
> 
> You could use perl like that:
> 
> --------------------------------------------------------------
> -----------------
> /usr/bin/perl -w
> my cmd="/path/command";
> my @result; # holds the output of your command
> open IN, "$command |" or die "Can't run $command: $!";
> while (<IN>) {
> # $_ holds the lines of output of the command
> # remove CR/LF
> chomp;
> push (@result, $_);
> }
> 
> # do something with the output:
> foreach (@result) { 
> # $_ holds the lines of output of the command
> if (/searchstring/i) {
> # etc, etc
> }
> }
> --------------------------------------------------------------
> -----------------
> 
> Andreas
> 
> 
>
*****************************************************************
*****
> This email and any files transmitted with it are confidential
and
> intended solely for the use of the individual or entity to whom
they
> are addressed. If you have received this email in error please
notify
> the system manager.
>
*****************************************************************
*****
> 
> 
> --------------------------------------------------------------
> -----------
> Using Tomcat but need to do more? Need to support web 
> services, security?
> Get stuff done quickly with pre-integrated technology to make 
> your job easier
> Download IBM WebSphere Application Server v.1.0.1 based on 
> Apache Geronimo
> 
dat=121642
_______________________________________________
Nagiosplug-help mailing list
Nagiosplug-help at lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/nagiosplug-help 
::: Please include plugins version (-v) and OS when reporting any
issue. 
::: Messages without supporting info will risk being sent to
/dev/null

-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642 
_______________________________________________
Nagiosplug-help mailing list
Nagiosplug-help at lists.sourceforge.net 
https://lists.sourceforge.net/lists/listinfo/nagiosplug-help 
::: Please include plugins version (-v) and OS when reporting any issue. 
::: Messages without supporting info will risk being sent to /dev/null

----------------------------------------------------------------------
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://www.monitoring-plugins.org/archive/help/attachments/20061110/b8ea13fe/attachment.html>


More information about the Help mailing list