diff options
| author | Silvio Rhatto <rhatto@riseup.net> | 2015-09-18 14:17:05 -0300 | 
|---|---|---|
| committer | Silvio Rhatto <rhatto@riseup.net> | 2015-09-18 14:17:05 -0300 | 
| commit | d09f347afc0a99481673f227f83864d06206add6 (patch) | |
| tree | 867eba743474f4d460ade4f2b5e04903f6e4ad17 | |
| parent | 94529422ec6736f9beaa1dc44540645b28925101 (diff) | |
| download | puppet-nodo-d09f347afc0a99481673f227f83864d06206add6.tar.gz puppet-nodo-d09f347afc0a99481673f227f83864d06206add6.tar.bz2  | |
Adds nodo::subsystem::monitor::interface
| -rwxr-xr-x | files/bin/ifcheck | 19 | ||||
| -rw-r--r-- | manifests/subsystem/monitor.pp | 7 | ||||
| -rw-r--r-- | manifests/subsystem/monitor/interface.pp | 14 | 
3 files changed, 40 insertions, 0 deletions
diff --git a/files/bin/ifcheck b/files/bin/ifcheck new file mode 100755 index 0000000..c66f2ad --- /dev/null +++ b/files/bin/ifcheck @@ -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 diff --git a/manifests/subsystem/monitor.pp b/manifests/subsystem/monitor.pp index 981bf19..ebb99e5 100644 --- a/manifests/subsystem/monitor.pp +++ b/manifests/subsystem/monitor.pp @@ -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 index 0000000..102f5b2 --- /dev/null +++ b/manifests/subsystem/monitor/interface.pp @@ -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, +  } +}  | 
