2010-10-20 Sancho Lerena <slerena@artica.es>

* conf/pandora_server.conf.windows: Sample conf for running pandora server
    on Windows (see windows.README).

    * lib/PandoraFMS/NetworkServer.pm: Adapted to have SNMPGET and PING functions
    redefined by each SO, this will allow to have native support on pandora
    to run under different OS (need to check FreeBSD and Solaris!). Windows
    support implemented.

    * lib/PandoraFMS/Core.pm: Removed ping functions here and moved to Tools.pm

    * lib/PandoraFMS/Tools.pm: Adapted Ping functions to work with any SO, at
    this time Linux and Windows only, need to check for Solaris and BSD.

    * util/windows.README: Small doc on how to make Pandora Server work on 
    Windows servers.

    * util/pandora_logrotate: Removed the index in the logrotation.



git-svn-id: https://svn.code.sf.net/p/pandora/code/trunk@3431 c3f86ba8-e40f-0410-aaad-9ba5e7f4b01f
This commit is contained in:
slerena 2010-10-20 13:54:43 +00:00
parent 444a03c1b3
commit 7092c0965f
7 changed files with 507 additions and 49 deletions

View File

@ -1,3 +1,23 @@
2010-10-20 Sancho Lerena <slerena@artica.es>
* conf/pandora_server.conf.windows: Sample conf for running pandora server
on Windows (see windows.README).
* lib/PandoraFMS/NetworkServer.pm: Adapted to have SNMPGET and PING functions
redefined by each SO, this will allow to have native support on pandora
to run under different OS (need to check FreeBSD and Solaris!). Windows
support implemented.
* lib/PandoraFMS/Core.pm: Removed ping functions here and moved to Tools.pm
* lib/PandoraFMS/Tools.pm: Adapted Ping functions to work with any SO, at
this time Linux and Windows only, need to check for Solaris and BSD.
* util/windows.README: Small doc on how to make Pandora Server work on
Windows servers.
* util/pandora_logrotate: Removed the index in the logrotation.
2010-10-20 Junichi Satoh <junichi@rworks.jp>
* util/pandora_server: Added support for chkconfig.

View File

