Projet

Général

Profil

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

root / plugins / snmp / snmp__netapp_diskbusy @ 81db94e2

Historique | Voir | Annoter | Télécharger (3,55 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
    # graph_category netapp # To show plugin in Gallery also in this category
67
 
68
    my ($host) = @_;
69

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

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

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

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

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

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

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

    
145
do_collect();
146

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

    
153
do_fetch();
154

    
155
exit 0;
156

    
157
__END__