<br><tt><font size=2>nagios-users-bounces@lists.sourceforge.net schrieb
am 09.07.2008 12:04:01:<br>
<br>
> after debugging some retry problems, I stumbled over strange entries<br>
> in the showlog.cgi (see attached <br>
> screenshot). This is the daily log. At 00:00 it rotates and logs all<br>
> initial states of the machines/services - <br>
> even though I disabled it in the nagios.cfg. Though I do not really
<br>
> mind that. The strange thing are the <br>
> empty entries of 01.01.1970 _after_ the initial states, then some
<br>
> current entries, then again 01.01.1970, then <br>
> again current states, and then nagios logs ALL the initial states
_again_. <br>
> <br>
> Not that it's causing any obvious problems, but it looks kinda <br>
> strange in my opinion. <br>
> Does anyone have an idea what may cause this behaviour? <br>
</font></tt>
<br><tt><font size=2>Self-replies rock. ;)</font></tt>
<br><tt><font size=2>I'll CC this to nagios-devel since it's a bug. I'm
not yet sure</font></tt>
<br><tt><font size=2>where it actually comes from, but I guess it's inside
process_macros().</font></tt>
<br><tt><font size=2>Still trying to pin it down exactly...</font></tt>
<br>
<br><tt><font size=2>Back to my initial problem (see above).</font></tt>
<br><tt><font size=2>After some debugging I found the culprit. It's my
service definitions</font></tt>
<br><tt><font size=2>containing quoted $ signs. Nagios stumbles over them
and logs nonsense</font></tt>
<br><tt><font size=2>in the current state logging after log rotating and
everytime else when</font></tt>
<br><tt><font size=2>it processes macros for this server (see below).</font></tt>
<br>
<br><tt><font size=2>This is an excerpt from nagios.log (notice the lines
with single $ on them):</font></tt>
<br>
<br><tt><font size=2>[1215727200] CURRENT SERVICE STATE: esskhk01;MSSQLSERVER;OK;HARD;1;OK:
MSSQLSERVER: started</font></tt>
<br><tt><font size=2>[1215727200] CURRENT SERVICE STATE: esskhk01;MSSQL_PERBIT;OK;HARD;1;OK:
MSSQL$PERBIT: started</font></tt>
<br><tt><font size=2>$</font></tt>
<br><tt><font size=2>[1215727200] CURRENT SERVICE STATE: esskhk01;MSSQL_PERSONAL;OK;HARD;1;OK:
MSSQL$PERSONAL: started</font></tt>
<br><tt><font size=2>$</font></tt>
<br><tt><font size=2>[1215727200] CURRENT SERVICE STATE: esskhk01;NSClient_Version;OK;HARD;1;I
(0.3.0.4 2007-12-04) seem to be doing fine...</font></tt>
<br><tt><font size=2>[1215727200] CURRENT SERVICE STATE: esskhk01;SQLAgent_PERBIT;OK;HARD;1;OK:
SQLAgent$PERBIT: started</font></tt>
<br><tt><font size=2>$</font></tt>
<br><tt><font size=2>[1215727200] CURRENT SERVICE STATE: esskhk01;SQLAgent_PERSONAL;OK;HARD;1;OK:
SQLAgent$PERSONAL: started</font></tt>
<br><tt><font size=2>$</font></tt>
<br><tt><font size=2>[1215727200] CURRENT SERVICE STATE: esskhk01;SQLSERVERAGENT;OK;HARD;1;OK:
SQLSERVERAGENT: started</font></tt>
<br>
<br><tt><font size=2>Those "$" lines show up as "</font></tt><font size=3>[01-01-1970
01:00:00] </font><tt><font size=2>" with empty info on them in the
showlog.cgi (see below).</font></tt>
<br>
<br><tt><font size=2>My service definition for example:</font></tt>
<br>
<br><tt><font size=2>define service {</font></tt>
<br><tt><font size=2>        service_description  
          MSSQL_PERBIT</font></tt>
<br><tt><font size=2>        use      
                     
generic-service-noperf</font></tt>
<br><tt><font size=2>        host_name    
                  esskhk01</font></tt>
<br><tt><font size=2>        check_command    
              check_nrpe_services!MSSQL"$$"PERBIT</font></tt>
<br><tt><font size=2>}</font></tt>
<br>
<br><tt><font size=2>Debugging shows (debug_level=-1, debug_verbosity=2):</font></tt>
<br>
<br><tt><font size=2>Check gets scheduled and nagios parses the returnvalue.
Obviously there is a \n that does not belong there.</font></tt>
<br><tt><font size=2>Not yet sure why it shows up there...</font></tt>
<br>
<br><tt><font size=2>[1215777431.127292] [001.0] [pid=3539] handle_async_service_check_result()</font></tt>
<br><tt><font size=2>[1215777431.127299] [016.0] [pid=3539] ** Handling
check result for service 'MSSQL_PERBIT' on host 'esskhk01'...</font></tt>
<br><tt><font size=2>[1215777431.127305] [016.1] [pid=3539] HOST: esskhk01,
SERVICE: MSSQL_PERBIT, CHECK TYPE: Active, OPTIONS: 0, SCHEDULED: Yes,
RESCHE</font></tt>
<br><tt><font size=2>DULE: Yes, EXITED OK: Yes, RETURN CODE: 3, OUTPUT:
Service: MSSQL$PERBI caused: GetServiceKeyName: Could not translate service
name(</font></tt>
<br><tt><font size=2>997)\n</font></tt>
<br><tt><font size=2>[1215777431.127320] [016.1] [pid=3539] Service is
in a non-OK state!</font></tt>
<br>
<br><tt><font size=2>- Shortly afterwards the macros for the alert get
processed.</font></tt>
<br><tt><font size=2>- The fprintf parses the \n and the log shows a newline
now.</font></tt>
<br><tt><font size=2>- Afterwards process_macros() parses the string and
tries to resolve everything after the $ in the service</font></tt>
<br><tt><font size=2>  definition.</font></tt>
<br><tt><font size=2>- It fails to do so for obvious reasons, but then
it seems to add an extra $ at the end of the buffer,</font></tt>
<br><tt><font size=2>  maybe while trying to fix up a "broken
macro"?</font></tt>
<br><tt><font size=2>- Because the input buffer does not seem to be stripped
yet, it adds an extra $ _after_ the \n</font></tt>
<br><tt><font size=2>- strip(buffer) doesn't work anymore, as it only strips
\n and " " when trailing and heading.</font></tt>
<br>
<br><tt><font size=2>That's why I see single "$" entries in my
logfile - which the showlog.cgi wrong parses as</font></tt>
<br><tt><font size=2>"</font></tt><font size=3>[01-01-1970 01:00:00]
</font><tt><font size=2>"</font></tt>
<br><tt><font size=2>Notice the buffer before processing (no $ at the end)
and after processing (with $ at the end - after the \n).</font></tt>
<br>
<br><tt><font size=2>[1215777431.129970] [2048.1] [pid=3539] **** BEGIN
MACRO PROCESSING ***********</font></tt>
<br><tt><font size=2>[1215777431.129978] [2048.1] [pid=3539] Processing:
'SERVICE ALERT: esskhk01;MSSQL_PERBIT;$SERVICESTATE$;$SERVICESTATETYPE$;$SERVICE</font></tt>
<br><tt><font size=2>ATTEMPT$;Service: MSSQL$PERBI caused: GetServiceKeyName:
Could not translate service name(997)</font></tt>
<br><tt><font size=2>'</font></tt>
<br><tt><font size=2>[1215777431.130001] [2048.0] [pid=3539]  WARNING:
Could not find a macro matching 'PERBI caused'!</font></tt>
<br><tt><font size=2>[1215777431.130010] [2048.0] [pid=3539]  WARNING:
An error occurred processing macro 'PERBI caused: GetServiceKeyName: Could
not tra</font></tt>
<br><tt><font size=2>nslate service name(997)</font></tt>
<br><tt><font size=2>'!</font></tt>
<br><tt><font size=2>[1215777431.130018] [2048.1] [pid=3539]   Done.
 Final output: 'SERVICE ALERT: esskhk01;MSSQL_PERBIT;UNKNOWN;SOFT;1;Service:
