#!/bin/bash # This file is part of Cachewall. # Licensed under Cachewall License Agreement. See: http://cachewall.com/LICENSE # # Gathers Cachewall logs and system information troubleshooting purposes. [ "$UID" -eq 0 ] || { echo "$0 must be run as root"; exit 1; } INSTALL_DIR=/usr/local/xvarnish REP_NAME=$(echo report_`uname -n`_`date -u +%FT%TZ` | tr -cd '[[:alnum:]]_') REP_DIR=$INSTALL_DIR/tmp/$REP_NAME echo -n "Creating report.. " [ ! -d "$REP_DIR" ] && mkdir -p "$REP_DIR" && cd "$REP_DIR" || exit 3 # varnishd shm and syslog messages if ps aux | grep -q varnishd then varnishlog -d -w ./varnishlog.bin fi mkdir ./syslog for logfn in /var/log/messages* do logfn=${logfn##*/} zgrep -E 'hitch|varnishd' /var/log/$logfn > syslog/$logfn [ -s "syslog/$logfn" ] || /bin/rm -f syslog/$logfn done # files cp $INSTALL_DIR/settings ./settings cp $INSTALL_DIR/var/exclusions.json ./exclusions.json cp $INSTALL_DIR/var/ratelimits.json ./ratelimits.json # directories cp -R /var/log/xvarnish ./logs cp -R "$INSTALL_DIR/varnish.conf.d" ./varnish.conf.d cp -R "$INSTALL_DIR/waf.conf.d" ./waf.conf.d # system information rep_log() { [ $# -eq 0 ] && set -- $(> $LOGFILE; } LOGFILE=system.txt rep_log "Date: $(date -R)" rep_log "System: $(uname -a)" rep_log "Packages:" rpm -qa '*varnish*' 2>&1 | rep_log if [ -f /var/cpanel/cpanel.config ] then rep_log "cPanel $(/usr/local/cpanel/cpanel -V)" if [ -f /etc/cpanel/ea4/is_ea4 ] then rep_log "EasyApache 4 is configured" httpdbin=/usr/sbin else rep_log "EasyApache 3 is configured" httpdbin=/usr/local/apache/bin fi if [ -d /usr/local/lsws ] then if [ -f "$httpdbin/httpd_ls_bak" ] then rep_log "LiteSpeed Web Server installed (enabled)" else rep_log "LiteSpeed Web Server installed (disabled)" fi fi rep_log "Apache:" httpd -V 2>&1 | rep_log httpd -M 2>&1 | rep_log else rep_log "cPanel configuration file does not exist." fi # limits LOGFILE=ulimit.txt rep_log "root:" su -c "ulimit -a" -s /bin/bash root | rep_log rep_log "varnish:" su -c "ulimit -a" -s /bin/bash varnish | rep_log # interfaces LOGFILE=interfaces.txt ip addr 2>&1 | rep_log # processes LOGFILE=processes.txt s="varnish|xvhealth|xvstats|stunnel|hitch|xvbeat|xvncsa|nginx|lsws|lshttpd" ps aux | egrep -i "$s" 2>&1 | rep_log # network sockets LOGFILE=network.txt for port in 80 82 443 445 6086 6087 do rep_log "$port:" lsof -Pni :$port -sTCP:LISTEN | rep_log done # create tarball, cleanup cd $REP_DIR && tar -zcf ../$REP_NAME.tgz . && echo "done" || exit 5 cd .. && /bin/rm -rf $REP_NAME || exit 6 echo -e "Provide the archive below in your correspondence with support. You" \ "may simply move it to a web-accessible directory and provide a link." echo -e "\n$REP_DIR.tgz"