Example #1
0
function syslog_is_partitioned()
{
    global $syslogdb_default;
    /* see if the table is partitioned */
    $syntax = syslog_db_fetch_row("SHOW CREATE TABLE `" . $syslogdb_default . "`.`syslog`");
    if (substr_count($syntax["Create Table"], "PARTITION")) {
        return true;
    } else {
        return false;
    }
}
Example #2
0
function syslog_action_edit()
{
    global $colors, $message_types, $severities;
    include dirname(__FILE__) . "/config.php";
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("type"));
    /* ==================================================== */
    if (isset($_GET["id"]) && $_GET["action"] == "edit") {
        $alert = syslog_db_fetch_row("SELECT *\n\t\t\tFROM `" . $syslogdb_default . "`.`syslog_alert`\n\t\t\tWHERE id=" . $_GET["id"]);
        $header_label = "[edit: " . $alert["name"] . "]";
    } else {
        if (isset($_GET["id"]) && $_GET["action"] == "newedit") {
            $syslog_rec = syslog_db_fetch_row("SELECT * FROM `" . $syslogdb_default . "`.`syslog` WHERE seq=" . $_GET["id"] . " AND logtime='" . $_GET["date"] . "'");
            $header_label = "[new]";
            if (sizeof($syslog_rec)) {
                $alert["message"] = $syslog_rec["message"];
            }
            $alert["name"] = "New Alert Rule";
        } else {
            $header_label = "[new]";
            $alert["name"] = "New Alert Rule";
        }
    }
    $alert_retention = read_config_option("syslog_alert_retention");
    if ($alert_retention != '' && $alert_retention > 0 && $alert_retention < 365) {
        $repeat_end = $alert_retention * 24 * 60 / 5;
    }
    $repeatarray = array(0 => 'Not Set', 1 => '5 Minutes', 2 => '10 Minutes', 3 => '15 Minutes', 4 => '20 Minutes', 6 => '30 Minutes', 8 => '45 Minutes', 12 => '1 Hour', 24 => '2 Hours', 36 => '3 Hours', 48 => '4 Hours', 72 => '6 Hours', 96 => '8 Hours', 144 => '12 Hours', 288 => '1 Day', 576 => '2 Days', 2016 => '1 Week', 4032 => '2 Weeks', 8640 => 'Month');
    if ($repeat_end) {
        foreach ($repeatarray as $i => $value) {
            if ($i > $repeat_end) {
                unset($repeatarray[$i]);
            }
        }
    }
    html_start_box("<strong>Alert Edit</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    $fields_syslog_alert_edit = array("spacer0" => array("method" => "spacer", "friendly_name" => "Alert Details"), "name" => array("method" => "textbox", "friendly_name" => "Alert Name", "description" => "Please describe this Alert.", "value" => "|arg1:name|", "max_length" => "250", "size" => 80), "severity" => array("method" => "drop_array", "friendly_name" => "Severity", "description" => "What is the Severity Level of this Alert?", "value" => "|arg1:severity|", "array" => $severities, "default" => "1"), "method" => array("method" => "drop_array", "friendly_name" => "Reporting Method", "description" => "Define how to Alert on the syslog messages.", "value" => "|arg1:method|", "array" => array("0" => "Individual", "1" => "Threshold"), "default" => "0"), "num" => array("method" => "textbox", "friendly_name" => "Threshold", "description" => "For the 'Threshold' method, If the number seen is above this value\n\t\tan Alert will be triggered.", "value" => "|arg1:num|", "size" => "4", "max_length" => "10", "default" => "1"), "type" => array("method" => "drop_array", "friendly_name" => "String Match Type", "description" => "Define how you would like this string matched.  If using the SQL Expression type you may use any valid SQL expression\n\t\tto generate the alarm.  Available fields include 'message', 'facility', 'priority', and 'host'.", "value" => "|arg1:type|", "array" => $message_types, "on_change" => "changeTypes()", "default" => "matchesc"), "message" => array("friendly_name" => "Syslog Message Match String", "description" => "The matching component of the syslog message.", "textarea_rows" => "2", "textarea_cols" => "70", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:message|", "default" => ""), "enabled" => array("method" => "drop_array", "friendly_name" => "Alert Enabled", "description" => "Is this Alert Enabled?", "value" => "|arg1:enabled|", "array" => array("on" => "Enabled", "" => "Disabled"), "default" => "on"), "repeat_alert" => array("friendly_name" => "Re-Alert Cycle", "method" => "drop_array", "array" => $repeatarray, "default" => "0", "description" => "Do not resend this alert again for the same host, until this amount of time has elapsed. For threshold\n\t\tbased alarms, this applies to all hosts.", "value" => "|arg1:repeat_alert|"), "notes" => array("friendly_name" => "Alert Notes", "textarea_rows" => "5", "textarea_cols" => "70", "description" => "Space for Notes on the Alert", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:notes|", "default" => ""), "spacer1" => array("method" => "spacer", "friendly_name" => "Alert Actions"), "open_ticket" => array("method" => "drop_array", "friendly_name" => "Open Ticket", "description" => "Should a Help Desk Ticket be opened for this Alert", "value" => "|arg1:open_ticket|", "array" => array("on" => "Yes", "" => "No"), "default" => ""), "email" => array("method" => "textarea", "friendly_name" => "E-Mails to Notify", "textarea_rows" => "5", "textarea_cols" => "70", "description" => "Please enter a comma delimited list of e-mail addresses to inform.  If you\n\t\twish to send out e-mail to a recipient in SMS format, please prefix that recipient's e-mail address\n\t\twith <b>'sms@'</b>.  For example, if the recipients SMS address is <b>'*****@*****.**'</b>, you would\n\t\tenter it as <b>'sms@2485551212@mycarrier.net'</b> and it will be formatted as an SMS message.", "class" => "textAreaNotes", "value" => "|arg1:email|", "max_length" => "255"), "command" => array("friendly_name" => "Alert Command", "textarea_rows" => "5", "textarea_cols" => "70", "description" => "When an Alert is triggered, run the following command.  The following replacement variables\n\t\tare available <b>'&lt;HOSTNAME&gt;'</b>, <b>'&lt;ALERTID&gt;'</b>, <b>'&lt;MESSAGE&gt;'</b>,\n\t\t<b>'&lt;FACILITY&gt;'</b>, <b>'&lt;PRIORITY&gt;'</b>, <b>'&lt;SEVERITY&gt;'</b>.  Please\n\t\tnote that <b>'&lt;HOSTNAME&gt;'</b> is only available on individual thresholds.", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:command|", "default" => ""), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "_id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_alert" => array("method" => "hidden", "value" => "1"));
    echo "<form method='post' autocomplete='off' onsubmit='changeTypes()' action='syslog_alerts.php' name='chk'>";
    draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => inject_form_variables($fields_syslog_alert_edit, isset($alert) ? $alert : array())));
    html_end_box();
    form_save_button("syslog_alerts.php", "", "id");
    ?>
	<script type='text/javascript'>
	function changeTypes() {
		if (document.getElementById('type').value == 'sql') {
			document.getElementById('message').rows = 6;
		}else{
			document.getElementById('message').rows = 2;
		}
	}
	</script>
	<?php 
}
Example #3
0
function syslog_uninstall_advisor()
{
    global $config, $colors;
    include dirname(__FILE__) . '/config.php';
    syslog_connect();
    $syslog_exists = sizeof(syslog_db_fetch_row('SHOW TABLES FROM `' . $syslogdb_default . "` LIKE 'syslog'"));
    top_header();
    $fields_syslog_update = array('uninstall_method' => array('method' => 'drop_array', 'friendly_name' => __('What uninstall method do you want to use?'), 'description' => __('When uninstalling syslog, you can remove everything, or only components, just in case you plan on re-installing in the future.'), 'value' => 'all', 'array' => array('all' => __('Remove Everything (Logs, Tables, Settings)'), 'syslog' => __('Syslog Data Only'))), 'mode' => array('method' => 'hidden', 'value' => 'uninstall'), 'id' => array('method' => 'hidden', 'value' => 'syslog'));
    print "<form action='plugins.php' method='get'>\n";
    print "<table align='center' width='80%'><tr><td>\n";
    html_start_box(__('Syslog Uninstall Preferences'), '100%', $colors['header'], '3', 'center', '');
    draw_edit_form(array('config' => array(), 'fields' => inject_form_variables($fields_syslog_update, array())));
    html_end_box();
    syslog_confirm_button('uninstall', 'plugins.php', $syslog_exists);
    print "</td></tr></table>\n";
    bottom_footer();
    exit;
}
Example #4
0
function syslog_action_edit()
{
    global $message_types;
    include dirname(__FILE__) . '/config.php';
    /* ================= input validation ================= */
    get_filter_request_var('id');
    get_filter_request_var('type');
    get_filter_request_var('date');
    /* ==================================================== */
    if (isset_request_var('id') && get_nfilter_request_var('action') == 'edit') {
        $removal = syslog_db_fetch_row('SELECT *
			FROM `' . $syslogdb_default . '`.`syslog_remove`
			WHERE id=' . get_request_var('id'));
        if (sizeof($removal)) {
            $header_label = __('Removal Rule Edit [edit: %s]', $removal['name']);
        } else {
            $header_label = __('Removal Rule Edit [new]');
            $removal['name'] = __('New Removal Record');
        }
    } else {
        if (isset_request_var('id') && get_nfilter_request_var('action') == 'newedit') {
            $syslog_rec = syslog_db_fetch_row('SELECT * FROM `' . $syslogdb_default . '`.`syslog` WHERE seq=' . get_request_var('id') . (isset_request_var('date') ? " AND logtime='" . get_request_var('date') . "'" : ""));
            $header_label = __('Removal Rule Edit [new]');
            if (sizeof($syslog_rec)) {
                $removal['message'] = $syslog_rec['message'];
            }
            $removal['name'] = __('New Removal Rule');
        } else {
            $header_label = '[new]';
            $removal['name'] = __('New Removal Record');
        }
    }
    $fields_syslog_removal_edit = array('spacer0' => array('method' => 'spacer', 'friendly_name' => __('Removel Rule Details')), 'name' => array('method' => 'textbox', 'friendly_name' => __('Removal Rule Name'), 'description' => __('Please describe this Removal Rule.'), 'value' => '|arg1:name|', 'max_length' => '250', 'size' => 80), 'enabled' => array('method' => 'drop_array', 'friendly_name' => __('Enabled?'), 'description' => __('Is this Removal Rule Enabled?'), 'value' => '|arg1:enabled|', 'array' => array('on' => __('Enabled'), '' => __('Disabled')), 'default' => 'on'), 'type' => array('method' => 'drop_array', 'friendly_name' => __('String Match Type'), 'description' => __('Define how you would like this string matched.  If using the SQL Expression type you may use any valid SQL expression
			to generate the alarm.  Available fields include \'message\', \'facility\', \'priority\', and \'host\'.'), 'value' => '|arg1:type|', 'array' => $message_types, 'on_change' => 'changeTypes()', 'default' => 'matchesc'), 'message' => array('friendly_name' => __('Syslog Message Match String'), 'description' => __('Enter the matching component of the syslog message, the facility or host name, or the SQL where clause if using the SQL Expression Match Type.'), 'method' => 'textarea', 'textarea_rows' => '2', 'textarea_cols' => '70', 'class' => 'textAreaNotes', 'value' => '|arg1:message|', 'default' => ''), 'rmethod' => array('method' => 'drop_array', 'friendly_name' => __('Method of Removal'), 'value' => '|arg1:method|', 'array' => array('del' => __('Deletion'), 'trans' => __('Transferal')), 'default' => 'del'), 'notes' => array('friendly_name' => __('Removal Rule Notes'), 'textarea_rows' => '5', 'textarea_cols' => '70', 'description' => __('Space for Notes on the Removal rule'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'value' => '|arg1:notes|', 'default' => ''), 'id' => array('method' => 'hidden_zero', 'value' => '|arg1:id|'), '_id' => array('method' => 'hidden_zero', 'value' => '|arg1:id|'), 'save_component_removal' => array('method' => 'hidden', 'value' => '1'));
    form_start('syslog_removal.php', 'syslog_edit');
    html_start_box($header_label, '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_syslog_removal_edit, isset($removal) ? $removal : array())));
    html_end_box();
    form_save_button('syslog_removal.php', '', 'id');
    ?>
	<script type='text/javascript'>
	function changeTypes() {
		if ($('#type').val == 'sql') {
			$('#message').prop('rows', 5);
		}else{
			$('#message').prop('rows', 2);
		}
	}
	</script>
	<?php 
}
Example #5
0
function syslog_action_edit()
{
    global $colors, $message_types, $syslog_freqs, $syslog_times;
    include dirname(__FILE__) . "/config.php";
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("type"));
    /* ==================================================== */
    if (isset($_GET["id"])) {
        $report = syslog_db_fetch_row("SELECT *\n\t\t\tFROM `" . $syslogdb_default . "`.`syslog_reports`\n\t\t\tWHERE id=" . $_GET["id"]);
        $header_label = "[edit: " . $report["name"] . "]";
    } else {
        $header_label = "[new]";
        $report["name"] = "New Report Record";
    }
    html_start_box("<strong>Report Edit</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    $fields_syslog_report_edit = array("spacer0" => array("method" => "spacer", "friendly_name" => "Report Details"), "name" => array("method" => "textbox", "friendly_name" => "Report Name", "description" => "Please describe this Report.", "value" => "|arg1:name|", "max_length" => "250"), "enabled" => array("method" => "drop_array", "friendly_name" => "Enabled?", "description" => "Is this Report Enabled?", "value" => "|arg1:enabled|", "array" => array("on" => "Enabled", "" => "Disabled"), "default" => "on"), "type" => array("method" => "drop_array", "friendly_name" => "String Match Type", "description" => "Define how you would like this string matched.", "value" => "|arg1:type|", "array" => $message_types, "default" => "matchesc"), "message" => array("method" => "textbox", "friendly_name" => "Syslog Message Match String", "description" => "The matching component of the syslog message.", "value" => "|arg1:message|", "default" => "", "max_length" => "255"), "timespan" => array("method" => "drop_array", "friendly_name" => "Report Frequency", "description" => "How often should this Report be sent to the distribution list?", "value" => "|arg1:timespan|", "array" => $syslog_freqs, "default" => "del"), "timepart" => array("method" => "drop_array", "friendly_name" => "Send Time", "description" => "What time of day should this report be sent?", "value" => "|arg1:timepart|", "array" => $syslog_times, "default" => "del"), "message" => array("friendly_name" => "Syslog Message Match String", "description" => "The matching component of the syslog message.", "method" => "textbox", "max_length" => "255", "value" => "|arg1:message|", "default" => ""), "body" => array("friendly_name" => "Report Body Text", "textarea_rows" => "5", "textarea_cols" => "60", "description" => "The information that will be contained in the body of the report.", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:body|", "default" => ""), "email" => array("friendly_name" => "Report e-mail Addresses", "textarea_rows" => "3", "textarea_cols" => "60", "description" => "Comma delimited list of e-mail addresses to send the report to.", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:email|", "default" => ""), "notes" => array("friendly_name" => "Report Notes", "textarea_rows" => "3", "textarea_cols" => "60", "description" => "Space for Notes on the Report", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:notes|", "default" => ""), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "_id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_report" => array("method" => "hidden", "value" => "1"));
    draw_edit_form(array("config" => array("form_name" => "chk"), "fields" => inject_form_variables($fields_syslog_report_edit, isset($report) ? $report : array())));
    html_end_box();
    form_save_button("syslog_reports.php", "", "id");
}
Example #6
0
}
$options["engine"] = $engine;
$options["db_type"] = $type;
$options["days"] = $days;
$options["upgrade_type"] = "background";
/* record the start time */
list($micro, $seconds) = explode(" ", microtime());
$start_time = $seconds + $micro;
$dir = dirname(__FILE__);
chdir($dir);
if (strpos($dir, 'plugins') !== false) {
    chdir('../../');
}
include "./include/global.php";
include_once dirname(__FILE__) . "/setup.php";
include dirname(__FILE__) . "/config.php";
include_once dirname(__FILE__) . "/functions.php";
/* Connect to the Syslog Database */
syslog_connect();
if (sizeof(syslog_db_fetch_row("SHOW TABLES IN " . $syslogdb_default . " LIKE 'syslog'"))) {
    syslog_db_execute("RENAME TABLE `" . $syslogdb_default . "`.`syslog` TO `" . $syslogdb_default . "`.`syslog_pre_upgrade`");
}
/* perform the upgrade */
syslog_upgrade_pre_oneoh_tables($options, true);
cacti_log("SYSLOG NOTE: Background Syslog Database Upgrade Process Completed", false, "SYSTEM");
function display_help()
{
    echo "Syslog Database Upgrade, Copyright 2004-2011 - The Cacti Group\n\n";
    echo "Syslog Database Upgrade script for Cacti Syslogging.\n\n";
    echo "usage: syslog_upgrade.php --type=trad|part --engine=MyISAM|InnoDB --days=N [--debug|-d]\n\n";
}
Example #7
0
function syslog_graph_buttons($graph_elements = array())
{
    global $config, $timespan, $graph_timeshifts;
    include dirname(__FILE__) . "/config.php";
    if ($_REQUEST["action"] == "view") {
        return;
    }
    if (isset($_REQUEST["graph_end"]) && strlen($_REQUEST["graph_end"])) {
        $date1 = date("Y-m-d H:i:s", $_REQUEST["graph_start"]);
        $date2 = date("Y-m-d H:i:s", $_REQUEST["graph_end"]);
    } else {
        $date1 = $timespan["current_value_date1"];
        $date2 = $timespan["current_value_date2"];
    }
    if (isset($graph_elements[1]["local_graph_id"])) {
        $graph_local = db_fetch_row("SELECT * FROM graph_local WHERE id='" . $graph_elements[1]["local_graph_id"] . "'");
        if (isset($graph_local["host_id"])) {
            $host = db_fetch_row("SELECT * FROM host WHERE id='" . $graph_local["host_id"] . "'");
            if (sizeof($host)) {
                $host = syslog_db_fetch_row("SELECT * FROM `" . $syslogdb_default . "`.`syslog_hosts` WHERE host LIKE '%%" . $host["hostname"] . "%%'");
                if (sizeof($host)) {
                    print "<a href='" . $config["url_path"] . "plugins/syslog/syslog.php?tab=syslog&host%5B%5D=" . $host["host_id"] . "&date1=" . $date1 . "&date2=" . $date2 . "&efacility=0&elevel=0'><img src='" . $config['url_path'] . "plugins/syslog/images/view_syslog.gif' border='0' alt='Display Syslog in Range' title='Display Syslog in Range' style='padding: 3px;'></a><br>";
                }
            }
        }
    }
}
Example #8
0
function syslog_action_edit()
{
    global $colors, $message_types;
    include dirname(__FILE__) . "/config.php";
    /* ================= input validation ================= */
    input_validate_input_number(get_request_var("id"));
    input_validate_input_number(get_request_var("type"));
    /* ==================================================== */
    if (isset($_GET["id"]) && $_GET["action"] == "edit") {
        $removal = syslog_db_fetch_row("SELECT *\n\t\t\tFROM `" . $syslogdb_default . "`.`syslog_remove`\n\t\t\tWHERE id=" . $_GET["id"]);
        $header_label = "[edit: " . $removal["name"] . "]";
    } else {
        if (isset($_GET["id"]) && $_GET["action"] == "newedit") {
            $syslog_rec = syslog_db_fetch_row("SELECT * FROM `" . $syslogdb_default . "`.`syslog` WHERE seq=" . $_GET["id"] . " AND logtime='" . $_GET["date"] . "'");
            $header_label = "[new]";
            if (sizeof($syslog_rec)) {
                $removal["message"] = $syslog_rec["message"];
            }
            $removal["name"] = "New Removal Rule";
        } else {
            $header_label = "[new]";
            $removal["name"] = "New Removal Record";
        }
    }
    html_start_box("<strong>Removal Rule Edit</strong> {$header_label}", "100%", $colors["header"], "3", "center", "");
    $fields_syslog_removal_edit = array("spacer0" => array("method" => "spacer", "friendly_name" => "Removel Rule Details"), "name" => array("method" => "textbox", "friendly_name" => "Removal Rule Name", "description" => "Please describe this Removal Rule.", "value" => "|arg1:name|", "max_length" => "250", "size" => 80), "enabled" => array("method" => "drop_array", "friendly_name" => "Enabled?", "description" => "Is this Removal Rule Enabled?", "value" => "|arg1:enabled|", "array" => array("on" => "Enabled", "" => "Disabled"), "default" => "on"), "type" => array("method" => "drop_array", "friendly_name" => "String Match Type", "description" => "Define how you would like this string matched.  If using the SQL Expression type you may use any valid SQL expression\n\t\tto generate the alarm.  Available fields include 'message', 'facility', 'priority', and 'host'.", "value" => "|arg1:type|", "array" => $message_types, "on_change" => "changeTypes()", "default" => "matchesc"), "message" => array("friendly_name" => "Syslog Message Match String", "description" => "The matching component of the syslog message.", "method" => "textarea", "textarea_rows" => "2", "textarea_cols" => "70", "class" => "textAreaNotes", "value" => "|arg1:message|", "default" => ""), "method" => array("method" => "drop_array", "friendly_name" => "Method of Removal", "value" => "|arg1:method|", "array" => array("del" => "Deletion", "trans" => "Transferal"), "default" => "del"), "notes" => array("friendly_name" => "Removal Rule Notes", "textarea_rows" => "5", "textarea_cols" => "70", "description" => "Space for Notes on the Removal rule", "method" => "textarea", "class" => "textAreaNotes", "value" => "|arg1:notes|", "default" => ""), "id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "_id" => array("method" => "hidden_zero", "value" => "|arg1:id|"), "save_component_removal" => array("method" => "hidden", "value" => "1"));
    echo "<form method='post' autocomplete='off' onsubmit='changeTypes()' action='syslog_removal.php' name='chk'>";
    draw_edit_form(array("config" => array("no_form_tag" => true), "fields" => inject_form_variables($fields_syslog_removal_edit, isset($removal) ? $removal : array())));
    html_end_box();
    form_save_button("syslog_removal.php", "", "id");
    ?>
	<script type='text/javascript'>
	function changeTypes() {
		if (document.getElementById('type').value == 'sql') {
			document.getElementById('message').rows = 5;
		}else{
			document.getElementById('message').rows = 2;
		}
	}
	</script>
	<?php 
}
 | as published by the Free Software Foundation; either version 2          |
 | of the License, or (at your option) any later version.                  |
 |                                                                         |
 | This program is distributed in the hope that it will be useful,         |
 | but WITHOUT ANY WARRANTY; without even the implied warranty of          |
 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the           |
 | GNU General Public License for more details.                            |
 +-------------------------------------------------------------------------+
 | Cacti: The Complete RRDTool-based Graphing Solution                     |
 +-------------------------------------------------------------------------+
 | This code is designed, written, and maintained by the Cacti Group. See  |
 | about.php and/or the AUTHORS file for specific developer information.   |
 +-------------------------------------------------------------------------+
 | http://www.cacti.net/                                                   |
 +-------------------------------------------------------------------------+
*/
/* do NOT run this script through a web browser */
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
    die("<br><strong>This script is only meant to run at the command line.</strong>");
}
$no_http_headers = true;
chdir(dirname(__FILE__) . '/../../');
include dirname(__FILE__) . '/../../include/global.php';
echo "NOTE: Fixing Warning vs. Warn Errors\n";
$found = syslog_db_fetch_row("SELECT * FROM syslog_priorities WHERE priority='warning' LIMIT 1");
if (sizeof($found)) {
    syslog_db_execute("UPDATE syslog SET priority_id=5 WHERE priority_id=" . $found["priority_id"]);
    syslog_db_execute("UPDATE syslog_statistics SET priority_id=5 WHERE priority_id=" . $found["priority_id"]);
    syslog_db_execute("DELETE FROM syslog_priorities WHERE priority='warning'");
}
echo "NOTE: Finished\n";
Example #10
0
if (!isset($_SERVER["argv"][0]) || isset($_SERVER['REQUEST_METHOD']) || isset($_SERVER['REMOTE_ADDR'])) {
    die("<br><strong>This script is only meant to run at the command line.</strong>");
}
$no_http_headers = true;
// PHP5 uses a different base path apparently
if (file_exists('include/auth.php')) {
    include dirname(__FILE__) . '/../../include/global.php';
} else {
    chdir('../../');
    include dirname(__FILE__) . '/../../include/global.php';
}
$sli = read_config_option("syslog_last_incoming");
$slt = read_config_option("syslog_last_total");
$line = syslog_db_fetch_row("SHOW TABLE STATUS LIKE 'syslog_incoming'");
$i_rows = $line['Auto_increment'];
$line = syslog_db_fetch_row("SHOW TABLE STATUS LIKE 'syslog'");
$total_rows = $line['Auto_increment'];
if ($sli == "") {
    $sql = "REPLACE INTO settings VALUES ('syslog_last_incoming','{$i_rows}')";
} else {
    $sql = "UPDATE settings SET value='{$i_rows}' WHERE name='syslog_last_incoming'";
}
db_execute($sql);
if ($slt == "") {
    $sql = "REPLACE INTO settings VALUES ('syslog_last_total','{$total_rows}')";
} else {
    $sql = "UPDATE settings SET value='{$total_rows}' WHERE name='syslog_last_total'";
}
db_execute($sql);
if ($sli == '') {
    $sli = 0;
Example #11
0
function syslog_action_edit()
{
    global $colors, $message_types, $syslog_freqs, $syslog_times;
    include dirname(__FILE__) . '/config.php';
    /* ================= input validation ================= */
    get_filter_request_var('id');
    get_filter_request_var('type');
    /* ==================================================== */
    if (isset_request_var('id')) {
        $report = syslog_db_fetch_row('SELECT *
			FROM `' . $syslogdb_default . '`.`syslog_reports`
			WHERE id=' . get_request_var('id'));
        if (sizeof($report)) {
            $header_label = __('Report Edit [edit: %s]', $report['name']);
        } else {
            $header_label = __('Report Edit [new]');
            $report['name'] = __('New Report Record');
        }
    } else {
        $header_label = __('Report Edit [new]');
        $report['name'] = __('New Report Record');
    }
    $fields_syslog_report_edit = array('spacer0' => array('method' => 'spacer', 'friendly_name' => __('Report Details')), 'name' => array('method' => 'textbox', 'friendly_name' => __('Report Name'), 'description' => __('Please describe this Report.'), 'value' => '|arg1:name|', 'max_length' => '250'), 'enabled' => array('method' => 'drop_array', 'friendly_name' => __('Enabled?'), 'description' => __('Is this Report Enabled?'), 'value' => '|arg1:enabled|', 'array' => array('on' => __('Enabled'), '' => __('Disabled')), 'default' => 'on'), 'type' => array('method' => 'drop_array', 'friendly_name' => __('String Match Type'), 'description' => __('Define how you would like this string matched.'), 'value' => '|arg1:type|', 'array' => $message_types, 'default' => 'matchesc'), 'message' => array('method' => 'textbox', 'friendly_name' => __('Syslog Message Match String'), 'description' => __('The matching component of the syslog message.'), 'value' => '|arg1:message|', 'default' => '', 'max_length' => '255'), 'timespan' => array('method' => 'drop_array', 'friendly_name' => __('Report Frequency'), 'description' => __('How often should this Report be sent to the distribution list?'), 'value' => '|arg1:timespan|', 'array' => $syslog_freqs, 'default' => 'del'), 'timepart' => array('method' => 'drop_array', 'friendly_name' => __('Send Time'), 'description' => __('What time of day should this report be sent?'), 'value' => '|arg1:timepart|', 'array' => $syslog_times, 'default' => 'del'), 'message' => array('friendly_name' => __('Syslog Message Match String'), 'description' => __('The matching component of the syslog message.'), 'method' => 'textbox', 'max_length' => '255', 'value' => '|arg1:message|', 'default' => ''), 'body' => array('friendly_name' => __('Report Body Text'), 'textarea_rows' => '5', 'textarea_cols' => '60', 'description' => __('The information that will be contained in the body of the report.'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'value' => '|arg1:body|', 'default' => ''), 'email' => array('friendly_name' => __('Report e-mail Addresses'), 'textarea_rows' => '3', 'textarea_cols' => '60', 'description' => __('Comma delimited list of e-mail addresses to send the report to.'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'value' => '|arg1:email|', 'default' => ''), 'notes' => array('friendly_name' => __('Report Notes'), 'textarea_rows' => '3', 'textarea_cols' => '60', 'description' => __('Space for Notes on the Report'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'value' => '|arg1:notes|', 'default' => ''), 'id' => array('method' => 'hidden_zero', 'value' => '|arg1:id|'), '_id' => array('method' => 'hidden_zero', 'value' => '|arg1:id|'), 'save_component_report' => array('method' => 'hidden', 'value' => '1'));
    form_start('syslog_reports.php');
    html_start_box($header_label, '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('form_name' => 'chk'), 'fields' => inject_form_variables($fields_syslog_report_edit, isset($report) ? $report : array())));
    html_end_box();
    form_save_button('syslog_reports.php', '', 'id');
    form_end();
}
Example #12
0
function syslog_action_edit()
{
    global $message_types, $severities;
    include dirname(__FILE__) . '/config.php';
    /* ================= input validation ================= */
    get_filter_request_var('id');
    get_filter_request_var('type');
    get_filter_request_var('date');
    /* ==================================================== */
    if (!isempty_request_var('id') && get_nfilter_request_var('action') == 'edit') {
        $alert = syslog_db_fetch_row('SELECT *
			FROM `' . $syslogdb_default . '`.`syslog_alert`
			WHERE id=' . get_request_var('id'));
        if (sizeof($alert)) {
            $header_label = __('Alert Edit [edit: %s]' . $alert['name']);
        } else {
            $header_label = __('Alert Edit [new]');
        }
    } else {
        if (isset_request_var('id') && get_nfilter_request_var('action') == 'newedit') {
            $syslog_rec = syslog_db_fetch_row("SELECT * FROM `" . $syslogdb_default . "`.`syslog` WHERE seq=" . get_request_var("id") . (isset_request_var('date') ? " AND logtime='" . get_request_var("date") . "'" : ""));
            $header_label = __('Alert Ednt [new]');
            if (sizeof($syslog_rec)) {
                $alert['message'] = $syslog_rec['message'];
            }
            $alert['name'] = __('New Alert Rule');
        } else {
            $header_label = __('Alert Edit [new]');
            $alert['name'] = __('New Alert Rule');
        }
    }
    $alert_retention = read_config_option('syslog_alert_retention');
    if ($alert_retention != '' && $alert_retention > 0 && $alert_retention < 365) {
        $repeat_end = $alert_retention * 24 * 60 / 5;
    }
    $repeatarray = array(0 => __('Not Set'), 1 => __('%d Minutes', 5), 2 => __('%d Minutes', 10), 3 => __('%d Minutes', 15), 4 => __('%d Minutes', 20), 6 => __('%d Minutes', 30), 8 => __('%d Minutes', 45), 12 => __('%d Hour', 1), 24 => __('%d Hours', 2), 36 => __('%d Hours', 3), 48 => __('%d Hours', 4), 72 => __('%d Hours', 6), 96 => __('%d Hours', 8), 144 => __('%d Hours', 12), 288 => __('%d Day', 1), 576 => __('%d Days', 2), 2016 => __('%d Week', 1), 4032 => __('%d Weeks', 2), 8640 => __('Month'));
    if ($repeat_end) {
        foreach ($repeatarray as $i => $value) {
            if ($i > $repeat_end) {
                unset($repeatarray[$i]);
            }
        }
    }
    $fields_syslog_alert_edit = array('spacer0' => array('method' => 'spacer', 'friendly_name' => __('Alert Details')), 'name' => array('method' => 'textbox', 'friendly_name' => __('Alert Name'), 'description' => __('Please describe this Alert.'), 'value' => '|arg1:name|', 'max_length' => '250', 'size' => 80), 'severity' => array('method' => 'drop_array', 'friendly_name' => __('Severity'), 'description' => __('What is the Severity Level of this Alert?'), 'value' => '|arg1:severity|', 'array' => $severities, 'default' => '1'), 'report_method' => array('method' => 'drop_array', 'friendly_name' => __('Reporting Method'), 'description' => __('Define how to Alert on the syslog messages.'), 'value' => '|arg1:method|', 'array' => array('0' => __('Individual'), '1' => __('Threshold')), 'default' => '0'), 'num' => array('method' => 'textbox', 'friendly_name' => __('Threshold'), 'description' => __('For the \'Threshold\' method, If the number seen is above this value an Alert will be triggered.'), 'value' => '|arg1:num|', 'size' => '4', 'max_length' => '10', 'default' => '1'), 'type' => array('method' => 'drop_array', 'friendly_name' => __('String Match Type'), 'description' => __('Define how you would like this string matched.  If using the SQL Expression type you may use any valid SQL expression
			to generate the alarm.  Available fields include \'message\', \'facility\', \'priority\', and \'host\'.'), 'value' => '|arg1:type|', 'array' => $message_types, 'on_change' => 'changeTypes()', 'default' => 'matchesc'), 'message' => array('friendly_name' => __('Syslog Message Match String'), 'description' => __('Enter the matching component of the syslog message, the facility or host name, or the SQL where clause if using the SQL Expression Match Type.'), 'textarea_rows' => '2', 'textarea_cols' => '70', 'method' => 'textarea', 'class' => 'textAreaNotes', 'value' => '|arg1:message|', 'default' => ''), 'enabled' => array('method' => 'drop_array', 'friendly_name' => __('Alert Enabled'), 'description' => __('Is this Alert Enabled?'), 'value' => '|arg1:enabled|', 'array' => array('on' => __('Enabled'), '' => __('Disabled')), 'default' => 'on'), 'repeat_alert' => array('friendly_name' => __('Re-Alert Cycle'), 'method' => 'drop_array', 'array' => $repeatarray, 'default' => '0', 'description' => __('Do not resend this alert again for the same host, until this amount of time has elapsed. For threshold based alarms, this applies to all hosts.'), 'value' => '|arg1:repeat_alert|'), 'notes' => array('friendly_name' => __('Alert Notes'), 'textarea_rows' => '5', 'textarea_cols' => '70', 'description' => __('Space for Notes on the Alert'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'value' => '|arg1:notes|', 'default' => ''), 'spacer1' => array('method' => 'spacer', 'friendly_name' => __('Alert Actions')), 'open_ticket' => array('method' => 'drop_array', 'friendly_name' => __('Open Ticket'), 'description' => __('Should a Help Desk Ticket be opened for this Alert'), 'value' => '|arg1:open_ticket|', 'array' => array('on' => __('Yes'), '' => __('No')), 'default' => ''), 'email' => array('method' => 'textarea', 'friendly_name' => __('E-Mails to Notify'), 'textarea_rows' => '5', 'textarea_cols' => '70', 'description' => __('Please enter a comma delimited list of e-mail addresses to inform.  If you
			wish to send out e-mail to a recipient in SMS format, please prefix that recipient\'s e-mail address
			with <b>\'sms@\'</b>.  For example, if the recipients SMS address is <b>\'2485551212@mycarrier.net\'</b>, you would
			enter it as <b>\'sms@2485551212@mycarrier.net\'</b> and it will be formatted as an SMS message.'), 'class' => 'textAreaNotes', 'value' => '|arg1:email|', 'max_length' => '255'), 'command' => array('friendly_name' => __('Alert Command'), 'textarea_rows' => '5', 'textarea_cols' => '70', 'description' => __('When an Alert is triggered, run the following command.  The following replacement variables
			are available <b>\'&lt;HOSTNAME&gt;\'</b>, <b>\'&lt;ALERTID&gt;\'</b>, <b>\'&lt;MESSAGE&gt;\'</b>,
			<b>\'&lt;FACILITY&gt;\'</b>, <b>\'&lt;PRIORITY&gt;\'</b>, <b>\'&lt;SEVERITY&gt;\'</b>.  Please
			note that <b>\'&lt;HOSTNAME&gt;\'</b> is only available on individual thresholds.'), 'method' => 'textarea', 'class' => 'textAreaNotes', 'value' => '|arg1:command|', 'default' => ''), 'id' => array('method' => 'hidden_zero', 'value' => '|arg1:id|'), '_id' => array('method' => 'hidden_zero', 'value' => '|arg1:id|'), 'save_component_alert' => array('method' => 'hidden', 'value' => '1'));
    form_start('syslog_alerts.php', 'syslog_edit');
    html_start_box($header_label, '100%', '', '3', 'center', '');
    draw_edit_form(array('config' => array('no_form_tag' => true), 'fields' => inject_form_variables($fields_syslog_alert_edit, sizeof($alert) ? $alert : array())));
    html_end_box();
    form_save_button('syslog_alerts.php', '', 'id');
    ?>
	<script type='text/javascript'>

	function changeTypes() {
		if ($('#type').val() == 'sql') {
			$('#message').prep('rows', 6);
		}else{
			$('#message').prep('rows', 2);
		}
	}
	</script>

	<?php 
}