Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Windows hosts perfdata parse #106

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
46 changes: 31 additions & 15 deletions graphios.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import os
import os.path
import re
import shlex
import sys
import time

Expand Down Expand Up @@ -360,21 +361,36 @@ def process_log(file_name):
variables = line.split('\t')
mobj = get_mobj(variables)
if mobj:
# break out the metric object into one object per perfdata metric
# log.debug('perfdata:%s' % mobj.PERFDATA)
for metric in mobj.PERFDATA.split():
try:
nobj = copy.copy(mobj)
(nobj.LABEL, d) = metric.split('=')
v = d.split(';')[0]
u = v
nobj.VALUE = re.sub("[a-zA-Z%]", "", v)
nobj.UOM = re.sub("[^a-zA-Z]+", "", u)
processed_objects.append(nobj)
except:
log.critical("failed to parse label: '%s' part of perf"
"string '%s'" % (metric, nobj.PERFDATA))
continue
#log.debug('perfdata:%s' % mobj.PERFDATA)
try:
metric_array = shlex.split(mobj.PERFDATA)
if not '=' in metric_array[0]:
if not '=' in metric_array[0]:
perf = ''
aux_metric_array = []
for value in metric_array:
perf += value
if '=' in value:
aux_metric_array.append(perf)
perf = ''
metric_array = aux_metric_array
except:
log.critical("failed to parse perfdata: %s" % (mobj.PERFDATA))
continue
for metric in metric_array:
if '=' in metric:
try:
nobj = copy.copy(mobj)
(nobj.LABEL, d) = metric.split('=')
v = d.split(';')[0]
u = v
nobj.VALUE = re.sub("[a-zA-Z%]", "", v)
nobj.UOM = re.sub("[^a-zA-Z]+", "", u)
processed_objects.append(nobj)
except:
log.critical("failed to parse label: '%s' part of perf"
"string '%s'" % (metric, nobj.PERFDATA))
continue
return processed_objects


Expand Down
2 changes: 1 addition & 1 deletion init/rhel/graphios
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ start () {

stop () {
echo -n "Stopping $prog"
killproc graphios.py
killproc graphios
RETVAL=$?
[ $RETVAL -eq 0 ] && success || failure
echo
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ def run(self):
# print data_files
setup(
name='graphios',
version='2.0.0b3',
version='2.0.0',
description='Emit Nagios metrics to Graphite, Statsd, and Librato',
author='Shawn Sterling',
author_email='[email protected]',
Expand Down