array_push($sql_filter, " (priority IN (" . $list . ")) "); } } if (isset($_GET['msg']) && $_GET['msg'] != "" && $_GET['msg'] != "undefined") { array_push($sql_filter, " (msg LIKE '%" . htmlentities($_GET['msg'], ENT_QUOTES) . "%') "); } $req_sql_filter = ""; if (isset($sql_filter)) { $req_sql_filter = join(" AND ", $sql_filter); } if ($req_sql_filter != "") { $req = "SELECT * FROM " . $cfg_syslog["db_table_logs"] . " WHERE " . $req_sql_filter . " ORDER BY datetime DESC LIMIT 50"; } else { $req = "SELECT * FROM " . $cfg_syslog["db_table_logs"] . " ORDER BY datetime DESC LIMIT 50"; } $DBRESULT =& $pearDB_syslog->query($req); $buffer = new SyslogXML(); $buffer->startElement("root"); $buffer->writeElement("label_datetime", _("Date / Time"), false); $buffer->writeElement("label_host", _("Host"), false); $buffer->writeElement("label_facility", _("Facility"), false); $buffer->writeElement("label_severity", _("Severity"), false); $buffer->writeElement("label_program", _("Program"), false); $buffer->writeElement("label_msg", _("Message"), false); $style = "list_two"; $priority_color = array('debug' => 'sev_debug', 'info' => 'sev_info', 'notice' => 'sev_notice', 'warning' => 'sev_warning', 'warn' => 'sev_warning', 'error' => 'sev_error', 'err' => 'sev_error', 'critical' => 'sev_critical', 'crit' => 'sev_critical', 'alert' => 'sev_alert', 'emerg' => 'sev_emerg'); if ($DBRESULT->numRows() == 0) { $buffer->startElement("error"); $buffer->writeElement("msg", _("No informations")); $buffer->endElement(); } else {
/* * Build SQL request */ if (isset($StartDate)) { $start_sql = strftime("%Y-%m-%d ", $StartDate) . $StartTime; } if (isset($EndDate)) { $end_sql = strftime("%Y-%m-%d ", $EndDate) . $EndTime; } if (count($sql_filter) > 0) { $req = "SELECT * FROM " . $cfg_syslog["db_table_logs_merge"] . " WHERE datetime > '{$start_sql}' AND datetime <= '{$end_sql}' AND " . $req_sql_filter . " ORDER BY datetime"; } else { $req = "SELECT * FROM " . $cfg_syslog["db_table_logs_merge"] . " WHERE datetime > '{$start_sql}' AND datetime <= '{$end_sql}' ORDER BY datetime"; } $nom = "syslog_events"; $DBRESULT =& $pearSyslogDB->query($req); if (PEAR::isError($DBRESULT)) { print "Mysql Error : " . $DBRESULT->getMessage() . "\n"; } if (isset($_GET["type"])) { $type = $_GET["type"]; } if (strcmp($type, "CSV") == 0) { header("Content-Type: application/csv-tab-delimited-table"); header("Content-disposition: filename=" . $nom . ".csv"); header("Cache-Control: cache, must-revalidate"); header("Pragma: public"); echo "Start time : " . $start_sql; echo "\n"; echo "End time : " . $end_sql; echo "\n";
require_once 'HTML/QuickForm/advmultiselect.php'; require_once 'HTML/QuickForm/Renderer/ArraySmarty.php'; /* * PHP functions */ require_once $syslog_mod_path . "include/common/common-Func.php"; require_once "./include/common/common-Func.php"; /* * Database retrieve information for Centreon-Syslog */ $pearCentreonDB = new SyslogDB("centreon"); $collectorList = getCollectorList(); # QuickSearch form include_once "./include/common/quickSearch.php"; # Set limit & num $DBRESULT =& $pearCentreonDB->query("SELECT maxViewMonitoring FROM general_opt LIMIT 1"); if (PEAR::isError($DBRESULT)) { # For Centreon 2.1 compatibility $DBRESULT =& $pearCentreonDB->query("SELECT `value` FROM options WHERE `key`=\"maxViewMonitoring\" LIMIT 1"); $row = $DBRESULT->fetchRow(); $gopt = $row["value"]; if (PEAR::isError($DBRESULT)) { print "Mysql Error : " . $DBRESULT->getMessage() . "\n"; } } else { $gopt = array_map("myDecode", $DBRESULT->fetchRow()); } # Get end Post values isset($_GET["num"]) ? $num = $_GET["num"] : ($num = 0); isset($_GET["search"]) ? $search = $_GET["search"] : ($search = NULL); # Get collectors
require_once $syslog_mod_path . "/include/common/common-Func.php"; require_once $syslog_mod_path . "class/syslogDB.class.php"; /* * Get host name and IP address */ $tab_host = explode(";", $_GET["hosts"]); print_r($tab_host); foreach ($tab_host as $host) { $hostAndIP = split("::", $host); if (isset($_GET['collector_id']) && $_GET['collector_id'] != "") { $collector_id = $_GET['collector_id']; } $hostname = $hostAndIP[0]; $hostIP = $hostAndIP[1]; $value = _("no IP"); if (strcmp($hostIP, $value) == 0) { $hostIP = "0.0.0.0"; } /* * Insert into Database informations */ $pearCentreonDB = new SyslogDB("centreon"); $DBRESULT =& $pearCentreonDB->query("SELECT `host_id` FROM `host` WHERE `host_address` = '" . $hostIP . "' OR `host_name` LIKE '%" . $hostname . "%' OR `host_alias` LIKE '%" . $hostname . "%'"); $result = $DBRESULT->fetchRow(); if ($DBRESULT->numRows() == 1) { $query = "INSERT INTO mod_syslog_hosts (id, collector_id, host_centreon_id, host_syslog_name, host_syslog_ipv4, state) VALUES ('', {$collector_id}, '" . $result["host_id"] . "', '" . $hostname . "', '" . $hostIP . "', '1');"; } else { $query = "INSERT INTO mod_syslog_hosts (id, collector_id, host_centreon_id, host_syslog_name, host_syslog_ipv4, state) VALUES ('', {$collector_id}, NULL, '" . $hostname . "', '" . $hostIP . "', '2');"; } $pearCentreonDB->query($query); }