MR info + bandwidth analysis in wizards
This commit is contained in:
parent
24ed77b5a1
commit
09b5400023
|
@ -0,0 +1,9 @@
|
|||
START TRANSACTION;
|
||||
|
||||
SET @plugin_name = 'Network bandwidth SNMP';
|
||||
SET @plugin_description = 'Retrieves amount of digital information sent and received from device or filtered  interface index over a particular time (agent/module interval).';
|
||||
SET @plugin_id = '';
|
||||
SELECT @plugin_id := `id` FROM `tplugin` WHERE `name` = @plugin_name;
|
||||
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (@plugin_id,@plugin_name,@plugin_description,300,0,'perl /usr/share/pandora_server/util/plugin/pandora_snmp_bandwidth.pl','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"SNMP Version(1,2c,3)\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Community\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Host\",\"help\":\"\",\"value\":\"_address_\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Port\",\"help\":\"\",\"value\":\"161\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Interface Index (filter)\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"6\":{\"macro\":\"_field6_\",\"desc\":\"securityName\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"7\":{\"macro\":\"_field7_\",\"desc\":\"context\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"8\":{\"macro\":\"_field8_\",\"desc\":\"securityLevel\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"9\":{\"macro\":\"_field9_\",\"desc\":\"authProtocol\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"10\":{\"macro\":\"_field10_\",\"desc\":\"authKey\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"11\":{\"macro\":\"_field11_\",\"desc\":\"privProtocol\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"12\":{\"macro\":\"_field12_\",\"desc\":\"privKey\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','-version '_field1_' -community '_field2_' -host '_field3_' -port '_field4_' -ifIndex '_field5_' -securityName '_field6_' -context '_field7_' -securityLevel '_field8_' -authProtocol '_field9_' -authKey '_field10_' -privProtocol '_field11_' -privKey '_field12_'');
|
||||
|
||||
COMMIT;
|
|
@ -2874,6 +2874,12 @@ SET @plugin_id = '';
|
|||
SELECT @plugin_id := `id` FROM `tplugin` WHERE `name` = @plugin_name;
|
||||
INSERT IGNORE INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (@plugin_id,@plugin_name,@plugin_description,20,0,'/usr/share/pandora_server/util/plugin/wizard_wmi_module',NULL,NULL,NULL,NULL,0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Host\",\"help\":\"\",\"value\":\"_address_\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Namespace (Optional)\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"User\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"WMI Class\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"6\":{\"macro\":\"_field6_\",\"desc\":\"Fields list\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"7\":{\"macro\":\"_field7_\",\"desc\":\"Query filter (Optional)\",\"help\":\"Use single quotes for query conditions\",\"value\":\"\",\"hide\":\"\"},\"8\":{\"macro\":\"_field8_\",\"desc\":\"Operation\",\"help\":\"Aritmetic operation to get data. Macros _fN_ will be changed by fields in list. Example: ((_f1_ - _f2_) * 100) / _f1_\",\"value\":\"\",\"hide\":\"\"}}','-host '_field1_' -namespace '_field2_' -user '_field3_' -pass '_field4_' -wmiClass '_field5_' -fieldsList '_field6_' -queryFilter "_field7_" -operation '_field8_' -wmicPath /usr/bin/wmic');
|
||||
|
||||
SET @plugin_name = 'Network bandwidth SNMP';
|
||||
SET @plugin_description = 'Retrieves amount of digital information sent and received from device or filtered  interface index over a particular time (agent/module interval).';
|
||||
SET @plugin_id = '';
|
||||
SELECT @plugin_id := `id` FROM `tplugin` WHERE `name` = @plugin_name;
|
||||
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (@plugin_id,@plugin_name,@plugin_description,300,0,'perl /usr/share/pandora_server/util/plugin/pandora_snmp_bandwidth.pl','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"SNMP Version(1,2c,3)\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Community\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Host\",\"help\":\"\",\"value\":\"_address_\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Port\",\"help\":\"\",\"value\":\"161\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Interface Index (filter)\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"6\":{\"macro\":\"_field6_\",\"desc\":\"securityName\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"7\":{\"macro\":\"_field7_\",\"desc\":\"context\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"8\":{\"macro\":\"_field8_\",\"desc\":\"securityLevel\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"9\":{\"macro\":\"_field9_\",\"desc\":\"authProtocol\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"10\":{\"macro\":\"_field10_\",\"desc\":\"authKey\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"11\":{\"macro\":\"_field11_\",\"desc\":\"privProtocol\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"12\":{\"macro\":\"_field12_\",\"desc\":\"privKey\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','-version '_field1_' -community '_field2_' -host '_field3_' -port '_field4_' -ifIndex '_field5_' -securityName '_field6_' -context '_field7_' -securityLevel '_field8_' -authProtocol '_field9_' -authKey '_field10_' -privProtocol '_field11_' -privKey '_field12_'');
|
||||
|
||||
SET @main_component_group_name = 'Wizard';
|
||||
SET @component_id = '';
|
||||
SELECT @component_id := `id_sg` FROM `tnetwork_component_group` WHERE `name` = @main_component_group_name;
|
||||
|
|
|
@ -1337,7 +1337,6 @@ class AgentWizard extends HTML
|
|||
$content .= html_print_table($table, true);
|
||||
|
||||
echo $content;
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
@ -1431,6 +1430,15 @@ class AgentWizard extends HTML
|
|||
$result[$value]['description'] = $data['module-default_description-'.$key];
|
||||
} else if (empty(preg_match('/module-value/', $k)) === false) {
|
||||
$result[$value]['value'] = $data['module-value-'.$key];
|
||||
} else if (empty(preg_match('/module-macros/', $k)) === false) {
|
||||
$result[$value]['macros'] = $data['module-macros-'.$key];
|
||||
continue;
|
||||
} else if (empty(preg_match('/module-id_plugin/', $k)) === false) {
|
||||
$result[$value]['id_plugin'] = $data['module-id_plugin-'.$key];
|
||||
continue;
|
||||
} else if (empty(preg_match('/module-id_modulo/', $k)) === false) {
|
||||
$result[$value]['id_modulo'] = $data['module-id_modulo-'.$key];
|
||||
continue;
|
||||
}
|
||||
|
||||
preg_match('/^(.*)-.*?_(\d+-\d+)$/', $k, $matches);
|
||||
|
@ -2062,35 +2070,42 @@ class AgentWizard extends HTML
|
|||
} else {
|
||||
$tmp->ip_target($this->targetIp);
|
||||
$tmp->id_modulo(MODULE_PLUGIN);
|
||||
$fieldsPlugin = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT macros FROM tplugin WHERE id=%d',
|
||||
(int) $infoMacros['server_plugin']
|
||||
)
|
||||
);
|
||||
|
||||
if ($fieldsPlugin !== false) {
|
||||
$fieldsPlugin = json_decode($fieldsPlugin, true);
|
||||
$i = 1;
|
||||
foreach ($infoMacros as $key => $value) {
|
||||
if (empty(preg_match('/_snmp_field/', $key)) === false) {
|
||||
$new_macros = [];
|
||||
foreach ($fieldsPlugin as $k => $v) {
|
||||
if ($v['macro'] === preg_replace('/_snmp_field/', '', $key)) {
|
||||
$fieldsPlugin[$k]['value'] = $this->replacementMacrosPlugin(
|
||||
$value,
|
||||
$infoMacros['macros']
|
||||
);
|
||||
$i++;
|
||||
continue;
|
||||
if (empty($candidate['macros']) === true) {
|
||||
$fieldsPlugin = db_get_value_sql(
|
||||
sprintf(
|
||||
'SELECT macros FROM tplugin WHERE id=%d',
|
||||
(int) $infoMacros['server_plugin']
|
||||
)
|
||||
);
|
||||
|
||||
if ($fieldsPlugin !== false) {
|
||||
$fieldsPlugin = json_decode($fieldsPlugin, true);
|
||||
$i = 1;
|
||||
foreach ($infoMacros as $key => $value) {
|
||||
if (empty(preg_match('/_snmp_field/', $key)) === false) {
|
||||
$new_macros = [];
|
||||
foreach ($fieldsPlugin as $k => $v) {
|
||||
if ($v['macro'] === preg_replace('/_snmp_field/', '', $key)) {
|
||||
$fieldsPlugin[$k]['value'] = $this->replacementMacrosPlugin(
|
||||
$value,
|
||||
$infoMacros['macros']
|
||||
);
|
||||
$i++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$tmp->id_plugin($infoMacros['server_plugin']);
|
||||
$tmp->macros(json_encode($fieldsPlugin));
|
||||
$tmp->id_plugin($infoMacros['server_plugin']);
|
||||
$tmp->macros(json_encode($fieldsPlugin));
|
||||
} else {
|
||||
// Use definition provided.
|
||||
$tmp->id_plugin($candidate['id_plugin']);
|
||||
$tmp->macros(base64_decode($candidate['macros']));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if ($this->protocol === 'wmi') {
|
||||
|
@ -2403,7 +2418,18 @@ class AgentWizard extends HTML
|
|||
}
|
||||
|
||||
// Get current value.
|
||||
$currentValue = $this->snmpGetValue($moduleData['value']);
|
||||
if (in_array(
|
||||
$moduleData['module_type'],
|
||||
[
|
||||
MODULE_TYPE_REMOTE_SNMP,
|
||||
MODULE_TYPE_REMOTE_SNMP_INC,
|
||||
MODULE_TYPE_REMOTE_SNMP_STRING,
|
||||
MODULE_TYPE_REMOTE_SNMP_PROC,
|
||||
]
|
||||
) === true
|
||||
) {
|
||||
$currentValue = $this->snmpGetValue($moduleData['value']);
|
||||
}
|
||||
|
||||
// It unit of measure have data, attach to current value.
|
||||
if (empty($moduleData['module_unit']) === false) {
|
||||
|
@ -2413,6 +2439,7 @@ class AgentWizard extends HTML
|
|||
// Stablish the data for show.
|
||||
$generalInterfaceModulesUpdated[] = [
|
||||
'component_id' => $component_id_number++,
|
||||
'execution_type' => $moduleData['execution_type'],
|
||||
'name' => $moduleData['module_name'],
|
||||
'type' => $moduleData['module_type'],
|
||||
'description' => $moduleData['module_info'],
|
||||
|
@ -2425,6 +2452,9 @@ class AgentWizard extends HTML
|
|||
'module_enabled' => $moduleData['default_enabled'],
|
||||
'name_oid' => $moduleData['value'],
|
||||
'value' => $moduleData['value'],
|
||||
'id_plugin' => $moduleData['id_plugin'],
|
||||
'macros' => $moduleData['macros'],
|
||||
'id_modulo' => $moduleData['id_modulo'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -2556,7 +2586,20 @@ class AgentWizard extends HTML
|
|||
}
|
||||
|
||||
// Get current value.
|
||||
$currentValue = $this->snmpGetValue($moduleData['value']);
|
||||
$currentValue = '';
|
||||
|
||||
if (in_array(
|
||||
$moduleData['module_type'],
|
||||
[
|
||||
MODULE_TYPE_REMOTE_SNMP,
|
||||
MODULE_TYPE_REMOTE_SNMP_INC,
|
||||
MODULE_TYPE_REMOTE_SNMP_STRING,
|
||||
MODULE_TYPE_REMOTE_SNMP_PROC,
|
||||
]
|
||||
) === true
|
||||
) {
|
||||
$currentValue = $this->snmpGetValue($moduleData['value']);
|
||||
}
|
||||
|
||||
// Format current value with thousands and decimals.
|
||||
if (is_numeric($currentValue) === true) {
|
||||
|
@ -2572,6 +2615,7 @@ class AgentWizard extends HTML
|
|||
// Stablish the data for show.
|
||||
$interfaceModulesUpdated[] = [
|
||||
'component_id' => $component_id_number++,
|
||||
'execution_type' => $moduleData['execution_type'],
|
||||
'name' => $moduleData['module_name'],
|
||||
'type' => $moduleData['module_type'],
|
||||
'description' => $moduleData['module_description'],
|
||||
|
@ -2585,6 +2629,9 @@ class AgentWizard extends HTML
|
|||
'current_value' => $currentValue,
|
||||
'name_oid' => $moduleData['value'],
|
||||
'value' => $moduleData['value'],
|
||||
'id_plugin' => $moduleData['id_plugin'],
|
||||
'macros' => $moduleData['macros'],
|
||||
'id_modulo' => $moduleData['id_modulo'],
|
||||
];
|
||||
}
|
||||
|
||||
|
@ -4189,14 +4236,49 @@ class AgentWizard extends HTML
|
|||
'form="form-create-modules"'
|
||||
);
|
||||
|
||||
// Macro module.
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'module-macros-'.$uniqueId,
|
||||
base64_encode($module['macros']),
|
||||
true,
|
||||
$md5IdBlock,
|
||||
'form="form-create-modules"'
|
||||
);
|
||||
if (empty($module['macros']) === false) {
|
||||
// Macro module.
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'module-macros-'.$uniqueId,
|
||||
base64_encode($module['macros']),
|
||||
true,
|
||||
$md5IdBlock,
|
||||
'form="form-create-modules"'
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($module['execution_type']) === false) {
|
||||
// Id plugin.
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'module-execution_type-'.$uniqueId,
|
||||
$module['execution_type'],
|
||||
true,
|
||||
$md5IdBlock,
|
||||
'form="form-create-modules"'
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($module['id_modulo']) === false) {
|
||||
// Id module.
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'module-id_modulo-'.$uniqueId,
|
||||
$module['id_modulo'],
|
||||
true,
|
||||
$md5IdBlock,
|
||||
'form="form-create-modules"'
|
||||
);
|
||||
}
|
||||
|
||||
if (empty($module['id_plugin']) === false) {
|
||||
// Id plugin.
|
||||
$data[6] .= html_print_input_hidden(
|
||||
'module-id_plugin-'.$uniqueId,
|
||||
$module['id_plugin'],
|
||||
true,
|
||||
$md5IdBlock,
|
||||
'form="form-create-modules"'
|
||||
);
|
||||
}
|
||||
|
||||
// Macro module.
|
||||
$data[6] .= html_print_input_hidden(
|
||||
|
@ -4551,6 +4633,85 @@ class AgentWizard extends HTML
|
|||
];
|
||||
}
|
||||
|
||||
// Bandwidth plugin.
|
||||
static $plugin;
|
||||
if ($plugin === null) {
|
||||
$plugin = \db_get_row_filter(
|
||||
'tplugin',
|
||||
[ 'name' => 'Network bandwidth SNMP' ]
|
||||
);
|
||||
}
|
||||
|
||||
if ($plugin !== false) {
|
||||
// Network Bandwidth is installed.
|
||||
$plugin_id = $plugin['id'];
|
||||
$macros = json_decode($plugin['macros'], 1);
|
||||
if (json_last_error() === JSON_ERROR_NONE) {
|
||||
// SNMP Version.
|
||||
$macros[1]['value'] = $this->version;
|
||||
|
||||
// Community.
|
||||
$macros[2]['value'] = $this->community;
|
||||
|
||||
// Host.
|
||||
$macros[3]['value'] = $this->targetIp;
|
||||
|
||||
// Port.
|
||||
$macros[4]['value'] = $this->targetPort;
|
||||
|
||||
// Interface index filter.
|
||||
$macros[5]['value'] = $value;
|
||||
|
||||
// SecurityName.
|
||||
$macros[6]['value'] = $this->authUserV3;
|
||||
|
||||
// SecurityContext.
|
||||
$macros[7]['value'] = $this->community;
|
||||
|
||||
// SecurityLevel.
|
||||
$macros[8]['value'] = $this->securityLevelV3;
|
||||
|
||||
// AuthProtocol.
|
||||
$macros[9]['value'] = $this->authMethodV3;
|
||||
|
||||
// AuthKey.
|
||||
$macros[10]['value'] = $this->authPassV3;
|
||||
|
||||
// PrivProtocol.
|
||||
$macros[11]['value'] = $this->privacyMethodV3;
|
||||
|
||||
// PrivKey.
|
||||
$macros[11]['value'] = $this->privacyPassV3;
|
||||
|
||||
$moduleName = $name.'Bandwidth';
|
||||
$definition['Bandwidth'] = [
|
||||
'module_name' => $moduleName,
|
||||
'module_type' => MODULE_TYPE_NUMERIC,
|
||||
'module_description' => sprintf(
|
||||
'(%s%s)',
|
||||
$moduleDescription,
|
||||
$moduleName
|
||||
),
|
||||
'module_info' => 'Amount of digital information sent and received from this inteerface over a particular time (see interval).',
|
||||
'execution_type' => EXECUTION_TYPE_PLUGIN,
|
||||
'id_plugin' => $plugin_id,
|
||||
'id_modulo' => MODULE_PLUGIN,
|
||||
'macros' => json_encode($macros),
|
||||
'default_enabled' => true,
|
||||
'module_enabled' => false,
|
||||
'module_unit' => '%',
|
||||
'module_thresholds' => [
|
||||
'min_warning' => '0',
|
||||
'max_warning' => '0',
|
||||
'inv_warning' => false,
|
||||
'min_critical' => '85',
|
||||
'max_critical' => '0',
|
||||
'inv_critical' => false,
|
||||
],
|
||||
];
|
||||
}
|
||||
}
|
||||
|
||||
// Continue with common x86 and x84 modules.
|
||||
// IfAdminStatus.
|
||||
$moduleName = $name.'ifAdminStatus';
|
||||
|
|
|
@ -1739,6 +1739,12 @@ SET @plugin_id = '';
|
|||
SELECT @plugin_id := `id` FROM `tplugin` WHERE `name` = @plugin_name;
|
||||
INSERT IGNORE INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (@plugin_id,@plugin_name,@plugin_description,20,0,'/usr/share/pandora_server/util/plugin/wizard_wmi_module',NULL,NULL,NULL,NULL,0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Host\",\"help\":\"\",\"value\":\"_address_\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Namespace (Optional)\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"User\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Password\",\"help\":\"\",\"value\":\"\",\"hide\":\"1\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"WMI Class\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"6\":{\"macro\":\"_field6_\",\"desc\":\"Fields list\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"7\":{\"macro\":\"_field7_\",\"desc\":\"Query filter (Optional)\",\"help\":\"Use single quotes for query conditions\",\"value\":\"\",\"hide\":\"\"},\"8\":{\"macro\":\"_field8_\",\"desc\":\"Operation\",\"help\":\"Aritmetic operation to get data. Macros _fN_ will be changed by fields in list. Example: ((_f1_ - _f2_) * 100) / _f1_\",\"value\":\"\",\"hide\":\"\"}}','-host '_field1_' -namespace '_field2_' -user '_field3_' -pass '_field4_' -wmiClass '_field5_' -fieldsList '_field6_' -queryFilter "_field7_" -operation '_field8_' -wmicPath /usr/bin/wmic');
|
||||
|
||||
SET @plugin_name = 'Network bandwidth SNMP';
|
||||
SET @plugin_description = 'Retrieves amount of digital information sent and received from device or filtered  interface index over a particular time (agent/module interval).';
|
||||
SET @plugin_id = '';
|
||||
SELECT @plugin_id := `id` FROM `tplugin` WHERE `name` = @plugin_name;
|
||||
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (@plugin_id,@plugin_name,@plugin_description,300,0,'perl /usr/share/pandora_server/util/plugin/pandora_snmp_bandwidth.pl','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"SNMP Version(1,2c,3)\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Community\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"3\":{\"macro\":\"_field3_\",\"desc\":\"Host\",\"help\":\"\",\"value\":\"_address_\",\"hide\":\"\"},\"4\":{\"macro\":\"_field4_\",\"desc\":\"Port\",\"help\":\"\",\"value\":\"161\",\"hide\":\"\"},\"5\":{\"macro\":\"_field5_\",\"desc\":\"Interface Index (filter)\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"6\":{\"macro\":\"_field6_\",\"desc\":\"securityName\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"7\":{\"macro\":\"_field7_\",\"desc\":\"context\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"8\":{\"macro\":\"_field8_\",\"desc\":\"securityLevel\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"9\":{\"macro\":\"_field9_\",\"desc\":\"authProtocol\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"10\":{\"macro\":\"_field10_\",\"desc\":\"authKey\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"11\":{\"macro\":\"_field11_\",\"desc\":\"privProtocol\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"},\"12\":{\"macro\":\"_field12_\",\"desc\":\"privKey\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','-version '_field1_' -community '_field2_' -host '_field3_' -port '_field4_' -ifIndex '_field5_' -securityName '_field6_' -context '_field7_' -securityLevel '_field8_' -authProtocol '_field9_' -authKey '_field10_' -privProtocol '_field11_' -privKey '_field12_'');
|
||||
|
||||
SET @main_component_group_name = 'Wizard';
|
||||
SET @component_id = '';
|
||||
SELECT @component_id := `id_sg` FROM `tnetwork_component_group` WHERE `name` = @main_component_group_name;
|
||||
|
|
|
@ -38,9 +38,6 @@ Pandora FMS Server plugin for bandwidth monitoring $VERSION
|
|||
|
||||
Where OPTIONS could be:
|
||||
|
||||
[OIDS]
|
||||
-use_x64 Use x64 counters (1) or not (0).
|
||||
|
||||
[SNMP]
|
||||
-community community
|
||||
-version SNMP version (1,2c,3)
|
||||
|
@ -179,7 +176,11 @@ sub prepare_tree {
|
|||
|
||||
my $inOctets = snmp_get(\%inOctets_call);
|
||||
if (ref($inOctets) eq "HASH") {
|
||||
$inOctets = $inOctets->{'data'};
|
||||
if ($inOctets->{'data'} eq '') {
|
||||
$inOctets = 0;
|
||||
} else {
|
||||
$inOctets = int $inOctets->{'data'};
|
||||
}
|
||||
} else {
|
||||
# Ignore, cannot retrieve inOctets.
|
||||
next;
|
||||
|
@ -196,7 +197,11 @@ sub prepare_tree {
|
|||
|
||||
my $outOctets = snmp_get(\%outOctets_call);
|
||||
if (ref($outOctets) eq "HASH") {
|
||||
$outOctets = $outOctets->{'data'};
|
||||
if ($outOctets->{'data'} eq '') {
|
||||
$outOctets = 0;
|
||||
} else {
|
||||
$outOctets = int $outOctets->{'data'};
|
||||
}
|
||||
} else {
|
||||
# Ignore, cannot retrieve inOctets.
|
||||
next;
|
||||
|
@ -213,7 +218,12 @@ sub prepare_tree {
|
|||
|
||||
my $duplex = snmp_get(\%duplex_call);
|
||||
if (ref($duplex) eq "HASH") {
|
||||
$duplex = $duplex->{'data'};
|
||||
if ($duplex->{'data'} eq '') {
|
||||
$duplex = 0;
|
||||
} else {
|
||||
$duplex = int $duplex->{'data'};
|
||||
}
|
||||
|
||||
} else {
|
||||
# Ignore, cannot retrieve inOctets.
|
||||
next;
|
||||
|
@ -230,21 +240,24 @@ sub prepare_tree {
|
|||
|
||||
my $speed = snmp_get(\%speed);
|
||||
if (ref($speed) eq "HASH") {
|
||||
$speed = $speed->{'data'};
|
||||
$speed = int $speed->{'data'};
|
||||
} else {
|
||||
# Ignore, cannot retrieve inOctets.
|
||||
next;
|
||||
}
|
||||
|
||||
$tree->{$value} = {
|
||||
'duplex' => int $duplex,
|
||||
'speed' => int $speed,
|
||||
'now' => {
|
||||
'timestamp' => time(),
|
||||
'inOctets' => int $inOctets,
|
||||
'outOctets' => int $outOctets,
|
||||
},
|
||||
}
|
||||
{
|
||||
no warnings "uninitialized";
|
||||
$tree->{$value} = {
|
||||
'duplex' => int $duplex,
|
||||
'speed' => int $speed,
|
||||
'now' => {
|
||||
'timestamp' => time(),
|
||||
'inOctets' => int $inOctets,
|
||||
'outOctets' => int $outOctets,
|
||||
},
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
load_data($config, $tree);
|
||||
|
@ -380,6 +393,7 @@ sub get_bandwidth {
|
|||
$bandwidth = ($input_bandwidth + $output_bandwidth) / 2;
|
||||
}
|
||||
else {
|
||||
no warnings "uninitialized";
|
||||
logger($config, 'info', "Failed to calculate bandwidth, unknown duplex mode: [" . $tree->{$iface}{'duplex_mode'} . "]");
|
||||
}
|
||||
}
|
||||
|
@ -409,7 +423,6 @@ if ($#ARGV < 0) {
|
|||
my $_config = {
|
||||
'oid_base' => ".1.3.6.1.2.1",
|
||||
'as_agent_plugin' => 1,
|
||||
'use_x64' => 0,
|
||||
'x86_indexes' => {
|
||||
'__idx__' => ".2.2.1.1",
|
||||
'duplex' => ".10.7.2.1.19",
|
||||
|
@ -450,6 +463,18 @@ $config->{'port'} = '161' if empty($config->{'port'});
|
|||
$config->{'tmp_separator'} = ';' if empty($config->{'tmp_separator'});
|
||||
$config->{'tmp'} = (($^O =~ /win/)?$ENV{'TMP'}:'/tmp') if empty($config->{'tmp'});
|
||||
|
||||
if(snmp_walk({
|
||||
%{$config},
|
||||
'oid' => '.1.3.6.1.2.1.31.1.1.1.6'
|
||||
})
|
||||
) {
|
||||
# x64 counters available.
|
||||
$config->{'use_x64'} = 1;
|
||||
} else {
|
||||
# x64 counters not available.
|
||||
$config->{'use_x64'} = 1;
|
||||
}
|
||||
|
||||
# Create unique name for tmp and log file for host
|
||||
my $filename = $config->{'tmp'}.'/pandora_bandwith_'.$config->{'host'};
|
||||
|
||||
|
|
Loading…
Reference in New Issue