Tag Info

Hot answers tagged

8

Load is not equal to CPU usage. It is basically an indicator how many processes are waiting to be executed. Some helpful links: http://superuser.com/questions/23498/what-does-load-average-mean-in-unix-linux http://blog.scoutapp.com/articles/2009/07/31/understanding-load-averages


8

If you have a separate server to run your check script on, something like this would do a simple Ping test to see if the server is alive: #!/bin/bash SERVERIP=192.168.2.3 NOTIFYEMAIL=test@example.com ping -c 3 $SERVERIP > /dev/null 2>&1 if [ $? -ne 0 ] then # Use your favorite mailer here: mailx -s "Server $SERVERIP is down" -t ...


8

In general, on a RPM-based distribution like Fedora, you can find the name of the package which provides a given command with rpm -qf /path/to/command. Like this: $ rpm -qf $( which uptime ) procps-3.2.8-18.20110302git.fc16.x86_64 You can then download the source RPM with yumdownloader --source procps. (yumdownloader comes from the yum-utils package, if ...


7

Uptime is part of the 'procps' package, the upstream source is at http://procps.sourceforge.net/ (Not a fedora user, so not sure where to find their .src.rpm). To answer the question you didn't ask, however; take a look in /proc/uptime The first number is seconds since boot. You should be able to turn that into something usable fairly easily :)


5

Pinging is an option, but on many occasions a machine will be able to send a ping reply, while the actual server that it is all about is down. It is better do an end-to-end test. In the below example a page is requested from the webserver. If it is a webserver, it would look something like this: #!/bin/bash wget -qO /dev/null ...


4

As log-files are usually deleted after some time, the total up-time is difficult to get. If the hard disk is as old as the PC, the RAW value (last number) of smartctl -a /dev/sda | grep Power_On_Hours could give a rough estimate how many hours the PC was used.


4

Load average is the number of processes who are in waiting queue for CPU time. These three values are the average number of processes in waiting queue for past 1, 5 and 15 minutes. I would suggest you to read the following articles: Linux Troubleshooting, Part I: High Load Examining Load Average I personally believes more on CPU IDLE Time than on load ...


3

uptimed One such tool that I came across many years ago is called uptimed. The project site is here: http://podgorny.cz/moin/Uptimed. This is a pretty straightforward install, given uptimed appears to be in most of the major distros' repositories. Installation $ sudo yum install uptimed Once installed the service needs to be configured so that it will ...


3

You can use the following 2 commands (who & last) to find out the last time the system was rebooted and also messages about previous shutdown or runlevel changes. Last time system booted? For this you can use the who command. Specifically with the -b switch. $ who -b system boot 2013-08-01 17:56 This says the last time the system was ...


3

You can do this for example with perl and some simple math: cat /proc/uptime | perl -ne '/(\d*)/ ; printf "%02d:%02d:%02d:%02d\n",int($1/86400),int(($1%86400)/3600),int(($1%3600)/60),$1%60' If you do not need the seconds, you can simply run the uptime command. Its output can then be simply transformed to DD:HH:MM. For example using (works this way only ...


3

On any POSIX-compliant system, you can use the etime column of ps. LC_ALL=POSIX ps -o etime= $PID The output is broken down into days, hours, minutes and seconds with the syntax [[dd-]hh:]mm:ss. You can work it back into a number of seconds with simple arithmetic: t=$(LC_ALL=POSIX ps -o etime= $PID) d=0 h=0 case $t in *-*) d=${t%%-*}; t=${t#*-};; esac ...


2

No, because it's not really a hard problem. Divide the number of seconds by 86400 using integer division to get the number of days. Take the remainder and divide that by 3600 to get the number of hours. Divide the remainder of that by 60 to get the number of minutes, and you're left with the number of seconds. All this is doable from the shell using the ...


2

Uptime shows the output of /proc/loadavg for loads. The manpage of man 5 proc says /proc/loadavg The first three fields in this file are load average figures giving the number of jobs in the run queue (state R) or waiting for disk I/O (state D) averaged over 1, 5, and 15 minutes. So you can have high loads even if you ...


1

the machine is remote/embed in a system.Sometimes the electricity is shut down. The internet connection is very slow Does the system have a clock and a battery in it?1 A lot of embedded systems don't. If not, this: Some other answers would say that the ntp server was launched after the reboot and so the system had to go backwards to set the ...


1

/var/log/messages That is the main log file you should check for messages related to this. Additionally either /var/log/syslog (Ubuntu) or /var/log/secure (CentOS) To find out when your server was last rebooted just type uptime to see how long it has been up.


1

If you have some server, use commands like: uptime w last HDD SMARTCTL is also good try. Also from installation could be information about date created of some files in filesystem. Think about, which files were created with installing of your system? If you have linux, look at the date of creation of your /root/ directory. If you have windows, it ...


1

If you are using Ubuntu then add below lines in "/etc/rc0.d/S60umountroot" at the beginning. Log="/var/log/uptime.log" echo "$(date) $(/usr/bin/uptime)" >> "${Log}" or you can simply use logger logger "UPTIME: $(uptime)" then it will gives details in /var/log/syslog or /var/log/messages Note :- Please careful edit this file If you are using ...


1

Here is how I solved the same problem #!/bin/bash NOTIFYEMAIL=<your email> SMSEMAIL=<cell phone number @ sms-gateway> SENDEREMAIL=alert@localhost SERVER=http://127.0.0.1/ PAUSE=60 FAILED=0 DEBUG=0 while true do /usr/bin/curl -sSf $SERVER > /dev/null 2>&1 CS=$? # For debugging purposes if [ $DEBUG -eq 1 ] then echo "STATUS = $CS" ...


1

[I caught some misconceptions here which I think will this post clear off eventually] There should not be any difference since both refer to /var/run/utmp file, which has its own format to store the records. If at all there is any difference, then your utmp file is busted. uptime shows the amount of time that has passed since the system has been booted or ...



Only top voted, non community-wiki answers of a minimum length are eligible