Skip to content

Commit

Permalink
Improved error output
Browse files Browse the repository at this point in the history
  • Loading branch information
Marc Schoechlin committed Dec 28, 2017
1 parent 2f9b0d5 commit 75cbe69
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions extension-files/tools/zabbix_check_dmesg
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ try:
except ImportError:
import pickle

######################################################################################################
# HELPERS
######################################################################################################

def get_status_data(statusfile):
data = {}
Expand All @@ -32,7 +35,8 @@ def get_status_data(statusfile):
mtime_statusfile = os.stat(statusfile).st_mtime
mtime_kmsg = os.stat("/dev/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)
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"))
Expand All @@ -43,6 +47,7 @@ def get_status_data(statusfile):

######################################################################################################
# MAIN
######################################################################################################

EXECUTABLE = os.path.basename(__file__)

Expand Down Expand Up @@ -104,6 +109,6 @@ try:
pickle.dump(status_data, open(status_file, "wb"))
except:
status="ERROR"
matched.append("but storing status failed")
matched.append("but storing status to %s failed" % status_file)

sys.stdout.write("%s: %s\n" % (status, ", ".join(matched)))

0 comments on commit 75cbe69

Please sign in to comment.