From 337ee609d373ba216756a9d330e9cdf62c8deef2 Mon Sep 17 00:00:00 2001 From: Cyberes Date: Fri, 2 Jun 2023 19:33:58 -0600 Subject: [PATCH] check_uptime: display in days --- check_uptime.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/check_uptime.sh b/check_uptime.sh index 8464c2c..dfbe45b 100755 --- a/check_uptime.sh +++ b/check_uptime.sh @@ -7,7 +7,7 @@ UPTIME_EXIT_CODE=$? # Check if the uptime command was successful if [ $UPTIME_EXIT_CODE -ne 0 ]; then echo "UNKNOWN - Unable to get uptime" - exit 3 + exit -1 fi # Calculate the uptime in seconds @@ -18,9 +18,9 @@ UPTIME_SECONDS=$((CURRENT_TIME - UPTIME_START)) # Convert the uptime seconds to hours UPTIME_HOURS=$(echo "scale=2; $UPTIME_SECONDS / 3600" | bc) -# Get the human-readable uptime -UPTIME_HUMAN=$(uptime -p) +# Convert the uptime seconds to days +UPTIME_DAYS=$(echo "scale=2; $UPTIME_SECONDS / 86400" | bc) # Print the result and performance data -echo "OK - Uptime: $UPTIME_HUMAN | uptime_hours=$UPTIME_HOURS" +echo "OK - Uptime: $UPTIME_DAYS days | uptime_hours=$UPTIME_HOURS" exit 0