nagiosでフリーな監視をしてみよう!~nagiosの設定(3)~
(3)Apacheの起動ユーザapacheがNagiosを再起動できるようにsudoersを編集します。
1 | # visudo |
・sudo設定変更前の内容
114 115 116 117 118 | ## Allows members of the users group to shutdown this system # %users localhost=/sbin/shutdown -h now ## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment) #includedir /etc/sudoers.d |
・sudo設定変更後の内容
114 115 116 117 118 119 | ## Allows members of the users group to shutdown this system # %users localhost=/sbin/shutdown -h now ## Read drop-in files from /etc/sudoers.d (the # here does not mean a comment) #includedir /etc/sudoers.d apache ALL=(ALL) NOPASSWD: /etc/rc .d /init .d /nagios reload |
(4)nconfが生成した設定ファイルをNagiosの設定ファイルディレクトリ(cd /usr/local/nagios/etc)に配置できるように設定します。
1 2 3 | # cd /usr/local/nagios/etc # mkdir Default_collector global # chown apache. Default_collector global nagios.cfg |
(5)nconfからnagios.cfgを編集・配置することもできるので、念のため、nconfのディレクトリ配下に「nagios.cfg」をコピーします。
1 2 | # cp /usr/local/nagios/etc/nagios.cfg /usr/local/apache2/htdocs/nconf/static_cfg/ # chown -R apache. /usr/local/apache2/htdocs/nconf/static_cfg/ |
(6)nconfが配置するファイルを設定ファイルとして使用するように、コピーした先の「/usr/local/apache2/htdocs/nconf/static_cfg/nagios.cfg」を編集します。
1 | # vi /usr/local/apache2/htdocs/nconf/static_cfg/nagios.cfg |
・「nagios.cfg」ファイル変更前の内容
※cfg_fileとcfg_dirを全てコメントアウトします。
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 | # You can specify individual object config files as shown below: cfg_file= /usr/local/nagios/etc/objects/commands .cfg cfg_file= /usr/local/nagios/etc/objects/contacts .cfg cfg_file= /usr/local/nagios/etc/objects/timeperiods .cfg cfg_file= /usr/local/nagios/etc/objects/templates .cfg # Definitions for monitoring the local (Linux) host cfg_file= /usr/local/nagios/etc/objects/localhost .cfg # Definitions for monitoring a Windows machine #cfg_file=/usr/local/nagios/etc/objects/windows.cfg # Definitions for monitoring a router/switch #cfg_file=/usr/local/nagios/etc/objects/switch.cfg # Definitions for monitoring a network printer #cfg_file=/usr/local/nagios/etc/objects/printer.cfg # You can also tell Nagios to process all config files (with a .cfg # extension) in a particular directory by using the cfg_dir # directive as shown below: |
・「nagios.cfg」ファイル変更後の内容
28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | # You can specify individual object config files as shown below: #cfg_file=/usr/local/nagios/etc/objects/commands.cfg #cfg_file=/usr/local/nagios/etc/objects/contacts.cfg #cfg_file=/usr/local/nagios/etc/objects/timeperiods.cfg #cfg_file=/usr/local/nagios/etc/objects/templates.cfg # Definitions for monitoring the local (Linux) host #cfg_file=/usr/local/nagios/etc/objects/localhost.cfg # Definitions for monitoring a Windows machine #cfg_file=/usr/local/nagios/etc/objects/windows.cfg # Definitions for monitoring a router/switch #cfg_file=/usr/local/nagios/etc/objects/switch.cfg # Definitions for monitoring a network printer #cfg_file=/usr/local/nagios/etc/objects/printer.cfg # You can also tell Nagios to process all config files (with a .cfg # extension) in a particular directory by using the cfg_dir # directive as shown below: cfg_dir= /usr/local/nagios/etc/global cfg_dir= /usr/local/nagios/etc/Default_collector |
(7)ApacheとNagiosを再起動します。
1 2 3 | # service httpd stop # service nagios restart # service httpd start |