![]() |
![]() |
Subject: | Zenoss and DNS/IP refresh |
Author: | [Not Specified] |
Posted: | 2014-01-16 09:10 |
Hi All,
We use zenoss core 4.2.3 on test environment,
If I add a device by its hostname, it's stored by its IP. Zenoss doesn't do a DNS lookup on the hostname after this and just saves the IP forever and ever.
If for example, you are monitoring external feeds that occasionally change their backend datacenters, Zenoss doesn't notice this, but continues to monitor the original IP. This means that this monitor is giving us incorrect/invalid data.
I want Zenoss to automatically do a DNS lookup against each device and to reset the IP if necessary.
I'm using a python script provided in the following link http://community.zenoss.org/thread/18085
#!/usr/bin/python
import os, sys, getopt
import logging
# Perform Zenoss specific imports.
##import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit
if len(sys.argv) < 3:
sys.exit('Usage: %s dev/id dev/manageIp ' % sys.argv[0])
name=sys.argv[1]
arg0=sys.argv[0]
print 'zeroth arg is ' + arg0
print 'DNS_CHECK :name is' + name
ip=sys.argv[2].strip()
# dig +short simply returns one or more IP addresses that DNS resolves for the supplied name
nameres = os.popen('dig +short %s' % (name) )
if ip in (i.strip() for i in nameres.readlines() ):
print 'No DNS change - OK | statusvar=0'
sys.exit(0)
else:
print 'Change in DNS - WARNING | statusvar=1'
# Get first response again from dig
nameres = os.popen('dig +short %s' % (name) )
dnsip = nameres.readline().strip()
print 'DNS IP identified is : ' + dnsip
dmd = ZenScriptBase(connect=True).dmd
dev=dmd.Devices.findDevice(name)
dev.setManageIp(dnsip)
commit()
sys.exit(0)
How to make Zenoss to do this as part of regular monitoring and checks.
Where can i check the logs , to confirm whether zenoss is running the script to reset the ip in regular internals along with the monitoring the device.
Please help me to resolve this issue.
Thanks in advance.
Subject: | see this thread this may be of use. |
Author: | [Not Specified] |
Posted: | 2014-07-07 20:48 |
http://community.zenoss.org/message/22934
If you run the setManageIp method of a device with no parameters it
will use DNS to figure it out.
for d in dmd.Devices.getSubDevices():
d.setManageIp()
commit()
Be aware that this will blank out the IP address for devices that
can't be resolved with DNS. You may want to do the following
afterwards to find any devices with a blank manageIp so that you can
get them added to DNS.
pprint([ d.id for d in dmd.Devices.getSubDevices() if d.manageIp ==
"" ])
____________________
create a script that runs that periodically from cron and you should be set.
< |
Previous Send one alert for multiple alerts |
Next Searching forums |
> |