Alexandros Kosiaris has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/124841

Change subject: Improve the check_eth check
......................................................................

Improve the check_eth check

This improves the check_eth script introduced in

700cb5f6512aa151f99a99c672395d3b09d5a2dd

by adding the ideas presented in

Id5130db48c14b87752197ce8f0b022ef13e40e4b

The idea is to have a single check and not two and at the same time make
sure the entire infrastructure is working as configured

Change-Id: I4a7a2c71be40941f812c4bcfa49c7ccb25ab36db
---
M manifests/role/nova.pp
M modules/base/manifests/monitoring/host.pp
A modules/base/templates/check_eth.erb
D modules/nrpe/files/plugins/check_eth
4 files changed, 38 insertions(+), 26 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/operations/puppet 
refs/changes/41/124841/1

diff --git a/manifests/role/nova.pp b/manifests/role/nova.pp
index dba7edc..97ee37e 100644
--- a/manifests/role/nova.pp
+++ b/manifests/role/nova.pp
@@ -436,11 +436,6 @@
                }
        }
 
-       nrpe::monitor_service {'check_eth':
-               description => 'check eth1 is present and connected',
-               nrpe_command => '/usr/local/lib/nagios/plugins/check_eth "eth1"'
-       }
-
        class { "openstack::compute-service": openstack_version => 
$openstack_version, novaconfig => $novaconfig }
 
        if $realm == "labs" {
diff --git a/modules/base/manifests/monitoring/host.pp 
b/modules/base/manifests/monitoring/host.pp
index 1b890f6..925480b 100644
--- a/modules/base/manifests/monitoring/host.pp
+++ b/modules/base/manifests/monitoring/host.pp
@@ -54,11 +54,11 @@
         source => 'puppet:///modules/base/monitoring/check_puppet_disabled';
     }
     file { '/usr/local/lib/nagios/plugins/check_eth':
-        ensure => present,
-        owner  => 'root',
-        group  => 'root',
-        mode   => '0555',
-        source => 'puppet:///modules/nrpe/plugins/check_eth';
+        ensure  => present,
+        owner   => 'root',
+        group   => 'root',
+        mode    => '0555',
+        content => template('nrpe/check_eth.erb'),
     }
 
     sudo_user { 'nagios':
@@ -95,4 +95,8 @@
         description  => 'puppet disabled',
         nrpe_command => '/usr/local/lib/nagios/plugins/check_puppet_disabled',
     }
+    nrpe::monitor_service {'check_eth':
+        description  => 'check configured eth',
+        nrpe_command => '/usr/local/lib/nagios/plugins/check_eth',
+    }
 }
diff --git a/modules/base/templates/check_eth.erb 
b/modules/base/templates/check_eth.erb
new file mode 100755
index 0000000..ca8cb60
--- /dev/null
+++ b/modules/base/templates/check_eth.erb
@@ -0,0 +1,29 @@
+#!/bin/sh
+EXIT_CODE=0
+for INTERFACE in <%= @interfaces.split(',', ' ') %> ; do
+       IFACE=${INTERFACE%:*}
+       REQ_SPEED=${INTERFACE#*:}
+       if [ $IFACE = $REQ_SPEED ]; then
+       REQ_SPEED=1000 # The default for now
+       fi
+       STATUS=`ip link show ${IFACE}`
+       if [ "$?" != "0" ]; then
+               echo "${IFACE} not found. This should never happen. Bailing out"
+               exit 1
+       fi
+       if echo ${STATUS} | grep -q "NO-CARRIER"
+       then
+               echo "${IFACE} reporting no carrier."
+               EXIT_CODE=2
+       fi
+       if echo ${STATUS} | grep -q "DOWN"
+       then
+               continue
+       fi
+       CONF_SPEED=$(/sbin/ethtool $IFACE | awk '/Speed:/ 
{gsub("Mb/s","",$2);print $2}')
+       if [ $REQ_SPEED -ne $CONF_SPEED ]; then
+               echo "${IFACE} has different negotiated speed than requested"
+               EXIT_CODE=1
+       fi
+done
+exit $EXIT_CODE
diff --git a/modules/nrpe/files/plugins/check_eth 
b/modules/nrpe/files/plugins/check_eth
deleted file mode 100755
index a2a458d..0000000
--- a/modules/nrpe/files/plugins/check_eth
+++ /dev/null
@@ -1,16 +0,0 @@
-#!/bin/sh
-for INTERFACE in $1; do
-       STATUS=`ip link show ${INTERFACE}`
-       if [ "$?" != "0" ]
-       then
-               echo "${INTERFACE} not found"
-               exit 2
-       fi
-       if echo ${STATUS} | grep "NO-CARRIER"
-       then
-               echo "${INTERFACE} reporting no carrier."
-               exit 2
-       fi
-done
-
-exit 0

-- 
To view, visit https://gerrit.wikimedia.org/r/124841
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I4a7a2c71be40941f812c4bcfa49c7ccb25ab36db
Gerrit-PatchSet: 1
Gerrit-Project: operations/puppet
Gerrit-Branch: production
Gerrit-Owner: Alexandros Kosiaris <akosia...@wikimedia.org>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to