extend to bandwidth evaluation
This commit is contained in:
parent
7345073bb0
commit
c2e8fb875a
@ -57,24 +57,26 @@ SELECT d.description, d.address,
|
|||||||
WHERE ddi.device = d.id AND
|
WHERE ddi.device = d.id AND
|
||||||
ddi.dataitem = di.id AND
|
ddi.dataitem = di.id AND
|
||||||
cd.devicedataitem = ddi.id AND
|
cd.devicedataitem = ddi.id AND
|
||||||
di.description = 'totalPages' AND
|
di.description = %s AND
|
||||||
cd.ts BETWEEN %s AND %s
|
cd.ts BETWEEN %s AND %s
|
||||||
ORDER BY cd.id
|
ORDER BY cd.id
|
||||||
|
|
||||||
"""
|
"""
|
||||||
|
|
||||||
cur.execute(query, (datetime.datetime(1970, 1, 1), datetime.datetime(2100, 12, 31)))
|
# itemType = 'totalPages'
|
||||||
|
itemType = 'WAN ifHCOutOctets'
|
||||||
|
cur.execute(query, (itemType, datetime.datetime(1970, 1, 1), datetime.datetime(2100, 12, 31)))
|
||||||
|
|
||||||
printers = {}
|
devices = {}
|
||||||
|
|
||||||
for (printerName, printerAddress, timestamp, totalPages, id) in cur:
|
for (deviceName, deviceAddress, timestamp, value, id) in cur:
|
||||||
totalPages = int(totalPages)
|
value = int(value)
|
||||||
if not printers.has_key(printerAddress):
|
if not devices.has_key(deviceAddress):
|
||||||
printers[printerAddress] = {'name': printerName, 'address': printerAddress,
|
devices[deviceAddress] = {'name': deviceName, 'address': deviceAddress,
|
||||||
'first': {'timestamp': timestamp, 'value': totalPages},
|
'first': {'timestamp': timestamp, 'value': value},
|
||||||
'last': {'timestamp': timestamp, 'value': totalPages}}
|
'last': {'timestamp': timestamp, 'value': value}}
|
||||||
else:
|
else:
|
||||||
printers[printerAddress]['last'] = {'timestamp': timestamp, 'value': totalPages}
|
devices[deviceAddress]['last'] = {'timestamp': timestamp, 'value': value}
|
||||||
|
|
||||||
|
|
||||||
secondsPerMonth = datetime.timedelta(30).total_seconds()
|
secondsPerMonth = datetime.timedelta(30).total_seconds()
|
||||||
@ -95,22 +97,22 @@ SELECT d.description, d.address,
|
|||||||
mySheet.writeSameNext('Week Average/Forecast')
|
mySheet.writeSameNext('Week Average/Forecast')
|
||||||
|
|
||||||
|
|
||||||
for printer in printers.values():
|
for device in devices.values():
|
||||||
|
|
||||||
print("Printer: %s, %s" % (printer['name'], printer['address']))
|
print("Device: %s, %s" % (device['name'], device['address']))
|
||||||
mySheet.writeNextFirst(printer['name'])
|
mySheet.writeNextFirst(device['name'])
|
||||||
mySheet.writeSameNext(printer['address'])
|
mySheet.writeSameNext(device['address'])
|
||||||
|
|
||||||
print(" First: %s, %s" % (printer['first']['timestamp'], printer['first']['value']))
|
print(" First: %s, %s" % (device['first']['timestamp'], device['first']['value']))
|
||||||
mySheet.writeSameNext(printer['first']['timestamp'])
|
mySheet.writeSameNext(device['first']['timestamp'])
|
||||||
mySheet.writeSameNext(printer['first']['value'])
|
mySheet.writeSameNext(device['first']['value'])
|
||||||
|
|
||||||
print(" Last: %s, %s" % (printer['last']['timestamp'], printer['last']['value']))
|
print(" Last: %s, %s" % (device['last']['timestamp'], device['last']['value']))
|
||||||
mySheet.writeSameNext(printer['last']['timestamp'])
|
mySheet.writeSameNext(device['last']['timestamp'])
|
||||||
mySheet.writeSameNext(printer['last']['value'])
|
mySheet.writeSameNext(device['last']['value'])
|
||||||
|
|
||||||
deltaTime = printer['last']['timestamp'] - printer['first']['timestamp']
|
deltaTime = device['last']['timestamp'] - device['first']['timestamp']
|
||||||
deltaValue = printer['last']['value'] - printer['first']['value']
|
deltaValue = device['last']['value'] - device['first']['value']
|
||||||
print(" Diff: %s, %s" % (deltaTime, deltaValue))
|
print(" Diff: %s, %s" % (deltaTime, deltaValue))
|
||||||
mySheet.writeSameNext(deltaValue)
|
mySheet.writeSameNext(deltaValue)
|
||||||
|
|
||||||
@ -130,7 +132,7 @@ except mysql.connector.Error as err:
|
|||||||
print("Failure when using database: %s" % (err))
|
print("Failure when using database: %s" % (err))
|
||||||
finally:
|
finally:
|
||||||
if xls is not None:
|
if xls is not None:
|
||||||
xls.save('printerStats.xls')
|
xls.save('deviceStats.xls')
|
||||||
if cur is not None:
|
if cur is not None:
|
||||||
cur.close()
|
cur.close()
|
||||||
if dbh is not None:
|
if dbh is not None:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user