This file is indexed.

/usr/lib/mon/mon.d/hpnp.monitor is in mon 1.2.0-9.

This file is owned by root:root, with mode 0o755.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
#!/usr/bin/perl
#
# SNMP monitoring of HP JetDirect-equipped printers
#
# returns 1 if an actual printer failure is indicated by SNMP,
# or 2 if it cannot communicate with the printer.
#
# Jim Trocki
#
# $Id: hpnp.monitor,v 1.1.1.1 2004/06/09 05:18:05 trockij Exp $
#
#    Copyright (C) 1998, Jim Trocki
#
#    This program is free software; you can redistribute it and/or modify
#    it under the terms of the GNU General Public License as published by
#    the Free Software Foundation; either version 2 of the License, or
#    (at your option) any later version.
#
#    This program is distributed in the hope that it will be useful,
#    but WITHOUT ANY WARRANTY; without even the implied warranty of
#    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#    GNU General Public License for more details.
#
#    You should have received a copy of the GNU General Public License
#    along with this program; if not, write to the Free Software
#    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
#
use SNMP;
use Getopt::Long;

GetOptions (\%opt, "community=s", "timeout=i", "retries=i", "lpq");

die "no host arguments\n" if (@ARGV == 0);

$RET = 0;
@ERRS = ();

$COMM = $opt{"community"} || "public";
$TIMEOUT = $opt{"timeout"} * 1000 * 1000 || 2000000;
$RETRIES = $opt{"retries"} || 5;

@DESC = ("offline", "paper problem", "needs human intervention",
    "peripheral error", "paper out", "paper jam", "toner low");


foreach $host (@ARGV) {
    undef $s;
    if (!defined($s = new SNMP::Session (DestHost => $host,
    		Timeout => $TIMEOUT, Community => $COMM,
		"Version" => 2,
		Retries => $RETRIES))) {
	print "cannot create SNMP session to $host\n";
	$RET = ($RET == 1) ? 1 : 2;
	next;
    }

    undef $vars;
    $vars = new SNMP::VarList (
    	['.1.3.6.1.4.1.11.2.3.9.1.1.2.1', 0],	# line state
    	['.1.3.6.1.4.1.11.2.3.9.1.1.2.2', 0],	# paper state
    	['.1.3.6.1.4.1.11.2.3.9.1.1.2.3', 0],	# human intervention
    	['.1.3.6.1.4.1.11.2.3.9.1.1.2.6', 0], # gdStatusPeripheralError
    	['.1.3.6.1.4.1.11.2.3.9.1.1.2.8', 0], # gdStatusPaperOut
    	['.1.3.6.1.4.1.11.2.3.9.1.1.2.9', 0], # gdStatusPaperJam
    	['.1.3.6.1.4.1.11.2.3.9.1.1.2.10', 0], # gdStatusTonerLow
    	['.1.3.6.1.4.1.11.2.3.9.1.1.3', 0], # gdStatusDisplay
    );

    if (!defined ($s->get($vars))) {
	push (@hosts, $host);
    	push (@ERRS, "$host unreachable\n\n");
	$RET = ($RET == 1) ? 1 : 2;
	next;
    }

    $display = ${$vars}[7]->val;

    $h = 0;
    @H = ();
    for ($i = 0; $i< 6; $i++) {
	if (${$vars}[$i]->val) {
	    push (@H, @DESC[$i]);
	    $RET = 1;
	    $h = 1;
	}
    }

    if ($h) {
    	push (@hosts, $host);
    }

    if (@H > 0) {
	push (@ERRS, "$host\n" . "-" x length($host) . "\n" .
		join ("\n", @H, "\n"));
	push (@ERRS, "display reads:\n$display\n\n");
    }
}

if (@hosts > 0) {
    print join (" ", sort @hosts), "\n";
    print "\n";
    print @ERRS;
}

exit $RET;