Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- ###########################################################################
- ## Script to create conf files and script links on a Plesk
- ## server that monitor all the apache log files
- ##
- ## Visit blog.surgeons.org.uk for updates
- ##
- ## mod jrc 280313 - rob cain - http://systemcore.co.uk :
- ## created this working version (scl_mk_vhosts_logwatch_configs.sh)
- ## from original draft http://blog.surgeons.org.uk/2008/02/monitoring-all-virtual-hosts-on-plesk.html
- ## by Neville Dastur (160208)
- ##
- ############################################################################
- ## Location of the virtual hosts directories
- vhost_root=/var/www/vhosts/
- ## Various logwatch directories
- dir_services="/etc/logwatch/conf/services"
- dir_logfiles="/etc/logwatch/conf/logfiles"
- dir_scripts="/etc/logwatch/scripts/services"
- http_script="/usr/share/logwatch/scripts/services/http"
- ## Now iter over each directory
- for domain in $( ls -Ichroot -Idefault $vhost_root ); do
- if [ -d "${vhost_root}${domain}" ]
- then
- echo "Making services logwatch enteries for ${domain}"
- domain_us=`echo $domain | tr . _ | tr '[:upper:]' '[:lower:]'`
- (
- cat << END_OF_SERVICES_CONF
- ###########################################################################
- # Configuration file for $domain http filter
- # See blog.surgeons.org.uk for updates ###########################################################################
- Title = "httpd - $domain"
- # Which logfile group...
- LogFile = http_$domain_us
- END_OF_SERVICES_CONF
- ) > ${dir_services}/http_${domain_us}.conf
- echo "Making logfiles logwatch entries for ${domain}"
- (
- cat << END_OF_LOGFILES_CONF
- ########################################################
- # Define log file group for http_$domain_us
- # See blog.surgeons.org.uk for updates
- #######################################################
- LogFile = /var/www/vhosts/$domain/statistics/logs/access_log
- LogFile = /var/www/vhosts/$domain/statistics/logs/access_log.processed
- LogFile = /var/www/vhosts/$domain/statistics/logs/access_ssl_log
- LogFile = /var/www/vhosts/$domain/statistics/logs/access_ssl_log.processed
- # If the archives are searched, here is one or more line
- # (optionally containing wildcards) that tell where they are...
- # If you use a "-" in naming add that as well -mgt
- Archive = /var/www/vhosts/$domain/statistics/logs/access_log.processed.?.gz
- Archive = /var/www/vhosts/$domain/statistics/logs/access_ssl__log.processed.?.gz
- # Expand the repeats (actually just removes them now)
- *ExpandRepeats
- # Keep only the lines in the proper date range...
- *ApplyhttpDate
- END_OF_LOGFILES_CONF
- ) > ${dir_logfiles}/http_${domain_us}.conf
- ## Make the script links
- echo "Creating script link for ${domain}"
- ln -s ${http_script} ${dir_scripts}/http_${domain_us}
- fi
- done
Add Comment
Please, Sign In to add comment