From: Roberto R. <Rob...@en...> - 2006-05-15 10:05:45
|
Q: what method are you using? http://perfparse.sourceforge.net/docs.php A: I think the method used be the sequent:=20 Nagios Invokes Perfparse Description: When you compile Nagios, don't specify --with-file-perfdata but = --with-default-perfdata. Then create a Nagios command to run=20 perfparse-log2mysql every time a log is generated.=20 We defined a shell script wich read from a file and send a kill signal = to nagios to reset its log. This is the content of the script executed = in crontab every 10 minutes: perfparse.sh *************************************************************************= #!/bin/sh CONFIG_FILE=3D"/usr/local/nagios/etc/perfparse.cfg" PERFPARSE=3D"/usr/local/nagios/bin/perfparse-log2mysql" NAGIOS_LOCK_FILE=3D"/usr/local/nagios/var/nagios.lock" ERROR_LOG=3D`egrep "^Error_Log *=3D" ${CONFIG_FILE} | sed -e = 's/^Error_Log *=3D *"\(.*\)".*$/\1/'` PERF_FILE=3D`egrep "^Service_Log = *=3D" ${CONFIG_FILE} | sed -e 's/^Service_Log *=3D *"\(.*\)".*$/\1/'` = TMP_ERR=3D/tmp/perfparse.err.$$ if [ ! -f $ERROR_LOG ] ; then echo Error_Log undefined in ${CONFIG_FILE} echo Cannot continue exit 1 fi if [ ! -f $PERF_FILE ] ; then exit fi if [ "x${NAGIOS_LOCK_FILE}" =3D "x" ] ; then echo "No Nagios Lock file defined." exit 1 fi if [ ! -f $NAGIOS_LOCK_FILE ] ; then NAGIOS_LOCK=3D else NAGIOS_LOCK=3D`cat ${NAGIOS_LOCK_FILE}` fi # Run: mv ${PERF_FILE} ${PERF_FILE}1 if [ "x$NAGIOS_LOCK" !=3D "x" ] ; then kill -1 $NAGIOS_LOCK fi cat ${PERF_FILE}1 |${PERFPARSE} --serviceperf-log - -c ${CONFIG_FILE} 2> = ${TMP_ERR} RETURN=3D$? rm ${PERF_FILE}1 # Did run? case ${RETURN} in 0) # Completed successfully. if [ -f ${TMP_ERR} ] ; then cat ${TMP_ERR} >> ${ERROR_LOG} ; fi ;; 120) # Another copy running if [ -f ${TMP_ERR} ] ; then cat ${TMP_ERR} >> ${ERROR_LOG} ; fi ;; *) # Error # Let this be picked up by cron and emailed # to default administrator if [ -f ${TMP_ERR} ] ; then cat ${TMP_ERR} >> ${ERROR_LOG} ; fi ;; esac if [ -f ${TMP_ERR} ] ; then rm ${TMP_ERR} 2> /dev/null ; fi exit *************************************************************************= This is the pertinent content of the config file nagios.cfg=20 *************************************************************************= cfg_file=3D/usr/local/nagios/etc/nagios_perfparse.cfg xpdfile_host_perfdata_file=3D/usr/local/nagios/var/perfdata-host.log xpdfile_host_perfdata_template=3D$TIMET$\t$HOSTNAME$\t$OUTPUT$\t$PERFDATA= $ xpdfile_service_perfdata_file=3D/usr/local/nagios/var/perfdata-service.lo= g xpdfile_service_perfdata_template=3D$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\t$= OUTPUT$\t$SERVICESTATE$\t$PERFDATA$ perfdata_timeout=3D5 process_performance_data=3D1 = host_perfdata_command=3Dprocess-host-perfdata service_perfdata_command=3Dprocess-service-perfdata # host_perfdata_file=3D = service_perfdata_file=3D/usr/local/nagios/var/perfdata.log # host_perfdata_file_template=3D = service_perfdata_file_template=3D$LASTSERVICECHECK$||$HOSTNAME$||$SERVICE= DESC$||$SERVICEOUTPUT$||$SERVICESPERDATA$ # host_perfdata_file_mode=3D service_perfdata_file_mode=3Da # host_perfdata_file_processing_interval=3D service_perfdata_file_processing_interval=3D30 # host_perfdata_file_processing_command=3D service_perfdata_file_processing_command=3Dprocess-service-perfdata ************************************* And this is the content of the config file perfparse.cfg *************************************************************************= * Error_Log =3D "/usr/local/nagios/var/perfparse.log" Error_Log_Rotate =3D "yes" Error_Log_Keep_N_Days =3D "7" Drop_File =3D "/usr/local/nagios/var/perfparse.drop" Drop_File_Rotate =3D "yes" Drop_File_Keep_N_Days =3D "7" Server_Port =3D "1976" Service_Log =3D "/usr/local/nagios/var/perfdata-service.log" Service_Log_Save_Position =3D "yes" Service_Log_Position_Mark_Path =3D = "/usr/local/nagios/var" Daemon_Lock =3D = "/usr/local/nagios//var/perfparsed.lock" Daemonize =3D "no" Periodic_Cleanup =3D "yes" Periodic_Cleanup_Lock =3D = "/usr/local/nagios//var/perfparsed_periodic_cleanup.lock" Periodic_Cleanup_Hour =3D "0230" Dummy_Hostname =3D "LinuxSAM" No_Raw_Data =3D "no" No_Bin_Data =3D "no" Storage_Modules_Dir =3D "/usr/local/nagios//lib" Storage_Modules_Load = =3D "mysql" Storage_Modules_Status_File =3D = "/usr/local/nagios/var/storage_modules.status" # Storage Module : mysql # = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D DB_User =3D "nagios" DB_Pass =3D "" DB_Name =3D "nagios" DB_Host =3D "LinuxSAM" *************************************************************************= Q: how is your process-service-perfdata command defined? A: this is the content of the config file nagios_perfparse.cfg ************************************* define command{ command_name process-service-perfdata command_line = /usr/local/nagios/bin/perfparse_nagios_command.pl = /usr/local/nagios/var/perfdata-service.log "$TIMET$"=20 "$HOSTNAME$" "$SERVICEDESC$" "$SERVICEOUTPUT$" "$SERVICESTATE$" = "$SERVICEPERFDATA$" } define command{ command_name process-host-perfdata command_line = /usr/local/nagios/bin/perfparse_nagios_command.pl = /usr/local/nagios/var/perfdata-host.log "$TIMET$"=20 "$HOSTNAME$" "$HOSTOUTPUT$" "$HOSTPERFDATA$" } =20 Roberto Raffo=20 Digital Solution Center System & Application Management ---------------------------------------- Via Galbani, n=B0 55 00156 - Roma Phone +39 06 7202 0337 Mobile +39 320 4080151 Fax +39 06 7202 8020 www.enterpriseda.com=20 =20 "Il presente messaggio e gli eventuali allegati sono di natura = confidenziale.=20 Qualora vi fosse pervenuto per errore, vi preghiamo di cancellarlo immediatamente dal vostro sistema e di avvisare il mittente. Grazie." =20 "This electronic mail transmission and any accompanying attachments = contain confidential information. If you have received this communication in = error, please immediately delete the E-mail and either notify the sender. Thank = you." =20 =20 >>-----Original Message----- >>From: per...@li... = [mailto:perfparse-users- >>ad...@li...] On Behalf Of Florian Gleixner >>Sent: venerd=EC 12 maggio 2006 23.45 >>To: per...@li... >>Subject: Re: [Perfparse-users] Nagios and Perfparse integration = problem >> >>Hi, >> >>what method are you using? >>http://perfparse.sourceforge.net/docs.php >>how is your process-service-perfdata command defined? >> >>Flo >> >>Roberto Raffo schrieb: >>> >>> >>> >>> >>> Hi folks! >>> >>> We use Nagios to monitor approximately 120 hosts with a total of 400 >>> checks. >>> >>> This worked fine but when we have installed perfparse many checks = appear >>> to have problems. >>> >>> In some cases they are rescheduled without produce output. In other >>> cases they simply do not work without even be rescheduled. >>> >>> Only a few checks go on working correctly, but, after a few hours, = all >>> the ckecks appear to stop working and rescheduling. >>> >>> The worse thing is that no error message is recorded on the event = log. >>> >>> >>> >>> Other informations: >>> >>> - We use Nagios 2.1 and Perfparse 0.105.6. >>> >>> - Perfparse is scheduled in crontab every 10 minutes. >>> >>> >>> >>> Any ideas? >>> >>> >>> >>> >>> >>> >>> >>> >>> >>> * Roberto Raffo * >>> >>> Application & Service Providing >>> >>> ---------------------------------------- >>> >>> Via Galbani, n=B0 55 00156 - Roma >>> >>> rob...@en... >>> >>> www.enterpriseda.com <http://www.enterpriseda.com/> >>> >>> >>> >> >> >>------------------------------------------------------- >>Using Tomcat but need to do more? Need to support web services, = security? >>Get stuff done quickly with pre-integrated technology to make your job >>easier >>Download IBM WebSphere Application Server v.1.0.1 based on Apache = Geronimo >>http://sel.as-us.falkag.net/sel?cmd=3Dk&kid=120709&bid&3057&dat=121642 >>_______________________________________________ >>Perfparse-users mailing list >>Per...@li... >>https://lists.sourceforge.net/lists/listinfo/perfparse-users |
From: Florian G. <fl...@bi...> - 2006-05-15 21:13:58
|
Hi, i'm not too familiar with nagios 2.X yet, so my answer may not be complet= e. You choosed to let nagios write the perfdata files. Tho avoid duplicates=20 in the database it was once necessary to restart nagios to write a new=20 logfile from time to time. This is what your cron-script shall do. But=20 this is no more necessary. perfparse can record the file position and=20 uses this to avoid duplicates. You have switched it already on with: Service_Log_Save_Position =3D "yes" Service_Log_Position_Mark_Path =3D "/usr/local/nagios/var" You just should do a logrotate whenever the file gets too big (once a=20 week?). The frequent nagios restarts worked if you just had some service=20 checks. If you have some hundreds, then nagios cannot schedule all=20 within two restarts. That's bad. Nagios 2 also offers a cron like performancefile processing command:=20 With the parameters service_perfdata_file_processing_interval=3D30 service_perfdata_file_processing_command=3Dprocess-service-perfdata you can tell nagios to do something with ther performance data log=20 everey 30 Minutes. You have defined a command here. If this command just=20 runs perfparse-log2mysql with the right parameters it could be enough=20 already. So in short: Disable that cronjob and do a periodic perfparse-log2mysql=20 via cron or nagios. What i don't know is if the nagios internal format of the performance=20 data has changed from 1.X to 2.X. If yes, then it may not work and you=20 have to define a command to write your performance logs - see pp docs. Flo Roberto Raffo schrieb: > Q: what method are you using? http://perfparse.sourceforge.net/docs.php >=20 > A: I think the method used be the sequent:=20 > Nagios Invokes Perfparse > Description: > When you compile Nagios, don't specify --with-file-perfdata but --with-= default-perfdata. Then create a Nagios command to run=20 >=20 > perfparse-log2mysql every time a log is generated.=20 >=20 > We defined a shell script wich read from a file and send a kill signal = to nagios to reset its log. This is the content of the script executed in= crontab every 10 minutes: perfparse.sh > ***********************************************************************= ** > #!/bin/sh > CONFIG_FILE=3D"/usr/local/nagios/etc/perfparse.cfg" > PERFPARSE=3D"/usr/local/nagios/bin/perfparse-log2mysql" > NAGIOS_LOCK_FILE=3D"/usr/local/nagios/var/nagios.lock" >=20 > ERROR_LOG=3D`egrep "^Error_Log *=3D" ${CONFIG_FILE} | sed -e 's/^Error_= Log *=3D *"\(.*\)".*$/\1/'` PERF_FILE=3D`egrep "^Service_Log *=3D" ${CONF= IG_FILE} | sed -e 's/^Service_Log *=3D *"\(.*\)".*$/\1/'` TMP_ERR=3D/tmp/= perfparse.err.$$ >=20 > if [ ! -f $ERROR_LOG ] ; then > echo Error_Log undefined in ${CONFIG_FILE} > echo Cannot continue > exit 1 > fi >=20 > if [ ! -f $PERF_FILE ] ; then > exit > fi >=20 > if [ "x${NAGIOS_LOCK_FILE}" =3D "x" ] ; then > echo "No Nagios Lock file defined." > exit 1 > fi >=20 > if [ ! -f $NAGIOS_LOCK_FILE ] ; then > NAGIOS_LOCK=3D > else > NAGIOS_LOCK=3D`cat ${NAGIOS_LOCK_FILE}` > fi >=20 > # Run: > mv ${PERF_FILE} ${PERF_FILE}1 > if [ "x$NAGIOS_LOCK" !=3D "x" ] ; then > kill -1 $NAGIOS_LOCK > fi > cat ${PERF_FILE}1 |${PERFPARSE} --serviceperf-log - -c ${CONFIG_FILE} 2= > ${TMP_ERR} RETURN=3D$? rm ${PERF_FILE}1 >=20 > # Did run? > case ${RETURN} in > 0) > # Completed successfully. > if [ -f ${TMP_ERR} ] ; then cat ${TMP_ERR} >> ${ERROR_LOG} ; fi > ;; > 120) > # Another copy running > if [ -f ${TMP_ERR} ] ; then cat ${TMP_ERR} >> ${ERROR_LOG} ; fi > ;; > *) > # Error > # Let this be picked up by cron and emailed > # to default administrator > if [ -f ${TMP_ERR} ] ; then cat ${TMP_ERR} >> ${ERROR_LOG} ; fi > ;; > esac >=20 >=20 > if [ -f ${TMP_ERR} ] ; then rm ${TMP_ERR} 2> /dev/null ; fi >=20 > exit > ***********************************************************************= ** >=20 >=20 > This is the pertinent content of the config file nagios.cfg=20 > ***********************************************************************= ** > cfg_file=3D/usr/local/nagios/etc/nagios_perfparse.cfg > xpdfile_host_perfdata_file=3D/usr/local/nagios/var/perfdata-host.log > xpdfile_host_perfdata_template=3D$TIMET$\t$HOSTNAME$\t$OUTPUT$\t$PERFDA= TA$ > xpdfile_service_perfdata_file=3D/usr/local/nagios/var/perfdata-service.= log > xpdfile_service_perfdata_template=3D$TIMET$\t$HOSTNAME$\t$SERVICEDESC$\= t$OUTPUT$\t$SERVICESTATE$\t$PERFDATA$ >=20 > perfdata_timeout=3D5 > process_performance_data=3D1 host_perfdata_command=3Dprocess-host-perfd= ata > service_perfdata_command=3Dprocess-service-perfdata > # host_perfdata_file=3D service_perfdata_file=3D/usr/local/nagios/var/p= erfdata.log > # host_perfdata_file_template=3D service_perfdata_file_template=3D$LAST= SERVICECHECK$||$HOSTNAME$||$SERVICEDESC$||$SERVICEOUTPUT$||$SERVICESPERDA= TA$ > # host_perfdata_file_mode=3D > service_perfdata_file_mode=3Da > # host_perfdata_file_processing_interval=3D > service_perfdata_file_processing_interval=3D30 > # host_perfdata_file_processing_command=3D > service_perfdata_file_processing_command=3Dprocess-service-perfdata > ************************************* >=20 >=20 > And this is the content of the config file perfparse.cfg > ***********************************************************************= *** > Error_Log =3D "/usr/local/nagios/var/perfparse.log" > Error_Log_Rotate =3D "yes" > Error_Log_Keep_N_Days =3D "7" > Drop_File =3D "/usr/local/nagios/var/perfparse.drop" > Drop_File_Rotate =3D "yes" > Drop_File_Keep_N_Days =3D "7" > Server_Port =3D "1976" > Service_Log =3D "/usr/local/nagios/var/perfdata-service.log" > Service_Log_Save_Position =3D "yes" Service_Log_Position_Mark_Path =3D = "/usr/local/nagios/var" Daemon_Lock =3D "/usr/local/nagios//var/perfparse= d.lock" > Daemonize =3D "no" > Periodic_Cleanup =3D "yes" > Periodic_Cleanup_Lock =3D "/usr/local/nagios//var/perfparsed_periodic_c= leanup.lock" > Periodic_Cleanup_Hour =3D "0230" > Dummy_Hostname =3D "LinuxSAM" > No_Raw_Data =3D "no" > No_Bin_Data =3D "no" > Storage_Modules_Dir =3D "/usr/local/nagios//lib" Storage_Modules_Load =3D= "mysql" Storage_Modules_Status_File =3D "/usr/local/nagios/var/storage_m= odules.status" >=20 > # Storage Module : mysql > # =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D > DB_User =3D "nagios" > DB_Pass =3D "" > DB_Name =3D "nagios" > DB_Host =3D "LinuxSAM" > ***********************************************************************= ** >=20 >=20 >=20 >=20 >=20 >=20 >=20 > Q: how is your process-service-perfdata command defined? >=20 > A: this is the content of the config file nagios_perfparse.cfg > ************************************* > define command{ > command_name process-service-perfdata > command_line /usr/local/nagios/bin/perfparse_nagios_command.= pl /usr/local/nagios/var/perfdata-service.log "$TIMET$"=20 >=20 > "$HOSTNAME$" "$SERVICEDESC$" "$SERVICEOUTPUT$" "$SERVICESTATE$" "$SERVI= CEPERFDATA$" > } > define command{ > command_name process-host-perfdata > command_line /usr/local/nagios/bin/perfparse_nagios_command.= pl /usr/local/nagios/var/perfdata-host.log "$TIMET$"=20 >=20 > "$HOSTNAME$" "$HOSTOUTPUT$" "$HOSTPERFDATA$" > } >=20 >=20 > =20 > Roberto Raffo=20 > Digital Solution Center > System & Application Management > ---------------------------------------- > Via Galbani, n=B0 55 00156 - Roma > Phone +39 06 7202 0337 > Mobile +39 320 4080151 > Fax +39 06 7202 8020 > www.enterpriseda.com=20 > =20 > "Il presente messaggio e gli eventuali allegati sono di natura confiden= ziale.=20 > Qualora vi fosse pervenuto per errore, vi preghiamo di cancellarlo > immediatamente dal vostro sistema e di avvisare il mittente. Grazie." > =20 > "This electronic mail transmission and any accompanying attachments con= tain > confidential information. If you have received this communication in er= ror, > please immediately delete the E-mail and either notify the sender. Than= k you." > =20 > =20 >=20 >>> -----Original Message----- >>> From: per...@li... [mailto:perfparse-u= sers- >>> ad...@li...] On Behalf Of Florian Gleixner >>> Sent: venerd=EC 12 maggio 2006 23.45 >>> To: per...@li... >>> Subject: Re: [Perfparse-users] Nagios and Perfparse integration probl= em >>> >>> Hi, >>> >>> what method are you using? >>> http://perfparse.sourceforge.net/docs.php >>> how is your process-service-perfdata command defined? >>> >>> Flo >>> >>> Roberto Raffo schrieb: >>>> >>>> >>>> >>>> Hi folks! >>>> >>>> We use Nagios to monitor approximately 120 hosts with a total of 400 >>>> checks. >>>> >>>> This worked fine but when we have installed perfparse many checks ap= pear >>>> to have problems. >>>> >>>> In some cases they are rescheduled without produce output. In other >>>> cases they simply do not work without even be rescheduled. >>>> >>>> Only a few checks go on working correctly, but, after a few hours, a= ll >>>> the ckecks appear to stop working and rescheduling. >>>> >>>> The worse thing is that no error message is recorded on the event lo= g. >>>> >>>> >>>> >>>> Other informations: >>>> >>>> - We use Nagios 2.1 and Perfparse 0.105.6. >>>> >>>> - Perfparse is scheduled in crontab every 10 minutes. >>>> >>>> >>>> >>>> Any ideas? >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> * Roberto Raffo * >>>> >>>> Application & Service Providing >>>> >>>> ---------------------------------------- >>>> >>>> Via Galbani, n=B0 55 00156 - Roma >>>> >>>> rob...@en... >>>> >>>> www.enterpriseda.com <http://www.enterpriseda.com/> >>>> >>>> >>>> >>> >>> ------------------------------------------------------- >>> Using Tomcat but need to do more? Need to support web services, secur= ity? >>> Get stuff done quickly with pre-integrated technology to make your jo= b >>> easier >>> Download IBM WebSphere Application Server v.1.0.1 based on Apache Ger= onimo >>> http://sel.as-us.falkag.net/sel?cmd=3Dk&kid=120709&bid&3057&dat=12164= 2 >>> _______________________________________________ >>> Perfparse-users mailing list >>> Per...@li... >>> https://lists.sourceforge.net/lists/listinfo/perfparse-users |