Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tingletech
Created April 5, 2012 02:17
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tingletech/2307485 to your computer and use it in GitHub Desktop.
Save tingletech/2307485 to your computer and use it in GitHub Desktop.
CDL Log Rotation Policy Compliance on stock SUSE SLES vm
set daemon 30
set logfile syslog facility log_daemon
#set logfile ${HOME}/servers/monit/logs/monit.log
set mailserver localhost
set mail-format { from: xxx@xxx-stg.example.org }
set alert osc@localhost but not on { instance, action }
set httpd port 2812
allow localhost
allow 127.0.0.1
check system xxx-stg.example.org
if loadavg (1min) > 10 then alert
if loadavg (5min) > 5 then alert
if memory usage > 98% then alert
if swap usage > 95% then alert
if cpu usage (user) > 90% for 5 cycles then alert
if cpu usage (system) > 90% then alert
if cpu usage (wait) > 70% then alert
check process apache with pidfile /apps/xxx/apache/logs/httpd.pid
group www
start program = "/apps/xxx/apache/bin/apachectl start"
stop program = "/apps/xxx/apache/bin/apachectl stop"
if failed host xxx-stg.example.org port 80
protocol HTTP request "/" then restart
if 5 restarts within 5 cycles then timeout
depends on apache_bin
check file apache_bin with path /usr/sbin/httpd2
group www
if failed checksum then unmonitor
if failed permission 755 then unmonitor
if failed uid root then unmonitor
if failed gid root then unmonitor
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\" %T" cdlstandard
ErrorLog "|/usr/sbin/rotatelogs2 -f -l /apps/xxx/apache/logs/error.%Y.%m.%d 86400"
CustomLog "|usr/sbin/rotatelogs2 -f -l /apps/xxx/apache/logs/access.%Y.%m.%d 86400" cdlstandard
# ...
Alias /logs/ "/apps/xxx/apache/logs/"
<Directory "/apps/xxx/apache/logs">
Options Indexes
AllowOverride None
Order deny,allow
Deny from all
Allow from stats.cdlib.org
</Directory>
#!/usr/bin/env bash
# 1:07 am
# 7 1 * * * if [ -x /apps/xxx/bin/nightly ] ; then /apps/xxx/bin/nightly ; fi
set -e
set -u
# remove older log files
find /apps/xxx/apache/logs/ \( -name "access.????.??.??.gz" -o -name "error.????.??.??.gz" \) -mtime +32 -exec /bin/rm {} \;
# compress files older than 2 weeks
find /apps/xxx/apache/logs/ -type f -name "*.????.??.??" -mtime +16 -exec /bin/gzip {} \;
#
### BEGIN INIT INFO
# Provides: monit
# Required-Start: $network $syslog
# Required-Stop:
# Default-Start: 2 3 5
# Default-Stop: 0 1 2 6
# Description: Start and stop monit
### END INIT INFO
#
case "$1" in
start)
echo
echo ">>> Loading monit..."
echo
/bin/su xxx -c '/cdlcommon/products/bin/monit'
sleep 30
/bin/su xxx -c '/cdlcommon/products/bin/monit start all'
#
#
;;
stop)
echo
echo ">>> Stopping monit..."
echo
/bin/su xxx -c '/cdlcommon/products/bin/monit stop all'
/bin/su xxx -c '/cdlcommon/products/bin/monit quit'
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment