1835221 Members
2070 Online
110078 Solutions
New Discussion

uptime script

 
Tapas Jha
Valued Contributor

uptime script

Hello,

I didn't find in forum exactly What i want. Can you help me out?

I don't have any tool to calculate uptime report for server.
I am using HP-ux 11.00 on 9000/800/L2000-5X. We have more than 6
hp-ux servers.

If anybody can give me any script or tell me how to calculate server
uptime then it would be better for me. Can i get six months back uptime?
If yes how?

Will be Highly obliged for any suggestion and help.

Rgds
Tapas
Tapas Jha
10 REPLIES 10
Pete Randall
Outstanding Contributor

Re: uptime script

Try the uptime command! man uptime


Pete

Pete
Bharat Katkar
Honored Contributor

Re: uptime script

Hi,

Use "uptime" and "ruptime" commands. Also you need to start rwhod daemon.

See man uptime.

Regards,
You need to know a lot to actually know how little you know
Chris Wilshaw
Honored Contributor

Re: uptime script

It depends on what level up uptime information you want.

For the current value, just use the uptime command.

Some historical data can be found in /etc/shutdownlog (but this won't tell you how long your server was down for).

What you probably need to do is to set up a script in /sbin/init.d which will be called at startup and shutdown, which creates a log entry indicating when the server state changed (this won't capture crash information though).

You also need to consider if you want your report to availability details of the applications on your servers (in my experience, you're more likely to see application downtime than server downtime). In order to do this, you'd need to extract the relevant details from your application log files.
Geoff Wild
Honored Contributor

Re: uptime script

How about:

last |grep reboot

What would work nicely is Big Brother:

http://www.bb4.org/

It has built in availability reports that are generated in a nice web view.


Rgds...Geoff
Proverbs 3:5,6 Trust in the Lord with all your heart and lean not on your own understanding; in all your ways acknowledge him, and he will make all your paths straight.
Steve Steel
Honored Contributor

Re: uptime script

Hi

Use w


topaz:/root # w
3:11pm up 53 days, 6:21, 11 users, load average: 0.02, 0.03, 0.03
User tty login@ idle JCPU PCPU what
root console 2:10pm576:53 15:48 15:48 -sh
steves pts/1 10:54am 17 -sh
root pts/2 9:03am 27:21 7 7 -sh
root pts/3 3:28pm 46:27 2 2 -sh
root pts/4 12:19pm573:09 5 5 -sh
root pts/5 3:38pm 22:25 -sh
root pts/6 11:49am 3:20 -sh
root pts/7 1:06pm 26 rlogin wilson
root pts/10 3:11pm w
root pts/11 2:48pm 23 telnet wilsongsp
root pts/5 2:50pm 22:25 -sh
topaz:/root #

Gives a useful snapshot


Steve Steel
If you want truly to understand something, try to change it. (Kurt Lewin)
Muthukumar_5
Honored Contributor

Re: uptime script

We can get the systems uptime using uptime command or with w ( it include uptime + currectly logged users)

If you want to calculate server's uptime on the whole local network ruptime. But rwhod(eamon) must be running on all systems in the network

If you want get uptime sometime back, change the time and date settings using date command and check the uptime command.

uptime
2:51am up 4:43, 3 users, load average: 0.00, 0.00, 0.00
date 08030151
date: do you really want to run time backwards?[yes/no]yes
unable to write utmps record to wtmps database
unable to write utmps record to wtmps database
Tue Aug 3 01:51:00 PDT 2004
uptime
1:51am up 4:43, 3 users, load average: 0.00, 0.00, 0.00

It will do that.
Easy to suggest when don't know about the problem!
Chris Wilshaw
Honored Contributor

Re: uptime script

Muthukumar,

I (and hopefully many others) would say that you should never reset the date on a server just to get the uptime reading at that time.

Depending on what applications you're running, you could create a serious problem for yourself with duplicate timestamps etc.
Chris Wilshaw
Honored Contributor

Re: uptime script

hit submit too early then.

Meant to say that in fact, changing the time won't even give you that;

2:51am up 4:43, 3 users, load average: 0.00, 0.00, 0.00
date 08030151
date: do you really want to run time backwards?[yes/no]yes
unable to write utmps record to wtmps database
unable to write utmps record to wtmps database
Tue Aug 3 01:51:00 PDT 2004
uptime
1:51am up 4:43, 3 users, load average: 0.00, 0.00, 0.00

As you can see, in both cases, your uptime value is 4:43
Muthukumar_5
Honored Contributor

Re: uptime script

hai Chris Wilshaw . Thanks for making me to know the problem and nice explanation.
Easy to suggest when don't know about the problem!
Tapas Jha
Valued Contributor

Re: uptime script

Thanx all.
Chris: Yes you are right. Actually i want something which will report me previous months uptime report also(i mean the duration of shutdown).

Geoff: I have not tried bigbrother yet. Just downloaded. Don't knwo how to use.


BTW, if do anyone of you have any good script which calculates uptime
based on server shutdowndown log and uptime then it will be great.

Rgds
Tapas
Tapas Jha