[Nagiosplug-help] Avoiding tmp-files for SNMP-check
Ralph.Grothe at itdz-berlin.de
Ralph.Grothe at itdz-berlin.de
Fri Nov 10 09:34:47 CET 2006
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
> 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
More information about the Help
mailing list