From 6daf5cffbfd7c64723561d18f8de443a730795a8 Mon Sep 17 00:00:00 2001 From: VC Date: Fri, 5 Jul 2024 11:53:06 +0200 Subject: [PATCH] Ajout des variables pour la surveillance du Switch --- .../host_vars/munin.dmz.mateu.be.yml | 2 - roles/munin-client/files/mikrotikdiskspace_ | 59 ------------------- roles/munin-client/files/mikrotikmemory_ | 59 ------------------- roles/munin-server/templates/munin.conf.j2 | 5 ++ 4 files changed, 5 insertions(+), 120 deletions(-) rename roles/munin-client/vars/main.yml => production/host_vars/munin.dmz.mateu.be.yml (93%) delete mode 100644 roles/munin-client/files/mikrotikdiskspace_ delete mode 100644 roles/munin-client/files/mikrotikmemory_ diff --git a/roles/munin-client/vars/main.yml b/production/host_vars/munin.dmz.mateu.be.yml similarity index 93% rename from roles/munin-client/vars/main.yml rename to production/host_vars/munin.dmz.mateu.be.yml index 75c41ac..65a8a7a 100644 --- a/roles/munin-client/vars/main.yml +++ b/production/host_vars/munin.dmz.mateu.be.yml @@ -1,7 +1,5 @@ mikrotik_unitary_scripts: - mikrotikcpu_ - - mikrotikdiskspace_ - - mikrotikmemory_ - mikrotikvoltage_ mikrotik_periface_scripts: diff --git a/roles/munin-client/files/mikrotikdiskspace_ b/roles/munin-client/files/mikrotikdiskspace_ deleted file mode 100644 index ad609f5..0000000 --- a/roles/munin-client/files/mikrotikdiskspace_ +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/perl -############################################################################### -use diagnostics; -use Net::SNMP; -use strict; -use warnings; -############################################################################### -my $DiskTotalOID = ".1.3.6.1.2.1.25.2.3.1.5.1"; -my $DiskUsedOID = ".1.3.6.1.2.1.25.2.3.1.6.1"; -my $SNMPCommunity = "public"; -my $SNMPPort = "161"; - -############################################################################### -## Determine Hostname -my $Host = undef; -$0 =~ /mikrotikdiskspace_(.+)*$/; -unless ($Host = $1) { - exit 2; -} - -############################################################################### -## Initiate SNMP Session -my ($Session, $Error) = Net::SNMP->session (-hostname => $Host, - -community => $SNMPCommunity, - -port => $SNMPPort, - -timeout => 60, - -retries => 5, - -version => 1); -if (!defined($Session)) { - die "Croaking: $Error"; -} - -############################################################################### -## Configuration -if ($ARGV[0] && $ARGV[0] eq "config") { - my $Result = $Session->get_request(-varbindlist => [$DiskTotalOID]); - print "host_name " . $Host . "\n"; - print "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit " . ($Result->{$DiskTotalOID} * 1024) . "\n"; - print "graph_title Disk Space usage\n"; - print "graph_category system\n"; - print "graph_info This graph shows the router's Disk Space usage.\n"; - print "graph_order Total Used\n"; - print "graph_vlabel bytes\n"; - print "Total.label Total Disk Space\n"; - print "Total.draw AREA\n"; - print "Used.label Used Disk Space\n"; - print "Used.draw AREA\n"; - $Session->close; - exit; -} - -############################################################################### -## Execution -if (my $Result = $Session->get_request(-varbindlist => [$DiskTotalOID, $DiskUsedOID])) { - print "Total.value " . ($Result->{$DiskTotalOID} * 1024) . "\n"; - print "Used.value " . ($Result->{$DiskUsedOID} * 1024) . "\n"; - $Session->close; - exit; -} diff --git a/roles/munin-client/files/mikrotikmemory_ b/roles/munin-client/files/mikrotikmemory_ deleted file mode 100644 index fd58d7b..0000000 --- a/roles/munin-client/files/mikrotikmemory_ +++ /dev/null @@ -1,59 +0,0 @@ -#!/usr/bin/perl -############################################################################### -use diagnostics; -use Net::SNMP; -use strict; -use warnings; -############################################################################### -my $MemTotalOID = ".1.3.6.1.2.1.25.2.3.1.5.2"; -my $MemUsedOID = ".1.3.6.1.2.1.25.2.3.1.6.2"; -my $SNMPCommunity = "public"; -my $SNMPPort = "161"; - -############################################################################### -## Determine Hostname -my $Host = undef; -$0 =~ /mikrotikmemory_(.+)*$/; -unless ($Host = $1) { - exit 2; -} - -############################################################################### -## Initiate SNMP Session -my ($Session, $Error) = Net::SNMP->session (-hostname => $Host, - -community => $SNMPCommunity, - -port => $SNMPPort, - -timeout => 60, - -retries => 5, - -version => 1); -if (!defined($Session)) { - die "Croaking: $Error"; -} - -############################################################################### -## Configuration -if ($ARGV[0] && $ARGV[0] eq "config") { - my $Result = $Session->get_request(-varbindlist => [$MemTotalOID]); - print "host_name " . $Host . "\n"; - print "graph_args --base 1024 -l 0 --vertical-label Bytes --upper-limit " . ($Result->{$MemTotalOID} * 1024) . "\n"; - print "graph_title Memory usage\n"; - print "graph_category system\n"; - print "graph_info This graph shows the router's memory usage.\n"; - print "graph_order Total Used\n"; - print "graph_vlabel bytes\n"; - print "Total.label Total Memory\n"; - print "Total.draw AREA\n"; - print "Used.label Used Memory\n"; - print "Used.draw AREA\n"; - $Session->close; - exit; -} - -############################################################################### -## Execution -if (my $Result = $Session->get_request(-varbindlist => [$MemTotalOID, $MemUsedOID])) { - print "Total.value " . ($Result->{$MemTotalOID} * 1024) . "\n"; - print "Used.value " . ($Result->{$MemUsedOID} * 1024) . "\n"; - $Session->close; - exit; -} diff --git a/roles/munin-server/templates/munin.conf.j2 b/roles/munin-server/templates/munin.conf.j2 index 27d4d12..98e87f9 100644 --- a/roles/munin-server/templates/munin.conf.j2 +++ b/roles/munin-server/templates/munin.conf.j2 @@ -101,6 +101,11 @@ includedir /etc/munin/munin-conf.d address {{ hostvars[host]['ansible_default_ipv4']['address'] }} {% endfor %} +{% for host in mikrotik_hosts %} +[{{ host.name }}] + address 127.0.0.1 +{% endfor %} + # # A more complex example of a host tree #