How to show multi-line of output using check_logfiles

Support forum for Nagios Core, Nagios Plugins, NCPA, NRPE, NSCA, NDOUtils and more. Engage with the community of users including those using the open source solutions.
prabakaran
Posts: 8
Joined: Fri Aug 03, 2012 4:48 am

How to show multi-line of output using check_logfiles

Post by prabakaran »

Hi all,
I used check_logfiles for Windows log files monitoring using "NSCliet++". Plug-in can identifies the no of errors on particular time, but it shows on UI (or EMail) with minimal results like below, here it shows 4 errors, 4 warnings but in mail it sent only one ERROR detail

CRITICAL - (4 errors, 4 warnings) - 8319: 20130204-001141-663: [401] (E:Utility) ERROR: Exception.cr/4280-aee3 /Error_DuplicateName/violation of unique constraint/ at System.Environment.StackTrace(Exception e, Boolean needFileInfo) ...

$seekfilesdir='.'; $MACROS = { LOGPATH => 'C:/xxxxxxx/yyyyyy/' }; $options = 'report=long'; @searches = ({ tag => 'Test', type => 'rotating::uniform', logfile => '$LOGPATH$20121104-040845-389-TestFile.txt', rotation => '.TestFile.', criticalpatterns => ['.ERROR:.'], warningpatterns => ['.WARNING:.'],
options => 'noprotocol,nologfilenocry' });

I tried with maxlength=4096 in 'options' also, but it doesn't resolve. How can i get whole errors and warning details in Mail alert and UI? Please help me to solve this.

Thanks
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: How to show multi-line of output using check_logfiles

Post by slansing »

For notifications you should be able to add in the following macro in the notification configuration to see additional output from the checks.

Next to $SERVICEOUTPUT$ place $LONGSERVICEOUTPUT$.

Code: Select all

$SERVICEOUTPUT$ $LONGSERVICEOUTPUT$
prabakaran
Posts: 8
Joined: Fri Aug 03, 2012 4:48 am

Re: How to show multi-line of output using check_logfiles

Post by prabakaran »

Slansing,thanks for your quick reply. Its really helps to me. But I required little more, Following is my email notification from Nagios

Additional Info: $SERVICEOUTPUT$
WARNING - (21 warnings) - 69085: 20130213-013933-805: [200] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role ...

Trace Info: $LONGSERVICEOUTPUT$
tag apiservice WARNING
68799: 20130213-013735-696: [206] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
68811: 20130213-013741-795: [206] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
68823: 20130213-013746-366: [226] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
68835: 20130213-013751-467: [209] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
68847: 20130213-013756-709: [152] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
68869: 20130213-013801-577: [226] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
68881: 20130213-013806-757: [227]

Actual warnings are 21, but i got 6 only. Compare to $SERVICEOUTPUT$ this one is fine, but can I get complete (i.e. 21 warnings) service output ?

Thanks
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: How to show multi-line of output using check_logfiles

Post by slansing »

Is that how the check result is formatted for you in your actual email? It looks like it is returning an additional line but there is nothing on it:
68881: 20130213-013806-757: [227]
If you switch the notification definition from $SERVICEOUTPUT$$LONGSERVICEOUTPUT$

To $LONGSERVICEOUTPUT$ only, do you see everything after what you normally see?
prabakaran
Posts: 8
Joined: Fri Aug 03, 2012 4:48 am

Re: How to show multi-line of output using check_logfiles

Post by prabakaran »

Hi, after configured as you mentioned "$SERVICEOUTPUT$$LONGSERVICEOUTPUT$" i got below output,
Testing Info:
WARNING - (13 warnings) - 67659: 20130220-024112-124: [009] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role ...tag apiservice WARNING
67281: 20130220-023916-778: [024] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
67293: 20130220-023923-954: [022] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
67315: 20130220-023953-251: [009] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
67327: 20130220-024003-188: [015] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
67339: 20130220-024010-660: [012] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
67351: 20130220-024020-566: [013] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
67363: 20130220-024028-491: [015]


But my log file returning more lines,
...
67363: 20130220-024028-491: [015] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
67375: 20130220-024034-918: [008] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
67387: 20130220-024042-063: [020] (W:CommonApiService) WARNING: RestApiHelper.RequestFilter: user is not in role
... etc.,

How can I resolve it ?

Thanks
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: How to show multi-line of output using check_logfiles

Post by slansing »

Can you show us an example of what you see on the service details page in your Nagios web UI? A copy and paste of the output with a screenshot would be great.
prabakaran
Posts: 8
Joined: Fri Aug 03, 2012 4:48 am

Re: How to show multi-line of output using check_logfiles

Post by prabakaran »

Hi,
I attached the output screenshot of error trace service. This is not same which I mentioned before, but similar to that. In here it shows 4 ERRORS , but I can view only two of them. These two error details only sent as a EMail alert. I want to send mail with complete error trace, How can I get complete error details ?

Thanks
Attachments
Screenshot of ERROR details from Nagios UI
Screenshot of ERROR details from Nagios UI
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

Re: How to show multi-line of output using check_logfiles

Post by slansing »

What does the check output when you run it from the Nagios command line? Use the same command as is shown in the email notification, and let us know what the output is, thanks!
nshah11
Posts: 8
Joined: Tue Oct 28, 2014 2:51 pm

Re: How to show multi-line of output using check_logfiles

Post by nshah11 »

Hi,

I am having the same issue. Was this one resolved?
I tried the $SERVICEOUTPUT$ $LONGSERVICEOUTPUT$ but I am still not receiving all the errors in the email.

Thanks
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: How to show multi-line of output using check_logfiles

Post by tmcdonald »

This topic is quite old and many things have changed since then. What version are you on now?
Former Nagios employee
Locked