set uptime [ns_info uptime]
if {$uptime < 60} {
set uptime [format %.2d $uptime]
} elseif {$uptime < 3600} {
set mins [expr $uptime / 60]
set secs [expr $uptime - ($mins * 60)]
set uptime "[format %.2d $mins]:[format %.2d $secs]"
} elseif {$uptime < 86400} {
set hours [expr $uptime / 3600]
set mins [expr ($uptime - ($hours * 3600)) / 60]
set secs [expr $uptime - (($hours * 3600) + ($mins * 60))]
set uptime "${hours}:[format %.2d $mins]:[format %.2d $secs]"
} else {
set days [expr $uptime / 86400]
set hours [expr ($uptime - ($days * 86400)) / 3600]
set mins [expr ($uptime - ($days * 86400) - ($hours * 3600)) / 60]
set secs [expr $uptime - ($days * 86400) - ($hours * 3600) - ($mins * 60)]
set uptime "${days}Days\n[format %.2d $hours]Hours\n[format %.2d $mins]Mins\n[format %.2d $secs]Secs"
}
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment