Perl SNMP_Session.pm Exporter error

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
chriscamm
Posts: 72
Joined: Thu Aug 22, 2013 6:12 am

Re: Perl SNMP_Session.pm Exporter error

Post by chriscamm »

Hi Steve,

I was already up to date on cpan so I have made the change.

I will let you know

Thanks

Chris
chriscamm
Posts: 72
Joined: Thu Aug 22, 2013 6:12 am

Re: Perl SNMP_Session.pm Exporter error

Post by chriscamm »

Still get this after updating all three files

Code: Select all

syntax error at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 50, near "/usr/local"
Compilation failed in require at /usr/bin/../lib/mrtg2/SNMP_util.pm line 46.
BEGIN failed--compilation aborted at /usr/bin/../lib/mrtg2/SNMP_util.pm line 46.
Compilation failed in require at /usr/bin/../lib/mrtg2/MRTG_lib.pm line 662.
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Perl SNMP_Session.pm Exporter error

Post by SteveBeauchemin »

Don't forget - the error changed after you were asked to edit the files, making a change to some lib.
I have added use lib /usr/local/share/perl5; to all 3 files for SNMP_Session.pm
That then changed the error to some other failure.
You introduced a compile error...

You need to get back to the "subroutine redefined" error. Look back to your original posts.

Once you remove that edit, you have a better chance to fix the original problem.

Thanks

Steve B
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
chriscamm
Posts: 72
Joined: Thu Aug 22, 2013 6:12 am

Re: Perl SNMP_Session.pm Exporter error

Post by chriscamm »

Hi Steve,

I edited the three SNMP_Session.pm files and removed the use lib /usr/local/share/perl5;

I now get the following errors:

Code: Select all

Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
syntax error at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 654, near ") {"
Global symbol "$socket" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 684.
Global symbol "$socket" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 685.
Global symbol "$community" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 686.
Global symbol "$remote_hostname" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 687.
Global symbol "$remote_addr" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 688.
Global symbol "$sockfamily" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 689.
Global symbol "$max_pdu_len" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 690.
Global symbol "$max_pdu_len" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 691.
Global symbol "$max_repetitions" requires explicit package name at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 700.
syntax error at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 708, near "}"
/usr/bin/../lib/mrtg2/SNMP_Session.pm has too many errors.
Compilation failed in require at /usr/bin/../lib/mrtg2/SNMP_util.pm line 46.
BEGIN failed--compilation aborted at /usr/bin/../lib/mrtg2/SNMP_util.pm line 46.
Compilation failed in require at /usr/bin/../lib/mrtg2/MRTG_lib.pm line 662.
Thanks

Chris
tmcdonald
Posts: 9117
Joined: Mon Sep 23, 2013 8:40 am

Re: Perl SNMP_Session.pm Exporter error

Post by tmcdonald »

Try this (exact keystrokes, my comments after # should be ignored):

Code: Select all

vi /usr/bin/../lib/mrtg2/SNMP_Session.pm
:708
#You should be on a "}"
%
#Let us know what line is shown, it should be "sub open {" otherwise you might see an error at the bottom, post that here
:q
Former Nagios employee
chriscamm
Posts: 72
Joined: Thu Aug 22, 2013 6:12 am

Re: Perl SNMP_Session.pm Exporter error

Post by chriscamm »

Hi I have sorted the line error I have put an extra character in

Here is the code now

Code: Select all

Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
chriscamm
Posts: 72
Joined: Thu Aug 22, 2013 6:12 am

Re: Perl SNMP_Session.pm Exporter error

Post by chriscamm »

Hi it does not matter which of these I put in to both lines I get the same errors

Code: Select all

1) import Socket6;
versus
2) Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));
versus
3) Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo unpack_sockaddr_in6));
jdalrymple
Skynet Drone
Posts: 2620
Joined: Wed Feb 11, 2015 1:56 pm

Re: Perl SNMP_Session.pm Exporter error

Post by jdalrymple »

SteveBeauchemin wrote:I did one other thing, but am not sure it fixed anything.
I updated IO::Socket::INET6 from CPAN

Code: Select all

cpan -i IO::Socket::INET6

Steve B
Did you per chance try that?
SteveBeauchemin
Posts: 524
Joined: Mon Oct 14, 2013 7:19 pm

Re: Perl SNMP_Session.pm Exporter error

Post by SteveBeauchemin »

I suspect that edits to your file may be causing some grief. I do not really know. but... read on.

I am in the middle of setting up a new Nagios XI 5 system.
So far, I have proven that it has this same MRTG problem with perl Subroutine complaints.
I am carefully fixing it and writing down each step I take.

First I am 'finding' all the suspicious files as the root user.

Code: Select all

cd /
find . -name SNMP_Session.pm
./usr/lib/mrtg2/SNMP_Session.pm
./usr/lib64/mrtg2/SNMP_Session.pm
./usr/share/perl5/vendor_perl/SNMP_Session.pm

So I have 3 files. I am copying them to a safe location for posterity, and in
case I need to revert. I do this because of many lessons learned where I thought I
would not need the old file. I am also changing the name to reflect the source location.

Code: Select all

cp /usr/lib/mrtg2/SNMP_Session.pm /tmp/SNMP_Session.pm-lib
cp /usr/lib64/mrtg2/SNMP_Session.pm /tmp/SNMP_Session.pm-lib64
cp /usr/share/perl5/vendor_perl/SNMP_Session.pm /tmp/SNMP_Session.pm-vendor
I am just checking to see which one runs clean.

From the /etc/cron.d/mrtg file I get the run syntax

Code: Select all

/usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
Without copying anything I want to see which file is used from what location.
When I run that line I can see from the error that it is using the file from /usr/lib/mrtg2
So I can eliminate that /lib/ file as a candidate.

