[Nagiosplug-help] Patch to fix apan's problem with spaces

jeff vier jeff.vier at tradingtechnologies.com
Tue Sep 23 08:08:07 CEST 2003


I was having a heck of a time figuring out what Apan wanted from me when
it came to services with spaces (the Ping service was my first Apan
conversion - it went great.  Drive Space C didn't go so well...)

I poured over apan.cgi a bit and it was immediately clear.  So, a few
hacks later, and I got it to behave.  It was confused between " " and
"%20", so I had to change it to two variables (it needs %20 in
URLs/image sources).

here's the patch (copy apan.cgi to apan.cgi.orig):
----cut here-------
--- apan.cgi.orig       2003-09-23 10:00:06.000000000 -0500
+++ apan.cgi    2003-09-23 09:58:29.000000000 -0500
@@ -14,7 +14,8 @@
 . $DEFSFILE
 # Get the params from the called URL
 HOST=`echo $QUERY_STRING|cut -d "&" -f 1|cut -d "=" -f 2`
-CHECK=`echo $QUERY_STRING|cut -d "&" -f 2|cut -d "=" -f 2`
+CHECK=`echo $QUERY_STRING|sed 's/%20/ /'|cut -d "&" -f 2|cut -d "=" -f
2`
+CHECK_NO_SPACES=`echo $QUERY_STRING|cut -d "&" -f 2|cut -d "=" -f 2`

 #Get the entry for this host/service from the config-file
 CONF=`egrep "^$HOST;$CHECK" $CFGFILE`
@@ -63,38 +64,38 @@

        if [ $N -ne 2 ]; then
                echo "Statistics for the last 10 minutes:<BR>"
-               echo "<IMG SRC=generate.cgi?$HOST&$CHECK&600><BR>"
+               echo "<IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&600><BR>"
                echo "Statistics for the last hour:<BR>"
-               echo "<IMG SRC=generate.cgi?$HOST&$CHECK&3600><BR>"
+               echo "<IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&3600><BR>"
                echo "Statistics for the last 24 hours:<BR>"
-               echo "<IMG SRC=generate.cgi?$HOST&$CHECK&86400><BR>"
+               echo "<IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&86400><BR>"
                echo "Statistics for the last week:<BR>"
-               echo "<IMG SRC=generate.cgi?$HOST&$CHECK&604800><BR>"
+               echo "<IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&604800><BR>"
                echo "Statistics for the last Month:<BR>"
-               echo "<IMG SRC=generate.cgi?$HOST&$CHECK&2851200><BR>"
+               echo "<IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&2851200><BR>"
                echo "Statistics for the last Year:<BR>"
-               echo "<IMG SRC=generate.cgi?$HOST&$CHECK&31557600><BR>"
+               echo "<IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&31557600><BR>"
        else
                echo "<TABLE COLS=2 BORDER=1>"
                echo "<TR><TD COLSPAN=2>Statistics for the last 10
minutes:</TD></TR>"
-               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK&600&0></TD>"
-               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK&300&1></TD></TR>"
+               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&600&0></TD>"
+               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&300&1></TD></TR>"
                echo "<TR><TD COLSPAN=2>Statistics for the last
hour:</TD></TR>"
-               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK&3600&0></TD>"
-               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK&3600&1></TD></TR>"
+               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&3600&0></TD>"
+               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&3600&1></TD></TR>"
                echo "<TR><TD COLSPAN=2>Statistics for the last 24
hours:</TD></TR>"
-               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK&86400&0><BR></TD>"
-               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK&86400&1></TD></TR>"
+               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&86400&0><BR></TD>"
+               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&86400&1></TD></TR>"
                echo "<TR><TD COLSPAN=2>Statistics for the last
week:</TD></TR>"
-               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK&604800&0></TD>"
-               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK&604800&1></TD></TR>"
+               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&604800&0></TD>"
+               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&604800&1></TD></TR>"

                echo "<TR><TD COLSPAN=2>Statistics for the last
month:</TD></TR>"
-               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK&2851200&0></TD>"
-               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK&2851200&1></TD></TR>"
+               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&2851200&0></TD>"
+               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&2851200&1></TD></TR>"
                echo "<TR><TD COLSPAN=2>Statistics for the last
year:</TD></TR>"
-               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK&31557600&0></TD>"
-               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK&31557600&1></TD></TR>"
+               echo "<TR><TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&31557600&0></TD>"
+               echo "<TD><IMG
SRC=generate.cgi?$HOST&$CHECK_NO_SPACES&31557600&1></TD></TR>"
                echo "</TABLE>"
        fi
-----cut here------





More information about the Help mailing list