Index: includes/definitions/mibs/rittal.inc.php =================================================================== --- includes/definitions/mibs/rittal.inc.php (revision 10975) +++ includes/definitions/mibs/rittal.inc.php (working copy) @@ -31,10 +31,13 @@ 'oid_15min' => 'cmcIIIUnitLoadAverage.10', 'oid_15min_num' => '.1.3.6.1.4.1.2606.7.2.14.1.2.10', ); -$config['mibs'][$mib]['status'][] = array('oid' => 'cmcIIIUnitStatus', 'descr' => 'Unit Status', 'measured' => 'device', 'type' => 'cmcIIIUnitStatus', 'oid_num' => '.1.3.6.1.4.1.2606.7.2.1'); -$config['mibs'][$mib]['status'][] = array('oid' => 'cmcIIIUnitCurrentSource', 'descr' => 'Power Source', 'measured' => 'device', 'type' => 'cmcIIIUnitCurrentSource', 'oid_num' => '.1.3.6.1.4.1.2606.7.2.9'); -$config['mibs'][$mib]['status'][] = array('oid' => 'cmcIIIUnitMode', 'descr' => 'Unit Mode', 'measured' => 'device', 'type' => 'cmcIIIUnitMode', 'oid_num' => '.1.3.6.1.4.1.2606.7.2.13'); +$config['mibs'][$mib]['status'][] = array('oid' => 'cmcIIIUnitStatus', 'descr' => 'Unit Status', 'measured' => 'device', 'type' => 'cmcIIIUnitStatus', 'oid_num' => '.1.3.6.1.4.1.2606.7.2.1'); +$config['mibs'][$mib]['status'][] = array('oid' => 'cmcIIIUnitCurrentSource', 'descr' => 'Power Source', 'measured' => 'device', 'type' => 'cmcIIIUnitCurrentSource', 'oid_num' => '.1.3.6.1.4.1.2606.7.2.9'); +$config['mibs'][$mib]['status'][] = array('oid' => 'cmcIIIUnitMode', 'descr' => 'Unit Mode', 'measured' => 'device', 'type' => 'cmcIIIUnitMode', 'oid_num' => '.1.3.6.1.4.1.2606.7.2.13'); +$config['mibs'][$mib]['status'][] = array('oid' => 'cmcIIISetBeeper', 'descr' => 'Beeper', 'measured' => 'device', 'type' => 'cmcIIISetBeeper', 'oid_num' => '.1.3.6.1.4.1.2606.7.3.2.2'); +$config['mibs'][$mib]['status'][] = array('oid' => 'cmcIIIModbusStatus', 'descr' => 'Modbus Status', 'measured' => 'device', 'type' => 'cmcIIIModbusStatus', 'oid_num' => '.1.3.6.1.4.1.2606.7.3.11.1'); + $type = 'cmcIIIUnitStatus'; $config['mibs'][$mib]['states'][$type][1] = array('name' => 'ok', 'event' => 'ok'); $config['mibs'][$mib]['states'][$type][2] = array('name' => 'failed', 'event' => 'alert'); @@ -93,6 +96,26 @@ $config['mibs'][$mib]['states'][$type][30] = array('name' => 'readOnly', 'event' => 'ok'); $config['mibs'][$mib]['states'][$type][31] = array('name' => 'exchanged', 'event' => 'ok'); +$type = 'cmcIIISetBeeper'; +$config['mibs'][$mib]['states'][$type][1] = array('name' => 'off', 'event' => 'ignore'); +$config['mibs'][$mib]['states'][$type][2] = array('name' => 'on', 'event' => 'ignore'); + +$type = 'cmcIIIModbusStatus'; +$config['mibs'][$mib]['states'][$type][1] = array('name' => 'shutdown', 'event' => 'ignore'); +$config['mibs'][$mib]['states'][$type][2] = array('name' => 'readonly', 'event' => 'ok'); +$config['mibs'][$mib]['states'][$type][3] = array('name' => 'writeonly', 'event' => 'ok'); +$config['mibs'][$mib]['states'][$type][4] = array('name' => 'readwrite', 'event' => 'ok'); + +$type = 'cmcIIIDevStatus'; +$config['mibs'][$mib]['states'][$type][1] = array('name' => 'notAvail', 'event' => 'exclude'); +$config['mibs'][$mib]['states'][$type][2] = array('name' => 'ok', 'event' => 'ok'); +$config['mibs'][$mib]['states'][$type][3] = array('name' => 'deviceDetectedConfirm', 'event' => 'warning'); +$config['mibs'][$mib]['states'][$type][4] = array('name' => 'deviceLost', 'event' => 'alert'); +$config['mibs'][$mib]['states'][$type][5] = array('name' => 'deviceChanged', 'event' => 'warning'); +$config['mibs'][$mib]['states'][$type][6] = array('name' => 'deviceError', 'event' => 'alert'); +$config['mibs'][$mib]['states'][$type][7] = array('name' => 'firmwareUpdatePending', 'event' => 'warning'); +$config['mibs'][$mib]['states'][$type][8] = array('name' => 'firmwareUpdateRunning', 'event' => 'ok'); + $mib = 'RITTAL-CMC-TC-MIB'; $config['mibs'][$mib]['enable'] = 1; $config['mibs'][$mib]['identity_num'] = '.1.3.6.1.4.1.2606.4'; Index: includes/discovery/sensors/rittal-cmc-iii-mib.inc.php =================================================================== --- includes/discovery/sensors/rittal-cmc-iii-mib.inc.php (revision 10975) +++ includes/discovery/sensors/rittal-cmc-iii-mib.inc.php (working copy) @@ -43,186 +43,213 @@ //RITTAL-CMC-III-MIB::cmcIIIVarName.1.26 = STRING: Input 2.Delay //RITTAL-CMC-III-MIB::cmcIIIVarName.1.27 = STRING: Input 2.Status //RITTAL-CMC-III-MIB::cmcIIIVarName.1.28 = STRING: Input 2.Category +// + +$cmcIIIdevices = snmpwalk_cache_oid($device, "cmcIIIDevTable", array(), $mib); +//print_debug_vars($cmcIIIdevices); + +foreach ($cmcIIIdevices as $index => $entry) +{ + $descr = $entry['cmcIIIDevAlias'] . ' (' . $entry['cmcIIIDevName'] . ') Status'; + + $oid_name = 'cmcIIIDevStatus'; + $type = 'cmcIIIDevStatus'; + $value = $entry['cmcIIIDevStatus']; + $oid_num = '.1.3.6.1.4.1.2606.7.4.1.2.1.6.'.$index; + + discover_status($device, $oid_num, "$oid_name.$index", 'cmcIIIDevStatus', $descr, $value, array('entPhysicalClass' => 'device')); +} + + $oids = snmpwalk_cache_oid($device, "cmcIIIVarTable", array(), $mib); //print_debug_vars($oids); // Rearrage this dumb array as more logic -$sensors = array(); +$device_sensors = array(); foreach ($oids as $index => $entry) { - $name_parts = explode('.', $entry['cmcIIIVarName']); - $param = array_pop($name_parts); - $param = $entry['cmcIIIVarType']; - $name = implode(' ', $name_parts); + $device_index = explode('.', $index)[0]; + $name_parts = explode('.', $entry['cmcIIIVarName']); + $param = array_pop($name_parts); + $param = $entry['cmcIIIVarType']; + $name = implode(' ', $name_parts); - $sensors[$name][$param] = $entry; - $sensors[$name][$param]['index'] = $index; + $device_sensors[$device_index][$name][$param] = $entry; + $device_sensors[$device_index][$name][$param]['index'] = $index; } -print_debug_vars($sensors); +//print_debug_vars($device_sensors);; -foreach ($sensors as $name => $sensor) +foreach($device_sensors as $cmcIIIdevice_index => $sensors) { - $descr = $name; - if (strlen($sensor['description']['cmcIIIVarValueStr'])) + foreach ($sensors as $name => $sensor) { - $tmp = str_replace(array('_', 'Sys '), - array(' ', 'System '), $sensor['description']['cmcIIIVarValueStr']); - if (!str_contains_array($name, $tmp)) - { - $descr .= ' - ' . $sensor['description']['cmcIIIVarValueStr']; - } - } + $descr = $cmcIIIdevices[$cmcIIIdevice_index]['cmcIIIDevAlias'] . ' ' . $name; + + if (strlen($sensor['description']['cmcIIIVarValueStr'])) + { + $tmp = str_replace(array('_', 'Sys '), + array(' ', 'System '), $sensor['description']['cmcIIIVarValueStr']); + if (!str_contains_array($name, $tmp)) + { + $descr .= ' - ' . $sensor['description']['cmcIIIVarValueStr']; + } + } - if (isset($sensor['value'])) - { - $entry = $sensor['value']; + if (isset($sensor['value'])) + { + $entry = $sensor['value']; - switch($entry['cmcIIIVarScale'][0]) - { - case '-': - $scale = 1/(int)substr($entry['cmcIIIVarScale'], 1); - break; - case '+': - $scale = (int)substr($entry['cmcIIIVarScale'], 1); - break; - default: - $scale = 1; - } - $scale_unit = 1; + switch($entry['cmcIIIVarScale'][0]) + { + case '-': + $scale = 1/(int)substr($entry['cmcIIIVarScale'], 1); + break; + case '+': + $scale = (int)substr($entry['cmcIIIVarScale'], 1); + break; + default: + $scale = 1; + } + $scale_unit = 1; - $index = $entry['index']; - $unit = $entry['cmcIIIVarUnit']; - //$type = $entry['cmcIIIVarType']; - //$name = $entry['cmcIIIVarName']; - $value = $entry['cmcIIIVarValueInt']; - $oid_num = '.1.3.6.1.4.1.2606.7.4.2.2.1.11.'.$index; + $index = $entry['index']; + $unit = $entry['cmcIIIVarUnit']; + //$type = $entry['cmcIIIVarType']; + //$name = $entry['cmcIIIVarName']; + $value = $entry['cmcIIIVarValueInt']; + $oid_num = '.1.3.6.1.4.1.2606.7.4.2.2.1.11.'.$index; - $options = array(); - /* - if ($type == 'outputPWM') - { - $t = "power"; - } - else if ($type == 'rotation') - { - $t = "fanspeed"; - } - else - */ - $type = NULL; - if (str_contains_array($unit, 'degree') || str_ends($unit, [ 'C', 'F' ])) - { - $type = "temperature"; - if ($temp_unit === 'fahrenheit') - { - $options['sensor_unit'] = 'F'; - } - } - elseif (str_ends($unit, 'V')) - { - $type = "voltage"; - } - elseif ($unit === "%") - { - if (str_icontains_array($name, 'RPM')) - { - $type = "load"; - } - } - elseif (str_contains_array($unit, 'l/min')) - { - $type = "waterflow"; - $options['sensor_unit'] = 'l/min'; - } - elseif (str_ends($unit, 'W')) - { - $type = "power"; - } - elseif (str_ends($unit, 'A')) - { - $type = "current"; - if ($unit === 'mA') { - $scale_unit = 0.001; - } - } - $scale *= $scale_unit; + $options = array(); + /* + if ($type == 'outputPWM') + { + $t = "power"; + } + else if ($type == 'rotation') + { + $t = "fanspeed"; + } + else + */ + $type = NULL; + if (str_contains_array($unit, 'degree') || str_ends($unit, [ 'C', 'F' ])) + { + $type = "temperature"; + if ($temp_unit === 'fahrenheit') + { + $options['sensor_unit'] = 'F'; + } + } + elseif (str_ends($unit, 'V')) + { + $type = "voltage"; + } + elseif ($unit === "%") + { + if (str_icontains_array($name, 'RPM')) + { + $type = "load"; + } + if ($sensor['description']['cmcIIIVarValueStr'] == 'Humidity') + { + $type = "humidity"; + } + } + elseif (str_contains_array($unit, 'l/min')) + { + $type = "waterflow"; + $options['sensor_unit'] = 'l/min'; + } + elseif (str_ends($unit, 'W') || $unit === 'VA') + { + $type = "power"; + } + elseif (str_ends($unit, 'A')) + { + $type = "current"; + if ($unit === 'mA') { + $scale_unit = 0.001; + } + } + $scale *= $scale_unit; - if ($type) - { - // Limits - foreach (array('limit_high' => 'setHigh', 'limit_high_warn' => 'setWarn', 'limit_low_warn' => 'setWarnLow', 'limit_low' => 'setLow') as $limit => $param) - { - if (isset($sensor[$param]) && is_numeric($sensor[$param]['cmcIIIVarValueInt'])) - { - $entry = $sensor[$param]; + if ($type) + { + // Limits + foreach (array('limit_high' => 'setHigh', 'limit_high_warn' => 'setWarn', 'limit_low_warn' => 'setWarnLow', 'limit_low' => 'setLow') as $limit => $param) + { + if (isset($sensor[$param]) && is_numeric($sensor[$param]['cmcIIIVarValueInt'])) + { + $entry = $sensor[$param]; - switch($entry['cmcIIIVarScale'][0]) - { - case '-': - $scale_limit = 1/(int)substr($entry['cmcIIIVarScale'], 1); - break; - case '+': - $scale_limit = (int)substr($entry['cmcIIIVarScale'], 1); - break; - default: - $scale_limit = 1; - } + switch($entry['cmcIIIVarScale'][0]) + { + case '-': + $scale_limit = 1/(int)substr($entry['cmcIIIVarScale'], 1); + break; + case '+': + $scale_limit = (int)substr($entry['cmcIIIVarScale'], 1); + break; + default: + $scale_limit = 1; + } - $options[$limit] = $entry['cmcIIIVarValueInt'] * $scale_limit * $scale_unit; - } - } + $options[$limit] = $entry['cmcIIIVarValueInt'] * $scale_limit * $scale_unit; + } + } - $options['rename_rrd'] = "Rittal-CMC-III-cmcIIIVarTable.$index"; - $object = 'cmcIIIVarValueInt'; - discover_sensor_ng($device, $type, $mib, $object, $oid_num, $index, NULL, $descr, $scale, $value, $options); - } - } + $options['rename_rrd'] = "Rittal-CMC-III-cmcIIIVarTable.$index"; + $object = 'cmcIIIVarValueInt'; + discover_sensor_ng($device, $type, $mib, $object, $oid_num, $index, NULL, $descr, $scale, $value, $options); + } + } - // Not sure about this sensor, converted from old - if (isset($sensor['rotation'])) - { - $entry = $sensor['rotation']; + // Not sure about this sensor, converted from old + if (isset($sensor['rotation'])) + { + $entry = $sensor['rotation']; - switch($entry['cmcIIIVarScale'][0]) - { - case '-': - $scale = 1/(int)substr($entry['cmcIIIVarScale'], 1); - break; - case '+': - $scale = (int)substr($entry['cmcIIIVarScale'], 1); - break; - default: - $scale = 1; - } + switch($entry['cmcIIIVarScale'][0]) + { + case '-': + $scale = 1/(int)substr($entry['cmcIIIVarScale'], 1); + break; + case '+': + $scale = (int)substr($entry['cmcIIIVarScale'], 1); + break; + default: + $scale = 1; + } - $index = $entry['index']; - $unit = $entry['cmcIIIVarUnit']; - //$type = $entry['cmcIIIVarType']; - //$name = $entry['cmcIIIVarName']; - $value = $entry['cmcIIIVarValueInt']; - $oid_num = '.1.3.6.1.4.1.2606.7.4.2.2.1.11.'.$index; + $index = $entry['index']; + $unit = $entry['cmcIIIVarUnit']; + //$type = $entry['cmcIIIVarType']; + //$name = $entry['cmcIIIVarName']; + $value = $entry['cmcIIIVarValueInt']; + $oid_num = '.1.3.6.1.4.1.2606.7.4.2.2.1.11.'.$index; - $object = 'cmcIIIVarValueInt'; + $object = 'cmcIIIVarValueInt'; - discover_sensor_ng($device,'fanspeed', $mib, $object, $oid_num, $index, NULL, $descr, $scale, $value, ['rename_rrd' => "Rittal-CMC-III-cmcIIIVarTable.$index"]); - } + discover_sensor_ng($device,'fanspeed', $mib, $object, $oid_num, $index, NULL, $descr, $scale, $value, ['rename_rrd' => "Rittal-CMC-III-cmcIIIVarTable.$index"]); + } - if (isset($sensor['status'])) - { - $entry = $sensor['status']; + if (isset($sensor['status'])) + { + $entry = $sensor['status']; - $index = $entry['index']; - $oid_name = 'cmcIIIVarValueInt'; - $datatype = $entry['cmcIIIVarDataType']; - $type = $entry['cmcIIIVarType']; - //$name = $entry['cmcIIIVarName']; - $value = $entry['cmcIIIVarValueInt']; - $oid_num = '.1.3.6.1.4.1.2606.7.4.2.2.1.11.'.$index; + $index = $entry['index']; + $oid_name = 'cmcIIIVarValueInt'; + $datatype = $entry['cmcIIIVarDataType']; + $type = $entry['cmcIIIVarType']; + //$name = $entry['cmcIIIVarName']; + $value = $entry['cmcIIIVarValueInt']; + $oid_num = '.1.3.6.1.4.1.2606.7.4.2.2.1.11.'.$index; - if ($datatype == 'enum') - { - discover_status($device, $oid_num, "$oid_name.$index", 'cmcIIIMsgStatus', $descr, $value, array('entPhysicalClass' => 'other')); - } + if ($datatype == 'enum') + { + discover_status($device, $oid_num, "$oid_name.$index", 'cmcIIIMsgStatus', $descr, $value, array('entPhysicalClass' => 'other')); + } + } } }