linux-lvm.redhat.com archive mirror
 help / color / mirror / Atom feed
* [linux-lvm] storage-logger: Recording changes to the udev database
@ 2020-03-26 23:31 Alasdair G Kergon
  2020-03-27  0:32 ` Brian McCullough
  2020-03-27 19:50 ` Brian McCullough
  0 siblings, 2 replies; 5+ messages in thread
From: Alasdair G Kergon @ 2020-03-26 23:31 UTC (permalink / raw)
  To: dm-devel, linux-lvm

I'm experimenting with ways of recording changes to the udev database so
you can look back at the history of the storage stack on a particular
machine.  This is still a work-in-progress, but it's reached a point
where I'd like more people to try it out.

I've written a shell script that records data related to storage uevents
in the system journal and a perl script that helps you to interrogate
this data later to create a representation of the storage components.

If you're interested, please try this out and let me know if you think
pursing this approach further would lead to something that you would
use and distributions should ship.

Source code:
  https://github.com/lvmteam/storage-logger
Fedora builds:
  https://copr.fedorainfracloud.org/coprs/agk/storage-logger/build/1320735/
Presentation:
  https://fosdem.org/2020/schedule/event/storage_logger/


Storage-logger
==============
The storage-logger project maintains a record of the storage
configuration of a linux system as it changes over time.
The idea is to provide a quick way to check the state
of a system at times in the past.

Logging
=======
The initial logging implementation is triggered by storage uevents and
consists of two components:

1. A new udev rule file, 99-zzz-storage-logger.rules, which runs after
all the other rules have run and invokes:

2. A script, udev_storage_logger.sh, that captures relevant
information about devices that changed and stores it in the system
journal.

The effect is to log relevant uevents plus some supplementary
information.  It does not yet handle filesystem-related events.

Reporting
=========
Two methods to query the data are offered:

1. journalctl
Reports the raw data using simple filtering.
Data is tagged with the identifier UDEVLOG and retrievable as
key-value pairs.
All the captured data:
  journalctl -t UDEVLOG --output verbose
or as JSON:
  journalctl -t UDEVLOG --output json
Between a time range:
  --since 'YYYY-MM-DD HH:MM:SS' 
  --until 'YYYY-MM-DD HH:MM:SS'
Other filtering features are described in the man page.

2. lsblkj
This wrapper creates a dummy system environment that "looks like" the
system did at a specified earlier time and then runs lsblk against it.
It accepts --since and --until arguments to pass to journalctl to
select the desired data, and passes other arguments controlling
the output format to the real lsblk.  
Use --verbose to watch it setting up the temporary environment .
Use --dry-run to see what it would do without actually doing it.
Use --git to create a git repository recording the changes over time.
 
Alasdair
-- 
agk@redhat.com

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-lvm] storage-logger: Recording changes to the udev database
  2020-03-26 23:31 [linux-lvm] storage-logger: Recording changes to the udev database Alasdair G Kergon
@ 2020-03-27  0:32 ` Brian McCullough
  2020-03-27 19:50 ` Brian McCullough
  1 sibling, 0 replies; 5+ messages in thread
From: Brian McCullough @ 2020-03-27  0:32 UTC (permalink / raw)
  To: dm-devel, linux-lvm

On Thu, Mar 26, 2020 at 11:31:45PM +0000, Alasdair G Kergon wrote:
> I'm experimenting with ways of recording changes to the udev database so
> you can look back at the history of the storage stack on a particular
> machine.  This is still a work-in-progress, but it's reached a point
> where I'd like more people to try it out.
> 
> I've written a shell script that records data related to storage uevents
> in the system journal and a perl script that helps you to interrogate
> this data later to create a representation of the storage components.
> 
> If you're interested, please try this out and let me know if you think
> pursing this approach further would lead to something that you would
> use and distributions should ship.


Alasdair,

I have downloaded and installed in a Debian 9 environment.

There are a couple of differences that I have seen so far.

First, most importantly, the udev rules are in /etc/udev/rules.d.

Secondly, it appears that the journalctl command does not like the
output fields option.

I will install this on another machine that has a bit more device
activity, and comment later.


Brian


 
  
