Commit 86cfc366 authored by Dylan Araps's avatar Dylan Araps Committed by GitHub

Merge pull request #383 from konimex/uptime-fix

Solaris: Rewritten uptime
parents 99d43ff2 e4c7f192
......@@ -268,8 +268,6 @@ getkernel() {
# Uptime {{{
getuptime() {
case "$os" in
"Linux" | "Windows" | "Mac OS X" | "iPhone OS" | "BSD")
# Get uptime in seconds
case "$os" in
"Linux" | "Windows")
......@@ -286,6 +284,11 @@ getuptime() {
now="$(date +%s)"
seconds="$((now - boot))"
;;
"Solaris")
seconds="$(kstat -p unix:0:system_misc:snaptime | awk '{print $2}')"
seconds="${seconds/.*}"
;;
esac
days="$((seconds / 60 / 60 / 24)) days"
......@@ -310,12 +313,6 @@ getuptime() {
uptime="${days:+$days, }${hours:+$hours, }${minutes}"
uptime="${uptime%', '}"
uptime="up ${uptime:-${seconds} seconds}"
;;
"Solaris")
uptime="$(uptime | /usr/xpg4/bin/awk -F ':[0-9]{2}+[a-z][a-z] |(, ){1}+' '{printf $2}')"
;;
esac
# Make the output of uptime smaller.
case "$uptime_shorthand" in
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment