[op5-users] Statistics/ICMP downed host detection without root privilgies
Mikael.Schmidt at ixx.se
Mikael.Schmidt at ixx.se
Fri Mar 13 11:39:45 CET 2009
Hi,
I had an issue with 2 hosts that I couldn't get graphed simply because the only way to detect if they were alive was via ICMP. Naturally, I don't wish to run it as root which is a must for the current ping.php to work. Replacing the ping_icmp function within /opt/statistics/lib/ping.php with the one below removes the need of running as root. Could we perhaps add this to future versions of Statistics?
function ping_icmp() {
/* ping me */
if ($this->host["hostname"]) {
/* initialize variables */
$this->ping_status = "down";
$this->ping_response = "ICMP Ping timed out";
/* establish timeout variables */
$to_sec = floor($this->timeout/1000);
$to_usec = ($this->timeout%1000)*1000;
/* clean up hostname if specifying snmp_transport */
$this->host["hostname"] = str_replace("TCP:", "", $this->host["hostname"]);
$this->host["hostname"] = str_replace("UDP:", "", $this->host["hostname"]);
/* determine the host's ip address */
$host_ip = gethostbyname($this->host["hostname"]);
$this->ping_response = "$host_ip";
$ping_output = system("ping $host_ip -c 1", $retval);
preg_match('/rtt/', $ping_output, $ping_worked);
if ($ping_worked){
$this->ping_status = 1000;
$this->ping_response = "Host is alive";
return true;
}else {
$this->response = "Host is dead";
return false;
}
}
}
Kind Regards,
Mikael Schmidt
IT-consultant, Security Specialist
[cid:image001.jpg at 01C9A3D0.716E5130]
IXX IT-partner AB
Address: Helsingborgsvägen 60, 262 72 Ängelholm
Phone: 0431-44 51 00 Direct: 0431-44 51 20
Web: www.ixx.se<http://www.ixx.se/> Mail: mikael.schmidt at ixx.se<mailto:mikael.bergman at ixx.se>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.op5.com/pipermail/op5-users/attachments/20090313/1c8ec9ee/attachment-0001.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.jpg
Type: image/jpeg
Size: 23747 bytes
Desc: image001.jpg
Url : http://lists.op5.com/pipermail/op5-users/attachments/20090313/1c8ec9ee/attachment-0001.jpg
More information about the op5-users
mailing list