Tylan / check_snmp_printer

Icinga Plugin for Checking SNMP Printer Status (Trays, Consumables and Pagecounts)
GNU General Public License v3.0
12 stars 4 forks source link

Can't call method "get" on an undefined value #34

Closed tgrymatt closed 1 year ago

tgrymatt commented 1 year ago

I tried to use your plugin with SNMP v3 with this command call:

./check_snmp_printer -v 3 -u icinga -A topsecret123 -a md5 -X topsecret123 -x des -H my-office-printer --messages

But then I got the error message:

Can't call method "get" on an undefined value at ./check_snmp_printer line 270.

Any idea? The system which I am using is Debian 10 with Perl version 5.28.1-6+deb10u1 installed. The printer is an Xerox AltaLink C-8135.

Tylan commented 1 year ago

Can you try this?

snmpget -v3 -On -l authPriv -u icinga -a md5 -A topsecret123 -x des -X topsecret123 my-office-printer 1.3.6.1.2.1.25.3.2.1.3.1

when I run that against my AltaLink C8045 it works:

.1.3.6.1.2.1.25.3.2.1.3.1 = STRING: Xerox AltaLink C8045 Multifunction Printer

./check_snmp_printer -v 3 -u [redacted] -a md5 -A [redacted] -x des -X [redacted] -H [redacted] --messages

Select Services to scan your job.

Check to see if your check_snmp_printer version is either v2.0.1 or v2.0.2:

./check_snmp_printer --version

./check_snmp_printer v2.0.2 (nagios-plugins 2.4.0) The nagios plugins come with ABSOLUTELY NO WARRANTY. You may redistribute copies of the plugins under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING.

v2.0.2 can be grabbed from the devel branch: https://github.com/Tylan/check_snmp_printer/blob/devel/check_snmp_printer

tgrymatt commented 1 year ago

Thanks for your quick reply! I tried the snmpget command you requested:

snmpget -v3 -On -l authPriv -u icinga -a md5 -A topsecret123 -x des -X topsecret123 my-office-printer 1.3.6.1.2.1.25.3.2.1.3.1

.1.3.6.1.2.1.25.3.2.1.3.1 = STRING: "Xerox AltaLink C8145 Multifunction Printer

I tried the v.2.0.2 version too, but unfortunately it does not work:

./check_snmp_printer_v2.0.2 -v 3 -u icinga -A topsecret123 -a md5 -X topsecret123 -x des -H my-office-printer --model
Can't call method "get" on an undefined value at ./check_snmp_printer_v2.0.2 line 270.
./check_snmp_printer --version

./check_snmp_printer v2.0.2 (monitoring-plugins 2.3.1) The Monitoring Plugins come with ABSOLUTELY NO WARRANTY. You may redistribute copies of the plugins under the terms of the GNU General Public License. For more information about these matters, see the file named COPYING.

Any idea or hint? Maybe I can produce some debug output to find the problem.

Tylan commented 1 year ago

Sorry for delay, I was working on adding some debug options to the code. Can you grab the new version:

https://github.com/Tylan/check_snmp_printer/blob/devel/check_snmp_printer

First, when you run it use at the end of your command: -d 1 --redact

Post those here. Then run it again with a -d 2 --redact and post the last 50 or so lines of that output. -d 2 will be mostly Net-SNMP debug logs so I cannot redact any sensitive information and you would have to do that manually.

The other thing I'd like to verify is that you installed the correct libraries for Debian:

sudo apt-get install snmp sudo apt-get install libsnmp-perl

you'll also probably have to install this Perl module:

cpan install Net::Ping::External

tgrymatt commented 1 year ago

Dear Tylan,

ITS FIXED! Thanks for your reply and the debug options. I tried as requested with -d 1 --redact

[Checking to see if host was entered as an IP address]
....it was not.
[Checking host for availability]
....color-laser-biogeo is reachable by ping.
[Converting host to an IP address]
....from: color-laser-biogeo
....to: <redacted_IP>
....conversion successful.
[Scrubbing data before printing to console....]
$VAR1 = {
          'Retries' => 3,
          'SecLevel' => 'authPriv',
          'UseNumeric' => '1',
          'SecName' => '<redacted_User>',
          'PrivPass' => '<redacted_PrivPass>',
          'PrivProto' => 'des',
          'DestHost' => '<redacted_IP>',
          'AuthProto' => 'md5',
          'RemotePort' => 161,
          'Version' => '3',
          'Timeout' => 3750000,
          'AuthPass' => '<redacted_AuthPass>'
        };
Can't call method "get" on an undefined value at ./check_snmp_printer line 457.

Unknown model, Serial #

That was not very helpfully for me. But the -d 2 option was extremely helpful!

(....)
netsnmp_ds_set_int: Setting LIB:4 = 1
error:snmp_new_v3_session:Unsupported authentication protocol(md5)
unable to create session at /usr/lib/x86_64-linux-gnu/perl5/5.28/SNMP.pm line 619.
Can't call method "get" on an undefined value at ./check_snmp_printer line 457.

Unknown model, Serial #

After the information with "Unsupported authentication protocol(md5)" I tried the following command:

./check_snmp_printer -v 3 -u icinga -A topsecret123 -a MD5 -X topsecret123 -x DES -H my-office-printer --messages

So I wrote DES and MD5 in upper case. And now it works:

Xerox AltaLink C8145 Multifunction Printer, Serial #

Yeah! Big thanks for your help!

Tylan commented 1 year ago

Woo! Glad you got it sorted out! That -d 2 is great just lots and lots of info to sift through LOL.

That's super weird it needed it in uppercase. I'll start experimenting with that and maybe put a check in for that on a future release.