User Login History", "98%", $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 (!empty($_REQUEST["username"])) {
$sql_where .= "WHERE user_log.username=" . $_REQUEST["username"];
}
/* filter by search string */
if ($_REQUEST["filter"] <> "") {
if (strlen($sql_where)) {
$sql_where .= " AND (user_log.username LIKE '%%" . $_REQUEST["filter"] . "%%'
OR user_log.ip LIKE '%%" . $_REQUEST["filter"] . "%%')";
}else{
$sql_where .= "WHERE (user_log.username LIKE '%%" . $_REQUEST["filter"] . "%%'
OR user_log.ip LIKE '%%" . $_REQUEST["filter"] . "%%')";
}
}
html_start_box("", "98%", $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";
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'] . "' ORDER BY time LIMIT " . ($total_rows - 1));
}
/* 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"));
/* 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_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");
html_start_box("Log File Filters", "98%", $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, "98%", $colors["header"], "3", "center", "");
$i = 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;
}
/* 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) {
?>
|
|
Clear Cacti Log File", "98%", $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');
html_start_box("SNMP Cache Items", "98%", $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("", "98%", $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";
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", "98%", $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("", "98%", $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";
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", "98%", $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.
|