change oreon->centreon

git-svn-id: http://svn.centreon.com/Plugins/Dev@3064 6bcd3966-0018-0410-8128-fd23d134de7e
This commit is contained in:
Julien Mathis 2007-09-05 08:06:38 +00:00
parent fc387b1b99
commit 1c3ac3be89
9 changed files with 34 additions and 299 deletions

View File

@ -31,10 +31,10 @@ use lib "@NAGIOS_PLUGINS@";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
if (eval "require oreon" ) {
use oreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
use vars qw($VERSION %oreon);
%oreon=get_parameters();
if (eval "require centreon" ) {
use centreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
use vars qw($VERSION %centreon);
%centreon = get_parameters();
} else {
print "Unable to load oreon perl module\n";
exit $ERRORS{'UNKNOWN'};

View File

@ -31,17 +31,17 @@ use lib "$FindBin::Bin";
use lib "@NAGIOS_PLUGINS@";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
if (eval "require oreon" ) {
use oreon qw(get_parameters);
use vars qw($VERSION %oreon);
%oreon=get_parameters();
if (eval "require centreon" ) {
use centreon qw(get_parameters);
use vars qw($VERSION %centreon);
%centreon = get_parameters();
} else {
print "Unable to load oreon perl module\n";
exit $ERRORS{'UNKNOWN'};
}
use vars qw($VERSION %oreon);
use vars qw(%oreon);
use vars qw($VERSION %centreon);
use vars qw(%centreon);
$VERSION = '$Revision: 1.2 $';
$VERSION =~ s/^\$.*:\W(.*)\W.+?$/$1/;

View File

@ -30,12 +30,12 @@ use lib "$FindBin::Bin";
use lib "@NAGIOS_PLUGINS@";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
if (eval "require oreon" ) {
use oreon qw(get_parameters);
use vars qw($VERSION %oreon);
%oreon=get_parameters();
if (eval "require centreon" ) {
use centreon qw(get_parameters);
use vars qw($VERSION %centreon);
%centreon = get_parameters();
} else {
print "Unable to load oreon perl module\n";
print "Unable to load centreon perl module\n";
exit $ERRORS{'UNKNOWN'};
}

View File

@ -30,14 +30,16 @@ use FindBin;
use lib "$FindBin::Bin";
use lib "@NAGIOS_PLUGINS@";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
if (eval "require oreon" ) {
use oreon qw(get_parameters);
use vars qw($VERSION %oreon);
%oreon = get_parameters();
if (eval "require centreon" ) {
use centreon qw(get_parameters);
use vars qw($VERSION %centreon);
%centreon = get_parameters();
} else {
print "Unable to load oreon perl module\n";
exit $ERRORS{'UNKNOWN'};
}
use vars qw($PROGNAME);
use Getopt::Long;
use vars qw($opt_V $opt_h $opt_v $opt_C $opt_H $opt_c $opt_w $opt_D $snmp $opt_k $opt_u $opt_p @critical @warning);

View File

@ -30,10 +30,10 @@ use FindBin;
use lib "$FindBin::Bin";
use lib "@NAGIOS_PLUGINS@";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
if (eval "require oreon" ) {
use oreon qw(get_parameters);
use vars qw($VERSION %oreon);
%oreon=get_parameters();
if (eval "require centreon" ) {
use centreon qw(get_parameters);
use vars qw($VERSION %centreon);
%centreon = get_parameters();
} else {
print "Unable to load oreon perl module\n";
exit $ERRORS{'UNKNOWN'};

View File

@ -32,15 +32,15 @@ use Getopt::Long;
# Nagios specific
use lib "/srv/nagios/libexec";
use lib "@NAGIOS_PLUGIN@";
use utils qw(%ERRORS $TIMEOUT);
# Oreon specific
# centreon specific
if (eval "require oreon" ) {
if (eval "require centreon" ) {
use oreon qw(get_parameters create_rrd update_rrd &is_valid_serviceid);
use vars qw($VERSION %oreon);
%oreon=get_parameters();
use vars qw($VERSION %centreon);
%centreon = get_parameters();
} else {
print "Unable to load oreon perl module\n";
exit $ERRORS{'UNKNOWN'};

View File

@ -30,10 +30,11 @@ use FindBin;
use lib "$FindBin::Bin";
use lib "@NAGIOS_PLUGINS@";
use utils qw($TIMEOUT %ERRORS &print_revision &support);
if (eval "require oreon" ) {
if (eval "require centreon" ) {
use oreon qw(get_parameters);
use vars qw(%oreon);
%oreon=get_parameters();
use vars qw(%centreon);
%centreon = get_parameters();
} else {
print "Unable to load oreon perl module\n";
exit $ERRORS{'UNKNOWN'};

View File

@ -1,50 +0,0 @@
[GLOBAL]
DIR_OREON=@INSTALL_DIR_OREON@/
DIR_TRAFFICMAP=@INSTALL_DIR_OREON@/include/trafficMap/average/
DIR_NAGIOS=@INSTALL_DIR_NAGIOS@/
DIR_RRDTOOL=@INSTALL_DIR_OREON@/rrd/
NAGIOS_LIBEXEC=@NAGIOS_PLUGINS@/
NAGIOS_ETC=@NAGIOS_ETC@/
[NT]
CPU=.1.3.6.1.2.1.25.3.3.1.2
HD_USED=.1.3.6.1.2.1.25.2.3.1.6
HD_NAME=.1.3.6.1.2.1.25.2.3.1.3
[CISCO]
NB_CONNECT=.1.3.6.1.4.1.9.9.147.1.2.2.2.1.5.40.6
[UNIX]
CPU_USER=.1.3.6.1.4.1.2021.11.50.0
CPU_SYSTEM=.1.3.6.1.4.1.2021.11.52.0
CPU_LOAD_1M =.1.3.6.1.4.1.2021.10.1.3.1
CPU_LOAD_5M =.1.3.6.1.4.1.2021.10.1.3.2
CPU_LOAD_15M =.1.3.6.1.4.1.2021.10.1.3.3
[DELL]
TEMP=.1.3.6.1.4.1.674.10892.1.700.20.1.6.1
[ALTEON]
VIRT=1.3.6.1.4.1.1872.2.1.8.2.7.1.3.1
FRONT=1.3.6.1.4.1.1872.2.1.8.2.5.1.3.1
[MIB2]
SW_RUNNAME=.1.3.6.1.2.1.25.4.2.1.2
SW_RUNINDEX=.1.3.6.1.2.1.25.4.2.1.1
SW_RUNSTATUS=.1.3.6.1.2.1.25.4.2.1.7
HR_STORAGE_DESCR=.1.3.6.1.2.1.25.2.3.1.3
HR_STORAGE_ALLOCATION_UNITS=.1.3.6.1.2.1.25.2.3.1.4
HR_STORAGE_SIZE=.1.3.6.1.2.1.25.2.3.1.5
HR_STORAGE_USED=.1.3.6.1.2.1.25.2.3.1.6
OBJECTID=.1.3.6.1.2.1.1.1.0
UPTIME_WINDOWS=.1.3.6.1.2.1.1.3.0
UPTIME_OTHER=.1.3.6.1.2.1.25.1.1.0
IF_IN_OCTET=.1.3.6.1.2.1.2.2.1.10
IF_OUT_OCTET=.1.3.6.1.2.1.2.2.1.16
IF_SPEED=.1.3.6.1.2.1.2.2.1.5
IF_DESC=.1.3.6.1.2.1.2.2.1.2
IF_IN_ERROR=.1.3.6.1.2.1.2.2.1.14
IF_OUT_ERROR=.1.3.6.1.2.1.2.2.1.20
IF_OPERSTATUS=.1.3.6.1.2.1.2.2.1.8

View File

@ -1,218 +0,0 @@
#
# $Id: check_graph_ping.pl,v 1.2 2005/07/27 22:21:49 wistof Exp $
#
# Oreon's plugins are developped with GPL Licence :
# http://www.fsf.org/licenses/gpl.txt
# Developped by : Mathieu Chateau - Christophe Coraboeuf
#
# The Software is provided to you AS IS and WITH ALL FAULTS.
# OREON makes no representation and gives no warranty whatsoever,
# whether express or implied, and without limitation, with regard to the quality,
# safety, contents, performance, merchantability, non-infringement or suitability for
# any particular or intended purpose of the Software found on the OREON web site.
# In no event will OREON be liable for any direct, indirect, punitive, special,
# incidental or consequential damages however they may arise and even if OREON has
# been previously advised of the possibility of such damages.
package oreon;
use Exporter ();
use FindBin qw($Bin);
use lib "$FindBin::Bin";
use lib "@NAGIOS_PLUGINS@";
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
use utils qw($TIMEOUT %ERRORS &print_revision &support);
if (eval "require Config::IniFiles" ) {
use Config::IniFiles;
} else {
print "Unable to load Config::IniFiles\n";
exit $ERRORS{'UNKNOWN'};
}
### RRDTOOL Module
use lib qw(@RRDTOOL_PERL_LIB@ ../lib/perl);
if (eval "require RRDs" ) {
use RRDs;
} else {
print "Unable to load RRDs perl module\n";
exit $ERRORS{'UNKNOWN'};
}
# On défini une version pour les vérifications
#$VERSION = do { my @r = (q$Revision: XXX $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
our @ISA = qw(Exporter);
our @EXPORT_OK = qw(get_parameters create_rrd update_rrd fetch_rrd &is_valid_serviceid);
our @EXPORT = @EXPORT_OK;
my $params_file="oreon.conf";
my @ds = ("a","b","c","d","e","f","g","h","i","j","k","l");
###############################################################################
# Get all parameters from the ini file
###############################################################################
sub get_parameters
{
$params_file = "@NAGIOS_PLUGINS@/$params_file";
unless (-e $params_file)
{
print "Unknown - In oreon.pm :: $params_file :: $!\n";
exit $ERRORS{'UNKNOWN'};
}
my %oreon;
tie %oreon, 'Config::IniFiles', ( -file => $params_file );
return %oreon;
}
###############################################################################
# Create RRD file
###############################################################################
sub create_rrd($$$$$$$)
{
my @rrd_arg;
my ($rrd, $nb_ds ,$start, $step, $min, $max, $type) = @_;
$nb_ds = 1 unless($nb_ds);
$start = time unless($start);
$step = 300 unless($step);
$min = "U" unless($min);
$max = "U" unless($max);
$type = "GAUGE" unless($type);
my $ERROR = RRDs::error;
@rrd_arg=($rrd,
"--start",
$start-1,
"--step",
$step);
for ($i = 0; $i < $nb_ds; $i++) {
push(@rrd_arg,"DS:".$ds[$i].":$type:".($step * 2).":".$min.":".$max);
}
push(@rrd_arg,"RRA:AVERAGE:0.5:1:8640",
"RRA:MIN:0.5:12:8640",
"RRA:MAX:0.5:12:8640");
RRDs::create (@rrd_arg);
$ERROR = RRDs::error;
if ($ERROR) {
print "unable to create '$rrd' : $ERROR\n" ;
exit 3;
}
}
###############################################################################
# Update RRD file
###############################################################################
sub update_rrd($$@)
{
my @rrd_arg;
my ($rrd, $start,@values) = @_;
$start = time unless($start);
my $ERROR = RRDs::error;
for (@values) {
s/,/\./ ;
$str_value .= ":" . $_;
}
RRDs::update ($rrd, "$start$str_value");
$ERROR = RRDs::error;
if ($ERROR) {
print "unable to update '$rrd' : $ERROR\n" ;
exit 3;
}
}
###############################################################################
# Fetch RRD file
###############################################################################
sub fetch_rrd($$)
{
my ($line, $val, @valeurs, $update_time, $step, $ds_names, $data, $i) ;
my ($rrd, $CF,@values) = @_;
$start = time unless($start);
my $ERROR = RRDs::error;
($update_time,$step,$ds_names,$data) = RRDs::fetch($rrd, "--resolution=300","--start=now-5min","--end=now",$CF);
$ERROR = RRDs::error;
if ($ERROR) {
print "unable to update '$rrd' : $ERROR\n" ;
exit 3;
}
foreach $line (@$data) {
foreach $val (@$line) {
if ( defined $val ) { $valeur[$i]=$val; } else { $valeur[$i]="undef"; }
$i++;
}
}
return @valeur;
}
###############################################################################
# Is a valid ServiceId
###############################################################################
sub is_valid_serviceid {
my $ServiceId = shift;
if ($ServiceId && $ServiceId =~ m/^([0-9_]+)$/) {
return $ServiceId;
}else{
print "Unknown -S Service ID expected... or it doesn't exist, try another id - number\n";
exit $ERRORS{'UNKNOWN'};
}
}
1;
__END__
=head1 NAME
Oreon - shared module for Oreon plugins
=head1 SYNOPSIS
use oreon;
oreon::get_parameters()
oreon::create_rrd( )
oreon::update_rrd( )
=head1 DESCRIPTION
=head2 Functions
B<oreon::create_rrd> create a rrd database.
create_rrd($rrd, $nb_ds ,$start, $step, $min, $max, $type );
$rrd : RRD filename
$nb_ds : Number of Data Sources to create
$start : Start time of RRD
$step : RRD step
$min : Minimum value in RRD
$max : Maximum value in RRD
$type : GAUGE or COUNTER
update_rrd($rrd, $start,@values);
$rrd : RRD filename to update
$start :
@values : update RRD with list values
=head1 AUTHOR
Mathieu Chateau E<lt>mathieu.chateau@lsafrance.comE<gt>
Christophe Coraboeuf E<lt>ccoraboeuf@oreon-project.orgE<gt>
=cut