44 lines
963 B
Bash
Executable file
44 lines
963 B
Bash
Executable file
#!/bin/sh
|
|
|
|
BASEDIR=`pwd`
|
|
. ${BASEDIR%scripts}/rrdtool.conf
|
|
|
|
FILE="cpu-server"
|
|
DBASE="${DBASEDIR}/${FILE}.rrd"
|
|
IMG="${IMGDIR}/${FILE}.png"
|
|
SIMG="${IMGDIR}/small-${FILE}.png"
|
|
|
|
if [ ! -f "${DBASE}" ]; then
|
|
|
|
${RRD} create ${DBASE} \
|
|
--start N \
|
|
--step 300 \
|
|
DS:cpu_srv:GAUGE:600:U:U \
|
|
RRA:AVERAGE:0.5:1:288
|
|
fi
|
|
|
|
|
|
${RRD} update ${DBASE} N:`uptime | awk '{gsub(",", ""); print $(NF-1)}' | awk '{print $1 * 100}'`
|
|
|
|
${RRD} graph ${IMG} \
|
|
--imgformat=PNG \
|
|
--title="CPU usage" \
|
|
--font LEGEND:7 \
|
|
--height=100 \
|
|
--width=400 \
|
|
--tabwidth=20 \
|
|
--lower-limit=0 \
|
|
--vertical-label="cpu usage %" \
|
|
DEF:cpu="${DBASE}":cpu_srv:AVERAGE \
|
|
AREA:cpu#00CF00:"CPU\t" GPRINT:cpu:LAST:"Last\:%4.0lf %s" GPRINT:cpu:AVERAGE:"Avg\:%4.0lf %s" GPRINT:cpu:MAX:"Max\:%4.0lf %s"
|
|
|
|
${RRD} graph ${SIMG} \
|
|
--imgformat=PNG \
|
|
--font DEFAULT:5 \
|
|
--height=50 \
|
|
--width=200 \
|
|
--tabwidth=20 \
|
|
--lower-limit=0 \
|
|
--no-legend \
|
|
DEF:cpu="${DBASE}":cpu_srv:AVERAGE \
|
|
AREA:cpu#00CF00:
|