Debian Codegraph @

check_printer_health/check_printer_health-1.1.0.2/plugins-scripts/Classes/Lexmark/Component/PrinterSubsystem.pm

raw
1 package Classes::Lexmark::Component::PrinterSubsystem;;
2 our @ISA = qw(Monitoring::GLPlugin::SNMP::Item);
3 use strict;
4
5 sub init {
6 my $self = shift;
7 $self->get_snmp_tables('LEXMARK-MPS-MIB', [
8 ['alerts', 'deviceAlertTable', 'Classes::Lexmark::Component::PrinterSubsystem::Alert'],
9 ]);
10 $self->get_snmp_tables('LEXMARK-PVT-MIB', [
11 ['prtgens', 'prtgenStatusTable', 'Classes::Lexmark::Component::PrinterSubsystem::Printer'],
12 ]);
13 }
14
15 package Classes::Lexmark::Component::PrinterSubsystem::Alert;
16 our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
17 use strict;
18
19 sub finish {
20 my ($self) = @_;
21 $self->{deviceAlertTimeHuman} = scalar localtime $self->{deviceAlertTime};
22 $self->{deviceAlertAgeMinutes} = (time - $self->{deviceAlertTime}) / 60;
23 }
24
25 sub check {
26 my ($self) = @_;
27 $self->add_info(sprintf '%s since %dmin',
28 $self->{deviceAlertDescription},
29 $self->{deviceAlertAgeMinutes}
30 );
31 if ($self->{deviceAlertSeverity} =~ /serviceRequired|warning/) {
32 $self->add_warning_mitigation();
33 } elsif ($self->{deviceAlertSeverity} eq "critical") {
34 $self->add_critical();
35 } elsif ($self->{deviceAlertSeverity} eq "unknown") {
36 $self->add_unknown();
37 } else {
38 $self->add_ok();
39 }
40 }
41
42
43 package Classes::Lexmark::Component::PrinterSubsystem::Printer;
44 our @ISA = qw(Monitoring::GLPlugin::SNMP::TableItem);
45 use strict;
46
47 sub check {
48 my ($self) = @_;
49 if ($self->{prtgenStatusIRC} ne "0") {
50 $self->add_warning(sprintf "intervention required code %s is shown",
51 $self->{prtgenStatusIRC});
52 }
53 if ($self->{prtgenStatusOutHopFull} eq "full") {
54 $self->add_warning_mitigation("the current output hopper is full");
55 }
56 if ($self->{prtgenStatusInputEmpty} eq "empty") {
57 $self->add_warning_mitigation("the active input paper tray is empty");
58 }
59 if ($self->{prtgenStatusPaperJam} eq "jamed") {
60 $self->add_warning("the paper path is jammed");
61 }
62 if ($self->{prtgenStatusTonerError} eq "tonerError") {
63 $self->add_warning_mitigation("the toner supply status shows an error");
64 }
65 if ($self->{prtgenStatusSrvcReqd} eq "serviceRequired") {
66 $self->add_warning_mitigation("service required");
67 }
68 if ($self->{prtgenStatusDiskError} eq "diskError") {
69 $self->add_critical("the disk has an error");
70 }
71 if ($self->{prtgenStatusCoverOpen} eq "coverOpen") {
72 $self->add_warning("the cover is open");
73 }
74 if ($self->{prtgenStatusPageComplex} eq "complexPage") {
75 #$self->add_warning("something is too complex????");
76 }
77 if ($self->{prtgenStatusLineStatus} eq "offline") {
78 #$self->add_warning("the printer is offline");
79 }
80 }
81
82
83