Merge branch '4581-sample-agent-nueva-funcionalidad' into 'develop'

Added feature sample_agent

See merge request artica/pandorafms!2826
This commit is contained in:
Alejandro Fraguas 2019-11-04 17:54:33 +01:00
commit 777bbdd180
9 changed files with 241 additions and 33 deletions

View File

@ -0,0 +1,66 @@
<?php
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2019 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 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.
require_once __DIR__.'/../include/config.php';
require_once __DIR__.'/../include/auth/mysql.php';
require_once __DIR__.'/../include/functions.php';
require_once __DIR__.'/../include/functions_db.php';
/*
* Review if sample agent is active and deploys configuration for
* visual consoles if necessary
*/
global $config;
// Deployment of sample agent for visual consoles.
if ($config['sample_agent'] == 1 && !isset($config['sample_agent_deployed'])) {
$id_agente = db_get_sql('SELECT id_agente FROM tagente WHERE nombre = "Sample_Agent";');
$modules = db_get_all_rows_filter('tagente_modulo', ['id_agente' => $id_agente], 'id_agente_modulo');
$count_modules = count($modules);
// Update of layout 1 (Rack sample).
$images_rack_server = [
'rack_server_rack',
'rack_server',
'rack_switch',
'rack_firewall',
'rack_double_server',
'rack_frame',
'rack_pdu',
];
$query = 'UPDATE `tlayout_data` SET `id_agent` = '.$id_agente.', `id_agente_modulo` = CASE ';
for ($i = 0; $i < $count_modules; $i++) {
$query .= 'WHEN `image` = "'.$images_rack_server[$i].'" THEN '.$modules[$i]['id_agente_modulo'].' ';
}
$query .= 'END WHERE `id_layout` = 1 AND `image` IN ("'.implode('","', $images_rack_server).'");';
db_process_sql($query);
// Update of layout 2 (Dashboard).
$query = 'UPDATE `tlayout_data` SET `id_agent`= '.$id_agente.', `id_agente_modulo` = CASE ';
$query .= 'WHEN `id` = 107 THEN '.$modules[0]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 108 THEN '.$modules[1]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 109 THEN '.$modules[2]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 110 THEN '.$modules[2]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 111 THEN '.$modules[3]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 112 THEN '.$modules[4]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 113 THEN '.$modules[5]['id_agente_modulo'].' ';
$query .= 'WHEN `id` = 114 THEN '.$modules[6]['id_agente_modulo'].' ';
$query .= 'END WHERE `id_layout` = 2 AND `id` IN (107,108,109,110,111,112,113,114);';
db_process_sql($query);
// This setting will avoid regenerate all the times the visual consoles.
config_update_value('sample_agent_deployed', 1);
}
extensions_add_main_function('sample_agent_deployment');

View File

