mirror of
				https://github.com/librenms/librenms.git
				synced 2024-10-07 16:52:45 +00:00 
			
		
		
		
	Updated Os netagent2 3phase support (#9175)
* netagent2 - 3Phase UPS support
* Revert "netagent2 - 3Phase UPS support"
This reverts commit 7900bc5bc0.
* OS netagent feature update - 3 phase support
* OS netagent2 update - 3phase support code cleanup
* OS netagent2 update - 3phase support code cleanup 2
* Netagent2 - Add status unknown to smoke and water states.
* NetAgent2 - changed detection method like murrant suggested.
* netagent2 - XPPC-MIB - 3 phase states support
* Added json test data
			
			
This commit is contained in:
		
				
					committed by
					
						
						Neil Lathwood
					
				
			
			
				
	
			
			
			
						parent
						
							4e5a0fa4d7
						
					
				
				
					commit
					7d5035da25
				
			
							
								
								
									
										44
									
								
								includes/definitions/discovery/netagent2.yaml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								includes/definitions/discovery/netagent2.yaml
									
									
									
									
									
										Normal file
									
								
							@@ -0,0 +1,44 @@
 | 
			
		||||
mib: UPS-MIB:XPPC-MIB
 | 
			
		||||
modules:
 | 
			
		||||
    sensors:
 | 
			
		||||
        state:
 | 
			
		||||
            data:
 | 
			
		||||
                -
 | 
			
		||||
                    oid: upsBaseBatteryStatus
 | 
			
		||||
                    num_oid: .1.3.6.1.4.1.935.1.1.1.2.1.1.
 | 
			
		||||
                    descr: Battery Status
 | 
			
		||||
                    index: 'upsBaseBatteryStatus.{{ $index }}'
 | 
			
		||||
                    state_name: upsBaseBatteryStatus
 | 
			
		||||
                    states:
 | 
			
		||||
                        - { descr: unknown, graph: 0, value: 1, generic: 3 }
 | 
			
		||||
                        - { descr: BatteryNormal, graph: 0, value: 2, generic: 0 }
 | 
			
		||||
                        - { descr: BatteryLow, graph: 0, value: 3, generic: 1 }
 | 
			
		||||
                -
 | 
			
		||||
                    oid: upsSmartBatteryReplaceIndicator
 | 
			
		||||
                    num_oid: .1.3.6.1.4.1.935.1.1.1.2.2.5.
 | 
			
		||||
                    descr: Battery Replace Status
 | 
			
		||||
                    index: 'upsSmartBatteryReplaceIndicator.{{ $index }}'
 | 
			
		||||
                    state_name: upsSmartBatteryReplaceIndicator
 | 
			
		||||
                    states:
 | 
			
		||||
                        - { descr: noBatteryNeedsReplacing, graph: 0, value: 1, generic: 0 }
 | 
			
		||||
                        - { descr: batteryNeedsReplacing, graph: 0, value: 2, generic: 2 }
 | 
			
		||||
                -
 | 
			
		||||
                    oid: upsEnvWater
 | 
			
		||||
                    num_oid: .1.3.6.1.4.1.935.1.1.1.9.1.3.
 | 
			
		||||
                    descr: Water Status
 | 
			
		||||
                    index: 'upsEnvWater.{{ $index }}'
 | 
			
		||||
                    state_name: upsEnvWater
 | 
			
		||||
                    states:
 | 
			
		||||
                        - { descr: unknown, graph: 0, value: 0, generic: 3 }
 | 
			
		||||
                        - { descr: normal, graph: 0, value: 1, generic: 0 }
 | 
			
		||||
                        - { descr: abnormal, graph: 0, value: 2, generic: 2 }
 | 
			
		||||
                -
 | 
			
		||||
                    oid: upsEnvSmoke
 | 
			
		||||
                    num_oid: .1.3.6.1.4.1.935.1.1.1.9.1.4.
 | 
			
		||||
                    descr: Smoke Status
 | 
			
		||||
                    index: 'upsEnvSmoke.{{ $index }}'
 | 
			
		||||
                    state_name: upsEnvSmoke
 | 
			
		||||
                    states:
 | 
			
		||||
                        - { descr: unknown, graph: 0, value: 0, generic: 3 }
 | 
			
		||||
                        - { descr: normal, graph: 0, value: 1, generic: 0 }
 | 
			
		||||
                        - { descr: abnormal, graph: 0, value: 2, generic: 2 }
 | 
			
		||||
@@ -1,9 +1,11 @@
 | 
			
		||||
os: netagent2
 | 
			
		||||
text: 'NET Agent II UPS'
 | 
			
		||||
text: 'MegaTec NetAgent II'
 | 
			
		||||
group: ups
 | 
			
		||||
type: power
 | 
			
		||||
over:
 | 
			
		||||
    - { graph: device_load, text: Load }
 | 
			
		||||
discovery:
 | 
			
		||||
    - sysDescr_regex:
 | 
			
		||||
        - '/^NET Agent II/'
 | 
			
		||||
    - sysObjectID:
 | 
			
		||||
        - .1.3.6.1.4.1.935
 | 
			
		||||
      sysObjectID_except:
 | 
			
		||||
        - .1.3.6.1.4.1.935.10
 | 
			
		||||
 
 | 
			
		||||
@@ -17,12 +17,24 @@
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 *
 | 
			
		||||
 * Original file
 | 
			
		||||
 * @package    LibreNMS
 | 
			
		||||
 * @link       http://librenms.org
 | 
			
		||||
 * @copyright  2016 Tony Murray
 | 
			
		||||
 * @author     Tony Murray <murraytony@gmail.com>
 | 
			
		||||
 * 3 Phase support extension
 | 
			
		||||
 * @copyright  2018 Mikael Sipilainen
 | 
			
		||||
 * @author     Mikael Sipilainen <mikael.sipilainen@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// Detect type of UPS (Signle-Phase/3 Phase)
 | 
			
		||||
    # Number of input lines
 | 
			
		||||
    $upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0';
 | 
			
		||||
    $in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
// Single-phase system
 | 
			
		||||
if ($in_phaseNum == '1') {
 | 
			
		||||
    // Input frequency
 | 
			
		||||
    $in_frequency_oid = '.1.3.6.1.4.1.935.1.1.1.3.2.4.0';
 | 
			
		||||
    $in_frequency = snmp_get($device, $in_frequency_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
@@ -54,7 +66,7 @@ if (!empty($in_frequency) || $in_frequency == 0) {
 | 
			
		||||
            $frequency
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Output Frequency
 | 
			
		||||
    $out_frequency_oid = '.1.3.6.1.4.1.935.1.1.1.4.2.2.0';
 | 
			
		||||
    $out_frequency = snmp_get($device, $frequency_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
@@ -86,3 +98,104 @@ if (!empty($out_frequency) || $out_frequency == 0) {
 | 
			
		||||
            $frequency
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 3 phase system
 | 
			
		||||
if ($in_phaseNum == '3') {
 | 
			
		||||
    // Input frequency
 | 
			
		||||
    $in_frequency_oid = '.1.3.6.1.4.1.935.1.1.1.8.2.1.0';
 | 
			
		||||
    $in_frequency = snmp_get($device, $in_frequency_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($in_frequency) || $in_frequency == 0) {
 | 
			
		||||
        $type             = 'netagent2';
 | 
			
		||||
        $index            = 0;
 | 
			
		||||
        $limit            = 60;
 | 
			
		||||
        $warnlimit        = 51;
 | 
			
		||||
        $lowlimit         = 0;
 | 
			
		||||
        $lowwarnlimit     = 49;
 | 
			
		||||
        $divisor          = 10;
 | 
			
		||||
        $frequency        = $in_frequency / $divisor;
 | 
			
		||||
        $descr            = 'Input frequency';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'frequency',
 | 
			
		||||
            $device,
 | 
			
		||||
            $in_frequency_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $frequency
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Output frequency
 | 
			
		||||
    $in_frequency_oid = '.1.3.6.1.4.1.935.1.1.1.8.3.1.0';
 | 
			
		||||
    $in_frequency = snmp_get($device, $in_frequency_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($in_frequency) || $in_frequency == 0) {
 | 
			
		||||
        $type             = 'netagent2';
 | 
			
		||||
        $index            = 1;
 | 
			
		||||
        $limit            = 60;
 | 
			
		||||
        $warnlimit        = 51;
 | 
			
		||||
        $lowlimit         = 0;
 | 
			
		||||
        $lowwarnlimit     = 49;
 | 
			
		||||
        $divisor          = 10;
 | 
			
		||||
        $frequency        = $in_frequency / $divisor;
 | 
			
		||||
        $descr            = 'Output frequency';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'frequency',
 | 
			
		||||
            $device,
 | 
			
		||||
            $in_frequency_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $frequency
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Bypass frequency
 | 
			
		||||
    $in_frequency_oid = '.1.3.6.1.4.1.935.1.1.1.8.4.1.0';
 | 
			
		||||
    $in_frequency = snmp_get($device, $in_frequency_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($in_frequency) || $in_frequency == 0) {
 | 
			
		||||
        $type             = 'netagent2';
 | 
			
		||||
        $index            = 2;
 | 
			
		||||
        $limit            = 60;
 | 
			
		||||
        $warnlimit        = 51;
 | 
			
		||||
        $lowlimit         = 0;
 | 
			
		||||
        $lowwarnlimit     = 49;
 | 
			
		||||
        $divisor          = 10;
 | 
			
		||||
        $frequency        = $in_frequency / $divisor;
 | 
			
		||||
        $descr            = 'Bypass frequency';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'frequency',
 | 
			
		||||
            $device,
 | 
			
		||||
            $in_frequency_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $frequency
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,8 +21,18 @@
 | 
			
		||||
 * @link       http://librenms.org
 | 
			
		||||
 * @copyright  2016 Tony Murray
 | 
			
		||||
 * @author     Tony Murray <murraytony@gmail.com>
 | 
			
		||||
 * 3 Phase support extension
 | 
			
		||||
 * @copyright  2018 Mikael Sipilainen
 | 
			
		||||
 * @author     Mikael Sipilainen <mikael.sipilainen@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// Detect type of UPS (Signle-Phase/3 Phase)
 | 
			
		||||
    # Number of input lines
 | 
			
		||||
    $upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0';
 | 
			
		||||
    $in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
// Single-phase system
 | 
			
		||||
if ($in_phaseNum == '1') {
 | 
			
		||||
    $load_oid = '.1.3.6.1.4.1.935.1.1.1.4.2.3.0';
 | 
			
		||||
    $output_load = snmp_get($device, $load_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
@@ -54,3 +64,104 @@ if (!empty($output_load) || $output_load == 0) {
 | 
			
		||||
            $load
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// 3 phase system
 | 
			
		||||
if ($in_phaseNum == '3') {
 | 
			
		||||
    // Output L1
 | 
			
		||||
    $load_oid = '.1.3.6.1.4.1.935.1.1.1.8.3.5.0';
 | 
			
		||||
    $output_load = snmp_get($device, $load_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($output_load) || $output_load == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 100;
 | 
			
		||||
        $warnlimit      = 80;
 | 
			
		||||
        $lowlimit       = 0;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 10;
 | 
			
		||||
        $load           = $output_load / $divisor;
 | 
			
		||||
        $descr          = 'Out L1 (R)';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'load',
 | 
			
		||||
            $device,
 | 
			
		||||
            $load_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $load
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Output L2
 | 
			
		||||
    $load_oid = '.1.3.6.1.4.1.935.1.1.1.8.3.6.0';
 | 
			
		||||
    $output_load = snmp_get($device, $load_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($output_load) || $output_load == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index          = 1;
 | 
			
		||||
        $limit          = 100;
 | 
			
		||||
        $warnlimit      = 80;
 | 
			
		||||
        $lowlimit       = 0;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 10;
 | 
			
		||||
        $load           = $output_load / $divisor;
 | 
			
		||||
        $descr          = 'Out L2 (S)';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'load',
 | 
			
		||||
            $device,
 | 
			
		||||
            $load_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $load
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // L3 output
 | 
			
		||||
    $load_oid = '.1.3.6.1.4.1.935.1.1.1.8.3.7.0';
 | 
			
		||||
    $output_load = snmp_get($device, $load_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($output_load) || $output_load == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index          = 2;
 | 
			
		||||
        $limit          = 100;
 | 
			
		||||
        $warnlimit      = 80;
 | 
			
		||||
        $lowlimit       = 0;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 10;
 | 
			
		||||
        $load           = $output_load / $divisor;
 | 
			
		||||
        $descr          = 'Out L3 (T)';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'load',
 | 
			
		||||
            $device,
 | 
			
		||||
            $load_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $load
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -21,6 +21,9 @@
 | 
			
		||||
 * @link       http://librenms.org
 | 
			
		||||
 * @copyright  2016 Tony Murray
 | 
			
		||||
 * @author     Tony Murray <murraytony@gmail.com>
 | 
			
		||||
 * 3 Phase support extension
 | 
			
		||||
 * @copyright  2018 Mikael Sipilainen
 | 
			
		||||
 * @author     Mikael Sipilainen <mikael.sipilainen@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
$ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.4.1.1.0';
 | 
			
		||||
@@ -88,3 +91,641 @@ if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $index
 | 
			
		||||
    );
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Detect type of UPS (Signle-Phase/3 Phase)
 | 
			
		||||
# Number of input lines
 | 
			
		||||
    $upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0';
 | 
			
		||||
    $in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
// 3 Phase system states
 | 
			
		||||
if ($in_phaseNum == '3') {
 | 
			
		||||
    // Inverter active
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.5.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseUPSStatusInverterOperating';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'yes',0,14,0) ,
 | 
			
		||||
                array($state_index_id,'no',0,16,2)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Inverter Operating';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // AC Status
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.3.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseUPSStatusACStatus';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'normal',0,10,0) ,
 | 
			
		||||
                array($state_index_id,'abnormal',0,11,2)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'AC status';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Bypass braker status
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.2.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseUPSStatusManualBypassBreaker';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'close',0,8,1) ,
 | 
			
		||||
                array($state_index_id,'open',0,9,)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Breaker Status';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Rectifier Operating
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.7.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseDCandRectifierStatusRecOperating';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'yes',0,14,0) ,
 | 
			
		||||
                array($state_index_id,'no',0,16,2)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Rectifier Operating';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Charge Status
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.6.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseDCandRectifierStatusChargeStatus';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'boost',0,6,0) ,
 | 
			
		||||
                array($state_index_id,'float',0,7,0) ,
 | 
			
		||||
                array($state_index_id,'no',0,16,2)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Charge Status';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Back Status
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.5.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseDCandRectifierStatusBatteryStatus';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'backup',0,4,1) ,
 | 
			
		||||
                array($state_index_id,'acnormal',0,5,0)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Back Status';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // In And Out
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.4.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseDCandRectifierStatusInAndOut';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'threeInOneOut',0,2,3) ,
 | 
			
		||||
                array($state_index_id,'threeInThreeOut',0,3,3)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'In And Out';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Rectifier Rotation Error
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.5.1.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseDCandRectifierStatusRecRotError';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'yes',0,14,2) ,
 | 
			
		||||
                array($state_index_id,'no',0,16,0)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Rectifier Rotation Error';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Short Circuit
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.7.7.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseFaultStatusShortCircuit';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'yes',0,14,2) ,
 | 
			
		||||
                array($state_index_id,'no',0,16,0)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Short Circuit';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Switch Mode
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.4.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseUPSStaticSwitchMode';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'invermode',0,12,0) ,
 | 
			
		||||
                array($state_index_id,'bypassmode',0,13,1)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Switch Mode';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Bypass Status
 | 
			
		||||
    $ups_state_oid = '.1.3.6.1.4.1.935.1.1.1.8.6.1.0';
 | 
			
		||||
    $ups_state = snmp_get($device, $ups_state_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($ups_state) || $ups_state == 0) {
 | 
			
		||||
        $state_name = 'upsThreePhaseUPSStatusBypassFreqFail';
 | 
			
		||||
        $state_index_id = create_state_index($state_name);
 | 
			
		||||
 | 
			
		||||
        if ($state_index_id !== null) {
 | 
			
		||||
            $states = array(
 | 
			
		||||
                array($state_index_id,'yes',0,14,2) ,
 | 
			
		||||
                array($state_index_id,'no',0,16,0)
 | 
			
		||||
            );
 | 
			
		||||
 | 
			
		||||
            foreach ($states as $value) {
 | 
			
		||||
                $insert = array(
 | 
			
		||||
                    'state_index_id' => $value[0],
 | 
			
		||||
                    'state_descr' => $value[1],
 | 
			
		||||
                    'state_draw_graph' => $value[2],
 | 
			
		||||
                    'state_value' => $value[3],
 | 
			
		||||
                    'state_generic_value' => $value[4]
 | 
			
		||||
                );
 | 
			
		||||
                dbInsert($insert, 'state_translations');
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        $index          = 0;
 | 
			
		||||
        $limit          = 10;
 | 
			
		||||
        $warnlimit      = null;
 | 
			
		||||
        $lowlimit       = null;
 | 
			
		||||
        $lowwarnlimit   = null;
 | 
			
		||||
        $divisor        = 1;
 | 
			
		||||
        $state          = $ups_state / $divisor;
 | 
			
		||||
        $descr          = 'Bypass freq. fail';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'state',
 | 
			
		||||
            $device,
 | 
			
		||||
            $ups_state_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $state
 | 
			
		||||
        );
 | 
			
		||||
        create_sensor_to_state_index(
 | 
			
		||||
            $device,
 | 
			
		||||
            $state_name,
 | 
			
		||||
            $index
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -17,25 +17,61 @@
 | 
			
		||||
 * You should have received a copy of the GNU General Public License
 | 
			
		||||
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
 | 
			
		||||
 *
 | 
			
		||||
 * Original file
 | 
			
		||||
 * @package    LibreNMS
 | 
			
		||||
 * @link       http://librenms.org
 | 
			
		||||
 * @copyright  2016 Tony Murray
 | 
			
		||||
 * @author     Tony Murray <murraytony@gmail.com>
 | 
			
		||||
 * 3 Phase support extension
 | 
			
		||||
 * @copyright  2018 Mikael Sipilainen
 | 
			
		||||
 * @author     Mikael Sipilainen <mikael.sipilainen@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// Config
 | 
			
		||||
    # RRD graph color start value
 | 
			
		||||
    $index             = 0;// Text color number to start increasing +1
 | 
			
		||||
 | 
			
		||||
    # Voltage levels - EU and UK 230 volts +10% - 6% (ie. between 216.2 volts and 253 volts)
 | 
			
		||||
    $limit             = 270;// Maximum graph level
 | 
			
		||||
    $warnlimit         = 253;// Warning limit (High)
 | 
			
		||||
    $lowlimit          = 210;     // Minimum graph level
 | 
			
		||||
    $lowwarnlimit      = 216;     // Warning limit (Low)
 | 
			
		||||
    $divisor1phase     = 10;      // Divisor to set sensor input value (eg. value 2324/10=232,4 Volts)
 | 
			
		||||
    $divisor3phase     = 10;       // Divisor to set sensor input value (eg. value 22/1=22 Volts)
 | 
			
		||||
 | 
			
		||||
    # UPS single-phase battery system values
 | 
			
		||||
    $bat_1phase_limit         = 30; // Remember to check correct values
 | 
			
		||||
    $bat_1phase_warnlimit     = 28;
 | 
			
		||||
    $bat_1phase_lowlimit      = 10;
 | 
			
		||||
    $bat_1phase_lowwarnlimit  = 18;
 | 
			
		||||
    $bat_1phase_divisor       = 1;
 | 
			
		||||
 | 
			
		||||
    # UPS 3 phase battery system values
 | 
			
		||||
    $bat_3phase_limit         = 270; // Remember to check correct values
 | 
			
		||||
    $bat_3phase_warnlimit     = 270;
 | 
			
		||||
    $bat_3phase_lowlimit      = 210;
 | 
			
		||||
    $bat_3phase_lowwarnlimit  = 215;
 | 
			
		||||
    $bat_3phase_divisor       = 10;
 | 
			
		||||
 | 
			
		||||
// Detect type of UPS (Signle-Phase/3 Phase)
 | 
			
		||||
# Number of input lines
 | 
			
		||||
    $upsInputNumLines_oid = '.1.3.6.1.2.1.33.1.3.2.0';
 | 
			
		||||
    $in_phaseNum = snmp_get($device, $upsInputNumLines_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    # Number of output lines
 | 
			
		||||
    $upsOutputNumLines_oid = '.1.3.6.1.2.1.33.1.4.3.0';
 | 
			
		||||
    $out_phaseNum = snmp_get($device, $upsOutputNumLines_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
// INPUT single-phase system
 | 
			
		||||
if ($in_phaseNum == '1') {
 | 
			
		||||
    $in_voltage_oid = '.1.3.6.1.4.1.935.1.1.1.3.2.1.0';
 | 
			
		||||
    $in_voltage = snmp_get($device, $in_voltage_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($in_voltage) || $in_voltage == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
    $index          = 0;
 | 
			
		||||
    $limit          = 300;
 | 
			
		||||
    $warnlimit      = 253;
 | 
			
		||||
    $lowlimit       = 0;
 | 
			
		||||
    $lowwarnlimit   = 216;
 | 
			
		||||
    $divisor        = 10;
 | 
			
		||||
        $divisor        = $divisor1phase;
 | 
			
		||||
        $voltage        = $in_voltage / $divisor;
 | 
			
		||||
    $descr          = 'Input Voltage';
 | 
			
		||||
        $descr          = 'Input';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
@@ -54,20 +90,106 @@ if (!empty($in_voltage) || $in_voltage == 0) {
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// INPUT voltage 3 Phase system
 | 
			
		||||
if ($in_phaseNum == '3') {
 | 
			
		||||
    // Phase L1 (R)
 | 
			
		||||
    $in_voltage1_oid = '.1.3.6.1.4.1.935.1.1.1.8.2.2.0';
 | 
			
		||||
    $in_voltage1 = snmp_get($device, $in_voltage1_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($in_voltage1) || $in_voltage1 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $in_voltage1 / $divisor;
 | 
			
		||||
        $descr          = 'In L1';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
            $in_voltage1_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Phase L2 (S)
 | 
			
		||||
    $in_voltage2_oid = '.1.3.6.1.4.1.935.1.1.1.8.2.3.0';
 | 
			
		||||
    $in_voltage2 = snmp_get($device, $in_voltage2_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($in_voltage2) || $in_voltage2 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $in_voltage2 / $divisor;
 | 
			
		||||
        $descr          = 'In L2';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
            $in_voltage2_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Phase L3 (T)
 | 
			
		||||
    $in_voltage3_oid = '.1.3.6.1.4.1.935.1.1.1.8.2.4.0';
 | 
			
		||||
    $in_voltage3 = snmp_get($device, $in_voltage3_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($in_voltage3) || $in_voltage3 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $in_voltage3 / $divisor;
 | 
			
		||||
        $descr          = 'In L3';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
            $in_voltage3_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// OUTPUT voltage single-phase
 | 
			
		||||
if ($in_phaseNum == '1') {
 | 
			
		||||
    $out_voltage_oid = '.1.3.6.1.4.1.935.1.1.1.4.2.1.0';
 | 
			
		||||
    $out_voltage = snmp_get($device, $out_voltage_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($out_voltage) || $out_voltage == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
    $index          = 1;
 | 
			
		||||
    $limit          = 300;
 | 
			
		||||
    $warnlimit      = 253;
 | 
			
		||||
    $lowlimit       = 0;
 | 
			
		||||
    $lowwarnlimit   = 216;
 | 
			
		||||
    $divisor        = 10;
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor1phase;
 | 
			
		||||
        $voltage        = $out_voltage / $divisor;
 | 
			
		||||
    $descr          = 'Output Voltage';
 | 
			
		||||
        $descr          = 'Output';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
@@ -86,26 +208,218 @@ if (!empty($out_voltage) || $out_voltage == 0) {
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
$battery_voltage_oid = '.1.3.6.1.4.1.935.1.1.1.2.2.2.0';
 | 
			
		||||
$battery_voltage = snmp_get($device, $battery_voltage_oid, '-Oqv');
 | 
			
		||||
// OUTPUT voltage 3 Phase system
 | 
			
		||||
if ($out_phaseNum == '3') {
 | 
			
		||||
    // Phase L1 (R)
 | 
			
		||||
    $out_voltage1_oid = '.1.3.6.1.4.1.935.1.1.1.8.3.2.0';
 | 
			
		||||
    $out_voltage1 = snmp_get($device, $out_voltage1_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
if (!empty($battery_voltage) || $battery_voltage == 0) {
 | 
			
		||||
    if (!empty($out_voltage1) || $out_voltage1 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
    $index          = 2;
 | 
			
		||||
    $limit          = 100;
 | 
			
		||||
    $warnlimit      = null;
 | 
			
		||||
    $lowlimit       = null;
 | 
			
		||||
    $lowwarnlimit   = null;
 | 
			
		||||
    $divisor        = 10;
 | 
			
		||||
    $voltage        = $battery_voltage / $divisor;
 | 
			
		||||
    $descr          = 'Battery Voltage';
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $out_voltage1 / $divisor;
 | 
			
		||||
        $descr          = 'Out L1';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
        $battery_voltage_oid,
 | 
			
		||||
            $out_voltage1_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Phase L2 (S)
 | 
			
		||||
    $out_voltage2_oid = '.1.3.6.1.4.1.935.1.1.1.8.3.3.0';
 | 
			
		||||
    $out_voltage2 = snmp_get($device, $out_voltage2_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($out_voltage2) || $out_voltage2 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $out_voltage2 / $divisor;
 | 
			
		||||
        $descr          = 'Out L2';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
            $out_voltage2_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Phase L3 (T)
 | 
			
		||||
    $out_voltage3_oid = '.1.3.6.1.4.1.935.1.1.1.8.3.4.0';
 | 
			
		||||
    $out_voltage3 = snmp_get($device, $out_voltage3_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($out_voltage3) || $out_voltage3 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $out_voltage3 / $divisor;
 | 
			
		||||
        $descr          = 'Out L3';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
            $out_voltage3_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// Bypass voltage 3 Phase system
 | 
			
		||||
if ($out_phaseNum == '3') {
 | 
			
		||||
    // Phase L1 (R)
 | 
			
		||||
    $bypass_voltage1_oid       = '.1.3.6.1.4.1.935.1.1.1.8.4.2.0';
 | 
			
		||||
    $bypass_voltage1           = snmp_get($device, $bypass_voltage1_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($bypass_voltage1) || $bypass_voltage1 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $bypass_voltage1 / $divisor;
 | 
			
		||||
        $descr          = 'Bypass L1';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
            $bypass_voltage1_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Phase L2 (S)
 | 
			
		||||
    $bypass_voltage2_oid       = '.1.3.6.1.4.1.935.1.1.1.8.4.3.0';
 | 
			
		||||
    $bypass_voltage2           = snmp_get($device, $bypass_voltage2_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($bypass_voltage2) || $bypass_voltage2 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $bypass_voltage2 / $divisor;
 | 
			
		||||
        $descr          = 'Bypass L2';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
            $bypass_voltage2_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
    // Phase L3 (T)
 | 
			
		||||
    $bypass_voltage3_oid       = '.1.3.6.1.4.1.935.1.1.1.8.4.4.0';
 | 
			
		||||
    $bypass_voltage3           = snmp_get($device, $bypass_voltage3_oid, '-Oqv');
 | 
			
		||||
 | 
			
		||||
    if (!empty($bypass_voltage3) || $bypass_voltage3 == 0) {
 | 
			
		||||
        $type           = 'netagent2';
 | 
			
		||||
        $index++;
 | 
			
		||||
        $divisor        = $divisor3phase;
 | 
			
		||||
        $voltage        = $bypass_voltage3 / $divisor;
 | 
			
		||||
        $descr          = 'Bypass L3';
 | 
			
		||||
 | 
			
		||||
        discover_sensor(
 | 
			
		||||
            $valid['sensor'],
 | 
			
		||||
            'voltage',
 | 
			
		||||
            $device,
 | 
			
		||||
            $bypass_voltage3_oid,
 | 
			
		||||
            $index,
 | 
			
		||||
            $type,
 | 
			
		||||
            $descr,
 | 
			
		||||
            $divisor,
 | 
			
		||||
            '1',
 | 
			
		||||
            $lowlimit,
 | 
			
		||||
            $lowwarnlimit,
 | 
			
		||||
            $warnlimit,
 | 
			
		||||
            $limit,
 | 
			
		||||
            $voltage
 | 
			
		||||
        );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
// BATTERY Voltage
 | 
			
		||||
# Set divisor and limit ranges 1 phase UPS systems
 | 
			
		||||
if ($in_phaseNum == '1') {
 | 
			
		||||
    $battery_voltage_oid = '.1.3.6.1.4.1.935.1.1.1.2.2.2.0';
 | 
			
		||||
    $battery_voltage1 = snmp_get($device, $battery_voltage_oid, '-Oqv');
 | 
			
		||||
    $limit = $bat_1phase_limit;
 | 
			
		||||
    $warnlimit = $bat_1phase_warnlimit;
 | 
			
		||||
    $lowlimit = $bat_1phase_lowlimit;
 | 
			
		||||
    $lowwarnlimit = $bat_1phase_lowwarnlimit;
 | 
			
		||||
    $divisor = $bat_1phase_divisor;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
# Set divisor and limit ranges 3 phase UPS systems
 | 
			
		||||
if ($in_phaseNum == '3') {
 | 
			
		||||
    $battery_voltage1_oid = '.1.3.6.1.2.1.33.1.2.5.0';
 | 
			
		||||
    $battery_voltage1 = snmp_get($device, $battery_voltage1_oid, '-Oqv');
 | 
			
		||||
    $limit = $bat_3phase_limit;
 | 
			
		||||
    $warnlimit = $bat_3phase_warnlimit;
 | 
			
		||||
    $lowlimit = $bat_3phase_lowlimit;
 | 
			
		||||
    $lowwarnlimit = $bat_3phase_lowwarnlimit;
 | 
			
		||||
    $divisor = $bat_3phase_divisor;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
if (!empty($battery_voltage1) || $battery_voltage1 == 0) {
 | 
			
		||||
    $type           = 'netagent2';
 | 
			
		||||
    $index++;
 | 
			
		||||
    $voltage        = $battery_voltage1 / $divisor;
 | 
			
		||||
    $descr          = 'Battery';
 | 
			
		||||
 | 
			
		||||
    discover_sensor(
 | 
			
		||||
        $valid['sensor'],
 | 
			
		||||
        'voltage',
 | 
			
		||||
        $device,
 | 
			
		||||
        $battery_voltage1_oid,
 | 
			
		||||
        $index,
 | 
			
		||||
        $type,
 | 
			
		||||
        $descr,
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@
 | 
			
		||||
/**
 | 
			
		||||
 * netagent2.inc.php
 | 
			
		||||
 *
 | 
			
		||||
 * LibreNMS os polling module for Megatec
 | 
			
		||||
 * LibreNMS os polling module for Megatec NetAgent II and NetAgent Mini
 | 
			
		||||
 *
 | 
			
		||||
 * This program is free software: you can redistribute it and/or modify
 | 
			
		||||
 * it under the terms of the GNU General Public License as published by
 | 
			
		||||
@@ -19,11 +19,10 @@
 | 
			
		||||
 *
 | 
			
		||||
 * @package    LibreNMS
 | 
			
		||||
 * @link       http://librenms.org
 | 
			
		||||
 * @copyright  2016 Neil Lathwood
 | 
			
		||||
 * @author     Neil Lathwood <neil@lathwood.co.uk>
 | 
			
		||||
 * @copyright  2018 Mikael Sipilainen
 | 
			
		||||
 * @author     Mikael Sipilainen <mikael.sipilainen@gmail.com>
 | 
			
		||||
 */
 | 
			
		||||
 | 
			
		||||
// NET Agent II
 | 
			
		||||
 | 
			
		||||
$version  = snmp_get($device, '.1.3.6.1.2.1.33.1.1.4.0', '-OQv');
 | 
			
		||||
$hardware = $device['sysDescr'];
 | 
			
		||||
$oid = snmp_get_multi($device, '.1.3.6.1.2.1.33.1.1.4.0 .1.3.6.1.2.1.33.1.1.1.0', '-OQU');
 | 
			
		||||
$version  = $oid[0]['.1.3.6.1.2.1.33.1.1.4.0'];
 | 
			
		||||
$hardware = $oid[0]['.1.3.6.1.2.1.33.1.1.1.0'];
 | 
			
		||||
 
 | 
			
		||||
							
								
								
									
										1758
									
								
								tests/data/netagent2.json
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										1758
									
								
								tests/data/netagent2.json
									
									
									
									
									
										Normal file
									
								
							
										
											
												File diff suppressed because it is too large
												Load Diff
											
										
									
								
							@@ -1,11 +1,195 @@
 | 
			
		||||
1.3.6.1.2.1.1.1.0|4|NET Agent II
 | 
			
		||||
1.3.6.1.2.1.1.2.0|6|.1.3.6.1.4.1.935
 | 
			
		||||
1.3.6.1.2.1.1.3.0|67|149390700
 | 
			
		||||
1.3.6.1.2.1.1.4.0|4|<private>
 | 
			
		||||
1.3.6.1.2.1.1.5.0|4|<private>
 | 
			
		||||
1.3.6.1.2.1.1.6.0|4|<private>
 | 
			
		||||
1.3.6.1.2.1.2.2.1.1.1|2|1
 | 
			
		||||
1.3.6.1.2.1.2.2.1.1.2|2|2
 | 
			
		||||
1.3.6.1.2.1.2.2.1.1.6|2|6
 | 
			
		||||
1.3.6.1.2.1.2.2.1.2.1|4|eth0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.2.2|4|eth0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.2.6|4|loopback
 | 
			
		||||
1.3.6.1.2.1.2.2.1.3.1|2|6
 | 
			
		||||
1.3.6.1.2.1.2.2.1.3.2|2|23
 | 
			
		||||
1.3.6.1.2.1.2.2.1.3.6|2|24
 | 
			
		||||
1.3.6.1.2.1.2.2.1.4.1|2|1500
 | 
			
		||||
1.3.6.1.2.1.2.2.1.4.2|2|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.4.6|2|1536
 | 
			
		||||
1.3.6.1.2.1.2.2.1.5.1|66|10000000
 | 
			
		||||
1.3.6.1.2.1.2.2.1.5.2|66|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.5.6|66|10000
 | 
			
		||||
1.3.6.1.2.1.2.2.1.6.1|4x|000000000000
 | 
			
		||||
1.3.6.1.2.1.2.2.1.6.2|4x|000000000000
 | 
			
		||||
1.3.6.1.2.1.2.2.1.6.6|4x|000000000000
 | 
			
		||||
1.3.6.1.2.1.2.2.1.7.1|2|1
 | 
			
		||||
1.3.6.1.2.1.2.2.1.7.2|2|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.7.6|2|1
 | 
			
		||||
1.3.6.1.2.1.2.2.1.8.1|2|1
 | 
			
		||||
1.3.6.1.2.1.2.2.1.8.2|2|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.8.6|2|1
 | 
			
		||||
1.3.6.1.2.1.2.2.1.9.1|67|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.9.2|67|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.9.6|67|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.10.1|65|28837733
 | 
			
		||||
1.3.6.1.2.1.2.2.1.10.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.10.6|65|136190511
 | 
			
		||||
1.3.6.1.2.1.2.2.1.11.1|65|280397
 | 
			
		||||
1.3.6.1.2.1.2.2.1.11.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.11.6|65|781077
 | 
			
		||||
1.3.6.1.2.1.2.2.1.12.1|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.12.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.12.6|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.13.1|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.13.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.13.6|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.14.1|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.14.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.14.6|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.15.1|65|12
 | 
			
		||||
1.3.6.1.2.1.2.2.1.15.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.15.6|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.16.1|65|47869709
 | 
			
		||||
1.3.6.1.2.1.2.2.1.16.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.16.6|65|136190511
 | 
			
		||||
1.3.6.1.2.1.2.2.1.17.1|65|273280
 | 
			
		||||
1.3.6.1.2.1.2.2.1.17.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.17.6|65|781077
 | 
			
		||||
1.3.6.1.2.1.2.2.1.18.1|65|60
 | 
			
		||||
1.3.6.1.2.1.2.2.1.18.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.18.6|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.19.1|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.19.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.19.6|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.20.1|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.20.2|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.20.6|65|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.21.1|66|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.21.2|66|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.21.6|66|0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.22.1|6|0.0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.22.2|6|0.0
 | 
			
		||||
1.3.6.1.2.1.2.2.1.22.6|6|0.0
 | 
			
		||||
1.3.6.1.2.1.4.3.0|65|1047704
 | 
			
		||||
1.3.6.1.2.1.4.4.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.5.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.6.0|65|27
 | 
			
		||||
1.3.6.1.2.1.4.7.0|65|6
 | 
			
		||||
1.3.6.1.2.1.4.8.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.9.0|65|1047676
 | 
			
		||||
1.3.6.1.2.1.4.10.0|65|1049147
 | 
			
		||||
1.3.6.1.2.1.4.11.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.12.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.14.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.15.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.16.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.17.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.18.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.19.0|65|0
 | 
			
		||||
1.3.6.1.2.1.4.20.1.2.0.0.0.0|2|2
 | 
			
		||||
1.3.6.1.2.1.4.20.1.2.127.0.0.1|2|6
 | 
			
		||||
1.3.6.1.2.1.4.20.1.2.192.168.100.22|2|1
 | 
			
		||||
1.3.6.1.2.1.4.20.1.3.0.0.0.0|64|255.0.0.0
 | 
			
		||||
1.3.6.1.2.1.4.20.1.3.127.0.0.1|64|255.0.0.0
 | 
			
		||||
1.3.6.1.2.1.4.20.1.3.192.168.100.22|64|255.255.255.0
 | 
			
		||||
1.3.6.1.2.1.4.22.1.2.1.192.168.100.20|4x|F44D306852F0
 | 
			
		||||
1.3.6.1.2.1.5.1.0|65|134133
 | 
			
		||||
1.3.6.1.2.1.5.2.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.3.0|65|6
 | 
			
		||||
1.3.6.1.2.1.5.4.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.5.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.6.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.7.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.8.0|65|74734
 | 
			
		||||
1.3.6.1.2.1.5.9.0|65|59393
 | 
			
		||||
1.3.6.1.2.1.5.10.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.11.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.12.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.13.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.14.0|65|134129
 | 
			
		||||
1.3.6.1.2.1.5.15.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.16.0|65|2
 | 
			
		||||
1.3.6.1.2.1.5.17.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.18.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.19.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.20.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.21.0|65|59393
 | 
			
		||||
1.3.6.1.2.1.5.22.0|65|74734
 | 
			
		||||
1.3.6.1.2.1.5.23.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.24.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.25.0|65|0
 | 
			
		||||
1.3.6.1.2.1.5.26.0|65|0
 | 
			
		||||
1.3.6.1.2.1.6.5.0|65|59393
 | 
			
		||||
1.3.6.1.2.1.6.6.0|65|59491
 | 
			
		||||
1.3.6.1.2.1.6.7.0|65|0
 | 
			
		||||
1.3.6.1.2.1.6.8.0|65|3
 | 
			
		||||
1.3.6.1.2.1.6.9.0|66|0
 | 
			
		||||
1.3.6.1.2.1.6.10.0|65|549177
 | 
			
		||||
1.3.6.1.2.1.6.11.0|65|551843
 | 
			
		||||
1.3.6.1.2.1.6.12.0|65|0
 | 
			
		||||
1.3.6.1.2.1.6.14.0|65|0
 | 
			
		||||
1.3.6.1.2.1.6.15.0|65|3
 | 
			
		||||
1.3.6.1.2.1.7.1.0|65|364395
 | 
			
		||||
1.3.6.1.2.1.7.2.0|65|2
 | 
			
		||||
1.3.6.1.2.1.7.3.0|65|0
 | 
			
		||||
1.3.6.1.2.1.7.4.0|65|363205
 | 
			
		||||
1.3.6.1.2.1.11.1.0|65|303743
 | 
			
		||||
1.3.6.1.2.1.11.2.0|65|303742
 | 
			
		||||
1.3.6.1.2.1.11.3.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.4.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.5.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.6.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.8.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.9.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.10.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.11.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.12.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.13.0|65|1303634
 | 
			
		||||
1.3.6.1.2.1.11.14.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.15.0|65|127809
 | 
			
		||||
1.3.6.1.2.1.11.16.0|65|75880
 | 
			
		||||
1.3.6.1.2.1.11.17.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.18.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.19.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.20.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.21.0|65|12
 | 
			
		||||
1.3.6.1.2.1.11.22.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.24.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.25.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.26.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.27.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.28.0|65|303744
 | 
			
		||||
1.3.6.1.2.1.11.29.0|65|0
 | 
			
		||||
1.3.6.1.2.1.11.30.0|2|2
 | 
			
		||||
1.3.6.1.2.1.33.1.1.1.0|4|INVT CO., LTD
 | 
			
		||||
1.3.6.1.2.1.33.1.1.4.0|4|2.48.DP520.WEST
 | 
			
		||||
1.3.6.1.2.1.33.1.2.5.0|2|2690
 | 
			
		||||
1.3.6.1.2.1.33.1.3.2.0|2|3
 | 
			
		||||
1.3.6.1.2.1.33.1.4.3.0|2|3
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.2.1.1.0|2|2
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.2.2.1.0|2|100
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.2.2.3.0|2|250
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.2.2.7.0|2|0
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.3.2.1.0|2|2545
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.3.2.4.0|2|500
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.4.1.1.0|2|9
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.4.2.1.0|2|2285
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.4.2.2.0|2|500
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.4.2.3.0|2|44
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.2.2.3.0|2|250
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.3.2.1.0|2|2545
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.4.2.1.0|2|2285
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.4.1.1.0|2|9
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.2.1.0|2|499
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.2.2.0|2|2360
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.2.3.0|2|2367
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.2.4.0|2|2379
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.3.1.0|2|499
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.3.2.0|2|2312
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.3.3.0|2|2313
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.3.4.0|2|2312
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.3.5.0|2|235
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.3.6.0|2|327
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.3.7.0|2|327
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.4.1.0|2|499
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.4.2.0|2|2346
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.4.3.0|2|2362
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.8.4.4.0|2|2364
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.9.1.3.0|2|0
 | 
			
		||||
1.3.6.1.4.1.935.1.1.1.9.1.4.0|2|0
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user