In my php-app I need the list of all IP's connected on port 80. I've chosen to do it this way:
<?php
$ips = exec("netstat -an |grep 'tcp\|udp' | awk '{print $5}' | cut -d: -f1 | sort | uniq -c", $info);
?>
But it doesn't work on my VPS FreeBSD server. When I start netstat -an
a notice appears and no connections are in output:
netstat: kvm not available: /dev/mem: No such file or directory
I tried to add device mem
to conf, but I have an empty /usr/src/sys. I got to the point that I need to rebuild the core.))
netstat
works correctly when user is root (from console). I haven't had any problems like this on a similar CentOS hosting platform.
Fot resolving /dev/mem: No such file or directory
I've tried to do mknod -m 660 /dev/mem c 1 1
but it calls an mknod: /dev/mem: Operation not permitted
I've got the following users pw showuser
owl:*:1000:1003:default:0:0:owl:/home/owl/data:/bin/csh
root:*:0:0::0:0:Charlie &:/root:/bin/csh
Summary:
When I run netstat
as owl
- it returns an empty list of connections
When I run netstat
as root
- it returns notice netstat: kvm not available: /dev/mem: No such file or directory
and IP's
Can anybody help me? Is there maybe another way that exists for resolving this task? Thank you