MRTG без SNMP: скрипты для сбора данных + конфиг

mrtg_cpu.sh
#!/bin/sh
DATA=`vmstat 1 2 | tail -n1`
echo $DATA | awk '{print $14}'
echo $DATA | awk '{print $13}'





mrtg_disk.sh #!/bin/sh DATA=`df -B1 | grep $1` echo $DATA | awk '{print $3}' echo $DATA | awk '{print $2}'
mrtg_la.sh #!/bin/sh DATA=`cat /proc/loadavg` FIRST=`echo $DATA | cut -d" " -f1` SECOND=`echo $DATA | cut -d" " -f3` echo $FIRST*100 | bc echo $SECOND*100 | bc
mrtg_mem.sh #!/bin/sh DATA=`free -b | grep Mem` echo $DATA | awk '{print $3}' echo $DATA | awk '{print $7}'
mrtg_net.sh #!/bin/sh DATA=`grep $1 /proc/net/dev` echo $DATA | awk '{print $2}' echo $DATA | awk '{print $10}'
mrtg_uptime.sh #!/bin/sh DATA=`cat /proc/uptime | awk '{print $1}'` echo $DATA/\(60*60*24\)|bc echo $DATA/\(60*60*24\)|bc
 

mrtg.cfg
######################################################################
# Multi Router Traffic Grapher -- Sample Configuration File
######################################################################
# This file is for use with mrtg-2.5.4c

# Global configuration
WorkDir: /var/www/mrtg
WriteExpires: Yes

Title[ppp0]: Network traffic via ppp0 (PPPoE)
PageTop[ppp0]: Network traffic via ppp0 (PPPoE)
Options[ppp0]: growright,pngdate,nolegend,noinfo,noborder
Target[ppp0]: `/usr/local/bin/mrtg_net.sh ppp0`
MaxBytes[ppp0]: 12500000
AbsMax[ppp0]: 12500000
YTics[ppp0]: 6

Title[uap0]: Network traffic via uap0 (Wi-Fi)
PageTop[uap0]: Network traffic via uap0 (Wi-Fi)
Options[uap0]: growright,pngdate,nolegend,noinfo,noborder
Target[uap0]: `/usr/local/bin/mrtg_net.sh uap0`
MaxBytes[uap0]: 6750000
YTics[uap0]: 6

Title[cpu]: CPU usage
PageTop[cpu]: CPU usage
Options[cpu]: growright,gauge,pngdate,nolegend,noinfo,nopercent,noborder
Target[cpu]: `/usr/local/bin/mrtg_cpu.sh`
MaxBytes[cpu]: 100
YLegend[cpu]: CPU sys/usr, %
ShortLegend[cpu]: %
LegendI[cpu]: SYS:
LegendO[cpu]: USER+NICE:

Title[fat32]: Disk usage (fat32)
PageTop[fat32]: Disk usage (fat32)
Options[fat32]: growright,gauge,pngdate,nolegend,noinfo,noborder
Target[fat32]: `/usr/local/bin/mrtg_disk.sh fat32`
MaxBytes[fat32]: 677794971648
kilo[fat32]: 1024
YLegend[fat32]: Number of bytes
ShortLegend[fat32]: b
LegendI[fat32]: Used:
LegendO[fat32]: Total:

Title[la]: Load average x 100
PageTop[la]: Load average x 100
Options[la]: growright,gauge,nopercent,pngdate,nolegend,noinfo,noborder
Target[la]: `/usr/local/bin/mrtg_la.sh`
MaxBytes[la]: 100
AbsMax[la]: 500
YLegend[la]: LA for 1/15 min
ShortLegend[la]: x
LegendI[la]: 1 min:
LegendO[la]: 15 mins:
YTics[la]: 5

Title[ext3]: Disk usage (ext3)
PageTop[ext3]: Disk usage (ext3)
Options[ext3]: growright,gauge,pngdate,nolegend,noinfo,noborder
Target[ext3]: `/usr/local/bin/mrtg_disk.sh ext3`
MaxBytes[ext3]: 319637348352
kilo[ext3]: 1024
YLegend[ext3]: Number of bytes
ShortLegend[ext3]: b
LegendI[ext3]: Used:
LegendO[ext3]: Total:

Title[mem]: Memory usage
PageTop[mem]: Memory usage
Options[mem]: growright,gauge,pngdate,nolegend,noinfo,noborder
Target[mem]: `/usr/local/bin/mrtg_mem.sh`
MaxBytes[mem]: 525754368
kilo[mem]: 1024
YLegend[mem]: Used/buffers
ShortLegend[mem]: b
Unscaled[mem]: ymwd
LegendI[mem]: Used:
LegendO[mem]: Buffers:
YTics[mem]: 6

Title[rootfs]: Disk usage (rootfs)
PageTop[rootfs]: Disk usage (rootfs)
Options[rootfs]: growright,gauge,pngdate,nolegend,noinfo,noborder
Target[rootfs]: `/usr/local/bin/mrtg_disk.sh rootfs`
MaxBytes[rootfs]: 484806656
kilo[rootfs]: 1024
YLegend[rootfs]: Number of bytes
ShortLegend[rootfs]: b
LegendI[rootfs]: Used:
LegendO[rootfs]: Total:

Title[ping]: Ping to 8.8.8.8
PageTop[ping]: Ping to 8.8.8.8
Options[ping]: growright,gauge,pngdate,nolegend,noinfo,noborder,nopercent,unknaszero
Target[ping]: `mrtg-ping-probe -k5 8.8.8.8`
MaxBytes[ping]: 1000
AbsMax[ping]: 3000
YLegend[ping]: ping time, ms
ShortLegend[ping]: ms
LegendI[ping]: Max:
LegendO[ping]: Min:

Title[uptime]: System uptime
PageTop[uptime]: System uptime
Options[uptime]: growright,gauge,nopercent,pngdate,nolegend,noinfo,noborder
Target[uptime]: `/usr/local/bin/mrtg_uptime.sh`
MaxBytes[uptime]: 365
AbsMax[uptime]: 730
YLegend[uptime]: Number of days
ShortLegend[uptime]: days
LegendI[uptime]: Uptime:
LegendO[uptime]:
YTics[uptime]: 6

Оставить комментарий