check_uptime: get ready for use
This commit is contained in:
parent
e709683320
commit
54b68b1fb8
|
@ -1,9 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Check if the system is Linux or BSD
|
# Check if the system is Linux or BSD
|
||||||
# if [[ "$(uname)" == "Linux" ]]; then
|
|
||||||
# # Get uptime in seconds for Linux
|
|
||||||
# total_uptime_seconds=$(cat /proc/uptime | awk '{print $1}')
|
|
||||||
if uname | grep -q "BSD"; then
|
if uname | grep -q "BSD"; then
|
||||||
# Get uptime in seconds for BSD
|
# Get uptime in seconds for BSD
|
||||||
boot_time_seconds=$(sysctl -n kern.boottime | awk -F'[ ,]' '{print $4}')
|
boot_time_seconds=$(sysctl -n kern.boottime | awk -F'[ ,]' '{print $4}')
|
||||||
|
@ -11,9 +8,6 @@ if uname | grep -q "BSD"; then
|
||||||
else
|
else
|
||||||
total_uptime_seconds=$(cat /proc/uptime | awk '{print $1}')
|
total_uptime_seconds=$(cat /proc/uptime | awk '{print $1}')
|
||||||
total_uptime_seconds=$(printf "%.0f" "${total_uptime_seconds}")
|
total_uptime_seconds=$(printf "%.0f" "${total_uptime_seconds}")
|
||||||
#else
|
|
||||||
# echo "UNKNOWN: Unsupported system"
|
|
||||||
# exit 3
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Calculate uptime in days, hours, minutes, and seconds
|
# Calculate uptime in days, hours, minutes, and seconds
|
||||||
|
@ -23,5 +17,5 @@ uptime_minutes=$(((total_uptime_seconds % 3600) / 60))
|
||||||
uptime_seconds=$((total_uptime_seconds % 60))
|
uptime_seconds=$((total_uptime_seconds % 60))
|
||||||
|
|
||||||
# Print the result and perfdata
|
# Print the result and perfdata
|
||||||
echo "OK: Uptime is ${uptime_days}d ${uptime_hours}h ${uptime_minutes}m ${uptime_seconds}s | total_uptime_seconds=${total_uptime_seconds}s;"
|
echo "OK: Uptime is ${uptime_days}d ${uptime_hours}h ${uptime_minutes}m ${uptime_seconds}s | uptime_seconds=${total_uptime_seconds}s;"
|
||||||
exit 0
|
exit 0
|
||||||
|
|
Loading…
Reference in New Issue