Nagios Ping Tool - Another Hack

line Tags: ,

I’ve received a patch from ed.davison, if you have commented out hosts in your config, you’ll get odd \”address - hostname\” results in the drop down list. Ed’s patch fixes that; thankx :-D

At the moment you’d have to apply the patch your self from the below; but I have a official revision in the pipeline.

-- readhosts.php       2005/11/09 18:07:43     1.1
+++ readhosts.php       2005/11/09 18:08:12
@@ -23,16 +23,20 @@

       $current = trim($line);

-       if (preg_match (\"/addres/\", \"$current\")) {
-               $keywords = preg_split (\"/[\\s,]+/\", \"$current\");
-               $ipaddress[$counter] = $keywords[1];
-               $counter++;
-       }
-
-       if (preg_match (\"/host_name/\", \"$current\")) {
-               $keywords = preg_split (\"/[\\s,]+/\", \"$current\");
-               $node_name[$counter2] = $keywords[1];
-               $counter2++;
+       if (!preg_match (\"/^#/\", \"$current\")) {
+
+               if (preg_match (\"/addres/\", \"$current\")) {
+                       $keywords = preg_split (\"/[\\s,]+/\", \"$current\");
+                       $ipaddress[$counter] = $keywords[1];
+                       $counter++;
+               }
+
+               if (preg_match (\"/host_name/\", \"$current\")) {
+                       $keywords = preg_split (\"/[\\s,]+/\", \"$current\");
+                       $node_name[$counter2] = $keywords[1];
+                       $counter2++;
+               }
+
       }
nick

 

2 Comments

  1. crest Says:

    what is this host file?…..
    what does it contain?

  2. [NICK] Says:

    Hi Crest, your comment isn’t a clear.
    There are two host files you could be referning to, 1 the unix etc hosts or 2 the nagios config file that contains a list of hosts for the configuration.
    I hope these links have been some use.

Got something to say?

 

Some other things that might interest you...

---