Need help with a dated filename


#1

I have this service setup:
define service{
use generic-service
host_name pflow
service_description PFlow_Log_File
check_command check_nt!FILEAGE!-l “c:\date +%Y%m%-d_dataproc.log” -w 10 -c 11
}

using this command:

‘check_nt’ command definition

define command{
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v $ARG1$ $ARG2$
}

This command seems to run fine on the command line, but through nagios’s web page, it is just returning a value of null.

Can anyone point me in the right direction?


#2

first check that what get’s executed is what you expect.
I suppose in the logs you should be able to find something.


#3

If you mean restarting the service, then yes I have.


#4

no. what i mean is to check if what nagios does is what you expect it to do.
is the executed command line the same as the one you run?


#5

Ok…

So my fix is this for the time being… I just transferred the main functionality to the command and away from the service and it seems to work fine. It looks to me like it was having trouble passing the tick marks… but this is just a guess at this point.

define service{
use generic-service
host_name pflow
service_description PFlow_Log_File
check_command check_pflow_log_file
}

define command{
command_name check_pflow_log_file
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -v FILEAGE -l “c:\date +%Y%m%-d_dataproc.log” -w 10 -c 11
}


#6

it may need escaping somehow (backslash in front?).
That’s the most frequent problem with command lines becoming a bit complicated it can be ven worse when you hav eosmthing like a windows process name containing double backslashes or " signs :slight_smile:
Check also how the parameters are passed. it’s usually better* to use more parameters instead of one parameter containing the whole command :slight_smile:

*better simply for readability and reusability not for performance :slight_smile: