mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-29 08:45:12 +02:00
2012-10-23 Ramon Novoa <rnovoa@artica.es>
* include/functions_cron.php: Added to repository. Cron related functions. * include/functions_html.php, pandoradb.sql, pandoradb.postgreSQL.sql, pandoradb.oracle.sql, extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql, extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql, extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql, godmode/agentes/module_manager_editor_common.php, godmode/agentes/configurar_agente.php, godmode/agentes/module_manager_editor.php: Added support for remote cron modules. * godmode/netflow/nf_item_list.php, godmode/netflow/nf_report_item.php, operation/netflow/nf_view.php, include/functions_netflow.php: Added a description to report items. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@7083 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
efaa5b4c69
commit
4fb3f07a42
@ -1,3 +1,23 @@
|
|||||||
|
2012-10-23 Ramon Novoa <rnovoa@artica.es>
|
||||||
|
|
||||||
|
* include/functions_cron.php: Added to repository. Cron related
|
||||||
|
functions.
|
||||||
|
|
||||||
|
* include/functions_html.php, pandoradb.sql,
|
||||||
|
pandoradb.postgreSQL.sql, pandoradb.oracle.sql,
|
||||||
|
extras/pandoradb_migrate_4.0.x_to_5.0.mysql.sql,
|
||||||
|
extras/pandoradb_migrate_4.0.x_to_5.0.oracle.sql,
|
||||||
|
extras/pandoradb_migrate_4.0.x_to_5.0.postgreSQL.sql,
|
||||||
|
godmode/agentes/module_manager_editor_common.php,
|
||||||
|
godmode/agentes/configurar_agente.php,
|
||||||
|
godmode/agentes/module_manager_editor.php: Added support for remote
|
||||||
|
cron modules.
|
||||||
|
|
||||||
|
* godmode/netflow/nf_item_list.php,
|
||||||
|
godmode/netflow/nf_report_item.php,
|
||||||
|
operation/netflow/nf_view.php,
|
||||||
|
include/functions_netflow.php: Added a description to report items.
|
||||||
|
|
||||||
2012-10-16 Vanessa Gil <vanessa.gil@artica.es>
|
2012-10-16 Vanessa Gil <vanessa.gil@artica.es>
|
||||||
|
|
||||||
* include/functions_events.php
|
* include/functions_events.php
|
||||||
|
@ -35,6 +35,7 @@ CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
|
|||||||
`id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`id_report` INTEGER UNSIGNED NOT NULL default 0,
|
`id_report` INTEGER UNSIGNED NOT NULL default 0,
|
||||||
`id_filter` INTEGER UNSIGNED NOT NULL default 0,
|
`id_filter` INTEGER UNSIGNED NOT NULL default 0,
|
||||||
|
`description` TEXT NOT NULL,
|
||||||
`date` bigint(20) NOT NULL default '0',
|
`date` bigint(20) NOT NULL default '0',
|
||||||
`period` int(11) NOT NULL default 0,
|
`period` int(11) NOT NULL default 0,
|
||||||
`max` int (11) NOT NULL default 0,
|
`max` int (11) NOT NULL default 0,
|
||||||
@ -152,6 +153,7 @@ ALTER TABLE `tagente_modulo` ADD COLUMN `warning_instructions` TEXT NOT NULL DEF
|
|||||||
ALTER TABLE `tagente_modulo` ADD COLUMN `unknown_instructions` TEXT NOT NULL DEFAULT '';
|
ALTER TABLE `tagente_modulo` ADD COLUMN `unknown_instructions` TEXT NOT NULL DEFAULT '';
|
||||||
ALTER TABLE `tagente_modulo` ADD COLUMN `critical_inverse` tinyint(1) unsigned default '0';
|
ALTER TABLE `tagente_modulo` ADD COLUMN `critical_inverse` tinyint(1) unsigned default '0';
|
||||||
ALTER TABLE `tagente_modulo` ADD COLUMN `warning_inverse` tinyint(1) unsigned default '0';
|
ALTER TABLE `tagente_modulo` ADD COLUMN `warning_inverse` tinyint(1) unsigned default '0';
|
||||||
|
ALTER TABLE `tagente_modulo` ADD COLUMN `cron_interval` varchar(100) default '';
|
||||||
|
|
||||||
------------------------------------------------------------------------
|
------------------------------------------------------------------------
|
||||||
-- Table `tnetwork_component`
|
-- Table `tnetwork_component`
|
||||||
|
@ -57,6 +57,7 @@ CREATE TABLE tnetflow_report_content (
|
|||||||
id_rc NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
id_rc NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
||||||
id_report NUMBER(10, 0) NOT NULL REFERENCES tnetflow_report(id_report) ON DELETE CASCADE,
|
id_report NUMBER(10, 0) NOT NULL REFERENCES tnetflow_report(id_report) ON DELETE CASCADE,
|
||||||
id_filter NUMBER(10,0) NOT NULL REFERENCES tnetflow_filter(id_sg) ON DELETE CASCADE,
|
id_filter NUMBER(10,0) NOT NULL REFERENCES tnetflow_filter(id_sg) ON DELETE CASCADE,
|
||||||
|
description CLOB default '',
|
||||||
"date" NUMBER(20, 0) default 0 NOT NULL,
|
"date" NUMBER(20, 0) default 0 NOT NULL,
|
||||||
period NUMBER(11, 0) default 0 NOT NULL,
|
period NUMBER(11, 0) default 0 NOT NULL,
|
||||||
max NUMBER(11, 0) default 0 NOT NULL,
|
max NUMBER(11, 0) default 0 NOT NULL,
|
||||||
@ -299,6 +300,7 @@ ALTER TABLE tagente_modulo ADD (wizard_level VARCHAR2(100) default 'nowizard' NO
|
|||||||
ALTER TABLE tagente_modulo ADD CONSTRAINT t_agente_modulo_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','custom','nowizard'));
|
ALTER TABLE tagente_modulo ADD CONSTRAINT t_agente_modulo_wizard_level_cons CHECK (wizard_level IN ('basic','advanced','custom','nowizard'));
|
||||||
ALTER TABLE tagente_modulo ADD (macros CLOB default '');
|
ALTER TABLE tagente_modulo ADD (macros CLOB default '');
|
||||||
ALTER TABLE tagente_modulo ADD (quiet NUMBER(5, 0) default 0 NOT NULL);
|
ALTER TABLE tagente_modulo ADD (quiet NUMBER(5, 0) default 0 NOT NULL);
|
||||||
|
ALTER TABLE tagente_modulo ADD (cron_interval VARCHAR2(100) DEFAULT '');
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
-- Table `tplugin`
|
-- Table `tplugin`
|
||||||
|
@ -53,6 +53,7 @@ CREATE TABLE "tnetflow_report_content" (
|
|||||||
"id_rc" SERIAL NOT NULL PRIMARY KEY,
|
"id_rc" SERIAL NOT NULL PRIMARY KEY,
|
||||||
"id_report" INTEGER NOT NULL default 0 REFERENCES tnetflow_report("id_report") ON DELETE CASCADE,
|
"id_report" INTEGER NOT NULL default 0 REFERENCES tnetflow_report("id_report") ON DELETE CASCADE,
|
||||||
"id_filter" INTEGER NOT NULL default 0 REFERENCES tnetflow_filter("id_sg") ON DELETE CASCADE,
|
"id_filter" INTEGER NOT NULL default 0 REFERENCES tnetflow_filter("id_sg") ON DELETE CASCADE,
|
||||||
|
"description" TEXT,
|
||||||
"date" BIGINT NOT NULL default 0,
|
"date" BIGINT NOT NULL default 0,
|
||||||
"period" INTEGER NOT NULL default 0,
|
"period" INTEGER NOT NULL default 0,
|
||||||
"max" INTEGER NOT NULL default 0,
|
"max" INTEGER NOT NULL default 0,
|
||||||
@ -174,6 +175,7 @@ ALTER TABLE "tagente_modulo" ADD COLUMN "warning_instructions" text default '';
|
|||||||
ALTER TABLE "tagente_modulo" ADD COLUMN "unknown_instructions" text default '';
|
ALTER TABLE "tagente_modulo" ADD COLUMN "unknown_instructions" text default '';
|
||||||
ALTER TABLE "tagente_modulo" ADD COLUMN "critical_inverse" SMALLINT NOT NULL default 0;
|
ALTER TABLE "tagente_modulo" ADD COLUMN "critical_inverse" SMALLINT NOT NULL default 0;
|
||||||
ALTER TABLE "tagente_modulo" ADD COLUMN "warning_inverse" SMALLINT NOT NULL default 0;
|
ALTER TABLE "tagente_modulo" ADD COLUMN "warning_inverse" SMALLINT NOT NULL default 0;
|
||||||
|
ALTER TABLE "tagente_modulo" ADD COLUMN "cron_interval" varchar(100) default '';
|
||||||
|
|
||||||
-- -----------------------------------------------------
|
-- -----------------------------------------------------
|
||||||
-- Table `tevent_filter`
|
-- Table `tevent_filter`
|
||||||
|
@ -21,6 +21,7 @@ enterprise_include ('godmode/agentes/configurar_agente.php');
|
|||||||
enterprise_include ('include/functions_policies.php');
|
enterprise_include ('include/functions_policies.php');
|
||||||
enterprise_include ('include/functions_modules.php');
|
enterprise_include ('include/functions_modules.php');
|
||||||
include_once($config['homedir'] . "/include/functions_agents.php");
|
include_once($config['homedir'] . "/include/functions_agents.php");
|
||||||
|
include_once($config['homedir'] . "/include/functions_cron.php");
|
||||||
ui_require_javascript_file('encode_decode_base64');
|
ui_require_javascript_file('encode_decode_base64');
|
||||||
|
|
||||||
check_login ();
|
check_login ();
|
||||||
@ -788,6 +789,13 @@ if ($update_module || $create_module) {
|
|||||||
$critical_inverse = (int) get_parameter('critical_inverse');
|
$critical_inverse = (int) get_parameter('critical_inverse');
|
||||||
$warning_inverse = (int) get_parameter('warning_inverse');
|
$warning_inverse = (int) get_parameter('warning_inverse');
|
||||||
|
|
||||||
|
$hour = get_parameter('hour');
|
||||||
|
$minute = get_parameter('minute');
|
||||||
|
$mday = get_parameter('mday');
|
||||||
|
$month = get_parameter('month');
|
||||||
|
$wday = get_parameter('wday');
|
||||||
|
$cron_interval = "$minute $hour $mday $month $wday";
|
||||||
|
|
||||||
if ($prediction_module != 3) {
|
if ($prediction_module != 3) {
|
||||||
unset($serialize_ops);
|
unset($serialize_ops);
|
||||||
enterprise_hook('modules_delete_synthetic_operations', array($id_agent_module));
|
enterprise_hook('modules_delete_synthetic_operations', array($id_agent_module));
|
||||||
@ -851,7 +859,8 @@ if ($update_module) {
|
|||||||
'warning_instructions' => $warning_instructions,
|
'warning_instructions' => $warning_instructions,
|
||||||
'unknown_instructions' => $unknown_instructions,
|
'unknown_instructions' => $unknown_instructions,
|
||||||
'critical_inverse' => $critical_inverse,
|
'critical_inverse' => $critical_inverse,
|
||||||
'warning_inverse' => $warning_inverse);
|
'warning_inverse' => $warning_inverse,
|
||||||
|
'cron_interval' => $cron_interval);
|
||||||
|
|
||||||
if ($prediction_module == 3 && $serialize_ops == '') {
|
if ($prediction_module == 3 && $serialize_ops == '') {
|
||||||
$result = false;
|
$result = false;
|
||||||
@ -890,6 +899,10 @@ if ($update_module) {
|
|||||||
if ($prediction_module == 3) {
|
if ($prediction_module == 3) {
|
||||||
enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops));
|
enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the module interval
|
||||||
|
cron_update_module_interval ($id_agent_module, $cron_interval);
|
||||||
|
|
||||||
ui_print_success_message(__('Module successfully updated'));
|
ui_print_success_message(__('Module successfully updated'));
|
||||||
$id_agent_module = false;
|
$id_agent_module = false;
|
||||||
$edit_module = false;
|
$edit_module = false;
|
||||||
@ -965,7 +978,8 @@ if ($create_module) {
|
|||||||
'warning_instructions' => $warning_instructions,
|
'warning_instructions' => $warning_instructions,
|
||||||
'unknown_instructions' => $unknown_instructions,
|
'unknown_instructions' => $unknown_instructions,
|
||||||
'critical_inverse' => $critical_inverse,
|
'critical_inverse' => $critical_inverse,
|
||||||
'warning_inverse' => $warning_inverse);
|
'warning_inverse' => $warning_inverse,
|
||||||
|
'cron_interval' => $cron_interval);
|
||||||
|
|
||||||
if ($prediction_module == 3 && $serialize_ops == '') {
|
if ($prediction_module == 3 && $serialize_ops == '') {
|
||||||
$id_agent_module = false;
|
$id_agent_module = false;
|
||||||
@ -1000,6 +1014,9 @@ if ($create_module) {
|
|||||||
enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops));
|
enterprise_hook('modules_create_synthetic_operations', array($id_agent_module, $serialize_ops));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Update the module interval
|
||||||
|
cron_update_module_interval ($id_agent_module, $cron_interval);
|
||||||
|
|
||||||
ui_print_success_message(__('Module added successfully'));
|
ui_print_success_message(__('Module added successfully'));
|
||||||
$id_agent_module = false;
|
$id_agent_module = false;
|
||||||
$edit_module = false;
|
$edit_module = false;
|
||||||
|
@ -208,7 +208,21 @@ if ($id_agent_module) {
|
|||||||
|
|
||||||
$critical_inverse = $module['critical_inverse'];
|
$critical_inverse = $module['critical_inverse'];
|
||||||
$warning_inverse = $module['warning_inverse'];
|
$warning_inverse = $module['warning_inverse'];
|
||||||
|
|
||||||
|
$cron_interval = explode (" ", $module['cron_interval']);
|
||||||
|
if (isset ($cron_interval[4])) {
|
||||||
|
$minute = $cron_interval[0];
|
||||||
|
$hour = $cron_interval[1];
|
||||||
|
$mday = $cron_interval[2];
|
||||||
|
$month = $cron_interval[3];
|
||||||
|
$wday = $cron_interval[4];
|
||||||
|
} else {
|
||||||
|
$minute = '*';
|
||||||
|
$hour = '*';
|
||||||
|
$mday = '*';
|
||||||
|
$month = '*';
|
||||||
|
$wday = '*';
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (!isset ($moduletype)) {
|
if (!isset ($moduletype)) {
|
||||||
@ -268,6 +282,13 @@ else {
|
|||||||
|
|
||||||
$critical_inverse = '';
|
$critical_inverse = '';
|
||||||
$warning_inverse = '';
|
$warning_inverse = '';
|
||||||
|
|
||||||
|
$cron_interval = '* * * * *';
|
||||||
|
$hour = '*';
|
||||||
|
$minute = '*';
|
||||||
|
$mday = '*';
|
||||||
|
$month = '*';
|
||||||
|
$wday = '*';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -369,6 +369,10 @@ $table_advanced->data[10][0] = __('Unknown instructions'). ui_print_help_tip(__(
|
|||||||
$table_advanced->data[10][1] = html_print_textarea ('unknown_instructions', 2, 65, $unknown_instructions, '', true);
|
$table_advanced->data[10][1] = html_print_textarea ('unknown_instructions', 2, 65, $unknown_instructions, '', true);
|
||||||
$table_advanced->colspan[10][1] = 4;
|
$table_advanced->colspan[10][1] = 4;
|
||||||
|
|
||||||
|
$table_advanced->data[11][0] = __('Cron') . ui_print_help_tip (__('If cron is set the module interval is ignored and the module runs on the specified date and time'), true);
|
||||||
|
$table_advanced->data[11][1] = html_print_extended_select_for_cron ($hour, $minute, $mday, $month, $wday, true);
|
||||||
|
$table_advanced->colspan[11][1] = 4;
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
|
@ -143,22 +143,24 @@ $table->width = '98%';
|
|||||||
$table->head = array ();
|
$table->head = array ();
|
||||||
$table->head[0] = __('Order');
|
$table->head[0] = __('Order');
|
||||||
$table->head[1] = __('Filter');
|
$table->head[1] = __('Filter');
|
||||||
$table->head[2] = __('Max. values');
|
$table->head[2] = __('Description');
|
||||||
$table->head[3] = __('Chart type');
|
$table->head[3] = __('Max. values');
|
||||||
$table->head[4] = __('Action') . html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
|
$table->head[4] = __('Chart type');
|
||||||
|
$table->head[5] = __('Action') . html_print_checkbox('all_delete', 0, false, true, false, 'check_all_checkboxes();');
|
||||||
|
|
||||||
$table->style = array ();
|
$table->style = array ();
|
||||||
$table->style[1] = 'font-weight: bold';
|
$table->style[1] = 'font-weight: bold';
|
||||||
$table->align = array ();
|
$table->align = array ();
|
||||||
$table->align[1] = 'left';
|
$table->align[1] = 'left';
|
||||||
$table->align[2] = 'center';
|
$table->align[2] = 'left';
|
||||||
$table->align[3] = 'center';
|
$table->align[3] = 'center';
|
||||||
$table->align[4] = 'right';
|
$table->align[4] = 'center';
|
||||||
|
$table->align[5] = 'right';
|
||||||
$table->size = array ();
|
$table->size = array ();
|
||||||
$table->size[0] = '20px';
|
$table->size[0] = '20px';
|
||||||
$table->size[2] = '5%';
|
$table->size[3] = '5%';
|
||||||
$table->size[3] = '15%';
|
$table->size[4] = '15%';
|
||||||
$table->size[4] = '60px';
|
$table->size[5] = '60px';
|
||||||
|
|
||||||
$table->data = array ();
|
$table->data = array ();
|
||||||
|
|
||||||
@ -200,27 +202,28 @@ foreach ($reports_item as $item) {
|
|||||||
$name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $item['id_filter']);
|
$name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $item['id_filter']);
|
||||||
$data[1] = '<a href="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_item&id='.$item['id_report'].'&id_rc='.$item['id_rc'].'">'.$name_filter.'</a>';
|
$data[1] = '<a href="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir'] . '/godmode/netflow/nf_report_item&id='.$item['id_report'].'&id_rc='.$item['id_rc'].'">'.$name_filter.'</a>';
|
||||||
|
|
||||||
$data[2] = $item['max'];
|
$data[2] = $item['description'];
|
||||||
|
$data[3] = $item['max'];
|
||||||
|
|
||||||
switch ($item['show_graph']) {
|
switch ($item['show_graph']) {
|
||||||
case 0:
|
case 0:
|
||||||
$data[3] = 'Area graph';
|
$data[4] = 'Area graph';
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
$data[3] = 'Pie graph';
|
$data[4] = 'Pie graph';
|
||||||
break;
|
break;
|
||||||
case 2:
|
case 2:
|
||||||
$data[3] = 'Data table';
|
$data[4] = 'Data table';
|
||||||
break;
|
break;
|
||||||
case 3:
|
case 3:
|
||||||
$data[3] = 'Statistics table';
|
$data[4] = 'Statistics table';
|
||||||
break;
|
break;
|
||||||
case 4:
|
case 4:
|
||||||
$data[3] = 'Summary table';
|
$data[4] = 'Summary table';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$data[4] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;'
|
$data[5] = "<a onclick='if(confirm(\"" . __('Are you sure?') . "\")) return true; else return false;'
|
||||||
href='" . $config['homeurl'] . "index.php?sec=netf&sec2=" . $config['homedir'] . "/godmode/netflow/nf_item_list&delete=1&id_rc=".$item['id_rc']."&id=".$id."&offset=0'>" .
|
href='" . $config['homeurl'] . "index.php?sec=netf&sec2=" . $config['homedir'] . "/godmode/netflow/nf_item_list&delete=1&id_rc=".$item['id_rc']."&id=".$id."&offset=0'>" .
|
||||||
html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "</a>" .
|
html_print_image('images/cross.png', true, array('title' => __('Delete'))) . "</a>" .
|
||||||
html_print_checkbox_extended ('delete_multiple[]', $item['id_rc'], false, false, '', 'class="check_delete"', true);
|
html_print_checkbox_extended ('delete_multiple[]', $item['id_rc'], false, false, '', 'class="check_delete"', true);
|
||||||
|
@ -68,12 +68,14 @@ if ($id_rc) {
|
|||||||
$name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter);
|
$name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter);
|
||||||
$max_val = $item['max'];
|
$max_val = $item['max'];
|
||||||
$show_graph = $item['show_graph'];
|
$show_graph = $item['show_graph'];
|
||||||
|
$description = $item['description'];
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
$name_filter = '';
|
$name_filter = '';
|
||||||
$max_val = '';
|
$max_val = '';
|
||||||
$show_graph = '';
|
$show_graph = '';
|
||||||
|
$description = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($update) {
|
if ($update) {
|
||||||
@ -81,13 +83,15 @@ if ($update) {
|
|||||||
$name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter);
|
$name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter);
|
||||||
$max_val = get_parameter('max','2');
|
$max_val = get_parameter('max','2');
|
||||||
$show_graph = get_parameter('show_graph','');
|
$show_graph = get_parameter('show_graph','');
|
||||||
|
$description = get_parameter('description','');
|
||||||
|
|
||||||
$result = db_process_sql_update ('tnetflow_report_content',
|
$result = db_process_sql_update ('tnetflow_report_content',
|
||||||
array (
|
array (
|
||||||
'id_report' => $id,
|
'id_report' => $id,
|
||||||
'id_filter' => $id_filter,
|
'id_filter' => $id_filter,
|
||||||
'max' => $max_val,
|
'max' => $max_val,
|
||||||
'show_graph' => $show_graph
|
'show_graph' => $show_graph,
|
||||||
|
'description' => $description
|
||||||
),
|
),
|
||||||
array ('id_rc' => $id_rc));
|
array ('id_rc' => $id_rc));
|
||||||
|
|
||||||
@ -101,6 +105,7 @@ if ($create){
|
|||||||
$name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter);
|
$name_filter = db_get_value('id_name', 'tnetflow_filter', 'id_sg', $id_filter);
|
||||||
$max_val = (int)get_parameter('max',2);
|
$max_val = (int)get_parameter('max',2);
|
||||||
$show_graph = (string)get_parameter('show_graph','');
|
$show_graph = (string)get_parameter('show_graph','');
|
||||||
|
$description = get_parameter('description','');
|
||||||
|
|
||||||
//insertion order
|
//insertion order
|
||||||
$sql = "SELECT max(`order`) as max_order FROM tnetflow_report_content where id_report=$id";
|
$sql = "SELECT max(`order`) as max_order FROM tnetflow_report_content where id_report=$id";
|
||||||
@ -118,6 +123,7 @@ if ($create){
|
|||||||
'id_filter' => $id_filter,
|
'id_filter' => $id_filter,
|
||||||
'max' => $max_val,
|
'max' => $max_val,
|
||||||
'show_graph' => $show_graph,
|
'show_graph' => $show_graph,
|
||||||
|
'description' => $description,
|
||||||
'`order`' => $order
|
'`order`' => $order
|
||||||
);
|
);
|
||||||
$id_rc = db_process_sql_insert('tnetflow_report_content', $values);
|
$id_rc = db_process_sql_insert('tnetflow_report_content', $values);
|
||||||
@ -174,6 +180,9 @@ $table->data[2][0] = '<b>'.__('Chart type').'</b>';
|
|||||||
$table->data[2][1] = html_print_select (netflow_get_chart_types (), 'show_graph', $show_graph,'','',0,true);
|
$table->data[2][1] = html_print_select (netflow_get_chart_types (), 'show_graph', $show_graph,'','',0,true);
|
||||||
$table->data[2][1] = html_print_select (netflow_get_chart_types (), 'show_graph', $show_graph,'','',0,true);
|
$table->data[2][1] = html_print_select (netflow_get_chart_types (), 'show_graph', $show_graph,'','',0,true);
|
||||||
|
|
||||||
|
$table->data[3][0] = '<b>'.__('Description').'</b>';
|
||||||
|
$table->data[3][1] = html_print_textarea ('description', 2, 65, $description, '', true);
|
||||||
|
|
||||||
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir']. '/godmode/netflow/nf_report_item&id='.$id.'">';
|
echo '<form method="post" action="' . $config['homeurl'] . 'index.php?sec=netf&sec2=' . $config['homedir']. '/godmode/netflow/nf_report_item&id='.$id.'">';
|
||||||
html_print_table ($table);
|
html_print_table ($table);
|
||||||
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
echo '<div class="action-buttons" style="width: '.$table->width.'">';
|
||||||
|
158
pandora_console/include/functions_cron.php
Normal file
158
pandora_console/include/functions_cron.php
Normal file
@ -0,0 +1,158 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
//Pandora FMS- http://pandorafms.com
|
||||||
|
// ==================================================
|
||||||
|
// Copyright (c) 20012 Artica Soluciones Tecnologicas
|
||||||
|
// Please see http://pandorafms.org for full contribution list
|
||||||
|
|
||||||
|
// This program is free software; you can redistribute it and/or
|
||||||
|
// modify it under the terms of the GNU Lesser General Public License
|
||||||
|
// as published by the Free Software Foundation; version 2
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
include_once($config['homedir'] . "/include/functions_db.php");
|
||||||
|
|
||||||
|
// Update the execution interval of the given module
|
||||||
|
function cron_update_module_interval ($module_id, $cron) {
|
||||||
|
|
||||||
|
// Check for a valid cron
|
||||||
|
if ($cron == '' || $cron == '* * * * *') {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return db_process_sql ('UPDATE tagente_estado SET current_interval = ' . cron_next_execution ($cron) . ' WHERE id_agente_modulo = ' . (int) $module_id);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// Get the number of seconds left to the next execution of the given cron entry.
|
||||||
|
function cron_next_execution ($cron) {
|
||||||
|
|
||||||
|
// Get day of the week and month from cron config
|
||||||
|
list ($minute, $hour, $mday, $month, $wday) = explode (" ", $cron);
|
||||||
|
|
||||||
|
// Get current time
|
||||||
|
$cur_time = time();
|
||||||
|
|
||||||
|
// Any day of the way
|
||||||
|
if ($wday == '*') {
|
||||||
|
$nex_time = cron_next_execution_date ($cron, $cur_time);
|
||||||
|
return $nex_time - $cur_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
// A specific day of the week
|
||||||
|
$count = 0;
|
||||||
|
$nex_time = $cur_time;
|
||||||
|
do {
|
||||||
|
$nex_time = cron_next_execution_date ($cron, $nex_time);
|
||||||
|
$nex_time_wd = $nex_time;
|
||||||
|
list ($nex_mon, $nex_wday) = explode (" ", date ("m w", $nex_time_wd));
|
||||||
|
do {
|
||||||
|
// Check the day of the week
|
||||||
|
if ($nex_wday == $wday) {
|
||||||
|
return $nex_time_wd - $cur_time;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Move to the next day of the month
|
||||||
|
$nex_time_wd += 86400;
|
||||||
|
list ($nex_mon_wd, $nex_wday) = explode (" ", date ("m w", $nex_time_wd));
|
||||||
|
} while ($mday == '*' && $nex_mon_wd == $nex_mon);
|
||||||
|
$count++;
|
||||||
|
} while ($count < 60);
|
||||||
|
|
||||||
|
// Something went wrong, default to 5 minutes
|
||||||
|
return 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get the next execution date for the given cron entry in seconds since epoch.
|
||||||
|
function cron_next_execution_date ($cron, $cur_time = false) {
|
||||||
|
|
||||||
|
// Get cron configuration
|
||||||
|
list ($min, $hour, $mday, $mon, $wday) = explode (" ", $cron);
|
||||||
|
|
||||||
|
// Months start from 0
|
||||||
|
if($mon != '*') {
|
||||||
|
$mon -= 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Get current time
|
||||||
|
if ($cur_time === false) {
|
||||||
|
$cur_time = time();
|
||||||
|
}
|
||||||
|
list ($cur_min, $cur_hour, $cur_mday, $cur_mon, $cur_year) = explode (" ", date ("i H d m Y", $cur_time));
|
||||||
|
|
||||||
|
// Get first next date candidate from cron configuration
|
||||||
|
$nex_min = $min;
|
||||||
|
$nex_hour = $hour;
|
||||||
|
$nex_mday = $mday;
|
||||||
|
$nex_mon = $mon;
|
||||||
|
$nex_year = $cur_year;
|
||||||
|
|
||||||
|
// Replace wildcards
|
||||||
|
if ($min == '*') {
|
||||||
|
if ($hour != '*' || $mday != '*' || $wday != '*' || $mon != '*') {
|
||||||
|
$nex_min = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nex_min = $cur_min;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($hour == '*') {
|
||||||
|
if ($mday != '*' || $wday != '*' ||$mon != '*') {
|
||||||
|
$nex_hour = 0;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nex_hour = $cur_hour;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($mday == '*') {
|
||||||
|
if ($mon != '*') {
|
||||||
|
$nex_mday = 1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nex_mday = $cur_mday;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($mon == '*') {
|
||||||
|
$nex_mon = $cur_mon;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the next execution date
|
||||||
|
$count = 0;
|
||||||
|
do {
|
||||||
|
$next_time = mktime($nex_hour, $nex_min, 0, $nex_mon, $nex_mday, $nex_year);
|
||||||
|
if ($next_time > $cur_time) {
|
||||||
|
return $next_time;
|
||||||
|
}
|
||||||
|
if ($min == '*' && $hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') {
|
||||||
|
list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + 60));
|
||||||
|
}
|
||||||
|
else if ($hour == '*' && $wday == '*' && $mday == '*' && $mon == '*') {
|
||||||
|
list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + 3600));
|
||||||
|
}
|
||||||
|
else if ($mday == '*' && $mon == '*') {
|
||||||
|
list ($nex_min, $nex_hour, $nex_mday, $nex_mon, $nex_year) = explode (" ", date ("i H d m Y", $next_time + 86400));
|
||||||
|
}
|
||||||
|
else if ($mon == '*') {
|
||||||
|
$nex_mon = $nex_mon + 1;
|
||||||
|
if ($nex_mon > 11) {
|
||||||
|
$nex_mon = 0;
|
||||||
|
$nex_year++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$nex_year++;
|
||||||
|
}
|
||||||
|
$count++;
|
||||||
|
} while ($count < 86400);
|
||||||
|
|
||||||
|
// Something went wrong, default to 5 minutes
|
||||||
|
return $cur_time + 300;
|
||||||
|
}
|
||||||
|
|
||||||
|
?>
|
@ -487,6 +487,62 @@ function html_print_extended_select_for_time ($name, $selected = '', $script = '
|
|||||||
echo $returnString;
|
echo $returnString;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Print selects to configure the cron of a module.
|
||||||
|
*
|
||||||
|
* @param string Run hour.
|
||||||
|
* @param string Run minute.
|
||||||
|
* @param string Run day of the month.
|
||||||
|
* @param string Run month.
|
||||||
|
* @param string Run day of the week.
|
||||||
|
* @param bool Whether to return an output string or echo now (optional, echo by default).
|
||||||
|
*
|
||||||
|
* @return string HTML code if return parameter is true.
|
||||||
|
*/
|
||||||
|
function html_print_extended_select_for_cron ($hour = '*', $minute = '*', $mday = '*', $month = '*', $wday = '*', $return = false) {
|
||||||
|
|
||||||
|
# Hours
|
||||||
|
for ($i = 0; $i < 24; $i++) {
|
||||||
|
$hours[$i] = $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Minutes
|
||||||
|
for ($i = 0; $i < 60; $i+=5) {
|
||||||
|
$minutes[$i] = $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Month days
|
||||||
|
for ($i = 0; $i < 31; $i++) {
|
||||||
|
$mdays[$i] = $i;
|
||||||
|
}
|
||||||
|
|
||||||
|
# Months
|
||||||
|
for ($i = 0; $i < 12; $i++) {
|
||||||
|
$months[$i] = date('F', mktime (0, 0, 0, $i, 1));
|
||||||
|
}
|
||||||
|
|
||||||
|
# Days of the week
|
||||||
|
$wdays = array(__('Sunday'), __('Monday'), __('Tuesday'), __('Wednesday'), __('Thursday'), __('Friday'), __('Saturday'));
|
||||||
|
|
||||||
|
# Print selectors
|
||||||
|
$table->id = 'cron';
|
||||||
|
$table->width = '98%';
|
||||||
|
$table->class = 'databox_color';
|
||||||
|
$table->head[0] = __('Hour');
|
||||||
|
$table->head[1] = __('Minute');
|
||||||
|
$table->head[2] = __('Month day');
|
||||||
|
$table->head[3] = __('Month');
|
||||||
|
$table->head[4] = __('Week day');
|
||||||
|
|
||||||
|
$table->data[0][0] = html_print_select ($hours, 'hour', $hour, '', __('Any'), '*', true, false, false);
|
||||||
|
$table->data[0][1] = html_print_select ($minutes, 'minute', $minute, '', __('Any'), '*', true, false, false);
|
||||||
|
$table->data[0][2] = html_print_select ($mdays, 'mday', $mday, '', __('Any'), '*', true, false, false);
|
||||||
|
$table->data[0][3] = html_print_select ($months, 'month', $month, '', __('Any'), '*', true, false, false);
|
||||||
|
$table->data[0][4] = html_print_select ($wdays, 'wday', $wday, '', __('Any'), '*', true, false, false);
|
||||||
|
|
||||||
|
return html_print_table ($table, $return);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Render an input text element. Extended version, use html_print_input_text() to simplify.
|
* Render an input text element. Extended version, use html_print_input_text() to simplify.
|
||||||
*
|
*
|
||||||
@ -1579,4 +1635,4 @@ function html_print_autocomplete_modules($name = 'module', $default = '', $id_ag
|
|||||||
echo $output;
|
echo $output;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
@ -1136,6 +1136,7 @@ function netflow_xml_report ($id, $start_date, $end_date, $interval_length = 0)
|
|||||||
}
|
}
|
||||||
|
|
||||||
echo " <report_item>\n";
|
echo " <report_item>\n";
|
||||||
|
echo " <description>" . io_safe_output ($content['description']) . "</description>\n";
|
||||||
echo " <type>" . io_safe_output ($item_types[$content['show_graph']]) . "</type>\n";
|
echo " <type>" . io_safe_output ($item_types[$content['show_graph']]) . "</type>\n";
|
||||||
echo " <max_aggregates>" . $content['max'] . "</max_aggregates>\n";
|
echo " <max_aggregates>" . $content['max'] . "</max_aggregates>\n";
|
||||||
echo " <filter>\n";
|
echo " <filter>\n";
|
||||||
|
@ -167,15 +167,19 @@ foreach ($report_contents as $content_report) {
|
|||||||
$content_id = $content_report['id_rc'];
|
$content_id = $content_report['id_rc'];
|
||||||
$max_aggregates= $content_report['max'];
|
$max_aggregates= $content_report['max'];
|
||||||
$type = $content_report['show_graph'];
|
$type = $content_report['show_graph'];
|
||||||
|
$description = $content_report['description'];
|
||||||
|
|
||||||
// Get item filters
|
// Get item filters
|
||||||
$filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . io_safe_input ($content_report['id_filter']) . "'", false, true);
|
$filter = db_get_row_sql("SELECT * FROM tnetflow_filter WHERE id_sg = '" . io_safe_input ($content_report['id_filter']) . "'", false, true);
|
||||||
|
if ($description == '') {
|
||||||
|
$description = $filter['id_name'];
|
||||||
|
}
|
||||||
|
|
||||||
if ($filter['aggregate'] != 'none') {
|
if ($filter['aggregate'] != 'none') {
|
||||||
echo '<h4>' . $filter['id_name'] . ' (' . __($filter['aggregate']) . '/' . __($filter['output']) . ')</h4>';
|
echo '<h4>' . $description . ' (' . __($filter['aggregate']) . '/' . __($filter['output']) . ')</h4>';
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
echo '<h4>' . $filter['id_name'] . ' (' . __($filter['output']) . ')</h4>';
|
echo '<h4>' . $description . ' (' . __($filter['output']) . ')</h4>';
|
||||||
}
|
}
|
||||||
|
|
||||||
// Build a unique id for the cache
|
// Build a unique id for the cache
|
||||||
|
@ -189,6 +189,7 @@ CREATE TABLE tagente_modulo (
|
|||||||
max NUMBER(19, 0) default 0 NOT NULL,
|
max NUMBER(19, 0) default 0 NOT NULL,
|
||||||
min NUMBER(19, 0) default 0 NOT NULL,
|
min NUMBER(19, 0) default 0 NOT NULL,
|
||||||
module_interval NUMBER(10, 0) default 0 NOT NULL,
|
module_interval NUMBER(10, 0) default 0 NOT NULL,
|
||||||
|
cron_interval VARCHAR2(100) DEFAULT '',
|
||||||
tcp_port NUMBER(10, 0) default 0 NOT NULL,
|
tcp_port NUMBER(10, 0) default 0 NOT NULL,
|
||||||
tcp_send CLOB default '',
|
tcp_send CLOB default '',
|
||||||
tcp_rcv CLOB default '',
|
tcp_rcv CLOB default '',
|
||||||
@ -1651,6 +1652,7 @@ CREATE TABLE tnetflow_report_content (
|
|||||||
id_rc NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
id_rc NUMBER(10, 0) NOT NULL PRIMARY KEY,
|
||||||
id_report NUMBER(10, 0) NOT NULL REFERENCES tnetflow_report(id_report) ON DELETE CASCADE,
|
id_report NUMBER(10, 0) NOT NULL REFERENCES tnetflow_report(id_report) ON DELETE CASCADE,
|
||||||
id_filter NUMBER(10,0) NOT NULL REFERENCES tnetflow_filter(id_sg) ON DELETE CASCADE,
|
id_filter NUMBER(10,0) NOT NULL REFERENCES tnetflow_filter(id_sg) ON DELETE CASCADE,
|
||||||
|
description CLOB default '',
|
||||||
"date" NUMBER(20, 0) default 0 NOT NULL,
|
"date" NUMBER(20, 0) default 0 NOT NULL,
|
||||||
period NUMBER(11, 0) default 0 NOT NULL,
|
period NUMBER(11, 0) default 0 NOT NULL,
|
||||||
max NUMBER(11, 0) default 0 NOT NULL,
|
max NUMBER(11, 0) default 0 NOT NULL,
|
||||||
|
@ -180,6 +180,7 @@ CREATE TABLE "tagente_modulo" (
|
|||||||
"max" BIGINT NOT NULL default 0,
|
"max" BIGINT NOT NULL default 0,
|
||||||
"min" BIGINT NOT NULL default 0,
|
"min" BIGINT NOT NULL default 0,
|
||||||
"module_interval" INTEGER NOT NULL default 0,
|
"module_interval" INTEGER NOT NULL default 0,
|
||||||
|
"cron_interval" varchar(100) default '',
|
||||||
"module_ff_interval" INTEGER NOT NULL default 0,
|
"module_ff_interval" INTEGER NOT NULL default 0,
|
||||||
"tcp_port" INTEGER NOT NULL default 0,
|
"tcp_port" INTEGER NOT NULL default 0,
|
||||||
"tcp_send" TEXT default '',
|
"tcp_send" TEXT default '',
|
||||||
@ -1394,6 +1395,7 @@ CREATE TABLE "tnetflow_report_content" (
|
|||||||
"id_rc" SERIAL NOT NULL PRIMARY KEY,
|
"id_rc" SERIAL NOT NULL PRIMARY KEY,
|
||||||
"id_report" INTEGER NOT NULL default 0 REFERENCES tnetflow_report("id_report") ON DELETE CASCADE,
|
"id_report" INTEGER NOT NULL default 0 REFERENCES tnetflow_report("id_report") ON DELETE CASCADE,
|
||||||
"id_filter" INTEGER NOT NULL default 0 REFERENCES tnetflow_filter("id_sg") ON DELETE CASCADE,
|
"id_filter" INTEGER NOT NULL default 0 REFERENCES tnetflow_filter("id_sg") ON DELETE CASCADE,
|
||||||
|
"description" TEXT,
|
||||||
"date" BIGINT NOT NULL default 0,
|
"date" BIGINT NOT NULL default 0,
|
||||||
"period" INTEGER NOT NULL default 0,
|
"period" INTEGER NOT NULL default 0,
|
||||||
"max" INTEGER NOT NULL default 0,
|
"max" INTEGER NOT NULL default 0,
|
||||||
|
@ -180,6 +180,7 @@ CREATE TABLE IF NOT EXISTS `tagente_modulo` (
|
|||||||
`max` bigint(20) default '0',
|
`max` bigint(20) default '0',
|
||||||
`min` bigint(20) default '0',
|
`min` bigint(20) default '0',
|
||||||
`module_interval` int(4) unsigned default '0',
|
`module_interval` int(4) unsigned default '0',
|
||||||
|
`cron_interval` varchar(100) default '',
|
||||||
`module_ff_interval` int(4) unsigned default '0',
|
`module_ff_interval` int(4) unsigned default '0',
|
||||||
`tcp_port` int(4) unsigned default '0',
|
`tcp_port` int(4) unsigned default '0',
|
||||||
`tcp_send` TEXT,
|
`tcp_send` TEXT,
|
||||||
@ -1566,7 +1567,8 @@ PRIMARY KEY(`id_report`)
|
|||||||
CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
|
CREATE TABLE IF NOT EXISTS `tnetflow_report_content` (
|
||||||
`id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
`id_rc` INTEGER UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||||
`id_report` INTEGER UNSIGNED NOT NULL default 0,
|
`id_report` INTEGER UNSIGNED NOT NULL default 0,
|
||||||
`id_filter` INTEGER UNSIGNED NOT NULL default 0,
|
`id_filter` INTEGER UNSIGNED NOT NULL default 0,
|
||||||
|
`description` TEXT NOT NULL,
|
||||||
`date` bigint(20) NOT NULL default '0',
|
`date` bigint(20) NOT NULL default '0',
|
||||||
`period` int(11) NOT NULL default 0,
|
`period` int(11) NOT NULL default 0,
|
||||||
`max` int (11) NOT NULL default 0,
|
`max` int (11) NOT NULL default 0,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user