Archived community.zenoss.org | full text search
Skip navigation
3311 Views 9 Replies Latest reply: Sep 21, 2011 1:24 PM by Shane Scott RSS
Welsh Rank: White Belt 22 posts since
Aug 25, 2011
Currently Being Moderated

Aug 30, 2011 5:17 PM

Graph Report to Text

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!

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    1. Aug 30, 2011 6:41 PM (in response to Welsh)
    Re: Graph Report to Text

    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

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    3. Sep 1, 2011 10:42 AM (in response to Welsh)
    Re: Graph Report to Text

    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

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    4. Sep 12, 2011 9:49 AM (in response to Shane Scott)
    Re: Graph Report to Text

    David:

     

    Did this work out for you?

     

    Best,

    --Hackman238

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    7. Sep 14, 2011 12:17 AM (in response to Welsh)
    Re: Graph Report to Text

    David:

     

    Whoops- I meant to delete that line. Delete that line and retry.

     

    Best,

    --Shane

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    9. Sep 21, 2011 1:24 PM (in response to Welsh)
    Re: Graph Report to Text

    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

More Like This

  • Retrieving data ...

Legend

  • Correct Answers - 4 points
  • Helpful Answers - 2 points