From e78294d7d9ba82fddab89fd3f14d7a2f1b647a4c Mon Sep 17 00:00:00 2001 From: Cyberes Date: Thu, 8 Jun 2023 22:48:55 -0600 Subject: [PATCH] check_uptime: fix floating point error --- check_uptime.sh | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/check_uptime.sh b/check_uptime.sh index b5ae57e..3dd1fab 100755 --- a/check_uptime.sh +++ b/check_uptime.sh @@ -10,14 +10,16 @@ if uname | grep -q "BSD"; then total_uptime_seconds=$(($(date +%s) - boot_time_seconds)) else total_uptime_seconds=$(cat /proc/uptime | awk '{print $1}') - # echo "UNKNOWN: Unsupported system" - # exit 3 + total_uptime_seconds=$(printf "%.0f" "${total_uptime_seconds}") +#else +# echo "UNKNOWN: Unsupported system" +# exit 3 fi # Calculate uptime in days, hours, minutes, and seconds uptime_days=$((total_uptime_seconds / 86400)) -uptime_hours=$(( (total_uptime_seconds % 86400) / 3600 )) -uptime_minutes=$(( (total_uptime_seconds % 3600) / 60 )) +uptime_hours=$(((total_uptime_seconds % 86400) / 3600)) +uptime_minutes=$(((total_uptime_seconds % 3600) / 60)) uptime_seconds=$((total_uptime_seconds % 60)) # Print the result and perfdata