Skip to content

Commit

Permalink
Merge branch 'dev'
Browse files Browse the repository at this point in the history
  • Loading branch information
Ricardo F committed Jan 2, 2020
2 parents 0ef024b + aa60f41 commit 0b6512a
Show file tree
Hide file tree
Showing 17 changed files with 1,181 additions and 285 deletions.
17 changes: 13 additions & 4 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
tuptime (4.1.0) unstable; urgency=low

* Register shutdowns lower than a second
* Adding option -A --at
* Refactoring --tat output
* Rename suspend time to sleep time

-- Ricardo Fraile <rfraile@rfraile.eu> Wed, 01 Jan 2020 17:03:00 +0100

tuptime (4.0.0) unstable; urgency=low

* Adding support for running and suspended time. (-p, --power)
Expand Down Expand Up @@ -42,7 +51,7 @@ tuptime (3.4.0) unstable; urgency=low
* Fixed equal number of values per line in csv output
* Fix right termination when SIGPIPE signal is received
* Upgrade timer unit with tuptime-cron.timer and tuptime-cron.service
* Adding OpenRC init script
* Adding OpenRC init script
* Tuptime user without /bin/sh shell
* Support environmental variable with DB file path

Expand All @@ -65,13 +74,13 @@ tuptime (3.3.2) unstable; urgency=low

* Fix print kernel in list and table outputs in partial registers
* Consistent decimals output when seconds are used in table and list
* Accurate report in largest/shortest uptime/downtime with partial
* Accurate report in largest/shortest uptime/downtime with partial
registers in narrow ranges
* Avoid import subprocess module
* Report in default output the state of last shutdown
* Adding systemd .timer as alternative to cron schedule

-- Ricardo Fraile <rfraile@rfraile.eu> Sat, 21 Jan 2017 19:46:00 +0100
-- Ricardo Fraile <rfraile@rfraile.eu> Sat, 21 Jan 2017 19:43:00 +0100

tuptime (3.3.1) unstable; urgency=medium

Expand Down Expand Up @@ -177,7 +186,7 @@ tuptime (2.4.26) stable; urgency=low

tuptime (2.4.10) stable; urgency=low

* Fix false wrong shutdown bug when some kernels rarely report +1 or -1
* Fix false wrong shutdown bug when some kernels rarely report +1 or -1
second inside /proc/stat btime variable

-- Ricardo Fraile <rfraile@rfraile.eu> Sun, 26 Jul 2015 10:00:00 -0400
Expand Down
40 changes: 30 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ Sample output after install:

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 uptime: 100.0% - 21 minutes, 30 seconds
System downtime: 0.0% - 0 seconds
System life: 21 minutes, 30 seconds

Largest uptime: 21 minutes, 30 seconds from 21:54:09 24/09/15
Expand All @@ -57,9 +57,9 @@ Sample output after install:
If you do the same a few days after, the output may will be more similar to this:

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 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

Largest uptime: 2 hours, 10 minutes, 44 seconds from 20:49:17 09/08/15
Expand Down Expand Up @@ -105,19 +105,39 @@ Don't forget! For keep it updated, add it to the init system, to the cron servic



### What offer tuptime different than other alternatives like uptimed and downtimed
### Highlights about Tuptime internals

- It doesn't run as a daemon, at least, it only need 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 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 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 (-s) or/and in csv format, easy to pipe it to other commands.
- 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.

- Its main purpose is tracking all the system startups/shutdowns and present that information to the user in a more understandable way. Don't have mail alerts when a milestones are reached or the limitation of keep the last n records.

- Its written to avoid false startups registers, actually there are some issues with other alternatives related to that. This is an issue that sometimes happens on virtualized enviroments, servers with high load or when ntp are running.
- It's written to avoid false startups registers. This is an issue that sometimes happens when the NTP adjust the system clock, on virtualized enviroments, on servers with high load, when the system resynchronized with their RTC clock after a suspend and resume cycle...

- It can report the whole life of the system or only a part of that life, closing the range between startups/shutdowns or timestamps. Also, it reports the accumulated running and suspended time.
- It can report:
- 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 system state at specific point in time.


### Alternatives

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

downtimed - Is a program for monitoring operating system downtime, uptime, shutdowns and crashes and for keeping record of such events.
https://dist.epipe.com/downtimed/

lastwake - Analyzes the system journal and prints out wake-up and sleep timestamps; for each cycle it tells whether the system was suspended to RAM or to disk (hibernated).
https://github.com/arigit/lastwake.py

(bonus) dateutils - Not an alternative, but nifty collection of tools to work with dates.
https://github.com/hroptatyr/dateutils


### More information
Expand Down
23 changes: 20 additions & 3 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
tuptime (4.1.0) unstable; urgency=low

* Register shutdowns lower than a second
* Adding option -A --at
* Refactoring --tat output
* Rename suspend time to sleep time

-- Ricardo Fraile <rfraile@rfraile.eu> Wed, 01 Jan 2020 17:03:00 +0100

tuptime (4.0.0) unstable; urgency=low

* Adding support for running and suspended time. (-p, --power)
Expand Down Expand Up @@ -98,9 +107,17 @@ tuptime (3.3.0-1) unstable; urgency=medium

tuptime (3.3.0) unstable; urgency=low

* Release new version.

-- Ricardo Fraile <rfraile@rfraile.eu> Mon, 11 Apr 2016 09:59:43 -0500
* Refactoring code
* Adding -S --since option
* Adding -U --until option
* Adding --tsince option
* Adding --tuntil option
* Adding -n --noup option
* Adding --csv option
* Fix inconsistencies with seconds reports due rounded decimals
* Fix inconsistencies when system clock drift

