== tuptime ==
Report how long the system or other components has been running, count it between restarts.
* System starts.
* Total uptime that the system is active.
* Total uptime of other components.
* Medium uptime for the system.
* Actual uptime for the system.
* Historically time of removed components.
* perl 5.10 - with modules "Time::Duration", "Sys::Syslog" and "Scalar::Util"
Execute all this commands with privileged user (root).
NOTES to RedHat based systems:
Install "perl" and "perl-Time-Duration", "perl-Sys-Syslog" and "Scalar::Util" pacakges are in the perl core package. For avoid errors in "perl-Time-Duration" package, is not recommended the use of CPAN for install it because alert some warnings. This package isn't int the official repositories, but in other yes (like http://packages.sw.be/perl-Time-Duration/).
# yum install perl perl-Time-Duration
NOTES to Debian based systems:
Install the perl modules from CPAN or with the debian pacakge manager:
"Sys::Syslog" is in the Perl package core.
"Time::Duration" is in libtime-duration-perl package.
"Scalar::Util" is in the Perl package core.
# apt-get install perl libtime-duration-perl
Copy the tuptime file in /usr/bin and give it execution permission:
# cp tuptime.pl /usr/bin/tuptime
# chmod 755 /usr/bin/tuptime
Execute it with the -i option for initialize the files:
# /usr/bin/tuptime -i
And now, with -u option for update the files:
# /usr/bin/tuptime -u
Put the init.d script (Debian or RedHat) for udate the counters each time the system starts, restart or stop:
# cp tuptime.init.d-debian /etc/init.d/tuptime
# chmod 755 /etc/init.d/tuptime
# update-rc.d tuptime defaults
# cp tuptime.init.d-redhat /etc/rc.d/init.d/tuptime
# chmod 755 /etc/rc.d/init.d/tuptime
# chkconfig --add tuptime
Execute this command (with root user) for create a file in /etc/cron.d/ wich automatically update and save the count time every five minutes, is only a safety measure in case of the system had a problem and it can't execute the init script:
# echo -e "# /etc/cron.d/tuptime: crontab entrie for tuptime update. \n\nMAILTO=root\n\n*/5 * * * * root if [ -x /usr/bin/tuptime ]; then /usr/bin/tuptime -u > /dev/null ; fi" > /etc/cron.d/tuptime
If you don't want to put the init script, tuptime can work with the previous cron entry, but is less accurate.
Replace only the /usr/bin/tuptime file.
# cp /route/to/new/tuptime.pl /usr/bin/tuptime
Initialize the files and update:
# tuptime -i -u
If you upgrade from a version previous 1.5, change the name of the files:
# cp /var/lib/tuptime/uptimes /var/lib/tuptime/lastuptime
# cp /var/lib/tuptime/starts /var/lib/tuptime/sysstarts
# cp /var/lib/tuptime/times /var/lib/tuptime/totaltime
Remove the init files and links:
# rm /etc/init.d/tuptime
# update-rc.d tuptime remove
# chkconfig --del tuptime
# rm /etc/rc.d/init.d/tuptime
Remove the complete directory:
# rm -rf /var/lib/tuptime
# rm -rf /etc/tuptime
Remove the crontab file:
# rm /etc/cron.d/tuptime
Remove the script:
# rm /usr/bin/tuptime
== Using tuptime
Print values in human readable style, any user can do it:
# tuptime -p
or, value only in minutes:
# tuptime -m
Update counts values, only root user:
# tuptime -u
Configure your preferred values in the conf file (/etc/tuptime/tuptime.conf), one per line, like next example. All of them have the same time value:
You can add a time value in minutes which decrease of increase the final time, like this:
If you add hardware to a running system, you can use (# tuptime -m) to read the time in minutes that the system was running and put the difference time with the new component, like this:
# tuptime -m
System Time: 1931 minutes
And now add in /etc/tuptime/tuptime.conf:
If you put a used hardware, you cand add time to it, like the example: (5000 minutes from used hardware - 1931 from system = value to put) like this:
If you remove hardware and want a historically print of how many time was running, you can add this special line:
The special line ends with ':RM' wich indicates that this is a ReMoved hardware. Tuptime will print the name and the time, but not increase or decrease it, simply print the value. For set the value, simply print the time in minutes when you remove the hardware, like this:
# tuptime -m
OldHardware: 52368 minutes
And add to the conf file with the ':RM' end, like this:
The next time that you run tuptime, the output will be something similar (and a few time ago, the same too):
OldHardware Time: 36 days, 8 hours, and 48 minutes
The program always print the system starts count, the estimated uptime between starts and the actual uptime for additional info:
System Starts, is the count of system starts.
Uptime Date, is the date when the system started the last time.
Medium Uptime, is the medium uptime between system starts (total time between system starts).
Actual Uptime, is the actual uptime for the system.
System Starts: 79
Uptime Date: 09:07:28 30-Sep-2011
Medium Uptime: 4 hours, 41 minutes, and 14 seconds
Actual Uptime: 3 hours, 16 minutes, and 25 seconds
System Time: 15 days, 10 hours, 18 minutes, and 4 seconds
Memory Time: 1 day, 21 hours, 25 minutes, and 4 seconds
Usage: tuptime [OPTION...]
# tuptime -i Initialize the files which uses.
# tuptime -p Print the values in human readable style.
# tuptime Print the values in human readable style.
# tuptime -m Print the values in minutes.
# tuptime -u Update and save the values to disk.
# tuptime -v Verbose output.
# tuptime -h Display this help.
# tuptime -V Version information.
* Ricardo F <email@example.com> - 2011