Exclude pings from apache error logs (ran from PHP exec)
- by fooraide
Now, for a number of reasons I need to ping several hosts on a regular basis for a dashboard display.
I use this PHP function to do it:
function PingHost($strIpAddr) {
        exec(escapeshellcmd('ping -q -W 1 -c 1 '.$strIpAddr), $dataresult, $returnvar);
        if (substr($dataresult[4],0,3) == "rtt") {
                //We got a ping result, lets parse it.
                        $arr = explode("/",$dataresult[4]);
                        return ereg_replace(" ms","",$arr[4]);
        } elseif (substr($dataresult[3],35,16) == "100% packet loss") {
                //Host is down!
                        return "Down";
        } elseif ($returnvar == "2") {
                return "No DNS";
        }
}
The problem is that whenever there is an unknown host, I will get an error logged to my apache error log (/var/log/apache/error.log).
How would I go about disabling logs for this particular function ?
Disabling logs in the vhost is not an option since logs for that vhost are relevant, just not the pings.
Thanks,