Nagios plugin unable to open external log file for reading

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.
Locked
arpand
Posts: 3
Joined: Wed Mar 20, 2013 4:30 am
Location: Kolkata , India

Nagios plugin unable to open external log file for reading

Post 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
abrist
Red Shirt
Posts: 8334
Joined: Thu Nov 15, 2012 1:20 pm

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

Post 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?
Former Nagios employee
"It is turtles. All. The. Way. Down. . . .and maybe an elephant or two."
VI VI VI - The editor of the Beast!
Come to the Dark Side.
arpand
Posts: 3
Joined: Wed Mar 20, 2013 4:30 am
Location: Kolkata , India

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

Post 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
slansing
Posts: 7698
Joined: Mon Apr 23, 2012 4:28 pm
Location: Travelling through time and space...

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

Post by slansing »

Hmm, interesting, let us know how this goes!
arpand
Posts: 3
Joined: Wed Mar 20, 2013 4:30 am
Location: Kolkata , India

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

Post 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
Locked