diff options
| author | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-24 10:39:43 +0000 |
|---|---|---|
| committer | sasha <sasha@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-24 10:39:43 +0000 |
| commit | f41d50841de55c6e2a14d9c4df9bcc3d6830d887 (patch) | |
| tree | 39fd069054f81339faea67a25f5de33c54a9f801 /frontends/php/include/scripts.inc.php | |
| parent | 196f05691a8b11aca754a36ce64421c34148f733 (diff) | |
| download | zabbix-f41d50841de55c6e2a14d9c4df9bcc3d6830d887.tar.gz zabbix-f41d50841de55c6e2a14d9c4df9bcc3d6830d887.tar.xz zabbix-f41d50841de55c6e2a14d9c4df9bcc3d6830d887.zip | |
- [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
Diffstat (limited to 'frontends/php/include/scripts.inc.php')
| -rw-r--r-- | frontends/php/include/scripts.inc.php | 25 |
1 files changed, 24 insertions, 1 deletions
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) |
