-unless File.exists? statusfile
- puts "UNKNOWN: #{statusfile} does not exist."
- exit NAGIOS_STATUS['UNKNOWN']
-end
-
-
-mtime = File.stat(statusfile).mtime
-if mtime + max_age < Time.now
- puts "WARNING: #{statusfile} is old: #{mtime}"
- exit NAGIOS_STATUS['WARNING']
-end
-
-status = File.new(statusfile)
-returnvalue = status.readline.chomp
-
-unless NAGIOS_STATUS.has_key? returnvalue
- puts "UNKNOWN: #{statusfile} has invalid return value: #{returnvalue}"
- exit NAGIOS_STATUS['UNKNOWN']
-end
-
-status.readlines.each do |line|
- print line
-end
-exit NAGIOS_STATUS[returnvalue]
+if not os.path.exists(statusfile):
+ print "UNKNOWN: %s does not exist."%(statusfile)
+ sys.exit(NAGIOS_STATUS['UNKNOWN'])
+
+
+mtime = os.path.getmtime(statusfile)
+if mtime + max_age < time.time():
+ print "WARNING: %s is old: %.1f hours."%(statusfile, (time.time() - mtime)/3600)
+ sys.exit(NAGIOS_STATUS['WARNING'])
+
+status = open(statusfile, "r")
+returnvalue = status.readline().strip()
+
+if not returnvalue in NAGIOS_STATUS:
+ print "UNKNOWN: %s has invalid return value: %s."%(statusfile, returnvalue)
+ sys.exit(NAGIOS_STATUS['UNKNOWN'])
+
+linecnt = 0
+for line in status:
+ print line,
+ linecnt += 1
+
+if linecnt == 0:
+ print "Found no output. Something is probably wrong"
+ sys.exit(NAGIOS_STATUS['UNKNOWN'])
+
+sys.exit(NAGIOS_STATUS[returnvalue])
+
+# vim:set et:
+# vim:set ts=4:
+# vim:set shiftwidth=4: