TR-71Wっていうネットワーク経由で動作する比較的安い温度計があるんです。
結構便利な製品で、ネットワーク経由で温度が取得出来て、温度をトリガーにしてアラートメールを飛ばす事も出来ます。
http://www.tandd.co.jp/product/tr7xW/
グラフ表示機能もついているのですが、あまり使いやすく無かったので、
Cactiで温度を取得してグラフ化出来るようにしてみました。
動作確認しただけなので、微妙な部分もあるかもしれません。
ログを楽に蓄積させて後から参照する場合には役に立つと思います。
温度の取得はVBSで行っているのでCactiはWindowsOSにインストールする必要があります。
また、温度取得の際にHTMLファイルを読み込んでいるので利用しているTR-71Wとの通信が正常に実施出来る必要があります。
TR-71W以外の機種でも動作する気がしますが、その場合には適当にスクリプトの内容を変更してみてください。
動作確認機器
Windows Server 2003
Cacti 0.8.7e
TR-71W
インストール方法
Cactiをインストールした配下のディレクトリ[resource]に[script_tr71w]というフォルダを作成し、[query.bat]と[query.vbs]を作成して、以下のスクリプトをそれぞれコピーします。
その後、Cactiに下記のXMLファイルを読み込ませればインストール完了です。
XML中にBATファイルのパスが記載されていますので、配置場所を変更した場合には変更してみてください。
BATファイル(query.bat)
@Cscript //B "<Cactiをインストールしたディレクトリ>\resource\script_tr71w\query.vbs" %1
VBスクリプト(query.vbs)
query.vbsは単体でも動作させる事が出来ます。
単体で動作させる場合には以下のように実行してみてください。
query.vbs <IPアドレス>
戻ってくる値はCactiで読み込めるフォーマットとなっています。
temp_1:30.9 temp_2:30.8
以下、スクリプトです。
On Error Resume Next Dim args,strIPaddr Dim objIE Dim i Dim StrHTML Dim StrHTMLBuff Dim strLineText Dim arrLineText Dim LineText Dim objRE Set args = Wscript.Arguments strIPaddr = args(0) Set objIE = WScript.CreateObject("InternetExplorer.Application","ie_") objIE.Visible = False objIE.Navigate "http://" & strIPaddr & "/B/crrntdata/cdata.txt" While objIE.busy Wend While (objIE.Document.readyState <> "complete") Wend i = 1 'StrHTMLにHTMLを取りこみ、さらにその中にLoginFormっていう文字列があるか探す。 StrHTML = objIE.document.body.innerHTML 'strMessageLOGに配列処理 StrHTMLBuff = Split(StrHTML,VBCrLf) for each strLineText in StrHTMLBuff If SearchWord(strLineText,"cTemperature") Then arrLineText = split(strLineText,"=") LineText = LineText & "temp_" & i & ":" & arrLineText(1) & " " i = i +1 End If Next While objIE.busy Wend While (objIE.Document.readyState <> "complete") Wend Dim WshShell Set WshShell = WScript.CreateObject("WScript.Shell") WshShell.LogEvent 0, "温度測定スクリプトが起動しました。" & vbCRLF & "測定対象IPアドレス:" & strIPaddr & vbCRLF &_ "測定温度:" & LineText Wscript.StdOut.Write Trim(LineText) Set objIE = Nothing Set WshShell = Nothing Function SearchWord(strSearchObject,strKeyword) Set objRE = New RegExp objRE.Pattern = strKeyword objRE.Global = True SearchWord = objRE.Test(strSearchObject) Set objRE = Nothing End Function
XMLデータ
<cacti> <hash_000019ce18cab9b0db5365f5b373732dfc1b50> <name>TR-71W</name> <graph> <t_title></t_title> <title>|host_description| - TR-71W Temperature</title> <t_image_format_id></t_image_format_id> <image_format_id>1</image_format_id> <t_height></t_height> <height>120</height> <t_width></t_width> <width>500</width> <t_slope_mode></t_slope_mode> <slope_mode>on</slope_mode> <t_auto_scale></t_auto_scale> <auto_scale>on</auto_scale> <t_auto_scale_opts></t_auto_scale_opts> <auto_scale_opts>2</auto_scale_opts> <t_auto_scale_log></t_auto_scale_log> <auto_scale_log></auto_scale_log> <t_scale_log_units></t_scale_log_units> <scale_log_units></scale_log_units> <t_auto_scale_rigid></t_auto_scale_rigid> <auto_scale_rigid></auto_scale_rigid> <t_auto_padding></t_auto_padding> <auto_padding></auto_padding> <t_export></t_export> <export></export> <t_upper_limit></t_upper_limit> <upper_limit>50</upper_limit> <t_lower_limit></t_lower_limit> <lower_limit>0</lower_limit> <t_base_value></t_base_value> <base_value>1000</base_value> <t_unit_value></t_unit_value> <unit_value></unit_value> <t_unit_exponent_value></t_unit_exponent_value> <unit_exponent_value></unit_exponent_value> <t_vertical_label></t_vertical_label> <vertical_label></vertical_label> </graph> <items> <hash_100019979d6d1817bb7b43de062bd9e5dcd71f> <task_item_id>hash_08001971c9be7afeffdf23e4a05287e9fb49f3</task_item_id> <color_id>00BED9</color_id> <alpha>FF</alpha> <graph_type_id>4</graph_type_id> <consolidation_function_id>1</consolidation_function_id> <cdef_id>0</cdef_id> <value></value> <gprint_id>hash_060019e9c43831e54eca8069317a2ce8c6f751</gprint_id> <text_format>temp1</text_format> <hard_return></hard_return> <sequence>1</sequence> </hash_100019979d6d1817bb7b43de062bd9e5dcd71f> <hash_100019796d59c4de52bcd46dc6274f1daf7e73> <task_item_id>hash_08001971c9be7afeffdf23e4a05287e9fb49f3</task_item_id> <color_id>0</color_id> <alpha>FF</alpha> <graph_type_id>9</graph_type_id> <consolidation_function_id>4</consolidation_function_id> <cdef_id>0</cdef_id> <value></value> <gprint_id>hash_060019e9c43831e54eca8069317a2ce8c6f751</gprint_id> <text_format>Temp1_Current:</text_format> <hard_return></hard_return> <sequence>2</sequence> </hash_100019796d59c4de52bcd46dc6274f1daf7e73> <hash_1000197b95d95fd8a9beebf9b992a5bf319c2d> <task_item_id>hash_08001971c9be7afeffdf23e4a05287e9fb49f3</task_item_id> <color_id>0</color_id> <alpha>FF</alpha> <graph_type_id>9</graph_type_id> <consolidation_function_id>3</consolidation_function_id> <cdef_id>0</cdef_id> <value></value> <gprint_id>hash_060019e9c43831e54eca8069317a2ce8c6f751</gprint_id> <text_format>Temp1_Maximum:</text_format> <hard_return></hard_return> <sequence>3</sequence> </hash_1000197b95d95fd8a9beebf9b992a5bf319c2d> <hash_1000198cb2c6c1b3a7cc40d409e5e251ba5595> <task_item_id>hash_080019201925286949342543abb44ab0125ce3</task_item_id> <color_id>750F7D</color_id> <alpha>FF</alpha> <graph_type_id>4</graph_type_id> <consolidation_function_id>1</consolidation_function_id> <cdef_id>0</cdef_id> <value></value> <gprint_id>hash_060019e9c43831e54eca8069317a2ce8c6f751</gprint_id> <text_format>temp2</text_format> <hard_return></hard_return> <sequence>4</sequence> </hash_1000198cb2c6c1b3a7cc40d409e5e251ba5595> <hash_100019c57f20ff9d43fb73c7d23689a6bd111d> <task_item_id>hash_080019201925286949342543abb44ab0125ce3</task_item_id> <color_id>0</color_id> <alpha>FF</alpha> <graph_type_id>9</graph_type_id> <consolidation_function_id>4</consolidation_function_id> <cdef_id>0</cdef_id> <value></value> <gprint_id>hash_060019e9c43831e54eca8069317a2ce8c6f751</gprint_id> <text_format>Temp2_Current:</text_format> <hard_return></hard_return> <sequence>5</sequence> </hash_100019c57f20ff9d43fb73c7d23689a6bd111d> <hash_1000190520cf2070f06e9ffd7ed52033520f09> <task_item_id>hash_080019201925286949342543abb44ab0125ce3</task_item_id> <color_id>0</color_id> <alpha>FF</alpha> <graph_type_id>9</graph_type_id> <consolidation_function_id>3</consolidation_function_id> <cdef_id>0</cdef_id> <value></value> <gprint_id>hash_060019e9c43831e54eca8069317a2ce8c6f751</gprint_id> <text_format>Temp2_Maximum:</text_format> <hard_return></hard_return> <sequence>6</sequence> </hash_1000190520cf2070f06e9ffd7ed52033520f09> </items> <inputs> <hash_090019f0307a3bfa9c55522d9e91ff408084a3> <name>temp_1</name> <description></description> <column_name>task_item_id</column_name> <items>hash_000019979d6d1817bb7b43de062bd9e5dcd71f|hash_000019796d59c4de52bcd46dc6274f1daf7e73|hash_0000197b95d95fd8a9beebf9b992a5bf319c2d</items> </hash_090019f0307a3bfa9c55522d9e91ff408084a3> <hash_0900198f8dab8c627b618a54f24950d8cb2e6e> <name>temp_2</name> <description></description> <column_name>task_item_id</column_name> <items>hash_000019c57f20ff9d43fb73c7d23689a6bd111d|hash_0000190520cf2070f06e9ffd7ed52033520f09|hash_0000198cb2c6c1b3a7cc40d409e5e251ba5595</items> </hash_0900198f8dab8c627b618a54f24950d8cb2e6e> </inputs> </hash_000019ce18cab9b0db5365f5b373732dfc1b50> <hash_01001974ebce957b8aa2e4fd064a7b7f85f95e> <name>[Data Templates] TR-71W</name> <ds> <t_name>on</t_name> <name>Temperature</name> <data_input_id>hash_030019c787bc921eac602fd25a97167f806d9a</data_input_id> <t_rra_id></t_rra_id> <t_rrd_step>on</t_rrd_step> <rrd_step>300</rrd_step> <t_active>on</t_active> <active>on</active> <rra_items>hash_150019c21df5178e5c955013591239eb0afd46|hash_1500190d9c0af8b8acdc7807943937b3208e29|hash_1500196fc2d038fb42950138b0ce3e9874cc60|hash_150019e36f3adb9f152adfa5dc50fd2b23337e|hash_150019283ea2bf1634d92ce081ec82a634f513</rra_items> </ds> <items> <hash_08001971c9be7afeffdf23e4a05287e9fb49f3> <t_data_source_name>on</t_data_source_name> <data_source_name>temp_1</data_source_name> <t_rrd_minimum></t_rrd_minimum> <rrd_minimum>0</rrd_minimum> <t_rrd_maximum></t_rrd_maximum> <rrd_maximum>0</rrd_maximum> <t_data_source_type_id>on</t_data_source_type_id> <data_source_type_id>1</data_source_type_id> <t_rrd_heartbeat>on</t_rrd_heartbeat> <rrd_heartbeat>600</rrd_heartbeat> <t_data_input_field_id>on</t_data_input_field_id> <data_input_field_id>hash_070019d69f2d237b415877c5687d6b58e42177</data_input_field_id> </hash_08001971c9be7afeffdf23e4a05287e9fb49f3> <hash_080019201925286949342543abb44ab0125ce3> <t_data_source_name>on</t_data_source_name> <data_source_name>temp_2</data_source_name> <t_rrd_minimum></t_rrd_minimum> <rrd_minimum>0</rrd_minimum> <t_rrd_maximum></t_rrd_maximum> <rrd_maximum>0</rrd_maximum> <t_data_source_type_id>on</t_data_source_type_id> <data_source_type_id>1</data_source_type_id> <t_rrd_heartbeat>on</t_rrd_heartbeat> <rrd_heartbeat>600</rrd_heartbeat> <t_data_input_field_id>on</t_data_input_field_id> <data_input_field_id>hash_0700197e515a4e0aacc2765fb7813bceb59618</data_input_field_id> </hash_080019201925286949342543abb44ab0125ce3> </items> <data> <item_000> <data_input_field_id>hash_0700192499a269e42601afa7d9fd5084beb5c0</data_input_field_id> <t_value></t_value> <value></value> </item_000> </data> </hash_01001974ebce957b8aa2e4fd064a7b7f85f95e> <hash_030019c787bc921eac602fd25a97167f806d9a> <name>Windows - TR-71W</name> <type_id>1</type_id> <input_string>C:\Inetpub\wwwroot\resource\script_tr71w\query.bat <IP_Addr></input_string> <fields> <hash_0700192499a269e42601afa7d9fd5084beb5c0> <name>IP Address</name> <update_rra></update_rra> <regexp_match></regexp_match> <allow_nulls></allow_nulls> <type_code>hostname</type_code> <input_output>in</input_output> <data_name>IP_Addr</data_name> </hash_0700192499a269e42601afa7d9fd5084beb5c0> <hash_070019d69f2d237b415877c5687d6b58e42177> <name>temperature1</name> <update_rra>on</update_rra> <regexp_match></regexp_match> <allow_nulls></allow_nulls> <type_code></type_code> <input_output>out</input_output> <data_name>temp_1</data_name> </hash_070019d69f2d237b415877c5687d6b58e42177> <hash_0700197e515a4e0aacc2765fb7813bceb59618> <name>temperature2</name> <update_rra>on</update_rra> <regexp_match></regexp_match> <allow_nulls></allow_nulls> <type_code></type_code> <input_output>out</input_output> <data_name>temp_2</data_name> </hash_0700197e515a4e0aacc2765fb7813bceb59618> </fields> </hash_030019c787bc921eac602fd25a97167f806d9a> <hash_150019c21df5178e5c955013591239eb0afd46> <name>Daily (5 Minute Average)</name> <x_files_factor>0.5</x_files_factor> <steps>1</steps> <rows>600</rows> <timespan>86400</timespan> <cf_items>1|3</cf_items> </hash_150019c21df5178e5c955013591239eb0afd46> <hash_1500190d9c0af8b8acdc7807943937b3208e29> <name>Weekly (30 Minute Average)</name> <x_files_factor>0.5</x_files_factor> <steps>6</steps> <rows>700</rows> <timespan>604800</timespan> <cf_items>1|3</cf_items> </hash_1500190d9c0af8b8acdc7807943937b3208e29> <hash_1500196fc2d038fb42950138b0ce3e9874cc60> <name>Monthly (2 Hour Average)</name> <x_files_factor>0.5</x_files_factor> <steps>24</steps> <rows>775</rows> <timespan>2678400</timespan> <cf_items>1|3</cf_items> </hash_1500196fc2d038fb42950138b0ce3e9874cc60> <hash_150019e36f3adb9f152adfa5dc50fd2b23337e> <name>Yearly (1 Day Average)</name> <x_files_factor>0.5</x_files_factor> <steps>288</steps> <rows>797</rows> <timespan>33053184</timespan> <cf_items>1|3</cf_items> </hash_150019e36f3adb9f152adfa5dc50fd2b23337e> <hash_150019283ea2bf1634d92ce081ec82a634f513> <name>Hourly (1 Minute Average)</name> <x_files_factor>0.5</x_files_factor> <steps>1</steps> <rows>500</rows> <timespan>14400</timespan> <cf_items>1|3</cf_items> </hash_150019283ea2bf1634d92ce081ec82a634f513> <hash_060019e9c43831e54eca8069317a2ce8c6f751> <name>Normal</name> <gprint_text>%8.2lf %s</gprint_text> </hash_060019e9c43831e54eca8069317a2ce8c6f751> </cacti>
このスクリプトを連続で利用していて、Userenvのエラーが出る場合には、User Profile Hive Cleanup Serviceを利用してみてください。
User Profile Hive Cleanup Service
手動でCacti用のグラフを作成する場合には、以下のサイトが参考になりました。