Skip to content

Commit

Permalink
Merge branch 'dev' with 5.0.0 release
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo F committed May 30, 2020
2 parents 0b6512a + 6f8faaf commit fe9966c
Show file tree
Hide file tree
Showing 34 changed files with 1,451 additions and 2,203 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG
@@ -1,3 +1,17 @@
tuptime (5.0.0) unstable; urgency=low

* Abbreviate format in time counters
* Identify new startups with boot_id
* Adding -b, --bootid option to show boot IDs
* Adding -i, --invert option to show startup number in reverse count
* Change database specs. Add bootid column
* After a graceful shutdown register, delay 5 seconds next DB update
* Change execution user from 'tuptime' to '_tuptime'
* Large refactoring
* Update .deb package

-- Ricardo Fraile <rfraile@rfraile.eu> Tue, 26 May 2020 19:58:00 +0100

tuptime (4.1.0) unstable; urgency=low

* Register shutdowns lower than a second
Expand Down
144 changes: 74 additions & 70 deletions README.md
Expand Up @@ -4,112 +4,113 @@ tuptime
Tuptime is a tool for report the historical and statistical real time of the system, keeping it between restarts. Like uptime command but with more interesting output.


### Basic Installation and usage
### Sample output

#### Package installation
Just after install:

* Debian: https://packages.debian.org/tuptime
* Ubuntu: https://packages.ubuntu.com/tuptime
* ArchLinux: https://aur.archlinux.org/packages/tuptime
* FreeBSD: https://www.freshports.org/sysutils/tuptime
System startups: 1 since 21:54:09 24/09/15
System shutdowns: 0 ok - 0 bad
System life: 21m 30s

#### Manual installation
System uptime: 100.0% - 21m 30s
System downtime: 0.0% - 0s

In a Linux or FreeBSD system...
Average uptime: 21m 30s
Average downtime: 0s

Clone the repo:
Current uptime: 21m 30s since 21:54:09 24/09/15

git clone https://github.com/rfrail3/tuptime.git
A few days later:

Copy the "tuptime" file located under "latest/" directory to "/usr/bin/" and make it executable:
System startups: 110 since 10:15:27 08/08/15
System shutdowns: 107 ok - 2 bad
System life: 47d 12h 2m 15s

cp tuptime/src/tuptime /usr/bin/tuptime
chmod ugo+x /usr/bin/tuptime
System uptime: 4.04% - 1d 22h 4m 44s
System downtime: 95.96% - 45d 13h 57m 30s

Assure that the system pass the prerequisites:
Average uptime: 25m 8s
Average downtime: 9h 56m 42s

python 3.X
Current uptime: 23m 33s since 21:54:09 24/09/15

Run first with a privileged user:
Swich to -t | --table option:

tuptime
No. Startup Date Uptime Shutdown Date End Downtime
1 10:15:27 08/08/15 42s 10:16:09 08/08/15 OK 16s
2 10:16:26 08/08/15 49s 10:17:15 08/08/15 OK 16s
3 10:17:32 08/08/15 5m 47s 10:23:19 08/08/15 OK 16s
4 10:23:36 08/08/15 9s 10:23:45 08/08/15 BAD 42s
5 10:24:28 08/08/15 2h 9m 27s 12:33:55 08/08/15 OK 41m 44s
. . .

#### Examples
Or swich to -l | --list option:

Sample output after install:
Startup: 1 at 10:15:27 08/08/15
Uptime: 42s
Shutdown: OK at 10:16:09 08/08/15
Downtime: 16s

System startups: 1 since 21:54:09 24/09/15
System shutdowns: 0 ok - 0 bad
System uptime: 100.0% - 21 minutes, 30 seconds
System downtime: 0.0% - 0 seconds
System life: 21 minutes, 30 seconds
Startup: 2 at 10:16:26 08/08/15
Uptime: 49s
Shutdown: OK at 10:17:15 08/08/15
Downtime: 16s

Startup: 3 at 10:17:32 08/08/15
Uptime: 5m 47s
Shutdown: OK at 10:23:19 08/08/15
Downtime: 16s
. . .

Largest uptime: 21 minutes, 30 seconds from 21:54:09 24/09/15
Shortest uptime: 21 minutes, 30 seconds from 21:54:09 24/09/15
Average uptime: 21 minutes, 30 seconds

Largest downtime: 0 seconds
Shortest downtime: 0 seconds
Average downtime: 0 seconds
### Basic Installation

