Exemplo n.º 1
0
function syslog_setup_table_new($options)
{
    global $config, $cnn_id, $settings, $syslog_incoming_config, $syslog_levels, $database_default, $database_hostname, $database_username;
    include dirname(__FILE__) . '/config.php';
    $tables = array();
    $syslog_levels = array(0 => 'emerg', 1 => 'crit', 2 => 'alert', 3 => 'err', 4 => 'warn', 5 => 'notice', 6 => 'info', 7 => 'debug', 8 => 'other');
    syslog_connect();
    /* validate some simple information */
    $mysqlVersion = syslog_get_mysql_version('syslog');
    $truncate = isset($options['upgrade_type']) && $options['upgrade_type'] == 'truncate' ? true : false;
    $engine = isset($options['engine']) && $options['engine'] == 'innodb' ? 'InnoDB' : 'MyISAM';
    $partitioned = isset($options['db_type']) && $options['db_type'] == 'part' ? true : false;
    $syslogexists = sizeof(syslog_db_fetch_row("SHOW TABLES FROM `" . $syslogdb_default . "` LIKE 'syslog'"));
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog`");
    }
    if (!$partitioned) {
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog` (\n\t\t\tfacility_id int(10) unsigned default NULL,\n\t\t\tpriority_id int(10) unsigned default NULL,\n\t\t\tprogram_id int(10) unsigned default NULL,\n\t\t\thost_id int(10) unsigned default NULL,\n\t\t\tlogtime TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\tmessage varchar(1024) NOT NULL default '',\n\t\t\tseq bigint unsigned NOT NULL auto_increment,\n\t\t\tPRIMARY KEY (seq),\n\t\t\tINDEX logtime (logtime),\n\t\t\tINDEX program_id (program_id),\n\t\t\tINDEX host_id (host_id),\n\t\t\tINDEX priority_id (priority_id),\n\t\t\tINDEX facility_id (facility_id)) ENGINE={$engine};");
    } else {
        syslog_create_partitioned_syslog_table($engine, $options['days']);
    }
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_alert`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_alert` (\n\t\t`id` int(10) NOT NULL auto_increment,\n\t\t`name` varchar(255) NOT NULL default '',\n\t\t`severity` int(10) UNSIGNED NOT NULL default '0',\n\t\t`method` int(10) unsigned NOT NULL default '0',\n\t\t`num` int(10) unsigned NOT NULL default '1',\n\t\t`type` varchar(16) NOT NULL default '',\n\t\t`enabled` CHAR(2) default 'on',\n\t\t`repeat_alert` int(10) unsigned NOT NULL default '0',\n\t\t`open_ticket` CHAR(2) default '',\n\t\t`message` VARCHAR(128) NOT NULL default '',\n\t\t`user` varchar(32) NOT NULL default '',\n\t\t`date` int(16) NOT NULL default '0',\n\t\t`email` varchar(255) default NULL,\n\t\t`command` varchar(255) default NULL,\n\t\t`notes` varchar(255) default NULL,\n\t\tPRIMARY KEY (id)) ENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_incoming`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_incoming` (\n\t\tfacility_id int(10) unsigned default NULL,\n\t\tpriority_id int(10) unsigned default NULL,\n\t\tprogram varchar(40) default NULL,\n\t\t`date` date default NULL,\n\t\t`time` time default NULL,\n\t\thost varchar(64) default NULL,\n\t\tmessage varchar(1024) NOT NULL DEFAULT '',\n\t\tseq bigint unsigned NOT NULL auto_increment,\n\t\t`status` tinyint(4) NOT NULL default '0',\n\t\tPRIMARY KEY (seq),\n\t\tINDEX program (program),\n\t\tINDEX `status` (`status`)) ENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_remove`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_remove` (\n\t\tid int(10) NOT NULL auto_increment,\n\t\tname varchar(255) NOT NULL default '',\n\t\t`type` varchar(16) NOT NULL default '',\n\t\tenabled CHAR(2) DEFAULT 'on',\n\t\tmethod CHAR(5) DEFAULT 'del',\n\t\tmessage VARCHAR(128) NOT NULL default '',\n\t\t`user` varchar(32) NOT NULL default '',\n\t\t`date` int(16) NOT NULL default '0',\n\t\tnotes varchar(255) default NULL,\n\t\tPRIMARY KEY (id)) ENGINE={$engine};");
    $present = syslog_db_fetch_row("SHOW TABLES FROM `" . $syslogdb_default . "` LIKE 'syslog_reports'");
    if (sizeof($present)) {
        $newreport = sizeof(syslog_db_fetch_row("SHOW COLUMNS FROM `" . $syslogdb_default . "`.`syslog_reports` LIKE 'body'"));
    } else {
        $newreport = true;
    }
    if ($truncate || !$newreport) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_reports`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_reports` (\n\t\tid int(10) NOT NULL auto_increment,\n\t\tname varchar(255) NOT NULL default '',\n\t\t`type` varchar(16) NOT NULL default '',\n\t\tenabled CHAR(2) DEFAULT 'on',\n\t\ttimespan int(16) NOT NULL default '0',\n\t\ttimepart char(5) NOT NULL default '00:00',\n\t\tlastsent int(16) NOT NULL default '0',\n\t\tbody " . ($mysqlVersion > 5 ? "varchar(1024)" : "text") . " default NULL,\n\t\tmessage varchar(128) default NULL,\n\t\t`user` varchar(32) NOT NULL default '',\n\t\t`date` int(16) NOT NULL default '0',\n\t\temail varchar(255) default NULL,\n\t\tnotes varchar(255) default NULL,\n\t\tPRIMARY KEY (id)) ENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_hosts`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_programs` (\n\t\t`program_id` int(10) unsigned NOT NULL auto_increment,\n\t\t`program` VARCHAR(40) NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY (`program`),\n\t\tINDEX host_id (`program_id`),\n\t\tINDEX last_updated (`last_updated`)) ENGINE={$engine}\n\t\tCOMMENT='Contains all programs currently in the syslog table'");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_hosts` (\n\t\t`host_id` int(10) unsigned NOT NULL auto_increment,\n\t\t`host` VARCHAR(64) NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY (`host`),\n\t\tINDEX host_id (`host_id`),\n\t\tINDEX last_updated (`last_updated`)) ENGINE={$engine}\n\t\tCOMMENT='Contains all hosts currently in the syslog table'");
    syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_facilities`");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_facilities` (\n\t\t`facility_id` int(10) unsigned NOT NULL,\n\t\t`facility` varchar(10) NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY  (`facility_id`),\n\t\tINDEX last_updated (`last_updated`)) ENGINE={$engine};");
    syslog_db_execute("INSERT INTO `" . $syslogdb_default . "`.`syslog_facilities` (facility_id, facility) VALUES \n\t\t(0,'kern'), (1,'user'), (2,'mail'), (3,'daemon'), (4,'auth'), (5,'syslog'), (6,'lpd'), (7,'news'), \n\t\t(8,'uucp'), (9,'crond'), (10,'authpriv'), (11,'ftpd'), (12,'ntpd'), (13,'logaudit'), (14,'logalert'), \n\t\t(15,'crond'), (16,'local0'), (17,'local1'), (18,'local2'), (19,'local3'), (20,'local4'), (21,'local5'), \n\t\t(22,'local6'), (23,'local7');");
    syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_priorities`");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_priorities` (\n\t\t`priority_id` int(10) unsigned NOT NULL,\n\t\t`priority` varchar(10) NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY (`priority_id`),\n\t\tINDEX last_updated (`last_updated`)) \n\t\tENGINE={$engine};");
    syslog_db_execute("INSERT INTO `" . $syslogdb_default . "`.`syslog_priorities` (priority_id, priority) VALUES \n\t\t(0,'emerg'), (1,'alert'), (2,'crit'), (3,'err'), (4,'warning'), (5,'notice'), (6,'info'), (7,'debug'), (8,'other');");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_host_facilities` (\n\t\t`host_id` int(10) unsigned NOT NULL,\n\t\t`facility_id` int(10) unsigned NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY  (`host_id`,`facility_id`)) \n\t\tENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_removed`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_removed` LIKE `" . $syslogdb_default . "`.`syslog`");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_logs` (\n\t\talert_id int(10) unsigned not null default '0',\n\t\tlogseq bigint unsigned NOT NULL,\n\t\tlogtime TIMESTAMP NOT NULL default '0000-00-00 00:00:00',\n\t\tlogmsg varchar(1024) default NULL,\n\t\thost varchar(64) default NULL,\n\t\tfacility_id int(10) unsigned default NULL,\n\t\tpriority_id int(10) unsigned default NULL,\n\t\tprogram_id int(10) unsigned default NULL,\n\t\tcount integer unsigned NOT NULL default '0',\n\t\thtml blob default NULL,\n\t\tseq bigint unsigned NOT NULL auto_increment,\n\t\tPRIMARY KEY (seq),\n\t\tINDEX `logseq` (`logseq`),\n\t\tINDEX `program_id` (`program_id`),\n\t\tINDEX `alert_id` (`alert_id`),\n\t\tINDEX `host` (`host`),\n\t\tINDEX `seq` (`seq`),\n\t\tINDEX `logtime` (`logtime`),\n\t\tINDEX `priority_id` (`priority_id`),\n\t\tINDEX `facility_id` (`facility_id`)) \n\t\tENGINE={$engine};");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_statistics` (\n\t\t`host_id` int(10) UNSIGNED NOT NULL,\n\t\t`facility_id` int(10) UNSIGNED NOT NULL,\n\t\t`priority_id` int(10) UNSIGNED NOT NULL,\n\t\t`program_id` int(10) unsigned default NULL,\n\t\t`insert_time` TIMESTAMP NOT NULL,\n\t\t`records` int(10) UNSIGNED NOT NULL,\n\t\tPRIMARY KEY (`host_id`, `facility_id`, `priority_id`, `insert_time`),\n\t\tINDEX `host_id`(`host_id`),\n\t\tINDEX `facility_id`(`facility_id`),\n\t\tINDEX `priority_id`(`priority_id`),\n\t\tINDEX `program_id` (`program_id`),\n\t\tINDEX `insert_time`(`insert_time`))\n\t\tENGINE = {$engine}\n\t\tCOMMENT = 'Maintains High Level Statistics';");
    if (!isset($settings['syslog'])) {
        syslog_config_settings();
    }
    foreach ($settings['syslog'] as $name => $values) {
        if (isset($values['default'])) {
            db_execute('REPLACE INTO `' . $database_default . "`.`settings` (name, value) VALUES ('{$name}', '" . $values['default'] . "')");
        }
    }
}
Exemplo n.º 2
0
function syslog_setup_table_new($options)
{
    global $config, $cnn_id, $settings, $syslog_incoming_config, $syslog_levels, $database_default, $database_hostname, $database_username;
    include dirname(__FILE__) . "/config.php";
    $tables = array();
    $syslog_levels = array(1 => 'emerg', 2 => 'crit', 3 => 'alert', 4 => 'err', 5 => 'warn', 6 => 'notice', 7 => 'info', 8 => 'debug', 9 => 'other');
    syslog_connect();
    /* validate some simple information */
    $mysqlVersion = syslog_get_mysql_version("syslog");
    $truncate = isset($options["upgrade_type"]) && $options["upgrade_type"] == "truncate" ? true : false;
    $engine = isset($options["engine"]) && $options["engine"] == "innodb" ? "InnoDB" : "MyISAM";
    $partitioned = isset($options["db_type"]) && $options["db_type"] == "part" ? true : false;
    $syslogexists = sizeof(syslog_db_fetch_row("SHOW TABLES FROM `" . $syslogdb_default . "` LIKE 'syslog'"));
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog`");
    }
    if (!$partitioned) {
        syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog` (\n\t\t\tfacility_id int(10) default NULL,\n\t\t\tpriority_id int(10) default NULL,\n\t\t\thost_id int(10) default NULL,\n\t\t\tlogtime TIMESTAMP NOT NULL DEFAULT '0000-00-00 00:00:00',\n\t\t\tmessage " . ($mysqlVersion > 5 ? "varchar(1024)" : "text") . " NOT NULL default '',\n\t\t\tseq bigint unsigned NOT NULL auto_increment,\n\t\t\tPRIMARY KEY (seq),\n\t\t\tKEY logtime (logtime),\n\t\t\tKEY host_id (host_id),\n\t\t\tKEY priority_id (priority_id),\n\t\t\tKEY facility_id (facility_id)) ENGINE={$engine};");
    } else {
        syslog_create_partitioned_syslog_table($engine, $options["days"]);
    }
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_alert`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_alert` (\n\t\t`id` int(10) NOT NULL auto_increment,\n\t\t`name` varchar(255) NOT NULL default '',\n\t\t`severity` INTEGER UNSIGNED NOT NULL default '0',\n\t\t`method` int(10) unsigned NOT NULL default '0',\n\t\t`num` int(10) unsigned NOT NULL default '1',\n\t\t`type` varchar(16) NOT NULL default '',\n\t\t`enabled` CHAR(2) default 'on',\n\t\t`repeat_alert` int(10) unsigned NOT NULL default '0',\n\t\t`open_ticket` CHAR(2) default '',\n\t\t`message` VARCHAR(128) NOT NULL default '',\n\t\t`user` varchar(32) NOT NULL default '',\n\t\t`date` int(16) NOT NULL default '0',\n\t\t`email` varchar(255) default NULL,\n\t\t`command` varchar(255) default NULL,\n\t\t`notes` varchar(255) default NULL,\n\t\tPRIMARY KEY (id)) ENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_incoming`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_incoming` (\n\t\tfacility varchar(10) default NULL,\n\t\tpriority varchar(10) default NULL,\n\t\t`date` date default NULL,\n\t\t`time` time default NULL,\n\t\thost varchar(128) default NULL,\n\t\tmessage " . ($mysqlVersion > 5 ? "varchar(1024)" : "text") . " NOT NULL DEFAULT '',\n\t\tseq bigint unsigned NOT NULL auto_increment,\n\t\t`status` tinyint(4) NOT NULL default '0',\n\t\tPRIMARY KEY (seq),\n\t\tKEY `status` (`status`)) ENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_remove`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_remove` (\n\t\tid int(10) NOT NULL auto_increment,\n\t\tname varchar(255) NOT NULL default '',\n\t\t`type` varchar(16) NOT NULL default '',\n\t\tenabled CHAR(2) DEFAULT 'on',\n\t\tmethod CHAR(5) DEFAULT 'del',\n\t\tmessage VARCHAR(128) NOT NULL default '',\n\t\t`user` varchar(32) NOT NULL default '',\n\t\t`date` int(16) NOT NULL default '0',\n\t\tnotes varchar(255) default NULL,\n\t\tPRIMARY KEY (id)) ENGINE={$engine};");
    $present = syslog_db_fetch_row("SHOW TABLES FROM `" . $syslogdb_default . "` LIKE 'syslog_reports'");
    if (sizeof($present)) {
        $newreport = sizeof(syslog_db_fetch_row("SHOW COLUMNS FROM `" . $syslogdb_default . "`.`syslog_reports` LIKE 'body'"));
    } else {
        $newreport = true;
    }
    if ($truncate || !$newreport) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_reports`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_reports` (\n\t\tid int(10) NOT NULL auto_increment,\n\t\tname varchar(255) NOT NULL default '',\n\t\t`type` varchar(16) NOT NULL default '',\n\t\tenabled CHAR(2) DEFAULT 'on',\n\t\ttimespan int(16) NOT NULL default '0',\n\t\ttimepart char(5) NOT NULL default '00:00',\n\t\tlastsent int(16) NOT NULL default '0',\n\t\tbody " . ($mysqlVersion > 5 ? "varchar(1024)" : "text") . " default NULL,\n\t\tmessage varchar(128) default NULL,\n\t\t`user` varchar(32) NOT NULL default '',\n\t\t`date` int(16) NOT NULL default '0',\n\t\temail varchar(255) default NULL,\n\t\tnotes varchar(255) default NULL,\n\t\tPRIMARY KEY (id)) ENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_hosts`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_hosts` (\n\t\t`host_id` int(10) unsigned NOT NULL auto_increment,\n\t\t`host` VARCHAR(128) NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY (`host`),\n\t\tKEY host_id (`host_id`),\n\t\tKEY last_updated (`last_updated`)) ENGINE={$engine}\n\t\tCOMMENT='Contains all hosts currently in the syslog table'");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_facilities`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_facilities` (\n\t\t`facility_id` int(10) unsigned NOT NULL auto_increment,\n\t\t`facility` varchar(10) NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY  (`facility`),\n\t\tKEY facility_id (`facility_id`),\n\t\tKEY last_updates (`last_updated`)) ENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_priorities`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_priorities` (\n\t\t`priority_id` int(10) unsigned NOT NULL auto_increment,\n\t\t`priority` varchar(10) NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY (`priority`),\n\t\tKEY priority_id (`priority_id`),\n\t\tKEY last_updated (`last_updated`)) ENGINE={$engine};");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_host_facilities` (\n\t\t`host_id` int(10) unsigned NOT NULL,\n\t\t`facility_id` int(10) unsigned NOT NULL,\n\t\t`last_updated` TIMESTAMP NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,\n\t\tPRIMARY KEY  (`host_id`,`facility_id`)) ENGINE={$engine};");
    if ($truncate) {
        syslog_db_execute("DROP TABLE IF EXISTS `" . $syslogdb_default . "`.`syslog_removed`");
    }
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_removed` LIKE `" . $syslogdb_default . "`.`syslog`");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_logs` (\n\t\talert_id integer unsigned not null default '0',\n\t\tlogseq bigint unsigned NOT NULL,\n\t\tlogtime TIMESTAMP NOT NULL default '0000-00-00 00:00:00',\n\t\tlogmsg " . ($mysqlVersion > 5 ? "varchar(1024)" : "text") . " default NULL,\n\t\thost varchar(32) default NULL,\n\t\tfacility varchar(10) default NULL,\n\t\tpriority varchar(10) default NULL,\n\t\tcount integer unsigned NOT NULL default '0',\n\t\thtml blob default NULL,\n\t\tseq bigint unsigned NOT NULL auto_increment,\n\t\tPRIMARY KEY (seq),\n\t\tKEY logseq (logseq),\n\t\tKEY alert_id (alert_id),\n\t\tKEY host (host),\n\t\tKEY seq (seq),\n\t\tKEY logtime (logtime),\n\t\tKEY priority (priority),\n\t\tKEY facility (facility)) ENGINE={$engine};");
    syslog_db_execute("CREATE TABLE IF NOT EXISTS `" . $syslogdb_default . "`.`syslog_statistics` (\n\t\t`host_id` INTEGER UNSIGNED NOT NULL,\n\t\t`facility_id` INTEGER UNSIGNED NOT NULL,\n\t\t`priority_id` INTEGER UNSIGNED NOT NULL,\n\t\t`insert_time` TIMESTAMP NOT NULL,\n\t\t`records` INTEGER UNSIGNED NOT NULL,\n\t\tPRIMARY KEY (`host_id`, `facility_id`, `priority_id`, `insert_time`),\n\t\tINDEX `host_id`(`host_id`),\n\t\tINDEX `facility_id`(`facility_id`),\n\t\tINDEX `priority_id`(`priority_id`),\n\t\tINDEX `insert_time`(`insert_time`))\n\t\tENGINE = MyISAM\n\t\tCOMMENT = 'Maintains High Level Statistics';");
    foreach ($syslog_levels as $id => $priority) {
        syslog_db_execute("REPLACE INTO `" . $syslogdb_default . "`.`syslog_priorities` (priority_id, priority) VALUES ({$id}, '{$priority}')");
    }
    if (!isset($settings["syslog"])) {
        syslog_config_settings();
    }
    foreach ($settings["syslog"] as $name => $values) {
        if (isset($values["default"])) {
            db_execute("REPLACE INTO `" . $database_default . "`.`settings` (name, value) VALUES ('{$name}', '" . $values["default"] . "')");
        }
    }
}