Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Description: Allows to run user scripts on a host's proxy
- With this new feature a new option appears on the frontend allowing
- to set up scripts for runing on a host's proxy.
- .
- zabbix (1:2.0.9-1+0.1) UNRELEASED; urgency=low
- .
- * Non-maintainer upload.
- * Adding run in proxy feature
- Author: Spotflux | Juan Pablo Daniel Borgna <jpdborgna@spotflux.com>
- ---
- The information above should follow the Patch Tagging Guidelines, please
- checkout http://dep.debian.net/deps/dep3/ to learn about the format. Here
- are templates for supplementary fields that you might want to add:
- Origin: <vendor|upstream|other>, <url of original patch>
- Bug: <url in upstream bugtracker>
- Bug-Debian: http://bugs.debian.org/<bugnumber>
- Bug-Ubuntu: https://launchpad.net/bugs/<bugnumber>
- Forwarded: <no|not-needed|url proving that it has been forwarded>
- Reviewed-By: <name and email of someone who approved the patch>
- Last-Update: <YYYY-MM-DD>
- Index: zabbix-2.0.9/include/common.h
- ===================================================================
- --- zabbix-2.0.9.orig/include/common.h 2013-10-12 13:51:42.000000000 +0000
- +++ zabbix-2.0.9/include/common.h 2013-10-18 03:31:40.841680400 +0000
- @@ -682,6 +682,7 @@
- #define ZBX_SCRIPT_EXECUTE_ON_AGENT 0
- #define ZBX_SCRIPT_EXECUTE_ON_SERVER 1
- +#define ZBX_SCRIPT_EXECUTE_ON_PROXY 2
- #define POLLER_DELAY 5
- #define DISCOVERER_DELAY 60
- Index: zabbix-2.0.9/frontends/php/scripts.php
- ===================================================================
- --- zabbix-2.0.9.orig/frontends/php/scripts.php 2013-10-12 13:51:53.000000000 +0000
- +++ zabbix-2.0.9/frontends/php/scripts.php 2013-10-18 03:31:40.841680400 +0000
- @@ -32,7 +32,7 @@
- 'scripts' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null),
- 'name' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})'),
- 'type' => array(T_ZBX_INT, O_OPT, null, IN('0,1'), 'isset({save})'),
- - 'execute_on' => array(T_ZBX_INT, O_OPT, null, IN('0,1'), 'isset({save})&&{type}=='.ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT),
- + 'execute_on' => array(T_ZBX_INT, O_OPT, null, IN('0,1,2'), 'isset({save})&&{type}=='.ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT),
- 'command' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'),
- 'commandipmi' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'),
- 'description' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'),
- Index: zabbix-2.0.9/frontends/php/popup.php
- ===================================================================
- --- zabbix-2.0.9.orig/frontends/php/popup.php 2013-10-12 13:51:53.000000000 +0000
- +++ zabbix-2.0.9/frontends/php/popup.php 2013-10-18 03:31:40.841680400 +0000
- @@ -1858,6 +1858,9 @@
- case ZBX_SCRIPT_EXECUTE_ON_SERVER:
- $scriptExecuteOn = _('Server');
- break;
- + case ZBX_SCRIPT_EXECUTE_ON_PROXY:
- + $scriptExecuteOn = _('Proxy');
- + break;
- }
- }
- else {
- Index: zabbix-2.0.9/frontends/php/include/defines.inc.php
- ===================================================================
- --- zabbix-2.0.9.orig/frontends/php/include/defines.inc.php 2013-10-18 03:31:06.917626992 +0000
- +++ zabbix-2.0.9/frontends/php/include/defines.inc.php 2013-10-18 03:31:40.841680400 +0000
- @@ -61,6 +61,7 @@
- define('ZBX_SCRIPT_TYPE_GLOBAL_SCRIPT', 4);
- define('ZBX_SCRIPT_EXECUTE_ON_AGENT', 0);
- +define('ZBX_SCRIPT_EXECUTE_ON_PROXY', 2);
- define('ZBX_SCRIPT_EXECUTE_ON_SERVER', 1);
- define('ZBX_FLAG_DISCOVERY_NORMAL', 0x0); // a normal item
- Index: zabbix-2.0.9/frontends/php/include/views/administration.script.edit.php
- ===================================================================
- --- zabbix-2.0.9.orig/frontends/php/include/views/administration.script.edit.php 2013-10-12 13:51:49.000000000 +0000
- +++ zabbix-2.0.9/frontends/php/include/views/administration.script.edit.php 2013-10-18 03:31:40.841680400 +0000
- @@ -55,6 +55,7 @@
- $typeRB->makeVertical();
- $typeRB->addValue(_('Zabbix agent'), ZBX_SCRIPT_EXECUTE_ON_AGENT);
- $typeRB->addValue(_('Zabbix server'), ZBX_SCRIPT_EXECUTE_ON_SERVER);
- +$typeRB->addValue(_('Zabbix proxy'), ZBX_SCRIPT_EXECUTE_ON_PROXY);
- $scriptTab->addRow(_('Execute on'), new CDiv($typeRB, 'objectgroup inlineblock border_dotted ui-corner-all'), $data['type'] == ZBX_SCRIPT_TYPE_IPMI);
- // command
- Index: zabbix-2.0.9/frontends/php/include/views/administration.script.list.php
- ===================================================================
- --- zabbix-2.0.9.orig/frontends/php/include/views/administration.script.list.php 2013-10-12 13:51:49.000000000 +0000
- +++ zabbix-2.0.9/frontends/php/include/views/administration.script.list.php 2013-10-18 03:31:40.841680400 +0000
- @@ -66,6 +66,9 @@
- case ZBX_SCRIPT_EXECUTE_ON_SERVER:
- $scriptExecuteOn = _('Server');
- break;
- + case ZBX_SCRIPT_EXECUTE_ON_PROXY:
- + $scriptExecuteOn = _('Proxy');
- + break;
- }
- }
- else {
- Index: zabbix-2.0.9/frontends/php/include/views/configuration.action.edit.php
- ===================================================================
- --- zabbix-2.0.9.orig/frontends/php/include/views/configuration.action.edit.php 2013-10-12 13:51:49.000000000 +0000
- +++ zabbix-2.0.9/frontends/php/include/views/configuration.action.edit.php 2013-10-18 03:31:40.841680400 +0000
- @@ -661,6 +661,7 @@
- $executeOnRadioButton->makeVertical();
- $executeOnRadioButton->addValue(SPACE._('Zabbix agent').SPACE, ZBX_SCRIPT_EXECUTE_ON_AGENT);
- $executeOnRadioButton->addValue(SPACE._('Zabbix server').SPACE, ZBX_SCRIPT_EXECUTE_ON_SERVER);
- + $executeOnRadioButton->addValue(SPACE._('Zabbix proxy').SPACE, ZBX_SCRIPT_EXECUTE_ON_PROXY);
- $newOperationsTable->addRow(array(_('Execute on'), new CDiv($executeOnRadioButton, 'objectgroup border_dotted ui-corner-all inlineblock')), 'class_opcommand_execute_on hidden indent_both');
- // ssh
- Index: zabbix-2.0.9/src/zabbix_server/scripts.c
- ===================================================================
- --- zabbix-2.0.9.orig/src/zabbix_server/scripts.c 2013-10-12 13:51:44.000000000 +0000
- +++ zabbix-2.0.9/src/zabbix_server/scripts.c 2013-10-18 03:31:40.841680400 +0000
- @@ -93,6 +93,44 @@
- return ret;
- }
- +static int zbx_execute_script_on_proxy(DC_HOST *host, const char *command, char **result,
- + char *error, size_t max_error_len)
- +{
- + const char *__function_name = "zbx_execute_script_on_proxy";
- + int ret = FAIL;
- + DB_RESULT db_result;
- + DB_ROW db_row;
- + DC_HOST proxy;
- +
- + zabbix_log(LOG_LEVEL_DEBUG, "In %s()", __function_name);
- +
- + /* query the agent running on the proxy host */
- + db_result = DBselect("select hostid from hosts where host = ( select host from hosts where hostid=\
- + ( select proxy_hostid from hosts where hostid = " ZBX_FS_UI64 ")) and status != 5", host->hostid);
- +
- + if (NULL != (db_row = DBfetch(db_result)))
- + {
- + memset(&proxy, 0, sizeof(proxy));
- + ZBX_DBROW2UINT64(proxy.hostid, db_row[0]);
- + }
- + DBfree_result(db_result);
- +
- +
- + if ((0 == proxy.hostid) || (SUCCEED != DCget_host_by_hostid(&proxy, proxy.hostid)))
- + {
- + zbx_snprintf(error, sizeof(error), "Unknown Proxy ID [" ZBX_FS_UI64 "] for Host ID [" ZBX_FS_UI64 "]",
- + proxy.hostid , host -> hostid);
- + goto fail;
- + }
- +
- +
- + ret = zbx_execute_script_on_agent(&proxy,command,result,error,max_error_len);
- +fail:
- + zabbix_log(LOG_LEVEL_DEBUG, "End of %s():%s", __function_name, zbx_result_string(ret));
- +
- + return ret;
- +}
- +
- #ifdef HAVE_OPENIPMI
- static int zbx_execute_ipmi_command(DC_HOST *host, const char *command, char *error, size_t max_error_len)
- {
- @@ -346,6 +384,10 @@
- ret = zbx_execute(script->command, result, error, max_error_len,
- CONFIG_TRAPPER_TIMEOUT);
- break;
- + case ZBX_SCRIPT_EXECUTE_ON_PROXY:
- + ret = zbx_execute_script_on_proxy(host, script->command, result,
- + error, max_error_len);
- + break;
- default:
- zbx_snprintf(error, max_error_len, "Invalid 'Execute on' option [%d]",
- (int)script->execute_on);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement