Build precise queries to find exactly what you need
Press ESC to close
Your review has been submitted and is pending approval.
* Original script written by Dmitry Vayntrub with version 1.04 released on 03/11/2009. * Bugfix added. * Performance Data added.
Current Version
1.06
Last Release Date
2011-01-27
Owner
Peter Lecki
####
Performance Data added by Tony Yarusso on Jan 27, 2011. (revision incremented to 1.06)
There was bug report posted by reviewer jsnyder on the script's page: http://localhost/directory/Plugins/System-Metrics/Uptime/check_uptime2/details
My fix simply adds another "if" conditional checking for existence of keyword "min" which means there will not be an hour count listed in the output of "uptime".
I also incremented the revision number to 1.05.
Sample output: OK - uptime is 57 Minutes OK - uptime is 1 Hours, 27 Minutes OK - uptime is 1 Days, 27 Minutes OK - uptime is 1 Days, 1 Hours, 57 Minutes
Thank you for this !! I have been hunting and testing for MONTHS to find a check_uptime script that works correctly. This is the only one that does with the different results (depending on time up) from 'uptime'. i.e Minutes, Hours & Minutes, Days & Minutes, Day & Hours & Minutes. I have made a few adjustments to mine as I have no need for warnings, just for monitoring: ========== #!/bin/sh UPTIME_REPORT=`uptime | tr -d ","` if echo $UPTIME_REPORT | grep -i day > /dev/null ; then if echo $UPTIME_REPORT | grep -i "min" > /dev/null ; then DAYS=`echo $UPTIME_REPORT | awk '{ print $3 }'` MINUTES=`echo $UPTIME_REPORT | awk '{ print $5}'` else DAYS=`echo $UPTIME_REPORT | awk '{ print $3 }'` HOURS=`echo $UPTIME_REPORT | awk '{ print $5}' | cut -f1 -d":"` MINUTES=`echo $UPTIME_REPORT | awk '{ print $5}' | cut -f2 -d":"` fi elif #in AIX 5:00 will show up as 5 hours, and in Solaris 2.6 as 5 hr(s) echo $UPTIME_REPORT | egrep -e "hour|hr(s)" > /dev/null ; then HOURS=`echo $UPTIME_REPORT | awk '{ print $3}'` else echo $UPTIME_REPORT | awk '{ print $3}' | grep ":" > /dev/null && HOURS=`echo $UPTIME_REPORT | awk '{ print $3}' | cut -f1 -d":"` MINUTES=`echo $UPTIME_REPORT | awk '{ print $3}' | cut -f2 -d":"` fi UPTIME_MSG="${DAYS:+$DAYS Days,} ${HOURS:+$HOURS Hours,} $MINUTES Minutes" echo System Uptime - $UPTIME_MSG ========== I now have this running on CentOS, Ubuntu and Raspberry Pi servers, all running perfectly! System Uptime - 0 Minutes System Uptime - 4 Hours, 19 Minutes System Uptime - 2 Days, 8 Hours, 54 Minutes
Hello, This is a patch to use with Debian and optiomal min/max options 2a3 > # Edit by Belgotux www.monlinux.net 30/07/2014 7a9 > # v 1.07 - Debian version and optiomal min/max options 107c109 UPTIME_DAYS=$(printf %3.4f $RAW_DAYS) 109c111,119 > PERFDATA="|Uptime=$UPTIME_DAYS;" > if [ "$MIN_WARNING" != "" ] || [ "$MAX_WARNING" != "" ] ; then PERFDATA="${PERFDATA}${MIN_WARNING}:${MAX_WARNING};" ; fi > if [ "$MIN_CRITICAL" != "" ] || [ "$MAX_CRITICAL" != "" ] ; then PERFDATA="${PERFDATA}${MIN_CRITICAL}:${MAX_CRITICAL};" ; fi > > PERFDATA="${PERFDATA}0;" > > #|Uptime=$UPTIME_DAYS;$MIN_WARNING:$MAX_WARNING;$MIN_CRITICAL:$MAX_CRITICAL;0; >
Works like a charm on my Raspberry Pi.
@cnoyes72: you can simply change the shell to: "/bin/bash", so the script works fine under Debian as well. Do this by editing the first line and replace "#!/bin/sh" with "#!/bin/bash". Hope this helps. Cheers.
Executing this script on a debian system results in the following being reported (along with the results): printf: 107: %3.4l: invalid directive OK - uptime is 10 Days, 19 Hours, 25 Minutes|Uptime=;:;:;0;
You must be logged in to submit a review.
To:
From:
We’ve completely redesigned the world’s largest repository of Nagios plugins and monitoring tools. Join thousands of users sharing monitoring solutions for servers, applications, and everything in between.
Due to our redesign, all existing accounts require a password reset to access your account again.
Ready to explore 6,100+ projects and contribute to the community?
Reset Password Create Account
Happy Monitoring!