[systemd-devel] Keeping track of usage time

Tomasz Torcz tomek at pipebreaker.pl
Tue Nov 3 00:42:06 PST 2015


On Tue, Nov 03, 2015 at 07:27:39AM +0100, Umut Tezduyar Lindskog wrote:
> journalctl --list-boots seems great actually but wouldn't work for us.
> We cannot keep lots of logs in our products.
> 
> Ultimately we are trying to answer the question of how long one of our
> product has been in use.
> 
> We will implement it with a .timer/.service which periodically adds
> /proc/uptime to a file and the file gets preserved over reboot.

  Hi,

  there's a daemon which does this: https://github.com/rpodgorny/uptimed

It keeps database in file: 
9932957:1354374472:Linux 3.6.8-1.fc18.x86_64
7635334:1400571727:Linux 3.14.2-200.fc20.x86_64
…

  And has text frontend for interactive use:
% uprecords -M
     #               Uptime | System                                     Boot up
----------------------------+---------------------------------------------------
     1   114 days, 23:09:17 | Linux 3.6.8-1.fc18.x86_6  Sat Dec  1 16:07:52 2012
     2    88 days, 08:55:34 | Linux 3.14.2-200.fc20.x8  Tue May 20 09:42:07 2014
     3    72 days, 14:59:41 | Linux 3.8.8-203.fc18.x86  Sun Apr 28 18:17:18 2013
     4    68 days, 03:35:07 | Linux 3.17.1-302.fc21.x8  Mon Oct 20 08:53:07 2014
     5    66 days, 02:38:32 | Linux 3.12.5-302.fc20.x8  Sun Dec 29 14:38:53 2013
     6    65 days, 18:50:12 | Linux 3.13.5-202.fc20.x8  Sun Mar  9 20:36:38 2014
     7    61 days, 15:45:36 | Linux 3.18.1-2.fc22.x86_  Sat Dec 27 15:43:00 2014
     8    59 days, 12:08:43 | Linux 4.0.0-0.rc2.git0.1  Sun Mar 22 11:13:26 2015
     9    48 days, 13:06:38 | Linux 3.4.0-1.fc17.x86_6  Thu Jun  7 18:51:12 2012
    10    44 days, 02:41:34 | Linux 3.11.3-201.fc19.x8  Fri Oct 11 14:34:46 2013
----------------------------+---------------------------------------------------
->  29    17 days, 18:31:09 | Linux 4.2.3-200.fc22.x86  Fri Oct 16 16:07:22 2015
----------------------------+---------------------------------------------------
1up in     0 days, 03:04:28 | at                        Tue Nov  3 12:42:59 2015
t10 in    26 days, 08:10:26 | at                        Sun Nov 29 17:48:57 2015
no1 in    97 days, 04:38:09 | at                        Mon Feb  8 14:16:40 2016
mst in     7 days, 05:28:52 | twenty-five days          Tue Nov 10 15:07:23 2015
    up  1413 days, 06:30:17 | since                     Sun Jan  1 03:11:26 2012
  down  -11 days, 00:-03:-1 | since                     Sun Jan  1 03:11:26 2012
   %up              100.785 | since                     Sun Jan  1 03:11:26 2012


  I see no need to merge it in systemd, really.

-- 
Tomasz Torcz                                                       72->|   80->|
xmpp: zdzichubg at chrome.pl                                          72->|   80->|



More information about the systemd-devel mailing list