@ -0,0 +1,274 @@
#############################################################################
# Pandora FMS Server Parameters
# Pandora FMS, the Flexible Monitoring System.
# Version 3.1
# Licensed under GPL license v2,
# (c) 2003-2010 Artica Soluciones Tecnologicas
# http://www.pandorafms.com
# Please change it for your setup needs
#############################################################################
# Servername: Name of this server
# if not given, it takes hostname. It's prefsnmpgeterable to setup one
# because machine name could change by some reason.
servername poseidon_win32
# incomingdir: Defines directory where incoming data packets are stored
# You could set directory relative to base path or absolute, starting with /
incomingdir c:\pandora_server/data_in
# log_file: Main logfile for pandora_server
# You could set file relative to base path or absolute, starting with /
log_file c:\pandora_server\log\pandora_server.log
# Log file for Pandora FMS SNMP console. Its generated by NetSNMP Trap daemon
snmp_logfile c:\pandora_server\log\pandora_snmptrap.log
# Error logfile: aux logfile for pandora_server errors (in Daemon mode)
# You could set file relative to base path or absolute, starting with /
errorlog_file c:\pandora_server\log\pandora_server.error
# daemon: Runs in daemon mode (background) if 1, if 0 runs in foreground
# this could be also configured on commandline with -D option
# daemon 1
# Database credentials. A VERY important configuration.
# This must be the same credentials used by your Pandora FMS Console
# but could be different if your console is not running in the same
# host than the server. Check your console setup in /include/config.php
# dbname: Database name (pandora by default
dbname pandora
# dbuser: Database user name (pandora by default)
dbuser pandora
# dbpass: Database password
dbpass pandora
# dbhost: Database hostname or IP address
dbhost 192.168.55.1
# verbosity: level of detail on errors/messages (0 default, 1 verbose, 2 debug.... 10 noisy)
# -v in command line (verbose) or -d (debug). Set this to 10 when try to locate problems and
# set to 0 or 1 on production enviroments.
verbosity 5
# Master Server, 1 if master server (normal mode), 0 for slave mode (slave in multi-server setup)
master 1
# Check datafiles using a MD5 hash, 1 to check (default), 0 to ignore .checksum
checksum 0
# Activate Pandora SNMP console (depending on snmptrapd)
# only available on Pandora Network server
snmpconsole 0
# Activate (1) Pandora Network Server
networkserver 1
# Activate (1) Pandora Data Server
dataserver 1
# Activate (1) Pandora FMS Recon server
reconserver 1
# pluginserver : 1 or 0. Set to 1 to activate plugin server with this setup
# DISABLED BY DEFAULT
pluginserver 1
# Pandora FMS Plugin exec tool filepath (by default at /usr/bin)
plugin_exec c:\pandora_server\bin/pandora_exec
# predictionserver : 1 or 0. Set to 1 to activate prediction server with this setup
# DISABLED BY DEFAULT
predictionserver 0
# wmiserver : 1 or 0. Set to 1 to activate WMI server with this setup
# DISABLED BY DEFAULT
wmiserver 0
# Network timeout (in seconds) for timeout in network connections for Network agents
network_timeout 5
# Server keepalive (in seconds)
server_keepalive 45
# Server Threshold: defines number of seconds of main loop (in sec)
server_threshold 5
# Network threads: Do not set too high (~40). Each threads make a network module check.
network_threads 5
# icmp_checks x : defines number of pings for each icmp_proc module type. at least one of
# that ping should be 1 to report 1
icmp_checks 1
# tcp specific options :
# tcp_checks: number of tcp retries if first attempt fails.
# tcp_timeout: specific timeout for tcp connections
tcp_checks 1
tcp_timeout 30
# snmp specific options :
# snmp_checks: number of snmp request retries if first attempt fails.
# snmp_timeout: specific timeout for snmp request.
snmp_checks 1
snmp_timeout 5
# snmp_proc_deadresponse 1 (default): Return DOWN if cannot contact
# or receive NULL from a SNMP PROC module.
snmp_proc_deadresponse 1
# plugin_threads: Specify number of plugin server threads for processing plugin calls
plugin_threads 2
# plugin_timeout: Specify number of seconds calling plugin exec waiting for response
# after this time, call is aborted and result is "unknown".
plugin_timeout 15
# wmi_timeout : specific timeout for wmi request.
wmi_timeout 10
# wmi_threads: Specify number of WMI server threads for processing WMI remote calls
wmi_threads 2
# recon_threads. Each thread will scan a different scantask.
recon_threads 2
# dataserver_threads: Number of threads for data server (XML processing threads)
dataserver_threads 2
# mta_address: External Mailer (MTA) IP Address to be used by Pandora FMS internal email capabilities
#mta_address 192.168.50.1
mta_address localhost
# mta_port: MTA port (default 25)
#mta_port 25
# mta_user MTA User (if needed for auth, FQD or simple user, depending on your server)
#mta_user myuser@mydomain.com
# mta_pass MTA Pass (if needed for auth)
#mta_pass mypassword
# mta_auth MTA Auth system (if needed, support: LOGIN, PLAIN, CRAM-MD5, DIGEST-MD)
#mta_auth LOGIN
# mta_from Email address that sends the mail, by default is pandora@localhost
# probably you need to change it to avoid problems with your antispam
#mta_from pandora@sampledomain.com
# xprobe2: Optional package to detect OS types using advanced TCP/IP
# fingerprinting tecniques, much more accurates than stadard nmap.
# If not provided, nmap is used insted xprobe2
xprobe2 c:\pandora_server\bin\xprobe2
# nmap: If provided, is used to detect OS type with recon server using
# advanded OS fingerprint technique. Xprobe2 gives more accurate results
# Nmap is also used to do TCP port scanning in detected host.
nmap c:\pandora_server\bin\nmap.exe
# snmpget: Needed to do SNMP checks. By default is on /usr/bin/snmpget
snmpget c:\pandora_server\bin\snmpget.exe
# Default group id for new agents created with Pandora FMS Data Server
autocreate_group 2
# Set to 1 if want to autocreate agents with Pandora FMS Data Server,
# set to 0 to disable
autocreate 1
# max_log_size: Specify max size of Pandora FMS server log file (1MB by default). If
# log file grows above this limit, is renamed to "pandora_server.log.old".
max_log_size 65536
# max_queue_files (250 by default)
# When server have more than max_queue_files in incoming directory, skips the read
# the directory to avoid filesystem overhead.
max_queue_files 250
# Use the XML file last modification time as timestamp.
# use_xml_timestamp 1
# Pandora FMS will autorestart itself each XXX seconds, use this if you experience problems with
# shutting down threads, or other stability problems.
# auto_restart 86400
# Pandora FMS will restart after restart_delay seconds on critical errors.
# restart 0
# restart_delay 60
# More information about GIS Setup in /usr/share/pandora_server/util/gis.README
# Flag to activate GIS (positional information for agents and maps)
# by default it is desactivated
#activate_gis 0
# Radius of error in meters to consider two gis locations as the same location.
#location_error 50
# Recon reverse geolocation mode [disabled, sql, file]
# disabled The recon task doesn't try to geolocate the ip discovered.
# sql The recon task trys to query the SQL database to geolocate the
# ip discovered
# file The recon task trys to find the geolocation information of the
# ip discovered in the file indicated in the
# recon_reverse_geolocation_file parameter
# recon_reverse_geolocation_mode disabled
# Recon reverse geolocation file. This is the database with the reverse
# geolocation information using MaxMind GPL GeoLiteCity.dat format).
#recon_reverse_geolocation_file /usr/local/share/GeoIP/GeoIPCity.dat
# Radius (in meters) of the circle in where the agents will be place randomly
# when finded by a recon task. Center of the circle is guessed
# by geolocating the IP.
#recon_location_scatter_radius 1000
# Pandora Server self-monitoring (embedded agent) (by default disabled)
#self_monitoring 1
# Update parent from the agent xml
#update_parent 1

