summaryrefslogtreecommitdiffstats
path: root/plugins/impstats/statslog-graph.py
diff options
context:
space:
mode:
authorAndre Lorbach <alorbach@adiscon.com>2013-07-11 11:28:39 +0200
committerAndre Lorbach <alorbach@adiscon.com>2013-07-11 11:28:39 +0200
commitfba8609b2a1458686bb90a98a11e134548616310 (patch)
treed9386b4b3057fcc0dfd9330f5aa021629546d4a9 /plugins/impstats/statslog-graph.py
parent53bd9a94ec2c7ad1a009c6fb6655adea48746ca3 (diff)
downloadrsyslog-fba8609b2a1458686bb90a98a11e134548616310.tar.gz
rsyslog-fba8609b2a1458686bb90a98a11e134548616310.tar.bz2
rsyslog-fba8609b2a1458686bb90a98a11e134548616310.zip
Added new option "chartscalcdelta" to generate charts with delta values instead of cumulative values.
Also fixed reading outputfile parameter in statslog-graph.py script.
Diffstat (limited to 'plugins/impstats/statslog-graph.py')
-rwxr-xr-xplugins/impstats/statslog-graph.py35
1 files changed, 26 insertions, 9 deletions
diff --git a/plugins/impstats/statslog-graph.py b/plugins/impstats/statslog-graph.py
index 7edafb21..abd4d5c3 100755
--- a/plugins/impstats/statslog-graph.py
+++ b/plugins/impstats/statslog-graph.py
@@ -28,6 +28,7 @@ bBarChart = False
bConvertPng = False
bLogarithmicChart = False
bFilledLineChart = False
+bChartCalcDelta = False
# Init variables
aFields = []
@@ -44,8 +45,8 @@ iStartSeconds = 0
for arg in sys.argv[-4:]:
if arg.find("--input=") != -1:
szInput = arg[8:]
- elif arg.find("--outputdir=") != -1:
- szOutputFile = arg[12:]
+ elif arg.find("--outputfile=") != -1:
+ szOutputFile = arg[13:]
elif arg.find("--maxdataxlabel=") != -1:
nMaxDataCount = int(arg[16:])
elif arg.find("--xlabeldatetime") != -1:
@@ -64,6 +65,8 @@ for arg in sys.argv[-4:]:
bLogarithmicChart = True
elif arg.find("--filledlinechart") != -1:
bFilledLineChart = True
+ elif arg.find("--chartscalcdelta") != -1:
+ bChartCalcDelta = True
elif arg.find("--h") != -1 or arg.find("-h") != -1 or arg.find("--help") != -1:
bHelpOutput = True
@@ -84,6 +87,7 @@ if bHelpOutput == True:
print " --barchart Generates a Barchart (Cannot be used with --linechart)"
print " --logarithmic Uses Logarithmic to scale the Y Axis, maybe useful in some cases. Default is OFF"
print " --filledlinechart Use filled lines on Linechart, maybe useful in some cases. Default is OFF"
+ print " --chartscalcdelta If set, charts will use calculated delta values instead of cumulative values."
print " --convertpng Generate PNG Output rather than SVG. "
print " Default is SVG output."
print " --h / -h / --help Displays this help message. \n"
@@ -91,16 +95,19 @@ if bHelpOutput == True:
else:
# Generate output filename
if len(szInput) > 0:
- if szInput.rfind(".") == -1:
- szOutputFile += szInput + ".svg"
- else:
- szOutputFile += szInput[:-4] + ".svg"
+ # Only set output filename if not specified
+ if len(szOutputFile) == 0:
+ if szInput.rfind(".") == -1:
+ szOutputFile += szInput + ".svg"
+ else:
+ szOutputFile += szInput[:-4] + ".svg"
else:
print "Error, no input file specified!"
sys.exit(0)
# Process inputfile
inputfile = open(szInput, 'r')
+ aLineDataPrev = [] # Helper variable for previous line!
for line in inputfile.readlines():
if nLineCount == 0:
aFields = line.strip().split(";")
@@ -137,7 +144,16 @@ else:
# Set data field
aData[field].append( iTimeStamp - iStartSeconds )
elif iFieldNum > 2:
- aData[field].append( int(aLineData[iFieldNum]) )
+ # Check if we need to calculate Deltas!
+ if bChartCalcDelta and len(aLineDataPrev) > 0:
+ iPreviousVal = int(aLineDataPrev[iFieldNum])
+ iCurrentVal = int(aLineData[iFieldNum])
+ if iCurrentVal != 0: # Calc DELTA
+ aData[field].append(iCurrentVal - iPreviousVal)
+ else: # Don't Calc delta value!
+ aData[field].append( iCurrentVal )
+ else:
+ aData[field].append( int(aLineData[iFieldNum]) )
else:
aData[field].append( aLineData[iFieldNum] )
@@ -147,8 +163,9 @@ else:
# Increment counter
nDataRecordCound += 1
- #print aData
- #sys.exit(0)
+ # in case deltas need to be calculated, Store current line into previous line
+ if bChartCalcDelta:
+ aLineDataPrev = aLineData
# Increment counter
nLineCount += 1