#------------------------------------------------------------------------------
# RRDtool3 - PlugIn Handler 'interface' 3.5.0
#
# Creation: 2010-08-29 Tiger
# Last Update: $Id: rc240.rrdtool3$
#
# Copyright (c) 2010 Fli4L Team
#
# This OPT package is licensed under Free Software Foundation, Inc.,
# General Public License Version 2, June 1991
#------------------------------------------------------------------------------
GetGraphParams_interface ()
{
local Timeline=$1
local InterfaceList=$2
local LabelList=$3
#---------------------------
: ${InterfaceList:=`ls -1d $RRDTOOL3_DIR_DATABASE/interface-* | sed 's|^'$RRDTOOL3_DIR_DATABASE'/interface-||' | tr '\n' '+'`}
if [ -n "$InterfaceList" ]
then
cat << __EOF__
"$RRDTOOL3_DIR_GRAPH_IMAGE/interface-$InterfaceList-$Timeline.png"
--title "$_rrdtool3_graph_interface_header - $(GetDecodedTimeline $Timeline)"
--imginfo ''
--vertical-label "$_rrdtool3_graph_interface_y_axis"
COMMENT:" $_rrdtool3_graph_label_maximum "
COMMENT:" $_rrdtool3_graph_label_average "
COMMENT:" $_rrdtool3_graph_label_minimum "
COMMENT:" $_rrdtool3_graph_label_last \l"
__EOF__
local index=1
local interface=
for interface in `echo $InterfaceList | tr '+' ' '`
do
local rrd_file=$RRDTOOL3_DIR_DATABASE/interface/if_octets-$interface.rrd
if [ -f "$rrd_file" ]
then
local label=`echo $LabelList | cut -d'+' -f$index`
: ${label:=$interface}
local direction=
for direction in tx rx
do
eval local this_label='"$label - $_rrdtool3_graph_interface_'$direction'"'
cat << __EOF__
DEF:ds${index}=$rrd_file:$direction:AVERAGE
VDEF:ds${index}max=ds${index},MAXIMUM
VDEF:ds${index}avg=ds${index},AVERAGE
VDEF:ds${index}min=ds${index},MINIMUM
VDEF:ds${index}last=ds${index},LAST
GPRINT:ds${index}max:"%6.2lf %S$_rrdtool3_graph_interface_unit"
GPRINT:ds${index}avg:"%6.2lf %S$_rrdtool3_graph_interface_unit"
GPRINT:ds${index}min:"%6.2lf %S$_rrdtool3_graph_interface_unit"
GPRINT:ds${index}last:"%6.2lf %S$_rrdtool3_graph_interface_unit"
LINE1:ds${index}#$(GetLineColour $index INTERFACE):"$this_label\l"
__EOF__
index=`expr $index + 1`
done
fi
done
fi
}
CollectdConfig_interface ()
{
local interfaces=$1
#------------------
local interface_list=`echo $interfaces | sed 's|^[^:]*:||;s|^|Interface "|;s|+|"\n Interface "|g;s|$|"|;\| ""$|d'`
cat << __EOF__
LoadPlugin interface
$interface_list
${RRDTOOL3_INTERFACE_IGNORESELECTED:+IgnoreSelected $RRDTOOL3_INTERFACE_IGNORESELECTED}
__EOF__
}