rfmoz / tuptime

Report historical and statistical real time of the system, keeping it between restarts. Like uptime command but with more interesting output.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

tuptime on AUR out of date and doesn't work

bshor opened this issue · comments

Hi, tuptime on AUR has been marked out of date and no longer works.

Installing via one-line shell script doesn't work for me either.

I have Garuda Linux, all updated with zen kernel 5.15.

Hi Boris,

You're right, AUR was a bit old but it seems to work anyway with an easy fix.
The following steps are done with this Garuda version (the current one today):

$ lsb_release  -a
LSB Version:	1.4
Distributor ID:	Garuda
Description:	Garuda Linux
Release:	Soaring
Codename:	Harpy-Eagl

$ uname -a
Linux garuda 5.15.5-zen1-1-zen #1 ZEN SMP PREEMPT Thu, 25 Nov 2021 22:09:35 +0000 x86_64 GNU/Linux

Install the AUR package and fix the error with an execution with the priviled account:

$ git clone https://aur.archlinux.org/tuptime.git
$ cd tuptime/
$ makepkg -si
$ tuptime 
ERROR:root:Checking db path "/var/lib/tuptime": [Errno 13] Permission denied: '/var/lib/tuptime'

# Fix the error with:
$ sudo tuptime 

# And set it at startup:
$ sudo systemctl enable tuptime
$ sudo systemctl start tuptime

# Reboot and see the result
$ tuptime

Anyway, I also tested the one line script and it wokrs fine:

# bash <(curl -Ls https://git.io/tuptime-install.sh)

++ Tuptime installation script ++

+ Getting source tar file
  [OK]
+ Copying files
  [OK]
+ Creating Tuptime execution user '_tuptime'
  [OK]
+ Creating Tuptime db
  [OK]
+ Setting Tuptime db ownership
  [OK]
+ Executing Tuptime with '_tuptime' user for testing
  [OK]
+ Copying Systemd file
Created symlink /etc/systemd/system/multi-user.target.wants/tuptime.service → /usr/lib/systemd/system/tuptime.service.
  [OK]
+ Copying tuptime-cron.timer and .service
Created symlink /etc/systemd/system/timers.target.wants/tuptime-cron.timer → /usr/lib/systemd/system/tuptime-cron.timer.
  [OK]
+ Enjoy!

System startups: 	1  since  19:33:32 18/12/21
System shutdowns: 	0 ok  +  0 bad
System life: 	        2m 54s

System uptime: 	        100.0%  =  2m 54s
System downtime: 	0.0%  =  0s

Average uptime: 	2m 54s
Average downtime: 	0s

Current uptime: 	2m 54s  since  19:33:32 18/12/21

# systemctl status tuptime
● tuptime.service - Tuptime service
     Loaded: loaded (/usr/lib/systemd/system/tuptime.service; enabled; vendor preset: disabled)
     Active: active (exited) since Sat 2021-12-18 19:36:26 CET; 20s ago
       Docs: man:tuptime(1)
             file:///usr/share/doc/tuptime/tuptime-manual.txt.gz
   Main PID: 2140 (code=exited, status=0/SUCCESS)
        CPU: 54ms

dic 18 19:36:26 garuda systemd[1]: Starting Tuptime service...
dic 18 19:36:26 garuda systemd[1]: Finished Tuptime service.

# reboot

# tuptime 
System startups: 	2  since  19:33:32 18/12/21
System shutdowns: 	1 ok  +  0 bad
System life: 	        5m 29s

System uptime: 	        66.57%  =  3m 39s
System downtime: 	33.43%  =  1m 50s

Average uptime: 	1m 50s
Average downtime: 	1m 50s

Current uptime: 	15s  since  19:38:46 18/12/21

Thanks for looking into this. Unfortunately both methods still fail for me.

The first method git clones and makes the package successfully, but gives me the same error as the AUR package:

Traceback (most recent call last):
  File "/usr/bin/tuptime", line 1298, in <module>
    main()
  File "/usr/bin/tuptime", line 1294, in main
    print_default(db_rows, btime, uptime, rntime, slptime, kernel, arg)
  File "/usr/bin/tuptime", line 1017, in print_default
    cal['tot']['downtime'] += row['downtime']
TypeError: unsupported operand type(s) for +=: 'int' and 'NoneType'

The second method fails with this error:

