This patch will work for both Nagios and Icinga 1.0.3
JES

} See attached. Basically it looks like the table is down one deeper.
}
} This patch is not backward compatible :(.
}
} JES

 Hi all,

 I stopped the migration from Nagios 3.2.0 to Icinga 1.0.3 since the
 wonderful nagstamon [1] tool does not work.

The nagstamon developer says:

 I alreday got some mail regarding this issue and have it on my todo
 list. I think they changed something in the final HTML structure on the
 services page which nagstamon seems not being able to parse as it does
 with original Nagios generated pages. The pages get parsed in
 nagstamonObjects.py in method GetStatusNagios() from class NagiosServer.
 There simply needs to be a modified version for Icinga I think. At the
 moment I am not able to do this because of a bunch of other work to do
 but I hope I will be able to do so in some weeks.

Any python-savvy folk here who has an interest in building a patch for
nagstamon?

[1]http://nagstamon.sourceforge.net/

Bye,
Peter


--- nagstamonObjects.py.old	2010-06-15 06:01:57.000000000 -0300
+++ nagstamonObjects.py	2010-09-13 15:11:06.358425276 -0300
@@ -7,6 +7,7 @@
 import socket
 import gc
 import copy
+import re
 
 try:
     import lxml.etree, lxml.objectify
@@ -393,10 +394,20 @@
         try:
             htobj = self.FetchURL(nagcgiurl_services)
 
-            for i in range(1, len(htobj.body.table[2].tr)):
+	    offset = 2
+	    try:
+		match = re.search('nagios', str(htobj.body.table.tr.td.table.tr.td.a))
+		if match:
+			offset = 2
+		else:
+			offset = 3
+	    except:
+		print "Application name check not workng"
+
+            for i in range(1, len(htobj.body.table[offset].tr)):
                 try:
                     # ignore empty <tr> rows - there are a lot of them - a Nagios bug? 
-                    if not htobj.body.table[2].tr[i].countchildren() == 1:
+                    if not htobj.body.table[offset].tr[i].countchildren() == 1:
                         n = {}
                         # host
                         # the resulting table of Nagios status.cgi table omits the
@@ -404,21 +415,21 @@
                         # so if the hostname is empty the nagios status item should get
                         # its hostname from the previuos item - one reason to keep "nagitems"
                         try:
-                            n["host"] = str(htobj.body.table[2].tr[i].td[0].table.tr.td.table.tr.td.a.text)
+                            n["host"] = str(htobj.body.table[offset].tr[i].td[0].table.tr.td.table.tr.td.a.text)
                         except:
                             n["host"] = str(nagitems["services"][len(nagitems["services"])-1]["host"])
                         # service
-                        n["service"] = str(htobj.body.table[2].tr[i].td[1].table.tr.td.table.tr.td.a.text)
+                        n["service"] = str(htobj.body.table[offset].tr[i].td[1].table.tr.td.table.tr.td.a.text)
                         # status
-                        n["status"] = str(htobj.body.table[2].tr[i].td[2].text)
+                        n["status"] = str(htobj.body.table[offset].tr[i].td[2].text)
                         # last_check
-                        n["last_check"] = str(htobj.body.table[2].tr[i].td[3].text)
+                        n["last_check"] = str(htobj.body.table[offset].tr[i].td[3].text)
                         # duration
-                        n["duration"] = str(htobj.body.table[2].tr[i].td[4].text)
+                        n["duration"] = str(htobj.body.table[offset].tr[i].td[4].text)
                         # attempt
-                        n["attempt"] = str(htobj.body.table[2].tr[i].td[5].text)
+                        n["attempt"] = str(htobj.body.table[offset].tr[i].td[5].text)
                         # status_information
-                        n["status_information"] = str(htobj.body.table[2].tr[i].td[6].text)
+                        n["status_information"] = str(htobj.body.table[offset].tr[i].td[6].text)
                         # add dictionary full of information about this service item to nagitems - only if service
                         nagitems["services"].append(n)
                         
------------------------------------------------------------------------------
Start uncovering the many advantages of virtual appliances
and start using them to simplify application deployment and
accelerate your shift to cloud computing
http://p.sf.net/sfu/novell-sfdev2dev
_______________________________________________
icinga-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/icinga-users

Reply via email to