From bfa5b81ee804dafa68da27c732646788b1dee424 Mon Sep 17 00:00:00 2001 From: fbsanchez Date: Wed, 21 Oct 2020 14:03:46 +0200 Subject: [PATCH] Added server component status - crash - --- .../godmode/servers/servers.build_table.php | 12 +++++++++++- pandora_console/include/constants.php | 3 ++- pandora_console/include/functions_modules.php | 2 ++ pandora_console/include/functions_ui.php | 4 ++++ pandora_server/bin/pandora_server | 2 +- 5 files changed, 20 insertions(+), 3 deletions(-) diff --git a/pandora_console/godmode/servers/servers.build_table.php b/pandora_console/godmode/servers/servers.build_table.php index 668ef26f0c..169789d81c 100644 --- a/pandora_console/godmode/servers/servers.build_table.php +++ b/pandora_console/godmode/servers/servers.build_table.php @@ -92,7 +92,17 @@ foreach ($servers as $server) { // Status $data[1] = ui_print_status_image(STATUS_SERVER_OK, '', true); if (($server['status'] == 0) || (($date - time_w_fixed_tz($server['keepalive'])) > ($server['server_keepalive']) * 2)) { - $data[1] = ui_print_status_image(STATUS_SERVER_DOWN, '', true); + $data[1] = ui_print_status_image( + STATUS_SERVER_DOWN, + __('Server is stopped.'), + true + ); + } else if ($server['status'] == -1) { + $data[1] = ui_print_status_image( + STATUS_SERVER_CRASH, + __('Server has crashed.'), + true + ); } // Type diff --git a/pandora_console/include/constants.php b/pandora_console/include/constants.php index d32dacb1fe..258b6e805c 100644 --- a/pandora_console/include/constants.php +++ b/pandora_console/include/constants.php @@ -309,7 +309,7 @@ define('STATUS_ALERT_DISABLED', 'alert_disabled.png'); // For servers. define('STATUS_SERVER_OK', 'server_ok.png'); define('STATUS_SERVER_DOWN', 'server_down.png'); - +define('STATUS_SERVER_CRASH', 'server_crash.png'); // Status images (ball). @@ -335,6 +335,7 @@ define('STATUS_ALERT_DISABLED_BALL', 'alert_disabled_ball.png'); // For servers. define('STATUS_SERVER_OK_BALL', 'server_ok_ball.png'); define('STATUS_SERVER_DOWN_BALL', 'server_down_ball.png'); +define('STATUS_SERVER_CRASH_BALL', 'server_crash_ball.png'); diff --git a/pandora_console/include/functions_modules.php b/pandora_console/include/functions_modules.php index 9a5ea93f92..e28c255f9c 100755 --- a/pandora_console/include/functions_modules.php +++ b/pandora_console/include/functions_modules.php @@ -2494,6 +2494,8 @@ function modules_get_color_status($status, $force_module=false) case STATUS_AGENT_CRITICAL: case STATUS_MODULE_CRITICAL_BALL: case STATUS_AGENT_CRITICAL_BALL: + case STATUS_SERVER_CRASH: + case STATUS_SERVER_CRASH_BALL: return COL_CRITICAL; case AGENT_MODULE_STATUS_WARNING: diff --git a/pandora_console/include/functions_ui.php b/pandora_console/include/functions_ui.php index ab6079fb36..65e6facc93 100755 --- a/pandora_console/include/functions_ui.php +++ b/pandora_console/include/functions_ui.php @@ -2762,6 +2762,7 @@ function get_shape_status_set($type) // Small squares. case STATUS_SERVER_OK: case STATUS_SERVER_DOWN: + case STATUS_SERVER_CRASH: $return = ['class' => 'status_small_squares']; break; @@ -2773,6 +2774,9 @@ function get_shape_status_set($type) case STATUS_AGENT_OK_BALL: case STATUS_AGENT_NO_DATA_BALL: case STATUS_AGENT_NO_MONITORS_BALL: + case STATUS_SERVER_OK_BALL: + case STATUS_SERVER_DOWN_BALL: + case STATUS_SERVER_CRASH_BALL: $return = ['class' => 'status_balls']; break; diff --git a/pandora_server/bin/pandora_server b/pandora_server/bin/pandora_server index 812bf1e57b..d82944f93b 100755 --- a/pandora_server/bin/pandora_server +++ b/pandora_server/bin/pandora_server @@ -771,7 +771,7 @@ sub main() { die("Server thread crashed.") unless (check_server_threads() == 1); db_do ($DBH, - "UPDATE tserver SET status = 0 + "UPDATE tserver SET status = -1 WHERE UNIX_TIMESTAMP(now())-UNIX_TIMESTAMP(keepalive) > 2*server_keepalive" );