View File

@ -68,10 +68,6 @@ Exported Functions:
=item * C<pandora_module_keep_alive_nd>
=item * C<pandora_ping>
=item * C<pandora_ping_latency>
=item * C<pandora_planned_downtime>
=item * C<pandora_process_alert>
@ -146,8 +142,6 @@ our @EXPORT = qw(
pandora_module_keep_alive
pandora_module_keep_alive_nd
pandora_module_unknown
pandora_ping
pandora_ping_latency
pandora_planned_downtime
pandora_process_alert
pandora_process_module
@ -1377,46 +1371,6 @@ sub pandora_evaluate_snmp_alerts ($$$$$$$$$) {
}
}
##############################################################################
=head2 C<< pandora_ping (I<$pa_config>, I<$host>) >>
Ping the given host.
Returns:
1 if the host is alive
0 otherwise.
=cut
##############################################################################
sub pandora_ping ($$) {
my ($pa_config, $host) = @_;
# Ping the host
`ping -q -W $pa_config->{'networktimeout'} -n -c $pa_config->{'icmp_checks'} $host >/dev/null 2>&1`;
return ($? == 0) ? 1 : 0;
}
##############################################################################
=head2 C<< pandora_ping_latency (I<$pa_config>, I<$host>) >>
Ping the given host. Returns the average round-trip time.
=cut
##############################################################################
sub pandora_ping_latency ($$) {
my ($pa_config, $host) = @_;
# Ping the host
my @output = `ping -q -W $pa_config->{'networktimeout'} -n -c $pa_config->{'icmp_checks'} $host 2>/dev/null`;
# Something went wrong
return 0 if ($? != 0);
# Parse the output
my $stats = pop (@output);
return 0 unless ($stats =~ m/([\d\.]+)\/([\d\.]+)\/([\d\.]+)\/([\d\.]+) +ms/);
return $2;
}
##########################################################################
# Utility functions, not to be exported.

View File

