petar.company/rrdtools/archive/prove/scripts.orig/bw-adsl.sh

67 lines
1.6 KiB
Bash
Raw Permalink Normal View History

2025-03-01 00:58:18 +01:00
#!/bin/sh
DBASE="/usr/local/www/data/rrdtools/dbase/bw-adsl.rrd"
IMG="/usr/local/www/data/rrdtools/pics/bw-adsl.png"
SIMG="/usr/local/www/data/rrdtools/pics/small-bw-adsl.png"
RRD="/usr/local/bin/rrdtool"
SNMPGET="/usr/local/bin/snmpget -v 1 -c public -Oqv localhost"
# RRA = 1 giorno
# Aggiungere :
# RRA:AVERAGE:0.5:288:31
# per salvare il report mensile
# ?
# RRA:AVERAGE:0.5:12:24
if [ ! -f "${DBASE}" ]; then
${RRD} create ${DBASE} \
--start N \
--step 300 \
DS:adsl_in:COUNTER:600:U:U \
DS:adsl_out:COUNTER:600:U:U \
RRA:AVERAGE:0.5:1:288
fi
${RRD} update ${DBASE} N:`${SNMPGET} IF-MIB::ifInOctets.4`:`${SNMPGET} IF-MIB::ifOutOctets.4`
${RRD} graph ${IMG} \
--imgformat=PNG \
--title="Adsl Bw" \
--font DEFAULT:7 \
--rigid \
--base=1000 \
--height=100 \
--width=400 \
--upper-limit=180000 \
--tabwidth=20 \
--lower-limit=0 \
--vertical-label="KB/sec" \
DEF:byte_in="${DBASE}":adsl_in:AVERAGE \
DEF:byte_out="${DBASE}":adsl_out:AVERAGE \
AREA:byte_in#00CF00:"IN\t" GPRINT:byte_in:LAST:"Last\:%8.2lf %s" GPRINT:byte_in:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_in:MAX:"Max\:%8.2lf %s\n" \
LINE1:byte_out#FF0000:"OUT\t" GPRINT:byte_out:LAST:"Last\:%8.2lf %s" GPRINT:byte_out:AVERAGE:"Avg\:%8.2lf %s" GPRINT:byte_out:MAX:"Max\:%8.2lf %s\n"
${RRD} graph ${SIMG} \
--imgformat=PNG \
--font DEFAULT:5 \
--height=50 \
--width=200 \
--upper-limit=180000 \
--tabwidth=20 \
--lower-limit=0 \
--no-legend \
DEF:byte_in="${DBASE}":adsl_in:AVERAGE \
DEF:byte_out="${DBASE}":adsl_out:AVERAGE \
AREA:byte_in#00CF00: \
LINE1:byte_out#FF0000:
# Optionals
# HRULE:150000#FF0000:"MAX possible speed"
# CDEF:byte_in=in,8,* \
# CDEF:byte_out=out,8,* \