mirror of
https://github.com/pandorafms/pandorafms.git
synced 2025-07-28 16:24:54 +02:00
2009-08-03 Ramon Novoa <rnovoa@artica.es>
* linux/plugins/inventory: Added the capacity for search services in init, details file system, and modify the software scanner to extract the description. git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@1836 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
parent
b2aa119ce2
commit
28096d7520
@ -6,7 +6,7 @@
|
|||||||
#
|
#
|
||||||
# inventory Generate a hardware/software inventory.
|
# inventory Generate a hardware/software inventory.
|
||||||
#
|
#
|
||||||
# Sample usage: ./inventory <interval in days> [cpu] [ram] [video] [nic] [hd] [cdrom] [software]
|
# Sample usage: ./inventory <interval in days> [cpu] [ram] [video] [nic] [hd] [cdrom] [software] [init_services] [filesystem]
|
||||||
#
|
#
|
||||||
# This program is free software; you can redistribute it and/or modify
|
# 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
|
# 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);
|
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
|
# Get a list of installed programs
|
||||||
sub get_software_module_data ($$) {
|
sub get_software_module_data ($$) {
|
||||||
my ($name, $modules) = @_;
|
my ($name, $modules) = @_;
|
||||||
@ -68,12 +110,14 @@ sub get_software_module_data ($$) {
|
|||||||
|
|
||||||
# Parse data
|
# Parse data
|
||||||
foreach my $row (@soft) {
|
foreach my $row (@soft) {
|
||||||
next unless ($row =~ /^ii\s+(\S+)\s+(\S+)/);
|
next unless ($row =~ /^ii\s+(\S+)\s+(\S+)\s+([^\n]+)/);
|
||||||
|
|
||||||
my %module;
|
my %module;
|
||||||
$module{'program'} = $1;
|
$module{'program'} = $1;
|
||||||
$module{'version'} = $2;
|
$module{'version'} = $2;
|
||||||
$module{'_keys'} = ['program', 'version'];
|
$module{'description'} = $3;
|
||||||
|
$module{'_keys'} = ['program', 'version','description'];
|
||||||
|
|
||||||
push (@{$modules->{$name}}, \%module);
|
push (@{$modules->{$name}}, \%module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -101,7 +145,7 @@ sub print_module ($$) {
|
|||||||
|
|
||||||
# Check command line parameters
|
# Check command line parameters
|
||||||
if ($#ARGV < 0) {
|
if ($#ARGV < 0) {
|
||||||
print "Usage: $0 <interval> [cpu] [ram] [video] [nic] [hd] [cdrom] [software]\n\n";
|
print "Usage: $0 <interval> [cpu] [ram] [video] [nic] [hd] [cdrom] [software] [init_services] [filesystem]\n\n";
|
||||||
exit 1;
|
exit 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -168,6 +212,17 @@ if ($enable_all == 1 || $enabled{'software'} == 1) {
|
|||||||
get_software_module_data ('Software', \%modules);
|
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 module data
|
||||||
print "<inventory>\n";
|
print "<inventory>\n";
|
||||||
while (my ($name, $module) = each (%modules)) {
|
while (my ($name, $module) = each (%modules)) {
|
||||||
|
10
pandora_server/util/agent_names.txt
Normal file
10
pandora_server/util/agent_names.txt
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
Agent_1
|
||||||
|
Agent_2
|
||||||
|
Agent_3
|
||||||
|
Agent_4
|
||||||
|
Agent_5
|
||||||
|
Agent_6
|
||||||
|
Agent_7
|
||||||
|
Agent_8
|
||||||
|
Agent_9
|
||||||
|
Agent_10
|
72
pandora_server/util/pandora_xml_stress.conf
Executable file
72
pandora_server/util/pandora_xml_stress.conf
Executable file
@ -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
|
Loading…
x
Reference in New Issue
Block a user