check_uptime: fix floating point error

This commit is contained in:
Cyberes 2023-06-08 22:48:55 -06:00
parent 5a34281bde
commit e78294d7d9
1 changed files with 6 additions and 4 deletions

View File

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