From cb5bced2151a486ee319de72dcb161a122c0e704 Mon Sep 17 00:00:00 2001 From: arjen Date: Sat, 8 Feb 2003 07:41:31 +0000 Subject: [PATCH] Recognize important start and stop events of various daemons --- src/gcm_daemon/classes/gnucomo.process_log.php | 126 ++++++++++++++++++++++++- 1 file changed, 123 insertions(+), 3 deletions(-) diff --git a/src/gcm_daemon/classes/gnucomo.process_log.php b/src/gcm_daemon/classes/gnucomo.process_log.php index f051dbd..734ceac 100644 --- a/src/gcm_daemon/classes/gnucomo.process_log.php +++ b/src/gcm_daemon/classes/gnucomo.process_log.php @@ -22,9 +22,10 @@ function linux_log () $local_log_string = str_replace(" ", " ", $dbms->db_result_row[6]); $local_logline_array = explode (" ", $local_log_string); - switch (strtolower($local_logline_array[4])) + $service_type = $dbms->db_result_row[3]; + switch (strtolower($service_type)) { - case "kernel:": + case "kernel": //This is a kernel logline now discover which type kernel-record we have //Detect if this is a network-line @@ -36,26 +37,89 @@ function linux_log () } else { + + //This line is a kernel line writing about a device. if (strtolower($local_logline_array[4]) == 'device') { + echo $local_log_string; + $local_result = linux_kernel_device(); return $local_result; + } + else + { + if ($developrelease == 'TRUE') + { + $local_failing_string = "Failing string: ".$dbms->db_result_row[5]; syslog (LOG_INFO, "Unrecognized kernelline:".$local_log_string); syslog (LOG_INFO, $local_failing_string); + } return "FALSE"; } - } // <=== We were missing this brace + } break; + case "anacron": + $local_result = linux_daemon(); + break; + + case "apmd": + $local_result = linux_daemon(); + break; + + case "atd": + $local_result = linux_daemon(); + break; + + case "crond": + $local_result = linux_daemon(); + break; + + case "httpd": + $local_result = linux_daemon(); + break; + + case "lpd": + $local_result = linux_daemon(); + break; + + case "mysqld": + $local_result = linux_daemon(); + break; + + case "postfix": + $local_result = linux_daemon(); + break; + + case "random": + $local_result = linux_daemon(); + break; + + case "rhnsd": + $local_result = linux_daemon(); + break; + + case "syslog": + $local_result = linux_daemon(); + break; + + case "syslogd": + $local_result = linux_daemon(); + break; + + case "xinetd": + $local_result = linux_daemon(); + break; + default: break; } @@ -243,6 +307,7 @@ function linux_kernel_network() { RETURN "TRUE"; } + function linux_kernel_device() { /* This function is able to deal with the output of kernel-network messages * coming from device related processes. Typically networkcard and other @@ -255,5 +320,60 @@ function linux_kernel_network() { global $dbms, $dbms_working; } + +function linux_daemon() { + /* This function is able to deal with the output of kernel-network messages + * coming from device related processes. Typically networkcard and other + * hardware-related data will show-up here + * INPUT : NONE + * GLOBALS : $dbms, $dbms_working + * OUTPUT : "TRUE" for success and "FALSE" for failure. + */ + + global $dbms, $dbms_working; + + $local_log_line = strtolower($dbms->db_result_row[6]); + + //Find a sign of stop + //Using the word shutdown + $pos = strpos($local_log_line, "shutdown"); + if ($pos > 0) { + $local_sql = "INSERT INTO log_adv_daemon (logid, detailed_table, service, event) VALUES "; + $local_sql .= "('".$dbms->db_result_row[0]."', 'log_adv_daemon', '".$dbms->db_result_row[3]."', 'stop')"; + $dbms_working->query($local_sql); + } else { + //Using the word stop + $pos = strpos($local_log_line, "stop"); + if ($pos > 0) { + $local_sql = "INSERT INTO log_adv_daemon (logid, detailed_table, service, event) VALUES "; + $local_sql .= "('".$dbms->db_result_row[0]."', 'log_adv_daemon', '".$dbms->db_result_row[3]."', 'stop')"; + $dbms_working->query($local_sql); + } else { + //As the word restart + $pos = strpos($local_log_line, "restart"); + if ($pos > 0) { + $local_sql = "INSERT INTO log_adv_daemon (logid, detailed_table, service, event) VALUES "; + $local_sql .= "('".$dbms->db_result_row[0]."', 'log_adv_daemon', '".$dbms->db_result_row[3]."', 'stop')"; + $dbms_working->query($local_sql); + + $local_sql = "INSERT INTO log_adv_daemon (logid, detailed_table, service, event) VALUES "; + $local_sql .= "('".$dbms->db_result_row[0]."', 'log_adv_daemon', '".$dbms->db_result_row[3]."', 'start')"; + $dbms_working->query($local_sql); + } else { + //As the word start this is an else for restart. + //If we wouldn't do so restart would also give a positive on start + $pos = strpos($local_log_line, "start"); + if ($pos > 0) { + $local_sql = "INSERT INTO log_adv_daemon (logid, detailed_table, service, event) VALUES "; + $local_sql .= "('".$dbms->db_result_row[0]."', 'log_adv_daemon', '".$dbms->db_result_row[3]."', 'start')"; + $dbms_working->query($local_sql); + } + } + } + } + + return "ok"; + + } ?> -- 2.11.0