harumaki.net

インフラ屋の覚書や、ラーメン食べある記とか。

GNU/Linux infra nagios 運用

nagiosgraph/4.グラフ設定例/check_cpu.sh

投稿日:2010年11月25日

Last Updated on 2021年7月4日 by かんりにん

[pukiwiki]

**nagiosgraphへのグラフ設定追加例[check_cpu.sh] [#s162aecf]

nagios exchangeから取得したcheck_cpu.shの実行結果をnagiosgraphでグラフ化した際の
作業ログ。

**1)コマンド実行結果を確認 [#qdf9a72b]

check_cpu.shはコマンドの実行結果内にoutputとperfdataの両方が出力される
(パイプで区切られた前半がoutput、後半がperfdata)
# ./check_cpu.sh -w 90 -c 95
OK – user: 0.50, nice: 0.50, sys: 4.30, iowait: 0.50, irq: 0.50, softirq: 0.50 idle: 96.69 |
‘user’=0.50 ‘nice’=0.50 ‘sys’=4.30 ‘softirq’=0.50 ‘iowait’=0.50 ‘irq’=0.50 ‘idle’=96.69

**2)ログ出力を確認 [#wd6f887d]

nagiosgraph.logに、コマンド実行結果が反映される。

‘1290586742’,
‘testhost’,
‘Cpu Usage’,
‘OK – user: 0.50, nice: 0.50, sys: 3.38, iowait: 0.50, irq: 0.50, softirq: 0.50 idle: 97.61’,
‘user=0.50 nice=0.50 sys=3.38 softirq=0.50 iowait=0.50 irq=0.50 idle=97.61′
一番下の行がperfdataで、グラフ出力時のデータとなるので、この値を読み出しできるようmapファイルを編集する。

**3)map定義を作成/編集 [#g5cdec71]

ファイル:/usr/local/nagios/etc/nagiosgraph/map

コメントアウト部分に、プラグインの実行結果の出力をサンプルとして記述しておくとgood。
# 2010-11-24 exchange plugin
# Service type: unix-cpu
# OK – user: 0.50, nice: 0.50, sys: 3.38, iowait: 0.50, irq: 0.50, softirq: 0.50 idle: 97.61’
# user=0.50 nice=0.50 sys=3.38 softirq=0.50 iowait=0.50 irq=0.50 idle=97.61
/perfdata:user=([.\d]+) nice=([.\d]+) sys=([.\d]+) softirq=([.\d]+) iowait= ([.\d]+) irq=([.\d]+) idle=([.\d]+)/
and push @s, [ ‘cpu’,
[ ‘user’, GAUGE, $1 ],
[ ‘nice’, GAUGE, $2 ],
[ ‘sys’, GAUGE, $3 ],
[ ‘softirq’, GAUGE, $4 ],
[ ‘iowait’, GAUGE, $5 ],
[ ‘irq’, GAUGE, $6 ],
[ ‘idle’, GAUGE, $7 ] ];

**4)書式チェック [#hf825e8a]

mapファイル編集後、perlの書式チェックをしておく。
# perl -c map
map syntax OK

**5)nagios再起動 [#g529ee9f]

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# /etc/init.d/nagios restart

**6)ログチェック [#c9e97ca4]

nagiosgraph.logをtail -fしてinsert.plの出力メッセージを確認。
“insert.pl debug insert.pl processing complete”と出力され、グラフの出力が確認できればOK。

Wed Nov 24 19:29:38 2010 insert.pl debug createrrd(testhost, Cpu Usage, 1290594541, cpu)
Wed Nov 24 19:29:38 2010 insert.pl debug createrrd checking /var/nagios/rrd/testhost/Cpu%20Usage___cpu.rrd
Wed Nov 24 19:29:38 2010 insert.pl debug createrrd resolutions: 600 700 775 797
Wed Nov 24 19:29:38 2010 insert.pl debug createrrd heartbeat: 600
Wed Nov 24 19:29:38 2010 insert.pl debug createrrd step: 300
Wed Nov 24 19:29:38 2010 insert.pl debug labels->[0] = [
‘user’,
‘GAUGE’,
‘0.50’
];
Wed Nov 24 19:29:38 2010 insert.pl debug labels->[1] = [
‘nice’,
‘GAUGE’,
‘0.50’
];
Wed Nov 24 19:29:38 2010 insert.pl debug labels->[2] = [
‘sys’,

“insert.pl warn perfdata not recognized:”と出力されている場合は
グラフ作成に失敗しているので、プラグインの出力内容にあるperfdataの書式と
mapに記述した内容を確認して、都度修正すること。

[/pukiwiki]

 
 

 

-GNU/Linux, infra, nagios, 運用
-

執筆者:


comment

メールアドレスが公開されることはありません。 が付いている欄は必須項目です

CAPTCHA


関連記事

nagios​/plugin​/SNMP​/インストール(perl版)

  [pukiwiki] **nagiosプラグイン[snmp]インストール・設定(perl版) [#a94a5cdc] **1)混合パッケージ [#z3649e5f] -参考サイト:お世話になってお …

no image

オープンソースでのクラスタリング環境構築/DRBD

[pukiwiki] #contents *オープンソースでのクラスタリング環境構築/DRBD ネットワークに接続されたホスト間でのディスクミラーリング機能を提供。 GNU GPLに準拠。 特徴として …

no image

CentOSにwmiクライアントを入れてみる

[pukiwiki] 何気に[[LINUX PACKAGE SEARCH>http://pkgs.org/]]でwmi(Windows Management Instrumentation)の RPM …

no image

[メモ]zipコマンドでのパスワードつき暗号化圧縮

[pukiwiki] mysqlからダンプしたファイル”backup.sql”をパスワードつきで圧縮しようとしたところ、 普段使っているtar、gzip、bzip2ではパスワー …

no image

[メモ]WindowsサーバのフォルダをLinuxサーバーへマウント

[pukiwiki] しばらくsmbを使っていなかったので、いつの間にかsmbmountを使わずとも mountコマンドのオプションでマウントを出来ることを知らなかったw WindowsフォルダのLi …