[prev in list] [next in list] [prev in thread] [next in thread] 

List:       nagiosplug-help
Subject:    [Nagiosplug-help] Bizarre xml file issue in pnp4nagios
From:       Jeff S <jeff80 () gmail ! com>
Date:       2011-06-08 20:12:17
Message-ID: BANLkTika6QMz9Dz5Fmkqf71wtdE3_udDDg () mail ! gmail ! com
[Download RAW message or body]

[Attachment #2 (multipart/alternative)]


Howdy,

I'm running Nagios Version 3.2.0 and I've got a very odd issue with Nagios
PNP with stats collection.


We run about 30 instances of Clammy on the server being checked. I have a
script which basically collects data about each instance of Clammy from a PS
command, parses the data and outputs to Nagios.
I pass specific dataset values via a pipe | to Perfdata and everything works
great...as long as I don't try to get data on more than 2 instances of
Clammy.

For example, here's the value of Performance Data when checking only 2
Clammys:

Clam_num=1;Scan_%=68.5;Scan_num=1943;Cache_%=31.5;Cache_num=895;Scan_per_sec=9.5;
Clam_num=2;Scan_%=66.7;Scan_num=2552;Cache_%=33.3;Cache_num=1273;Scan_per_sec=12.8;

That works great, and PNP graphs the values just fine. However, if I make
the check for 3 Clammys, I get the following output:

Clam_num=1;Scan_%=68.5;Scan_num=1943;Cache_%=31.5;Cache_num=895;Scan_per_sec=9.5;
Clam_num=2;Scan_%=66.7;Scan_num=2552;Cache_%=33.3;Cache_num=1273;Scan_per_sec=12.8;
Clam_num:3 Scan_%:67.3 Scan_num:6474 Cache_%:32.7 Cache_num:3143
Scan/sec:32.1 |
Clam_num=3;Scan_%=67.3;Scan_num=6474;Cache_%=32.7;Cache_num=3143;Scan_per_sec=32.1;

As you can see, the parser suddenly decides that for Clam_num 3 it's going
to insert both the status and performance data into the DS of what should
only be performance data.

When I look at the XML file, the DS that should just contain the value "3"
for Clam_num actually contains the entire string of:
"Clam_num:3 Scan_%:67.3 Scan_num:6474 Cache_%:32.7 Cache_num:3143
Scan/sec:32.1 |
Clam_num=3;Scan_%=67.3;Scan_num=6474;Cache_%=32.7;Cache_num=3143;Scan_per_sec=32.1;"

Even stranger, the DS values that follow resume correctly and contain what
they should. e.g. The scan_% value for Clam 3 is correct, the Scan_num value
is correct, etc.

Am I missing something here or is this the twilight zone?


PHP script on the Nagios box:

$ds_name[1] = " statistics"; $opt[1] = "-M --title \"Clam stat check for
$hostname\" --height=250 --width=800 "; $def[1] = "";

$colors = array(

            'Clam_num' => '#F90303',
            'Scan_%' => '#FC4A4A',
            'Scan_num' => '#FC8A8A',
            'Cache_%' => '#FBBCBC',
            'Cache_num' => '#F906F5',
            'Scan_per_sec' => '#F87BF6',

            );

$keys = array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18); foreach( $keys
as $key){ $def[1] .= "DEF:var$key=$rrdfile:$DS[$key]:AVERAGE " ; $def[1] .=
"LINE:var$key".$colors[$NAME[$key]].":\"$NAME[$key]\t\" " ; $def[1] .=
"GPRINT:var$key:LAST:\"%1.0lf Max\" "; }

?>


Check script that runs on the client and collects the data:

#!/bin/bash

ECHO=/bin/echo CUT=/usr/bin/cut GREP=/bin/grep SORT=/usr/bin/sort

F=/var/log/purewire.log rm /tmp/AVS_clam_*

pid_list=ps axu | $GREP clammy | $GREP -v grep | awk '{print $2}'

c=0 for x in $pid_list ; do

    let c=c+1

    entry=`$GREP "clammy\[$x\]" $F | $GREP "scan stats" | $SORT | tail -1`

    ## AVSCAN data
    AVSCAN=`$ECHO "$entry" | $CUT -s -d" " -f10`
    Scan_p=`$ECHO $AVSCAN | $CUT -s -d"|" -f 2`
    Scan_num=`$ECHO $AVSCAN | $CUT -s -d"|" -f 3 | $CUT -d">" -f 1`

    ## CACHE data
    CACHE=`$ECHO "$entry" | $CUT -s -d" " -f11`
    Cache_p=`$ECHO $CACHE | $CUT -s -d"|" -f 2`
    Cache_num=`$ECHO $CACHE | $CUT -s -d"|" -f 3 | $CUT -d">" -f 1`

    ## Throughput data
    TPUT=`$ECHO "$entry" | $CUT -s -d" " -f14`
    Scan_sec=`$ECHO $TPUT | $CUT -s -d"|" -f 2`

    let Tot=Scan_num+Cache_num

