check_logfiles plugin

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_logfiles plugin

Post by ssax »

Try deleting the protocols files from C:\Nagios\NSClient++, use the code below, and then test again:

Code: Select all

use File::stat;

$protocolsdir = 'C:/Nagios/NSClient++';
$seekfilesdir = 'C:/Nagios/NSClient++';

my @files = sort {stat($a)->mtime <=> stat($b)->mtime} glob '"C:\Program Files\Apache Software Foundation\Tomcat 8.5_Tomcat8_BMC_SmartIT\logs\localhost.*.log"';
my $latest_file = $files[-1];

@searches = ();

push(@searches, {
    tag => basename("$latest_file"),
    logfile => "$latest_file",
    criticalpatterns => ['java.net.SocketException: Connection reset by peer']
});

# Need to end with this
1;
It's working on mine with the last as well with the same directory layout and files.
deek
Posts: 194
Joined: Fri Apr 26, 2019 2:01 am

Re: check_logfiles plugin

Post by deek »

Tried , Im getting the same error . Is it something to do with the directory permission ?
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_logfiles plugin

Post by ssax »

It may be, are you running the nsclient++ service as Local System or a different users account?

What do the permissions show on C:\Nagios\NSClient++?

Try creating D:\testing and then change it to this:

Code: Select all

use File::stat;

$protocolsdir = 'D:\testing';
$seekfilesdir = 'D:\testing';

my @files = sort {stat($a)->mtime <=> stat($b)->mtime} glob '"C:\Program Files\Apache Software Foundation\Tomcat 8.5_Tomcat8_BMC_SmartIT\logs\localhost.*.log"';
my $latest_file = $files[-1];

@searches = ();

push(@searches, {
    tag => basename("$latest_file"),
    logfile => "$latest_file",
    criticalpatterns => ['java.net.SocketException: Connection reset by peer']
});

# Need to end with this
1;
deek
Posts: 194
Joined: Fri Apr 26, 2019 2:01 am

Re: check_logfiles plugin

Post by deek »

nsclient++ is running as Local system .

I created D:\testing and tries , but im getting same output .

[nagios@abcd ~]$ /usr/local/nagios/libexec/check_nrpe -H 172.**.***.** -u -t 100 -c check_logfile_Tomcat8_BMC
CRITICAL - (1 errors, 1 unknown in Tomcat8_BMC.protocol-2021-08-11-05-28-18) - cannot write status file D:\testing/Tomcat8_BMC...\! check your filesystem (permissions/usage/integrity) and disk devices |'.\_lines'=0 '.\_warnings'=0 '.\_criticals'=1 '.\_unknowns'=1


Tomcat8_BMC.protocol-2021-08-11-05-28-18 file :
CRITICAL Errors in .\ (tag .\)
cannot write status file D:\testing/Tomcat8_BMC...\! check your filesystem (permissions/usage/integrity) and disk devices
UNKNOWN Errors in .\ (tag .\)
could not find logfile

Capture_nsclient.PNG
You do not have the required permissions to view the files attached to this post.
ssax
Dreams In Code
Posts: 7682
Joined: Wed Feb 11, 2015 12:54 pm

Re: check_logfiles plugin

Post by ssax »

I'm unable to replicate it.

What Windows version is it running? What NSClient++ version is it running?

Please PM me your nsclient.ini as well.
Locked