Added php files for nagios monitoring
This commit is contained in:
33
check_ssl.php
Normal file
33
check_ssl.php
Normal file
@@ -0,0 +1,33 @@
|
||||
#!/usr/bin/php
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/config/init.php';
|
||||
|
||||
$jsonFile = __DIR__ . '/web_check.json';
|
||||
|
||||
if (!file_exists($jsonFile)) {
|
||||
echo "CRITICAL - JSON file not found\n";
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$data = json_decode(file_get_contents($jsonFile), true);
|
||||
if (!$data) {
|
||||
echo "CRITICAL - Invalid JSON\n";
|
||||
exit(2);
|
||||
}
|
||||
|
||||
$problems = [];
|
||||
|
||||
foreach ($data as $site) {
|
||||
if ($site['sslcheck_ok'] != 1) {
|
||||
$problems[] = $site['domain'];
|
||||
}
|
||||
}
|
||||
|
||||
if (!empty($problems)) {
|
||||
echo "CRITICAL - SSL problems on: " . implode(', ', $problems) . "\n";
|
||||
exit(2);
|
||||
}
|
||||
|
||||
echo "OK - All SSL certificates valid\n";
|
||||
exit(0);
|
||||
Reference in New Issue
Block a user