Systemd compatibility.

This commit is contained in:
Andreas Grimm 2019-02-20 17:27:02 +01:00
parent be4039d647
commit 3a2fff387d
4 changed files with 17 additions and 8 deletions

View File

@ -1,7 +1,7 @@
#!/bin/sh
# load utils
for util in ./lib/utils/*.sh; do
for util in ${DIR}/lib/utils/*.sh; do
. $util
done
@ -16,10 +16,10 @@ main_defaults () {
DEFAULT_REPORTER=stdout
fi
if [ -z $CUSTOM_REPORTERS_PATH ]; then
CUSTOM_REPORTERS_PATH=./reporters/custom
CUSTOM_REPORTERS_PATH=${DIR}/reporters/custom
fi
if [ -z $CUSTOM_METRICS_PATH ]; then
CUSTOM_METRICS_PATH=./metrics/custom
CUSTOM_METRICS_PATH=${DIR}/metrics/custom
fi
}

View File

@ -2,7 +2,7 @@
get_available_reporters () {
local result
for file in `ls ./reporters/*.sh $CUSTOM_REPORTERS_PATH/*.sh 2> /dev/null`; do
for file in `ls ${DIR}/reporters/*.sh $CUSTOM_REPORTERS_PATH/*.sh 2> /dev/null`; do
local filename=$(basename $file)
local reporter=${filename%.*}
result=$(echo "$result $reporter")
@ -12,7 +12,7 @@ get_available_reporters () {
get_available_metrics () {
local result
for file in `ls ./metrics/*.sh $CUSTOM_METRICS_PATH/*.sh 2> /dev/null`; do
for file in `ls ${DIR}/metrics/*.sh $CUSTOM_METRICS_PATH/*.sh 2> /dev/null`; do
local filename=$(basename $file)
local metric=${filename%.*}
# register metric
@ -26,7 +26,7 @@ load_reporter_with_prefix () {
local name=$2
local file
for dir in $CUSTOM_REPORTERS_PATH ./reporters; do
for dir in $CUSTOM_REPORTERS_PATH ${DIR}/reporters; do
if [ -f $dir/$name.sh ]; then
file=$dir/$name.sh
break
@ -53,7 +53,7 @@ load_metric_with_prefix () {
local name=$2
local file
for dir in $CUSTOM_METRICS_PATH ./metrics; do
for dir in $CUSTOM_METRICS_PATH ${DIR}/metrics; do
if [ -f $dir/$name.sh ]; then
file=$dir/$name.sh
break

View File

@ -4,6 +4,7 @@
LC_ALL=en_US.UTF-8
LANG=en_US.UTF-8
LANGUAGE=en_US.UTF-8
DIR=$(dirname "$(readlink -f "$0")")
usage () {
echo " Usage: $0 [-d] [-h] [-v] [-c] [-m] [-r] [-i] [-C] [-u]"
@ -90,7 +91,7 @@ while [ $# -gt 0 ]; do
done
# run
. ./lib/main.sh
. ${DIR}/lib/main.sh
if [ $opt_do_update = true ]; then
if ! command_exists git; then

View File

@ -0,0 +1,8 @@
[Unit]
Description=Server metrics collector
[Service]
ExecStart=/opt/metrics.sh/metrics.sh -c /etc/metrics.sh/metrics.ini
[Install]
WantedBy=multi-user.target