SNMP over TCP (snmp works cacti doesn't)

Post general support questions here that do not specifically fall into the Linux or Windows categories.

Moderators: Developers, Moderators

Post Reply
WayneB
Posts: 3
Joined: Tue Feb 09, 2010 1:53 am

SNMP over TCP (snmp works cacti doesn't)

Post by WayneB »

Hi

First off I'm new to all things Cacti and snmp, although we have been running it it our company for some time I have only recently started administrating it.

Anyhow, we have a new project which involves monitoring servers over TCP, pretty much exactly as described in this howto (http://forums.cacti.net/viewtopic.php?t ... p+over+tcp)

The first step for us however is just to get one local server being monitored over TCP i.e. without the tunnelling.
I have followed the steps in the HOW TO and have managed to get as getting a successful response from a manual snmpwalk

Code: Select all

 C:\>snmpwalk -v 1 -c myc tcp:10.xxx.xxx.xxx:1161 sysname
SNMPv2-MIB::sysName.0 = STRING: myhost
However when I configure the host device in Cacti with the appropriate community and set the the hostname to tcp:10.xxx.xxx.xxx:1161 I get a SNMP error

We have just upgraded from 0.8.7.a to 0.8.7.e

Please help :(
User avatar
BSOD2600
Cacti Moderator
Posts: 12171
Joined: Sat May 08, 2004 12:44 pm
Location: USA

Post by BSOD2600 »

In the snmp port field, trying using: tcp:1161
WayneB
Posts: 3
Joined: Tue Feb 09, 2010 1:53 am

Post by WayneB »

BSOD2600 wrote:In the snmp port field, trying using: tcp:1161
unfortunately the SNMP port field can only accept 5 characters, so I can only get as far as tcp:1


If I go into Cacti Settings I can set the default SNMP port to tcp:1161, which then gets inserted into the snmp port field when I add a new device, however, I get an error on the field when I try save/create the device.
User avatar
gandalf
Developer
Posts: 22383
Joined: Thu Dec 02, 2004 2:46 am
Location: Muenster, Germany
Contact:

Post by gandalf »

BSOD2600 wrote:In the snmp port field, trying using: tcp:1161
So try using "<hostname> tcp:1161" instead of "<hostname>" in the host name field
R.
WayneB
Posts: 3
Joined: Tue Feb 09, 2010 1:53 am

Post by WayneB »

gandalf wrote:
BSOD2600 wrote:In the snmp port field, trying using: tcp:1161
So try using "<hostname> tcp:1161" instead of "<hostname>" in the host name field
R.
That's one combination I hadn't tried yet, but alas it still doesn't work :(

I've tried
tcp:<hostname>:1161
<hostname>:1161
tcp:<hostname>
<hostname> tcp:1161
<hostname>:tcp:1161
tcp:1161:<hostname>
tcp:1161 <hostname>

I have also tried all the above combinations with <hostip>

....any other suggestions?
procyon
Posts: 1
Joined: Thu Feb 11, 2010 2:57 am

Post by procyon »

I had a similar problem with 0.8.7e. I'm using PHP 5.3.1, and SNMP v3. After some tracing, it looks like the PHP snmp3_get function was blowing up with the tcp:hostname syntax. I altered the snmp_get_method function in lib/snmp.php to force it to return SNMP_METHOD_BINARY and everything started working.

Not sure if that helps you, but it worked for me.
chefchanyu
Cacti User
Posts: 153
Joined: Wed Aug 25, 2010 11:07 pm

Re: SNMP over TCP (snmp works cacti doesn't)

Post by chefchanyu »

Hi all:

i had same issue. please help me to fix this issue.
mitkodotcom
Posts: 1
Joined: Tue Nov 20, 2018 11:15 am

Re: SNMP over TCP (snmp works cacti doesn't)

Post by mitkodotcom »

I have "fixed" this problem by editing /usr/share/cacti/site/lib/snmp.php

Replace all occurrences of:

if ((snmp_get_method($version) == SNMP_METHOD_PHP)

with

if ((snmp_get_method($version,$hostname) == SNMP_METHOD_PHP)


Also replace

function snmp_get_method($version = 1,$hostname = '') {
if ((function_exists("snmpget")) && ($version == 1)) {
return SNMP_METHOD_PHP;
}else if ((function_exists("snmp2_get")) && ($version == 2)) {
return SNMP_METHOD_PHP;

with

function snmp_get_method($version = 1,$hostname = '') {
if ((function_exists("snmpget")) && ($version == 1)) {
return SNMP_METHOD_PHP;
}else if ((function_exists("snmp2_get")) && ($version == 2)) {
if (substr($hostname,0,4) == "tcp:") return SNMP_METHOD_BINARY;
else return SNMP_METHOD_PHP;

However this is a temporary "solution" as this file will be replaced with the next upgrade.
netniV
Cacti Guru User
Posts: 3441
Joined: Sun Aug 27, 2017 12:05 am

Re: SNMP over TCP (snmp works cacti doesn't)

Post by netniV »

Submit that as a PR to GitHub and it'll likely get merged.
Cacti Developer & Release Manager
The Cacti Group

Director
BV IT Solutions Ltd

+--------------------------------------------------------------------------+

Cacti Resources:
Cacti Website (including releases)
Cacti Issues
Cacti Development Releases
Cacti Development Documentation
Post Reply

Who is online

Users browsing this forum: No registered users and 2 guests