日々の生活を好き勝手につづったブログ(My blog is written by inoshita.jp)
hotsanicのグラフ表示は見やすくて良いが個々に観るより同じ座標で見えた方が評価しやすいので1つのグラフにまとめてみた
(tempgraph.cgi)
#!/bin/sh
RRDDIR=/opt/HotSaNIC/modules/sensors/rrd
RRDTOOL=/usr/bin/rrdtool
WWWHOME=/srv/www
GIMAGE=/admin/tempGraph.png
FIMAGE=/admin/fanGraph.png
GWIDTH=400
GHEIGHT=150
GTIME=-3h
# Temperature graph
$RRDTOOL graph $WWWHOME$GIMAGE \
-w $GWIDTH -h $GHEIGHT -a PNG -s $GTIME \
-t "CPU MEM VR HDD Temperature last 3 hour" -v "C" \
--alt-autoscale --alt-y-grid \
DEF:avgcpu0=$RRDDIR/core0.rrd:data:AVERAGE \
DEF:maxcpu0=$RRDDIR/core0.rrd:data:MAX DEF:mincpu0=$RRDDIR/core0.rrd:data:MIN \
DEF:avgcpu1=$RRDDIR/core1.rrd:data:AVERAGE \
DEF:maxcpu1=$RRDDIR/core1.rrd:data:MAX DEF:mincpu1=$RRDDIR/core1.rrd:data:MIN \
CDEF:maxcore=maxcpu0,maxcpu1,MAX \
CDEF:mincore=mincpu0,mincpu1,MIN \
DEF:avghdd=$RRDDIR/sda.rrd:data:AVERAGE \
DEF:avgvr=$RRDDIR/vr.rrd:data:AVERAGE \
DEF:avgmem=$RRDDIR/memory.rrd:data:AVERAGE \
LINE2:avgmem#d2b48c:MEM \
AREA:maxcore#c0ffc0: AREA:mincore#ffffff: \
LINE1:maxcore#a0a0a0: LINE1:mincore#a0a0a0: \
LINE2:avgcpu0#00a000: \
LINE2:avgcpu1#00a000:CPU \
LINE2:avgvr#ee82ee:VR \
LINE2:avghdd#dc143c:HDD \
HRULE:0#000000 \
> /dev/null 2>&1
# FAN graph
$RRDTOOL graph $WWWHOME$FIMAGE \
-w $GWIDTH -h $GHEIGHT -a PNG -s $GTIME \
-t "FAN last 3 hour" -v "RPM" \
--alt-autoscale --alt-y-grid \
DEF:avgrpm=$RRDDIR/fan1.rrd:data:AVERAGE \
LINE2:avgrpm#6a5acd:FAN \
HRULE:0#000000 \
> /dev/null 2>&1
echo "Content-type: text/html\n"
echo "<html><body>";
echo "<img src=\"$GIMAGE\">"
echo "<br>";
echo "<img src=\"$FIMAGE\">"
echo "</body></html>"
exit 0
htmlからiframeで実行させる
<iframe src="./tempgraph.cgi" width="600" height="800" frameborder="no" scrolling="no">
この部分は iframe 対応のブラウザで見てください。
</iframe>
<!--
最初はFAN回転数(1/100して縦軸30までに間に描画させる)も入れていたが座標系が同じでないと認識しずらいので止めた
(初期バージョン)
#!/bin/sh
RRDDIR=/opt/HotSaNIC/modules/sensors/rrd
RRDTOOL=/usr/bin/rrdtool
WWWHOME=/srv/www
GIMAGE=/admin/tempgraph.png
$RRDTOOL graph $WWWHOME$GIMAGE \
-w 400 -h 600 -a PNG -s -3h \
-t "CPU MEM VR HDD Temperature last 3 hour" -v "C, RPM/100" \
--alt-autoscale --alt-y-grid \
DEF:avgcpu0=$RRDDIR/core0.rrd:data:AVERAGE \
DEF:maxcpu0=$RRDDIR/core0.rrd:data:MAX DEF:mincpu0=$RRDDIR/core0.rrd:data:MIN \
DEF:avgcpu1=$RRDDIR/core1.rrd:data:AVERAGE \
DEF:maxcpu1=$RRDDIR/core1.rrd:data:MAX DEF:mincpu1=$RRDDIR/core1.rrd:data:MIN \
CDEF:maxcore=maxcpu0,maxcpu1,MAX \
CDEF:mincore=mincpu0,mincpu1,MIN \
DEF:avghdd=$RRDDIR/sda.rrd:data:AVERAGE \
DEF:avgvr=$RRDDIR/vr.rrd:data:AVERAGE \
DEF:avgmem=$RRDDIR/memory.rrd:data:AVERAGE \
DEF:avgrpm=$RRDDIR/fan1.rrd:data:AVERAGE CDEF:avgfan=avgrpm,100,\/ \
LINE2:avgmem#d2b48c:MEM \
AREA:maxcore#c0ffc0: AREA:mincore#ffffff: \
LINE1:maxcore#a0a0a0: LINE1:mincore#a0a0a0: \
LINE2:avgcpu0#00a000: \
LINE2:avgcpu1#00a000:CPU \
LINE2:avgvr#ee82ee:VR \
LINE2:avghdd#dc143c:HDD \
LINE2:avgfan#6a5acd:FAN \
HRULE:0#000000 \
> /dev/null 2>&1
echo "Content-type: text/html\n"
echo "<html><body>";
echo "<img src=\"$GIMAGE\">"
echo "</body></html>"
exit 0
(MAX, MINの描画について)