I got an email from my system administrator saying that I needed to reboot my system to apply some patches. I had forgotten about it and after a couple of hours I got another mail telling me that I was yet to reboot my system.
I have since rebooted my system but I'm surprised how they'd know if I had rebooted my machine or not. Can someone explain how this works?
A quick way to check this remotely can be done using SNMP (provided your SysAdmin has set this up on your network):
Most likely, the data would be polled and stored in a network management/monitoring system of some sort (i.e. Nagios or Cacti).
In case anyone is interested in playing around with the
snmpwalk
command, see the answer here to get a basic SNMP configuration set up on your system.A simple method will be to check the output of the
uptime
command, which shows how long you have been running the system without a shutdown/restart.Sample Output:
It says that my system has been powered on for 3 hours and 8 minutes.
The admin can set up a shell script to either make use of
uptime
or to use some other method, as detailed in this link. Another method the admin can utilise is to setup an email to be send at system shutdown or restart, the details are available at this link.@saji89 mentioned the
uptime
command. I'll go one step lower, and simply posit that the sysadmin has a script somewhere that connects to each computer and does acat /proc/uptime
(or something equivalent). The first field of the output is the time, in seconds, since the system was last rebooted, which is much easier to parse than the output ofuptime
. For example, my computer gives a first uptime field of1441218.24
withuptime
returningup 16 days, 16:20
. 1441218 seconds is 16 days plus 58818 seconds, and 58818 seconds is 16 1/3 hours. 16 days 16 1/3 hours.When you know the maximum length of time since the system should have been rebooted, this data makes it trivial to check to see if the system has been rebooted since then or not.
It could be done through a monitoring tool such as Nagios, or through a separate script that the sysadmin keeps on his computer (or rather accessible through it, I'd imagine) which connects to each computer in turn or in parallell and prints the time since last reboot in some format. That all depends on how elaborate to make it.
Another way, just for the sake of completeness, is to look at
/var/log/wtmp
via the last command. Example:This method is a favorite because it also happens to be the perfect mnemonic.
When a package that requires a reboot has been updated via
apt
, a file calledreboot-required
is created into/var/run/
. The sysadmin can check for the presence of this file remotely to determine if a reboot is required due to updates.This ...
is the key part.
If the admin is any good he probably set up the updates from HIS machine so the PC's do not have to download the same file from the web. If so he can see from his own machine who downloaded the patches.
He then only has to look at the IP addresses of those systems that did load the patches and send and email to those that did not. That email can even be an automatically generated mail. Imagine there are 500 machines. Manually checking each of them is a waste of time if there are several methods where he can do from his own machime.
1 very important reason for doing it this way: an admin needs to have control on what is happening on the systems he needs to maintain. So he should always have a single point of control (ie. his own machine where he has all the tools) where he can see the status of any machine.
There are several valid methods described in the answers. Logging in and checking the uptime would be strange for a large company, but doable for a smaller one. The sysadmin could have been checking via SNMP, but the same "trouble" argument could be used there.
The most likely situations are, as far as I'm concerned:
If the system is connected to a network he controls, the sysadmin can simply look at the switch or the dhcp server to see how long your network connection has been active. That will also tell him you have not rebooted.