Page 1 of 1

Nagios plugin unable to open external log file for reading

Posted: Wed Mar 20, 2013 4:38 am
by arpand
Hi i have a plugin written in c that will parse a .log<server log> file and determine the page hit count

_xLogFileName = "loging.log";
_xFile = fopen ( _xLogFileName, "r" );
if ( _xFile != NULL )
{
// process file
}else
{
printf("error\n");
return 3;
}

now i placed the a.out file in /usr/lib/nagios/plugin folder and placed the "loging.log" file in the same folder- for both chmod 777 done. now i can run the plugin from command line but when i integrate the same with nagios then it is giving unknown status and printing the "error" from else part-- can anyone plese help

Re: Nagios plugin unable to open external log file for readi

Posted: Wed Mar 20, 2013 9:18 am
by abrist
Well, looking at your code snippet, I would say that your _xFile is 'NULL', but you probably knew that. Any information in you nagios logs or system messages? Does the initial file exist?

Re: Nagios plugin unable to open external log file for readi

Posted: Thu Mar 21, 2013 12:34 am
by arpand
Ya, The problem is solved now. Actually nagios is searching the "loging.log" file in me / directory. which i identify , when i printf a PWD in the code. So i placed the loging.log file there and it is working fine.

But it will not work when i deploy the same to a server. so searching for the solution to find the relative path of the file

Re: Nagios plugin unable to open external log file for readi

Posted: Thu Mar 21, 2013 9:23 am
by slansing
Hmm, interesting, let us know how this goes!

Re: Nagios plugin unable to open external log file for readi

Posted: Mon Mar 25, 2013 1:47 am
by arpand
Hmnn my plugin is working fine now,

./check_page_hit -f loging.log

loging.log is the file name. And it is parsing the log file and calculate the page hit in the application and it is also generating the perf data :D