SNMP from PHP

Whether you are using Linux on the desktop or as a server, it's still good that you're using Linux. Linux related questions go here.

Moderator: General Moderators

Post Reply
batatudo
Forum Newbie
Posts: 6
Joined: Tue Dec 30, 2003 6:28 am

SNMP from PHP

Post by batatudo »

Hi

I installed NET-SNMP 5.0.8 on my mandrake linux server running apache 4.3.3.

Everything looks OK, but none of the snmp functions in PHP works.
I think I have to enable some module in PHP to activate the SNMP functions,
or maybe is in the Apache. I don't know.

I need help!!!
thanks

bye
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

Apache 4.3.3 huh? You're way ahead of me buddy!! :D

But did you read the man page?
http://us2.php.net/manual/en/ref.snmp.php

Btw: Just curious what you want to use SNMP for?
batatudo
Forum Newbie
Posts: 6
Joined: Tue Dec 30, 2003 6:28 am

Post by batatudo »

Jeje, Sorry Apache is 2.0, and PHP is 4.3.3 anyway...

I read the manual. The manual said this "you need to define NO_ZEROLENGTH_COMMUNITY to 1 before compiling it." I don't know where this variable is defined. anyway I don't have the source code of PHP and don't know how to compile PHP.
I'm new to linux. I came from the dark side "windows".
I know PHP is working but I don't know where is installed, too many strange folders for me.

Any idea?
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

That's only for UCD_SNMP, but you're using NET SNMP. But in order to enable snmp in php you have to recompile php from source. If I were you, I would uninstall whatever packages you have for php/apache and go read the install guide at:

http://us2.php.net/manual/en/install.apache2.php

When you do the compile php part, you'll add --with-snmp to the configure line.

Once again though, just asking, what do you want/need snmp for?
batatudo
Forum Newbie
Posts: 6
Joined: Tue Dec 30, 2003 6:28 am

Post by batatudo »

I need SNMP to get the CPU utilization of another server. I need this for my office.
Example: When a user in my company open the browser they are first connected to the linux server.
From there they click the link "Reprorts". Then the PHP program check two windows 2000 servers and have
to decide which one to redirect the user. That part is very easy, if the first server is down then redirect
to the second server. But I also want to make what I call "low balance". If the two servers are online, the
PHP program has to decide who are less busy. I know I can make this works tracking the users in a MYSQL table,
but there is more services running on these widows servers and I have no control over them.

How I compile PHP?
I'm using mandrake 9.2 and everything was installed at setup.

bye
User avatar
Pyrite
Forum Regular
Posts: 769
Joined: Tue Sep 23, 2003 11:07 pm
Location: The Republic of Texas
Contact:

Post by Pyrite »

That link I gave you ... read it!
User avatar
BDKR
DevNet Resident
Posts: 1207
Joined: Sat Jun 08, 2002 1:24 pm
Location: Florida
Contact:

Post by BDKR »

batatudo wrote:I need SNMP to get the CPU utilization of another server. I need this for my office.
Example: When a user in my company open the browser they are first connected to the linux server.
From there they click the link "Reprorts". Then the PHP program check two windows 2000 servers and have
to decide which one to redirect the user. That part is very easy, if the first server is down then redirect
to the second server. But I also want to make what I call "low balance". If the two servers are online, the
PHP program has to decide who are less busy. I know I can make this works tracking the users in a MYSQL table,
but there is more services running on these widows servers and I have no control over them.

How I compile PHP?
I'm using mandrake 9.2 and everything was installed at setup.

bye
It sounds to me you are talking about load balancing. If that's the case, this really isn't the correct way to do it. Normally, there is a machine that acts as a traffic manager and directs the process or request to a machine amongst a pool of machines. 2 machines are enough to qualify as a pool.

Anyway, the method you describe will invoke a good deal more overhead into the overall processing of an individual request than should ever be needed. With one machine acting as a cluster manager or traffic manager, it will have the overhead of deciding where to send the next request. And it's really not all that hard.

Do your homework on load balancing. There is also the open source project called Piranha, which is a load balancing / cluster solution.

Cheers,
BDKR
Post Reply