2016年11月12日土曜日

Orange Pi PC で MRTGの設定 (温度計測)

LM75温度センサーで温度計測ができるようになりましたので、室温とCPU温度をMRTGを利用してグラフ化してみました。

CPUの温度はOrangepi のフォーラムによると
cat /sys/devices/virtual/thermal/thermal_zone0/temp
で分かるようです。

/etc/mrtg.d 配下に temperature.sh を作りました。

#!/bin/sh

ROOM_TEMP=`/usr/sbin/i2cget -y 0 0x48 0x00 w | awk '{print \
(("0x"substr($1,5,2)substr($1,3,1))*0.0625)}'`
CPU_TEMP=`cat /sys/devices/virtual/thermal/thermal_zone0/temp`

echo $ROOM_TEMP
echo $CPU_TEMP
echo ""
echo ""
exit 0

mrtg.cfg に下記内容を追加しました。

## temperature ##
Target[opi-pc_temp]: `/etc/mrtg.d/temperature.sh`
Directory[opi-pc_temp]: localhost
MaxBytes[opi-pc_temp]: 100
Unscaled[opi-pc_temp]: dwmy
Options[opi-pc_temp]: gauge, absolute, growright, noinfo, nopercent
WithPeak[opi-pc_temp]: ymw
YLegend[opi-pc_temp]: 温度計測(℃)
ShortLegend[opi-pc_temp]: (℃)
LegendI[opi-pc_temp]: 室温
LegendO[opi-pc_temp]: CPU
Legend1[opi-pc_temp]: 室温
Legend2[opi-pc_temp]: CPU
Legend3[opi-pc_temp]: Max 室温
Legend4[opi-pc_temp]: Max CPU
Title[opi-pc_temp]: Orange Pi PC 温度計測
PageTop[opi-pc_temp]: <h1>Orange Pi PC 温度計測</h1>

 

2016/11/15 追記
Orange Pi PC をケースに組み込むでの試験結果も終わりましたので、新規に計測を始めました。合わせてディレクトリとファイル名が長すぎる気がしたので、こちらも短くしました。現在の設定は下記の通り。

後、今頃気がついたのですが YLegend は英記号以外だと表示できませんね。文字→jpeg変換をする際、1byte文字を、方法はよく分からないのですが90°左に回転させているようです。2byte文字だと上手くいかないようです。(ShortLegend の方は問題ないので、2byte文字表記のままです。)

$ sudo cat /etc/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[^]: Traffic Analysis for
Title[^]: MRTG for

# 128K leased line
# ----------------
#Title[leased]: a 128K leased line
#PageTop[leased]: <H1>Our 128K link to the outside world</H1>
#Target[leased]: 1:public@router.localnet
#MaxBytes[leased]: 16000

##################################
## Orange Pi PC(192.168.11.252) ##
##################################
## CPU Used ##
Target[cpu]: .1.3.6.1.4.1.2021.10.1.5.1&.1.3.6.1.4.1.2021.10.1.5.2:test-ro@localhost
Directory[cpu]: opi-pc
MaxBytes[cpu]: 100
Unscaled[cpu]: dwmy
Options[cpu]: gauge, absolute, growright, noinfo, nopercent
WithPeak[cpu]: ymw
YLegend[cpu]: CPU Load
ShortLegend[cpu]: (%)
LegendI[cpu]: 1分間平均
LegendO[cpu]: 5分間平均
Legend1[cpu]: 1分間平均(%)
Legend2[cpu]: 5分間平均(%)
Legend3[cpu]: Max 1分間平均(%)
Legend4[cpu]: Max 5分間平均(%)
Title[cpu]: Orange Pi PC CPU使用率
PageTop[cpu]: <h1>Orange Pi PC CPU使用率</h1>

## temperature ##
Target[temp]: `/etc/mrtg.d/temperature.sh`
Directory[temp]: opi-pc
MaxBytes[temp]: 70
Unscaled[temp]: dwmy
Options[temp]: gauge, absolute, growright, noinfo, nopercent
WithPeak[temp]: ymw
YLegend[temp]: Temperature
ShortLegend[temp]: (℃)
LegendI[temp]: 室温
LegendO[temp]: CPU
Legend1[temp]: 室温
Legend2[temp]: CPU
Legend3[temp]: Max 室温
Legend4[temp]: Max CPU
Title[temp]: Orange Pi PC 温度計測
PageTop[temp]: <h1>Orange Pi PC 温度計測</h1>

0 件のコメント:

コメントを投稿