#echo "Scan %: $Scan_p  Number Scanned: $Scan_num"
#echo "Cache %: $Cache_p  Cache hits: $Cache_num"
#echo "Scans per Sec: $Scan_sec   Total Scanned: $Tot"

    #echo $c,$Scan_p,$Scan_num,$Cache_p,$Cache_num,$Scan_sec
    if [[ $c -le 3 ]]; then
    echo $c,$Scan_p,$Scan_num,$Cache_p,$Cache_num,$Scan_sec >>
/tmp/AVS_clam_"$c"_stats
            clammy=`awk -F"," '{ print "Clam_num:" $1 " Scan_%:" $2 "
Scan_num:" $3 " Cache_%:" $4 " Cache_num:" $5 " Scan/sec:" $6 " | Clam_num="
$1 ";Scan_%=" $2 ";Scan_num=" $3 ";Cache_%=" $4 ";Cache_num=" $5
";Scan_per_sec=" $6 ";"}' /tmp/AVS_clam_"$c"_stats`
    echo $clammy
    else
    exit
    fi

done exit 0

[Attachment #5 (text/html)]

Howdy,<br><br>I&#39;m running Nagios Version 3.2.0 and I&#39;ve got a very odd issue \
with Nagios PNP with stats collection.<br><br><br>We run about 30 instances of Clammy \
on the server being checked. I have a script which basically collects data about each \
instance of Clammy from a PS command, parses the data and outputs to Nagios.<br> I \
pass specific dataset values via a pipe | to Perfdata and everything works great...as \
long as I don&#39;t try to get data on more than 2 instances of Clammy.<br><br>For \
example, here&#39;s the value of Performance Data when checking only 2 Clammys:<br> \
<br>Clam_num=1;Scan_%=68.5;Scan_num=1943;Cache_%=31.5;Cache_num=895;Scan_per_sec=9.5; \
Clam_num=2;Scan_%=66.7;Scan_num=2552;Cache_%=33.3;Cache_num=1273;Scan_per_sec=12.8;<br><br>That \
works great, and PNP graphs the values just fine. However, if I make the check for 3 \
Clammys, I get the following output:<br> \
<br>Clam_num=1;Scan_%=68.5;Scan_num=1943;Cache_%=31.5;Cache_num=895;Scan_per_sec=9.5; \
Clam_num=2;Scan_%=66.7;Scan_num=2552;Cache_%=33.3;Cache_num=1273;Scan_per_sec=12.8; \
Clam_num:3 Scan_%:67.3 Scan_num:6474 Cache_%:32.7 Cache_num:3143 Scan/sec:32.1 | \
Clam_num=3;Scan_%=67.3;Scan_num=6474;Cache_%=32.7;Cache_num=3143;Scan_per_sec=32.1;<br>
 <br>As you can see, the parser suddenly decides that for Clam_num 3 it&#39;s going \
to insert both the status and performance data into the DS of what should only be \
performance data.<br><br>When I look at the XML file, the DS that should just contain \
the value &quot;3&quot; for Clam_num actually contains the entire string of: <br> \
&quot;Clam_num:3 Scan_%:67.3 Scan_num:6474 Cache_%:32.7 Cache_num:3143 Scan/sec:32.1 \
| Clam_num=3;Scan_%=67.3;Scan_num=6474;Cache_%=32.7;Cache_num=3143;Scan_per_sec=32.1;&quot;<br><br>Even \
stranger, the DS values that follow resume correctly and contain what they should. \
e.g. The scan_% value for Clam 3 is correct, the Scan_num value is correct, etc.<br> \
<br>Am I missing something here or is this the twilight zone?<br><br><br>PHP script \
on the Nagios box:<br><br>$ds_name[1] = &quot; statistics&quot;; $opt[1] = &quot;-M \
--title \&quot;Clam stat check for $hostname\&quot; --height=250 --width=800 &quot;; \
$def[1] = &quot;&quot;;<br> <br>$colors = array(<br><br>            \
&#39;Clam_num&#39; =&gt; &#39;#F90303&#39;,<br>            &#39;Scan_%&#39; =&gt; \
&#39;#FC4A4A&#39;,<br>            &#39;Scan_num&#39; =&gt; &#39;#FC8A8A&#39;,<br>     \
&#39;Cache_%&#39; =&gt; &#39;#FBBCBC&#39;,<br>  &#39;Cache_num&#39; =&gt; \
&#39;#F906F5&#39;,<br>            &#39;Scan_per_sec&#39; =&gt; \
&#39;#F87BF6&#39;,<br><br>            );<br><br>$keys = \
array(1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18); foreach( $keys as $key){ $def[1] \
.= &quot;DEF:var$key=$rrdfile:$DS[$key]:AVERAGE &quot; ; $def[1] .= \
&quot;LINE:var$key&quot;.$colors[$NAME[$key]].&quot;:\&quot;$NAME[$key]\t\&quot; \
&quot; ; $def[1] .= &quot;GPRINT:var$key:LAST:\&quot;%1.0lf Max\&quot; &quot;; }<br> \
<br>?&gt;<br><br><br>Check script that runs on the client and collects the \
data:<br><br>#!/bin/bash<br><br>ECHO=/bin/echo CUT=/usr/bin/cut GREP=/bin/grep \
SORT=/usr/bin/sort<br><br>F=/var/log/purewire.log rm /tmp/AVS_clam_*<br> \
<br>pid_list=ps axu | $GREP clammy | $GREP -v grep | awk &#39;{print \
$2}&#39;<br><br>c=0 for x in $pid_list ; do<br><br>    let c=c+1<br><br>    \
entry=`$GREP &quot;clammy\[$x\]&quot; $F | $GREP &quot;scan stats&quot; | $SORT | \
tail -1`<br> <br>    ## AVSCAN data<br>    AVSCAN=`$ECHO &quot;$entry&quot; | $CUT -s \
-d&quot; &quot; -f10`<br>    Scan_p=`$ECHO $AVSCAN | $CUT -s -d&quot;|&quot; -f \
2`<br>    Scan_num=`$ECHO $AVSCAN | $CUT -s -d&quot;|&quot; -f 3 | $CUT \
-d&quot;&gt;&quot; -f 1`<br> <br>    ## CACHE data<br>    CACHE=`$ECHO \
&quot;$entry&quot; | $CUT -s -d&quot; &quot; -f11`<br>    Cache_p=`$ECHO $CACHE | \
$CUT -s -d&quot;|&quot; -f 2`<br>    Cache_num=`$ECHO $CACHE | $CUT -s \
-d&quot;|&quot; -f 3 | $CUT -d&quot;&gt;&quot; -f 1`<br> <br>    ## Throughput \
data<br>    TPUT=`$ECHO &quot;$entry&quot; | $CUT -s -d&quot; &quot; -f14`<br>    \
Scan_sec=`$ECHO $TPUT | $CUT -s -d&quot;|&quot; -f 2`<br><br>    let \
Tot=Scan_num+Cache_num<br><br>#echo &quot;Scan %: $Scan_p  Number Scanned: \
$Scan_num&quot;<br> #echo &quot;Cache %: $Cache_p  Cache hits: \
$Cache_num&quot;<br>#echo &quot;Scans per Sec: $Scan_sec   Total Scanned: \
$Tot&quot;<br><br>    #echo $c,$Scan_p,$Scan_num,$Cache_p,$Cache_num,$Scan_sec<br>    \
if [[ $c -le 3 ]]; then<br>  echo $c,$Scan_p,$Scan_num,$Cache_p,$Cache_num,$Scan_sec \
&gt;&gt; /tmp/AVS_clam_&quot;$c&quot;_stats<br>            clammy=`awk \
-F&quot;,&quot; &#39;{ print &quot;Clam_num:&quot; $1 &quot; Scan_%:&quot; $2 &quot; \
Scan_num:&quot; $3 &quot; Cache_%:&quot; $4 &quot; Cache_num:&quot; $5 &quot; \
Scan/sec:&quot; $6 &quot; | Clam_num=&quot; $1 &quot;;Scan_%=&quot; $2 \
&quot;;Scan_num=&quot; $3 &quot;;Cache_%=&quot; $4 &quot;;Cache_num=&quot; $5 \
&quot;;Scan_per_sec=&quot; $6 &quot;;&quot;}&#39; \
/tmp/AVS_clam_&quot;$c&quot;_stats`<br>  echo $clammy<br>    else<br>    exit<br>    \
fi<br><br>done exit 0<br><br>



------------------------------------------------------------------------------
EditLive Enterprise is the world's most technically advanced content
authoring tool. Experience the power of Track Changes, Inline Image
Editing and ensure content is compliant with Accessibility Checking.
http://p.sf.net/sfu/ephox-dev2dev

_______________________________________________
Nagiosplug-help mailing list
Nagiosplug-help@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


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic