You are here

KSH Plugin incorrectly says a file does not exist

3 posts / 0 new
Last post
enyfeo
enyfeo's picture
KSH Plugin incorrectly says a file does not exist

Hi There,

Im new to writing plugins for Opsview and was after some help.

Im not sure if this is an environment thing or some other issue.

I have a check called check_suite. It takes in arguments for a path and a filename.

I can see the variables are being received and when I run the plugin from the command line fully, it works absolutely fine as root and as my own user.

However, when using it in opsview, it will occasionally say that the file does not exist and execute a branch of code in my script that I do not expect it to hit as the file definitely exists. The file has is updated regularly and has been present in the same place since December last year.

I am using KSH. I have tried using the if [ -e $FILE_PATH/$FILE_NAME ]option and -r option to see if the file exists. This comes back false on some occasions.

Doing an ls of the folder and including this in the output sent to opsview shows that the file is there. But doing an ls for the PATH/FILE says it does not. Im not sure why this can happen so randomly.

This script has been running for 2 years under crontab and our own scheduling system. It has never executed through that branch of the code, except when the file really was not present. Or when the network went down as it is from a shared file system using NFS.

 

As a test in my output I have asked the script to do an LS for the exact file, an ls of the folder and then do the if [-e check.

Running manually on CMD line I get the file I expect, the folder listing and the file is there and the if [-e says the file exists.

Using opsview I get no file, the ls of the folder shows the file to be present. But the if [ -e fails and returns False.

 

Any help would be appreciated.

 

 

 

smarsh
smarsh's picture
Re: KSH Plugin incorrectly says a file does not exist

This may sound very basic (and apologies in advance!) but are you running the plugin on the command line as the nagios user? As thats the user that opsview executes the plugin as.

enyfeo
enyfeo's picture
Re: KSH Plugin incorrectly says a file does not exist

Thanks for the reply.

I cannot access the nagios user as whomever installed nagios accounts throughout our network has set that they have no shell.

I have set nrpe to run checks as my user. Mainly as there are restrictions on the log files. So the environment should be the same as runnng it from the Command line.

I have actually now got a different result. Before I was getting 2 variables, path and file. Just because we have multiple logs in one path and sometimes we switch.

Trying it with the full path seems to work fine. So the problem seems to come from a constructed path. But this only affects me at certan times of day.... Which is confusing.

Particularly around 2AM which is odd.