Oct 26, 2009 1:14 PM
Bandwidth Reporting
-
Like (0)
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.
Here's an interface utilization script that I wrote (it's basically a copy of the one included with Zenoss with some added options)...
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).
Awesome tool! Thanks for the help!
One issue we're running into on one of our boxes is this:
zenoss@PPLD-MNGSVCS-PC:~$ python ./f733976c8.txt -y 1256803200 -z 1256850000
Device,Interface,Speed,Input,Output,Total,% Util
ERROR:zen.RRDView:int argument required
Traceback (most recent call last):
File "/usr/local/zenoss/zenoss/Products/ZenModel/RRDView.py", line 156, in getRRDValues
gopts.append("--start=%d" % start)
TypeError: int argument required
Traceback (most recent call last):
File "./f733976c8.txt", line 80, in ?
input = results.get('ifHCInOctets',
AttributeError: 'NoneType' object has no attribute 'get'
When I run the command using -s and -e options, it works fine, but on this one box using the epoch time throws that error.
Any suggestions?
LOL
Let me re-direct you to my first statement of not being anything close to a programmer.
I've tried renaming and I get errors like ":No such file or directory" upon running the script. Even when renamed, using "python ./f733976c8.py -s 10/29/2009 -e 10/30/2009 -c AVERAGE works and gives me what I'm looking for.
This works on all my deployed boxes except for this one. All my builds are identical, so I'm curious as to why it works on all but this one. And even on this box, it works if my options are -s and -e, but when I try -y and -z it gives the error I indicated above.
Yes, I can use the GUI to get interface statistics.
Update: I'm now having this problem on more than one deployed box. And it only occurs when attempting to use epoch time; using start and end dates works fine.
All of my Zenoss deployments are identical, so I'm trying to discern what's different between the box that works and those that don't work to see if there may be a conflict with the OS or the application or a Zenpack or something.
I agree with the possibility of an RRD issue; I've been wondering for a few days if there's something inherent to my deployments that might be causing the error. I'm using Ubuntu as the base OS; which Linux variant and version are you using?
Interesting new developments:
I was using Ubuntu 9.04 and Zenoss 2.4.2 which was generating the errors reported above.
I have since completely re-installed (from scratch) Ubuntu 9.10 and Zenoss 2.50 on my lab system. I still can run the script with any options flawlessly.
I upgraded one of my deployed boxes to Ubuntu 9.10, still running Zenoss 2.4.2, and now that box throws these errors:
zenoss@PPLD-MNGSVCS-PC:~$ python ./f733976c8.py -s 10/29/2009 -e 10/30/20009 -c AVERAGE
Traceback (most recent call last):
File "./f733976c8.py", line 43, in ?
startDate, endDate = map(Time.ParseUSDate, (startDate, endDate))
File "/usr/local/zenoss/zenoss/Products/ZenUtils/Time.py", line 49, in ParseUSDate
return time.mktime(time.strptime(mdy, "%m/%d/%Y"))
File "/usr/local/zenoss/python/lib/python2.4/_strptime.py", line 296, in strptime
raise ValueError("unconverted data remains: %s" %
ValueError: unconverted data remains: 9
Kynnzak:
The following part of the error:
"input = results.get('ifHCInOctets',
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
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.
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.
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
Follow Us On Twitter »
|
Latest from the Zenoss Blog » | Community | Products | Services Resources | Customers Partners | About Us | ||
Copyright © 2005-2011 Zenoss, Inc.
|
||||||||