1
0
Fork 0
mirror of https://github.com/munin-monitoring/contrib.git synced 2025-07-22 02:51:03 +00:00

[network/upnpc_] Add support for host_name

Signed-off-by: Olivier Mehani <shtrom@ssji.net>
This commit is contained in:
Olivier Mehani 2019-09-27 21:01:57 +10:00 committed by Lars Kruse
parent 01edaf0086
commit 282b32b0e5

View file

@ -27,6 +27,19 @@ plugin-configuration:
[upnpc*] [upnpc*]
env.traffic_remove_max true env.traffic_remove_max true
You can display the graph on another host (e.g., the actual router) than the
one running upnpc. To do so, first configure the plugin to use a different
hostname.
env.host_name router
Then configure munin (in /etc/munin/munin-conf or /etc/munin/munin-conf.d), to
support a new host.
[example.net;router]
address 127.0.0.1
use_node_name no
=head1 AUTHOR =head1 AUTHOR
Olivier Mehani Olivier Mehani
@ -62,7 +75,17 @@ SUPPORTED_MODES=$(
s/.*Packets.*/pkts/p; \ s/.*Packets.*/pkts/p; \
s/.*uptime=.*/uptime/p; \ s/.*uptime=.*/uptime/p; \
") ")
HOST=$(echo "${DATA}" | sed -n "s#.*desc: http://\([^/:]\+\).*#\1#p")
HOST=${host_name:-}
HOST_TITLE=""
HOST_NAME="host_name ${HOST}"
if [ -z "${HOST}" ]; then
HOST=$(echo "${DATA}" | sed -n "s#.*desc: http://\([^/:]\+\).*#\1#p")
# Only add the host name to the title if autodetected
HOST_TITLE=" ($HOST)"
# ...but not as a separate host
HOST_NAME=""
fi
autoconf() { autoconf() {
test -n "${DATA}" && echo yes || echo "no (No UPnP router detected)" test -n "${DATA}" && echo yes || echo "no (No UPnP router detected)"
@ -80,7 +103,7 @@ config () {
case ${1} in case ${1} in
"uptime") "uptime")
cat << EOF cat << EOF
graph_title Uplink connection uptime (${HOST}) graph_title Uplink connection uptime${HOST_TITLE}
graph_args -l 0 graph_args -l 0
graph_category network graph_category network
graph_scale no graph_scale no
@ -88,11 +111,12 @@ graph_vlabel uptime in hours
uptime.label uptime uptime.label uptime
uptime.draw AREA uptime.draw AREA
uptime.cdef uptime,3600,/ uptime.cdef uptime,3600,/
${HOST_NAME}
EOF EOF
;; ;;
"bitrate") "bitrate")
cat << EOF cat << EOF
graph_title [DEPRECATED] Uplink bitrate (${HOST}) graph_title [DEPRECATED] Uplink bitrate${HOST_TITLE}
graph_args --base 1000 -l 0 graph_args --base 1000 -l 0
graph_category network graph_category network
graph_vlabel bitrate down (-) / up (+) graph_vlabel bitrate down (-) / up (+)
@ -100,11 +124,12 @@ down.label bps
up.label bps up.label bps
down.graph no down.graph no
up.negative down up.negative down
${HOST_NAME}
EOF EOF
;; ;;
"traffic") "traffic")
cat << EOF cat << EOF
graph_title Uplink traffic (${HOST}) graph_title Uplink traffic${HOST_TITLE}
graph_args --base 1000 -l 0 graph_args --base 1000 -l 0
graph_category network graph_category network
EOF EOF
@ -127,12 +152,13 @@ up.min 0
up.cdef up,8,* up.cdef up,8,*
down.graph no down.graph no
up.negative down up.negative down
${HOST_NAME}
EOF EOF
;; ;;
"pkts") "pkts")
# ${graph_period} is not a shell variable # ${graph_period} is not a shell variable
cat << EOF cat << EOF
graph_title Uplink packets (${HOST}) graph_title Uplink packets${HOST_TITLE}
graph_args --base 1000 -l 0 graph_args --base 1000 -l 0
graph_category network graph_category network
EOF EOF
@ -148,9 +174,13 @@ up.type DERIVE
up.min 0 up.min 0
down.graph no down.graph no
up.negative down up.negative down
${HOST_NAME}
EOF EOF
;; ;;
"multi"|"upnpc") "multi"|"upnpc")
echo "${HOST_NAME}"
# Don't repeat HOST_NAME in sub-configs
HOST_NAME=""
echo "multigraph ${PLUGIN_NAME}" echo "multigraph ${PLUGIN_NAME}"
config "traffic" config "traffic"
for mode in ${SUPPORTED_MODES}; do for mode in ${SUPPORTED_MODES}; do