Xen schreef op 14-04-2017 19:36:
I'm sorry, I was trying to discover how to use journalctl to check for
the message and it is just incredibly painful.
So this is how you find out the messages of a certain program by
journalctl:
journalctl SYSLOG_IDENTIFIER=lvm
So user friendly ;-).
Then you need to mimick the behaviour of logtail and write your own
program for it.
You can save the cursor in journalctl so as to do that.
journalctl SYSLOG_IDENTIFIER=lvm --show-cursor
and then use it with --cursor or --after-cursor, but I have no clue what
the difference is.
I created a script to be run as a cron job that will email root in a
pretty nice message.
http://www.xenhideout.nl/scripts/snapshot-check.sh.txt
I only made it for regular snapshot messages currently though, I have
not yet seen fit to test the messages that
libdevmapper-event-lvm2thin.so produces.
But this is the format you can expect:
Snapshot linux/root-snap has been unmounted from /srv/root.
Log message:
Apr 14 21:11:01 perfection lvm[463]: Unmounting invalid snapshot
linux-root--snap from /srv/root.
Earlier messages:
Apr 14 19:25:31 perfection lvm[463]: Snapshot linux-root--snap is now
81% full.
Apr 14 19:25:41 perfection lvm[463]: Snapshot linux-root--snap is now
86% full.
Apr 14 21:10:51 perfection lvm[463]: Snapshot linux-root--snap is now
93% full.
Apr 14 21:11:01 perfection lvm[463]: Snapshot linux-root--snap is now
97% full.
I haven't yet fully tested everything but it saves the cursor in
/run/lvm/lastlog ;-), and will not produce output when there is nothing
new. It will not produce any output when run as a cron job and it will
produce status messages when run interactively.
It has options like:
-c : clear the cursor
-u : update the cursor and nothing else
-d : dry-run
--help
There is not yet an option to send the email to stdout but if you botch
up the script or emailing fails it will put the email to stderr so cron
will pick it up.
I guess the next option is to not send an email or to send it to stdout
instead (also picked up by cron normally).
In any case I assume current LVM already has ways of running scripts,
but that depends on dmeventd....
So you could have different actions in the script as well and have it
run other scripts.
Currently the action is simply to email...
Once I have tested thin fillup I will put that in too :p.
Regards.
_______________________________________________
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/