From 573421700d2b921dc7650970564d929fb5c1dfe2 Mon Sep 17 00:00:00 2001 From: sld-admin Date: Thu, 12 Feb 2026 22:44:33 +0000 Subject: [PATCH] Added php files for nagios monitoring --- check_content.php | 31 +++++++++++ check_expiry.php | 49 +++++++++++++++++ check_ssl.php | 33 ++++++++++++ functions/main.php | 132 +++++++++++++++++++++++---------------------- web_check.json | 73 +++++++++++++++++++++++++ web_list.json | 9 ++++ 6 files changed, 263 insertions(+), 64 deletions(-) create mode 100644 check_content.php create mode 100644 check_expiry.php create mode 100644 check_ssl.php diff --git a/check_content.php b/check_content.php new file mode 100644 index 0000000..638daf4 --- /dev/null +++ b/check_content.php @@ -0,0 +1,31 @@ +#!/usr/bin/php += 0) return -1; + if ($b_days < 0 && $a_days >= 0) return 1; + + // 4️⃣ Ordina per giorni crescenti (meno giorni prima) + return $a_days <=> $b_days; }); foreach($webcheck_json as $check_element){ @@ -126,7 +95,11 @@ function status_class_bg($ssl, $word, $expiry, $retcol=null, $showday="null"){ $ssl_expiry=$check_element['ssl-expiry']; $ssl_company=$check_element['ssl-company']; $http_error=$check_element['content_http_code']; - $expirying_days=status_class_bg($sslcheck_ok, $checkword_ok, $ssl_expiry, false, 'on'); + $content_error=$check_element['content_error']; + $ssl_error=$check_element['ssl_error']; + $expirying_days = ssl_days_left($ssl_expiry); + $expiry_col = get_expiry_style($expirying_days); + $status_class = get_status_class($sslcheck_ok, $checkword_ok, $ssl_expiry); $col_red = "#ff4747"; $col_orange = "#ff830f"; $col_yellow = "#ffd70f"; @@ -147,7 +120,7 @@ function status_class_bg($ssl, $word, $expiry, $retcol=null, $showday="null"){ } ?> -
+
HOST:
DOMAIN:
@@ -155,13 +128,22 @@ function status_class_bg($ssl, $word, $expiry, $retcol=null, $showday="null"){
>SSL:
+
WORD TO CHECK:
SSL RELEASED:
-
SSL EXPIRY: >
-
SSL DAYS LEFT: >
+
SSL EXPIRY: >
+
SSL DAYS LEFT: >
SSL COMPANY:
PATH:
ERROR CODE:
+ +
ERROR CODE:
+
CONTENT ERROR:
+
SSL ERROR:
+ +
@@ -236,5 +218,27 @@ function status_class_bg($ssl, $word, $expiry, $retcol=null, $showday="null"){ return $days; } + function get_expiry_style($days){ + + $col_red = "#ff4747"; + $col_orange = "#ff830f"; + $col_yellow = "#ffd70f"; + $col_green = "#42c500"; + + if ($days === null) return ""; + + if ($days < 0) { + return "style='font-weight:bold;color:$col_red;'"; + } + elseif ($days <= SSL_CRITICAL_DAYS) { + return "style='font-weight:bold;color:$col_orange;'"; + } + elseif ($days <= SSL_WARNING_DAYS) { + return "style='font-weight:bold;color:$col_yellow;'"; + } + + return "style='font-weight:bold;color:$col_green;'"; +} + ?> \ No newline at end of file diff --git a/web_check.json b/web_check.json index e69de29..e503719 100644 --- a/web_check.json +++ b/web_check.json @@ -0,0 +1,73 @@ +[ + { + "host": "hostname", + "domain": "domain", + "path": "/path(leave empty if is the webroot)", + "wordtocheck": "word to check", + "wordcheck_ok": 0, + "sslcheck_ok": 0, + "ssl-released": null, + "ssl-expiry": null, + "ssl-company": null, + "content_http_code": 0, + "content_error": "URL rejected: Malformed input to a URL function", + "ssl_error": "stream_socket_client failed: php_network_getaddresses: getaddrinfo for domain failed: Name or service not known (0)" + }, + + { + "host": "hostname", + "domain": "domain", + "path": "/path(leave empty if is the webroot)", + "wordtocheck": "word to check", + "wordcheck_ok": 1, + "sslcheck_ok": 1, + "ssl-released": "24/12/2025", + "ssl-expiry": "24/02/2026", + "ssl-company": null, + "content_http_code": 200, + "content_error": null, + "ssl_error": null + }, + { + "host": "hostname", + "domain": "testdomain", + "path": "/path(leave empty if is the webroot)", + "wordtocheck": "word to check", + "wordcheck_ok": 1, + "sslcheck_ok": 1, + "ssl-released": "24/12/2025", + "ssl-expiry": "16/02/2026", + "ssl-company": null, + "content_http_code": 200, + "content_error": null, + "ssl_error": null + }, + { + "host": "sld-app-a", + "domain": "sld-server.org", + "path": "", + "wordtocheck": "proxmox", + "wordcheck_ok": 1, + "sslcheck_ok": 1, + "ssl-released": "24/12/2025", + "ssl-expiry": "24/03/2026", + "ssl-company": "Cloudflare TLS Issuing ECC CA 3", + "content_http_code": 200, + "content_error": null, + "ssl_error": null + }, + { + "host": "hostname", + "domain": "domain", + "path": "/path(leave empty if is the webroot)", + "wordtocheck": "word to check", + "wordcheck_ok": 1, + "sslcheck_ok": 1, + "ssl-released": "24/12/2025", + "ssl-expiry": "22/02/2026", + "ssl-company": null, + "content_http_code": 200, + "content_error": null, + "ssl_error": null + } +] \ No newline at end of file diff --git a/web_list.json b/web_list.json index 49128e4..6ba33a5 100644 --- a/web_list.json +++ b/web_list.json @@ -7,5 +7,14 @@ "basic_auth":false, "basic_auth_name":"basic_auth_name", "basic_auth_password":"basic_auth_pass" + }, + { + "host":"sld-app-a", + "domain":"sld-server.org", + "path":"", + "word-to-check":"proxmox", + "basic_auth":false, + "basic_auth_name":"basic_auth_name", + "basic_auth_password":"basic_auth_pass" } ] \ No newline at end of file