[problem] PHP & SNMP - Tree of Souls - An Avatar Community Forum
Tree of Souls - An Avatar Community Forum
Go Back   Tree of Souls - An Avatar Community Forum » General Forums » Development

Reply
 
LinkBack Thread Tools Display Modes
  #1  
Old 01-30-2011, 01:29 PM
MGCJerry's Avatar
needs a life :þ
MGCJerry is gone
 
Join Date: Mar 2010
Posts: 86
Default [problem] PHP & SNMP

I would post this on another site, but the site I usually post my programming discussions has really gone downhill the past several years. So, I'm going to give you guys a shot since there's some pretty savvy people here.

I'm trying to get PHP to pull SNMP data off my network switch to show information. I have installed Perl & MRTG on my main server "Ettin" and MRTG works great, it has no problems querying the switch. I've already setup a simple PHP script to show a table of ports instead of the normal Apache directory listing. You can see the results for that here

Now when trying to use PHP to get SNMP data, PHP times out. Maximum execution time exceeded. Anyone have any ideas how to get PHP to talk to SNMP?

Here's what I've done:
* Enabled "php_snmp.dll" in "php.ini".
* Restarted Apache
* Switch management IP, "192.168.0.4"
* SNMP community, "public" <-- at least it works with MRTG

Relevant Server Specs:
* Windows Server 2003
* Apache 1.3
* PHP 5.2.14
* Perl 5.12.2

Switch Specs (copied from Identify):
* Product: HP J4813A ProCurve Switch 2524
* Version: revision F.05.55, ROM F.02.01 (/sw/code/build/info(s02))
* IP Address: 192.168.0.4

Additional information:
I have "root" access to this server, so if I need to install additional software I can.
__________________
Don't like what I say? Click HERE to add me to your ignore list.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #2  
Old 02-02-2011, 09:18 PM
Sight Unseen's Avatar
Nawmtu
Sight Unseen now has an updated status.
 
Join Date: Mar 2010
Location: Texas, eventually Pandora.
Posts: 1,149
Default

I'll bite, even though I've never done anything like this. I've never had to deal too much with managed switches, or snmp for that matter, but I'll try to help. Most of the time when I have problems like this that google won't fix, it's something obvious.

Network cable plugged in all the way on both ends?
Unblocked the ports in both directions that SNMP uses in windows firewall? (UDP 161 and 162)
Switch isn't dropping your SNMP requests/ SNMP disabled on switch?
Might have to run apache as root (gasp!) if you're in windows and need an obscene amount of simultaneous connections
No network hardware in between that's screwing with your packet headers?
Using correct ip/subnet mask?
Both manager and agent use same version of SNMP? (SNMPv2 will work with SNMPv1, but just to be absolutely certain this isn't your problem)
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #3  
Old 02-05-2011, 01:47 AM
MGCJerry's Avatar
needs a life :þ
MGCJerry is gone
 
Join Date: Mar 2010
Posts: 86
Default

Thanks for the reply Sight... I'll address your points one by one.

Here's a network graphic to help visualize.


MRTG graph for internet uplink to router...


1. Yes, cables are connected on both ends. The machine that is talking to the switch has 2 network cards in a Failover network team. One interface is run through a 1gb switch (unmanaged), and the other is attached directly to the managed switch (100M only). Every machine on my network can talk to the managed switch and access its admin interface. This machine is already reading SNMP data via Perl to generate MRTG graphs.
2. I'm not using windows firewall, or any other firewall.
3. SNMP is enabled, See #1 & MRTG graphic.
4. I will not run Apache as root, even if it will fix it... This would be absolutely retarded for Microsoft, PHP group & Apache group if this is required.
5. Not that I know of. The server that's already talking to the managed switch is generates my MRTG graphs. Perl talks just fine to SNMP, once every 5 minutes, so I'm sure if there was another hardware issue MRTG would not work, correct?
6. Yes, I have a correct ip & netmask setup. The router assigns IPs based on my specified settings in the router setup.
7. Now this one I'm not sure of... I couldn't find any SNMP version information on the switch. Perhaps this is the issue? I'll look further into this.

Thanks again for the ideas.
__________________
Don't like what I say? Click HERE to add me to your ignore list.

Last edited by MGCJerry; 02-05-2011 at 01:49 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #4  
Old 02-05-2011, 05:28 AM
Sight Unseen's Avatar
Nawmtu
Sight Unseen now has an updated status.
 
Join Date: Mar 2010
Location: Texas, eventually Pandora.
Posts: 1,149
Default

Jesus... Thats one Gordian Knot of a network.

Are you sure the switch supports the variables you're trying to read? Are you querying too fast? Are you querying more than one variable at a time with different sessions?

As for #4, its a limitation of the windows xp kernel iirc. Actually, running as root won't help either. If your number of connections is in the thousands, this may be your problem.

Last edited by Sight Unseen; 02-05-2011 at 05:36 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #5  
Old 02-06-2011, 02:22 AM
MGCJerry's Avatar
needs a life :þ
MGCJerry is gone
 
Join Date: Mar 2010
Posts: 86
Default

Ya, there's a few things on the network. I dont have all my audio/video stuff on there either but that's a whole other monster.

I found out the switch supports SNMP version 2c.

All I'm trying to do is get the raw data so I can display uptime and version info which I know the switch sends because its in my "mrtg.cfg" file. I'm only doing one query per page load and these pages are not publicly accessible.

The server is running Windows Server 2003, and not XP.
__________________
Don't like what I say? Click HERE to add me to your ignore list.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #6  
Old 02-06-2011, 04:54 AM
Sight Unseen's Avatar
Nawmtu
Sight Unseen now has an updated status.
 
Join Date: Mar 2010
Location: Texas, eventually Pandora.
Posts: 1,149
Default

I think 2003 runs the xp kernel.

Also, make sure you're not making more than one read at a time. Like for instance calling the read method, then calling it immediately again before the switch has a chance to respond to the first request. I guess what I'm saying is make sure your code queries everything at once instead of sending a seperate query for each read request... or something. I'm just making a shot in the dark really.

Last edited by Sight Unseen; 02-06-2011 at 05:01 AM.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
  #7  
Old 02-15-2011, 12:13 AM
MGCJerry's Avatar
needs a life :þ
MGCJerry is gone
 
Join Date: Mar 2010
Posts: 86
Default

It's about time I can follow up on this... Been a hell of a week or so.

As far as I know, my code is only querying the switch once and is asking for all data. However, I have placed this project on the back burner since I have a few more projects that are a bit more immediate that needs more attention.

Thanks for the help Sight...
__________________
Don't like what I say? Click HERE to add me to your ignore list.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Visit our partner sites:

     



All times are GMT +1. The time now is 10:28 AM.

Based on the Planet Earth theme by Themes by Design


Powered by vBulletin® Version 3.8.2
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2010, Crawlability, Inc.
All images and clips of Avatar are the exclusive property of 20th Century Fox.