-- Ricardo Fraile <rfraile@rfraile.eu> Sat, 12 Mar 2016 10:51:00 +0100

tuptime (3.2.3) unstable; urgency=low

Expand Down
3 changes: 2 additions & 1 deletion debian/control
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Section: utils
Priority: optional
Maintainer: Ricardo Fraile <rfraile@rfraile.eu>
Build-Depends: debhelper-compat (= 12)
Standards-Version: 4.4.0
Rules-Requires-Root: no
Standards-Version: 4.4.1
Homepage: https://github.com/rfrail3/tuptime

Package: tuptime
Expand Down
3 changes: 2 additions & 1 deletion misc/bsd-manual-install.txt
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ Add the cron entry and restart the service:
Copy rc.d file:

# install -m 555 tuptime/src/rc.d/freebsd/tuptime /usr/local/etc/rc.d/tuptime
# echo 'tuptime_enable="YES"' >> /etc/rc.conf
# sysrc tuptime_enable=YES
# service tuptime start

It's all done.

Expand Down
4 changes: 2 additions & 2 deletions misc/rpm/rpm-readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
Z.- For testing with "dev" branch. Install "git" on step "1" and replace step "2" with the following:

cd ~
git clone -b dev https://github.com/rfrail3/tuptime.git tuptime-4.0.0
git clone -b dev https://github.com/rfrail3/tuptime.git tuptime-4.1.0
rpmdev-setuptree
cd ~/rpmbuild/SPECS/
cp ../../tuptime-4.0.0/misc/rpm/tuptime.spec .
tar -czvf ../SOURCES/4.0.0.tar.gz ../../tuptime-4.0.0
tar -czvf ../SOURCES/4.1.0.tar.gz ../../tuptime-4.1.0
rpmbuild -ba --target=noarch tuptime.spec
4 changes: 2 additions & 2 deletions misc/rpm/tuptime.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: tuptime
Version: 4.0.0
Version: 4.1.0
Release: 1%{?dist}
Summary: Report historical system real time

Expand Down Expand Up @@ -88,5 +88,5 @@ su -s /bin/sh tuptime -c "(umask 0022 && /usr/bin/tuptime -x)"


%changelog
* Sat Jan 05 2019 Ricardo Fraile <rfraile@rfraile.eu> 4.0.0-1
* Wed Jan 01 2020 Ricardo Fraile <rfraile@rfraile.eu> 4.1.0-1
- RPM release
25 changes: 25 additions & 0 deletions misc/scripts/readme.txt → misc/scripts/README.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,26 @@
#### Scripts #####




____Tools____

tuptime_dbcheck.py
Test database integrity. Catch and fix errors.

tuptime_join.py
Join two tuptime db files into an other one.

tuptime_modify.py
Modify registers keeping nearest values in sycn.
Allow change 'end status', 'startup date' and 'shutdown date'.





____DB migrations____

db-tuptime-migrate.sh
Update tuptime database format from versions previous than 3.0.00.

Expand All @@ -17,6 +38,10 @@ uptimed-to-tuptime.py
Migrate Uptimed records to Tuptime.




____Plots____

tuptime-barchart_from_db.py
Graph a daily plot reading directly from tuptime database.

Expand Down
6 changes: 3 additions & 3 deletions misc/scripts/db-tuptime-migrate-3.1-to-4.0.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# Change the db origin:
# btime integer, uptime real, offbtime integer, endst integer, downtime real, kernel text
# to:
# btime integer, uptime real, rntime real, spdtime real, offbtime integer, endst integer, downtime real, kernel text
# btime integer, uptime real, rntime real, slptime real, offbtime integer, endst integer, downtime real, kernel text

SOURCE_DB='/var/lib/tuptime/tuptime.db'
USER_DB=$(stat -c '%U' ${SOURCE_DB})
Expand Down Expand Up @@ -41,13 +41,13 @@ if [ $? -ne 0 ]; then
fi

# Adding new columns
sqlite3 ${TMP_DBF} "CREATE TABLE tuptimeNew (btime integer, uptime integer, rntime integer, spdtime integer, offbtime integer, endst integer, downtime integer, kernel text);" && \
sqlite3 ${TMP_DBF} "CREATE TABLE tuptimeNew (btime integer, uptime integer, rntime integer, slptime integer, offbtime integer, endst integer, downtime integer, kernel text);" && \
sqlite3 ${TMP_DBF} "UPDATE tuptime SET offbtime = cast(round(offbtime) as int);" && \
sqlite3 ${TMP_DBF} "UPDATE tuptime SET uptime = cast(round(uptime) as int);" && \
sqlite3 ${TMP_DBF} "UPDATE tuptime SET downtime = cast(round(downtime) as int);" && \
sqlite3 ${TMP_DBF} "INSERT INTO tuptimeNew(btime, uptime, offbtime, endst, downtime, kernel) SELECT btime, uptime, offbtime, endst, downtime, kernel FROM tuptime;" && \
sqlite3 ${TMP_DBF} "UPDATE tuptimeNew SET rntime = uptime;" && \
sqlite3 ${TMP_DBF} "UPDATE tuptimeNew SET spdtime = 0;" && \
sqlite3 ${TMP_DBF} "UPDATE tuptimeNew SET slptime = 0;" && \
sqlite3 ${TMP_DBF} "DROP TABLE tuptime;" && \
sqlite3 ${TMP_DBF} "ALTER TABLE tuptimeNew RENAME TO tuptime;"
if [ $? -ne 0 ]; then
Expand Down
Loading

0 comments on commit 0b6512a

Please sign in to comment.