Projet

Général

Profil

Révision 38403565

ID38403565c4998d04c4de0333861449d0cf7d3935
Parent 83a8cfc7
Enfant adbc670d

Ajouté par adrianp il y a plus de 7 ans

Documentation for multiple instances and fake host, Link speed labels documented and drawn as different colors

Voir les différences:

plugins/tplink/tl_sg
38 38
=head1 CONFIGURATION
39 39

  
40 40
Add this to the relevant munin-node config file. You can specify switch address, username, password and description for each port
41
(the switch management doesn't allow port descriptions)
41
(the switch management doesn't allow port descriptions). You should also create a fake host for the switch and attach the graphs to it.
42
Details here: https://cweiske.de/tagebuch/munin-multiple-hosts.htm
43

  
44
In /etc/munin/munin.conf add a new host called tl-sg108e (or whatever you want):
45
  [tl-sg108e]
46
    address 127.0.0.1
47
    use_node_name no 
48

  
49
In /etc/munin/plugin-conf.d/munin-node add the following entry:
42 50

  
43 51
  [tl_sg]
52
  host_name tl-sg108e
44 53
  env.host 192.168.1.12
45 54
  env.port 80
46 55
  env.numberOfPorts 8
......
55 64
  env.p7 'Not used'
56 65
  env.p8 'Uplink'
57 66

  
67
The name in host_name must match the name defined in munin.conf, and the tl_sg name must match the plugin instance name (symlink).
68

  
58 69
If you're monitoring multiple switches, create different symlinks in /etc/munin/plugins pointing to this plugin and use the symlink
59 70
name as a configuration section as described above.
60 71

  
......
94 105
my $password = ( $ENV{password} || 'admin' );
95 106
my $numberOfPorts = ( $ENV{numberOfPorts} || '8' );
96 107

  
108
my %speedMapping = (
109
    0 => "down",
110
    1 => "auto",
111
    2 => "10M half-duplex",
112
    3 => "10M full-duplex",
113
    4 => "100M half-duplex",
114
    5 => "100M full-duplex",
115
    6 => "1G full-duplex",
116
);
117

  
118

  
97 119
#populate the ports and descriptions based on ENV
98 120
my %ports = ();
99 121
for ( 1 .. $numberOfPorts ) {
......
123 145
              "graph_category network\n";
124 146
            if ( $graphType eq 'Speed' ) {
125 147
                print "graph_vlabel speed\n";
126
                print "p${port}.label Port $port Link speed\n";
127
                print "p${port}.type GAUGE\n";
148
                foreach my $value (sort keys %speedMapping){
149
                    print "p${port}_$value.label $speedMapping{$value}\n";
150
                    print "p${port}_$value.type GAUGE\n";
151
                }
128 152
            }
129 153
            else {
130 154
                print "graph_vlabel packets\n";
......
158 182
$result   = $mech->get("http://$host:$tcpport/PortStatisticsRpm.htm");
159 183
$response = $mech->response();
160 184

  
161
# print STDERR $response->code()."\n";
185
#print STDERR $response->code()."\n";
162 186

  
163 187
# get the data
164 188
my $data = $mech->content( raw => 1 );
165 189

  
166
# print STDERR "$data\n";
190
#print STDERR "$data\n";
167 191

  
168 192
# The page stores the data in a table, but internally it is stored in 3 javascript arrays:
169 193
# state:[1,1,1,1,1,1,1,1,0,0],
......
171 195
# pkts:[0,0,0,0,14141090,0,10461386,0,14226,0,12252,0,0,0,0,0,2872063,0,1402200,0,59764503,0,34619246,0,4913873,0,4393574,0,44170456,0,68499653,0,0,0]
172 196

  
173 197
# state: 1 - Enabled, 0 - Disabled (administratively)
174
# link_status: 0 - down, 5 - 100Mbps full, 6 - 1Gbps
198
# link_status: 0 - down, 1 - auto, 2 - 10Mbps half, 3 - 10Mbps full, 4 - 100Mbps half, 5 - 100Mbps full, 6 - 1Gbps full
175 199
# pkts: every group of 4 values represent txGoodPkt, txBadPkt, rxGoodPkt, rxBadPkt
176 200

  
177 201
# parse good/bad packets
......
204 228
        my $currentPort = $_;
205 229
        my $link        = $links[ $currentPort - 1 ];
206 230
        print "multigraph Speed_if_$currentPort\n";
207

  
208
        print "p${currentPort}.value $link\n";
231
        foreach my $value (sort keys %speedMapping){
232
            print "p${currentPort}_$value.value ".(($value eq $link)?1:0)."\n";
233
        }
209 234
    }
210 235

  
211 236
}

Formats disponibles : Unified diff