Nagiosのインストールから監視を始めるまでのあれこれ
※面倒臭いから全部rootアカウントでやってるけど良い子は真似しちゃダメだぞ!
What's Nagios
→ Nagios
準備
- アカウント作成
# useradd -d /usr/local/nagios nagios
# chmod 755 /usr/local/nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios
- ライブラリ
# yum install -y yum install wget httpd php gcc glibc glibc-common gd gd-devel make net-snmp openssl openssl-devel
install
- コア
# wget http://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.1.0/nagios-4.1.0rc1.tar.gz/download?use_mirror=jaist
# tar xf download\?use_mirror\=jaist
# ls
download\?use_mirror\=jaist nagios-4.1.0rc1/
# cd nagios-4.1.0rc1/
# ./configure --with-command-group=nagcmd
# make all
# make install
# make install-init
# make install-commandmode
# make install-config
# make install-webconf
- プラグイン
# wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
# tar xf nagios-plugins-2.0.3.tar.gz
# cd nagios-plugins-2.0.3
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --with-openssl
# make
# make install
エラーチェック(設定とかに間違いがないか)
$ /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
起動(+自動起動)
# /etc/init.d/nagios start
# chkconfig nagios on
その他
- WebUIでInternalServerErrorが出る
- SELinuxを切ってみる->こことか参考
# getenforce
Enable
# setenforce 0
# getenforce
Permissive
# /etc/init.d/nagios restart
- WebUIから外部コマンドを使おうとしてCould not stat() command file '/usr/local/nagios/var/が出る
- 例えば : Web画面からアラート通知のON/OFFを切り替えたり…
- Disable notifications for this service -> commit -> Error!
- ここを参考にしてみる
# ls -l /usr/local/nagios/var/rw/
合計 0
prw-rw----. 1 nagios nagcmd 0 7月 4 20:36 2015 nagios.cmd
srw-rw----. 1 nagios nagcmd 0 7月 4 20:33 2015 nagios.qh
# ls -l /usr/local/nagios/var/ | grep rw
とかいろいろと調べるけど結局は
# usermod -G nagios nagios
# usermod -G nagcmd apache
っぽい。
grep nag /etc/group
nagios:x:501:
nagcmd:x:502:nagios,apache
こーなってれば多分大丈夫。