diff --git a/pandora_agents/linux/plugins/inventory b/pandora_agents/linux/plugins/inventory index 9f190dc977..02075d2372 100755 --- a/pandora_agents/linux/plugins/inventory +++ b/pandora_agents/linux/plugins/inventory @@ -6,7 +6,7 @@ # # inventory Generate a hardware/software inventory. # -# Sample usage: ./inventory [cpu] [ram] [video] [nic] [hd] [cdrom] [software] +# Sample usage: ./inventory [cpu] [ram] [video] [nic] [hd] [cdrom] [software] [init_services] [filesystem] # # 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 @@ -48,6 +48,48 @@ sub get_module_data ($$$$) { push (@{$modules->{$name}}, \%module); } +# Get a list of information file system in machine +sub get_file_system($$) { + my ($name, $modules) = @_; + + my @fileSystems = `df -h | tail -n +2`; #remove the titles of columns + + foreach my $row (@fileSystems) { + next unless ($row =~ /^(\S+)\s+\S+\s+(\S+)\s+(\S+)\s+\S+\s+(\S+)/); + + my %module; + $module{'filesystem'} = $1; + $module{'used'} = $2; + $module{'avail'} = $3; + $module{'mount'} = $4; + $module{'_keys'} = ['filesystem', 'used','avail', 'mount']; + push (@{$modules->{$name}}, \%module); + } +} + +# Get a list of services init in machine +sub get_servicies_init_machine($$) { + my ($name, $modules) = @_; + my $runlevel = `runlevel | cut -d' ' -f2`; + + #ini trim($runlevel) + $runlevel =~ s/^\s*//; #ltrim + $runlevel =~ s/\s*$//; #rtrim + #end trim($runlevel) + + my $script = "ls /etc/rc" . $runlevel .".d/ -l | grep \"^l.*\" | grep \" S.* \" | cut -d' ' -f11"; + + my @services = `$script`; + foreach my $row (@services) { + next unless ($row =~ /^\S+\/(\S+)$/); + + my %module; + $module{'service'} = $1; + $module{'_keys'} = ['service']; + push (@{$modules->{$name}}, \%module); + } +} + # Get a list of installed programs sub get_software_module_data ($$) { my ($name, $modules) = @_; @@ -68,12 +110,14 @@ sub get_software_module_data ($$) { # Parse data foreach my $row (@soft) { - next unless ($row =~ /^ii\s+(\S+)\s+(\S+)/); - + next unless ($row =~ /^ii\s+(\S+)\s+(\S+)\s+([^\n]+)/); + my %module; $module{'program'} = $1; $module{'version'} = $2; - $module{'_keys'} = ['program', 'version']; + $module{'description'} = $3; + $module{'_keys'} = ['program', 'version','description']; + push (@{$modules->{$name}}, \%module); } } @@ -101,7 +145,7 @@ sub print_module ($$) { # Check command line parameters if ($#ARGV < 0) { - print "Usage: $0 [cpu] [ram] [video] [nic] [hd] [cdrom] [software]\n\n"; + print "Usage: $0 [cpu] [ram] [video] [nic] [hd] [cdrom] [software] [init_services] [filesystem]\n\n"; exit 1; } @@ -168,6 +212,17 @@ if ($enable_all == 1 || $enabled{'software'} == 1) { get_software_module_data ('Software', \%modules); } +#init_services +if ($enable_all == 1 || $enabled{'init_services'} == 1) { + get_servicies_init_machine ('Init services', \%modules); +} + +#filesystem +if ($enable_all == 1 || $enabled{'filesystem'} == 1) { + get_file_system('File system', \%modules); +} + + # Print module data print "\n"; while (my ($name, $module) = each (%modules)) { diff --git a/pandora_server/util/agent_names.txt b/pandora_server/util/agent_names.txt new file mode 100644 index 0000000000..9240d2dbe0 --- /dev/null +++ b/pandora_server/util/agent_names.txt @@ -0,0 +1,10 @@ +Agent_1 +Agent_2 +Agent_3 +Agent_4 +Agent_5 +Agent_6 +Agent_7 +Agent_8 +Agent_9 +Agent_10 diff --git a/pandora_server/util/pandora_xml_stress.conf b/pandora_server/util/pandora_xml_stress.conf new file mode 100755 index 0000000000..055c1b0de9 --- /dev/null +++ b/pandora_server/util/pandora_xml_stress.conf @@ -0,0 +1,72 @@ +# Maximum number of threads, by default 10. +max_threads 10 + +# File containing a list of agent names (one per line). +agent_file agent_names.txt + +# Directory where XML data files will be placed, by default /tmp. +temporal /var/spool/pandora/data_in + +# Pandora FMS XML Stress log file, logs to stdout by default. +#log_file pandora_xml_stress.log + +# XML version, by default 1.0. +xml_version 1.0 + +# XML encoding, by default ISO-8859-1. +encoding ISO-8859-1 + +# Operating system (shared by all agents), by default Linux. +os_name Linux + +# Operating system version (shared by all agents), by default 2.6. +os_version 2.6 + +# Agent interval, by default 300. +agent_interval 300 + +# Data file generation start date, by default now. +time_from 2009-07-20 00:00:00 + +# Data file generation end date, by default now. +#time_to 2009-06-05 00:00:00 + +# Delay after generating the first data file for each agent to avoid +# race conditions when auto-creating the agent, by default 2. +startup_delay 2 + +# Address of the Tentacle server where XML files will be sent (optional). +# server_ip 192.168.50.1 + +# Port of the Tentacle server, by default 41121. +# server_port 41121 + +# Module definitions. Similar to pandora_agent.conf. + +module_begin +module_name Module_1 +module_type generic_data +module_descripcion Module 1 description. +module_max 100 +module_min 0 +# Probability of the module data changing, by default 100% +module_variation 100 +module_end + +module_begin +module_name Module_2 +module_type generic_data_string +module_descripcion Module 2 description. +# Maximum string length, by default 0. +module_max 20 +# Minimum string length, by default 0 +module_min 10 +module_end + +module_begin +module_name Module_3 +module_type generic_proc +module_descripcion Module 3 description. +# Initial data. +module_data 1 +module_end