PDA

View Full Version : host definition with '/' and '#S#'


flouba
8th December 2008, 14:49
Hello all,

I have some trouble trying to configure some host checks that use the '/' characters in the check command's args.
I enter a '/' char in the text field of the configuration page, and when I save the host definition and get back editing it, my '/' are replaced by some '#S#'.

I read that this substitution was some trick with Oreon having difficulites to deal with '/' in the database. All the slashes are indeed substituated by #S# in the database tables 'service' and 'host'.

For service, there is no problem, the #S# are well recognized and translated back to '/' (in Centreon interface, and Nagios config files), but for host it seems that this is missing: they still appear #S# both in Centreon interface and in Nagios config file host.cfg...

I'm using Centreon 1.4.2.7.

Is it a bug, or have I missed something ??

Thanks for your help

Florent

flouba
15th December 2008, 13:24
Hello all,

As there is no answer, I go though the code, and find that the problem seems to be a simple typo in genHosts.php.

In version stable version 1.4.2.7, the code in genHosts.php that generate the check_command line in the hosts.cfg file is the following :


$host["command_command_id_arg2"] = str_replace('#BR#', "\\n", $host["command_command_id_arg2"]);
$host["command_command_id_arg2"] = str_replace('#T#', "\\t", $host["command_command_id_arg2"]);
$host["command_command_id_arg2"] = str_replace('#R#', "\\r", $host["command_command_id_arg2"]);
$host["command_command_id_arg2"] = str_replace('#S#', "/", $host["command_command_id_arg2"]);
$host["command_command_id_arg2"] = str_replace('#BS#', "\\", $host["command_command_id_arg2"]);

while($DBRESULT2->fetchInto($command))
$str .= print_line("check_command", $command["command_name"].$host["command_command_id_arg1"]);


This code take care of the remplacement of special characters, but it replace them in command_command_id_arg2 (that is event handler args) instead of command_command_id_arg1. The proper command_command_id_arg1 is then written to the config file, but unmodified.


In last beta version (v2 RC8 ), the code has been modified to use the function removeSpecialChar, but it still works on command_command_id_arg2 :
$host["command_command_id_arg2"] = removeSpecialChar($host["command_command_id_arg2"]);


Changing $host["command_command_id_arg2"] by $host["command_command_id_arg1"] does the trick.


Hope it may help in futur release !

Florent