How Can I check Linux, Windows Machine Uptime?

-->

 

Today, 

 

somebody ask me to retrieve up time from approximately a hundreds servers accross malaysia. Since we didn’t setup any systems that will store the uptime, services and availability history information for both Linux and windows flavor…~!

 

So, we’ll use the command like below on my linux box:

 

[root@virtual ~]# last reboot

 

reboot   system boot  2.6.18-92.1.17.e Wed Nov 19 12:42         (1+07:43)

reboot   system boot  2.6.18-92.1.17.e Fri Nov 14 11:18         (5+01:20)

reboot   system boot  2.6.18-92.1.17.e Wed Nov 12 16:08         (1+19:06)

reboot   system boot  2.6.18-92.1.17.e Wed Nov 12 12:10          (03:06)

reboot   system boot  2.6.18-92.el5xen Tue Nov 11 18:10          (17:56)

 

wtmp begins Tue Nov 11 18:10:47 2008

 

The command will print the date and time of your machine rebooted or restarted…

 

well, that command will only show the history of reboot, so how do we check the uptime period?

Again, Linux come with handy tools such:

[root@virtual ~]# uptime

 20:31:10 up 1 day,  7:48,  1 user,  load average: 0.00, 0.00, 0.00

[root@virtual ~]#

Look at the result above, it show us the uptime, the time printed is the time when the machine was started / reborted…once you rebooted your Linux box, the uptime counter will reset to zero

Well, on Linux box is easy to get this information…but how about windows family machine?we also have so many MS Windows machine as much as Linux Box..

So i found that Ms Windows also provided a few tools to let the user retrieve such information. Just open up you command Prompt, and type in a command like below:

C:Documents and SettingsAdministrator>net statistics server

Server Statistics for \AZAM

Statistics since 11/20/2008 8:59 AM

Sessions accepted                  1

Sessions timed-out                 0

Sessions errored-out               121

Kilobytes sent                     130

Kilobytes received                 154

Mean response time (msec)          0

System errors                      0

Permission violations              121

Password violations                0

Files accessed                     27

Communication devices accessed     0

Print jobs spooled                 0



Times buffers exhausted

  Big buffers                      0

  Request buffers                  0

The command completed successfully.

well, so much information that I dont want on the result, but nevermind, just ignore it…

to run the command on each servers will cost me my valueable time….~!

so, I decided to write a simple script and leave a copy on each windows server, and might be using it on the future…

Just copy and paste it to notepad and save it as ‘bat’ file, with any name, your filename may look like ‘script.bat‘:

@echo off

title Check Server Uptime Status – http://blog.mohamadazam.com

:prompt

color 00

cls

echo   – Check Uptime Script for Windows

echo.

echo Type s for Server Status

echo Type w for Workstation Status

echo Type c to go to Command Prompt

echo Type q to exit

set /p answer=

if ‘%answer%’ == ‘s’ goto srv

if ‘%answer%’ == ‘S’ goto srv

if ‘%answer%’ == ‘c’ goto cmd

if ‘%answer%’ == ‘C’ goto cmd

if ‘%answer%’ == ‘q’ goto quit

if ‘%answer%’ == ‘Q’ goto quit

if ‘%answer%’ == ‘w’ goto wrk

if ‘%answer%’ == ‘W’ goto wrk

pause >nul

:srv

cls

echo.

echo.

echo       ###########################

echo  - Starting Server statistics Status -

echo       ###########################

echo.

net statistics server

echo.

echo     Press Any Key to go to MENU…

pause >nul

goto prompt

:wrk

cls

echo.

echo.

echo       ################################

echo  - Starting workstation statistics Status -

echo       ################################

echo.

net statistics server

echo.

echo     Press Any Key to go to MENU…

pause >nul

goto prompt

:quit

cls

echo   – Thanks For Using The Net Statistics Status Script By CrusheD_LameR

echo.

echo.

pause

exit

:cmd

@color 7

cls

cmd

@echo on

Or you can simply Click Here to download the file…~!

 

After i finish my effort on the script, I realized that Microsoft also provided ‘uptime.exe’ on their site…you can use that too….~!



Recent Entries

Leave a Reply