Nov 28, 2011 6:42 PM
Need Some Advice: Currently developing ZenPack to monitor Windows Services via SNMP
-
Like (0)
I'm currently developing a ZenPack for monitoring Windows Services via SNMP. I'm starting with developing the interface for 2.5 and will also make sure that it's fully compatible with the 3.x interface before release.
I've run in to a snag with the way that Microsoft does the SNMP for this. The OIDs for the Services are made up from the name of the services. Each number in the OID after a certain point represents a character in the name of the service. There is also an OID that represents the status of the process.
For example, the OID for the "FileZilla Server FTP server" Service status would be:
1.3.6.1.4.1.77.1.2.3.1.3.27.70.105.108.101.90.105.108.108.97.32.83.101.114.118.101.114.32.70.84.80.32.115.101.114.118.101.114
Where 1.3.6.1.4.1.77.1.2.3.1.3.27 is the index OID for status values and 70.105.108.101.90.105.108.108.97.32.83.101.114.118.101.114.32.70.84.80.32.115.101.114.118.101.114 is the part of the OID representing the service.
70 | 105 | 108 | 101 | 90 | 105 | 108 | 108 | 97 | 32 | 83 | 101 | 114 | 118 | 101 | 114 | 32 | 70 | 84 | 80 | 32 | 115 | 101 | 114 | 118 | 101 | 114 |
F | i | l | e | Z | i | l | l | a | S | e | r | v | e | r | F | T | P | s | e | r | v | e | r |
The nice part about them doing the OIDs this way is that you're never going to end up with bad OIDs for services since they never change for any particular service. The bad part is that, instead of changing the status value when a service is stopped, they actually represent the service as being stopped by removing it from the SNMP index/table. This means that instead of receiving a status value other than 1, I end up receiving a debug event in Zenoss. As a temporary measure I'm using a command datasource that sends a value of 0 when the OID doesn't return a value, but I can't keep it that way because it definitely won't scale well at all.
Does anyone have any good idea of how I might be able to do this without having to write a new datasource type and daemon? I would really like to avoid doing so over simply returning a 0 value. Any suggestions would be greatly appreciated.
Here is a preview of what I have done so far. The collector plugin that I wrote works lovely, and it identified and saves the snmpindex value for each of the services. It really all boils down to getting the polling working efficiently and fixing up the skin before it's ready to go. I need to build locking capability in because if an automated remodel were to kick off while a service is down, it would end up removing the service from the list, which is obviously undersirable. I also plan on adding a zProperty where Service names can be input to be automatically omitted during modelling.
Ryan:
Very tricky problem. Since you're just checking the existence of the OID I might suggest a test that instead of using zenperfsnmp uses snmpget and parses for a successful or failure in the reply.
--Shane
I already have it configured to use the following script:
#!/bin/bash
status=$(snmpget -On -Cf -v2c -c $1 $2 1.3.6.1.4.1.77.1.2.3.1.3.$3 2>/dev/null | cut -d ":" -f 2 | cut -d ' ' -f 2)
if [[ "$status" == "1" ]]
then
echo "|ServiceStatus=1"
else
echo "|ServiceStatus=0"
fi
It works, the problem is that it's not going to scale well... i.e: 50 services * 300 servers = 15000 OIDs == 15000 scripts kicking off each cycle.
Ryan:
I agree, it won't scale hardly at all. I'll keep thinking but I think you're probably going to need to create a daemon for this.
--Shane
So I've been working full days on this pack the last 2 days and got a lot done. The 2.5 UI portion is done including the ability to toggle locking/monitoring. The daemon is done and working. I'm going to work on the 3.x UI portion tomorrow. Once that's done I just need to write the code that will allow services to be globally enabled/disabled for monitoring and then the pack will be ready for release.
Here are some screenshots of what I coded today:
Awesome. This will work without any permission issues that plague WMI. Now if only Windows would include a syslog daemon for event logs rather than needing 3rd party, and we basically wouldn't need to futz with WMI.
--
James Pulver
ZCA Member
LEPP Computer Group
Cornell University
I wish that Microsoft would just ditch WMI and use SNMP/Syslog for everything. It would be a hell of a lot more reliable.
Ryan:
Sounds great! I wouldn't hold your breath for the death of WMI...we'll just have to hope it dies on its own one day.
Good to hear the locking is working now. Let me know if I can help with anything else.
Best,
--Shane (Hackman238)
I've run in to a snag which I've yet to solve. The collector plugin that I wrote works perfectly fine in Zenoss 2.5, but when it comes time to parse the data in Zenoss 3.2.1 I get the following traceback from zenhub:
2012-01-07 23:07:51,735 DEBUG zen.Plugins: Loading collector plugins from: /usr/local/zenoss/zenoss/Products/ZenRRD/parsers
Traceback (most recent call last):
File "/usr/local/zenoss/zenoss/Products/ZenHub/zenhub.py", line 658, in <module>
z.main()
File "/usr/local/zenoss/zenoss/Products/ZenHub/zenhub.py", line 625, in main
reactor.run()
File "/usr/local/zenoss/python/lib/python2.6/site-packages/Twisted-8.1.0-py2.6-linux-x86_64.egg/twisted/internet/base.py", line 1048, in run
self.mainLoop()
File "/usr/local/zenoss/python/lib/python2.6/site-packages/Twisted-8.1.0-py2.6-linux-x86_64.egg/twisted/internet/base.py", line 1057, in mainLoop
self.runUntilCurrent()
--- <exception caught here> ---
File "/usr/local/zenoss/python/lib/python2.6/site-packages/Twisted-8.1.0-py2.6-linux-x86_64.egg/twisted/internet/base.py", line 705, in runUntilCurrent
call.func(*call.args, **call.kw)
File "/usr/local/zenoss/zenoss/Products/ZenHub/services/Procrastinator.py", line 41, in _doNow
self.cback(device)
File "/usr/local/zenoss/zenoss/Products/ZenCollector/services/config.py", line 268, in _pushConfig
if self._filterDevice(device):
File "/usr/local/zenoss/zenoss/Products/ZenCollector/services/config.py", line 226, in _filterDevice
return device.monitorDevice()
exceptions.AttributeError: 'NoneType' object has no attribute 'monitorDevice'
rmatte:
I'm on the road and working from my cell so I can't be sure, but I think the device proxy isn't extending the method or attribute you're trying to return. Make sure info.py and interfaces.py are correct.
--Shane
It turns out it was actually a problem with the device itself. The device existed on that server when Zenoss was 2.5.2. I guess after the upgrade it was messed up. I removed it and re-added it then modelling worked fine. I finished coding/testing the 3.x UI portion. The last thing I need to do is figure out how I want to control which services are monitored/excluded globally. The simple solution would be zProperties (which I may end up doing), but I'm going to see if I can somehow use the existing "Windows Services" section.
I've decided to use zProperties to control what services get included/excluded when modelling. I looked at the existing "Windows Services" section, but it's too geared towards WMI to use. I also like the fact that zProperties will allow configuration at different levels. I'll be adding the zProperties in tomorrow and modifying the collector plugin to use them. I do also need to make sure that the ZenPack uninstalls cleanly. It currently appears to leave things behind that cause daemons not to start after the pack is uninstalled. I'll be working to sort that out before I release the pack. The pack will be ready for beta testing by tomorrow night.
Here are the latest screenshots:
I'll be adding a Status column to the 3.x skin.
+1 awesome
--
James Pulver
ZCA Member
LEPP Computer Group
Cornell University
The ZenPack is complete and the public beta test is now in effect. Visit http://dmon.org/downloads/zenoss/WinServiceSNMP/ for downloads and details.
Hello,
I've tried test this, but no success :/
[zenoss@zenoss ZenPacks]$ zenpack --install ZenPacks.Nova.WinServiceSNMP-1.0-py2.6.egg
WARNING:zen.Events:Error processing transform/mapping on Event Class /
Problem on line 0: AttributeError: Event instance has no attribute 'agent'
if evt.agent == "zensyslog" and evt.ntevid:
Transform:
0 if evt.agent == "zensyslog" and evt.ntevid:
1 evt.eventClassKey = "nteventlog"
2 """ evt.eventClass = "/Win"
3 """
WARNING:zen.Events:Error processing transform/mapping on Event Class /
Problem on line 0: AttributeError: Event instance has no attribute 'agent'
if evt.agent == "zensyslog" and evt.ntevid:
Transform:
0 if evt.agent == "zensyslog" and evt.ntevid:
1 evt.eventClassKey = "nteventlog"
2 """ evt.eventClass = "/Win"
3 """
......
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||