From f41d50841de55c6e2a14d9c4df9bcc3d6830d887 Mon Sep 17 00:00:00 2001 From: sasha Date: Wed, 24 Oct 2007 10:39:43 +0000 Subject: - [DEV-48] Support of Ping and Traceroute in Status of Triggers screen git-svn-id: svn://svn.zabbix.com/trunk@4908 97f52cf1-0a1b-0410-bd0e-c28be96e8082 --- frontends/php/include/scripts.inc.php | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'frontends/php/include/scripts.inc.php') diff --git a/frontends/php/include/scripts.inc.php b/frontends/php/include/scripts.inc.php index 8ff9018e..66639a12 100644 --- a/frontends/php/include/scripts.inc.php +++ b/frontends/php/include/scripts.inc.php @@ -39,10 +39,33 @@ function update_script($scriptid,$name,$command,$access){ return $result; } +function script_make_command($scriptid,$hostid) +{ + $host_db = DBfetch(DBselect("select dns,useip,ip from hosts where hostid=$hostid")); + $script_db = DBfetch(DBselect("select command from scripts where scriptid=$scriptid")); + if($host_db && $script_db) + { + $command = $script_db["command"]; + $command = str_replace("{HOST.DNS}", $host_db["dns"],$command); + $command = str_replace("{IPADDRESS}", $host_db["ip"],$command); + $command = ($host_db["useip"]==0)? + str_replace("{HOST.CONN}", $host_db["dns"],$command): + str_replace("{HOST.CONN}", $host_db["ip"],$command); + } + else + { + $command = FALSE; + } + return $command; +} + function execute_script($scriptid,$hostid){ $res = array(); $res["flag"]=1; + $command = script_make_command($scriptid,$hostid); + $nodeid = id2nodeid($hostid); + $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); if(!$socket) { @@ -54,7 +77,7 @@ function execute_script($scriptid,$hostid){ } if($res) { - $send = "Command\255$scriptid\255$hostid\n"; + $send = "Command\255$nodeid\255$command\n"; socket_write($socket,$send); } if($res) -- cgit