@ -25,6 +25,7 @@ use threads::shared;
use Thread::Semaphore;
use IO::Socket::INET;
use HTML::Entities;
use POSIX qw(strftime);
# Default lib dir for RPM and DEB packages
@ -150,6 +151,9 @@ sub pandora_query_tcp ($$$$$$$$) {
my $tcp_rcv = $_[6];
my $id_tipo_modulo = $_[7];
$tcp_send = decode_entities($tcp_send);
$tcp_rcv = decode_entities($tcp_rcv);
my $counter;
for ($counter =0; $counter < $pa_config->{'tcp_checks'}; $counter++){
my $temp; my $temp2;
@ -242,6 +246,52 @@ next_pair:
}
}
###############################################################################
# Set commands for SNMP checks depending on OS type
###############################################################################
sub pandora_snmp_get_command ($$$$$$$$$) {
my ($snmpget_cmd, $snmp_version, $snmp_retries, $snmp_timeout, $snmp_community, $snmp_target, $snmp_oid, $snmp3_security_level, $snmp3_extra) = @_;
my $output = "";
# See codes on http://perldoc.perl.org/perlport.html#PLATFORMS
my $OSNAME = $^O;
# On windows, we need the snmpget command from net-snmp, already present on win agent
# the call is the same than in linux
if (($OSNAME eq "MSWin32") || ($OSNAME eq "MSWin32-x64") || ($OSNAME eq "cygwin")){
if ($snmp_version ne "3"){
$output = `$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -c $snmp_community $snmp_target $snmp_oid 2> NUL`;
} else {
$output = `$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -l $snmp3_security_level $snmp3_extra $snmp_target $snmp_oid 2> NUL`;
}
}
# Need to implement
elsif ($OSNAME eq "solaris"){
$output = "";
}
# Need to implement
elsif ($OSNAME eq "freebsd"){
$output = "";
}
# by default LINUX calls
else {
if ($snmp_version ne "3"){
$output = `$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -c '$snmp_community' $snmp_target $snmp_oid 2>/dev/null`;
} else {
$output = `$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -l $snmp3_security_level $snmp3_extra $snmp_target $snmp_oid 2>/dev/null`;
}
}
return $output;
}
##########################################################################
# SUB pandora_query_snmp (pa_config, module)
# Makes a call to SNMP modules to get a value,
@ -280,7 +330,8 @@ sub pandora_query_snmp ($$) {
# SNMP v1, v2 and v2c call
if ($snmp_version ne '3'){
$output = `$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -c '$snmp_community' $snmp_target $snmp_oid 2>/dev/null`;
$output = pandora_snmp_get_command ($snmpget_cmd, $snmp_version, $snmp_retries, $snmp_timeout, $snmp_community, $snmp_target, $snmp_oid, "", "");
if ($output ne ""){
$module_result = 0;
$module_data = $output;
@ -301,8 +352,8 @@ sub pandora_query_snmp ($$) {
if ($snmp3_security_level eq "authPriv"){
$snmp3_extra = " -a $snmp3_auth_method -u $snmp3_auth_user -A $snmp3_auth_pass -x $snmp3_privacy_method -X $snmp3_privacy_pass ";
}
$snmp3_execution = "$snmpget_cmd -v $snmp_version -r $snmp_retries -t $snmp_timeout -OUevqt -l $snmp3_security_level $snmp3_extra $snmp_target $snmp_oid 2>/dev/null";
$snmp3_execution = pandora_snmp_get_command ($snmpget_cmd, $snmp_version, $snmp_retries, $snmp_timeout, $snmp_community, $snmp_target, $snmp_oid, $snmp3_security_level, $snmp3_extra);
$output = `$snmp3_execution`;
if ($output ne ""){

View File

@ -53,6 +53,8 @@ our @EXPORT = qw(
free_mem
md5
md5_init
pandora_ping
pandora_ping_latency
);
##########################################################################
@ -549,6 +551,135 @@ sub free_mem {
return $free_mem;
}
##############################################################################
=head2 C<< pandora_ping (I<$pa_config>, I<$host>) >>
Ping the given host.
Returns:
1 if the host is alive
0 otherwise.
=cut
##############################################################################
sub pandora_ping ($$) {
my ($pa_config, $host) = @_;
my $output = 0;
# See codes on http://perldoc.perl.org/perlport.html#PLATFORMS
my $OSNAME = $^O;
# Windows XP .. Windows 7
if (($OSNAME eq "MSWin32") || ($OSNAME eq "MSWin32-x64") || ($OSNAME eq "cygwin")){
my $ms_timeout = $pa_config->{'networktimeout'} * 1000;
$output = `ping -n $pa_config->{'icmp_checks'} -w $ms_timeout $host`;
if ($output =~ /TTL/){
return 1;
} else {
return 0;
}
}
# Need to implement
elsif ($OSNAME eq "solaris"){
$output = "";
}
# Need to implement
elsif ($OSNAME eq "freebsd"){
$output = "";
}
# by default LINUX calls
else {
my $ping_command = "ping";
if ($host =~ /\d+:|:\d+/ ) {
$ping_command = "ping6";
}
# Ping the host
`$ping_command -q -W $pa_config->{'networktimeout'} -n -c $pa_config->{'icmp_checks'} $host >/dev/null 2>&1`;
return ($? == 0) ? 1 : 0;
}
return $output;
}
##############################################################################
=head2 C<< pandora_ping_latency (I<$pa_config>, I<$host>) >>
Ping the given host. Returns the average round-trip time.
=cut
##############################################################################
sub pandora_ping_latency ($$) {
my ($pa_config, $host) = @_;
my $output = 0;
# See codes on http://perldoc.perl.org/perlport.html#PLATFORMS
my $OSNAME = $^O;
# Windows XP .. Windows 2008, I assume Win7 is the same
if (($OSNAME eq "MSWin32") || ($OSNAME eq "MSWin32-x64") || ($OSNAME eq "cygwin")){
# System ping reports in different languages, but with the same format:
# Mínimo = xxms, Máximo = xxms, Media = XXms
# Minimun = xxms, Mamimun = xxms, Average = XXms
# If this fails, ping can be replaced by fping which also have the same format
# but always in english
my $ms_timeout = $pa_config->{'networktimeout'} * 1000;
$output = `ping -n $pa_config->{'icmp_checks'} -w $ms_timeout $host`;
if ($output =~ m/\=\s([0-9]*)[a-z][a-z]\r/){
return $1;
} else {
return 0;
}
}
# Need to implement
elsif ($OSNAME eq "solaris"){
$output = "";
}
# Need to implement
elsif ($OSNAME eq "freebsd"){
$output = "";
}
# by default LINUX calls
else {
my $ping_command = "ping";
if ($host =~ /\d+:|:\d+/ ) {
$ping_command = "ping6";
}
# Ping the host
my @output = `$ping_command -q -W $pa_config->{'networktimeout'} -n -c $pa_config->{'icmp_checks'} $host 2>/dev/null`;
# Something went wrong
return 0 if ($? != 0);
# Parse the output
my $stats = pop (@output);
return 0 unless ($stats =~ m/([\d\.]+)\/([\d\.]+)\/([\d\.]+)\/([\d\.]+) +ms/);
return $2;
}
# If no valid get values until now, just return with empty value (not valid)
return $output;
}
# End of function declaration
# End of defined Code

View File

@ -38,6 +38,7 @@
notifempty
create 664 root root
postrotate
rm /var/log/pandora/pandora_snmptrap.log.index 2> /dev/null
/etc/init.d/pandora_server restart
endscript

View File

@ -0,0 +1,27 @@
Pandora FMS on Windows servers
==============================
This is not recommended for production systems (due lack of depth testing and performance penalty) but it's possible to have Pandora FMS server working on Windows servers (XP, 2000, 2003, Vista, 2008 and Windows 7).
You need to have the ActiveState Perl installed in your system and some Perl modules installed (ActiveState Perl has a nice installer).
You will need to create the paths you will need by hand, there aren't an automated installer for Windows (yet):
c:\pandora_server - Will contain everything, put contents of pandora server tarball there.
c:\pandora_server\conf - Will contain the configuration file, you have a windows sample file in conf\pandora_server.conf.windows as sample
c:\pandora_server\data_in - put search there for all incoming data files.
c:\pandora_server\bin - Will search there for tentacle_server, nmap, and snmpget tool. You will use the snmpget tool from the pandora windows agent (\util\snmpget.exe).
To start tentacle
-----------------
C:\pandora_server\bin>perl tentacle_server -p 41121 -a 0.0.0.0 -s c:\pandora_server\data_in -i.*\.conf:conf;.*\.md5:md5;.*\.zip:collections
To start pandora server
-----------------------
C:\pandora_server\bin>perl pandora_server c:\windows_server\conf\pandora_server.conf