/', '', $php_info); $php_info = preg_replace('/\<\/body\>.*$/', '', $php_info); $php_info = preg_replace('/\/U', '', $php_info); $php_info = preg_replace('/\<\/a\>/', '
', $php_info); $php_info = preg_replace('/\/U', '', $php_info); $php_info = preg_replace('/\<\/?address\>/', '', $php_info); return $php_info; } function utilities_view_tech($php_info = "") { global $colors, $config; html_start_box("Technical Support", "100%", $colors["header"], "3", "center", ""); html_header(array("Cacti Information"), 2); print "\n"; print " Date\n"; print " " . date("r") . "\n"; print "\n"; print "\n"; print " Cacti Version\n"; print " " . $config["cacti_version"] . "\n"; print "\n"; print "\n"; print " Cacti OS\n"; print " " . $config["cacti_server_os"] . "\n"; print "\n"; print "\n"; print " PHP Version\n"; print " " . phpversion() . "\n"; print "\n"; print "\n"; print " PHP OS\n"; print " " . PHP_OS . "\n"; print "\n"; if (function_exists("php_uname")) { print "\n"; print " PHP uname\n"; print " " . php_uname() . "\n"; print "\n"; } print "\n"; print " PHP SNMP\n"; print " "; if (function_exists("snmpget")) { print "Installed"; } else { print "Not Installed"; } print "\n"; print "\n"; html_header(array("PHP Settings"), 2); print " \n"; print " max_execution_time\n"; print " " . ini_get("max_execution_time") . "\n"; print "\n"; print " \n"; print " memory_limit\n"; print " " . ini_get("memory_limit") . "\n"; print "\n"; html_header(array("PHP Module Information"), 2); print "\n"; print " " . $php_info . "\n"; print "\n"; html_end_box(); } function utilities_view_user_log() { global $colors, $poller_actions; define("MAX_DISPLAY_PAGES", 21); /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("result")); input_validate_input_number(get_request_var_request("page")); /* ==================================================== */ /* clean up username */ if (isset($_REQUEST["username"])) { $_REQUEST["username"] = sanitize_search_string(get_request_var("username")); } /* clean up search filter */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* clean up sort_column */ if (isset($_REQUEST["sort_column"])) { $_REQUEST["sort_column"] = sanitize_search_string(get_request_var("sort_column")); } /* clean up sort direction */ if (isset($_REQUEST["sort_direction"])) { $_REQUEST["sort_direction"] = sanitize_search_string(get_request_var("sort_direction")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_userlog_current_page"); kill_session_var("sess_userlog_username"); kill_session_var("sess_userlog_result"); kill_session_var("sess_userlog_filter"); kill_session_var("sess_userlog_sort_column"); kill_session_var("sess_userlog_sort_direction"); unset($_REQUEST["page"]); unset($_REQUEST["result"]); unset($_REQUEST["filter"]); unset($_REQUEST["username"]); unset($_REQUEST["sort_column"]); unset($_REQUEST["sort_direction"]); } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_userlog_current_page", "1"); load_current_session_value("username", "sess_userlog_username", "-1"); load_current_session_value("result", "sess_userlog_result", "-1"); load_current_session_value("filter", "sess_userlog_filter", ""); load_current_session_value("sort_column", "sess_userlog_sort_column", "time"); load_current_session_value("sort_direction", "sess_userlog_sort_direction", "DESC"); $_REQUEST['page_referrer'] = 'view_user_log'; load_current_session_value('page_referrer', 'page_referrer', 'view_user_log'); ?> User Login History", "100%", $colors["header"], "3", "center", ""); include("./include/html/inc_user_log_filter_table.php"); html_end_box(); $sql_where = ""; /* filter by host */ if ($_REQUEST["username"] == "-1") { /* Show all items */ }elseif ($_REQUEST["username"] == "-2") { $sql_where = "WHERE user_log.username NOT IN (SELECT DISTINCT username from user_auth)"; }elseif (!empty($_REQUEST["username"])) { $sql_where = "WHERE user_log.username='" . $_REQUEST["username"] . "'"; } /* filter by result */ if ($_REQUEST["result"] == "-1") { /* Show all items */ }else{ if (strlen($sql_where)) { $sql_where .= " AND user_log.result=" . $_REQUEST["result"]; }else{ $sql_where = "WHERE user_log.result=" . $_REQUEST["result"]; } } /* filter by search string */ if ($_REQUEST["filter"] <> "") { if (strlen($sql_where)) { $sql_where .= " AND (user_log.username LIKE '%%" . $_REQUEST["filter"] . "%%' OR user_log.time LIKE '%%" . $_REQUEST["filter"] . "%%' OR user_log.ip LIKE '%%" . $_REQUEST["filter"] . "%%')"; }else{ $sql_where = "WHERE (user_log.username LIKE '%%" . $_REQUEST["filter"] . "%%' OR user_log.time LIKE '%%" . $_REQUEST["filter"] . "%%' OR user_log.ip LIKE '%%" . $_REQUEST["filter"] . "%%')"; } } html_start_box("", "100%", $colors["header"], "3", "center", ""); $total_rows = db_fetch_cell("SELECT COUNT(*) FROM user_auth RIGHT JOIN user_log ON user_auth.username = user_log.username $sql_where"); $user_log_sql = "SELECT user_log.username, user_auth.full_name, user_log.time, user_log.result, user_log.ip FROM user_auth RIGHT JOIN user_log ON user_auth.username = user_log.username $sql_where ORDER BY " . $_REQUEST["sort_column"] . " " . $_REQUEST["sort_direction"] . " LIMIT " . (read_config_option("num_rows_data_source")*($_REQUEST["page"]-1)) . "," . read_config_option("num_rows_data_source"); // print $user_log_sql; $user_log = db_fetch_assoc($user_log_sql); /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, read_config_option("num_rows_data_source"), $total_rows, "utilities.php?action=view_user_log&username=" . $_REQUEST["username"] . "&filter=" . $_REQUEST["filter"]); $nav = " \n \n \n
<< "; if ($_REQUEST["page"] > 1) { $nav .= ""; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= ""; } $nav .= " Showing Rows " . ((read_config_option("num_rows_data_source")*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_data_source")) || ($total_rows < (read_config_option("num_rows_data_source")*$_REQUEST["page"]))) ? $total_rows : (read_config_option("num_rows_data_source")*$_REQUEST["page"])) . " of $total_rows [$url_page_select] "; if (($_REQUEST["page"] * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= ""; } $nav .= "Next"; if (($_REQUEST["page"] * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= ""; } $nav .= " >>
\n"; print $nav; $display_text = array( "username" => array("Username", "ASC"), "full_name" => array("Full Name", "ASC"), "time" => array("Date", "ASC"), "result" => array("Result", "DESC"), "ip" => array("IP Address", "DESC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($user_log) > 0) { foreach ($user_log as $item) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); ?> \\1", $item["username"]);?> \\1", $item["full_name"]);?> \\1", $item["time"]);?> \\1", $item["ip"]);?> 1) { db_execute("DELETE FROM user_log WHERE username = '" . $user['username'] . "' AND result = 1 ORDER BY time LIMIT " . ($total_rows - 1)); } db_execute("DELETE FROM user_log WHERE username = '" . $user['username'] . "' AND result = 0"); } /* delete inactive users */ db_execute("DELETE FROM user_log WHERE username NOT IN (SELECT username FROM user_auth)"); } } function utilities_view_logfile() { global $colors, $log_tail_lines, $page_refresh_interval; $logfile = read_config_option("path_cactilog"); if ($logfile == "") { $logfile = "./log/rrd.log"; } /* helps determine output color */ $linecolor = True; input_validate_input_number(get_request_var_request("tail_files")); input_validate_input_number(get_request_var_request("message_type")); input_validate_input_number(get_request_var_request("refresh")); input_validate_input_number(get_request_var_request("reverse")); /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_logfile_tail_lines"); kill_session_var("sess_logfile_message_type"); kill_session_var("sess_logfile_filter"); kill_session_var("sess_logfile_refresh"); kill_session_var("sess_logfile_reverse"); unset($_REQUEST["tail_lines"]); unset($_REQUEST["message_type"]); unset($_REQUEST["filter"]); unset($_REQUEST["refresh"]); unset($_REQUEST["reverse"]); } load_current_session_value("tail_lines", "sess_logfile_tail_lines", read_config_option("num_rows_log")); load_current_session_value("message_type", "sess_logfile_message_type", "-1"); load_current_session_value("filter", "sess_logfile_filter", ""); load_current_session_value("refresh", "sess_logfile_refresh", read_config_option("log_refresh_interval")); load_current_session_value("reverse", "sess_logfile_reverse", 1); $_REQUEST['page_referrer'] = 'view_logfile'; load_current_session_value('page_referrer', 'page_referrer', 'view_logfile'); $refresh["seconds"] = $_REQUEST["refresh"]; $refresh["page"] = "utilities.php?action=view_logfile"; include_once("./include/top_header.php"); ?> Log File Filters", "100%", $colors["header"], "3", "center", ""); include("./include/html/inc_view_logfile_table.php"); html_end_box(); /* read logfile into an array and display */ $logcontents = tail_file($logfile, $_REQUEST["tail_lines"]); if ($_REQUEST["reverse"] == 1) { $logcontents = array_reverse($logcontents); } if ($_REQUEST["message_type"] > 0) { $start_string = "Log File [Total Lines: " . sizeof($logcontents) . " - Non-Matching Items Hidden]"; }else{ $start_string = "Log File [Total Lines: " . sizeof($logcontents) . " - All Items Shown]"; } html_start_box($start_string, "100%", $colors["header"], "3", "center", ""); $i = 0; $j = 0; $linecolor = false; foreach ($logcontents as $item) { $host_start = strpos($item, "Host["); $ds_start = strpos($item, "DS["); $new_item = ""; if ((!$host_start) && (!$ds_start)) { $new_item = $item; }else{ if ($host_start) { $host_end = strpos($item, "]", $host_start); $host_id = substr($item, $host_start+5, $host_end-($host_start+5)); $new_item = $new_item . substr($item, 0, $host_start + 5) . "" . substr($item, $host_start + 5, $host_end-($host_start + 5)) . ""; $item = substr($item, $host_end); } $ds_start = strpos($item, "DS["); if ($ds_start) { $ds_end = strpos($item, "]", $ds_start); $ds_id = substr($item, $ds_start+3, $ds_end-($ds_start+3)); $new_item = $new_item . substr($item, 0, $ds_start + 3) . "" . substr($item, $ds_start + 3, $ds_end-($ds_start + 3)) . ""; $item = substr($item, $ds_end); $new_item = $new_item . $item; }else{ $new_item = $new_item . $item; } } /* determine if we are to display the line */ switch ($_REQUEST["message_type"]) { case -1: /* all */ $display = true; break; case 5: /* sql calls */ if (substr_count($new_item, " SQL ")) { $display=true; }else{ $display=false; } break; case 1: /* stats */ if (substr_count($new_item, "STATS")) { $display=true; }else{ $display=false; } break; case 2: /* warnings */ if (substr_count($new_item, "WARN")) { $display=true; }else{ $display=false; } break; case 3: /* errors */ if (substr_count($new_item, "ERROR")) { $display=true; }else{ $display=false; } break; case 4: /* debug */ if (substr_count($new_item, "DEBUG")) { $display=true; }else{ $display=false; } if (substr_count($new_item, " SQL ")) { $display=false; } break; default: /* all other lines */ $display=true; break; } /* match any lines that match the search string */ if (strlen($_REQUEST["filter"])) { if ((substr_count(strtolower($new_item), strtolower($_REQUEST["filter"]))) || (@preg_match($_REQUEST["filter"], $new_item))) { $display=true; }else{ $display=false; } } /* get the background color */ if ((substr_count($new_item, "ERROR")) || (substr_count($new_item, "FATAL"))) { $bgcolor = "FF3932"; }elseif (substr_count($new_item, "WARN")) { $bgcolor = "EACC00"; }elseif (substr_count($new_item, " SQL ")) { $bgcolor = "6DC8FE"; }elseif (substr_count($new_item, "DEBUG")) { $bgcolor = "C4FD3D"; }elseif (substr_count($new_item, "STATS")) { $bgcolor = "96E78A"; }else{ if ($linecolor) { $bgcolor = "CCCCCC"; }else{ $bgcolor = "FFFFFF"; } $linecolor = !$linecolor; } if ($display) { ?> 1000) { ?> >>> LINE LIMIT OF 1000 LINES REACHED!! <<<<";?> Clear Cacti Log File", "100%", $colors["header"], "1", "center", ""); if (file_exists($logfile)) { if (is_writable($logfile)) { $timestamp = date("m/d/Y h:i:s A"); $log_fh = fopen($logfile, "w"); fwrite($log_fh, $timestamp . " - WEBUI: Cacti Log Cleared from Web Management Interface\n"); fclose($log_fh); print "Cacti Log File Cleared"; }else{ print "Error: Unable to clear log, no write permissions."; } }else{ print "Error: Unable to clear log, file does not exist."; } html_end_box(); } function utilities_view_snmp_cache() { global $colors, $poller_actions; define("MAX_DISPLAY_PAGES", 21); /* ================= input validation ================= */ input_validate_input_number(get_request_var_request("host_id")); input_validate_input_number(get_request_var_request("snmp_query_id")); input_validate_input_number(get_request_var_request("page")); input_validate_input_number(get_request_var_request("poller_action")); /* ==================================================== */ /* clean up search filter */ if (isset($_REQUEST["filter"])) { $_REQUEST["filter"] = sanitize_search_string(get_request_var("filter")); } /* if the user pushed the 'clear' button */ if (isset($_REQUEST["clear_x"])) { kill_session_var("sess_snmp_current_page"); kill_session_var("sess_snmp_host_id"); kill_session_var("sess_snmp_snmp_query_id"); kill_session_var("sess_snmp_filter"); unset($_REQUEST["page"]); unset($_REQUEST["filter"]); unset($_REQUEST["host_id"]); unset($_REQUEST["snmp_query_id"]); } /* remember these search fields in session vars so we don't have to keep passing them around */ load_current_session_value("page", "sess_snmp_current_page", "1"); load_current_session_value("host_id", "sess_snmp_host_id", "-1"); load_current_session_value("snmp_query_id", "sess_snmp_snmp_query_id", "-1"); load_current_session_value("filter", "sess_snmp_filter", ""); $_REQUEST['page_referrer'] = 'view_snmp_cache'; load_current_session_value('page_referrer', 'page_referrer', 'view_snmp_cache'); ?> SNMP Cache Items", "100%", $colors["header"], "3", "center", ""); include("./include/html/inc_snmp_cache_filter_table.php"); html_end_box(); $sql_where = ""; /* filter by host */ if ($_REQUEST["host_id"] == "-1") { /* Show all items */ }elseif ($_REQUEST["host_id"] == "0") { $sql_where .= " AND host.id=0"; }elseif (!empty($_REQUEST["host_id"])) { $sql_where .= " AND host.id=" . $_REQUEST["host_id"]; } /* filter by query name */ if ($_REQUEST["snmp_query_id"] == "-1") { /* Show all items */ }elseif (!empty($_REQUEST["snmp_query_id"])) { $sql_where .= " AND host_snmp_cache.snmp_query_id=" . $_REQUEST["snmp_query_id"]; } /* filter by search string */ if ($_REQUEST["filter"] <> "") { $sql_where .= " AND (host.description LIKE '%%" . $_REQUEST["filter"] . "%%' OR snmp_query.name LIKE '%%" . $_REQUEST["filter"] . "%%' OR host_snmp_cache.field_name LIKE '%%" . $_REQUEST["filter"] . "%%' OR host_snmp_cache.field_value LIKE '%%" . $_REQUEST["filter"] . "%%' OR host_snmp_cache.oid LIKE '%%" . $_REQUEST["filter"] . "%%')"; } html_start_box("", "100%", $colors["header"], "3", "center", ""); $total_rows = db_fetch_cell("SELECT COUNT(*) FROM (host_snmp_cache,snmp_query,host) WHERE host_snmp_cache.host_id=host.id AND host_snmp_cache.snmp_query_id=snmp_query.id $sql_where"); $snmp_cache_sql = "SELECT host_snmp_cache.*, host.description, snmp_query.name FROM (host_snmp_cache,snmp_query,host) WHERE host_snmp_cache.host_id=host.id AND host_snmp_cache.snmp_query_id=snmp_query.id $sql_where LIMIT " . (read_config_option("num_rows_data_source")*($_REQUEST["page"]-1)) . "," . read_config_option("num_rows_data_source"); // print $snmp_cache_sql; $snmp_cache = db_fetch_assoc($snmp_cache_sql); /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, read_config_option("num_rows_data_source"), $total_rows, "utilities.php?action=view_snmp_cache&host_id=" . $_REQUEST["host_id"] . "&filter=" . $_REQUEST["filter"]); $nav = " \n \n \n
<< "; if ($_REQUEST["page"] > 1) { $nav .= ""; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= ""; } $nav .= " Showing Rows " . ((read_config_option("num_rows_data_source")*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_data_source")) || ($total_rows < (read_config_option("num_rows_data_source")*$_REQUEST["page"]))) ? $total_rows : (read_config_option("num_rows_data_source")*$_REQUEST["page"])) . " of $total_rows [$url_page_select] "; if (($_REQUEST["page"] * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= ""; } $nav .= "Next"; if (($_REQUEST["page"] * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= ""; } $nav .= " >>
\n"; print $nav; html_header(array("Details")); $i = 0; if (sizeof($snmp_cache) > 0) { foreach ($snmp_cache as $item) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); ?> Host: \\1", $item["description"]);?> , SNMP Query: \\1", $item["name"]);?> Index: , Field Name: \\1", $item["field_name"]);?> , Field Value: \\1", $item["field_value"]);?> OID: \\1", $item["oid"]);?> Poller Cache Items", "100%", $colors["header"], "3", "center", ""); include("./include/html/inc_poller_item_filter_table.php"); html_end_box(); /* form the 'where' clause for our main sql query */ $sql_where = "WHERE poller_item.local_data_id=data_template_data.local_data_id"; if ($_REQUEST["poller_action"] == "-1") { /* Show all items */ }else { $sql_where .= " AND poller_item.action='" . $_REQUEST["poller_action"] . "'"; } if ($_REQUEST["host_id"] == "-1") { /* Show all items */ }elseif ($_REQUEST["host_id"] == "0") { $sql_where .= " AND poller_item.host_id=0"; }elseif (!empty($_REQUEST["host_id"])) { $sql_where .= " AND poller_item.host_id=" . $_REQUEST["host_id"]; } if (strlen($_REQUEST["filter"])) { $sql_where .= " AND (data_template_data.name_cache LIKE '%%" . $_REQUEST["filter"] . "%%' OR host.description LIKE '%%" . $_REQUEST["filter"] . "%%' OR poller_item.arg1 LIKE '%%" . $_REQUEST["filter"] . "%%' OR poller_item.hostname LIKE '%%" . $_REQUEST["filter"] . "%%' OR poller_item.rrd_path LIKE '%%" . $_REQUEST["filter"] . "%%')"; } html_start_box("", "100%", $colors["header"], "3", "center", ""); $total_rows = db_fetch_cell("SELECT COUNT(*) FROM data_template_data INNER JOIN (poller_item INNER JOIN host ON poller_item.host_id = host.id) ON data_template_data.local_data_id = poller_item.local_data_id $sql_where"); $poller_sql = "SELECT poller_item.*, data_template_data.name_cache, host.description FROM data_template_data INNER JOIN (poller_item INNER JOIN host ON poller_item.host_id = host.id) ON data_template_data.local_data_id = poller_item.local_data_id $sql_where ORDER BY " . $_REQUEST["sort_column"] . " " . $_REQUEST["sort_direction"] . ", action ASC LIMIT " . (read_config_option("num_rows_data_source")*($_REQUEST["page"]-1)) . "," . read_config_option("num_rows_data_source"); // print $poller_sql; $poller_cache = db_fetch_assoc($poller_sql); /* generate page list */ $url_page_select = get_page_list($_REQUEST["page"], MAX_DISPLAY_PAGES, read_config_option("num_rows_data_source"), $total_rows, "utilities.php?action=view_poller_cache&host_id=" . $_REQUEST["host_id"] . "&poller_action=" . $_REQUEST["poller_action"]); $nav = " \n \n \n
<< "; if ($_REQUEST["page"] > 1) { $nav .= ""; } $nav .= "Previous"; if ($_REQUEST["page"] > 1) { $nav .= ""; } $nav .= " Showing Rows " . ((read_config_option("num_rows_data_source")*($_REQUEST["page"]-1))+1) . " to " . ((($total_rows < read_config_option("num_rows_data_source")) || ($total_rows < (read_config_option("num_rows_data_source")*$_REQUEST["page"]))) ? $total_rows : (read_config_option("num_rows_data_source")*$_REQUEST["page"])) . " of $total_rows [$url_page_select] "; if (($_REQUEST["page"] * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= ""; } $nav .= "Next"; if (($_REQUEST["page"] * read_config_option("num_rows_data_source")) < $total_rows) { $nav .= ""; } $nav .= " >>
\n"; print $nav; $display_text = array( "data_template_data.name_cache" => array("Data Source Name", "ASC"), "" => array("Details", "ASC")); html_header_sort($display_text, $_REQUEST["sort_column"], $_REQUEST["sort_direction"]); $i = 0; if (sizeof($poller_cache) > 0) { foreach ($poller_cache as $item) { form_alternate_row_color($colors["form_alternate1"],$colors["form_alternate2"],$i); ?> ">\\1", $item["name_cache"]);?> \\1", $item["arg1"]); }else{ $details = "SNMP Version: " . $item["snmp_version"] . ", " . "User: " . $item["snmp_username"] . ", OID: " . $item["arg1"]; } }elseif ($item["action"] == 1) { $details = "Script: " . eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "\\1", $item["arg1"]); }else{ $details = "Script Server: " . eregi_replace("(" . preg_quote($_REQUEST["filter"]) . ")", "\\1", $item["arg1"]); } print $details; ?> RRD: Cacti System Utilities", "100%", $colors["header"], "3", "center", ""); ?> ">

View Cacti Log File

The Cacti Log File stores statistic, error and other message depending on system settings. This information can be used to identify problems with the poller and application.

">

View User Log

Allows Administrators to browse the user log. Administrators can filter and export the log as well.

">

View Poller Cache

This is the data that is being passed to the poller each time it runs. This data is then in turn executed/interpreted and the results are fed into the rrd files for graphing or the database for display.

">

View SNMP Cache

The SNMP cache stores information gathered from SNMP queries. It is used by cacti to determine the OID to use when gathering information from an SNMP-enabled host.

">

Rebuild Poller Cache

The poller cache will be cleared and re-generated if you select this option. Sometimes host/data source data can get out of sync with the cache in which case it makes sense to clear the cache and start over.

">

Technical Support Output

Cacti technical support output. Used by developers and technical support persons to assist with issues in Cacti.