-
-
Notifications
You must be signed in to change notification settings - Fork 31
Expand file tree
/
Copy pathmonitoring.init
More file actions
executable file
·75 lines (58 loc) · 2.05 KB
/
monitoring.init
File metadata and controls
executable file
·75 lines (58 loc) · 2.05 KB
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
#!/bin/sh /etc/rc.common
#
# OpenWISP Monitoring Daemon
# shellcheck disable=SC2034
START=99
USE_PROCD=1
PROG="/usr/sbin/openwisp-monitoring"
PROG_NAME="OpenWISP monitoring daemon"
add_option() {
# shellcheck disable=SC3043
{
local cfg="$1"
local flag="$2"
local option="$3"
local default="$4"
local value
}
config_get value "$cfg" "$option" "$default"
[ -n "$value" ] && procd_append_param command "$flag" "$value"
}
start_service() {
# for openwisp-config
config_load openwisp
respawn_threshold=$(config_get http respawn_threshold)
respawn_timeout=$(config_get http respawn_timeout)
respawn_retry=$(config_get http respawn_retry)
procd_open_instance "openwisp-monitoring_send_data"
procd_set_param command $PROG
add_option "http" "--url" url
add_option "http" "--uuid" uuid
add_option "http" "--key" key
add_option "http" "--cacert" cacert
add_option "http" "--capath" capath
add_option "http" "--verify_ssl" verify_ssl "1"
config_load openwisp-monitoring
add_option "monitoring" "--verbose_mode" verbose_mode "0"
add_option "monitoring" "--max_retries" max_retries "5"
add_option "monitoring" "--interval" interval "300"
procd_append_param command "--mode" "send"
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
procd_close_instance
procd_open_instance "openwisp-monitoring_collect_data"
procd_set_param command $PROG
add_option "monitoring" "--monitored_interfaces" monitored_interfaces "*"
add_option "monitoring" "--required_memory" required_memory "0.05"
add_option "monitoring" "--verbose_mode" verbose_mode "0"
add_option "monitoring" "--interval" interval "300"
procd_append_param command "--mode" "collect"
procd_set_param respawn "${respawn_threshold:-3600}" "${respawn_timeout:-5}" "${respawn_retry:-5}"
procd_close_instance
logger -s "$PROG_NAME started." -t openwisp-monitoring -p daemon.info
}
stop_service() {
logger -s "$PROG_NAME stopping." -t openwisp-monitoring -p daemon.info
}
service_triggers() {
procd_add_reload_trigger "openwisp" "openwisp-monitoring"
}