1
0
mirror of https://git.openwrt.org/feed/packages.git synced 2024-06-18 05:13:56 +02:00
openwrt-packages/net/apinger/files/graphs.sh
Jaymin Patel 4281b7639c apinger: add rrd graph support
- add package apinger-rrd for RRD graphs
- add RPC to get an overview and update graphs
- fix interface hotplug to restart apinger instance
- add patch to split alarms list in the status

Signed-off-by: Jaymin Patel <jem.patel@gmail.com>
2022-07-29 14:12:45 +05:30

45 lines
863 B
Bash

#!/bin/sh
. /lib/functions.sh
. /usr/share/libubox/jshn.sh
APINGER="/usr/sbin/apinger"
RRDCGI="/www/cgi-bin/apinger"
GRAPH_DIR="/apinger/graphs"
WWW_LOCATION="/www${GRAPH_DIR}"
update_interface_graphs() {
local iface cfg cmd
iface=$1
cfg=/var/run/apinger-$iface.conf
[ ! -f $cfg ] && return
cmd="$APINGER -c $cfg -g $WWW_LOCATION -l $GRAPH_DIR"
if [ -x $RRDCGI ]; then
$cmd 2>/dev/null | sed -e '/\(HTML\|TITLE\|H1\|H2\|by\|^#\)/d' >> $RRDCGI
else
$cmd 2>/dev/null | sed -e '/\(HTML\|TITLE\|H1\|H2\|by\)/d' > $RRDCGI
chmod 755 $RRDCGI
fi
}
update_graphs() {
[ ! -d $WWW_LOCATION ] && mkdir -p $WWW_LOCATION
[ -e $RRDCGI ] && rm -f $RRDCGI
config_load apinger
config_foreach update_interface_graphs interface
json_init
json_add_string rrdcgi "$RRDCGI"
json_dump
}
graphs_help() {
json_add_object update_graphs
json_close_object
}