sudo  bash <(curl -Ls https://git.io/tuptime-install.sh)
bash: /dev/fd/63: No such file or directory

Interestingly, another system running Garuda Linux has tuptime run fine, despite being "out of date".

Right, please try the command with a second "<", like this one:

$ sudo bash < <(curl -Ls https://git.io/tuptime-install.sh)

++ Tuptime installation script ++
...

Could you provide the output of tuptime -v? It seems that the system values aren't loaded from the system.

Also, if you attach the file /var/lib/tuptime/tuptime.db here I'll take a look on it to check the behaviour.

With the addition of the second "<" I get installation, but still the same error about unsupported operands.

Github isn't allowing me to attach a DB file. How can I send it to you?

The error still exists because the DB keep the wrong information.

You can upload the file to a sharing service like https://www.file.io/ and paste the url here.

After that, delete the file /var/lib/tuptime/tuptime.db and restart the service with systemctl restart tuptime.service. That must works.

Here is the link.

After deleting the database, it now runs (of course there is no data anymore).

The interpretation of the DB registers shows that the time reported by the system goes backward, probably related with the suspend power state.

Last versions of Tuptime (v5 and above) improve the logic to avoid the related problem, the use of DB transactions and Boot ID make harder to fall into the same situation.

Thanks for the file, indeed, it was helpful to understand the situation and reinforce the Tuptime behaviour.

Please, if you keep getting errors or the registers seems abnormal, let me know.

Yup, I use suspend on that machine every day (but I use it on other machines where it didn't fail, too).

Looking forward to the new version!

Hi guys!
Sorry for the late update. The AUR package is now also at version 5.0.2.

Great!

Also @dstengele, could you apply the following path? It fix an issue with the .timer unit and give more information to the user:

diff --git a/PKGBUILD b/PKGBUILD
index a44b357..75a242d 100644
--- a/PKGBUILD
+++ b/PKGBUILD
@@ -1,7 +1,7 @@
 # Maintainer: Dennis Stengele <d.stengele (at) derintendant (dot) de>
 pkgname=tuptime
 pkgver=5.0.2
-pkgrel=1
+pkgrel=2
 pkgdesc="Report the historical and statistical running time of system"
 arch=('any')
 url="https://github.com/rfrail3/tuptime"
@@ -26,6 +26,5 @@ package() {
     install -D -m644 "src/systemd/tuptime-cron.service" "$pkgdir/usr/lib/systemd/system/tuptime-cron.service"
     install -D -m644 "src/systemd/tuptime-cron.timer" "$pkgdir/usr/lib/systemd/system/tuptime-cron.timer"
     install -d -m755 "$pkgdir/usr/lib/systemd/system/timers.target.wants"
-    ln -s "../tuptime.timer" "$pkgdir/usr/lib/systemd/system/timers.target.wants/tuptime.timer"
     ln -s "../tuptime-cron.timer" "$pkgdir/usr/lib/systemd/system/timers.target.wants/tuptime-cron.timer"
 }
diff --git a/tuptime.install b/tuptime.install
index 322af16..e344478 100644
--- a/tuptime.install
+++ b/tuptime.install
@@ -1,7 +1,14 @@
 post_install() {
+    echo "|--------------------------- tuptime ---------------------------|"
     echo ""
-    echo "tuptime has been installed and the corresponding .timer unit"
-    echo "has been enabled. To start tuptime now, run"
-    echo "    # systemctl start tuptime.timer"
+    echo "    Tuptime has been installed correctly."
+    echo "    Finish the setup enabling and staring their units with:"
     echo ""
+    echo "        systemctl enable tuptime.service"
+    echo "        systemctl start tuptime.service"
+    echo "        systemctl enable tuptime-cron.timer"
+    echo "        systemctl start tuptime-cron.timer"
+    echo "        systemctl start tuptime-cron.service"
+    echo ""
+    echo "|---------------------------------------------------------------|"
 }

I see the new version on AUR! Great! But ... since I installed via the shell script, it complains about conflicting files. How do I uninstall the shell script version?

error: failed to commit transaction (conflicting files)
tuptime: /usr/bin/tuptime exists in filesystem
tuptime: /usr/lib/systemd/system/tuptime-cron.service exists in filesystem
tuptime: /usr/lib/systemd/system/tuptime-cron.timer exists in filesystem
tuptime: /usr/lib/systemd/system/tuptime.service exists in filesystem
Errors occurred, no packages were upgraded.

Try the installation again after deleting the files reported on the error, but take into account that an user reported an error after last update on AUR.

Hi @dstengele

Plus the previous patch, the error reported on AUR have this solution:

diff --git a/PKG b/PKG
index a44b357..4d42b09 100644
--- a/PKG
+++ b/PKG
@@ -15,8 +15,8 @@ sha256sums=('b7b5a47fd0935b03d2768beaf4542c9512b389c844c0a78795bcba38978099f2')
 
 prepare() {
     cd "$srcdir/$pkgname-${pkgver}"
-    sed -i '/User=tuptime/d' "src/systemd/tuptime.service"
-    sed -i '/User=tuptime/d' "src/systemd/tuptime-cron.service"
+    sed -i '/User=_tuptime/d' "src/systemd/tuptime.service"
+    sed -i '/User=_tuptime/d' "src/systemd/tuptime-cron.service"
 }
 
 package() {

The user chaged from "tuptime" to "_tuptime" due the recommendation for system users in Debian Policy 4.5.0:

9.2.1
When maintainers choose a new hardcoded or dynamically generated username for packages to use, 
they should start this username with an underscore.

The following updates on this topic fit better on the AUR package comments