From 2ed7792a20d62038938ccdfbb3363714382f552f Mon Sep 17 00:00:00 2001 From: Andreas Grimm Date: Thu, 21 Feb 2019 18:17:45 +0100 Subject: [PATCH] Readme and nicer Unit --- systemd/README.md | 41 ++++++++++++++++++++++++++++++++++++++ systemd/metrics.sh.service | 4 +++- 2 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 systemd/README.md diff --git a/systemd/README.md b/systemd/README.md new file mode 100644 index 0000000..ae589b9 --- /dev/null +++ b/systemd/README.md @@ -0,0 +1,41 @@ +# Running metrics.sh as a systemd service on Linux + +Run the following commands as root: + +```sh +# Install metrics.sh at /opt/metrics.sh +$ mkdir /opt; cd /opt +$ git clone https://github.com/pstadler/metrics.sh.git +$ cd metrics.sh +# Install the service +$ cp -p $PWD/systemd/metrics.sh.service /etc/systemd/system/metrics.sh.service +$ chmod 664 /etc/systemd/system/metrics.sh.service +# Create a config file +$ mkdir /etc/metrics.sh && chmod 600 /etc/metrics.sh +$ ./metrics.sh -C > /etc/metrics.sh/metrics.ini +# At this point you should edit your config file at +# /etc/metrics.sh/metrics.ini + +# Reload systemd daemon +$ systemctl daemon-reload + +# Start service +$ systemctl start metrics.sh.service + +# If run with the default configuration where reporter is 'stdout', metrics +# will be written to /var/log/metrics.sh.log. Be aware that this file will +# grow fast. +$ tail -f /var/log/metrics.sh.log + +# Stop service +$ systemctl stop metrics.sh.service + +# Check service status +$ systemctl status metrics.sh.service + +# Automatically start service when booting and stop when shutting down +$ systemctl enable metrics.sh.service + +# Disable automatic starting/stopping +$ systemctl disable metrics.sh.service +``` diff --git a/systemd/metrics.sh.service b/systemd/metrics.sh.service index 06b76cc..2d529d7 100644 --- a/systemd/metrics.sh.service +++ b/systemd/metrics.sh.service @@ -1,5 +1,7 @@ [Unit] -Description=Server metrics collector +Description=Controls the metrics daemon "metrics.sh" +Documentation=https://github.com/pstadler/metrics.sh +After=network.target [Service] ExecStart=/opt/metrics.sh/metrics.sh -c /etc/metrics.sh/metrics.ini