File: init

package info (click to toggle)
mtail 3.2.24-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 7,384 kB
  • sloc: yacc: 647; makefile: 226; sh: 78; lisp: 77; awk: 17
file content (76 lines) | stat: -rwxr-xr-x 2,743 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
    set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides:          mtail
# Required-Start:    $remote_fs
# Required-Stop:     $remote_fs
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Extract monitoring data from logs
# Description:       mtail is a tool for extracting metrics from application
#                    logs to be exported into a timeseries database or
#                    timeseries calculator for alerting and dashboarding.
#                    It aims to fill a niche between applications that do not
#                    export their own internal state, and existing monitoring
#                    systems, without patching those applications or rewriting
#                    the same framework for custom extraction glue code.
#                    Metrics are exported for scraping by a collector as JSON
#                    or Prometheus format over HTTP, or can be periodically
#                    sent to a collectd, StatsD, or Graphite collector socket.
### END INIT INFO

# Author: Martina Ferrari <tina@debian.org>
# Author: Guillem Jover <gjover@sipwise.com>

DESC="monitoring data extractor from application logs"
NAME=mtail
USER=mtail
GROUP=$USER
DAEMON=/usr/bin/$NAME
PIDFILE=/run/$NAME/$NAME.pid
LOGFILE=/var/log/$NAME/$NAME.log

START_ARGS="--no-close --background --make-pidfile"
STOP_ARGS="--remove-pidfile"

ARGS="-progs /etc/mtail -logtostderr"
[ -n "$HOST" ] && ARGS="${ARGS} -address $HOST"
[ -n "$PORT" ] && ARGS="${ARGS} -port $PORT"

# Deprecated options, left for backwards-compatibility.
[ -n "$COLLECTD_SOCKETPATH" ] && \
    ARGS="${ARGS} -collectd_socketpath $COLLECTD_SOCKETPATH"
[ -n "$GRAPHITE_HOSTPORT" ] && \
    ARGS="${ARGS} -graphite_host_port $GRAPHITE_HOSTPORT"
[ -n "$STATSD_HOSTPORT" ] && ARGS="${ARGS} -statsd_hostport $STATSD_HOSTPORT"
[ -n "$METRIC_PUSH_INTERVAL" ] && \
    ARGS="${ARGS} -metric_push_interval_seconds $METRIC_PUSH_INTERVAL"

do_start_prepare()
{
  mkdir -p $(dirname $PIDFILE)
  if [ -z "${LOGS}" ]; then
    log_failure_msg
    echo "Missing mandatory parameter LOGS in /etc/default/mtail" >&2
    exit 1
  fi
}

do_start_cmd_override()
{
  start-stop-daemon --start --quiet --oknodo \
    --exec $DAEMON --pidfile $PIDFILE --user $USER --group $GROUP \
    --chuid $USER:$GROUP $START_ARGS -- $ARGS -logs "$LOGS" $EXTRA_ARGS \
    >>$LOGFILE 2>&1
}

do_stop_cmd_override()
{
  start-stop-daemon --stop --quiet --oknodo --retry=TERM/30/KILL/5 \
    --exec $DAEMON --pidfile $PIDFILE --user $USER $STOP_ARGS
}

alias do_reload=do_reload_sigusr1