mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-14 10:37:39 -07:00
Merge changes from upstream
I'm a little angry
This commit is contained in:
parent
dcf849263d
commit
2b16d9bd83
254 changed files with 24485 additions and 24094 deletions
|
@ -1,116 +1,116 @@
|
|||
#!/bin/bash
|
||||
# info: update network rrd
|
||||
# options: period
|
||||
#
|
||||
# The function is for updating network usage rrd database and graphic.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
period=${1-daily}
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Switching on time period
|
||||
case $period in
|
||||
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
|
||||
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
|
||||
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
|
||||
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
|
||||
*) exit $E_RRD ;;
|
||||
esac
|
||||
|
||||
# Checking directory
|
||||
if [ ! -d "$RRD/net" ]; then
|
||||
mkdir $RRD/net
|
||||
fi
|
||||
|
||||
# Parsing network interfaces
|
||||
ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g")
|
||||
|
||||
# Parsing excludes
|
||||
for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do
|
||||
ifaces=$(echo "$ifaces" |grep -vw "$exclude" )
|
||||
done
|
||||
|
||||
for iface in $ifaces; do
|
||||
# Checking database
|
||||
if [ ! -e "$RRD/net/$iface.rrd" ]; then
|
||||
# Adding database
|
||||
rrdtool create $RRD/net/$iface.rrd --step $RRD_STEP \
|
||||
DS:RX:COUNTER:600:U:U \
|
||||
DS:TX:COUNTER:600:U:U \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797
|
||||
fi
|
||||
|
||||
# Parsing device stats
|
||||
if [ "$period" = 'daily' ]; then
|
||||
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
|
||||
rx=$(echo "$raw_iface" |awk '{print $2}')
|
||||
tx=$(echo "$raw_iface" |awk '{print $10}')
|
||||
|
||||
# Updating rrd database
|
||||
rrdtool update $RRD/net/$iface.rrd N:$rx:$tx
|
||||
fi
|
||||
|
||||
# Updating rrd graph
|
||||
rrdtool graph $RRD/net/$period-$iface.png \
|
||||
--imgformat PNG \
|
||||
--height="120" \
|
||||
--width="440" \
|
||||
--start "$start" \
|
||||
--end "$end" \
|
||||
--vertical-label "KBytes" \
|
||||
--x-grid "$grid" \
|
||||
-c "BACK#7a766d" \
|
||||
-c "SHADEA#7a766d" \
|
||||
-c "SHADEB#7a766d" \
|
||||
-c "FONT#FFFFFF" \
|
||||
-c "CANVAS#302c2d" \
|
||||
-c "GRID#666666" \
|
||||
-c "MGRID#AAAAAA" \
|
||||
-c "FRAME#302c2d" \
|
||||
-c "ARROW#FFFFFF" \
|
||||
DEF:inoctets=$RRD/net/$iface.rrd:RX:AVERAGE \
|
||||
DEF:outoctets=$RRD/net/$iface.rrd:TX:AVERAGE \
|
||||
"CDEF:in=inoctets,8,*" \
|
||||
"CDEF:out=outoctets,8,*" \
|
||||
COMMENT:'\r' \
|
||||
AREA:in#C8EA2E:"Input (rx) "\
|
||||
GPRINT:in:'LAST: Current\:''%8.0lf' \
|
||||
GPRINT:in:'MIN: Min\:''%8.0lf' \
|
||||
GPRINT:in:'MAX: Max\:''%8.0lf\j' \
|
||||
LINE1:out#1c74cd:"Output (tx)" \
|
||||
GPRINT:out:'LAST:Current\:''%8.0lf' \
|
||||
GPRINT:out:'MIN:Min\:''%8.0lf' \
|
||||
GPRINT:out:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$?
|
||||
|
||||
if [ "$result" -ne 0 ]; then
|
||||
exit $E_RRD
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
||||
#!/bin/bash
|
||||
# info: update network rrd
|
||||
# options: PERIOD
|
||||
#
|
||||
# The function is for updating network usage rrd database and graphic.
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Variable&Function #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Argument defenition
|
||||
period=${1-daily}
|
||||
|
||||
# Includes
|
||||
source $VESTA/conf/vesta.conf
|
||||
source $VESTA/func/main.sh
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Action #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
# Switching on time period
|
||||
case $period in
|
||||
daily) start='-1d'; end='now'; grid='MINUTE:30:HOUR:1:HOUR:4:0:%H:%M';;
|
||||
weekly) start='-7d'; end='now'; grid='HOUR:8:DAY:1:DAY:1:0:%a %d';;
|
||||
monthly) start='-1m'; end='now'; grid='WEEK:1:WEEK:1:WEEK:1:0:%b %d';;
|
||||
yearly) start='-1y'; end='now'; grid='MONTH:1:YEAR:1:MONTH:2:2419200:%b';;
|
||||
*) exit $E_RRD ;;
|
||||
esac
|
||||
|
||||
# Checking directory
|
||||
if [ ! -d "$RRD/net" ]; then
|
||||
mkdir $RRD/net
|
||||
fi
|
||||
|
||||
# Parsing network interfaces
|
||||
ifaces=$(cat /proc/net/dev |grep : |cut -f 1 -d : |sed -e "s/ //g")
|
||||
|
||||
# Parsing excludes
|
||||
for exclude in $(echo ${RRD_IFACE_EXCLUDE//,/ }); do
|
||||
ifaces=$(echo "$ifaces" |grep -vw "$exclude" )
|
||||
done
|
||||
|
||||
for iface in $ifaces; do
|
||||
# Checking database
|
||||
if [ ! -e "$RRD/net/$iface.rrd" ]; then
|
||||
# Adding database
|
||||
rrdtool create $RRD/net/$iface.rrd --step $RRD_STEP \
|
||||
DS:RX:COUNTER:600:U:U \
|
||||
DS:TX:COUNTER:600:U:U \
|
||||
RRA:AVERAGE:0.5:1:600 \
|
||||
RRA:AVERAGE:0.5:6:700 \
|
||||
RRA:AVERAGE:0.5:24:775 \
|
||||
RRA:AVERAGE:0.5:288:797 \
|
||||
RRA:MAX:0.5:1:600 \
|
||||
RRA:MAX:0.5:6:700 \
|
||||
RRA:MAX:0.5:24:775 \
|
||||
RRA:MAX:0.5:288:797
|
||||
fi
|
||||
|
||||
# Parsing device stats
|
||||
if [ "$period" = 'daily' ]; then
|
||||
raw_iface=$(grep "$iface:" /proc/net/dev |sed -e "s/:/ /")
|
||||
rx=$(echo "$raw_iface" |awk '{print $2}')
|
||||
tx=$(echo "$raw_iface" |awk '{print $10}')
|
||||
|
||||
# Updating rrd database
|
||||
rrdtool update $RRD/net/$iface.rrd N:$rx:$tx
|
||||
fi
|
||||
|
||||
# Updating rrd graph
|
||||
rrdtool graph $RRD/net/$period-$iface.png \
|
||||
--imgformat PNG \
|
||||
--height="120" \
|
||||
--width="440" \
|
||||
--start "$start" \
|
||||
--end "$end" \
|
||||
--vertical-label "KBytes" \
|
||||
--x-grid "$grid" \
|
||||
-c "BACK#7a766d" \
|
||||
-c "SHADEA#7a766d" \
|
||||
-c "SHADEB#7a766d" \
|
||||
-c "FONT#FFFFFF" \
|
||||
-c "CANVAS#302c2d" \
|
||||
-c "GRID#666666" \
|
||||
-c "MGRID#AAAAAA" \
|
||||
-c "FRAME#302c2d" \
|
||||
-c "ARROW#FFFFFF" \
|
||||
DEF:inoctets=$RRD/net/$iface.rrd:RX:AVERAGE \
|
||||
DEF:outoctets=$RRD/net/$iface.rrd:TX:AVERAGE \
|
||||
"CDEF:in=inoctets,8,*" \
|
||||
"CDEF:out=outoctets,8,*" \
|
||||
COMMENT:'\r' \
|
||||
AREA:in#C8EA2E:"Input (rx) "\
|
||||
GPRINT:in:'LAST: Current\:''%8.0lf' \
|
||||
GPRINT:in:'MIN: Min\:''%8.0lf' \
|
||||
GPRINT:in:'MAX: Max\:''%8.0lf\j' \
|
||||
LINE1:out#1c74cd:"Output (tx)" \
|
||||
GPRINT:out:'LAST:Current\:''%8.0lf' \
|
||||
GPRINT:out:'MIN:Min\:''%8.0lf' \
|
||||
GPRINT:out:'MAX:Max\:''%8.0lf\j' &>/dev/null; result=$?
|
||||
|
||||
if [ "$result" -ne 0 ]; then
|
||||
exit $E_RRD
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
|
||||
#----------------------------------------------------------#
|
||||
# Vesta #
|
||||
#----------------------------------------------------------#
|
||||
|
||||
exit
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue