forked from evolix/ansible-roles
drbd-utils: munin/nagios plugins are vendored
This commit is contained in:
parent
00aafd8767
commit
002d143548
27
drbd-utils/README.md
Normal file
27
drbd-utils/README.md
Normal file
|
@ -0,0 +1,27 @@
|
|||
# drbd-utils
|
||||
|
||||
Install tools to setup DRBD replication accross servers.
|
||||
|
||||
## Tasks
|
||||
|
||||
Everything is in the `tasks/main.yml` file.
|
||||
|
||||
## Available variables
|
||||
|
||||
The variable `admin_users` must be a "dict" of one or more users :
|
||||
|
||||
```
|
||||
admin_users:
|
||||
foo:
|
||||
name: foo
|
||||
uid: 1001
|
||||
fullname: 'Mr Foo'
|
||||
password_hash: 'sdfgsdfgsdfgsdfg'
|
||||
ssh_key: 'ssh-rsa AZERTYXYZ'
|
||||
bar:
|
||||
name: bar
|
||||
uid: 1002
|
||||
fullname: 'Mr Bar'
|
||||
password_hash: 'gsdfgsdfgsdfgsdf'
|
||||
ssh_key: 'ssh-rsa QWERTYUIOP'
|
||||
```
|
143
drbd-utils/files/munin/drbd-plugin
Normal file
143
drbd-utils/files/munin/drbd-plugin
Normal file
|
@ -0,0 +1,143 @@
|
|||
#!/usr/bin/perl
|
||||
|
||||
# http://www.drbd.org/users-guide/ch-admin.html#s-proc-drbd
|
||||
|
||||
use strict;
|
||||
|
||||
my $file="/proc/drbd";
|
||||
my $store = {};
|
||||
my $temp;
|
||||
|
||||
&crunch;
|
||||
&display;
|
||||
|
||||
sub display{
|
||||
if ($ARGV[0] and $ARGV[0] eq "config"){
|
||||
print "graph_title DRBD\n";
|
||||
print "graph_category DRBD\n";
|
||||
print "graph_info Graph DRBD\n";
|
||||
print "graph_vlabel Bytes per \${graph_period} read (-) / written (+)\n";
|
||||
print "graph_args --base 1024 --lower-limit 0\n";
|
||||
|
||||
foreach my $key ( keys %$store ){
|
||||
my $drbdname = 'drbd'.$key;
|
||||
print $drbdname."dr.label $drbdname disk\n";
|
||||
print $drbdname."dr.cdef ".$drbdname."dr,819,*\n";
|
||||
print $drbdname."dr.type DERIVE\n";
|
||||
print $drbdname."dr.min 0\n";
|
||||
print $drbdname."dr.graph no\n";
|
||||
print $drbdname."dw.label $drbdname disk\n";
|
||||
print $drbdname."dw.cdef ".$drbdname."dw,819,*\n";
|
||||
print $drbdname."dw.type DERIVE\n";
|
||||
print $drbdname."dw.min 0\n";
|
||||
print $drbdname."dw.negative ".$drbdname."dr\n";
|
||||
print $drbdname."nr.label $drbdname net\n";
|
||||
print $drbdname."nr.cdef ".$drbdname."nr,819,*\n";
|
||||
print $drbdname."nr.type DERIVE\n";
|
||||
print $drbdname."nr.min 0\n";
|
||||
print $drbdname."nr.graph no\n";
|
||||
print $drbdname."ns.label $drbdname net\n";
|
||||
print $drbdname."ns.cdef ".$drbdname."ns,819,*\n";
|
||||
print $drbdname."ns.type DERIVE\n";
|
||||
print $drbdname."ns.min 0\n";
|
||||
print $drbdname."ns.negative ".$drbdname."nr\n";
|
||||
}
|
||||
exit 0;
|
||||
}
|
||||
|
||||
foreach my $key ( keys %$store ){
|
||||
my $drbdname = 'drbd'.$key;
|
||||
print $drbdname."dw.value ".$store->{$key}->{'dw'}."\n";
|
||||
print $drbdname."dr.value ".$store->{$key}->{'dr'}."\n";
|
||||
print $drbdname."ns.value ".$store->{$key}->{'ns'}."\n";
|
||||
print $drbdname."nr.value ".$store->{$key}->{'nr'}."\n";
|
||||
}
|
||||
}
|
||||
|
||||
sub crunch{
|
||||
open (IN, $file ) || die "Could not open $file for reading: $!";
|
||||
while (<IN>){
|
||||
next if /version:|GIT-hash:/;
|
||||
chomp;
|
||||
|
||||
my ($drbd) = $_ =~ /^\s+(\d):/;
|
||||
$temp = $drbd if $drbd =~ /\d/;
|
||||
|
||||
if (/resync/){
|
||||
my ($hits) = $_ =~ /hits:(\d*)/;
|
||||
$store->{ $temp }->{'resync'}->{hits} = $hits if $hits ne undef;
|
||||
|
||||
my ($misses) = $_ =~ /misses:(\d*)/;
|
||||
$store->{ $temp }->{'resync'}->{misses} = $misses if $misses ne undef;
|
||||
|
||||
my ($starving) = $_ =~ /starving:(\d*)/;
|
||||
$store->{ $temp }->{'resync'}->{starving} = $starving if $starving ne undef;
|
||||
|
||||
my ($dirty) = $_ =~ /dirty:(\d*)/;
|
||||
$store->{ $temp }->{'resync'}->{dirty} = $dirty if $dirty ne undef;
|
||||
|
||||
my ($changed) = $_ =~ /changed:(\d*)/;
|
||||
$store->{ $temp }->{'resync'}->{changed} = $changed if $changed ne undef;
|
||||
}
|
||||
|
||||
if (/act_log/){
|
||||
my ($hits) = $_ =~ /hits:(\d*)/;
|
||||
$store->{ $temp }->{'act_log'}->{hits} = $hits if $hits ne undef;
|
||||
|
||||
my ($misses) = $_ =~ /misses:(\d*)/;
|
||||
$store->{ $temp }->{'act_log'}->{misses} = $misses if $misses ne undef;
|
||||
|
||||
my ($starving) = $_ =~ /starving:(\d*)/;
|
||||
$store->{ $temp }->{'act_log'}->{starving} = $starving if $starving ne undef;
|
||||
|
||||
my ($dirty) = $_ =~ /dirty:(\d*)/;
|
||||
$store->{ $temp }->{'act_log'}->{dirty} = $dirty if $dirty ne undef;
|
||||
|
||||
my ($changed) = $_ =~ /changed:(\d*)/;
|
||||
$store->{ $temp }->{'act_log'}->{changed} = $changed if $changed ne undef;
|
||||
}
|
||||
|
||||
my ($ns) = $_ =~ /ns:(\d*)/;
|
||||
$store->{ $temp }->{'ns'} = $ns if $ns ne undef;
|
||||
|
||||
my ($nr) = $_ =~ /nr:(\d*)/;
|
||||
$store->{ $temp }->{'nr'} = $nr if $ns ne undef;
|
||||
|
||||
my ($dw) = $_ =~ /dw:(\d*)/;
|
||||
$store->{ $temp }->{'dw'} = $dw if $dw ne undef;
|
||||
|
||||
my ($dr) = $_ =~ /dr:(\d*)/;
|
||||
$store->{ $temp }->{'dr'} = $dr if $dr ne undef;
|
||||
|
||||
my ($al) = $_ =~ /al:(\d*)/;
|
||||
$store->{ $temp }->{'al'} = $al if $dr ne undef;
|
||||
|
||||
my ($bm) = $_ =~ /bm:(\d*)/;
|
||||
$store->{ $temp }->{'bm'} = $bm if $dr ne undef;
|
||||
|
||||
my ($lo) = $_ =~ /lo:(\d*)/;
|
||||
$store->{ $temp }->{'lo'} = $lo if $dr ne undef;
|
||||
|
||||
my ($pe) = $_ =~ /pe:(\d*)/;
|
||||
$store->{ $temp }->{'pe'} = $pe if $dr ne undef;
|
||||
|
||||
my ($ua) = $_ =~ /ua:(\d*)/;
|
||||
$store->{ $temp }->{'ua'} = $ua if $dr ne undef;
|
||||
|
||||
my ($ap) = $_ =~ /ap:(\d*)/;
|
||||
$store->{ $temp }->{'ap'} = $ap if $ap ne undef;
|
||||
|
||||
my ($hits) = $_ =~ /hits:(\d*)/;
|
||||
$store->{ $temp }->{'hits'} = $hits if $hits ne undef;
|
||||
|
||||
my ($used) = $_ =~ /used:(\d*\\\d*)\s/;
|
||||
$store->{ $temp }->{'used'} = $used if $used ne undef;
|
||||
}
|
||||
|
||||
close (IN);
|
||||
|
||||
#print Dumper \$store;
|
||||
|
||||
}
|
||||
|
||||
exit 0;
|
0
drbd-utils/files/nagios/check_drbd
Normal file
0
drbd-utils/files/nagios/check_drbd
Normal file
|
@ -1,9 +1,6 @@
|
|||
---
|
||||
- include: packages.yml
|
||||
|
||||
- name: Mount /usr in rw
|
||||
command: mount -o remount,rw /usr warn=no
|
||||
changed_when: False
|
||||
|
||||
- include: munin.yml
|
||||
|
||||
- include: nagios.yml
|
||||
|
|
|
@ -1,14 +1,15 @@
|
|||
---
|
||||
|
||||
# https://raw.githubusercontent.com/munin-monitoring/contrib/master/plugins/drbd/drbd
|
||||
- name: Get Munin plugin
|
||||
get_url:
|
||||
url: 'https://raw.githubusercontent.com/munin-monitoring/contrib/master/plugins/drbd/drbd'
|
||||
dest: '/etc/munin/plugins/'
|
||||
copy:
|
||||
src: munin/drbd-plugin
|
||||
dest: /etc/munin/plugins/drbd
|
||||
mode: "755"
|
||||
notify: restart munin-node
|
||||
|
||||
- name: Copy Munin plugin conf
|
||||
copy:
|
||||
src: files/munin-plugins
|
||||
dest: '/etc/munin/plugin-conf.d/drbd'
|
||||
src: munin/drbd-config
|
||||
dest: /etc/munin/plugin-conf.d/drbd
|
||||
notify: restart munin-node
|
||||
|
|
|
@ -1,6 +1,12 @@
|
|||
---
|
||||
- name: Get Nagios plugin
|
||||
get_url:
|
||||
url: 'https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=3367&cf_id=30'
|
||||
dest: '/usr/local/lib/nagios/plugins/check_drbd'
|
||||
|
||||
- name: Mount /usr in rw
|
||||
command: mount -o remount,rw /usr warn=no
|
||||
changed_when: False
|
||||
|
||||
# https://exchange.nagios.org/components/com_mtree/attachment.php?link_id=3367&cf_id=30
|
||||
- name: Install Nagios plugin
|
||||
copy:
|
||||
src: "nagios/check_drbd"
|
||||
dest: "/usr/local/lib/nagios/plugins/check_drbd"
|
||||
mode: "755"
|
||||
|
|
Loading…
Reference in a new issue