Aug 30, 2011 5:17 PM
Graph Report to Text
-
Like (0)
Hello All,
I've tried searching around, tried reading documentation and books on this but haven't had any luck yet.
What I would like to accomplish if this is possible is I have a couple of graphs for Memory Utilization for Solaris Servers and for the most part the memory utilization stays stable at a high % used. However deploys will be made that will adjust the amount used and it would be nice to be able to see it textualy rather than on a graph since the change by a few % and its very difficult to see that 3% change for example.
I've seen under reports you can get the Memory utilization for a server of my choice on a date of my choosing and it can display the % Utilized. What I want would be like:
Date: August 30/2011
00:00 01:00 02:00 03:00 04:00 05:00
Server 1 94.3% 94.5% 94.6% 94.5% 95.6% 97.6%
Server 2 94.1% 94.2% 94.7% 94.1% 91.4% 94.2%
I know you can create Custom Reports and they use TALES markup, but I'm wondering if this is possible or has already been done? I have no problem learning how to build it but I'm a bit of a loss on how exactly to get the data points I need. (ie Server 1 Memory Utilization for 01:00)
Thanks!
David:
The for what you need I believe you would need to create a new memory report plugin and a completely custom report. A simpler method might be to write a python script and import ZenScriptBase. Doing this you can import the dmd object. This lets you use Zenoss methods to enumerate devices, interfaces, etc and get their associated datapoints at the time(s) desired while not needing to fuss with tales to programmatically aggregate the data.
If you need help with a simple example, let me know and I'll write a simple demo.
Best,
--Hackman238
It certainly sounds like the python script would be a lot more simplier and quicker to implement.
Any examples you could provide would be very helpful!
Thanks
David
David Welsh:
This is a simple script that gets total throughput over a time on a set of devices:
RQS_TP.py{
#!/usr/bin/env python
import Globals
from Products.ZenUtils.ZenScriptBase import ZenScriptBase
from transaction import commit
from Products.ZenUtils import Time
from optparse import OptionParser
import types
import re
import sys
import time
import locale
locale.setlocale(locale.LC_ALL, 'en_US')
dmd = ZenScriptBase(connect=True, noopts=True).dmd
re.I
re.S
parser = OptionParser()
parser.add_option("-s", "--start-date", dest="startDate",
help="Select Start Date [MM/DD/YYYY]", metavar="StartDate")
parser.add_option("-e", "--end-date", dest="endDate",
help="Select End Date [MM/DD/YYYY]", metavar="EndDate")
parser.add_option("-c", "--consolidation", dest="how", default="AVERAGE",
help="Select consolidation [MINIMUM, AVERAGE, MAXIMUM]", metavar="FUNCTION")
parser.add_option("-k", "--class", dest="klass", default="/",
help="Filter using Device Class")
parser.add_option("-i", "--intfilter", dest="intfilter", default="",
help="Filter by Interface Name")
parser.add_option("-g", "--system", dest="system", default="/",
help="Filter using Device System")
parser.add_option("-l", "--location", dest="location", default="/",
help="Filter using Device Location")
parser.add_option("-x", "--epoch-start", dest="startDateEpoch",
help="Select start time in seconds", metavar="SECONDS")
parser.add_option("-z", "--epoch-end", dest="endDateEpoch",
help="Select end time in seconds", metavar="SECONDS")
parser.add_option("-t", "--type", dest="typeOp",
help="Select operation type: UTILIZATION", default="UTILIZATION")
(options, args) = parser.parse_args()
if not options.startDate and not options.endDate and not options.startDateEpoch and not options.endDateEpoch:
parser.print_help()
sys.exit()
how = options.how
if not options.startDateEpoch and not options.endDateEpoch:
if options.startDate and options.endDate:
startDate = int(time.mktime(time.strptime(options.startDate, '%m/%d/%Y %H:%M:%S')))
endDate = int(time.mktime(time.strptime(options.endDate, '%m/%d/%Y %H:%M:%S')))
time = int(endDate) - int(startDate)
else:
print "Start and end options need to be used in conjunction with each other."
sys.exit()
else:
if options.startDateEpoch and options.endDateEpoch:
startDate = options.startDateEpoch
endDate = options.endDateEpoch
time = int(endDate) - int(startDate)
else:
print "Start and end options need to be used in conjunction with each other."
sys.exit()
multi = time
Int-Filter:%s" % (options.startDate, options.endDate, multi, options.how, options.typeOp, options.klass, options.system, options.location, options.intfilter)
if options.typeOp == "UTILIZATION" or not options.typeOp:
systemsMatch = re.compile('.*%s.*' % options.system)
locationsMatch = re.compile('.*%s.*' % options.location)
intMatch = re.compile('%s' % options.intfilter)
for d in dmd.Devices.getOrganizer(options.klass).getSubDevices():
if not d.monitorDevice(): continue
if not systemsMatch.search(d.getSystemNamesString()): continue
if not locationsMatch.search(d.getLocationName()): continue
for i in d.os.interfaces():
if i.getInterfaceName() != options.intfilter: continue
if i.getOperStatus()!= 1: continue
if not i.monitored(): continue
if i.snmpIgnore(): continue
results = i.getRRDValues(['ifHCInOctets',
'ifInOctets',
'ifOutOctets',
'ifHCOutOctets'],
start=startDate, end=endDate, function=how)
input = results.get('ifHCInOctets',
results.get('ifInOctets', None))
output = results.get('ifHCOutOctets',
results.get('ifOutOctets', None))
if None not in [input, output]:
input = input * multi
output = output * multi
finput = locale.format("%d", input, grouping=True)
foutput = locale.format("%d", output, grouping=True)
print "\"%s\",\"%s\",\"%s\",\"%s\"" % (d.id, i.id, finput, foutput)
}
Best,
--Hackman238
David:
Did this work out for you?
Best,
--Hackman238
Hey,
Unfortunantly I haven't had time to take a look at the script yet but I'm hoping to get to it this week!
Much thanks for the example.
- David
Hey,
I finally got everything setup to the point where I was able to try your script, however I'm getting an invalid syntax error with this line:
Int-Filter:%s" % (options.startDate, options.endDate, multi, options.how, options.typeOp, options.klass, options.system, options.location, options.intfilter)
I'm pretty new to Python so I'm trying to fiddle to get it working, but understand the gist of what the script does.
David:
Whoops- I meant to delete that line. Delete that line and retry.
Best,
--Shane
Hey Shane,
I get the script to run (sorta) on my VM of Zenoss that I'm using before I do anything to our Live Version but I'm not getting any results printed out to the terminal.
I run the full command below and with various variations (As well as tried by Interface Name)
./RQS_TP.py -s '09/13/2011 10:00:00' -e '09/13/2011 16:00:00' -c AVERAGE -k /Server/Solaris -t UTILIZATION
But they all show no output. Since It's a VM and I dont have it running I elected for a Window from 10am to 4pm on Sept 13th as I know it has data there. Am I just using the command wrong? I'll keep trying to fiddle with it.
Davind:
Your usage is correct. Do the VM's have interface data? They also must be in production, not set to zSnmpIgnore and the interfaces considered 'monitored'. Can you PM me the output of the script?
Best,
--Shane
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||