Skip to content

Commit

Permalink
Bugfix
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Schoechlin committed Dec 27, 2017
1 parent ce977bb commit eac1999
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions extension-files/tools/zabbix_check_dmesg
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,15 @@ def get_status_data(statusfile):
data = {}
data["timestamp"] = -1
if os.path.exists(statusfile):
try:
data = pickle.load(open(statusfile, "rb"))
except:
sys.stderr.write("ERROR: unable to read statusfile %s" % statusfile)
mtime_statusfile = os.stat(statusfile).st_mtime
mtime_kmsg = os.stat("/proc/kmsg").st_mtime
if mtime_statusfile < mtime_kmsg:
sys.stderr.write("Skipping load of old status data, old status file from before last boot detected (/proc/kmsg younger than %s)" % statusfile)
else:
try:
data = pickle.load(open(statusfile, "rb"))
except:
sys.stderr.write("ERROR: unable to read statusfile %s" % statusfile)
return data


Expand Down Expand Up @@ -74,10 +79,6 @@ while True:

lines += 1
current_time_stamp = float(m.group("timestamp"))

if latest_time_stamp > current_time_stamp:
latest_time_stamp = current_time_stamp

msg = m.group("msg")

if current_time_stamp > latest_time_stamp:
Expand All @@ -98,5 +99,5 @@ if lines <= 0:
matched = []
matched.append("parsing failed")

sys.stdout.write("%s: %s" % (status, ", ".join(matched)))
pickle.dump(status_data, open(status_file, "wb"))
sys.stdout.write("%s: %s\n" % (status, ", ".join(matched)))

0 comments on commit eac1999

Please sign in to comment.