]> gitweb.fluxo.info Git - puppet-nodo.git/commitdiff
Adds nodo::subsystem::monitor::interface
authorSilvio Rhatto <rhatto@riseup.net>
Fri, 18 Sep 2015 17:17:05 +0000 (14:17 -0300)
committerSilvio Rhatto <rhatto@riseup.net>
Fri, 18 Sep 2015 17:17:05 +0000 (14:17 -0300)
files/bin/ifcheck [new file with mode: 0755]
manifests/subsystem/monitor.pp
manifests/subsystem/monitor/interface.pp [new file with mode: 0644]

diff --git a/files/bin/ifcheck b/files/bin/ifcheck
new file mode 100755 (executable)
index 0000000..c66f2ad
--- /dev/null
@@ -0,0 +1,19 @@
+#!/bin/bash
+#
+# Check if a network interface is up, fixing if needed.
+#
+
+# Parameters
+BASENAME="`basename $0`"
+IFACE="$1"
+
+# Syntax check
+if [ -z "$IFACE" ]; then
+  echo "usage: $BASENAME <interface>"
+  exit 1
+fi
+
+# Run
+if ! LANG=C LC_ALL=C ifconfig $IFACE | grep -q "inet addr:"; then
+  ifup --force $IFACE
+fi
index 981bf196f75061a3bc4d150d9ad1969bd7a596e3..ebb99e59de0c49a0ac53e616587c698efcc982a3 100644 (file)
@@ -6,6 +6,13 @@ class nodo::subsystem::monitor(
   $check_ssh     = hiera('nodo::subsystem::monitor::check_ssh',     absent),
   $ping_rate     = hiera('nodo::subsystem::monitor::ping_rate',     '!100.0,20%!500.0,60%')
 ) {
+  file { '/usr/local/sbin/ifcheck' :
+    ensure  => present,
+    owner   => 'root',
+    group   => 'root',
+    mode    => '0755',
+    source  => 'puppet:///modules/nodo/bin/ifcheck',
+  }
 
   if $use_nagios != false {
 
diff --git a/manifests/subsystem/monitor/interface.pp b/manifests/subsystem/monitor/interface.pp
new file mode 100644 (file)
index 0000000..102f5b2
--- /dev/null
@@ -0,0 +1,14 @@
+define nodo::subsystem::monitor::interface(
+  $ensure = 'present'
+  $hour   = "*",
+  $minute = "*",
+)
+{
+  cron { "ifcheck-${name}":
+    command => "/usr/local/sbin/ifcheck ${name}",
+    user    => 'root',
+    hour    => $hour,
+    minute  => $minute,
+    ensure  => $ensure,
+  }
+}