> Alasdair
> -- 
> agk@redhat.com
> 
> _______________________________________________
> linux-lvm mailing list
> linux-lvm@redhat.com
> https://www.redhat.com/mailman/listinfo/linux-lvm
> read the LVM HOW-TO at http://tldp.org/HOWTO/LVM-HOWTO/
> 

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-lvm] storage-logger: Recording changes to the udev database
  2020-03-26 23:31 [linux-lvm] storage-logger: Recording changes to the udev database Alasdair G Kergon
  2020-03-27  0:32 ` Brian McCullough
@ 2020-03-27 19:50 ` Brian McCullough
  2020-03-27 20:53   ` Alasdair G Kergon
  1 sibling, 1 reply; 5+ messages in thread
From: Brian McCullough @ 2020-03-27 19:50 UTC (permalink / raw)
  To: dm-devel, linux-lvm

On Thu, Mar 26, 2020 at 11:31:45PM +0000, Alasdair G Kergon wrote:
> I'm experimenting with ways of recording changes to the udev database so
> you can look back at the history of the storage stack on a particular
> machine.  This is still a work-in-progress, but it's reached a point
> where I'd like more people to try it out.
> 
> I've written a shell script that records data related to storage uevents
> in the system journal and a perl script that helps you to interrogate
> this data later to create a representation of the storage components.
> 
> If you're interested, please try this out and let me know if you think
> pursing this approach further would lead to something that you would
> use and distributions should ship.

Quick note, Alasdair.

In your instructions, you say to put the "working" script in /usr/sbin,
while in the udev rule, it is in /sbin/



I tried adding and removing a USB-connected drive, but did not see any
response in the journal.  Should I have seen something, or are those not
seen?



Thanks,
Brian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-lvm] storage-logger: Recording changes to the udev database
  2020-03-27 20:53   ` Alasdair G Kergon
@ 2020-03-27 20:52     ` Brian McCullough
  0 siblings, 0 replies; 5+ messages in thread
From: Brian McCullough @ 2020-03-27 20:52 UTC (permalink / raw)
  To: dm-devel, linux-lvm

On Fri, Mar 27, 2020 at 08:53:29PM +0000, Alasdair G Kergon wrote:
> On Fri, Mar 27, 2020 at 03:50:06PM -0400, Brian McCullough wrote:
> > In your instructions, you say to put the "working" script in /usr/sbin,
> > while in the udev rule, it is in /sbin/
> 
> In Fedora they are the same.

Ah.  So they are aliases.



> > I tried adding and removing a USB-connected drive, but did not see any
> > response in the journal.  Should I have seen something, or are those not
> > seen?
> 
> You should test the script in isolation in case there are any other 
> differences on Debian.  Change the top line to '...bash -x' so you
> can watch it, set some environment variables (like ACTION=add) and 
> run it directly.


Thank you.  I will do so over the weekend, and report.


> Alasdair


Brian

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [linux-lvm] storage-logger: Recording changes to the udev database
  2020-03-27 19:50 ` Brian McCullough
@ 2020-03-27 20:53   ` Alasdair G Kergon
  2020-03-27 20:52     ` Brian McCullough
  0 siblings, 1 reply; 5+ messages in thread
From: Alasdair G Kergon @ 2020-03-27 20:53 UTC (permalink / raw)
  To: Brian McCullough; +Cc: dm-devel, linux-lvm

On Fri, Mar 27, 2020 at 03:50:06PM -0400, Brian McCullough wrote:
> In your instructions, you say to put the "working" script in /usr/sbin,
> while in the udev rule, it is in /sbin/

In Fedora they are the same.

> I tried adding and removing a USB-connected drive, but did not see any
> response in the journal.  Should I have seen something, or are those not
> seen?

You should test the script in isolation in case there are any other 
differences on Debian.  Change the top line to '...bash -x' so you
can watch it, set some environment variables (like ACTION=add) and 
run it directly.

Alasdair

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2020-03-27 21:09 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-26 23:31 [linux-lvm] storage-logger: Recording changes to the udev database Alasdair G Kergon
2020-03-27  0:32 ` Brian McCullough
2020-03-27 19:50 ` Brian McCullough
2020-03-27 20:53   ` Alasdair G Kergon
2020-03-27 20:52     ` Brian McCullough

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).