diff options
author | alex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-22 19:48:26 +0000 |
---|---|---|
committer | alex <alex@97f52cf1-0a1b-0410-bd0e-c28be96e8082> | 2007-10-22 19:48:26 +0000 |
commit | 92bf3020da3e671315d21b93ca998b6ab3305136 (patch) | |
tree | 7bba589d79c713a5e891f816e334301596374c35 /frontends/php/include | |
parent | 8586918ae51297d8be70ff360a8cac4d58f593eb (diff) | |
download | zabbix-92bf3020da3e671315d21b93ca998b6ab3305136.tar.gz zabbix-92bf3020da3e671315d21b93ca998b6ab3305136.tar.xz zabbix-92bf3020da3e671315d21b93ca998b6ab3305136.zip |
- [DEV-48] improvements for script execution (Alexei)
[svn merge -r4895:4896 svn://svn.zabbix.com/branches/1.4.j]
git-svn-id: svn://svn.zabbix.com/trunk@4897 97f52cf1-0a1b-0410-bd0e-c28be96e8082
Diffstat (limited to 'frontends/php/include')
-rw-r--r-- | frontends/php/include/forms.inc.php | 13 | ||||
-rw-r--r-- | frontends/php/include/scripts.inc.php | 35 |
2 files changed, 47 insertions, 1 deletions
diff --git a/frontends/php/include/forms.inc.php b/frontends/php/include/forms.inc.php index a05f2da4..393991f1 100644 --- a/frontends/php/include/forms.inc.php +++ b/frontends/php/include/forms.inc.php @@ -4862,4 +4862,17 @@ include_once 'include/discovery.inc.php'; $frmCnct->Show(); } + + function insert_command_result_form($scriptid,$hostid) + { + $result = execute_script($scriptid,$hostid); + + $script_info = DBfetch(DBselect("select name from scripts where scriptid=$scriptid")); + + $frmResult = new CFormTable(S_COMMENTS." ".$script_info["name"]); + $frmResult->AddRow(S_COMMENTS,new CTextArea("message",$result["message"],100,25)); + $frmResult->AddItemToBottomRow(new CButtonCancel(null,'close_window();')); + + $frmResult->Show(); + } ?> diff --git a/frontends/php/include/scripts.inc.php b/frontends/php/include/scripts.inc.php index 071b45f9..edbd853e 100644 --- a/frontends/php/include/scripts.inc.php +++ b/frontends/php/include/scripts.inc.php @@ -40,8 +40,41 @@ return $result; } function execute_script($scriptid,$hostid){ + $res = array(); + $res["flag"]=1; + + $socket = socket_create(AF_INET, SOCK_STREAM, SOL_TCP); + if(!$socket) + { + $res["flag"] = 1; + } + if($res) + { + $res = socket_connect($socket, '127.0.0.1', 10051); + } + if($res) + { + $send = "Command\255$scriptid\255$hostid\n"; + socket_write($socket,$send); + } + if($res) + { + $res = socket_read($socket,65535); + } + if($res) + { + list($flag,$msg)=split("\255",$res); + $message["flag"]=$flag; + $message["message"]=$msg; + } + else + { + $message = socket_strerror(socket_last_error()); + } +return $message; } + function get_accessible_scripts_by_hosts($hosts){ global $USER_DETAILS; @@ -77,4 +110,4 @@ function get_accessible_scripts_by_hosts($hosts){ return $scripts_by_host; } -?>
\ No newline at end of file +?> |