SNMP Issue with hostnames VS IPs
Moderators: Developers, Moderators
SNMP Issue with hostnames VS IPs
To put it really simply - if I use a numeric IP address in the hostname field of a device, everything works fine. If I put in the name of the box (just the name, FQDN, or anything else that resolves to an IP) into the hostname field, nothing works. The "SNMP Information" field at the top of the device just says "SNMP error" and running a Data Query against it gives a "No SNMP data returned" error. From an SSH terminal I can ping and snmpwalk all of my hosts by name, FQDN, or IP - it does not appear to be a DNS issue on the cacti box.
I use the |host_hostname| field in a lot of my graph titles, and I'd really prefer to have names that mean something in there rather than having to use 111.222.333.444 style names all over, and have meaningless titles on my graphs.
Any ideas?
I use the |host_hostname| field in a lot of my graph titles, and I'd really prefer to have names that mean something in there rather than having to use 111.222.333.444 style names all over, and have meaningless titles on my graphs.
Any ideas?
Same issue here. I have a ton of servers in that have no problems with snmp queries. I can snmpwalk the server from the command line using the FQDN. But cacti complains & spits out Problem initializing snmp session 'servername'
If I put in the IP, it works fine. This shouldn't be the case. I can ping this server by FQDN as well as snmpwalk it from the command line. I am rebuilding httpd & php from src since I was using the rpm packages installed. All my other builds I use built from source packages. Not sure if this is the issue but I'll find out soon enough.
If I put in the IP, it works fine. This shouldn't be the case. I can ping this server by FQDN as well as snmpwalk it from the command line. I am rebuilding httpd & php from src since I was using the rpm packages installed. All my other builds I use built from source packages. Not sure if this is the issue but I'll find out soon enough.
I had similiar problem. My Cacti worked fine for a month. Then all graphs I had configured worked fine, but all devices had SNMP Error and I couldnt rescan interfaces. Newly added devices had the same problem.Even I put IP Address instead of FQDN in hostname situation didn't get better. Then I put configuration found in another topic, and since then everything has been working fine:
Code: Select all
; variable in order to use PHP's session functions.
;session.save_path = /var/lib/php/session
session.save_path = /tmp
After searching around and finding out that session.save_path is a setting in php.ini and isn't directly accessed anywhere in the cacti code, I also found out that mine is already set to use /tmp, which seems to be the default. I didn't bother moving it around to see if it would make a difference, however I did verify that the permissions in /tmp are correct, and php is properly creating session files in there.
Ok - some further information...
I've gone into the host.php file and found the section of code responsible for displaying the SNMP summary at the top of the edit-device page. For people not familiar with it, that section basically does an SNMP get of ".1.3.6.1.2.1.1.1.0" for the host, if the result is empty it display's "SNMP Error", else it gets the rest of the information and shows the little system summary.
So I started inserting code into the section that prints the error message. Mine now also prints all the related variables passed to cacti_snmp_get() (and yes they are all correct), and also makes a couple of extra cacti_snmp_get() calls with parameters that I've hard-coded in place. When it's called with a hostname it fails, when called with a numeric IP address it succeeds. I also went over the cacti_snmp_get() function in snmp.php and verified that it doesn't do anything with hostname except pass it to (in my case) snmpget() or snmp2_get().
And the final bit of testing, which really just confuses me more at this point... I created a test.php, and copied the includes section from host.php, but left it otherwize blank. test.php only makes 1 call, to cacti_snmp_get() with parameters hard-coded just like I did in my debug section above in host.php. Running that file from the shell (as either root or the user cacti runs as) cacti_snmp_get() returns the proper result using either a hostname or an IP address.
And now I'm about stuck about what to look at next. I'm far from an expert PHP programmer, and the documentation for the SNMP api is pretty much non-existant. Anyone else have any idea's why the cacti_snmp_get() function is acting differently when called from the shell instead of through apache?
Edit: My little test script altered slightly to run through apache behaves the same as host.php - ip's work, names are broken. There is some difference with the way that function reacts depending on whether it's run through apache or not. But I don't even know where to start looking to figure out what that might be.
I've gone into the host.php file and found the section of code responsible for displaying the SNMP summary at the top of the edit-device page. For people not familiar with it, that section basically does an SNMP get of ".1.3.6.1.2.1.1.1.0" for the host, if the result is empty it display's "SNMP Error", else it gets the rest of the information and shows the little system summary.
So I started inserting code into the section that prints the error message. Mine now also prints all the related variables passed to cacti_snmp_get() (and yes they are all correct), and also makes a couple of extra cacti_snmp_get() calls with parameters that I've hard-coded in place. When it's called with a hostname it fails, when called with a numeric IP address it succeeds. I also went over the cacti_snmp_get() function in snmp.php and verified that it doesn't do anything with hostname except pass it to (in my case) snmpget() or snmp2_get().
And the final bit of testing, which really just confuses me more at this point... I created a test.php, and copied the includes section from host.php, but left it otherwize blank. test.php only makes 1 call, to cacti_snmp_get() with parameters hard-coded just like I did in my debug section above in host.php. Running that file from the shell (as either root or the user cacti runs as) cacti_snmp_get() returns the proper result using either a hostname or an IP address.
And now I'm about stuck about what to look at next. I'm far from an expert PHP programmer, and the documentation for the SNMP api is pretty much non-existant. Anyone else have any idea's why the cacti_snmp_get() function is acting differently when called from the shell instead of through apache?
Edit: My little test script altered slightly to run through apache behaves the same as host.php - ip's work, names are broken. There is some difference with the way that function reacts depending on whether it's run through apache or not. But I don't even know where to start looking to figure out what that might be.
Who is online
Users browsing this forum: No registered users and 0 guests