Precise system uptime??


 
Thread Tools Search this Thread
Operating Systems Solaris Precise system uptime??
# 1  
Old 05-14-2013
Precise system uptime??

OK folks, my first post here.. hope the community can come up with a clever solution. Cross posting this in the Solaris and Shell scripting forums, as problem is scripting problem specifically on Solaris platform.

I am trying to detect a host's uptime with greater precision than is offered up by the usual suspects (e.g. uptime, who -b, last reboot -n 1, ...). These all offer only hour:minute precision, and don't include the year.

if all the target hosts were running "modern" Solaris, I might be able to grope for answer down /proc/0 (init) path for a useable timestamp, but script must run a) on older Solaris hosts, some with several hundred days of uptime, and b) without any elevated priviledges.

if I could compile some C program, I would grab the output of times(), do some math, and return a standard time value of N seconds since epoch. For the sake of this question, I must rule out that possibility. The solution must be basic Perl or shell script, executing any standard tools included with the Solaris distribution.

Anyone know of a value to inspect using kstat? mdb? dtrace?
# 2  
Old 05-15-2013
Here is a way to get the uptime in seconds that doesn't require root privilege:
Code:
kstat -p unix:0:system_misc:boot_time|nawk '
{
  srand();
  printf("%d s\n",srand()-$2);
}'


Last edited by jlliagre; 05-15-2013 at 05:53 AM.. Reason: grammar
This User Gave Thanks to jlliagre For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

[zenity] precise progress bar

Hello everyone, Is it possible to have a precise progress bar in zenity during the execution of the following: find -type f \( -not -name "$file_name".md5 \) -exec md5sum '{}' \; > "$file_name".md5Currently I am using zenity --title="Running..." --progress --pulsate --auto-close... (1 Reply)
Discussion started by: soichiro
1 Replies

2. AIX

Managed system's uptime

How to find Physical server uptime from HMC/ ASMI. Server was in standby mode. We have started the Lpar manually. Server rebooted automatically but no information updated in Lpars's errpt, alog.console or HMC prior to the reboot. (1 Reply)
Discussion started by: sunnybee
1 Replies

3. War Stories

Once upon an uptime.

Hi All, Having recently started a new job, a Data Center Migration in fact I have been tasked with looking at some of the older Solaris boxes when I came across this little gem. nismas# uname -a SunOS nismas 5.5.1 Generic_103640-27 sun4u sparc SUNW,Ultra-1 nismas# uptime 10:37am up 2900... (2 Replies)
Discussion started by: gull04
2 Replies

4. Shell Programming and Scripting

Solaris, Perl, and precise system uptime??

OK folks, my first post here.. hope the community can come up with a clever solution. Cross posting this in the Solaris and Shell scripting forums, as problem is scripting problem specifically on Solaris platform. I am trying to detect a host's uptime with greater precision than is offered up... (1 Reply)
Discussion started by: Yeaboem
1 Replies

5. Solaris

Finding system uptime without login

Hi, Am writing a script where I want to find uptime of certain servers. Is there any command where we can find uptime without login to the server, since the server list is big logging to the server will time consuming. Thanks in advance (7 Replies)
Discussion started by: rogerben
7 Replies

6. Solaris

uptime command not showing how long the system has been up

Hello folks, uptime command not shows how long the system has been up. I know it come from a corruption of /var/adm/utmpx file. I've done : cat /dev/null > /var/adm/utmpx Now who and last commands work fine. But uptime still give me back an answer without the "up time". In which... (6 Replies)
Discussion started by: gogol_bordello
6 Replies

7. Shell Programming and Scripting

Extract the uptime from the output of the uptime command

Hi! I want to extract the uptime from the output of the uptime command. The output: 11:53 up 3:02, 2 users, load averages: 0,32 0,34 0,43 I just need the "3:02" part. How can I do this? Dirk (6 Replies)
Discussion started by: Dirk Einecke
6 Replies

8. UNIX for Dummies Questions & Answers

Difference between system uptime and last boot time.

My Linux system was last rebooted few hours ago. But it seems little confusing for me to figure out the exact reason behind it. I guess following command should justify what i meant to say. # date Wed May 11 13:22:49 IST 2011 # last | grep "May 10" reboot system boot 2.6.18-194.el5 ... (5 Replies)
Discussion started by: pinga123
5 Replies

9. UNIX for Dummies Questions & Answers

Getting uptime

I'm trying to get the uptime of my computer (Mac OS X) and I can go into the terminal and type "uptime" OK, and that gives me a string with the uptime in it. The problem is that the string changes a lot, and its very difficult to get the data I'm trying to extract out cleanly. Now I have 3... (2 Replies)
Discussion started by: Freefall
2 Replies

10. UNIX for Dummies Questions & Answers

uptime

Hi Folks uptime 12:24pm up 2 days, 3:12, 4 users, load average: 0.00, 0.00, 0.00 what does the load average figure mean.. regards Hrishy (2 Replies)
Discussion started by: xiamin
2 Replies
Login or Register to Ask a Question