summaryrefslogtreecommitdiffstats
path: root/plugins-scripts
diff options
context:
space:
mode:
Diffstat (limited to 'plugins-scripts')
-rwxr-xr-xplugins-scripts/check_ifstatus.pl45
-rwxr-xr-xplugins-scripts/check_ircd.pl61
2 files changed, 59 insertions, 47 deletions
diff --git a/plugins-scripts/check_ifstatus.pl b/plugins-scripts/check_ifstatus.pl
index 38b87fcc..f0b7c491 100755
--- a/plugins-scripts/check_ifstatus.pl
+++ b/plugins-scripts/check_ifstatus.pl
@@ -97,11 +97,12 @@ my $opt_V ;
97my $opt_u; 97my $opt_u;
98my $opt_n; 98my $opt_n;
99my $opt_x ; 99my $opt_x ;
100my $opt_d;
100my %excluded ; 101my %excluded ;
101my %unused_names ; 102my %unused_names ;
102my @unused_ports ; 103my @unused_ports ;
103my %session_opts; 104my %session_opts;
104 105my @exclude_descriptions;
105 106
106 107
107 108
@@ -134,6 +135,7 @@ if (!defined($session)) {
134} 135}
135 136
136 137
138push(@snmpoids,$snmpLocIfDescr);
137push(@snmpoids,$snmpIfOperStatus); 139push(@snmpoids,$snmpIfOperStatus);
138push(@snmpoids,$snmpIfAdminStatus); 140push(@snmpoids,$snmpIfAdminStatus);
139push(@snmpoids,$snmpIfDescr); 141push(@snmpoids,$snmpIfDescr);
@@ -180,18 +182,28 @@ foreach $key (keys %ifStatus) {
180 if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) { 182 if ($ifStatus{$key}{$snmpIfAdminStatus} == 1 ) {
181 #check only if interface is not excluded 183 #check only if interface is not excluded
182 if (!defined $unused_names{$ifStatus{$key}{$snmpIfDescr}} ) { 184 if (!defined $unused_names{$ifStatus{$key}{$snmpIfDescr}} ) {
183 # check only if interface type is not listed in %excluded 185 #check only if interface is not excluded (by description)
184 if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) { 186 #counter for matching descriptions
185 if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ; } 187 my $match_descr = 0;
186 if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) { 188 foreach my $description (@exclude_descriptions) {
187 $ifdown++ ; 189 if ($ifStatus{$key}{$snmpLocIfDescr} =~ /^$description/) { $match_descr = 1; }
188 if (defined $ifXTable) { 190 }
189 $ifmessage .= sprintf("%s: down -> %s<BR>\n", $ifStatus{$key}{$snmpIfName}, $ifStatus{$key}{$snmpIfAlias}); 191 if ($match_descr == 0) {
190 }else{ 192 # check only if interface type is not listed in %excluded
191 $ifmessage .= sprintf("%s: down <BR>\n",$ifStatus{$key}{$snmpIfDescr}); 193 if (!defined $excluded{$ifStatus{$key}{$snmpIfType}} ) {
192 } 194 if ($ifStatus{$key}{$snmpIfOperStatus} == 1 ) { $ifup++ ; }
195 if ($ifStatus{$key}{$snmpIfOperStatus} == 2 ) {
196 $ifdown++ ;
197 if (defined $ifXTable) {
198 $ifmessage .= sprintf("%s: down -> %s<BR>\n", $ifStatus{$key}{$snmpIfName}, $ifStatus{$key}{$snmpIfAlias});
199 }else{
200 $ifmessage .= sprintf("%s: down <BR>\n",$ifStatus{$key}{$snmpIfDescr});
201 }
202 }
203 if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;}
204 } else {
205 $ifexclude++;
193 } 206 }
194 if ($ifStatus{$key}{$snmpIfOperStatus} == 5 ) { $ifdormant++ ;}
195 } else { 207 } else {
196 $ifexclude++; 208 $ifexclude++;
197 } 209 }
@@ -264,6 +276,9 @@ sub print_help() {
264 printf " the descriptive name. Do not use if you don't know what this is. \n"; 276 printf " the descriptive name. Do not use if you don't know what this is. \n";
265 printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n"; 277 printf " -x (--exclude) A comma separated list of ifType values that should be excluded \n";
266 printf " from the report (default for an empty list is PPP(23).\n"; 278 printf " from the report (default for an empty list is PPP(23).\n";
279 printf " -d (--exclude_ports_by_description) A comma separated list of LocIfDescr values that should be excluded \n";
280 printf " from the report (default is an empty exclusion list). Done using regexp '/^arg/', ex:\n";
281 printf " '-d connect,test' will match with descriptions like 'testing phase' but not 'in testing'.\n";
267 printf " -n (--unused_ports_by_name) A comma separated list of ifDescr values that should be excluded \n"; 282 printf " -n (--unused_ports_by_name) A comma separated list of ifDescr values that should be excluded \n";
268 printf " from the report (default is an empty exclusion list).\n"; 283 printf " from the report (default is an empty exclusion list).\n";
269 printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n"; 284 printf " -u (--unused_ports) A comma separated list of ifIndex values that should be excluded \n";
@@ -306,6 +321,7 @@ sub process_arguments() {
306 "I" => \$ifXTable, "ifmib" => \$ifXTable, 321 "I" => \$ifXTable, "ifmib" => \$ifXTable,
307 "x:s" => \$opt_x, "exclude:s" => \$opt_x, 322 "x:s" => \$opt_x, "exclude:s" => \$opt_x,
308 "u=s" => \$opt_u, "unused_ports=s" => \$opt_u, 323 "u=s" => \$opt_u, "unused_ports=s" => \$opt_u,
324 "d=s" => \$opt_d, "exclude_ports_by_description=s" => \$opt_d,
309 "n=s" => \$opt_n, "unused_ports_by_name=s" => \$opt_n, 325 "n=s" => \$opt_n, "unused_ports_by_name=s" => \$opt_n,
310 "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize, 326 "M=i" => \$maxmsgsize, "maxmsgsize=i" => \$maxmsgsize,
311 "t=i" => \$timeout, "timeout=i" => \$timeout, 327 "t=i" => \$timeout, "timeout=i" => \$timeout,
@@ -414,6 +430,11 @@ sub process_arguments() {
414 } 430 }
415 } 431 }
416 432
433 # Exclude interfaces by descriptions
434 if (defined $opt_d) {
435 @exclude_descriptions = split(/,/,$opt_d);
436 }
437
417 # Excluded interface descriptors 438 # Excluded interface descriptors
418 if (defined $opt_n) { 439 if (defined $opt_n) {
419 my @unused = split(/,/,$opt_n); 440 my @unused = split(/,/,$opt_n);
diff --git a/plugins-scripts/check_ircd.pl b/plugins-scripts/check_ircd.pl
index 4822fe68..15a70802 100755
--- a/plugins-scripts/check_ircd.pl
+++ b/plugins-scripts/check_ircd.pl
@@ -40,15 +40,16 @@
40 40
41# ----------------------------------------------------------------[ Require ]-- 41# ----------------------------------------------------------------[ Require ]--
42 42
43require 5.004; 43require 5.14.0;
44 44
45# -------------------------------------------------------------------[ Uses ]-- 45# -------------------------------------------------------------------[ Uses ]--
46 46
47use Socket;
48use strict; 47use strict;
48use IO::Socket::IP;
49use Getopt::Long; 49use Getopt::Long;
50use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $verbose); 50use vars qw($opt_V $opt_h $opt_t $opt_p $opt_H $opt_w $opt_c $opt_4 $opt_6 $verbose);
51use vars qw($PROGNAME); 51use vars qw($PROGNAME);
52use vars qw($ClientSocket);
52use FindBin; 53use FindBin;
53use lib "$FindBin::Bin"; 54use lib "$FindBin::Bin";
54use utils qw($TIMEOUT %ERRORS &print_revision &support &usage); 55use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
@@ -58,7 +59,6 @@ use utils qw($TIMEOUT %ERRORS &print_revision &support &usage);
58sub print_help (); 59sub print_help ();
59sub print_usage (); 60sub print_usage ();
60sub connection ($$$$); 61sub connection ($$$$);
61sub bindRemote ($$);
62 62
63# -------------------------------------------------------------[ Environment ]-- 63# -------------------------------------------------------------[ Environment ]--
64 64
@@ -104,7 +104,7 @@ sub connection ($$$$)
104 $answer = "Server $in_remotehost has less than 0 users! Something is Really WRONG!\n"; 104 $answer = "Server $in_remotehost has less than 0 users! Something is Really WRONG!\n";
105 } 105 }
106 106
107 print ClientSocket "quit\n"; 107 print $ClientSocket "quit\n";
108 print $answer; 108 print $answer;
109 exit $ERRORS{$state}; 109 exit $ERRORS{$state};
110} 110}
@@ -112,7 +112,7 @@ sub connection ($$$$)
112# ------------------------------------------------------------[ print_usage ]-- 112# ------------------------------------------------------------[ print_usage ]--
113 113
114sub print_usage () { 114sub print_usage () {
115 print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>] [-p <port>]\n"; 115 print "Usage: $PROGNAME -H <host> [-w <warn>] [-c <crit>] [-p <port>] [ -4|-6 ]\n";
116} 116}
117 117
118# -------------------------------------------------------------[ print_help ]-- 118# -------------------------------------------------------------[ print_help ]--
@@ -135,33 +135,15 @@ Perl Check IRCD plugin for monitoring
135 Number of connected users which generates a critical state (Default: 100) 135 Number of connected users which generates a critical state (Default: 100)
136-p, --port=INTEGER 136-p, --port=INTEGER
137 Port that the ircd daemon is running on <host> (Default: 6667) 137 Port that the ircd daemon is running on <host> (Default: 6667)
138-4, --use-ipv4
139 Use IPv4 connection
140-6, --use-ipv6
141 Use IPv6 connection
138-v, --verbose 142-v, --verbose
139 Print extra debugging information 143 Print extra debugging information
140"; 144";
141} 145}
142 146
143# -------------------------------------------------------------[ bindRemote ]--
144
145sub bindRemote ($$)
146{
147 my ($in_remotehost, $in_remoteport) = @_;
148 my $proto = getprotobyname('tcp');
149 my $that;
150 my ($name, $aliases,$type,$len,$thataddr) = gethostbyname($in_remotehost);
151
152 if (!socket(ClientSocket,AF_INET, SOCK_STREAM, $proto)) {
153 print "IRCD UNKNOWN: Could not start socket ($!)\n";
154 exit $ERRORS{"UNKNOWN"};
155 }
156 $that = pack_sockaddr_in ($in_remoteport, $thataddr);
157 if (!connect(ClientSocket, $that)) {
158 print "IRCD UNKNOWN: Could not connect socket ($!)\n";
159 exit $ERRORS{"UNKNOWN"};
160 }
161 select(ClientSocket); $| = 1; select(STDOUT);
162 return \*ClientSocket;
163}
164
165# ===================================================================[ MAIN ]== 147# ===================================================================[ MAIN ]==
166 148
167MAIN: 149MAIN:
@@ -177,6 +159,8 @@ MAIN:
177 "w=i" => \$opt_w, "warning=i" => \$opt_w, 159 "w=i" => \$opt_w, "warning=i" => \$opt_w,
178 "c=i" => \$opt_c, "critical=i" => \$opt_c, 160 "c=i" => \$opt_c, "critical=i" => \$opt_c,
179 "p=i" => \$opt_p, "port=i" => \$opt_p, 161 "p=i" => \$opt_p, "port=i" => \$opt_p,
162 "4" => \$opt_4, "use-ipv4" => \$opt_4,
163 "6" => \$opt_6, "use-ipv6" => \$opt_6,
180 "H=s" => \$opt_H, "hostname=s" => \$opt_H); 164 "H=s" => \$opt_H, "hostname=s" => \$opt_H);
181 165
182 if ($opt_V) { 166 if ($opt_V) {
@@ -187,7 +171,7 @@ MAIN:
187 if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};} 171 if ($opt_h) {print_help(); exit $ERRORS{'UNKNOWN'};}
188 172
189 ($opt_H) || ($opt_H = shift @ARGV) || usage("Host name/address not specified\n"); 173 ($opt_H) || ($opt_H = shift @ARGV) || usage("Host name/address not specified\n");
190 my $remotehost = $1 if ($opt_H =~ /([-.A-Za-z0-9]+)/); 174 my $remotehost = $1 if ($opt_H =~ /([-.:%A-Za-z0-9]+)/);
191 ($remotehost) || usage("Invalid host: $opt_H\n"); 175 ($remotehost) || usage("Invalid host: $opt_H\n");
192 176
193 ($opt_w) || ($opt_w = shift @ARGV) || ($opt_w = 50); 177 ($opt_w) || ($opt_w = shift @ARGV) || ($opt_w = 50);
@@ -212,21 +196,28 @@ MAIN:
212 196
213 alarm($TIMEOUT); 197 alarm($TIMEOUT);
214 198
215 my ($name, $alias, $proto) = getprotobyname('tcp');
216
217 print "MAIN(debug): binding to remote host: $remotehost -> $remoteport\n" if $verbose; 199 print "MAIN(debug): binding to remote host: $remotehost -> $remoteport\n" if $verbose;
218 my $ClientSocket = &bindRemote($remotehost,$remoteport); 200 $ClientSocket = IO::Socket::IP->new(
201 PeerHost => $remotehost,
202 PeerService => $remoteport,
203 Family => $opt_4 ? AF_INET : $opt_6 ? AF_INET6 : undef,
204 Type => SOCK_STREAM,
205 );
206 if (!$ClientSocket) {
207 print "IRCD UNKNOWN: Could not start socket ($!)\n";
208 exit $ERRORS{"UNKNOWN"};
209 }
219 210
220 print ClientSocket "NICK $NICK\nUSER $USER_INFO\n"; 211 print $ClientSocket "NICK $NICK\nUSER $USER_INFO\n";
221 212
222 while (<ClientSocket>) { 213 while (<$ClientSocket>) {
223 print "MAIN(debug): default var = $_\n" if $verbose; 214 print "MAIN(debug): default var = $_\n" if $verbose;
224 215
225 # DALnet,LagNet,UnderNet etc. Require this! 216 # DALnet,LagNet,UnderNet etc. Require this!
226 # Replies with a PONG when presented with a PING query. 217 # Replies with a PONG when presented with a PING query.
227 # If a server doesn't require it, it will be ignored. 218 # If a server doesn't require it, it will be ignored.
228 219
229 if (m/^PING (.*)/) {print ClientSocket "PONG $1\n";} 220 if (m/^PING (.*)/) {print $ClientSocket "PONG $1\n";}
230 221
231 alarm(0); 222 alarm(0);
232 223