Current uptime: 21 minutes, 30 seconds since 21:54:09 24/09/15

If you do the same a few days after, the output may will be more similar to this:
#### By package manager

System startups: 110 since 10:15:27 08/08/15
System shutdowns: 107 ok - 2 bad
System uptime: 4.04% - 1 days, 22 hours, 4 minutes, 44 seconds
System downtime: 95.96% - 45 days, 13 hours, 57 minutes, 30 seconds
System life: 47 days, 12 hours, 2 minutes, 15 seconds
* Debian: https://packages.debian.org/tuptime
* Ubuntu: https://packages.ubuntu.com/tuptime
* ArchLinux: https://aur.archlinux.org/packages/tuptime
* CentOS, Fedora: https://copr.fedorainfracloud.org/coprs/frankcrawford/tuptime/
* FreeBSD: https://www.freshports.org/sysutils/tuptime

Largest uptime: 2 hours, 10 minutes, 44 seconds from 20:49:17 09/08/15
Shortest uptime: 9 seconds from 10:23:36 08/08/15
Average uptime: 25 minutes, 8 seconds

Largest downtime: 7 days, 10 hours, 17 minutes, 26 seconds from 06:09:45 10/08/15
Shortest downtime: 15 seconds from 19:27:24 19/09/15
Average downtime: 9 hours, 56 minutes, 42 seconds
#### By one-liner script

Current uptime: 23 minutes, 33 seconds since 21:54:09 24/09/15
bash <(curl -Ls https://git.io/tuptime-install.sh)

Or this, with -t | --table option:

No. Startup Date Uptime Shutdown Date End Downtime
1 10:15:27 08/08/15 42 seconds 10:16:09 08/08/15 OK 16 seconds
2 10:16:26 08/08/15 49 seconds 10:17:15 08/08/15 OK 16 seconds
3 10:17:32 08/08/15 5 minutes, 47 seconds 10:23:19 08/08/15 OK 16 seconds
4 10:23:36 08/08/15 9 seconds 10:23:45 08/08/15 BAD 42 seconds
5 10:24:28 08/08/15 2 hours, 9 minutes, 27 seconds 12:33:55 08/08/15 OK 41 minutes, 44 seconds
. . .
#### By manual method

Or this, with -l | --list option:
Briefly in a Linux or FreeBSD system...

Startup: 1 at 10:15:27 08/08/15
Uptime: 42 seconds
Shutdown: OK at 10:16:09 08/08/15
Downtime: 16 seconds
Clone the repo:

Startup: 2 at 10:16:26 08/08/15
Uptime: 49 seconds
Shutdown: OK at 10:17:15 08/08/15
Downtime: 16 seconds
git clone https://github.com/rfrail3/tuptime.git

Startup: 3 at 10:17:32 08/08/15
Uptime: 5 minutes, 47 seconds
Shutdown: OK at 10:23:19 08/08/15
Downtime: 16 seconds
. . .
Copy the 'tuptime' file located under 'latest/' directory to '/usr/bin/' and make it executable:

Don't forget! For keep it updated, add it to the init system, to the cron service and use 'tuptime' user for execution. (All scripts, units and related files are provided inside this repo)
cp tuptime/src/tuptime /usr/bin/tuptime
chmod ugo+x /usr/bin/tuptime

Assure that the system pass the prerequisites:

python 3.X

Run first with a privileged user:

tuptime

Pick from 'src/' folder the right file for your cron and init manager, setup both
properly. See 'tuptime-manual.txt' for more information.


### Highlights about Tuptime internals

- It doesn't run as a daemon, at least, it only needs execution when the init manager startup and shutdown the system. To avoid issues with a switch off without a proper shutdown, like power failures, a cron job and a .timer unit are shipped with the project to update the registers each n minutes. As a system administrator, you can easily choose the best number for your particular system requirements.

- It is written in Python using common modules and as few as possible, easy to see what is inside it, and modify it for fit for your particular use case.
- It is written in Python using common modules and as few as possible, quick execution, easy to see what is inside it, and modify it for fit for your particular use case.

- It registers the times in a sqlite database. Any other software can use it. The specs are in the tuptime-manual.txt. Also, it has the option to output the registers in seconds and epoch or/and in csv format, easy to pipe it to other commands.

Expand All @@ -121,12 +122,15 @@ Don't forget! For keep it updated, add it to the init system, to the cron servic
- Registers as a table or list ordering by any label.
- The whole life of the system or only a part of it, closing the range between startups/shutdowns or timestamps.
- Accumulated running and sleeping time over an uptime.
- The kernel version used.
- The kernel version used and boot idenfiers.
- The system state at specific point in time.


### Alternatives

journalctl --list-boots - Show a tabular list of boot numbers (relative to the current boot), their IDs, and the timestamps of the first and last message pertaining to the boot.
https://github.com/systemd/systemd/

uptimed - Is an uptime record daemon keeping track of the highest uptimes a computer system ever had. It uses the system boot time to keep sessions apart from each other.
https://github.com/rpodgorny/uptimed

Expand Down
14 changes: 14 additions & 0 deletions debian/changelog
@@ -1,3 +1,17 @@
tuptime (5.0.0) unstable; urgency=low

* Abbreviate format in time counters
* Identify new startups with boot_id
* Adding -b, --bootid option to show boot IDs
* Adding -i, --invert option to show startup number in reverse count
* Change database specs. Add bootid column
* After a graceful shutdown register, delay 5 seconds next DB update
* Change execution user from 'tuptime' to '_tuptime'
* Large refactoring
* Update .deb package

-- Ricardo Fraile <rfraile@rfraile.eu> Tue, 26 May 2020 19:58:00 +0100

tuptime (4.1.0) unstable; urgency=low

* Register shutdowns lower than a second
Expand Down
5 changes: 2 additions & 3 deletions debian/control
Expand Up @@ -2,9 +2,9 @@ Source: tuptime
Section: utils
Priority: optional
Maintainer: Ricardo Fraile <rfraile@rfraile.eu>
Build-Depends: debhelper-compat (= 12)
Build-Depends: debhelper-compat (= 13)
Rules-Requires-Root: no
Standards-Version: 4.4.1
Standards-Version: 4.5.0
Homepage: https://github.com/rfrail3/tuptime

Package: tuptime
Expand All @@ -18,4 +18,3 @@ Depends: ${misc:Depends}, ${shlibs:Depends}
Description: report historical system real time
Tuptime track and report historical and statistical real time of the
system, keeping the uptime and downtime between shutdowns.
Includes an Uptimed migration script.
21 changes: 14 additions & 7 deletions debian/postinst
Expand Up @@ -20,23 +20,30 @@ set -e

case "$1" in
configure)
if ! getent passwd tuptime >/dev/null ; then
echo "Adding tuptime user ..."

