mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-30 01:05:39 +02:00
Merge branch 'feature/123-deteccion-de-ekid-automatica' into 'develop'
Feature/123 deteccion de ekid automatica Closes Issue artica/pandora_enterprise#123 See merge request !3
This commit is contained in:
commit
58fe27a664
51
pandora_agents/unix/pandora_agent
Normal file → Executable file
51
pandora_agents/unix/pandora_agent
Normal file → Executable file
@ -131,6 +131,7 @@ my %DefaultConf = (
|
|||||||
'temporal' => '/var/spool/pandora',
|
'temporal' => '/var/spool/pandora',
|
||||||
'interval' => 300,
|
'interval' => 300,
|
||||||
'debug' => 0,
|
'debug' => 0,
|
||||||
|
'ehorus_conf' => undef,
|
||||||
'agent_name' => hostname (),
|
'agent_name' => hostname (),
|
||||||
'agent_name_cmd' => '',
|
'agent_name_cmd' => '',
|
||||||
'description' => '',
|
'description' => '',
|
||||||
@ -2194,6 +2195,39 @@ sub init_module ($) {
|
|||||||
$module->{'alert_template'} = undef;
|
$module->{'alert_template'} = undef;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
################################################################################
|
||||||
|
# Get the eHorus key from the eHorus agent configuration file.
|
||||||
|
################################################################################
|
||||||
|
sub get_ehkey {
|
||||||
|
my $fh;
|
||||||
|
|
||||||
|
return '' unless defined($Conf{'ehorus_conf'});
|
||||||
|
|
||||||
|
# Open the eHorus configuration file.
|
||||||
|
if (!open($fh, '<', $Conf{'ehorus_conf'})) {
|
||||||
|
# Do not write to the log, since ehorus_conf points to the default eHorus configuration file by default.
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
|
# Look for the eHorus key.
|
||||||
|
while (my $line = <$fh>) {
|
||||||
|
|
||||||
|
# Skip comments.
|
||||||
|
next if ($line =~ m/^\s*#/);
|
||||||
|
|
||||||
|
if ($line =~ m/\s*eh_key\s+(\S+)/) {
|
||||||
|
my $eh_key = $1;
|
||||||
|
close($fh);
|
||||||
|
|
||||||
|
return $eh_key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
# Not found.
|
||||||
|
close($fh);
|
||||||
|
return '';
|
||||||
|
}
|
||||||
|
|
||||||
################################################################################
|
################################################################################
|
||||||
# Main.
|
# Main.
|
||||||
################################################################################
|
################################################################################
|
||||||
@ -2373,11 +2407,14 @@ while (1) {
|
|||||||
# Clear the XML
|
# Clear the XML
|
||||||
$Xml = "";
|
$Xml = "";
|
||||||
|
|
||||||
|
# Get the eHorus key.
|
||||||
|
my $eh_key = get_ehkey();
|
||||||
|
|
||||||
# Custom fields
|
# Custom fields
|
||||||
|
|
||||||
my @customfieldskeys = keys(%Customfields);
|
my @customfieldskeys = keys(%Customfields);
|
||||||
if ($#customfieldskeys > -1) {
|
if ($#customfieldskeys > -1 || $eh_key ne '') {
|
||||||
$Xml .= "<custom_fields>\n";
|
$Xml .= "<custom_fields>\n";
|
||||||
|
|
||||||
foreach my $customfieldkey (@customfieldskeys) {
|
foreach my $customfieldkey (@customfieldskeys) {
|
||||||
if($customfieldkey =~ m/^(custom_field\d+_)name/) {
|
if($customfieldkey =~ m/^(custom_field\d+_)name/) {
|
||||||
if(defined($Customfields{$1."value"})) {
|
if(defined($Customfields{$1."value"})) {
|
||||||
@ -2388,6 +2425,15 @@ while (1) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Add the eHorus key as a custom field.
|
||||||
|
if ($eh_key ne '') {
|
||||||
|
$Xml .= " <field>\n";
|
||||||
|
$Xml .= " <name>eHorusID</name>\n";
|
||||||
|
$Xml .= " <value><![CDATA[". $eh_key ."]]></value>\n";
|
||||||
|
$Xml .= " </field>\n";
|
||||||
|
}
|
||||||
|
|
||||||
$Xml .= "</custom_fields>\n";
|
$Xml .= "</custom_fields>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2475,6 +2521,7 @@ while (1) {
|
|||||||
$xml_header .= "' position_description='" .$Conf{'position_description'};
|
$xml_header .= "' position_description='" .$Conf{'position_description'};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$xml_header .= "'>\n";
|
$xml_header .= "'>\n";
|
||||||
$Xml = $xml_header . $Xml . "</agent_data>";
|
$Xml = $xml_header . $Xml . "</agent_data>";
|
||||||
|
|
||||||
|
@ -385,7 +385,7 @@ Pandora_Windows_Service::getXmlHeader () {
|
|||||||
char timestamp[20];
|
char timestamp[20];
|
||||||
string agent_name, os_name, os_version, encoding, value, xml, address, parent_agent_name, agent_name_cmd;
|
string agent_name, os_name, os_version, encoding, value, xml, address, parent_agent_name, agent_name_cmd;
|
||||||
string custom_id, url_address, latitude, longitude, altitude, position_description, gis_exec, gis_result, agent_mode;
|
string custom_id, url_address, latitude, longitude, altitude, position_description, gis_exec, gis_result, agent_mode;
|
||||||
string group_password;
|
string group_password, ehorus_conf;
|
||||||
time_t ctime;
|
time_t ctime;
|
||||||
struct tm *ctime_tm = NULL;
|
struct tm *ctime_tm = NULL;
|
||||||
int pos;
|
int pos;
|
||||||
@ -479,13 +479,12 @@ Pandora_Windows_Service::getXmlHeader () {
|
|||||||
xml += url_address;
|
xml += url_address;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Url Address
|
// Get group password
|
||||||
group_password = conf->getValue ("group_password");
|
group_password = conf->getValue ("group_password");
|
||||||
if (group_password != "") {
|
if (group_password != "") {
|
||||||
xml += "\" group_password=\"";
|
xml += "\" group_password=\"";
|
||||||
xml += group_password;
|
xml += group_password;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Get Coordinates
|
// Get Coordinates
|
||||||
gis_exec = conf->getValue ("gis_exec");
|
gis_exec = conf->getValue ("gis_exec");
|
||||||
|
|
||||||
@ -1634,6 +1633,7 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
|
|||||||
string xml_filename, random_integer;
|
string xml_filename, random_integer;
|
||||||
string tmp_filename, tmp_filepath;
|
string tmp_filename, tmp_filepath;
|
||||||
string encoding;
|
string encoding;
|
||||||
|
string ehorus_conf, eh_key;
|
||||||
static HANDLE mutex = 0;
|
static HANDLE mutex = 0;
|
||||||
ULARGE_INTEGER free_bytes;
|
ULARGE_INTEGER free_bytes;
|
||||||
double min_free_bytes = 0;
|
double min_free_bytes = 0;
|
||||||
@ -1653,6 +1653,12 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
|
|||||||
|
|
||||||
data_xml = getXmlHeader ();
|
data_xml = getXmlHeader ();
|
||||||
|
|
||||||
|
/* Get the eHorus key. */
|
||||||
|
ehorus_conf = conf->getValue ("ehorus_conf");
|
||||||
|
if (ehorus_conf != "") {
|
||||||
|
eh_key = getEHKey(ehorus_conf);
|
||||||
|
}
|
||||||
|
|
||||||
/* Write custom fields */
|
/* Write custom fields */
|
||||||
int c = 1;
|
int c = 1;
|
||||||
|
|
||||||
@ -1662,8 +1668,8 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
|
|||||||
sprintf(token_value_token, "custom_field%d_value", c);
|
sprintf(token_value_token, "custom_field%d_value", c);
|
||||||
string token_name = conf->getValue (token_name_token);
|
string token_name = conf->getValue (token_name_token);
|
||||||
string token_value = conf->getValue (token_value_token);
|
string token_value = conf->getValue (token_value_token);
|
||||||
|
|
||||||
if(token_name != "" && token_value != "") {
|
if((token_name != "" && token_value != "") || eh_key != "") {
|
||||||
data_xml += "<custom_fields>\n";
|
data_xml += "<custom_fields>\n";
|
||||||
while(token_name != "" && token_value != "") {
|
while(token_name != "" && token_value != "") {
|
||||||
data_xml += " <field>\n";
|
data_xml += " <field>\n";
|
||||||
@ -1677,6 +1683,15 @@ Pandora_Windows_Service::sendXml (Pandora_Module_List *modules) {
|
|||||||
token_name = conf->getValue (token_name_token);
|
token_name = conf->getValue (token_name_token);
|
||||||
token_value = conf->getValue (token_value_token);
|
token_value = conf->getValue (token_value_token);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Add the eHorus key as a custom field. */
|
||||||
|
if (eh_key != "") {
|
||||||
|
data_xml += " <field>\n";
|
||||||
|
data_xml += " <name>eHorusID</name>\n";
|
||||||
|
data_xml += " <value><![CDATA["+ eh_key +"]]></value>\n";
|
||||||
|
data_xml += " </field>\n";
|
||||||
|
}
|
||||||
|
|
||||||
data_xml += "</custom_fields>\n";
|
data_xml += "</custom_fields>\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2034,6 +2049,37 @@ Pandora_Windows_Service::getConf () {
|
|||||||
return this->conf;
|
return this->conf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string
|
||||||
|
Pandora_Windows_Service::getEHKey (string ehorus_conf) {
|
||||||
|
string buffer, eh_key;
|
||||||
|
std::ifstream ifs(ehorus_conf.c_str());
|
||||||
|
int pos;
|
||||||
|
|
||||||
|
if (! ifs.is_open ()) {
|
||||||
|
pandoraDebug ("Error opening eHorus configuration file %s", ehorus_conf.c_str ());
|
||||||
|
return eh_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Look for the eHorus key. */
|
||||||
|
while (ifs.good ()) {
|
||||||
|
getline (ifs, buffer);
|
||||||
|
|
||||||
|
/* Skip comments. */
|
||||||
|
if (buffer.empty() || buffer.at(0) == '#') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
pos = buffer.find("eh_key");
|
||||||
|
if (pos != string::npos){
|
||||||
|
eh_key = buffer.substr(pos + 7); /* pos + strlen("eh_key ") */
|
||||||
|
eh_key = trim(eh_key);
|
||||||
|
return eh_key;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return eh_key;
|
||||||
|
}
|
||||||
|
|
||||||
long
|
long
|
||||||
Pandora_Windows_Service::getInterval () {
|
Pandora_Windows_Service::getInterval () {
|
||||||
return this->interval;
|
return this->interval;
|
||||||
|
@ -114,6 +114,7 @@ namespace Pandora {
|
|||||||
int sendXml (Pandora_Module_List *modules);
|
int sendXml (Pandora_Module_List *modules);
|
||||||
void sendBufferedXml (string path);
|
void sendBufferedXml (string path);
|
||||||
Pandora_Agent_Conf *getConf ();
|
Pandora_Agent_Conf *getConf ();
|
||||||
|
string getEHKey (string ehorus_conf);
|
||||||
long getInterval ();
|
long getInterval ();
|
||||||
long getIntensiveInterval ();
|
long getIntensiveInterval ();
|
||||||
|
|
||||||
|
@ -123,3 +123,8 @@ ALTER TABLE tlayout ADD `background_color` varchar(50) NOT NULL default '#FFF';
|
|||||||
-- Table `tlayout_data`
|
-- Table `tlayout_data`
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
ALTER TABLE tlayout_data ADD `type_graph` varchar(50) NOT NULL default 'area';
|
ALTER TABLE tlayout_data ADD `type_graph` varchar(50) NOT NULL default 'area';
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tagent_custom_fields`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
INSERT INTO `tagent_custom_fields` (`name`) VALUES ('eHorusID');
|
||||||
|
@ -101,3 +101,8 @@ ALTER TABLE tlayout ADD COLUMN background_color varchar(50) NOT NULL default '#F
|
|||||||
-- Table `tlayout_data`
|
-- Table `tlayout_data`
|
||||||
-- ---------------------------------------------------------------------
|
-- ---------------------------------------------------------------------
|
||||||
ALTER TABLE tlayout_data ADD COLUMN type_graph varchar(50) NOT NULL default 'area';
|
ALTER TABLE tlayout_data ADD COLUMN type_graph varchar(50) NOT NULL default 'area';
|
||||||
|
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
-- Table `tagent_custom_fields`
|
||||||
|
-- ---------------------------------------------------------------------
|
||||||
|
INSERT INTO tagent_custom_fields (name) VALUES ('eHorusID');
|
||||||
|
@ -1371,6 +1371,7 @@ EXECUTE IMMEDIATE 'ALTER TRIGGER tagent_custom_fields_inc DISABLE';
|
|||||||
INSERT INTO tagent_custom_fields VALUES (1,'Serial Number',0);
|
INSERT INTO tagent_custom_fields VALUES (1,'Serial Number',0);
|
||||||
INSERT INTO tagent_custom_fields VALUES (2,'Department',0);
|
INSERT INTO tagent_custom_fields VALUES (2,'Department',0);
|
||||||
INSERT INTO tagent_custom_fields VALUES (3,'Additional ID',0);
|
INSERT INTO tagent_custom_fields VALUES (3,'Additional ID',0);
|
||||||
|
INSERT INTO tagent_custom_fields VALUES (4,'eHorusID',0);
|
||||||
|
|
||||||
-- Update curr val of sequence
|
-- Update curr val of sequence
|
||||||
update_currval('tagent_custom_fields', 'id_field');
|
update_currval('tagent_custom_fields', 'id_field');
|
||||||
|
@ -1033,7 +1033,7 @@ INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `execute`, `p
|
|||||||
|
|
||||||
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (9,'Packet Loss','Checks for dropped packages after X seconds of testing. It returns % of dropped packets. It uses ping flood mode to launch 50 consecutive pings to a remote destination. On local, stable networks, value should be 0.
',30,0,'/usr/share/pandora_server/util/plugin/packet_loss.sh','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Test time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','_field1_ _field2_');
|
INSERT INTO `tplugin` (`id`, `name`, `description`, `max_timeout`, `max_retries`, `execute`, `net_dst_opt`, `net_port_opt`, `user_opt`, `pass_opt`, `plugin_type`, `macros`, `parameters`) VALUES (9,'Packet Loss','Checks for dropped packages after X seconds of testing. It returns % of dropped packets. It uses ping flood mode to launch 50 consecutive pings to a remote destination. On local, stable networks, value should be 0.
',30,0,'/usr/share/pandora_server/util/plugin/packet_loss.sh','','','','',0,'{\"1\":{\"macro\":\"_field1_\",\"desc\":\"Test time\",\"help\":\"\",\"value\":\"8\",\"hide\":\"\"},\"2\":{\"macro\":\"_field2_\",\"desc\":\"Target IP\",\"help\":\"\",\"value\":\"\",\"hide\":\"\"}}','_field1_ _field2_');
|
||||||
|
|
||||||
INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0),(2,'Department',0),(3,'Additional ID',0);
|
INSERT INTO `tagent_custom_fields` VALUES (1,'Serial Number',0),(2,'Department',0),(3,'Additional ID',0),(4,'eHorusID',0);
|
||||||
|
|
||||||
INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','',''),(2,'critical','Critical modules','','',''),(3,'dmz','DMZ Network Zone','','',''),(4,'performance','Performance anda capacity modules','','',''),(5,'configuration','','','','');
|
INSERT INTO `ttag` VALUES (1,'network','Network equipment','http://artica.es','',''),(2,'critical','Critical modules','','',''),(3,'dmz','DMZ Network Zone','','',''),(4,'performance','Performance anda capacity modules','','',''),(5,'configuration','','','','');
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user