init III
This commit is contained in:
BIN
Windows Procurve STP Status via Perl/clemail.exe
Normal file
BIN
Windows Procurve STP Status via Perl/clemail.exe
Normal file
Binary file not shown.
BIN
Windows Procurve STP Status via Perl/libsnmp.dll
Normal file
BIN
Windows Procurve STP Status via Perl/libsnmp.dll
Normal file
Binary file not shown.
4
Windows Procurve STP Status via Perl/output.txt
Normal file
4
Windows Procurve STP Status via Perl/output.txt
Normal file
@@ -0,0 +1,4 @@
|
||||
Switch Port Erwartet Ausgelesen
|
||||
------------------------------------------------
|
||||
170.60.2.11 Trk13 blocking forwarding
|
||||
170.60.2.12 Trk13 forwarding blocking
|
||||
BIN
Windows Procurve STP Status via Perl/snmptrap.exe
Normal file
BIN
Windows Procurve STP Status via Perl/snmptrap.exe
Normal file
Binary file not shown.
BIN
Windows Procurve STP Status via Perl/snmpwalk.exe
Normal file
BIN
Windows Procurve STP Status via Perl/snmpwalk.exe
Normal file
Binary file not shown.
38
Windows Procurve STP Status via Perl/stp_state.conf
Normal file
38
Windows Procurve STP Status via Perl/stp_state.conf
Normal file
@@ -0,0 +1,38 @@
|
||||
# snmpget auf
|
||||
# .1.3.6.1.2.1.17.2.15.1.3.ifIndex
|
||||
# ergibt stp status
|
||||
# 1 : disabled
|
||||
# 2 : blocking
|
||||
# 3 : listening
|
||||
# 4 : learning
|
||||
# 5 : forwarding
|
||||
# 6 : broken
|
||||
|
||||
|
||||
# zu Überwachende Ports und deren gewünschter STP Status
|
||||
# Angabe des STP Status als 1_ 2_ 3_ usw. wobei die Ziffern den Status wie oben beschreiben
|
||||
# 1_ bedeutet demnach disabled 2_blocking usw 5_ forwarding
|
||||
|
||||
@{$switches{'10.10.11.26'}} = qw /5_Mesh/;
|
||||
@{$switches{'10.10.11.4'}} = qw /5_Mesh 5_Trk1 5_Trk3 5_Trk4 5_Trk5 5_Trk6 5_Trk7 5_Trk8 5_Trk12/;
|
||||
@{$switches{'10.10.11.22'}} = qw /5_Mesh 5_Trk2 5_Trk33 5_H16/;
|
||||
@{$switches{'10.10.11.32'}} = qw /5_Mesh 5_Trk2 5_Trk6 5_Trk7 5_Trk8 5_Trk13/;
|
||||
@{$switches{'10.10.11.24'}} = qw /5_Mesh/;
|
||||
@{$switches{'10.10.11.28'}} = qw /5_Mesh/;
|
||||
@{$switches{'10.10.11.41'}} = qw /5_Mesh 5_Trk1 5_Trk2 5_Trk3 5_Trk6 5_Trk7 5_Trk9 5_Trk12 5_Trk13/;
|
||||
@{$switches{'10.10.11.42'}} = qw /5_Mesh 5_Trk1 5_Trk3 5_Trk4 5_Trk5 5_Trk6 5_Trk8 5_Trk9 5_Trk10 2_Trk11 5_Trk22 5_Trk23 5_Trk24 5_Trk25 5_Trk26 5_Trk28/;
|
||||
@{$switches{'10.10.11.45'}} = qw /5_Mesh/;
|
||||
@{$switches{'10.10.11.46'}} = qw /5_Mesh/;
|
||||
|
||||
@{$switches{'10.10.11.11'}} = qw /5_Mesh 5_Trk1 5_Trk33/;
|
||||
@{$switches{'10.10.11.12'}} = qw /5_Mesh 1_Trk33/;
|
||||
@{$switches{'10.10.11.14'}} = qw /5_Mesh 5_Trk1 5_Trk2/;
|
||||
@{$switches{'10.10.11.29'}} = qw /5_Mesh/;
|
||||
####@{$switches{'10.10.11.19'}} = qw /5_Mesh 5_Trk1/;
|
||||
|
||||
####@{$switches{'10.10.11.30'}} = qw /5_Trk2/;
|
||||
####@{$switches{'10.10.11.31'}} = qw /5_Trk1/;
|
||||
####@{$switches{'10.10.11.39'}} = qw /5_24 5_Trk1 5_Trk2/;
|
||||
|
||||
@{$switches{'170.60.2.11'}} = qw /5_Mesh 2_Trk13/;
|
||||
@{$switches{'170.60.2.12'}} = qw /5_Mesh 5_Trk13/;
|
||||
BIN
Windows Procurve STP Status via Perl/stp_state.exe
Normal file
BIN
Windows Procurve STP Status via Perl/stp_state.exe
Normal file
Binary file not shown.
32
Windows Procurve STP Status via Perl/stp_state.perlsvc
Normal file
32
Windows Procurve STP Status via Perl/stp_state.perlsvc
Normal file
@@ -0,0 +1,32 @@
|
||||
#!C:\Program Files\ActiveState Perl Dev Kit 8.2.1\bin\perlsvc-gui.exe
|
||||
PAP-Version: 1.0
|
||||
Packer: C:\Program Files\ActiveState Perl Dev Kit 8.2.1\bin\perlsvc.exe
|
||||
Script: stp_state.pl
|
||||
Cwd: G:\My Documents\Diverse Skripts\STP Status
|
||||
Clean: 1
|
||||
Date: 2010-08-27 10:12:56
|
||||
Debug:
|
||||
Dependent: 0
|
||||
Dyndll: 0
|
||||
Exe: stp_state.exe
|
||||
Force: 1
|
||||
Hostname: LAZAREUS
|
||||
Manifest:
|
||||
No-Compress: 0
|
||||
No-Logo: 0
|
||||
Runlib:
|
||||
Shared: none
|
||||
Tmpdir:
|
||||
Verbose: 0
|
||||
Version-Comments:
|
||||
Version-CompanyName:
|
||||
Version-FileDescription:
|
||||
Version-FileVersion: 1.0.1
|
||||
Version-InternalName: STP Status Checker
|
||||
Version-LegalCopyright: Andre Wisniewski
|
||||
Version-LegalTrademarks:
|
||||
Version-OriginalFilename: STP Status Checker
|
||||
Version-ProductName: STP Status Checker
|
||||
Version-ProductVersion: 1.0.1
|
||||
Warnings: 0
|
||||
Xclude: 0
|
||||
92
Windows Procurve STP Status via Perl/stp_state.pl
Normal file
92
Windows Procurve STP Status via Perl/stp_state.pl
Normal file
@@ -0,0 +1,92 @@
|
||||
#!/bin/perl
|
||||
package PerlSvc;
|
||||
our %Config;
|
||||
|
||||
$PerlSvc::Name = "STP Status Checker";
|
||||
$PerlSvc::DisplayName = "STP Status Checker";
|
||||
|
||||
my @AlarmText;
|
||||
|
||||
sub MainLoop {
|
||||
my %switches;
|
||||
my @StpStatusTrans = qw / undef disabled blocking listening learning forwarding broken/;
|
||||
my $AlarmFlag;
|
||||
|
||||
@AlarmText=();
|
||||
my $Header = sprintf " %-15s %-6s %-12s %-12s\n ------------------------------------------------\n", "Switch", "Port", "Erwartet", "Ausgelesen";
|
||||
push @AlarmText, $Header;
|
||||
|
||||
open CONF, "<c:\\stp_state.conf";
|
||||
my @config=<CONF>;
|
||||
close CONF;
|
||||
|
||||
eval "@config";
|
||||
|
||||
my %IfIndex;
|
||||
my %StpStatus;
|
||||
|
||||
# Jede Switch durchlaufen
|
||||
foreach my $switch (keys %switches) {
|
||||
# debug ausgabe
|
||||
#print "\n$switch\n";
|
||||
|
||||
# Port Namen lesen um auf IfIndex zurückzuschließen
|
||||
my @IfIndexArray = `snmpwalk -mall -c public $switch .1.3.6.1.2.1.2.2.1.2`;
|
||||
|
||||
# STP Status lesen um zum IfIndex den STP Status zuzuordnen
|
||||
my @IfStpStatusArray = `snmpwalk -mall -c public $switch .1.3.6.1.2.1.17.2.15.1.3`;
|
||||
|
||||
# Jeden Port dieser Switch durchlaufen
|
||||
foreach (@{$switches{$switch}}) {
|
||||
my ($SollStatus,$port) = $_ =~ /([0-9])_(.*)/;
|
||||
# debug ausgabe
|
||||
#printf " %-6s %-12s", $port, $StpStatusTrans[$SollStatus];
|
||||
|
||||
# Suche IfIndex zu Portname
|
||||
foreach (@IfIndexArray) {
|
||||
if ($_ =~ /$port"/) {
|
||||
my $index;
|
||||
($index) = $_ =~ /\.([0-9]*) =/;
|
||||
${$IfIndex{$switch}}{$port} = $index;
|
||||
|
||||
# Suche STP Status zu IfIndex
|
||||
foreach (@IfStpStatusArray) {
|
||||
if ($_ =~ /$index = /) {
|
||||
my $stp;
|
||||
($stp) = $_ =~ /= ([0-9])/;
|
||||
${$StpStatus{$switch}}{$port} = $StpStatusTrans[$stp];
|
||||
# debug ausgabe
|
||||
#printf "%-12s", $StpStatusTrans[$stp];
|
||||
if ($stp != $SollStatus) {
|
||||
# debug ausgabe
|
||||
#print " ! ";
|
||||
AlarmMail($switch, $port, $StpStatusTrans[$SollStatus], $StpStatusTrans[$stp]);
|
||||
$AlarmFlag = 1;
|
||||
}
|
||||
# debug ausgabe
|
||||
#print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($AlarmFlag) {
|
||||
open OUT, ">output.txt";
|
||||
printf OUT "@AlarmText";
|
||||
close OUT;
|
||||
`clemail -to a.wisniewski\@icfsystems.de -subject "Unerwarteter STP Status" -bodyfile output.txt -from rz\@icfsystems.de -smtpserver 130.35.0.143 -smtpport 25`;
|
||||
#unlink "output.txt";
|
||||
}
|
||||
}
|
||||
sub AlarmMail {
|
||||
my ($a,$b,$c,$d) = @_;
|
||||
push @AlarmText, sprintf "%-15s %-6s %-12s %-12s\n", $a, $b, $c, $d;
|
||||
}
|
||||
|
||||
sub Startup {
|
||||
while (ContinueRun(600)) {
|
||||
MainLoop();
|
||||
}
|
||||
}
|
||||
90
Windows Procurve STP Status via Perl/stp_state_noservice.pl
Normal file
90
Windows Procurve STP Status via Perl/stp_state_noservice.pl
Normal file
@@ -0,0 +1,90 @@
|
||||
#!/bin/perl
|
||||
our %Config;
|
||||
|
||||
my @AlarmText;
|
||||
|
||||
while (1) {
|
||||
my %switches;
|
||||
my @StpStatusTrans = qw / undef disabled blocking listening learning forwarding broken/;
|
||||
my $AlarmFlag;
|
||||
|
||||
my $t=localtime;
|
||||
printf "%s\n", $t;
|
||||
|
||||
@AlarmText=();
|
||||
my $Header = sprintf " %-15s %-6s %-12s %-12s\n ------------------------------------------------\n", "Switch", "Port", "Erwartet", "Ausgelesen";
|
||||
push @AlarmText, $Header;
|
||||
|
||||
open CONF, "<stp_state.conf";
|
||||
my @config=<CONF>;
|
||||
close CONF;
|
||||
|
||||
eval "@config";
|
||||
|
||||
my %IfIndex;
|
||||
my %StpStatus;
|
||||
|
||||
# Jede Switch durchlaufen
|
||||
foreach my $switch (keys %switches) {
|
||||
# debug ausgabe
|
||||
#print "\n$switch\n";
|
||||
|
||||
# Port Namen lesen um auf IfIndex zurückzuschließen
|
||||
my @IfIndexArray = `snmpwalk -mall -c public $switch .1.3.6.1.2.1.2.2.1.2`;
|
||||
|
||||
# STP Status lesen um zum IfIndex den STP Status zuzuordnen
|
||||
my @IfStpStatusArray = `snmpwalk -mall -c public $switch .1.3.6.1.2.1.17.2.15.1.3`;
|
||||
|
||||
# Jeden Port dieser Switch durchlaufen
|
||||
foreach (@{$switches{$switch}}) {
|
||||
my ($SollStatus,$port) = $_ =~ /([0-9])_(.*)/;
|
||||
# debug ausgabe
|
||||
#printf " %-6s %-12s", $port, $StpStatusTrans[$SollStatus];
|
||||
|
||||
# Suche IfIndex zu Portname
|
||||
foreach (@IfIndexArray) {
|
||||
if ($_ =~ /$port"/) {
|
||||
my $index;
|
||||
($index) = $_ =~ /\.([0-9]*) =/;
|
||||
${$IfIndex{$switch}}{$port} = $index;
|
||||
|
||||
# Suche STP Status zu IfIndex
|
||||
foreach (@IfStpStatusArray) {
|
||||
if ($_ =~ /$index = /) {
|
||||
my $stp;
|
||||
($stp) = $_ =~ /= ([0-9])/;
|
||||
${$StpStatus{$switch}}{$port} = $StpStatusTrans[$stp];
|
||||
# debug ausgabe
|
||||
#printf "%-12s", $StpStatusTrans[$stp];
|
||||
if ($stp != $SollStatus) {
|
||||
# debug ausgabe
|
||||
#print " ! ";
|
||||
AlarmMail($switch, $port, $StpStatusTrans[$SollStatus], $StpStatusTrans[$stp]);
|
||||
$AlarmFlag = 1;
|
||||
}
|
||||
# debug ausgabe
|
||||
#print "\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($AlarmFlag) {
|
||||
open OUT, ">output.txt";
|
||||
printf OUT "@AlarmText";
|
||||
close OUT;
|
||||
|
||||
# Mailserver
|
||||
`clemail -to a.wisniewski\@icfsystems.de -subject "Unerwarteter STP Status" -bodyfile output.txt -from rz\@icfsystems.de -smtpserver 130.35.0.143 -smtpport 25`;
|
||||
|
||||
}
|
||||
# Pause zwischen Prüfungen in Sekunden
|
||||
sleep(600);
|
||||
}
|
||||
|
||||
sub AlarmMail {
|
||||
my ($a,$b,$c,$d) = @_;
|
||||
push @AlarmText, sprintf "%-15s %-6s %-12s %-12s\n", $a, $b, $c, $d;
|
||||
}
|
||||
Reference in New Issue
Block a user