@@ -15,13 +15,18 @@ use constant enterprises => '.1.3.6.1.4.1' ;
15
15
use constant pantum => enterprises . ' .40093' ;
16
16
17
17
use constant pantumPrinter => pantum . ' .1.1' ;
18
+ use constant pantumFWVersion => pantumPrinter . ' .1.1' ;
19
+ use constant pantumRAM => pantumPrinter . ' .1.2' ;
18
20
use constant pantumSerialNumber1 => pantumPrinter . ' .1.5' ;
19
21
use constant pantumSerialNumber2 => pantum . ' .6.1.2' ;
20
22
use constant pantumSerialNumber3 => pantum . ' .10.1.1.4' ;
23
+ use constant pantumCounters => pantumPrinter . ' .3' ;
21
24
22
25
# Printer-MIB
23
26
use constant printmib => mib2 . ' .43' ;
24
27
use constant prtGeneralPrinterName => printmib . ' .5.1.1.16.1' ;
28
+ use constant prtMarkerSuppliesEntry => printmib . ' .11.1.1' ;
29
+ use constant prtMarkerColorantEntry => printmib . ' .12.1.1' ;
25
30
26
31
our $mibSupport = [
27
32
{
@@ -43,6 +48,151 @@ sub getSerial {
43
48
$self -> get(pantumSerialNumber3);
44
49
}
45
50
51
+ sub run {
52
+ my ($self ) = @_ ;
53
+
54
+ my $device = $self -> device
55
+ or return ;
56
+
57
+ # Consumable level: most manufacturers reports trees under .1.3.6.1.2.1.43.11.1.1.x.1 oids
58
+ # where Pantum manufacturer decided to use directly each oids when they are using only one consumable
59
+
60
+ # Same as in GLPI::Agent::Tools::Hardware
61
+ my %consumable_types = (
62
+ 3 => ' TONER' ,
63
+ 4 => ' WASTETONER' ,
64
+ 5 => ' CARTRIDGE' ,
65
+ 6 => ' CARTRIDGE' ,
66
+ 8 => ' WASTETONER' ,
67
+ 9 => ' DRUM' ,
68
+ 10 => ' DEVELOPER' ,
69
+ 12 => ' CARTRIDGE' ,
70
+ 15 => ' FUSERKIT' ,
71
+ 18 => ' MAINTENANCEKIT' ,
72
+ 20 => ' TRANSFERKIT' ,
73
+ 21 => ' TONER' ,
74
+ 32 => ' STAPLES' ,
75
+ );
76
+
77
+ my $max = $self -> get(prtMarkerSuppliesEntry . ' .8.1' );
78
+ my $current = $self -> get(prtMarkerSuppliesEntry . ' .9.1' );
79
+ if (defined ($max ) && defined ($current )) {
80
+ # Consumable identification
81
+ my $type_id = $self -> get(prtMarkerSuppliesEntry . ' .5.1' );
82
+ my $description = getCanonicalString($self -> get(prtMarkerSuppliesEntry . ' .6.1' ) // ' ' );
83
+
84
+ my $type ;
85
+ if ($type_id && $type_id != 1) {
86
+ $type = $consumable_types {$type_id };
87
+ } else {
88
+ # fallback on description
89
+ $type =
90
+ $description =~ / maintenance/i ? ' MAINTENANCEKIT' :
91
+ $description =~ / fuser/i ? ' FUSERKIT' :
92
+ $description =~ / transfer/i ? ' TRANSFERKIT' :
93
+ undef ;
94
+ }
95
+
96
+ if (!$type ) {
97
+ $device -> {logger }-> debug(" unknown consumable type $type_id : " . ($description || " no description" ))
98
+ if $device -> {logger };
99
+ } elsif ($type eq ' TONER' || $type eq ' DRUM' || $type eq ' CARTRIDGE' || $type eq ' DEVELOPER' ) {
100
+ my $color = getCanonicalString($self -> get(prtMarkerColorantEntry . ' .4.1' ));
101
+ if (!$color ) {
102
+ $device -> {logger }-> debug(" setting black color as default for: " . ($description || " no description" ))
103
+ if $device -> {logger };
104
+ # fallback on description or black
105
+ $color =
106
+ $description =~ / cyan/i ? ' cyan' :
107
+ $description =~ / magenta/i ? ' magenta' :
108
+ $description =~ / (yellow|jaune)/i ? ' yellow' :
109
+ $description =~ / (black|noir)/i ? ' black' : ' black' ;
110
+ }
111
+ $type .= uc ($color );
112
+ }
113
+
114
+ my $value ;
115
+ if ($current == -2) {
116
+ # A value of -2 means "unknown" according to the RFC - but this
117
+ # is not NULL - it means "something undetermined between
118
+ # OK and BAD".
119
+ # Several makers seem to have grabbed it as a way of indicating
120
+ # "almost out" for supplies and waste. (Like a vehicle low fuel warning)
121
+ #
122
+ # This was previously set to undef - but that was triggering a bug
123
+ # that caused bad XML to be output and that in turn would block FI4G imports
124
+ # which in turn would make page counters look strange for the days
125
+ # when it was happening (zero pages, then a big spike)
126
+ #
127
+ # Using "WARNING" should allow print monitoring staff to ensure
128
+ # replacement items are in stock before they go "BAD"
129
+ $value = ' WARNING' ;
130
+ } elsif ($current == -3) {
131
+ # A value of -3 means that the printer knows that there is some
132
+ # supply/remaining space, respectively.
133
+ $value = ' OK' ;
134
+ } else {
135
+ if (isInteger($max ) && $max >= 0) {
136
+ if (isInteger($current ) && $max > 0) {
137
+ $value = int (( 100 * $current ) / $max );
138
+ }
139
+ } else {
140
+ # PrtMarkerSuppliesSupplyUnitTC in Printer MIB
141
+ my $unit_id = $self -> get(prtMarkerSuppliesEntry . ' .7.1' );
142
+ $value =
143
+ $unit_id == 19 ? $current :
144
+ $unit_id == 18 ? $current . ' items' :
145
+ $unit_id == 17 ? $current . ' m' :
146
+ $unit_id == 16 ? $current . ' feet' :
147
+ $unit_id == 15 ? ($current / 10) . ' ml' :
148
+ $unit_id == 13 ? ($current / 10) . ' g' :
149
+ $unit_id == 11 ? $current . ' hours' :
150
+ $unit_id == 8 ? $current . ' sheets' :
151
+ $unit_id == 7 ? $current . ' impressions' :
152
+ $unit_id == 4 ? ($current / 1000) . ' mm' :
153
+ $current . ' ?' ;
154
+ }
155
+ }
156
+
157
+ $device -> {CARTRIDGES }-> {$type } = $value
158
+ if $type && defined ($value );
159
+ }
160
+
161
+ my $ram = $self -> get(pantumRAM);
162
+ $device -> {INFO }-> {RAM } = $ram
163
+ if defined ($ram ) && isInteger($ram );
164
+
165
+ my $counters = $self -> walk(pantumCounters);
166
+ if ($counters ) {
167
+ my $total = 0;
168
+ my %mapping = (
169
+ 1 => ' DUPLEX' ,
170
+ 9 => ' COPYTOTAL' ,
171
+ 12 => ' PRINTTOTAL' ,
172
+ );
173
+
174
+ foreach my $key (sort keys (%mapping )) {
175
+ my $count = $counters -> {$key };
176
+ next unless defined ($count ) && isInteger($count );
177
+ $device -> {PAGECOUNTERS }-> {$mapping {$key }} = $count ;
178
+ $total += $count ;
179
+ }
180
+ $device -> {PAGECOUNTERS }-> {TOTAL } = $total ;
181
+ }
182
+
183
+ my $version = getCanonicalString($self -> get(pantumFWVersion));
184
+ if ($version ) {
185
+ my $firmware = {
186
+ NAME => " Pantum $device ->{MODEL} firmware" ,
187
+ DESCRIPTION => " Pantum $device ->{MODEL} firmware version" ,
188
+ TYPE => " printer" ,
189
+ VERSION => $version ,
190
+ MANUFACTURER => " Pantum"
191
+ };
192
+ $device -> addFirmware($firmware );
193
+ }
194
+ }
195
+
46
196
1;
47
197
48
198
__END__
0 commit comments