# Undefined subroutine &SNMP_Session::inet_ntop called[SOLVED]

## Frautoincnam

Hi,

After updating my server, now mrtg gives me errors :

```
Undefined subroutine &SNMP_Session::inet_ntop called at /usr/lib64/perl5/vendor_perl/5.24.3/SNMP_Session.pm line 553.
```

I tried https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=781126 but it gives me another error :

```
SNMP Error:

no response received

SNMPv1_Session (remote host: "localhost" [::1].161)

                  community: "public"

                 request ID: 702487398

                PDU bufsize: 8000 bytes

                    timeout: 2s

                    retries: 5

                    backoff: 1)

 at /usr/lib64/perl5/vendor_perl/5.24.3/SNMP_util.pm line 492.

SNMPGET Problem for sysUptime sysName on public@localhost

 at /usr/bin/mrtg line 669.
```

so I reverted back.

The line which makes the error is :

```
/usr/bin/mrtg /etc/mrtg/cpu.cfg
```

and cpu.cfg is :

```
WorkDir: /var/log/www/mrtg

LoadMIBs: /usr/share/snmp/mibs/UCD-SNMP-MIB.txt

Target[localhost.01-cpu]:ssCpuRawUser.0&ssCpuRawUser.0:public@localhost + ssCpuRawSystem.0&ssCpuRawSystem.0:public@localhost + ssCpuRawNice.0&ssCpuRawNice.0:public@localhost

RouterUptime[localhost.01-cpu]: public@localhost

MaxBytes[localhost.01-cpu]: 100

Title[localhost.01-cpu]: CPU Load

PageTop[localhost.01-cpu]: <H1>Active CPU Load %</H1>

Unscaled[localhost.01-cpu]: ymwd

ShortLegend[localhost.01-cpu]: %

YLegend[localhost.01-cpu]: CPU Utilization

Legend1[localhost.01-cpu]: Active CPU in % (Load)

Legend2[localhost.01-cpu]:

Legend3[localhost.01-cpu]:

Legend4[localhost.01-cpu]:

LegendI[localhost.01-cpu]:  Active

LegendO[localhost.01-cpu]:

Options[localhost.01-cpu]: growright,nopercent,pngdate

Language: french
```

I don't know if the problem is with net-snmp (not updated) or SNMP_Session (not updated but contains /usr/lib64/perl5/vendor_perl/5.24.3/SNMP_Session.pm), or anything else...

I didn't modify any config file (except what needed for postfix update etc... but anything for snmp).

revdep-rebuild doesn't give anything to recompile.

List of ebuilds updated :

