NYCPHP Meetup

NYPHP.org

[nycphp-talk] Is PHP a good choice for automating network monitoring?

Hans Zaunere hans at nyphp.com
Sat Sep 18 16:07:52 EDT 2004


> Instead, I'm wondering if it's possible for PHP to monitor my
> computer's IP address, or more accurately, my local network's WAN IP
> address, so that it can alert me when the address changes via a DHCP
> offer(). Here's the situation:
> 
> I have a computer at my parent's house constantly running and
> connected to the Internet via a Road Runner account. I'd like to
> connect to it remotely sometimes. The problem is, as you know, Road
> Runner uses DHCP to designate their subscriber modem's IP addresses,
> and this means it changes all the time. I'm savvy enough to configure
> an SSH server on the machine locally and configure the router over
> there to let requests from the Internet through, but I obviously can't
> figure out where that computer is unless I call my parents and direct
> her to whatismyip.com.
> 
> So the question is, does PHP have any capability to discover and
> monitor a network's WAN IP address?

Yes and no.  I'm not aware of an extension that ties directly into the
kernel system calls, but depending on your system, it'd be trivial to
parse /proc info, ifconfig output, etc.  Possibly helpful of course
would be these functions:

http://lists.nyphp.org/mailman/listinfo/front-end

There are likely PEAR classes and other open source projects that do
much of this parsing, and there are probably even extensions that take
it to the C level (the right way to do it).  I had worked on a C
extension to sculpt raw packets, but it's since stalled any development.

> I'd imagine that the solution would be a PHP-CLI script invoked with
> cron or a similar utility which would then email me the current
> address. (I suppose Windows has the Task Scheduler for this, and I
> guess this would also require setting up some kind of mail server, or
> else use something like http://phpmailer.sourceforge.net/ suggested by
> Dan, earlier. (I'm also sorry for not promptly thanking you for that
> suggestion, Dan. I really appreciated the pointer!)). But most
> importantly for right now, I'm not sure this is the best way to go
> about it in the first place.
> 
> Can anyone offer some good points why I shouldn't attempt this
> project? I'd be grateful if you save me some time.  :)  Thanks in
> advance.

I think this approache would work, and some other tools - cacti comes to
mind - might be useful here, too.

H




More information about the talk mailing list