Uptime

check_uptime3

Description:

* 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

Compatible With

Owner


Project Files
Project Notes
#### 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://exchange.nagios.org/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
Reviews (5) Add a Review
Best one I've seen
by pelicanmedia, April 30, 2018

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



Patch Debian version
by belgotux, July 31, 2014

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; >



Thanks
by elpatron, October 31, 2013

Works like a charm on my Raspberry Pi.



check_uptime3 under Debian [SOLVED]
by schams.net, October 31, 2011

@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.



nice plugin with one error
by cnoyes72, September 30, 2011

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;



Add a Review

You must be logged in to submit a review.

Thank you for your review!

Your review has been submitted and is pending approval.

Recommend

To:


From:


Thank you for your recommendation!

Your recommendation has been sent.

Project Stats
Rating
4.5 (8)
Favorites
3
Views
102,210