```
     Tue Sep 18 08:15:24 2018 >>> app-arch/bzip2-1.0.6-r10

     Tue Sep 18 08:15:42 2018 >>> dev-lang/python-exec-2.4.6

     Tue Sep 18 08:17:02 2018 >>> sys-devel/patch-2.7.6-r2

     Tue Sep 18 08:17:17 2018 >>> app-admin/eselect-1.4.13

     Tue Sep 18 08:21:20 2018 >>> dev-libs/openssl-1.0.2p

     Tue Sep 18 08:22:54 2018 >>> dev-db/sqlite-3.24.0

     Tue Sep 18 08:25:34 2018 >>> dev-lang/python-2.7.15

     Tue Sep 18 08:27:21 2018 >>> net-misc/curl-7.61.1

     Tue Sep 18 08:29:01 2018 >>> mail-mta/postfix-3.3.1-r1

     Tue Sep 18 08:30:27 2018 >>> sys-devel/bison-3.0.5-r1

     Tue Sep 18 08:33:10 2018 >>> net-libs/gnutls-3.5.19

     Tue Sep 18 08:33:28 2018 >>> app-portage/gemato-14.0

     Tue Sep 18 08:34:18 2018 >>> sys-apps/portage-2.3.49

     Tue Sep 18 09:07:25 2018 >>> sys-libs/timezone-data-2018e

     Tue Sep 18 09:07:55 2018 >>> sys-devel/make-4.2.1-r4

     Tue Sep 18 09:08:14 2018 >>> app-crypt/rhash-1.3.6-r1

     Tue Sep 18 09:08:32 2018 >>> dev-perl/Text-Unidecode-1.300.0

     Tue Sep 18 09:09:58 2018 >>> dev-db/mysql-connector-c-6.1.11-r1

     Tue Sep 18 09:15:14 2018 >>> dev-db/mysql-5.6.40-r2

     Tue Sep 18 09:21:04 2018 >>> net-mail/dovecot-2.3.2.1

     Tue Sep 18 09:30:01 2018 >>> dev-util/re2c-1.0.3

     Tue Sep 18 09:30:15 2018 >>> dev-perl/URI-1.730.0

     Tue Sep 18 09:30:36 2018 >>> dev-perl/NetAddr-IP-4.79.0

     Tue Sep 18 09:30:48 2018 >>> dev-perl/Net-CIDR-Lite-0.210.0-r1

     Tue Sep 18 09:31:02 2018 >>> dev-perl/XML-SAX-1.0.0

     Tue Sep 18 09:31:15 2018 >>> dev-perl/XML-SAX-Writer-0.570.0

     Tue Sep 18 09:31:27 2018 >>> dev-perl/Net-DNS-Resolver-Programmable-0.9.0

     Tue Sep 18 09:31:41 2018 >>> dev-perl/Net-DNS-SEC-1.30.0

     Tue Sep 18 09:32:12 2018 >>> mail-filter/spamassassin-3.4.1-r21

     Tue Sep 18 09:35:29 2018 >>> net-ftp/lftp-4.8.4

     Tue Sep 18 09:35:46 2018 >>> sys-apps/pciutils-3.5.6

     Tue Sep 18 09:57:53 2018 >>> app-vim/gentoo-syntax-20180821

     Tue Sep 18 09:59:11 2018 >>> app-admin/sudo-1.8.23-r2

     Tue Sep 18 10:05:05 2018 >>> sys-apps/memtest86+-5.01-r4

     Tue Sep 18 10:05:14 2018 >>> virtual/perl-Socket-2.20.30_rc-r2

     Tue Sep 18 10:05:27 2018 >>> dev-perl/Net-Ident-1.240.0-r1

     Tue Sep 18 10:11:10 2018 >>> sys-kernel/gentoo-sources-4.14.65

     Tue Sep 18 10:11:45 2018 >>> dev-perl/DBD-mysql-4.44.0

     Tue Sep 18 10:12:49 2018 >>> dev-libs/apr-1.6.3-r3

     Tue Sep 18 10:13:23 2018 >>> dev-libs/apr-util-1.6.1-r3

     Tue Sep 18 10:13:52 2018 >>> app-admin/apache-tools-2.4.34

     Tue Sep 18 10:15:35 2018 >>> www-servers/apache-2.4.34-r2

     Tue Sep 18 10:16:42 2018 >>> net-ftp/proftpd-1.3.6-r1

     Tue Sep 18 10:19:59 2018 >>> net-mail/dovecot-2.3.2.1

     Tue Sep 18 12:35:05 2018 >>> media-libs/libjpeg-turbo-1.5.3-r2

     Tue Sep 18 12:47:03 2018 >>> dev-lang/php-7.1.22

     Tue Sep 18 12:57:00 2018 >>> dev-lang/php-5.6.38

     Tue Sep 18 13:08:44 2018 >>> dev-lang/php-7.0.32

     Tue Sep 18 13:19:37 2018 >>> media-libs/libdvdcss-1.4.2

     Tue Sep 18 13:20:07 2018 >>> sys-apps/less-531

     Tue Sep 18 13:21:53 2018 >>> sys-apps/busybox-1.29.0

     Tue Sep 18 13:22:15 2018 >>> sys-apps/man-pages-4.16

     Tue Sep 18 13:23:31 2018 >>> sys-apps/diffutils-3.6-r1

     Tue Sep 18 13:23:51 2018 >>> dev-python/pbr-4.2.0-r1

     Tue Sep 18 13:24:59 2018 >>> dev-python/cryptography-2.2.2-r1

     Tue Sep 18 13:25:19 2018 >>> dev-perl/Socket6-0.280.0

     Tue Sep 18 13:25:29 2018 >>> virtual/perl-IO-Socket-IP-0.370.0-r3

     Tue Sep 18 13:25:43 2018 >>> dev-perl/Sys-CPU-0.610.0-r1

     Tue Sep 18 13:25:56 2018 >>> dev-perl/Sys-MemInfo-0.990.0

     Tue Sep 18 13:26:08 2018 >>> dev-perl/Sub-Name-0.210.0

     Tue Sep 18 13:26:20 2018 >>> dev-perl/Try-Tiny-0.300.0

     Tue Sep 18 13:26:33 2018 >>> dev-perl/WWW-RobotRules-6.20.0-r1

     Tue Sep 18 13:26:45 2018 >>> dev-perl/IO-Socket-INET6-2.720.0-r1

     Tue Sep 18 13:26:57 2018 >>> dev-perl/Net-SMTP-SSL-1.40.0

     Tue Sep 18 13:27:10 2018 >>> dev-perl/Net-HTTP-6.170.0

     Tue Sep 18 13:27:41 2018 >>> media-libs/libmng-2.0.3

     Tue Sep 18 13:27:51 2018 >>> dev-util/glib-utils-2.52.3

     Tue Sep 18 13:29:03 2018 >>> media-libs/libsdl2-2.0.8-r2

     Tue Sep 18 13:29:48 2018 >>> net-mail/fetchmail-6.3.26-r3

     Tue Sep 18 13:30:29 2018 >>> media-sound/mpg123-1.25.10-r1

     Tue Sep 18 13:32:04 2018 >>> net-misc/openssh-7.7_p1-r9

     Tue Sep 18 13:32:20 2018 >>> dev-libs/tinyxml2-6.2.0

     Tue Sep 18 13:32:40 2018 >>> dev-libs/yajl-2.1.0-r1

     Tue Sep 18 13:34:55 2018 >>> media-libs/libmediainfo-18.05

     Tue Sep 18 13:35:55 2018 >>> media-libs/fontconfig-2.13.0-r4

     Tue Sep 18 13:36:47 2018 >>> x11-libs/pango-1.42.4

     Tue Sep 18 13:49:39 2018 >>> dev-lang/php-7.2.10

     Tue Sep 18 13:50:28 2018 >>> net-print/cups-filters-1.20.4

     Tue Sep 18 13:53:42 2018 >>> media-gfx/imagemagick-7.0.8.11

     Tue Sep 18 13:54:25 2018 >>> dev-php/pecl-imagick-3.4.3

     Tue Sep 18 13:55:45 2018 >>> media-video/transcode-1.1.7-r3

     Tue Sep 18 13:56:07 2018 >>> dev-perl/libwww-perl-6.270.0

```