@ -138,7 +138,8 @@ INSERT INTO `tconfig` (`token`, `value`) VALUES
('cr_incident_type', ''),
('cr_incident_status', ''),
('cr_incident_title', ''),
('cr_incident_content', '');
('cr_incident_content', ''),
('sample_agent', '0');
UNLOCK TABLES;
--
@ -1402,41 +1403,41 @@ VALUES
(53,1,1413,243,205,426,'','rack_frame',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(54,1,962,381,73,408,'','rack_firewall',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(55,1,962,454,73,408,'','rack_pdu',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(56,1,530,732,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(57,1,962,233,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(58,1,962,307,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(59,1,530,658,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(60,1,530,350,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(61,1,530,204,73,408,'','rack_psa',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(62,1,530,277,73,408,'','rack_pdu',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(63,1,530,585,73,408,'','rack_firewall',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(64,1,530,424,161,411,'','rack_double_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(56,1,530,732,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(57,1,962,233,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(58,1,962,307,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(59,1,530,658,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(60,1,530,350,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(61,1,530,204,73,408,'','rack_psa',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(62,1,530,277,73,408,'','rack_pdu',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(63,1,530,585,73,408,'','rack_firewall',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(64,1,530,424,161,411,'','rack_double_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(65,1,1426,448,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(66,1,1495,540,174,29,'','rack_server_rack',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(67,1,1423,260,174,29,'','rack_server_rack',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(68,1,1463,540,174,29,'','rack_server_rack',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(69,1,1433,540,174,29,'','rack_server_rack',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(70,1,74,733,73,408,'','rack_pdu',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(70,1,74,733,73,408,'','rack_pdu',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(71,1,1098,701,80,18,'','rack_hard_disk',0,3600,9,2,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(72,1,1148,701,80,18,'','rack_hard_disk',0,3600,9,2,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(73,1,1340,699,80,18,'','rack_hard_disk_2',0,3600,9,2,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(74,1,1358,783,80,18,'','rack_hard_disk_2',0,3600,9,2,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(75,1,1358,699,80,18,'','rack_hard_disk_2',0,3600,9,2,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(76,1,1143,783,80,18,'','rack_hard_disk',0,3600,9,2,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(77,1,962,682,205,426,'','rack_frame',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(77,1,962,682,205,426,'','rack_frame',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(78,1,1522,540,174,29,'','rack_server_rack',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(79,1,1419,521,205,426,'','rack_frame',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(80,1,74,278,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(81,1,74,572,161,411,'','rack_double_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(79,1,1420,521,205,426,'','rack_frame',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(80,1,74,278,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(81,1,74,572,161,411,'','rack_double_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(82,1,1418,729,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(83,1,962,527,73,408,'','rack_switch',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(84,1,74,352,73,408,'','rack_router',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(85,1,962,600,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(86,1,530,806,73,408,'','rack_firewall',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(87,1,74,425,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(86,1,530,806,73,408,'','rack_firewall',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(87,1,74,425,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(88,1,74,499,73,408,'','rack_switch',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(89,1,74,806,73,408,'','rack_psa',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(90,1,74,204,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(89,1,74,806,73,408,'','rack_psa',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(90,1,74,204,74,413,'','rack_server',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(91,1,1424,806,73,408,'','rack_firewall',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(92,1,1486,907,0,0,'&lt;p&#x20;style=&quot;text-align:&#x20;center;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;Office&#x20;8&#x20;-&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;Rack&#x20;2&lt;/span&gt;&lt;/p&gt;','white',4,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,0),
(93,1,1048,889,58,281,'&lt;p&#x20;style=&quot;text-align:&#x20;center;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;Office&#x20;8&#x20;-&amp;nbsp;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;Rack&#x20;1&lt;/span&gt;&lt;/p&gt;','white',4,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,0),
@ -1445,18 +1446,20 @@ VALUES
(96,1,733,20,0,0,'&lt;p&#x20;style=&quot;overflow:&#x20;hidden;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_48pt&quot;&gt;&lt;strong&gt;&lt;span&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;OFFICE&#x20;RACKS&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;','white',4,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,0),
(97,1,1479,260,174,29,'','rack_server_rack',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,'0.000','0.000',0,0,'analogic_1','time','Europe/Madrid',0,60),
(98,2,709,103,0,400,'','white',19,3600,0,0,0,0,1,0,0,0,0,'line','down','','#FFFFFF',0,0,'default',0,0.000,0.000,0,0,'digital_1','timedate','Europe/Madrid',0,0),
(99,2,178,481,111,111,'','status',0,3600,11556,430,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(100,2,542,481,111,111,'','status',0,3600,13,2,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(101,2,905,481,111,111,'','status',0,3600,114,11,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(102,2,1276,481,111,111,'','status',0,3600,7,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(103,2,1631,482,111,111,'','status',0,3600,11547,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(104,2,157,393,0,0,'<p style=\"line-height: 18px;\"><span class=\"visual_font_size_28pt\" style=\"line-height: 18px; color: #ffffff;\">Backups</span></p>\n<p style=\"line-height: 18px;\"> </p>','white',
4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(105,2,512,382,96,172,'&lt;p&#x20;style=&quot;overflow:&#x20;hidden;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;font-family:&#x20;opensans;&#x20;color:&#x20;#ffffff;&quot;&gt;DB&#x20;Status&lt;/span&gt;&lt;/p&gt;&#x0a;&lt;p&#x20;style=&quot;overflow:&#x20;hidden;&quot;&gt;&amp;nbsp;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(99,2,1251,382,0,0,'<p style=\"line-height: 18px; overflow: hidden;\"><span class=\"visual_font_size_28pt\" style=\"color: #ffffff; font-family: opensans;\">Disk /var</span></p>\n<p style=\"line-height: 18px; overflow: hidden;\"> </p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(100,2,1547,382,0,0,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;Authentification&lt;/span&gt;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(101,2,126,820,0,0,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_36pt&quot;&#x20;style=&quot;font-family:&#x20;opensans;&#x20;color:&#x20;#ffffff;&quot;&gt;Processing&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(102,2,755,820,0,0,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_36pt&quot;&#x20;style=&quot;font-family:&#x20;opensans;&#x20;color:&#x20;#ffffff;&quot;&gt;Network&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(103,2,1281,820,0,0,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_36pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;Storage&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(104,2,157,393,0,0,'<p style=\"line-height: 18px;\"><span class=\"visual_font_size_28pt\" style=\"line-height: 18px; color: #ffffff;\">Backups</span></p>\n<p style=\"line-height: 18px;\"> </p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(105,2,512,382,96,172,'&lt;p&#x20;style=&quot;overflow:&#x20;hidden;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;font-family:&#x20;opensans;&#x20;color:&#x20;#ffffff;&quot;&gt;DB&#x20;Status&lt;/span&gt;&lt;/p&gt;&#x0a;&lt;p&#x20;style=&quot;overflow:&#x20;hidden;&quot;&gt;&amp;nbsp;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(106,2,886,382,0,0,'<p style=\"line-height: 18px; overflow: hidden;\"><span class=\"visual_font_size_28pt\" style=\"color: #ffffff; font-family: opensans;\">Disk slave</span></p>\n<p style=\"line-height: 18px; overflow: hidden;\"> </p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(107,2,1251,382,0,0,'<p style=\"line-height: 18px; overflow: hidden;\"><span class=\"visual_font_size_28pt\" style=\"color: #ffffff; font-family: opensans;\">Disk /var</span></p>\n<p style=\"line-height: 18px; overflow: hidden;\"> </p>','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(108,2,1547,382,0,0,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_28pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;Authentification&lt;/span&gt;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(109,2,126,820,0,0,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_36pt&quot;&#x20;style=&quot;font-family:&#x20;opensans;&#x20;color:&#x20;#ffffff;&quot;&gt;Processing&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(110,2,755,820,0,0,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_36pt&quot;&#x20;style=&quot;font-family:&#x20;opensans;&#x20;color:&#x20;#ffffff;&quot;&gt;Network&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(111,2,1281,820,0,0,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_36pt&quot;&#x20;style=&quot;color:&#x20;#ffffff;&#x20;font-family:&#x20;opensans;&quot;&gt;Storage&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;','white',4,3600,0,0,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0)
(107,2,178,481,111,111,'','status',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(108,2,542,481,111,111,'','status',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(109,2,905,481,111,111,'','status',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(110,2,1276,481,111,111,'','status',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(111,2,1631,482,111,111,'','status',0,3600,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0.000,0.000,0,0,'analogic_1','time','Europe/Madrid',0,0),
(112,2,387,825,100,226,'&lt;p&#x20;style=&quot;line-height:&#x20;26px;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_60pt&quot;&gt;&lt;strong&gt;&lt;span&#x20;style=&quot;line-height:&#x20;26px;&#x20;font-family:&#x20;roboto;&#x20;color:&#x20;#ffff99;&quot;&gt;&#40;_VALUE_&#41;&lt;/span&gt;&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;','',2,300,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(113,2,936,799,0,226,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;strong&gt;&lt;span&#x20;class=&quot;visual_font_size_60pt&quot;&#x20;style=&quot;font-family:&#x20;roboto;&#x20;color:&#x20;#ccffcc;&quot;&gt;&#40;_VALUE_&#41;&lt;/span&gt;&lt;/strong&gt;&lt;/p&gt;','',2,300,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0),
(114,2,1476,818,0,226,'&lt;p&#x20;style=&quot;line-height:&#x20;18px;&#x20;overflow:&#x20;hidden;&quot;&gt;&lt;span&#x20;class=&quot;visual_font_size_36pt&quot;&#x20;style=&quot;color:&#x20;#ccffff;&#x20;font-family:&#x20;roboto;&quot;&gt;&#40;_VALUE_&#41;&lt;/span&gt;&lt;/p&gt;&#x0d;&#x0a;&lt;div&#x20;id=&quot;gtx-trans&quot;&#x20;style=&quot;position:&#x20;absolute;&#x20;left:&#x20;43px;&#x20;top:&#x20;4.65625px;&quot;&gt;&amp;nbsp;&lt;/div&gt;','',2,300,1,1,0,0,1,0,0,0,0,'line','down','','',0,0,'default',0,0,0,0,0,'analogic_1','time','Europe/Madrid',0,0)
;

View File

@ -348,6 +348,15 @@ self_monitoring 1
# Self monitoring interval (in seconds).
self_monitoring_interval 300
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
# will make sample data. Disabled by default.
sample_agent 0
# Pandora Sample Agent interval (in seconds).
sample_agent_interval 600
# Update parent from the agent xml
#update_parent 1

View File

@ -340,6 +340,15 @@ restart_delay 60
self_monitoring 1
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
# will make sample data. Disabled by default.
sample_agent 0
# Pandora Sample Agent interval (in seconds).
sample_agent_interval 600
# Update parent from the agent xml
#update_parent 1

View File

@ -382,6 +382,16 @@ sub pandora_server_tasks ($) {
pandora_self_monitoring ($pa_config, $dbh);
}
# Pandora sample agent
if (defined($pa_config->{'sample_agent'})) {
if ($pa_config->{'sample_agent'} == 1
&& !is_metaconsole($pa_config)
&& $counter % $pa_config->{'sample_agent_interval'} == 0){
pandora_sample_agent ($pa_config);
}
pandora_update_config_token ($dbh, 'sample_agent', $pa_config->{'sample_agent'});
}
# Avoid counter overflow
if ($counter >= ~0){
$counter = 0;

View File

@ -376,6 +376,15 @@ self_monitoring 1
# Self monitoring interval (in seconds).
self_monitoring_interval 300
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
# will make sample data. Disabled by default.
sample_agent 0
# Pandora Sample Agent interval (in seconds).
sample_agent_interval 600
# Update parent from the agent xml
#update_parent 1

View File

@ -330,6 +330,15 @@ restart_delay 60
# Self monitoring interval (in seconds).
#self_monitoring_interval 300
# Pandora Sample Agent. If enabled, every 10 minutes, this embedded agent
# will make sample data. Disabled by default.
sample_agent 0
# Pandora Sample Agent interval (in seconds).
sample_agent_interval 600
# Update parent from the agent xml
#update_parent 1

View File

@ -79,7 +79,7 @@ sub help_screen {
sub pandora_init {
my $pa_config = $_[0];
my $init_string = $_[1];
print "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-2018 " . pandora_get_initial_copyright_notice() . "\n";
print "\n$init_string $pandora_version Build $pandora_build Copyright (c) 2004-20".substr($pandora_build,0,2)." " . pandora_get_initial_copyright_notice() . "\n";
print "This program is OpenSource, licensed under the terms of GPL License version 2.\n";
print "You can download latest versions and documentation at official web page.\n\n";
@ -397,6 +397,12 @@ sub pandora_load_config {
# Self monitoring interval
$pa_config->{'self_monitoring_interval'} = 300; # 5.1SP1
# Sample Agent
$pa_config->{'sample_agent'} = 0;
# Sample agent interval
$pa_config->{'sample_agent_interval'} = 600;
# Process XML data files as a stack
$pa_config->{"dataserver_lifo"} = 0; # 5.0
@ -946,6 +952,12 @@ sub pandora_load_config {
elsif ($parametro =~ m/^self_monitoring_interval\s+([0-9]*)/i) {
$pa_config->{'self_monitoring_interval'} = clean_blank($1);
}
elsif ($parametro =~ m/^sample_agent\s+([0-1])/i) {
$pa_config->{'sample_agent'} = clean_blank($1);
}
elsif ($parametro =~ m/^sample_agent_interval\s+([0-9]*)/i) {
$pa_config->{'sample_agent_interval'} = clean_blank($1);
}
elsif ($parametro =~ m/^update_parent\s+([0-1])/i) {
$pa_config->{'update_parent'} = clean_blank($1);
}

View File

@ -100,6 +100,8 @@ Exported Functions:
=item * C<pandora_self_monitoring>
=item * C<pandora_sample_agent>
=back
=head1 METHODS
@ -122,6 +124,7 @@ use threads::shared;
use JSON qw(decode_json encode_json);
use MIME::Base64;
use Text::ParseWords;
use Math::Trig; # Math functions
# Debugging
#use Data::Dumper;
@ -247,6 +250,7 @@ our @EXPORT = qw(
pandora_group_statistics
pandora_server_statistics
pandora_self_monitoring
pandora_sample_agent
pandora_process_policy_queue
subst_alert_macros
subst_column_macros
@ -5235,6 +5239,83 @@ sub pandora_self_monitoring ($$) {
print XMLFILE $xml_output;
close (XMLFILE);
}
##########################################################################
=head2 C<< xml_module_template (I<$module_name>, I<$module_type>, I<$module_data>) >>
Module template for sample agent
=cut
##########################################################################
sub xml_module_template ($$$) {
my ($module_name, $module_type, $module_data) = @_;
my $output = "<module>\n";
$module_name = "<![CDATA[".$module_name."]]>" if $module_name =~ /[\s+.]+/;
$module_data = "<![CDATA[".$module_data."]]>" if $module_data =~ /[\s+.]+/;
$output .= "\t<name>".$module_name."</name>\n";
$output .= "\t<type>".$module_type."</type>\n";
$output .= "\t<data>".$module_data."</data>\n";
$output .= "</module>\n";
return $output;
}
##########################################################################
=head2 C<< pandora_sample_agent (I<$pa_config>) >>
Pandora agent for make sample data
=cut
##########################################################################
sub pandora_sample_agent ($) {
my ($pa_config) = @_;
my $utimestamp = time ();
my $timestamp = strftime ("%Y-%m-%d %H:%M:%S", localtime());
# First line
my $xml_output = "<?xml version='1.0' encoding='UTF-8'?>\n";
# Header
$xml_output = "<agent_data agent_name='Sample_Agent' agent_alias='Sample_Agent' description='Agent for sample generation purposes' group='Servers' os_name='$OS' os_version='$OS_VERSION' interval='".$pa_config->{'sample_agent_interval'}."' version='" . $pa_config->{'version'} . "' timestamp='".$timestamp."'>\n";
# Boolean ever return TRUE
$xml_output .= xml_module_template ("Boolean ever true", "generic_proc","1");
# Boolean return TRUE at 80% of times
my $sample_boolean_mostly_true = 1;
$sample_boolean_mostly_true = 0 if rand(9) > 7;
$xml_output .= xml_module_template ("Boolean mostly true", "generic_proc",$sample_boolean_mostly_true);
# Boolean return false at 80% of times
my $sample_boolean_mostly_false = 0;
$sample_boolean_mostly_false = 1 if rand(9) > 7;
$xml_output .= xml_module_template ("Boolean mostly false", "generic_proc", $sample_boolean_mostly_false);
# Boolean ever return FALSE
$xml_output .= xml_module_template ("Boolean ever false", "generic_proc","0");
# Random integer between 0 and 100
$xml_output .= xml_module_template ("Random integer values", "generic_data",int(rand(100)));
# Random values obtained with sinusoidal curves between 0 and 100 values
my $b = 1;
my $sample_serie_curve = 1 + cos(deg2rad($b));
$b = $b + rand(20)/10;
$b = 0 if ($b > 180);
$sample_serie_curve = $sample_serie_curve * $b * 10;
$sample_serie_curve =~ s/\,/\./g;
$xml_output .= xml_module_template ("Random serie curve", "generic_data", $sample_serie_curve);
# String with 10 random characters
my $sample_random_text = "";
my @characters = ('a'..'z','A'..'Z');
for (1...10){
$sample_random_text .= $characters[int(rand(@characters))];
}
$xml_output .= xml_module_template ("Random text", "generic_data_string", $sample_random_text);
# End of xml
$xml_output .= "</agent_data>";
# File path definition
my $filename = $pa_config->{"incomingdir"}."/".$pa_config->{'servername'}.".sample.".$utimestamp.".data";
# Opening, Writing and closing of XML
open (my $xmlfile, ">", $filename) or die "[FATAL] Could not open sample XML file for deploying monitorization at '$filename'";
print $xmlfile $xml_output;
close ($xmlfile);
}
##########################################################################
=head2 C<< set_master (I<$pa_config>, I<$dbh>) >>