fix: Fixed and improved toner discovery (#8428)

* fix: Fixed and improved toner discovery

* Update konica data
xerox tries to insert too long of descriptions.  Lets remove the part and serial number, they are ugly to look at in the ui.
This commit is contained in:
Neil Lathwood
2018-03-29 04:13:45 +01:00
committed by Tony Murray
parent fb701bc1b4
commit 07ee21b04d
5 changed files with 214 additions and 35 deletions

View File

@@ -4,21 +4,16 @@ $valid_toner = array();
if ($device['os_group'] == 'printer') {
echo 'Toner: ';
$oids = snmpwalk_cache_oid($device, 'prtMarkerColorantMarkerIndex', array(), 'Printer-MIB');
if (empty($oids)) {
$oids = snmpwalk_cache_oid($device, 'prtMarkerSuppliesMarkerIndex', $oids, 'Printer-MIB');
}
$oids = snmpwalk_cache_oid($device, 'prtMarkerSuppliesLevel', $oids, 'Printer-MIB');
if (!empty($oids)) {
$oids = snmpwalk_cache_oid($device, 'prtMarkerSuppliesLevel', $oids, 'Printer-MIB');
$oids = snmpwalk_cache_oid($device, 'prtMarkerSuppliesMaxCapacity', $oids, 'Printer-MIB');
$oids = snmpwalk_cache_oid($device, 'prtMarkerSuppliesDescription', $oids, 'Printer-MIB', null, '-OQUsa');
$oids = snmpwalk_cache_oid($device, 'prtMarkerColorantValue', $oids, 'Printer-MIB', null, '-OQUsa');
}
foreach ($oids as $index => $data) {
$last_index = substr($index, strrpos($index, '.') + 1);
$raw_toner = $data['prtMarkerSuppliesLevel'];
$descr = $data['prtMarkerSuppliesDescription'];
$raw_capacity = $data['prtMarkerSuppliesMaxCapacity'];
@@ -31,17 +26,18 @@ if ($device['os_group'] == 'printer') {
$raw_toner = snmp_get($device, $toner_oid, '-Oqv');
}
if (empty($raw_toner)) {
$raw_toner = snmp_get($device, $toner_oid, '-Oqv');
}
if (empty($descr)) {
$descr_oid = ".1.3.6.1.4.1.367.3.2.1.2.24.1.1.3.$last_index";
$descr = snmp_get($device, $descr_oid, '-Oqva');
}
if (empty($raw_toner)) {
$raw_toner = snmp_get($device, $toner_oid, '-Oqv');
}
if (!empty($data['prtMarkerColorantValue'])) {
$descr = ucfirst($data['prtMarkerColorantValue']);
// trim part & serial number from devices that include it
if (str_contains($descr, ', PN')) {
$descr = explode(', PN', $descr)[0];
}
$type = 'jetdirect';

View File

@@ -585,17 +585,15 @@
"discovery": {
"toner": [
{
"toner_id": "1",
"toner_index": "1",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.1",
"toner_descr": "Cyan",
"toner_descr": "Toner (Cyan)",
"toner_capacity": "100",
"toner_current": "29",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.1"
},
{
"toner_id": "10",
"toner_index": "10",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.10",
@@ -605,7 +603,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.10"
},
{
"toner_id": "11",
"toner_index": "11",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.11",
@@ -615,7 +612,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.11"
},
{
"toner_id": "12",
"toner_index": "12",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.12",
@@ -625,7 +621,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.12"
},
{
"toner_id": "13",
"toner_index": "13",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.13",
@@ -635,7 +630,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.13"
},
{
"toner_id": "14",
"toner_index": "14",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.14",
@@ -645,7 +639,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.14"
},
{
"toner_id": "15",
"toner_index": "15",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.15",
@@ -655,7 +648,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.15"
},
{
"toner_id": "16",
"toner_index": "16",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.16",
@@ -665,7 +657,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.16"
},
{
"toner_id": "17",
"toner_index": "17",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.17",
@@ -675,37 +666,33 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.17"
},
{
"toner_id": "2",
"toner_index": "2",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.2",
"toner_descr": "Magenta",
"toner_descr": "Toner (Magenta)",
"toner_capacity": "100",
"toner_current": "31",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.2"
},
{
"toner_id": "3",
"toner_index": "3",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.3",
"toner_descr": "Yellow",
"toner_descr": "Toner (Yellow)",
"toner_capacity": "100",
"toner_current": "58",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.3"
},
{
"toner_id": "4",
"toner_index": "4",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.4",
"toner_descr": "Black",
"toner_descr": "Toner (Black)",
"toner_capacity": "100",
"toner_current": "83",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.4"
},
{
"toner_id": "5",
"toner_index": "5",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.5",
@@ -715,7 +702,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.5"
},
{
"toner_id": "6",
"toner_index": "6",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.6",
@@ -725,7 +711,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.6"
},
{
"toner_id": "7",
"toner_index": "7",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.7",
@@ -735,7 +720,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.7"
},
{
"toner_id": "8",
"toner_index": "8",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.8",
@@ -745,7 +729,6 @@
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.8"
},
{
"toner_id": "9",
"toner_index": "9",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.9",

155
tests/data/xerox.json Normal file
View File

@@ -0,0 +1,155 @@
{
"os": {
"discovery": {
"devices": [
{
"sysName": "<private>",
"sysObjectID": ".1.3.6.1.4.1.253.8.62.1.35.2.3.1.1",
"sysDescr": "Xerox AltaLink C8045; SS 100.002.057.09608, NC 100.002.09608, UI 100.002.09608, ME 063.022.000, CC 100.002.09608, DF 007.019.000, FI ------, FA 003.012.013, CCOS 100.007.09608, NCOS 100.007.09608, SC 013.014.002, SU 100.002.09608",
"sysContact": null,
"version": null,
"hardware": "",
"features": null,
"location": null,
"os": "xerox",
"type": "printer",
"serial": null,
"icon": "xerox.svg"
}
]
},
"poller": {
"devices": [
{
"sysName": "<private>",
"sysObjectID": ".1.3.6.1.4.1.253.8.62.1.35.2.3.1.1",
"sysDescr": "Xerox AltaLink C8045; SS 100.002.057.09608, NC 100.002.09608, UI 100.002.09608, ME 063.022.000, CC 100.002.09608, DF 007.019.000, FI ------, FA 003.012.013, CCOS 100.007.09608, NCOS 100.007.09608, SC 013.014.002, SU 100.002.09608",
"sysContact": "<private>",
"version": null,
"hardware": "Xerox AltaLink C8045",
"features": null,
"location": "<private>",
"os": "xerox",
"type": "printer",
"serial": null,
"icon": "xerox.svg"
}
]
}
},
"toner": {
"discovery": {
"toner": [
{
"toner_index": "1",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.1",
"toner_descr": "Black Toner",
"toner_capacity": "5300",
"toner_current": "20",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.1"
},
{
"toner_index": "10",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.10",
"toner_descr": "Waste Toner Container",
"toner_capacity": "100",
"toner_current": "5",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.10"
},
{
"toner_index": "11",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.11",
"toner_descr": "Transfer Belt Cleaner",
"toner_capacity": "100",
"toner_current": "65",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.11"
},
{
"toner_index": "12",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.12",
"toner_descr": "Second Bias Transfer Roll",
"toner_capacity": "100",
"toner_current": "86",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.12"
},
{
"toner_index": "2",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.2",
"toner_descr": "Cyan Toner",
"toner_capacity": "3000",
"toner_current": "66",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.2"
},
{
"toner_index": "3",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.3",
"toner_descr": "Magenta Toner",
"toner_capacity": "3000",
"toner_current": "72",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.3"
},
{
"toner_index": "4",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.4",
"toner_descr": "Yellow Toner",
"toner_capacity": "3050",
"toner_current": "60",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.4"
},
{
"toner_index": "5",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.5",
"toner_descr": "Drum Cartridge (R1)",
"toner_capacity": "100",
"toner_current": "50",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.5"
},
{
"toner_index": "6",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.6",
"toner_descr": "Drum Cartridge (R2)",
"toner_capacity": "100",
"toner_current": "92",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.6"
},
{
"toner_index": "7",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.7",
"toner_descr": "Drum Cartridge (R3)",
"toner_capacity": "100",
"toner_current": "93",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.7"
},
{
"toner_index": "8",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.8",
"toner_descr": "Drum Cartridge (R4)",
"toner_capacity": "100",
"toner_current": "93",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.8"
},
{
"toner_index": "9",
"toner_type": "jetdirect",
"toner_oid": ".1.3.6.1.2.1.43.11.1.1.9.1.9",
"toner_descr": "Fuser",
"toner_capacity": "100",
"toner_current": "90",
"toner_capacity_oid": ".1.3.6.1.2.1.43.11.1.1.8.1.9"
}
]
},
"poller": "matches discovery"
}
}

View File

@@ -51,7 +51,7 @@ storage:
excluded_fields: [device_id, storage_id]
toner:
toner:
excluded_fields: [device_id]
excluded_fields: [device_id, toner_id]
order_by: toner_oid, toner_index
wireless:
wireless_sensors:

View File

@@ -0,0 +1,45 @@
1.3.6.1.2.1.1.1.0|4|Xerox AltaLink C8045; SS 100.002.057.09608, NC 100.002.09608, UI 100.002.09608, ME 063.022.000, CC 100.002.09608, DF 007.019.000, FI ------, FA 003.012.013, CCOS 100.007.09608, NCOS 100.007.09608, SC 013.014.002, SU 100.002.09608
1.3.6.1.2.1.1.2.0|6|1.3.6.1.4.1.253.8.62.1.35.2.3.1.1
1.3.6.1.2.1.1.3.0|67|4280423
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.25.1.1.0|67|4277806
1.3.6.1.2.1.43.11.1.1.6.1.1|4|Black Toner, PN 006R01509;SN48178080E0000481
1.3.6.1.2.1.43.11.1.1.6.1.2|4|Cyan Toner, PN 006R01512;SN461E7A80E0000489
1.3.6.1.2.1.43.11.1.1.6.1.3|4|Magenta Toner, PN 006R01511;SN45304780E0000489
1.3.6.1.2.1.43.11.1.1.6.1.4|4|Yellow Toner, PN 006R01510;SN4E0B8980E000048A
1.3.6.1.2.1.43.11.1.1.6.1.5|4|Drum Cartridge (R1), PN 013R00662;SN5238EF80E000048E
1.3.6.1.2.1.43.11.1.1.6.1.6|4|Drum Cartridge (R2), PN 013R00662;SN52100780E000048E
1.3.6.1.2.1.43.11.1.1.6.1.7|4|Drum Cartridge (R3), PN 013R00662;SN52374F80E000048E
1.3.6.1.2.1.43.11.1.1.6.1.8|4|Drum Cartridge (R4), PN 013R00662;SN5234E480E000048E
1.3.6.1.2.1.43.11.1.1.6.1.9|4|Fuser, PN unknown;SNunknown
1.3.6.1.2.1.43.11.1.1.6.1.10|4|Waste Toner Container, PN 008R13061;SNunknown
1.3.6.1.2.1.43.11.1.1.6.1.11|4|Transfer Belt Cleaner, PN 001R00613;SNunknown
1.3.6.1.2.1.43.11.1.1.6.1.12|4|Second Bias Transfer Roll, PN 008R13064;SNunknown
1.3.6.1.2.1.43.11.1.1.8.1.1|2|5300
1.3.6.1.2.1.43.11.1.1.8.1.2|2|3000
1.3.6.1.2.1.43.11.1.1.8.1.3|2|3000
1.3.6.1.2.1.43.11.1.1.8.1.4|2|3050
1.3.6.1.2.1.43.11.1.1.8.1.5|2|100
1.3.6.1.2.1.43.11.1.1.8.1.6|2|100
1.3.6.1.2.1.43.11.1.1.8.1.7|2|100
1.3.6.1.2.1.43.11.1.1.8.1.8|2|100
1.3.6.1.2.1.43.11.1.1.8.1.9|2|100
1.3.6.1.2.1.43.11.1.1.8.1.10|2|100
1.3.6.1.2.1.43.11.1.1.8.1.11|2|100
1.3.6.1.2.1.43.11.1.1.8.1.12|2|100
1.3.6.1.2.1.43.11.1.1.9.1.1|2|1060
1.3.6.1.2.1.43.11.1.1.9.1.2|2|1980
1.3.6.1.2.1.43.11.1.1.9.1.3|2|2160
1.3.6.1.2.1.43.11.1.1.9.1.4|2|1830
1.3.6.1.2.1.43.11.1.1.9.1.5|2|50
1.3.6.1.2.1.43.11.1.1.9.1.6|2|92
1.3.6.1.2.1.43.11.1.1.9.1.7|2|93
1.3.6.1.2.1.43.11.1.1.9.1.8|2|93
1.3.6.1.2.1.43.11.1.1.9.1.9|2|90
1.3.6.1.2.1.43.11.1.1.9.1.10|2|5
1.3.6.1.2.1.43.11.1.1.9.1.11|2|65
1.3.6.1.2.1.43.11.1.1.9.1.12|2|86
1.3.6.1.4.1.253.8.51.1.2.1.20.1|4|MFG:Xerox; CMD:PCL, PJL, PostScript, XPS; MDL:AltaLink C8045; CLS:Printer; DES:Xerox AltaLink C8045; CID:XR_PS_Office_Color
1.3.6.1.6.3.10.2.1.3.0|2|42809