Archived community.zenoss.org | full text search
Skip navigation
Currently Being Moderated

ZenDMD - playing with interfaces

VERSION 3  Click to view document history
Created on: Sep 14, 2009 11:21 AM by Noel Brockett - Last Modified:  Oct 16, 2009 5:11 PM by kobalt

Introduction

As of version 2.1.72 all interfaces of newly discovered/added devices are monitored too. If you check the device's interfaces and select one you can see that for the field Monitor the value is set to True.

 

Having a lot of interfaces and only a few you want to monitor deactivating monitoring for the other interfaces is a real pain - incase you do it via the web interface.

ZENDMD

With zendmd you can get this done faster:

 

As zenoss user start the command line management tool:

 

$ zendmd

 

>>> 

You get a console like interface. Make sure that you use tabs or spaces for the indent and to add another return after you issued the last command - this is necessary for the execution.
Simple Examples

Now lets disable monitoring for all interfaces of all devices:

 

 

>>> for d in dmd.Devices.getSubDevices():
...     for interface in d.os.interfaces():
...         interface.monitor = False
...
>>> commit()
>>>

You can double-check openeing a device via the web interface and selecting a interface.

 

Some of you might only want to monitor interface which have an IP assigned:

 

 

>>> for d in dmd.Devices.getSubDevices():
...     for interface in d.os.interfaces():
...         if interface.getIpAddress() != None:
...             interface.monitor = True
...
>>> commit()
>>>

Of course, sometimes you only want to modify a group (location, device group) of devices. This can be done like this:

 

>>> for d in dmd.Devices.getSubDevices():
...     if d.getDeviceClassPath() == '/Discovered':
...         for interface in d.os.interfaces():
...             interface.monitor = False
...
>>> commit()
>>>

Some of the interfaces' operational status might be down. Monitoring might be disabled for those:

 

>>> for d in dmd.Devices.getSubDevices():
...      for interface in d.os.interfaces():
...          if interface.operStatus > 1:
...              interface.monitor = False
...
>>> commit()

Advanced Examples

Sometimes you want, e.g., to select devices based on their name. With the help of regular expression you can do this. Due to naming conventions (e.g. for locations, systems, etc.) you can select a group of devices, e.g., all devices starting with ap. If you not familiar with regular expression you find help on the web.

 

>>> import re
>>> p = re.compile('^ap', re.IGNORECASE)
>>> for d in dmd.Devices.getSubDevices():
...     if p.match(d.getDeviceName()):
...         for interface in d.os.interfaces():
...             interface.monitor = False
...
>>> commit()
>>>

Of course, you can do this with interface names too. Selecting only interfaces which name starts with FastEthernet.

 

 

>>> import re
>>> p = re.compile('^FastEthernet')
>>> for d in dmd.Devices.getSubDevices():
...     for interface in d.os.interfaces():
...         if p.match(interface.getInterfaceName()):
...             interface.monitor = True
...
>>> commit()
>>>

You probably do not want to monitor Loopback interfaces:

 

>>> import re
>>> p = re.compile('^Loopback', re.IGNORECASE)
>>> for d in dmd.Devices.getSubDevices():
...     for interface in d.os.interfaces():
...         if p.match(interface.getInterfaceName()):
...             interface.monitor = False
...
>>> commit()
>>>

Note

The graphs (rrd files) will not be removed if you disable monitoring for an interface. Hence, if you deactivate it and after some time re-activate it the graphs will be continued from there and you still have the old data (depending on how old and your rrd creating properties).

 

Unfortunately even interfaces for which monitoring is disabled are polled by the performance monitor. AFAIK this will be fixed in Zenoss-2.2.

 

Suggestions and comments are welcome mbuerger_AT_edu.uni-klu.ac.at

 

>>updated syntax for a few of the scripts -kobalt

Comments (1)