From: Alexander Barton Date: Thu, 21 Jan 2010 12:27:42 +0000 (+0100) Subject: Log all non-OK status codes to syslog X-Git-Tag: rel-2~19 X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?p=nagcollect.git;a=commitdiff_plain;h=560753ef7994d3d5551c98e55496941f4950de9e Log all non-OK status codes to syslog Logging to the Apache error log has been removed. --- diff --git a/server/web/nagcollect.php b/server/web/nagcollect.php index 38fc338..3f07341 100644 --- a/server/web/nagcollect.php +++ b/server/web/nagcollect.php @@ -51,7 +51,6 @@ function checkKey($key, $host) } } fclose($fh); - error_log("NagCollect: received invalid key \"$key\"!"); return false; } @@ -96,12 +95,21 @@ function getHttpStatusText($status) } } +openlog("NagCollect", LOG_ODELAY, LOG_DAEMON); + $httpStatus = processRequest($_POST); $httpStatusText = getHttpStatusText($httpStatus); $statusText = $httpStatus . ' - ' . $httpStatusText; -header("HTTP/1.0 $httpStatus $ttpStatusText"); +if ($httpStatus != 200) { + syslog(LOG_WARNING, "Warning: $httpStatusText ($httpStatus) from " + . "\"{$_SERVER['REMOTE_ADDR']}\" ({$_SERVER['HTTP_USER_AGENT']})"); +} + +closelog(); + +header("HTTP/1.0 $httpStatus $httpStatusText"); ?>