From c11149a87323cf96cf467eece9befc381cc8e7bf Mon Sep 17 00:00:00 2001 From: Gabriel Detraz Date: Mon, 26 Jan 2015 18:33:13 +0100 Subject: [PATCH] Ajout du support de monit --- files/etc/init.d/monit | 17 +++++++++++++ files/etc/monitrc | 57 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 74 insertions(+) create mode 100755 files/etc/init.d/monit create mode 100644 files/etc/monitrc diff --git a/files/etc/init.d/monit b/files/etc/init.d/monit new file mode 100755 index 0000000000..f8d355367a --- /dev/null +++ b/files/etc/init.d/monit @@ -0,0 +1,17 @@ +#!/bin/sh /etc/rc.common +# Copyright (C) 2006-2012 OpenWrt.org + +START=60 + +SERVICE_USE_PID=1 + +start() { + [ -f /etc/monitrc ] || return 1 + ls -l /etc/monitrc | grep -q '^-rw-------' + [ $? -eq 0 ] || chmod 0700 /etc/monitrc + service_start /usr/bin/monit +} + +stop() { + service_stop /usr/bin/monit +} diff --git a/files/etc/monitrc b/files/etc/monitrc new file mode 100644 index 0000000000..610ed1644e --- /dev/null +++ b/files/etc/monitrc @@ -0,0 +1,57 @@ +############################################################################### +## Monit Cr@ns Config ! +############################################################################### +## +## Start Monit in the background (run as a daemon): +# +set daemon 60 # check services at 1-minute intervals + with start delay 30 # optional: delay the first check by 4-minutes (by +# # default Monit check immediately after Monit start) + +set logfile syslog facility log_daemon +#set logfile /tmp/monit_log # Test logging +# +## Set the location of the Monit id file which stores the unique id for the +## Monit instance. The id is generated and stored on first Monit start. By +## default the file is placed in $HOME/.monit.id. +# +set idfile /var/.monit.id + +# Bind and authorize only to localhost: +set httpd port 2812 and + use address localhost + allow localhost + +# +## Set the location of the Monit state file which saves monitoring states +## on each cycle. By default the file is placed in $HOME/.monit.state. If +## the state file is stored on a persistent filesystem, Monit will recover +## the monitoring state across reboots. If it is on temporary filesystem, the +## state will be lost on reboot which may be convenient in some situations. +# +set statefile /var/.monit.state + +## Check hostapd +check process hostapd-0 with pidfile /var/run/wifi-phy0.pid + start program = "/usr/sbin/hostapd -P /var/run/wifi-phy0.pid -B /var/run/hostapd-phy0.conf" with timeout 60 seconds + stop program = "/usr/bin/killall hostapd" + if 5 restarts within 5 cycles then timeout + +check process hostapd-1 with pidfile /var/run/wifi-phy1.pid + start program = "/usr/sbin/hostapd -P /var/run/wifi-phy1.pid -B /var/run/hostapd-phy1.conf" with timeout 60 seconds + stop program = "/usr/bin/killall hostapd" + if 5 restarts within 5 cycles then timeout + +check process sshd with pidfile /var/run/dropbear.1.pid + start program "/etc/init.d/dropbear start" + stop program "/etc/init.d/dropbear stop" + if failed port 22 protocol ssh then restart + if 5 restarts within 5 cycles then timeout + +check program watch_net with path "/usr/share/watch_net/watch_net.sh" + if status != 0 then alert + +check process logread with pidfile /var/run/logread.2.pid + start program "/etc/init.d start" + stop program "/etc/init.d stop" + if 5 restarts within 5 cycles then timeout