Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / snmp / snmp__netapp_diskbusy @ de8aa961

Historique | Voir | Annoter | Télécharger (3,47 ko)

1
#!/usr/bin/perl -w
2
# -*- perl -*-
3
# vim: ft=perl
4

    
5
=head1 NAME
6

    
7

    
8
=head1 APPLICABLE SYSTEMS
9

    
10

    
11
=head1 CONFIGURATION
12

    
13
You have to setup ssh with public key authentication for this plugin
14
SNMP is only used for getting the hostname
15

    
16
   [snmp_$host_netapp_diskbusy]
17
    env.ssh /usr/bin/ssh (default)
18
    env.sshuser munin (default)
19
    env.sshopts -i /home/munin/.ssh/id_rsa -o UserKnownHostsFile=/home/munin/.ssh/known_hosts (no default)
20
    env.spares 2 (no default)
21

    
22
Number of spares is only used for total diskusage.
23

    
24
=head1 INTERPRETATION
25

    
26
This plugin only prints the disk busy status at check time. There is no
27
average calculated, but it still gives a goood overview if all disk are
28
used equally or you have got a single hot disk.
29

    
30
=head1 AUTHOR
31

    
32
2013, Claudius Herder
33

    
34
=head1 LICENSE
35

    
36
GPLv2.
37

    
38
=cut
39

    
40
use strict;
41
use Munin::Plugin;
42
use Munin::Plugin::SNMP;
43
need_multigraph();
44

    
45
my %disks;
46

    
47
sub do_collect
48
{
49
    my $input;
50
    my @tmp;
51
    my $ssh = $ENV{'ssh'} || '/usr/bin/ssh';
52
    my $sshuser = $ENV{'sshuser'} || $ENV{'USER'};
53
    my $sshopts = $ENV{'sshopts'} || "";
54
    my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session();
55

    
56
    $input=`$ssh $sshopts $sshuser\@$host stats show disk:*:disk_busy`;
57
    foreach my $line (split(/\n/, $input))
58
    {
59
        @tmp = split(/:/, $line);
60
        ($disks{$tmp[2]} = $tmp[12]) =~ s/%//;
61
    }
62
}
63

    
64
sub do_config_root
65
{
66
    my ($host) = @_;
67

    
68
    print "multigraph diskbusy\n";
69
    print "graph_title $host Aggregate busy status\n";
70
    print "graph_args --base 1000 --lower-limit 0 --rigid\n";
71
    print "graph_vlabel aggr busy status\n";
72
    print "graph_category disk\n";
73
    print "graph_info This graph shows the aggr busy status in percent for $host without spares\n";
74
    print "diskbusy.label DiskBusy\n";
75
    print "diskbusy.min 0\n";
76
    print "diskbusy.draw AREASTACK\n";
77
    print "diskbusy.type GAUGE\n";
78
}
79

    
80
sub do_config_disk
81
{
82
    my ($host,$disk) = @_;
83
    my $extrainfo = '';
84

    
85
    print "multigraph diskbusy.$disk\n";
86
    print "graph_title disk busy status for disk $disk\n";
87
    print "graph_args --base 1000 --lower-limit 0 --rigid\n";
88
    print "graph_vlabel disk busy status\n";
89
    print "graph_category disk\n";
90
    print "graph_info This graph shows disk busy status in percent for the $disk disk.$extrainfo\n";
91
    print "diskbusy.info This is the disk busy status in percent of $disk\n";
92
    print "diskbusy.type GAUGE\n";
93
    print "diskbusy.label DiskBusy\n";
94
    print "diskbusy.min 0\n";
95
    print "diskbusy.draw AREASTACK\n";
96
}
97

    
98
sub do_fetch_root
99
{
100
    my $spares=$ENV{'spares'} || 0;
101
    my $busy =0;
102
    my $numberofdisk=0;
103
    my $diskbusy=0;
104
    $numberofdisk =(keys %disks);
105
    foreach my $disk (keys %disks)
106
    {
107
        $busy += $disks{$disk};
108
    }
109
    $diskbusy=$busy/($numberofdisk-$spares);
110
    print "multigraph diskbusy\n";
111
    printf("diskbusy.value %.3f \n",$diskbusy);
112
}
113

    
114
sub do_fetch_disk
115
{
116
    my($disk) = @_;
117
    my $busy;
118
    $busy = $disks{$disk};
119
    print "multigraph diskbusy.$disk\n";
120
    print "diskbusy.value $busy\n";
121
}
122

    
123
sub do_config
124
{
125
    my ($host, undef, undef, undef) = Munin::Plugin::SNMP->config_session();
126
    print "host_name $host\n" unless $host eq 'localhost';
127
    foreach my $disk (sort keys %disks)
128
    {
129
        do_config_disk($host,$disk);
130
    }
131
    do_config_root($host);
132
}
133

    
134
sub do_fetch
135
{
136
    foreach my $disk (sort  keys %disks)
137
    {
138
        do_fetch_disk($disk);
139
    }
140
    do_fetch_root();
141
}
142

    
143
do_collect();
144

    
145
if ($ARGV[0] and $ARGV[0] eq "config")
146
{
147
    do_config();
148
    exit 0;
149
}
150

    
151
do_fetch();
152

    
153
exit 0;
154

    
155
__END__