Any idea of what I can try ?

Thanks.Last edited by Frautoincnam on Thu Oct 04, 2018 2:14 pm; edited 1 time in total

----------

## araemo

After running updates this month, I'm having the same problem.

```
# /etc/cron.mrtg/traffic.sh

Undefined subroutine &SNMP_Session::inet_ntop called at /usr/lib64/perl5/vendor_perl/5.24.3/SNMP_Session.pm line 553.

```

Mine is in traffic.cfg instead of cpu.cfg.

I tried the same fix as you and got the same error as you:

```
# /etc/cron.mrtg/traffic.sh

SNMP Error:

no response received

SNMPv1_Session (remote host: "localhost" [::1].161)

                  community: "public"

                 request ID: 257999700

                PDU bufsize: 8000 bytes

                    timeout: 2s

                    retries: 5

                    backoff: 1)

 at /usr/lib64/perl5/vendor_perl/5.24.3/SNMP_util.pm line 492.

SNMPGET Problem for ifDescr.3 ifInOctets.3 ifDescr.3 ifOutOctets.3 sysUptime sysName on public@localhost:

 at /usr/bin/mrtg line 2330.

2018-10-03 21:35:23: WARNING: Could not match host:'public@localhost:' ref:'Descr' key:'wan0'

2018-10-03 21:35:23: WARNING: Could not match host:'public@localhost:' ref:'Descr' key:'lan0'

2018-10-03 21:35:23: WARNING: Could not match host:'public@localhost:' ref:'Descr' key:'dmz0'

2018-10-03 21:35:43: ERROR: Target[localhost_wan0][_IN_] ' $target->[0]{$mode} ' did not eval into defined data

2018-10-03 21:35:43: ERROR: Target[localhost_wan0][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data

2018-10-03 21:35:43: ERROR: Target[localhost_lan0][_IN_] ' $target->[1]{$mode} ' did not eval into defined data

2018-10-03 21:35:43: ERROR: Target[localhost_lan0][_OUT_] ' $target->[1]{$mode} ' did not eval into defined data

2018-10-03 21:35:43: ERROR: Target[localhost_dmz0][_IN_] ' $target->[2]{$mode} ' did not eval into defined data

2018-10-03 21:35:43: ERROR: Target[localhost_dmz0][_OUT_] ' $target->[2]{$mode} ' did not eval into defined data

```

