Archived community.zenoss.org | full text search
Skip navigation
1 2 Previous Next 133694 Views 16 Replies Latest reply: Jan 29, 2013 5:32 PM by Ryan Matte RSS
Kynnzak Rank: White Belt 12 posts since
Jul 27, 2009
Currently Being Moderated

Oct 26, 2009 1:14 PM

Bandwidth Reporting

Ok, disclaimer first:  I am in no way, shape or form a progammer!

 

I'm looking to find a way to report on bandwidth utilization for network devices such as routers, switches, etc. but instead of having a 24-hour time frame, being able to focus specifically on business hours, i.e. 8 am to 5 pm M-F, et. al.

 

Has anyone done anything like this, and if so, can you share the "guts" of your graph reports?

 

Unfortunately the non-business hour times skew the averages and cause the graphs to not reflect the overall average utilization accurately.

  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    1. Oct 26, 2009 4:31 PM (in response to Kynnzak)
    Re: Bandwidth Reporting

    Here's an interface utilization script that I wrote (it's basically a copy of the one included with Zenoss with some added options)...

     

    http://pastebin.com/f733976c8

     


    You can run the script with options to specify the start and end date.  It can also be run by specifying the start and end time in epoch time.  You just need to find some way of converting the dates and times that you want for start and end dates to epoch time and then run the script with those values.  It's not exactly what you're looking for but it's a good start.  Start reading up on epoch time (if you're not familliar with it).

  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    2. Oct 27, 2009 11:23 AM (in response to Kynnzak)
    Re: Bandwidth Reporting
    I forgot to mention that the script needs to be run from the commandline as the Zenoss user and it will output the data in CSV format.  If you run the script without options it will list the supported options.
  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    4. Oct 30, 2009 1:45 PM (in response to Kynnzak)
    Re: Bandwidth Reporting
    Well first off I have absolutely no idea why you're running the script like that.  Rename the script from .txt to .py as it's a python script.  "chmod +x" the file to make it executable, then just run it like: "./script.py -y 1256803200 -z 1256850000".  That will ensure that it's using the correct python libraries.  You should also probably specify the function like AVERAGE, so "./script.py -y 1256803200 -z 1256850000 -c AVERAGE".  If you're still getting an error after doing that let me know.
  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    6. Oct 30, 2009 5:20 PM (in response to Kynnzak)
    Re: Bandwidth Reporting
    It seems to be complaining that ifHCInOctets is "None" instead of a value on one of your interfaces.  I literally copied the part of the code that it's complaining about directly from the Zenoss interfaces report.  Are you able to successfully run the interface performance report from the UI on that Zenoss box?
  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    8. Nov 2, 2009 9:51 AM (in response to Kynnzak)
    Re: Bandwidth Reporting
    I just ran the report script with the exact same epoch time parameters that you're trying to use.  I ran it on all 11 of my Zenoss Core systems.  It worked perfectly fine on all of them, including one that I am monitoring over 3000 interfaces on.  From the error message that you're getting I'm thinking it's either possibly a corrupted RRD file somewhere, or that a function needs to be added to the script to ensure that something is converted to an integer.  The corrupted RRD theory seems more likely since you're only having the problem on a few of your Zenoss boxes.  I can't reproduce the issue myself so troubleshooting this particular issue will be quite difficult for me (until I happen to come across it at some point).
  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    10. Nov 3, 2009 11:34 AM (in response to Kynnzak)
    Re: Bandwidth Reporting

    Kynnzak:

     

    The following part of the error:

    "input = results.get('ifHCInOctets',

    AttributeError: 'NoneType' object has no attribute 'get'"

    Suggests that for at least 1 instance of 'ifHCInOctets' is being set to =None which doesnt support get. I can't think of how this could be possible unless your script is not intact. Have you verifiied its contents?
  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    11. Nov 3, 2009 11:44 AM (in response to Shane Scott)
    Re: Bandwidth Reporting

    We are running Ubuntu Server 8.04 I believe.  We are running Zenoss 2.4.5 with the following patches applied:

     

    zenpatch 15003 && zenpatch 14397 && zenpatch 15214

  • Ryan Matte ZenossMaster 653 posts since
    Mar 26, 2009
    Currently Being Moderated
    12. Nov 3, 2009 11:56 AM (in response to Ryan Matte)
    Re: Bandwidth Reporting

    And yeh, that part of the code is basically directly copied from the report that Zenoss uses...

     

    Here are the lines from the Zenoss script:

     

                    results = i.getRRDValues(['ifHCInOctets',
                                              'ifInOctets',
                                              'ifOutOctets',
                                              'ifHCOutOctets'],
                                             **summary)
                    input = results.get('ifHCInOctets',
                                        results.get('ifInOctets', None))
                    output = results.get('ifHCOutOctets',
                                         results.get('ifOutOctets', None))

     

    Here are the lines from mine:

     

                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))

     

    The only difference between the two is that I substituted "**summary" for "start=startDate, end=endDate, function=how" which is what **summary represents anyways.  I haven't added or removed any error checking for that value from the original script.  If you're able to run the interface report fine from the UI then there's absolutely no reason why you shouldn't be able to run my script (except for the fact that you are trying to use a much more specific time range than the UI report supports, so you can't possibly compare.  It sounds like you have a gap in one of your RRD files during that entire particular period which is somehow resulting in a None value for ifInOctets.  I've never seen this behaviour before.

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    13. Nov 3, 2009 12:06 PM (in response to Ryan Matte)
    Re: Bandwidth Reporting

    Try adding:

    check=-1

     

    if None not in [input, output]:
          check= input + output

     

    if check==-1: continue

     

    This will cause the script to bail on that device if either input or ouptut are =None.

  • Shane Scott ZenossMaster 1,373 posts since
    Jul 6, 2009
    Currently Being Moderated
    14. Nov 3, 2009 12:23 PM (in response to Shane Scott)
    Re: Bandwidth Reporting

    An example of this is a script I use for errors reporting:

     

    import Globals
    from Products.ZenReports import Utils, Utilization
    import re
    
    class interfaceErrsBH:
        "The interface error report"
    
        def run(self, dmd, args):
            summary = Utilization.getSummaryArgs(dmd, args)
            time = int(summary["end"]) - int(summary["start"])
            report = []
            for d in Utilization.filteredDevices(dmd, args):
    
                isLocal = re.compile(d.zLocalInterfaceNames)
                for i in d.os.interfaces():
                    if isLocal.match(i.name()): continue
                    if not i.monitored(): continue
                    if i.snmpIgnore(): continue
                    if not i.speed: continue
                    total=0
                    duplex=0
    
                    try:
                        results = i.getRRDValues(['ifInErrors',
                                                 'ifOutErrors'],
                                                **summary)
                    except Exception:
                        pass
    
                    if i.duplexN != 0 and i.duplex == 0:
                        duplex=i.duplexN + 1
    
                    if i.duplex != 0 and i.duplexN == 0:
                        duplex=i.duplex
    
                    ifInErrors = results.get('ifInErrors', None)
                    ifOutErrors = results.get('ifOutErrors', None)
    
                    if None not in [ifInErrors, ifOutErrors]:
                            total = ifInErrors + ifOutErrors
                            if total == 0: continue
    
                            r = Utils.Record(device=d,
                                             interface=i,
                                             speed=i.speed,
                                             duplex=duplex,
                                             inerror=ifInErrors,
                                             outerror=ifOutErrors,
                                             inerrorP=(ifInErrors*time),
                                             outerrorP=(ifOutErrors*time),
                                             totalP=(total*time),
                                             total=total)
                            report.append(r)
    
            return report
    
    
1 2 Previous Next

More Like This

  • Retrieving data ...

Legend

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