RrdTool

Aus Programmers Guide

Wechseln zu: Navigation, Suche

Monitor CPU-Last

#!/bin/bash
 
DATE=$(date +%H:%M:%S)
 
cpudata=`grep '^cpu ' /proc/stat | awk '{print "N:"$2":"$3":"$4+$6+$7":"$5;}'`
rrdtool update /etc/rrdtool/cpu.rrd $cpudata
echo $cpudata
 
rrdtool graph /var/www/stats/cpuload.png --start -86400 \
--title "Erstellt um $DATE" \
--vertical-label "CPU-Auslastung in %" \
-w 600 -h 200 \
DEF:user=/etc/rrdtool/cpu.rrd:user:AVERAGE \
DEF:nice=/etc/rrdtool/cpu.rrd:nice:AVERAGE \
DEF:sys=/etc/rrdtool/cpu.rrd:sys:AVERAGE \
DEF:idle=/etc/rrdtool/cpu.rrd:idle:AVERAGE \
CDEF:utilization_pct=user,sys,idle,+,+,user,nice,sys,idle,+,+,+,/,100,* \
AREA:user#ff0000:"User\l":STACK \
AREA:sys#0000ff:"System\l":STACK \
AREA:nice#00ff00:"Nice\l:"STACK
 
#LINE:user#ff0000:"User\l" \
#LINE:nice#00ff00:"Nice\l" \
#LINE:sys#0000ff:"System\l"
 
#STACK:user#ff0000:"User\l" \
#STACK:sys#0000ff:"System\l" \
#STACK:nice#00ff00:"Nice\l"
 
#rrdtool graph /var/www/stats/cpuload.png --start -86400 \
#--title "Erstellt um $DATE" \
#--vertical-label "Temperatur in °C" \
#-w 600 -h 200 DEF:temphda=/etc/rrdtool/tempcpu.rrd:temphda:AVERAGE \
#AREA:temphda#00ff00:"Prozessor" \
#LINE1:temphda#CC3300
exit 0


Monitor Netzwerk-Last

#!/bin/bash
 
DATE=$(date +%H:%M:%S)
file="/etc/rrdtool/network.rrd"
statgrab="/usr/bin/statgrab"
rrdtool="/usr/bin/rrdtool"
ifaces="eth1"
 
for i in ${ifaces}; do \
    ibts=`${statgrab} -u net.${i}.rx`; \
    obts=`${statgrab} -u net.${i}.tx`; \
    rrdfile=`echo ${file} | sed -e "s/IF/${i}/"`; \
    call="${rrdtool} update ${rrdfile} N:${ibts}:${obts}"; \
    `${call}`
done
echo ${ibts}
 
rrdtool graph /var/www/stats/network.png \
--start -1d \
--title "Erstellt um $DATE" \
--vertical-label "Byte/s" \
--width 600 --height 200 \
--interlaced \
'DEF:inbytes=/etc/rrdtool/network.rrd:inbytes:AVERAGE' \
'DEF:outbytes=/etc/rrdtool/network.rrd:outbytes:AVERAGE' \
'LINE:inbytes#00ff00:Rein' \
'LINE:outbytes#0000ff:Raus'
exit 0
Persönliche Werkzeuge