diff options
| author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-11-15 09:02:40 +0000 |
|---|---|---|
| committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-11-15 09:02:40 +0000 |
| commit | 24c2ec574fb95128703b44d469059825842acd51 (patch) | |
| tree | 3b4f617d846044761fcae9125e3af9e3feb48616 /frontends/php/include/scripts.inc.php | |
| parent | a5c40a7099cdbc66ebc78bcb6c47f4f1485bda6e (diff) | |
| download | zabbix-24c2ec574fb95128703b44d469059825842acd51.tar.gz zabbix-24c2ec574fb95128703b44d469059825842acd51.tar.xz zabbix-24c2ec574fb95128703b44d469059825842acd51.zip | |
- [NTT-56] Configuration parameters for connection to ZABBIX server
git-svn-id: svn://svn.zabbix.com/trunk@5047 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include/scripts.inc.php')
| -rw-r--r-- | frontends/php/include/scripts.inc.php | 30 |
1 files changed, 11 insertions, 19 deletions
diff --git a/frontends/php/include/scripts.inc.php b/frontends/php/include/scripts.inc.php index b87749cd..417333eb 100644 --- a/frontends/php/include/scripts.inc.php +++ b/frontends/php/include/scripts.inc.php @@ -66,37 +66,25 @@ function execute_script($scriptid,$hostid){ $command = script_make_command($scriptid,$hostid); $nodeid = id2nodeid($hostid); - $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + $socket = @socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + if(!$socket) { $res["flag"] = 1; } if($res) { - global $ZBX_LOCALNODEID; - $res = false; - if($nodeid == 0) - { - $res = socket_connect($socket, '127.0.0.1', 10051); - } - else - { - $sql = "SELECT ip,port FROM nodes WHERE nodeid=$ZBX_LOCALNODEID"; - $node = DBselect($sql); - if($row = DBfetch($node)) - { - $res = socket_connect($socket, $row['ip'], $row['port']); - } - } + global $ZBX_SERVER, $ZBX_SERVER_PORT; + $res = @socket_connect($socket, $ZBX_SERVER, $ZBX_SERVER_PORT); } if($res) { $send = "Command\255$nodeid\255$command\n"; - socket_write($socket,$send); + @socket_write($socket,$send); } if($res) { - $res = socket_read($socket,65535); + $res = @socket_read($socket,65535); } if($res) { @@ -104,10 +92,14 @@ function execute_script($scriptid,$hostid){ $message["flag"]=$flag; $message["message"]=$msg; } + if($res) + { + @socket_close($socket); + } else { $message["flag"]=-1; - $message["message"] = socket_strerror(socket_last_error()); + $message["message"] = S_CONNECT_TO_SERVER_ERROR.' ['.$ZBX_SERVER.':'.$ZBX_SERVER_PORT.'] ['.socket_strerror(socket_last_error()).']'; } return $message; } |
