Tips

nagiosでフリーな監視をしてみよう!~nagiosの設定(10)~

pnp4nagiosの設定


次に、PNP4NagiosとNagiosが連携されるように、それぞれの設定ファイルを編集したりしていきます。

(1)「nagios.cfg」ファイルを編集します。

# vi /usr/local/nagios/etc/nagios.cfg


・「/usr/local/nagios/etc/nagios.cfg」ファイル変更前の内容

 # Values: 1 = process performance data, 0 = do not process performance data

 process_performance_data=0


・「/usr/local/nagios/etc/nrpe.cfg」ファイル変更後の内容

 # Values: 1 = process performance data, 0 = do not process performance data

 #process_performance_data=0
 process_performance_data=1

 #
 # service performance data
 #
 service_perfdata_file=/usr/local/pnp4nagios/var/service-perfdata
 service_perfdata_file_template=DATATYPE::SERVICEPERFDATAtTIMET::$TIMET$tHOSTNAME::$HOSTNAME$tSERVICEDESC::$SERVICEDESC$tSERVICEPERFDATA::$SERVICEPERFDATA$tSERVICECHECKCOMMAND::$SERVICECHECKCOMMAND$tHOSTSTATE::$HOSTSTATE$tHOSTSTATETYPE::$HOSTSTATETYPE$tSERVICESTATE::$SERVICESTATE$tSERVICESTATETYPE::$SERVICESTATETYPE$
 service_perfdata_file_mode=a
 service_perfdata_file_processing_interval=15
 service_perfdata_file_processing_command=process-service-perfdata-file


(2)「command.cfg」ファイルを編集します。

# vi /usr/local/nagios/etc/objects/commands.cfg


・「/usr/local/nagios/etc/objects/commands.cfg」ファイル変更後の内容

 # 'process-host-perfdata' command definition
 define command{
    command_name    process-host-perfdata
    command_line    /usr/bin/printf "%b" "$LASTHOSTCHECK$t$HOSTNAME$t$HOSTSTATE$t$HOSTATTEMPT$t$HOSTSTATETYPE$t$HOSTEXECUTIONT        IME$t$HOSTOUTPUT$t$HOSTPERFDATA$n" >> /usr/local/nagios/var/host-perfdata.out
    }


 # 'process-service-perfdata' command definition
 define command{
    command_name    process-service-perfdata
    command_line    /usr/bin/printf "%b" "$LASTSERVICECHECK$t$HOSTNAME$t$SERVICEDESC$t$SERVICESTATE$t$SERVICEATTEMPT$t$SERVICE        STATETYPE$t$SERVICEEXECUTIONTIME$t$SERVICELATENCY$t$SERVICEOUTPUT$t$SERVICEPERFDATA$n" >> /usr/local/nagios/var/service-perfda        ta.out
    }


・「/usr/local/nagios/etc/objects/commands.cfg」ファイル変更後の内容

 # 'process-host-perfdata' command definition
 #define command{
 #   command_name    process-host-perfdata
 #   command_line    /usr/bin/printf "%b" "$LASTHOSTCHECK$t$HOSTNAME$t$HOSTSTATE$t$HOSTATTEMPT$t$HOSTSTATETYPE$t$HOSTEXECUTIONT        IME$t$HOSTOUTPUT$t$HOSTPERFDATA$n" >> /usr/local/nagios/var/host-perfdata.out
 #   }


 # 'process-service-perfdata' command definition
 #define command{
 #   command_name    process-service-perfdata
 #   command_line    /usr/bin/printf "%b" "$LASTSERVICECHECK$t$HOSTNAME$t$SERVICEDESC$t$SERVICESTATE$t$SERVICEATTEMPT$t$SERVICE        STATETYPE$t$SERVICEEXECUTIONTIME$t$SERVICELATENCY$t$SERVICEOUTPUT$t$SERVICEPERFDATA$n" >> /usr/local/nagios/var/service-perfda        ta.out
 #   }

 define command{
     command_name    process-service-perfdata-file
     command_line    /bin/mv /usr/local/pnp4nagios/var/service-perfdata /usr/local/pnp4nagios/var/spool/service-perfdata.$TIMET$
 }

 define command{
     command_name    process-host-perfdata-file
     command_line    /bin/mv /usr/local/pnp4nagios/var/host-perfdata /usr/local/pnp4nagios/var/spool/host-perfdata.$TIMET$
 }


(3)「templates.cfg」を編集します。

# vi /usr/local/nagios/etc/objects/templates.cfg


・「/usr/local/nagios/etc/objects/templates.cfg」ファイル変更後の内容

         register                        0           ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
         action_url /pnp4nagios/index.php?host=$HOSTNAME$' onmouseover="get_g('$HOSTNAME$','_HOST_')" onmouseout="clear_g()"
         }

     register            0       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
     action_url /pnp4nagios/index.php?host=$HOSTNAME$' onmouseover="get_g('$HOSTNAME$','_HOST_')" onmouseout="clear_g()"
     }


(4)pnp4nagios確認用画面の設定を行います。

# cp -p /usr/local/src/pnp4nagios-0.6.25/sample-config/httpd.conf /usr/local/apache2/conf/extra/pnp4nagios.conf
# vi /usr/local/apache2/conf/httpd.conf


・「/usr/local/apache2/conf/httpd.conf」ファイル変更後の内容

 # nagios setting
 Include conf/extra/nagios.conf
 Include conf/extra/pnp4nagios.conf

Linux認定資格 LPICを取るなら・・

Linux資格 「LPIC Lv1」徹底解説 連載目次

Recent News

Recent Tips

Tag Search