Merge pull request #383 from konimex/uptime-fix

Solaris: Rewritten uptime
This commit is contained in:
Dylan Araps 2016-10-21 20:31:23 +11:00 committed by GitHub
commit 86cfc366c2

View file

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