Git Product home page Git Product logo

systemd-utils's Introduction

systemd-utils

Random systemd utilities and unit files.

Usage

Recommended location:

cd $HOME/.config/systemd
git clone https://github.com/kylemanna/systemd-utils.git utils

Symlink or hardlink unit files into $HOME/.config/systemd/user. Systemd appears to have some issues with symlinked unit files at the time of writing.

Scripts

On Failure

  • Allows users to specify OnFailure=failure-email@%i.service under [Unit] section of systemd files.

  • The failure-email service will email the user when a service fails unexpectedly and include the systemd status <svc> output.

  • Example configuration systemd file:

      [Unit]
      ...
      OnFailure=failure-email@%i.service
    

Failure Monitor

  • Systemd service that runs and parses the output of journalctl. When a task fails, an email is sent to the user at the configured email address.

  • The failure-monitor service will email the user when a service fails unexpectedly and include the systemd status <svc> output.

  • Example configuration:

      $ systemctl --user start failure-monitor@[email protected]
    

Email Journal Log

Upon completion of a script (i.e. a daily backup script), send an email of the log output. The following code should be used to save a cursor before the execution of the service and send all the data followign that cursor.

ExecStartPre=/bin/sh -c 'journalctl -o cat -n 0 -u %n --show-cursor | cut -f3 -d" " > /run/%n.cursor'

ExecStart=...

ExecStopPost=/bin/sh -c '/etc/systemd/scripts/systemd-email [email protected] %n $(cat /run/%n.cursor)'
ExecStopPost=/bin/rm -f /run/%n.cursor

It would be nice if systemd provided a reference to a cursor prior to the most recent invocation of the service (like the --boot option refers to this boot). Until then hack around it.

systemd-utils's People

Contributors

kylemanna avatar szepeviktor avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

systemd-utils's Issues

Testing

Please point out how to test failure-monitor.
E.g. kill -9 $(cat /run/atd.pid)

Consider using RESULT / JOB_RESULT instead of parsing message

I imagine this change (broadens) the scope of what emails get sent, so you might not like it as a breaking change. I am probably going to this anyway with a fork for me, but if you'd like the change pulled in I'll contribute once I have tested it. If not feel free to close.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.