j2l
08-07-2007, 12:24 PM
J'ai développé un petit plugin permettant de grapher la température d'un balde center IBM (températeur ambiante ou interieure) voici le code (je me suis énormément inspiré de plugin existants)
#!/usr/bin/perl
sub print_usage {
print "check_blade_temp.pl IP COMMUNITY warning critical mm|ambiant\n";
}
$PROGNAME = "check_blade_temp.pl";
if ( @ARGV[0] eq "" || @ARGV[1] eq "" || @ARGV[2] eq "" || @ARGV[4] eq "") {
print_usage();
exit 0;
}
$STATE_CRITICAL = 2;
$STATE_WARNING = 1;
$STATE_UNKNONW = 3;
$STATE_OK = 0;
$IP=@ARGV[0];
$COMMUNITY=@ARGV[1];
$warning=@ARGV[2];
$critical=@ARGV[3];
$tempType=@ARGV[4];
$mibAmbiant = ".1.3.6.1.4.1.2.3.51.2.2.1.5.1.0";
$mibMM = ".1.3.6.1.4.1.2.3.51.2.2.1.1.2.0";
if ($tempType eq "mm"){
$resultat = `snmpwalk -v 1 -c $COMMUNITY $IP $mibMM`;
}
else{
$resultat = `snmpwalk -v 1 -c $COMMUNITY $IP $mibAmbiant`;
}
if ( $resultat ) {
@temperature = split(/ /,$resultat);
@temperature2 = split(/\"/,$temperature[3]);
$temp = $temperature2[1];
if ( $temp < $warning ) {
print "OK : Temperature $temp|Default_DS3=".$temp." ".";".$warning.";".$critical;
###################
exit $STATE_OK;
}
elsif ( $temp < $critical ) {
print "WARNING : Temperature $temp|Default_DS3=".$temp." ".";".$warning.";".$critical;
exit $STATE_WARNING;
}
else {
print "CRITICAL : Temperature :$temp|Default_DS3=".$temp." ".";".$warning.";".$critical;
exit $STATE_CRITICAL;
}
}
else {
print "Unkonwn : No response\n";
exit $STATE_UNKNONW;
}
Au passage une petite question j'ai créé un graph template qui prend la valeur de Default_DS3 mais est-il possible de créer un metric temperature par exemple ? si oui par quel moyen ?
#!/usr/bin/perl
sub print_usage {
print "check_blade_temp.pl IP COMMUNITY warning critical mm|ambiant\n";
}
$PROGNAME = "check_blade_temp.pl";
if ( @ARGV[0] eq "" || @ARGV[1] eq "" || @ARGV[2] eq "" || @ARGV[4] eq "") {
print_usage();
exit 0;
}
$STATE_CRITICAL = 2;
$STATE_WARNING = 1;
$STATE_UNKNONW = 3;
$STATE_OK = 0;
$IP=@ARGV[0];
$COMMUNITY=@ARGV[1];
$warning=@ARGV[2];
$critical=@ARGV[3];
$tempType=@ARGV[4];
$mibAmbiant = ".1.3.6.1.4.1.2.3.51.2.2.1.5.1.0";
$mibMM = ".1.3.6.1.4.1.2.3.51.2.2.1.1.2.0";
if ($tempType eq "mm"){
$resultat = `snmpwalk -v 1 -c $COMMUNITY $IP $mibMM`;
}
else{
$resultat = `snmpwalk -v 1 -c $COMMUNITY $IP $mibAmbiant`;
}
if ( $resultat ) {
@temperature = split(/ /,$resultat);
@temperature2 = split(/\"/,$temperature[3]);
$temp = $temperature2[1];
if ( $temp < $warning ) {
print "OK : Temperature $temp|Default_DS3=".$temp." ".";".$warning.";".$critical;
###################
exit $STATE_OK;
}
elsif ( $temp < $critical ) {
print "WARNING : Temperature $temp|Default_DS3=".$temp." ".";".$warning.";".$critical;
exit $STATE_WARNING;
}
else {
print "CRITICAL : Temperature :$temp|Default_DS3=".$temp." ".";".$warning.";".$critical;
exit $STATE_CRITICAL;
}
}
else {
print "Unkonwn : No response\n";
exit $STATE_UNKNONW;
}
Au passage une petite question j'ai créé un graph template qui prend la valeur de Default_DS3 mais est-il possible de créer un metric temperature par exemple ? si oui par quel moyen ?