| 1 |
|
#!/usr/bin/perl -w |
| 2 |
|
|
| 3 |
+ |
# |
| 4 |
+ |
# i-scream central monitoring system |
| 5 |
+ |
# http://www.i-scream.org.uk |
| 6 |
+ |
# Copyright (C) 2000-2002 i-scream |
| 7 |
+ |
# |
| 8 |
+ |
# This program is free software; you can redistribute it and/or |
| 9 |
+ |
# modify it under the terms of the GNU General Public License |
| 10 |
+ |
# as published by the Free Software Foundation; either version 2 |
| 11 |
+ |
# of the License, or (at your option) any later version. |
| 12 |
+ |
# |
| 13 |
+ |
# This program is distributed in the hope that it will be useful, |
| 14 |
+ |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 15 |
+ |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 16 |
+ |
# GNU General Public License for more details. |
| 17 |
+ |
# |
| 18 |
+ |
# You should have received a copy of the GNU General Public License |
| 19 |
+ |
# along with this program; if not, write to the Free Software |
| 20 |
+ |
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 21 |
+ |
# |
| 22 |
+ |
|
| 23 |
|
#----------------------------------------------------------------- |
| 24 |
|
# i-scream host plugin - disk information |
| 25 |
|
# $Author$ |
| 35 |
|
# You'd be silly not to use this ;) |
| 36 |
|
use strict; |
| 37 |
|
|
| 38 |
< |
# Have to hope this will work really. |
| 39 |
< |
my($ostype) = `uname -s`; chomp($ostype); |
| 38 |
> |
# Exclude list |
| 39 |
> |
my($exclude_list) = "^/nfs/;^/cdrom/"; |
| 40 |
> |
my(@exclude_array) = split(';', $exclude_list); |
| 41 |
|
|
| 42 |
+ |
# Get the OS type from the args, or try towork it out |
| 43 |
+ |
my($ostype) = $ARGV[0]; |
| 44 |
+ |
$ostype = `uname -s` if not defined $ostype; |
| 45 |
+ |
chomp($ostype); |
| 46 |
+ |
|
| 47 |
|
# Decide which paths we should use. |
| 48 |
|
my($dfbin); |
| 49 |
|
if ($ostype eq "SunOS") { |
| 66 |
|
} |
| 67 |
|
|
| 68 |
|
# Run the following components: - |
| 43 |
– |
&print_ident(); |
| 69 |
|
&include_disk(); |
| 70 |
|
|
| 71 |
|
# End the program normally. |
| 74 |
|
|
| 75 |
|
|
| 76 |
|
|
| 52 |
– |
# prints out an identifier for this version of the script |
| 53 |
– |
# this could be used in checks further downstream |
| 54 |
– |
sub print_ident() { |
| 55 |
– |
print 'packet.plugins.ident.i-scream_disk i-scream_disk.pl $Revision$'; |
| 56 |
– |
print "\n"; |
| 57 |
– |
} |
| 58 |
– |
|
| 77 |
|
# sub to print pairs of data, separated by a single space character. |
| 78 |
|
# If the second argument is undefined, then the pair is still printed, |
| 79 |
|
# however, the value shall be displayed as the the 'default' value |
| 109 |
|
} |
| 110 |
|
if ($line =~ /^([^\s]+)\s+([0-9]+)\s+([0-9]+)\s+([0-9]+)\s+[^\s]+\s+(\/[^\s]*)\s*/) { |
| 111 |
|
my ($filesystem, $kbytes, $used, $avail, $mount) = ($1, $2, $3, $4, $5); |
| 112 |
< |
&print_pair("unknown", "packet.disk.p$partition_no.attributes.name", $filesystem); |
| 113 |
< |
&print_pair(0, "packet.disk.p$partition_no.attributes.kbytes", $kbytes); |
| 114 |
< |
&print_pair(0, "packet.disk.p$partition_no.attributes.used", $used); |
| 115 |
< |
&print_pair(0, "packet.disk.p$partition_no.attributes.avail", $avail); |
| 116 |
< |
&print_pair("unknown", "packet.disk.p$partition_no.attributes.mount", $mount); |
| 117 |
< |
++$partition_no; |
| 112 |
> |
my($do_disk) = 1; |
| 113 |
> |
foreach my $exclusion (@exclude_array) { |
| 114 |
> |
if ($mount =~ /$exclusion/) { |
| 115 |
> |
$do_disk = 0; |
| 116 |
> |
last; |
| 117 |
> |
} |
| 118 |
> |
} |
| 119 |
> |
if($do_disk) { |
| 120 |
> |
&print_pair("unknown", "packet.disk.p$partition_no.attributes.name", $filesystem); |
| 121 |
> |
&print_pair(0, "packet.disk.p$partition_no.attributes.kbytes", $kbytes); |
| 122 |
> |
&print_pair(0, "packet.disk.p$partition_no.attributes.used", $used); |
| 123 |
> |
&print_pair(0, "packet.disk.p$partition_no.attributes.avail", $avail); |
| 124 |
> |
&print_pair("unknown", "packet.disk.p$partition_no.attributes.mount", $mount); |
| 125 |
> |
++$partition_no; |
| 126 |
> |
} |
| 127 |
|
} |
| 128 |
|
} |
| 129 |
|
|