MSSQL$P</font></tt>
<br><tt><font size=2>ERBI caused: GetServiceKeyName: Could not translate
service name(997)</font></tt>
<br><tt><font size=2>$'</font></tt>
<br><tt><font size=2>[1215777431.130025] [2048.1] [pid=3539] **** END MACRO
PROCESSING *************</font></tt>
<br>
<br>
<br><tt><font size=2>Sadly process_macros() is really ... uhm ... ugly
;) I haven't been able to find the problem yet.</font></tt>
<br><tt><font size=2>Maybe someone with more insight in common/macros.c
can have a look? I'm more then happy to assist though.</font></tt>
<br>
<br><tt><font size=2>Regards</font></tt>
<br><tt><font size=2>        Sascha</font></tt>
<br>
<br><tt><font size=2>PS: Nagios 3.0.3 of course.</font></tt>
<br>
<br><font size=2 face="sans-serif">-- <br>
Sascha Runschke<br>
Netzwerk-  und  Systemmanagement<br>
Telefon : +49 (201) 102-1879 Mobil : +49 (173) 5419665 Fax : +49 (201)
102-1102105</font>
<br>
<br>
<br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">GFKL Financial Services AG</span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">Vorstand: Dr. Peter Jänsch (Vors.), Jürgen Baltes, Dr. Till Ergenzinger, Dr. Tom Haverkamp</span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">Vorsitzender des Aufsichtsrats: Dr. Georg F. Thoma</span><br>
<span style="font-family:sans-serif,helvetica; font-size:10pt; color:#000000">Sitz: Limbecker Platz 1, 45127 Essen, Amtsgericht Essen, HRB 13522</span>