Debian Codegraph @

check_printer_health/src/plugins-scripts/Classes/Device.pm

raw
1 package Classes::Device;
2 our @ISA = qw(Monitoring::GLPlugin::SNMP);
3 use strict;
4
5 sub classify {
6 my $self = shift;
7 if (! ($self->opts->hostname || $self->opts->snmpwalk)) {
8 $self->add_unknown('either specify a hostname or a snmpwalk file');
9 } else {
10 $self->check_snmp_and_model();
11 if (! $self->check_messages()) {
12 if ($self->opts->verbose && $self->opts->verbose) {
13 printf "I am a %s\n", $self->{productname};
14 }
15 if ($self->opts->mode =~ /^my-/) {
16 $self->load_my_extension();
17 } elsif ($self->implements_mib('LEXMARK-PVT-MIB')) {
18 bless $self, 'Classes::Lexmark';
19 $self->debug('using Classes::Lexmark');
20 } elsif ($self->implements_mib('PRINTER-MIB')) {
21 bless $self, 'Classes::PRINTERMIB';
22 $self->debug('using Classes::PRINTERMIB');
23 } elsif ($self->implements_mib('HOST-RESOURCES-MIB')) {
24 bless $self, 'Classes::HOSTRESOURCESMIB';
25 $self->debug('using Classes::HOSTRESOURCESMIB');
26 } elsif ($self->implements_mib('KYOCERA-Private-MIB')) {
27 bless $self, 'Classes::Kyocera';
28 $self->debug('using Classes::Kyocera');
29 } elsif ($self->implements_mib('BROTHER-MIB')) {
30 bless $self, 'Classes::Brother';
31 $self->debug('using Classes::Brother');
32 } else {
33 if (my $class = $self->discover_suitable_class()) {
34 bless $self, $class;
35 $self->debug('using '.$class);
36 } else {
37 bless $self, 'Classes::Generic';
38 $self->debug('using Classes::Generic');
39 }
40 }
41 }
42 }
43 return $self;
44 }
45
46
47 package Classes::Generic;
48 our @ISA = qw(Classes::Device);
49 use strict;
50
51 sub init {
52 my $self = shift;
53 if ($self->mode =~ /something specific/) {
54 } else {
55 bless $self, 'Monitoring::GLPlugin::SNMP';
56 $self->no_such_mode();
57 }
58 }