mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
Use /bin/bash for bash script, and save with UNIX line breaks
This commit is contained in:
parent
685a58d863
commit
41fedbb267
1 changed files with 189 additions and 189 deletions
|
@ -1,189 +1,189 @@
|
||||||
#!/bin/sh
|
#!/bin/bash
|
||||||
#
|
#
|
||||||
# Munin plugin for HFSC Traffic Shaping Statistics UP/DOWN
|
# Munin plugin for HFSC Traffic Shaping Statistics UP/DOWN
|
||||||
#
|
#
|
||||||
# It shows the download and upload statistic graph of a used net bandwidth per a user.
|
# It shows the download and upload statistic graph of a used net bandwidth per a user.
|
||||||
#
|
#
|
||||||
# This plugin was tailored to the HFSC solution
|
# This plugin was tailored to the HFSC solution
|
||||||
# presented at http://www.elessar.one.pl/article_kernel2.6.php
|
# presented at http://www.elessar.one.pl/article_kernel2.6.php
|
||||||
#
|
#
|
||||||
# You can find the plugin description and the installation notes here:
|
# You can find the plugin description and the installation notes here:
|
||||||
# http://www.elessar.one.pl/article_munin.php
|
# http://www.elessar.one.pl/article_munin.php
|
||||||
#
|
#
|
||||||
###
|
###
|
||||||
# Written by Rafal Rajs
|
# Written by Rafal Rajs
|
||||||
# Date: 2007/06/19
|
# Date: 2007/06/19
|
||||||
# Email: elessar1@poczta.wp.pl
|
# Email: elessar1@poczta.wp.pl
|
||||||
# WWW: http://www.elessar.one.pl
|
# WWW: http://www.elessar.one.pl
|
||||||
###
|
###
|
||||||
|
|
||||||
# path to the file with global defs
|
# path to the file with global defs
|
||||||
. /etc/scripts/globals
|
. /etc/scripts/globals
|
||||||
|
|
||||||
# imported from HFSC script
|
# imported from HFSC script
|
||||||
# set class numbers
|
# set class numbers
|
||||||
|
|
||||||
N_CLASS_D_1=70
|
N_CLASS_D_1=70
|
||||||
N_CLASS_D_2=100
|
N_CLASS_D_2=100
|
||||||
N_CLASS_U_1=130
|
N_CLASS_U_1=130
|
||||||
N_CLASS_U_2=160
|
N_CLASS_U_2=160
|
||||||
SH_TMP="/etc/scripts/tmp1.txt"
|
SH_TMP="/etc/scripts/tmp1.txt"
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
|
|
||||||
echo "graph_title HFSC Traffic Shaping Stats - UP/DOWN"
|
echo "graph_title HFSC Traffic Shaping Stats - UP/DOWN"
|
||||||
echo 'graph_vlabel bytes DOWN(-)/UP(+) per ${graph_period}'
|
echo 'graph_vlabel bytes DOWN(-)/UP(+) per ${graph_period}'
|
||||||
echo 'graph_width 450'
|
echo 'graph_width 450'
|
||||||
echo 'graph_category network'
|
echo 'graph_category network'
|
||||||
|
|
||||||
j=1
|
j=1
|
||||||
|
|
||||||
while [ $j -le $L_USERS ]
|
while [ $j -le $L_USERS ]
|
||||||
do
|
do
|
||||||
echo "${USERNAMES[${j}]}_down.label ${USERNAMES[${j}]}"
|
echo "${USERNAMES[${j}]}_down.label ${USERNAMES[${j}]}"
|
||||||
echo "${USERNAMES[${j}]}_down.type COUNTER"
|
echo "${USERNAMES[${j}]}_down.type COUNTER"
|
||||||
echo "${USERNAMES[${j}]}_down.graph no"
|
echo "${USERNAMES[${j}]}_down.graph no"
|
||||||
|
|
||||||
if [ $j == 1 ]; then
|
if [ $j == 1 ]; then
|
||||||
echo "${USERNAMES[${j}]}_down.draw AREA"
|
echo "${USERNAMES[${j}]}_down.draw AREA"
|
||||||
else
|
else
|
||||||
echo "${USERNAMES[${j}]}_down.draw STACK"
|
echo "${USERNAMES[${j}]}_down.draw STACK"
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
echo "${USERNAMES[${j}]}_down.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}"
|
echo "${USERNAMES[${j}]}_down.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}"
|
||||||
echo "${USERNAMES[${j}]}_down.min 0"
|
echo "${USERNAMES[${j}]}_down.min 0"
|
||||||
echo "${USERNAMES[${j}]}_down.max 130000"
|
echo "${USERNAMES[${j}]}_down.max 130000"
|
||||||
|
|
||||||
echo "${USERNAMES[${j}]}_up.label ${USERNAMES[${j}]}"
|
echo "${USERNAMES[${j}]}_up.label ${USERNAMES[${j}]}"
|
||||||
echo "${USERNAMES[${j}]}_up.type COUNTER"
|
echo "${USERNAMES[${j}]}_up.type COUNTER"
|
||||||
echo "${USERNAMES[${j}]}_up.negative ${USERNAMES[${j}]}_down"
|
echo "${USERNAMES[${j}]}_up.negative ${USERNAMES[${j}]}_down"
|
||||||
|
|
||||||
if [ $j == 1 ]; then
|
if [ $j == 1 ]; then
|
||||||
echo "${USERNAMES[${j}]}_up.draw AREA"
|
echo "${USERNAMES[${j}]}_up.draw AREA"
|
||||||
else
|
else
|
||||||
echo "${USERNAMES[${j}]}_up.draw STACK"
|
echo "${USERNAMES[${j}]}_up.draw STACK"
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
echo "${USERNAMES[${j}]}_up.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}"
|
echo "${USERNAMES[${j}]}_up.info Stats for ${USERNAMES[${j}]} - ${USER_IP[${j}]}"
|
||||||
echo "${USERNAMES[${j}]}_up.min 0"
|
echo "${USERNAMES[${j}]}_up.min 0"
|
||||||
echo "${USERNAMES[${j}]}_up.max 30000"
|
echo "${USERNAMES[${j}]}_up.max 30000"
|
||||||
|
|
||||||
|
|
||||||
j=$[$j+1]
|
j=$[$j+1]
|
||||||
|
|
||||||
done;
|
done;
|
||||||
|
|
||||||
#customized colours
|
#customized colours
|
||||||
echo 'Serwer_down.colour 000000'
|
echo 'Serwer_down.colour 000000'
|
||||||
echo 'Serwer_up.colour 000000'
|
echo 'Serwer_up.colour 000000'
|
||||||
|
|
||||||
exit 0
|
exit 0
|
||||||
|
|
||||||
fi;
|
fi;
|
||||||
|
|
||||||
#### DOWNLOAD
|
#### DOWNLOAD
|
||||||
|
|
||||||
temp1=`/sbin/tc -s class show dev imq0 > $SH_TMP`
|
temp1=`/sbin/tc -s class show dev imq0 > $SH_TMP`
|
||||||
|
|
||||||
while read line
|
while read line
|
||||||
do
|
do
|
||||||
test_hfsc=`echo $line | grep "hfsc"`
|
test_hfsc=`echo $line | grep "hfsc"`
|
||||||
|
|
||||||
j=1
|
j=1
|
||||||
|
|
||||||
while [ $j -le $L_USERS ]
|
while [ $j -le $L_USERS ]
|
||||||
do
|
do
|
||||||
case $test_hfsc in
|
case $test_hfsc in
|
||||||
|
|
||||||
*hfsc[\ ]1:$[$N_CLASS_D_1+$j]*)
|
*hfsc[\ ]1:$[$N_CLASS_D_1+$j]*)
|
||||||
# check N_CLASS_D_1 stats for every user
|
# check N_CLASS_D_1 stats for every user
|
||||||
read line
|
read line
|
||||||
temp1=`echo $line | awk '{ print $2; }'`
|
temp1=`echo $line | awk '{ print $2; }'`
|
||||||
STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1]
|
STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1]
|
||||||
# echo "N_CLASS_D_1="$temp1
|
# echo "N_CLASS_D_1="$temp1
|
||||||
# echo "N_CLASS_D_1_SUM "$j" ="${STAT_USER[$j]}
|
# echo "N_CLASS_D_1_SUM "$j" ="${STAT_USER[$j]}
|
||||||
;;
|
;;
|
||||||
*hfsc[\ ]1:$[$N_CLASS_D_2+$j]*)
|
*hfsc[\ ]1:$[$N_CLASS_D_2+$j]*)
|
||||||
# check N_CLASS_D_2 stats for every user
|
# check N_CLASS_D_2 stats for every user
|
||||||
read line
|
read line
|
||||||
temp1=`echo $line | awk '{ print $2; }'`
|
temp1=`echo $line | awk '{ print $2; }'`
|
||||||
STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1]
|
STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1]
|
||||||
# echo "N_CLASS_D_2="$temp1
|
# echo "N_CLASS_D_2="$temp1
|
||||||
# echo "N_CLASS_D_2_SUM "$j" ="${STAT_USER[$j]}
|
# echo "N_CLASS_D_2_SUM "$j" ="${STAT_USER[$j]}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
j=$[$j+1]
|
j=$[$j+1]
|
||||||
|
|
||||||
done;
|
done;
|
||||||
|
|
||||||
done < $SH_TMP
|
done < $SH_TMP
|
||||||
|
|
||||||
|
|
||||||
####
|
####
|
||||||
|
|
||||||
j=1
|
j=1
|
||||||
while [ $j -le $L_USERS ]
|
while [ $j -le $L_USERS ]
|
||||||
do
|
do
|
||||||
echo ${USERNAMES[${j}]}"_down.value "${STAT_USER[$j]}
|
echo ${USERNAMES[${j}]}"_down.value "${STAT_USER[$j]}
|
||||||
j=$[$j+1]
|
j=$[$j+1]
|
||||||
done;
|
done;
|
||||||
|
|
||||||
#reset values
|
#reset values
|
||||||
|
|
||||||
j=1
|
j=1
|
||||||
while [ $j -le $L_USERS ]
|
while [ $j -le $L_USERS ]
|
||||||
do
|
do
|
||||||
STAT_USER[$j]=0
|
STAT_USER[$j]=0
|
||||||
j=$[$j+1]
|
j=$[$j+1]
|
||||||
done;
|
done;
|
||||||
|
|
||||||
#### UPLOAD
|
#### UPLOAD
|
||||||
|
|
||||||
temp1=`/sbin/tc -s class show dev imq1 > $SH_TMP`
|
temp1=`/sbin/tc -s class show dev imq1 > $SH_TMP`
|
||||||
|
|
||||||
while read line
|
while read line
|
||||||
do
|
do
|
||||||
test_hfsc=`echo $line | grep "hfsc"`
|
test_hfsc=`echo $line | grep "hfsc"`
|
||||||
|
|
||||||
j=1
|
j=1
|
||||||
|
|
||||||
while [ $j -le $L_USERS ]
|
while [ $j -le $L_USERS ]
|
||||||
do
|
do
|
||||||
case $test_hfsc in
|
case $test_hfsc in
|
||||||
|
|
||||||
*hfsc[\ ]1:$[$N_CLASS_U_1+$j]*)
|
*hfsc[\ ]1:$[$N_CLASS_U_1+$j]*)
|
||||||
# check N_CLASS_U_1 stats for every user
|
# check N_CLASS_U_1 stats for every user
|
||||||
read line
|
read line
|
||||||
temp1=`echo $line | awk '{ print $2; }'`
|
temp1=`echo $line | awk '{ print $2; }'`
|
||||||
STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1]
|
STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1]
|
||||||
# echo "N_CLASS_U_1="$temp1
|
# echo "N_CLASS_U_1="$temp1
|
||||||
# echo "N_CLASS_U_1_SUM "$j" ="${STAT_USER[$j]}
|
# echo "N_CLASS_U_1_SUM "$j" ="${STAT_USER[$j]}
|
||||||
;;
|
;;
|
||||||
*hfsc[\ ]1:$[$N_CLASS_U_2+$j]*)
|
*hfsc[\ ]1:$[$N_CLASS_U_2+$j]*)
|
||||||
# check N_CLASS_U_2 stats for every user
|
# check N_CLASS_U_2 stats for every user
|
||||||
read line
|
read line
|
||||||
temp1=`echo $line | awk '{ print $2; }'`
|
temp1=`echo $line | awk '{ print $2; }'`
|
||||||
STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1]
|
STAT_USER[$j]=$[${STAT_USER[$j]}+$temp1]
|
||||||
# echo "N_CLASS_U_2="$temp1
|
# echo "N_CLASS_U_2="$temp1
|
||||||
# echo "N_CLASS_U_2_SUM "$j" ="${STAT_USER[$j]}
|
# echo "N_CLASS_U_2_SUM "$j" ="${STAT_USER[$j]}
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
j=$[$j+1]
|
j=$[$j+1]
|
||||||
|
|
||||||
done;
|
done;
|
||||||
|
|
||||||
done < $SH_TMP
|
done < $SH_TMP
|
||||||
|
|
||||||
j=1
|
j=1
|
||||||
while [ $j -le $L_USERS ]
|
while [ $j -le $L_USERS ]
|
||||||
do
|
do
|
||||||
echo ${USERNAMES[${j}]}"_up.value "${STAT_USER[$j]}
|
echo ${USERNAMES[${j}]}"_up.value "${STAT_USER[$j]}
|
||||||
j=$[$j+1]
|
j=$[$j+1]
|
||||||
done;
|
done;
|
||||||
|
|
||||||
|
|
||||||
## clean temp file
|
## clean temp file
|
||||||
temp1=`echo "" > $SH_TMP`
|
temp1=`echo "" > $SH_TMP`
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue