mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
newdevice: samsung printer ml series (#4781)
* initial support * added os test * workaround toner level samsung ml * snmpsim sysobject oid added
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
<?php
|
||||
|
||||
if (str_contains($sysDescr, array('Samsung CLX', 'Samsung SCX', 'Samsung C', 'Samsung S'))) {
|
||||
if (str_contains($sysDescr, array('Samsung CLX', 'Samsung SCX', 'Samsung C', 'Samsung S', 'Samsung ML'))) {
|
||||
$os = 'samsungprinter';
|
||||
}
|
||||
|
||||
@@ -14,39 +14,53 @@ if ($device['os_group'] == 'printer') {
|
||||
echo 'Jetdirect ';
|
||||
}
|
||||
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
if ($data) {
|
||||
list($oid, $role) = explode(' ', $data);
|
||||
$split_oid = explode('.', $oid);
|
||||
$index = $split_oid[(count($split_oid) - 1)];
|
||||
if (is_numeric($role)) {
|
||||
//ricoh using private oids to expose toner levels
|
||||
if ($os == 'ricoh' || $os == 'nrg' || $os == 'lanier') {
|
||||
$toner_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.$index";
|
||||
$descr_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.3.$index";
|
||||
$capacity_oid = '';
|
||||
} else {
|
||||
$toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.1.$index";
|
||||
$descr_oid = ".1.3.6.1.2.1.43.11.1.1.6.1.$index";
|
||||
$capacity_oid = ".1.3.6.1.2.1.43.11.1.1.8.1.$index";
|
||||
}
|
||||
//samsung ml series does not responde to snmpwalk
|
||||
if ($os == 'samsungprinter' && str_contains($device['sysDescr'], 'Samsung ML')) {
|
||||
$toner_oid = '.1.3.6.1.2.1.43.12.1.1.4.1.1';
|
||||
$descr_oid = '.1.3.6.1.2.1.43.11.1.1.6.1.1';
|
||||
$capacity_oid = '.1.3.6.1.2.1.43.11.1.1.8.1.1';
|
||||
$descr = trim(str_replace("\n", '', preg_replace('/[^ \w]+/', '', snmp_get($device, $descr_oid, '-Oqv'))));
|
||||
$oid_toner = snmp_get($device, $toner_oid, '-Oqv');
|
||||
$oid_capacity = snmp_get($device, $capacity_oid, '-Oqv');
|
||||
$capacity = get_toner_capacity($device, $oid_capacity);
|
||||
$current = get_toner_levels($device, $oid_toner, $oid_capacity);
|
||||
|
||||
$descr = trim(str_replace("\n", '', preg_replace('/[^ \w]+/', '', snmp_get($device, $descr_oid, '-Oqv'))));
|
||||
|
||||
if ($descr != '') {
|
||||
$oid_toner = snmp_get($device, $toner_oid, '-Oqv');
|
||||
$oid_capacity = snmp_get($device, $capacity_oid, '-Oqv');
|
||||
|
||||
$capacity = get_toner_capacity($device, $oid_capacity);
|
||||
$current = get_toner_levels($device, $oid_toner, $oid_capacity);
|
||||
|
||||
$type = 'jetdirect';
|
||||
if (isHexString($descr)) {
|
||||
$descr = preg_replace('/[^ \w]+/', '', snmp_hexstring($descr));
|
||||
discover_toner($valid_toner, $device, $toner_oid, 1, 'jetdirect', $descr, $capacity_oid, $capacity, $current);
|
||||
} else {
|
||||
foreach (explode("\n", $oids) as $data) {
|
||||
$data = trim($data);
|
||||
if ($data) {
|
||||
list($oid, $role) = explode(' ', $data);
|
||||
$split_oid = explode('.', $oid);
|
||||
$index = $split_oid[(count($split_oid) - 1)];
|
||||
if (is_numeric($role)) {
|
||||
//ricoh using private oids to expose toner levels
|
||||
if ($os == 'ricoh' || $os == 'nrg' || $os == 'lanier') {
|
||||
$toner_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.5.$index";
|
||||
$descr_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.3.$index";
|
||||
$capacity_oid = '';
|
||||
} else {
|
||||
$toner_oid = ".1.3.6.1.2.1.43.11.1.1.9.1.$index";
|
||||
$descr_oid = ".1.3.6.1.2.1.43.11.1.1.6.1.$index";
|
||||
$capacity_oid = ".1.3.6.1.2.1.43.11.1.1.8.1.$index";
|
||||
}
|
||||
|
||||
discover_toner($valid_toner, $device, $toner_oid, $index, $type, $descr, $capacity_oid, $capacity, $current);
|
||||
$descr = trim(str_replace("\n", '', preg_replace('/[^ \w]+/', '', snmp_get($device, $descr_oid, '-Oqv'))));
|
||||
|
||||
if ($descr != '') {
|
||||
$oid_toner = snmp_get($device, $toner_oid, '-Oqv');
|
||||
$oid_capacity = snmp_get($device, $capacity_oid, '-Oqv');
|
||||
|
||||
$capacity = get_toner_capacity($device, $oid_capacity);
|
||||
$current = get_toner_levels($device, $oid_toner, $oid_capacity);
|
||||
|
||||
$type = 'jetdirect';
|
||||
if (isHexString($descr)) {
|
||||
$descr = preg_replace('/[^ \w]+/', '', snmp_hexstring($descr));
|
||||
}
|
||||
|
||||
discover_toner($valid_toner, $device, $toner_oid, $index, $type, $descr, $capacity_oid, $capacity, $current);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1146,6 +1146,7 @@ class DiscoveryTest extends \PHPUnit_Framework_TestCase
|
||||
$this->checkOS('samsungprinter', 'samsungprinter-scx');
|
||||
$this->checkOS('samsungprinter', 'samsungprinter-c');
|
||||
$this->checkOS('samsungprinter', 'samsungprinter-s');
|
||||
$this->checkOS('samsungprinter', 'samsungprinter-ml');
|
||||
}
|
||||
|
||||
public function testSanos()
|
||||
|
||||
2
tests/snmpsim/samsungprinter-ml.snmprec
Normal file
2
tests/snmpsim/samsungprinter-ml.snmprec
Normal file
@@ -0,0 +1,2 @@
|
||||
1.3.6.1.2.1.1.1.0|4|Samsung ML-2850 Series OS 1.01.15.47 02-10-2010;Engine 1.01.25;NIC V4.01.09(ML-285x)
|
||||
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.236.11.5.1
|
||||
Reference in New Issue
Block a user