#!/bin/bash
#############################################################
# Name:        Supportconfig Plugin for NOWS SBE Help Desk
# Description: Gathers Help Desk troubleshooting information
# License:     GPLv2
# Author:      Randy Goddard (randage@gmail.com)
#              Jason Record (jrecord@novell.com)
# Modified:    2010 Oct 21
#############################################################

SVER=2.02
RCFILE="/usr/lib/supportconfig/resources/scplugin.rc"
LOG_LINES=0	#0 means include the entire file
LOG_DIR="/var/log/apache2"
CONF_DIR="/srv/www/htdocs/helpdesk/includes"

[ -s $RCFILE ] && . $RCFILE || { echo "ERROR: Initializing resource file: $RCFILE"; exit 1; }

section_header "Supportconfig Plugin for NOWS SBE Help Desk, v${SVER}"

plugin_command "rpm -qa | egrep -i 'apache2|helpdesk' | sort"
RPMLIST=$(rpm -qa | egrep -i 'apache2|helpdesk' | sort)
if [ -z "$RPMLIST" ]; then
  echo "ERROR: Help Desk package(s) not installed"
  echo
  exit 111
fi

for THISRPM in $RPMLIST
do
   validate_rpm $THISRPM
done

for i in apache2
do
	if [ -s /etc/init.d/$i ]; then
		plugin_command "chkconfig -l $i"
		plugin_command "/etc/init.d/$i status"
	fi
done

plugin_command "ps axwwo user,pid,ppid,%cpu,%mem,vsz,rss,stat,time,cmd | egrep 'apache2' | egrep -v 'nowsbe_|grep'"

plugin_command "netstat -nlp | grep httpd"
plugin_command "sed -e '/^\$ldapPassword/d' $CONF_DIR/helpdesk_config.php | sed -e '/^[[:space:]]*$/d;/^#/d'"
FILES=$(find $LOG_DIR -type f)
[ -n "$FILES" ] && plog_files $LOG_LINES $FILES || section_header "No log files found in $LOG_DIR"


