For those Zenoss users out there, this script will send a emailof devices that are in the discovered class.
So once you receive this email you will know that you need to move those devices into there appropriate classes.
#!/bin/env python#Copyright (C) 2008 Allen Sanabria
#This program is free software; you can redistribute it and/or modify#it under the terms of the GNU General Public License as published by#the Free Software Foundation; either version 2 of the License, or#(at your option) any later version.
#This program is distributed in the hope that it will be useful,#but WITHOUT ANY WARRANTY; without even the implied warranty of#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License along#with this program; if not, write to the Free Software Foundation, Inc.,#51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.###############################################################Created by Allen Sanabria aka LinuxDynasty aka PrNino69#This script is to check how many devices are in the#Discovered Class#Started Nov 28th#Completed, Nov 28th##############################################################
import os, sysfrom re import subfrom string import splitfrom string import joinfrom urllib import urlopenfrom smtplib import SMTPfrom time import sleep
user = "zenoss"passwd = 'zenoss'util = '@zenoss'base = "http://%s:%s%s:8080" % (user,passwd,util)discovered_url = urlopen(base+'/zport/dmd/Devices/Discovered/getSubDevices').read()discovered_sub = sub("<Device at /zport/dmd/Devices/Discovered/devices/|>|^[|]$|,", "", discovered_url)discovered_list = list(split(discovered_sub))
message = """nThe boxes below were discovered in the last run of zendisc.nThey are all located under /Devices/Discovered Class.n Please move Devices to appropriate Device class, if one does not exist please create one.n This script runs on the zenoss (cc17-22) server."""devices = sub(",|[|]", "n", str(discovered_list))BODY = join((message, devices),"n")print BODYFROM = "zenoss@linuxdynasty.org"TO = "sa@linuxdynasty.org"SUBJECT = "Devices That Were Discovered During The Network Scan!"body = join(("From: %s" % FROM, "To: %s" % TO, "Subject: %s" % SUBJECT, "", BODY), "n")server = SMTP('localhost')server.set_debuglevel(1)server.sendmail(FROM, [TO], body)sleep(10)server.quit()
Recent Comments