# Rename to underscore if previous exists
getent passwd tuptime >/dev/null && usermod -l _tuptime tuptime
getent group tuptime > /dev/null && groupmod -n _tuptime tuptime

# Create user if not exists
if ! getent passwd _tuptime >/dev/null ; then
echo "Adding _tuptime user..."
adduser --quiet --system --group --disabled-password \
--home "/var/lib/tuptime" \
--shell '/usr/sbin/nologin' \
--gecos 'Tuptime execution user,,,' tuptime
--gecos 'Tuptime execution user,,,' \
--force-badname _tuptime
fi

# ensure right ownership
# Ensure right ownership
if [ -d /var/lib/tuptime ]; then
chown tuptime:tuptime /var/lib/tuptime
chown _tuptime:_tuptime /var/lib/tuptime
if [ -f /var/lib/tuptime/tuptime.db ]; then
chown tuptime:tuptime /var/lib/tuptime/tuptime.db
chown _tuptime:_tuptime /var/lib/tuptime/tuptime.db
fi
fi

su -s /bin/sh tuptime -c "tuptime -x"
su -s /bin/sh _tuptime -c "tuptime -x"
;;

abort-upgrade|abort-remove|abort-deconfigure)
Expand Down
2 changes: 1 addition & 1 deletion debian/postrm
Expand Up @@ -22,7 +22,7 @@ set -e
case "$1" in
purge|disappear)
rm -rf /var/lib/tuptime/
deluser tuptime || true
deluser _tuptime || true
;;

remove|upgrade|failed-upgrade|abort-install|abort-upgrade)
Expand Down
1 change: 0 additions & 1 deletion debian/tuptime.install
Expand Up @@ -2,4 +2,3 @@ src/systemd/tuptime.service lib/systemd/system/
src/init.d/debian/tuptime etc/init.d/
src/cron.d/tuptime etc/cron.d/
src/tuptime usr/bin/
misc/scripts/uptimed-to-tuptime.py usr/share/doc/tuptime/contrib/

0 comments on commit fe9966c

Please sign in to comment.