... but I got past the snmp connection error after restarting snmpd for some reason.  (Technically I did edit the config, but I also reverted that change, and restated snmpd again, and I still don't get "no  response received" error.  I see both of us are seeing ::1 as the resolved address for 'localhost' in that error, but I do explicitly _not_ have my snmpd listening on ipv6.  I suspect that is the cause of the SNMP error.

However, I'm now still seeing the warnings and errors above:

```
# /etc/cron.mrtg/traffic.sh

2018-10-03 22:11:46: WARNING: Could not match host:'public@localhost:' ref:'Descr' key:'wan0'

2018-10-03 22:11:46: WARNING: Could not match host:'public@localhost:' ref:'Descr' key:'lan0'

2018-10-03 22:11:46: WARNING: Could not match host:'public@localhost:' ref:'Descr' key:'dmz0'

2018-10-03 22:11:56: ERROR: Target[localhost_wan0][_IN_] ' $target->[0]{$mode} ' did not eval into defined data

2018-10-03 22:11:56: ERROR: Target[localhost_wan0][_OUT_] ' $target->[0]{$mode} ' did not eval into defined data

2018-10-03 22:11:56: ERROR: Target[localhost_lan0][_IN_] ' $target->[1]{$mode} ' did not eval into defined data

2018-10-03 22:11:56: ERROR: Target[localhost_lan0][_OUT_] ' $target->[1]{$mode} ' did not eval into defined data

2018-10-03 22:11:56: ERROR: Target[localhost_dmz0][_IN_] ' $target->[2]{$mode} ' did not eval into defined data

2018-10-03 22:11:56: ERROR: Target[localhost_dmz0][_OUT_] ' $target->[2]{$mode} ' did not eval into defined data

```

I verified that snmp is listening 

My list of updated packages:

```
     Tue Oct  2 00:43:57 2018 >>> dev-lang/python-exec-2.4.6

     Tue Oct  2 00:44:36 2018 >>> dev-util/re2c-1.0.3

     Tue Oct  2 00:46:43 2018 >>> dev-lang/go-1.10.3

     Tue Oct  2 00:46:58 2018 >>> sys-kernel/linux-firmware-20180825

     Tue Oct  2 00:47:15 2018 >>> dev-libs/libbsd-0.9.1

     Tue Oct  2 00:47:23 2018 >>> app-admin/eselect-1.4.13

     Tue Oct  2 00:47:37 2018 >>> sys-apps/less-531

     Tue Oct  2 00:47:41 2018 >>> dev-util/glib-utils-2.52.3

     Tue Oct  2 00:47:53 2018 >>> sys-apps/man-pages-4.16

     Tue Oct  2 00:48:04 2018 >>> app-vim/gentoo-syntax-20180821

     Tue Oct  2 00:48:58 2018 >>> sys-devel/bison-3.0.5-r1

     Tue Oct  2 00:49:44 2018 >>> app-editors/nano-2.9.8

     Tue Oct  2 00:50:14 2018 >>> sys-apps/iproute2-4.17.0

     Tue Oct  2 00:50:35 2018 >>> media-libs/gd-2.2.5-r1

     Tue Oct  2 00:53:36 2018 >>> dev-libs/openssl-1.0.2p

     Tue Oct  2 00:53:42 2018 >>> sys-apps/lsb-release-1.4-r3

     Tue Oct  2 00:53:48 2018 >>> dev-perl/X11-Protocol-0.560.0-r1

     Tue Oct  2 00:53:54 2018 >>> dev-perl/Text-Iconv-1.700.0-r2

     Tue Oct  2 00:53:59 2018 >>> virtual/perl-IO-Socket-IP-0.370.0-r3

     Tue Oct  2 00:54:03 2018 >>> virtual/perl-Time-HiRes-1.974.100-r2

     Tue Oct  2 00:54:22 2018 >>> dev-libs/dbus-glib-0.110

     Tue Oct  2 00:54:28 2018 >>> dev-perl/XML-XPath-1.130.0-r1

     Tue Oct  2 00:54:35 2018 >>> net-libs/miniupnpc-2.0.20180503

     Tue Oct  2 00:54:50 2018 >>> x11-misc/shared-mime-info-1.10

     Tue Oct  2 00:54:58 2018 >>> sys-apps/help2man-1.47.6

     Tue Oct  2 00:55:04 2018 >>> dev-perl/Tie-IxHash-1.230.0

     Tue Oct  2 00:55:10 2018 >>> dev-perl/IO-Socket-INET6-2.720.0-r1

     Tue Oct  2 00:55:16 2018 >>> dev-perl/Net-SMTP-SSL-1.40.0

     Tue Oct  2 00:57:31 2018 >>> dev-lang/python-2.7.15

     Tue Oct  2 00:57:37 2018 >>> dev-perl/Net-HTTP-6.170.0

     Tue Oct  2 00:59:02 2018 >>> net-misc/curl-7.61.1

     Tue Oct  2 00:59:51 2018 >>> dev-libs/apr-1.6.3-r3

     Tue Oct  2 01:00:12 2018 >>> dev-libs/nspr-4.19

     Tue Oct  2 01:00:58 2018 >>> media-libs/tiff-4.0.9-r4

     Tue Oct  2 01:02:34 2018 >>> app-portage/eix-0.33.2

     Tue Oct  2 01:03:14 2018 >>> x11-libs/libxcb-1.13.1

     Tue Oct  2 01:05:39 2018 >>> dev-libs/nss-3.37.3

     Tue Oct  2 01:05:58 2018 >>> app-crypt/pinentry-1.1.0-r2

     Tue Oct  2 01:06:23 2018 >>> sys-apps/portage-2.3.49

     Tue Oct  2 01:06:30 2018 >>> dev-perl/XML-Twig-3.520.0

     Tue Oct  2 01:06:39 2018 >>> dev-perl/Net-DBus-1.1.0

     Tue Oct  2 01:06:53 2018 >>> x11-misc/xdg-utils-1.1.3-r1

     Tue Oct  2 01:07:10 2018 >>> www-client/google-chrome-69.0.3497.100

     Tue Oct  2 01:07:50 2018 >>> net-print/cups-filters-1.20.4

     Tue Oct  2 01:09:12 2018 >>> dev-util/android-tools-8.1.0_p1

     Tue Oct  2 01:09:32 2018 >>> sys-apps/openrc-0.38.2

     Tue Oct  2 01:10:29 2018 >>> dev-db/mysql-connector-c-6.1.11-r1

     Tue Oct  2 01:10:51 2018 >>> dev-libs/apr-util-1.6.1-r3

     Tue Oct  2 01:11:11 2018 >>> app-admin/apache-tools-2.4.34

     Tue Oct  2 01:12:36 2018 >>> www-servers/apache-2.4.34-r2

     Tue Oct  2 01:19:57 2018 >>> dev-db/mysql-5.6.40-r2

     Tue Oct  2 01:39:02 2018 >>> dev-lang/php-7.2.10

     Tue Oct  2 01:39:07 2018 >>> virtual/httpd-php-7.2

     Wed Oct  3 21:55:59 2018 >>> dev-perl/Date-Manip-6.600.0

     Wed Oct  3 21:56:04 2018 >>> app-portage/genlop-0.30.9-r1

```

And, for what it's worth, that MRTG config last ran at Tue Oct  2 00:51, so it would be one of the packages between 00:50 and 00:55 that broke it.

So.. I tried downgrading dev-perl/IO-Socket-INET6-2.720.0-r1 and virtual/perl-IO-Socket-IP-0.370.0-r3, but those were apparently NEW in my october 2nd emerge.

So, I looked at their revdeps, and found Net-HTTP-6.170.0 pulled them in. So I downgraded dev-perl/Net-HTTP-6.170.0 to dev-perl/Net-HTTP-6.90.0.

```

sudo emerge -va1 =dev-perl/Net-HTTP-6.90.0

sudo emerge -cav 'virtual/perl-IO-Socket-IP' 'dev-perl/IO-Socket-INET6'

```

After doing that, my mrtg runs again, even with the original SNMP_Session.pm.

```
# /etc/cron.mrtg/traffic.sh

2018-10-03 22:41:21: WARNING: IPv6 libraries not found, IPv6 disabled.

```

(And I see the stats updating on the web site)

so... I think perl-IO-Socket-IP/IO-Socket-INET6 is what caused this by causing MRTG to attempt to use ipv6 to talk to snmp.  (And also breaking SNMP_Session.pm)

But for some reason I can't get snmp to work over ipv6.  I added a udp6 listener to my snmpd.conf, verified that it shows up in netstat after restart snmpd, but snmpwalk cannot hit it.

I'm not even sure where to go next to submit bug reports...  Can anyone help out here?

----------

## araemo

replying to my own post.. but...

I think I found the true root cause here, even though the original error (undefined subroutine) is a bug that should be reported (and looks like it's on its way upstream).

If I get snmpd responding on ipv6, I don't get the undefined subroutine error.  If I turn off ipv6, it comes back.

So, how did I get snmpd listening on ivp6 loopback?

Two additions to /etc/snmp/snmpd.conf:

add "udp6:[::1]:161" to "agentAddress:

before:

```
agentAddress  udp:127.0.0.1:161
```

after:

```
agentAddress  udp:127.0.0.1:161,udp6:[::1]:161
```

And add "rocommunity6"

before:

```
rocommunity public  localhost

```

after:

```
rocommunity public  localhost

rocommunity6 public  localhost

```

Restart snmpd, and mrtg is back to normal.

It's worth noting that even without these changes, you'll see snmpd listening on ::1 in netstat, which looks odd, but it doesn't respond without these kinds of directives in the config file.

So, the "Undefined subroutine &SNMP_Session::inet_ntop" error is only called when there's an error running the snmp query, I think.

----------

## Frautoincnam

Thanks for your help.

The only solution that worked for me were to downgrade Net-HTTP.

I don't have IPV6 on my system. I tried to add use ipv6 to snmp, modified config as you suggested, but same error.

I don't really know what bug to create on https://bugs.gentoo.org/, and my english is not very good. May be can you do it.

----------

## araemo

 *Frautoincnam wrote:*   

> Thanks for your help.
> 
> The only solution that worked for me were to downgrade Net-HTTP.
> 
> I don't have IPV6 on my system. I tried to add use ipv6 to snmp, modified config as you suggested, but same error.
> ...

 

Another option for you would be to change your cpu.cfg, and change all instances of 'localhost' to '127.0.0.1' (I think?)  I'm not terribly clear on the syntax of the mrtg config files, but that should force it to use ipv4, I think.

Do you truly have no ipv6 support?  'ifconfig lo' doesn't show you a inet6 addr of ::1?

You don't need a routable or even link-local ipv6 addr for the kernel to support ipv6 loopback, and that's all you would need for the fix I suggested.

If you DON'T have ::1 on lo, but have ::1 listed in /etc/hosts, that seems like a bug/misconfiguration, and you should probably change /etc/hosts.

----------

## Frautoincnam

 *araemo wrote:*   

> Do you truly have no ipv6 support?  'ifconfig lo' doesn't show you a inet6 addr of ::1?

 

Really  :Smile: 

```
# ifconfig lo

lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536

        inet 127.0.0.1  netmask 255.0.0.0

        loop  txqueuelen 1000  (Boucle locale)

        RX packets 51825901  bytes 85745072041 (79.8 GiB)

        RX errors 0  dropped 0  overruns 0  frame 0

        TX packets 51825901  bytes 85745072041 (79.8 GiB)

        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0
```

-ipv6 in global USE.

 *Quote:*   

> If you DON'T have ::1 on lo, but have ::1 listed in /etc/hosts, that seems like a bug/misconfiguration, and you should probably change /etc/hosts.

 

Oh ! Thank you for pointing that. That was it. I just 

- removed "::1            localhost" from /etc/hosts

- reverted back to my snmp config and net-snmp USE

and all works fine now.

So, it was my fault, not a bug.

Thanks again for your help.

----------

