From dd9a6048bb109494072d94281701ad9734d2b275 Mon Sep 17 00:00:00 2001 From: My Name Date: Thu, 11 Dec 2014 00:47:01 +0100 Subject: Added ZNC init + monit script, rtorrent + zabbix-server monit config and fixed typos --- initrc/rtorrent | 36 ++++++++++++++++++++++++++++++++++++ initrc/znc | 37 +++++++++++++++++++++++++++++++++++++ monit/memcached.conf | 2 +- monit/nginx-vhost.conf | 2 +- monit/rtorrent.conf | 10 ++++++++++ monit/zabbix-server.conf | 7 +++++++ monit/znc.conf | 5 +++++ rtorrent/init.sh | 36 ------------------------------------ 8 files changed, 97 insertions(+), 38 deletions(-) create mode 100755 initrc/rtorrent create mode 100755 initrc/znc create mode 100644 monit/rtorrent.conf create mode 100644 monit/zabbix-server.conf create mode 100644 monit/znc.conf delete mode 100755 rtorrent/init.sh diff --git a/initrc/rtorrent b/initrc/rtorrent new file mode 100755 index 0000000..7f36a74 --- /dev/null +++ b/initrc/rtorrent @@ -0,0 +1,36 @@ +#!/bin/bash +set -e + +RTORRENTUSER="horus" +NAME=rtorrent +DESC="rtorrent, a cli bittorrent client." + +DAEMON="/usr/bin/rtorrent" +SCREEN="/usr/bin/screen" + +PIDFILE="/var/run/${NAME}.pid" + +START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --chuid $RTORRENTUSER --exec $SCREEN -- -DmUS ${NAME} ${DAEMON}" +END_OPTS="--stop --pidfile ${PIDFILE}" + +case "$1" in + start) + echo "Starting ${DESC}" + start-stop-daemon $START_OPTS + ;; + stop) + echo "Stopping ${DESC}" + start-stop-daemon $END_OPTS + rm -f "${PIDFILE}" + ;; + restart) + "$0" stop + rm -f "${PIDFILE}" + sleep 1 + "$0" start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac diff --git a/initrc/znc b/initrc/znc new file mode 100755 index 0000000..7f7bcb0 --- /dev/null +++ b/initrc/znc @@ -0,0 +1,37 @@ +#!/bin/bash +set -e + +USER="horus" +DATADIR="/home/${USER}/.znc" +NAME=znc +DESC="ZNC, the IRC Bouncer" + +DAEMON="/usr/bin/znc" +DAEMON_OPTS="--foreground --datadir=$DATADIR" + +PIDFILE="/var/run/${NAME}.pid" + +START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --chuid $USER" +END_OPTS="--stop --pidfile ${PIDFILE}" + +case "$1" in + start) + echo "Starting ${DESC}" + start-stop-daemon $START_OPTS --exec ${DAEMON} -- $DAEMON_OPTS + ;; + stop) + echo "Stopping ${DESC}" + start-stop-daemon $END_OPTS + rm -f "${PIDFILE}" + ;; + restart) + "$0" stop + rm -f "${PIDFILE}" + sleep 1 + "$0" start + ;; + *) + echo "Usage: $0 {start|stop|restart}" + exit 1 + ;; +esac diff --git a/monit/memcached.conf b/monit/memcached.conf index 49f8875..947b632 100644 --- a/monit/memcached.conf +++ b/monit/memcached.conf @@ -1,4 +1,4 @@ -check process with pidfile /var/run/memcached.pid +check process memcached with pidfile /var/run/memcached.pid start program = "/etc/init.d/memcached start" stop program = "/etc/init.d/memcached stop" if failed host localhost port 11211 protocol MEMCACHE then restart diff --git a/monit/nginx-vhost.conf b/monit/nginx-vhost.conf index 1a33323..a34ea1a 100644 --- a/monit/nginx-vhost.conf +++ b/monit/nginx-vhost.conf @@ -1,6 +1,6 @@ server { listen 443 ssl; - server_name monit.example.org + server_name monit.example.org; ssl_certificate /etc/nginx/ssl/example.crt; ssl_certificate_key /etc/nginx/ssl/example.key; diff --git a/monit/rtorrent.conf b/monit/rtorrent.conf new file mode 100644 index 0000000..052498c --- /dev/null +++ b/monit/rtorrent.conf @@ -0,0 +1,10 @@ +check process rtorrent with pidfile "/var/run/rtorrent.pid" + start program = "/etc/init.d/rtorrent start" + stop program = "/etc/init.d/rtorrent stop" + if 2 restarts within 3 cycles then timeout + if totalmem > 100 Mb then alert + if children > 255 for 5 cycles then stop + if cpu usage > 95% for 3 cycles then restart + if failed host 127.0.0.1 port 5000 then restart + if 3 restarts within 3 cycles then alert + if 5 restarts within 5 cycles then timeout diff --git a/monit/zabbix-server.conf b/monit/zabbix-server.conf new file mode 100644 index 0000000..7f75704 --- /dev/null +++ b/monit/zabbix-server.conf @@ -0,0 +1,7 @@ +check process zabbix_server with pidfile /var/run/zabbix/zabbix_server.pid + start program = "/etc/init.d/zabbix-server start" + stop program = "/etc/init.d/zabbix-server stop" + if failed port 10051 type tcp for 3 times within 5 cycles then alert + if failed port 10051 type tcp for 5 times within 10 cycles then restart + if 3 restarts within 3 cycles then alert + if 5 restarts within 5 cycles then timeout diff --git a/monit/znc.conf b/monit/znc.conf new file mode 100644 index 0000000..b4c4d4d --- /dev/null +++ b/monit/znc.conf @@ -0,0 +1,5 @@ +check process ZNC with pidfile /var/run/znc.pid + start program = "/etc/init.d/znc start" + stop program = "/etc/init.d/znc stop" + if failed host localhost port 9999 then restart + if 5 restarts within 5 cycles then timeout diff --git a/rtorrent/init.sh b/rtorrent/init.sh deleted file mode 100755 index 7f36a74..0000000 --- a/rtorrent/init.sh +++ /dev/null @@ -1,36 +0,0 @@ -#!/bin/bash -set -e - -RTORRENTUSER="horus" -NAME=rtorrent -DESC="rtorrent, a cli bittorrent client." - -DAEMON="/usr/bin/rtorrent" -SCREEN="/usr/bin/screen" - -PIDFILE="/var/run/${NAME}.pid" - -START_OPTS="--start --background --make-pidfile --pidfile ${PIDFILE} --chuid $RTORRENTUSER --exec $SCREEN -- -DmUS ${NAME} ${DAEMON}" -END_OPTS="--stop --pidfile ${PIDFILE}" - -case "$1" in - start) - echo "Starting ${DESC}" - start-stop-daemon $START_OPTS - ;; - stop) - echo "Stopping ${DESC}" - start-stop-daemon $END_OPTS - rm -f "${PIDFILE}" - ;; - restart) - "$0" stop - rm -f "${PIDFILE}" - sleep 1 - "$0" start - ;; - *) - echo "Usage: $0 {start|stop|restart}" - exit 1 - ;; -esac -- cgit v1.2.3