It gives me 6 errors of this flavor. Not identical, but more than zero is too many.

Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/share/perl5/vendor_perl/Exporter.pm line 66.
at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.

From my safe location, I can copying over the bad file. Trying the vendor file first.
Actually copied over all the files. I made sure all 3 were the same.

cp /tmp/SNMP_Session.pm-vendor /usr/lib/mrtg2
cp /tmp/SNMP_Session.pm-vendor /usr/lib64/mrtg2
cp /tmp/SNMP_Session.pm-vendor /usr/share/perl5/vendor_perl

Ran the mrtg test line and no good. Similar problem, but only subroutine 4 errors.
Trying the lib64 file next. Last file - it's always the last one you try...

Code: Select all

cp /tmp/SNMP_Session.pm-lib64 /usr/lib/mrtg2/
cp /tmp/SNMP_Session.pm-lib64 /usr/lib64/mrtg2/
cp /tmp/SNMP_Session.pm-lib64 /usr/share/perl5/vendor_perl
Now when I run the command it does not complain any more.

So I had 3 files with different innards. Tried them each one at a time.
Found one that does not have perl errors during execution.

I suggest you copy your files somewhere in case they have edits.
I have attached the file I ended up using.

To recap, my locations are these. Yours could be different.
/usr/lib/mrtg2/
/usr/lib64/mrtg2/
/usr/share/perl5/vendor_perl/

Each of those locations should have the SNMP_Session.pm file replaced.

That's my story, and I'm sticking to it.

Please see attached.

Steve B
You do not have the required permissions to view the files attached to this post.
XI 5.7.3 / Core 4.4.6 / NagVis 1.9.8 / LiveStatus 1.5.0p11 / RRDCached 1.7.0 / Redis 3.2.8 /
SNMPTT / Gearman 0.33-7 / Mod_Gearman 3.0.7 / NLS 2.0.8 / NNA 2.3.1 /
NSClient 0.5.0 / NRPE Solaris 3.2.1 Linux 3.2.1 HPUX 3.2.1
chriscamm
Posts: 72
Joined: Thu Aug 22, 2013 6:12 am

Re: Perl SNMP_Session.pm Exporter error

Post by chriscamm »

Hi,

So I reverted back to my original files

I then did:

Code: Select all

cp /usr/lib/mrtg3/SNMP_Session.pm /tmp/SNMP_Session.pm-lib
cp /usr/lib64/mrtg3/SNMP_Session.pm /tmp/SNMP_Session.pm-lib64
cp /usr/share/perl5/SNMP_Session.pm /tmp/SNMP_Session.pm-perl5
Then I ran

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
Here is the output

Code: Select all

Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
Now I copied the lib64 backup over the existing files:

Code: Select all

 cp /tmp/SNMP_Session.pm-lib64 /usr/lib/mrtg2/SNMP_Session.pm
cp /tmp/SNMP_Session.pm-lib64 /usr/lib64/mrtg2/SNMP_Session.pm
cp /tmp/SNMP_Session.pm-lib64 /usr/share/perl5/SNMP_Session.pm
This is the output of the next run:

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
So I tried with the last one:

Code: Select all

 cp /tmp/SNMP_Session.pm-perl5 /usr/lib/mrtg2/SNMP_Session.pm
cp /tmp/SNMP_Session.pm-perl5 /usr/lib64/mrtg2/SNMP_Session.pm
 cp /tmp/SNMP_Session.pm-perl5 /usr/share/perl5/SNMP_Session.pm
Here is the output

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
Subroutine SNMP_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMP_Session::unpack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMP_Session::sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 149.
Subroutine SNMPv1_Session::pack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
Subroutine SNMPv1_Session::unpack_sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
Subroutine SNMPv1_Session::sockaddr_in6 redefined at /usr/local/share/perl5/Exporter.pm line 66.
 at /usr/bin/../lib/mrtg2/SNMP_Session.pm line 604.
So looking at this the lib64 looks to be the closest to correcting the problems so what does line 149 and 604 say in this version of the file:

Code: Select all

Line 149

Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));

Line 604

Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));
Now in the text file Steve so kindly uploaded his line 149 and 604 are as follows:

Code: Select all

Socket6->import(qw(inet_pton getaddrinfo inet_ntop));
Not sure where that line came from as that is not in any of my files at all? In fact the original dates of the files I have are:

Code: Select all

ls -lah /usr/lib/mrtg2/SNMP_Session.pm
-rw-r--r-- 1 root root 35K Jun  1  2014 /usr/lib/mrtg2/SNMP_Session.pm
ls -lah /usr/lib64/mrtg2/SNMP_Session.pm
-rw-r--r-- 1 root root 35K Nov 12  2012 /usr/lib64/mrtg2/SNMP_Session.pm
ls -lah /usr/share/perl5/SNMP_Session.pm
-rw-r--r-- 1 root root 35K Mar 19  2008 /usr/share/perl5/SNMP_Session.pm
So not sure if a newer version of the files should have come down in the upgrade from 4 to 5 or if there a package to update for the installation?

Next step is to replace lines 149 and 604 with the lines provided by Steve B in his attachment and now this is the output

Code: Select all

Replaced:

Socket6->import(qw(pack_sockaddr_in6 inet_pton getaddrinfo));

With:

Socket6->import(qw(inet_pton getaddrinfo inet_ntop));
Here is the output now:

Code: Select all

LANG=C LC_ALL=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg --lock-file /var/lock/mrtg/mrtg_l --confcache-file /var/lib/mrtg/mrtg.ok
Interested to know where the new code line came from

Thanks very much to Steve and everyone else for there help getting to the bottom of this. Much appreciated.
Locked