X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=server%2Fweb%2Fnagcollect.php;h=9b5637b2e66144f8cea0694c23b44e6ca5e6c113;hb=e6e15206564c674a50ef13fa4afca7c7d47efb19;hp=38fc33884ec3e66ba6d24f18436f3a568b8fdc48;hpb=51723be3245dcb9df2659b48d66a183e2e738eed;p=nagcollect.git diff --git a/server/web/nagcollect.php b/server/web/nagcollect.php index 38fc338..9b5637b 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; } @@ -77,7 +76,9 @@ function processRequest($args) return 500; } else { // Service Update - if (!nagiosSubmitHost($host, 0, 'Received passive service check')) + $hostStatus = 'Received passive service check from ' + . '"' . $_SERVER['REMOTE_ADDR'] . '"'; + if (!nagiosSubmitHost($host, 0, $hostStatus)) return 500; if (!nagiosSubmitService($host, $service, $status, $text)) return 500; @@ -96,12 +97,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"); ?>