]> arthur.barton.de Git - nagcollect.git/blobdiff - server/web/nagcollect.php
Log all non-OK status codes to syslog
[nagcollect.git] / server / web / nagcollect.php
index 38fc33884ec3e66ba6d24f18436f3a568b8fdc48..3f07341787bc5560100445b2f90c35cff2642242 100644 (file)
@@ -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");
 
 ?><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
        "http://www.w3.org/TR/html4/strict.dtd">