Fixed the snmp wizard for uptime and added unit octets. TICKET: #1742

(cherry picked from commit 584d00f321)
This commit is contained in:
mdtrooper 2015-02-13 15:32:28 +01:00
parent f19f971273
commit ab12b4456a
2 changed files with 32 additions and 20 deletions

View File

@ -75,8 +75,8 @@ $static_snmp_descriptions = array(
'ssRawContexts' => 'Number of context switches',
'ssCpuRawUser' => 'user CPU time',
'ssCpuRawSystem' => 'system CPU time',
'ssCpuRawIdle' => 'idle CPU time'
);
'ssCpuRawIdle' => 'idle CPU time',
'sysUpTime' => 'system Up time');
$static_snmp_oids = array(
'Load-1' => '.1.3.6.1.4.1.2021.10.1.5.1',
@ -98,8 +98,11 @@ $static_snmp_oids = array(
'ssRawContexts' => '.1.3.6.1.4.1.2021.11.60.0',
'ssCpuRawUser' => '.1.3.6.1.4.1.2021.11.50.0',
'ssCpuRawSystem' => '.1.3.6.1.4.1.2021.11.52.0',
'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0'
);
'ssCpuRawIdle' => '.1.3.6.1.4.1.2021.11.53.0',
'sysUpTime' => '1.3.6.1.2.1.1.3.0');
$static_snmp_post_process = array(
'sysUpTime' => "0.00000011574074");
// Using plugin
if (!empty($plugin)) {
@ -450,6 +453,10 @@ if ($create_modules) {
$module_values['descripcion'] = $static_snmp_descriptions[$snmpdata_name];
$module_values['id_tipo_modulo'] = modules_get_type_id('remote_snmp');
if (isset($static_snmp_post_process[$snmpdata_name])) {
$module_values['post_process'] =
$static_snmp_post_process[$snmpdata_name];
}
//Average use of CPUs is a plugin module
switch ($snmpdata_name) {
@ -460,7 +467,7 @@ if ($create_modules) {
$macros = json_decode($plugin['macros'], true);
foreach($macros as $k => $macro) {
foreach ($macros as $k => $macro) {
switch($macro['macro']) {
case '_field1_':
// Field 1 is the IP Address
@ -656,7 +663,8 @@ if ($create_modules) {
unset($module_values['ip_target']); //ip_target
unset($module_values['tcp_send']); //snmp_version
$result = modules_create_agent_module($id_agent, io_safe_input($disk), $module_values);
$result = modules_create_agent_module($id_agent,
io_safe_input($disk), $module_values);
$results[$result][] = $disk;
}

View File

@ -157,51 +157,55 @@ if ($create_modules) {
$ifPhysAddress = $interfaces[$id]['ifPhysAddress']['value'];
}
foreach ($modules as $module) {
$oid_array = explode('.',$module);
$oid_array[count($oid_array)-1] = $id;
$oid = implode('.',$oid_array);
$oid_array = explode('.', $module);
$oid_array[count($oid_array) - 1] = $id;
$oid = implode('.', $oid_array);
// Get the name
$name_array = explode('::',$oid_array[0]);
$name_array = explode('::', $oid_array[0]);
$name = $name_array[1] . "_" . $ifname;
// Clean the name
$name = str_replace ( "\"" , "" , $name);
// Proc moduletypes
if (preg_match ( "/Status/", $name_array[1]))
if (preg_match ("/Status/", $name_array[1]))
$module_type = 18;
elseif (preg_match ( "/Present/", $name_array[1]))
elseif (preg_match ("/Present/", $name_array[1]))
$module_type = 18;
elseif (preg_match ( "/PromiscuousMode/", $name_array[1]))
elseif (preg_match("/PromiscuousMode/", $name_array[1]))
$module_type = 18;
// String moduletypes
elseif (preg_match ( "/Alias/", $name_array[1]))
elseif (preg_match("/Alias/", $name_array[1]))
$module_type = 17;
elseif (preg_match ( "/Address/", $name_array[1]))
elseif (preg_match("/Address/", $name_array[1]))
$module_type = 17;
elseif (preg_match ( "/Name/", $name_array[1]))
elseif (preg_match("/Name/", $name_array[1]))
$module_type = 17;
elseif (preg_match ( "/Specific/", $name_array[1]))
elseif (preg_match("/Specific/", $name_array[1]))
$module_type = 17;
elseif (preg_match ( "/Descr/", $name_array[1]))
elseif (preg_match("/Descr/", $name_array[1]))
$module_type = 17;
// Specific counters (ends in s)
elseif (preg_match ( "/s$/", $name_array[1]))
elseif (preg_match("/s$/", $name_array[1]))
$module_type = 16;
// Otherwise, numeric
else
$module_type = 15;
if (preg_match("/Octets/", $name_array[1])) {
$values['unit'] = "Bytes";
}
$values['id_tipo_modulo'] = $module_type;
if (!empty($ifPhysAddress))