A newbie in scripting is trying to run the script bellow but keep getting an error message ;
syntax error at line 76 : `<<' unmatched
what we have on that area pointed to is highlighted in red bellow:
##################################################
fi
# Memory Performance (vmstat - sr column)
# The experts say that when the 'sr' or scan rate column reaches above #200,
# the system is scanning through memory looking for pages to free at a #high
# rate. This indicates active pages might be stolen from processes. A high
# scan rate can cause your system to consume more cpu resources than it
# normally would.
if [ "$MEMSTAT" -gt "200" ]; then
mail $MAILADD <<EOF
From:$SRVNM
To: $MAILADD
Subject: Memory Performance on $SRVNM
According to vmstat, the scanrate on $SRVNM is
$MEMSTAT. This indicates that there is not enough
memory to meet the server's current load.
EOF
################################################
i think in my own dummy way that the satisfy the code example stated bellow by jim mcnamara. I am a bit confused because the same format was used for others. for clearity purpose i hereby copy the whole scripts for you the forum to help me debug and tell me what is wrong.
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
#!/bin/ksh
#
# Solaris 2.X Performance Monitoring Script
# Purpose: This script executes performance commands and notifies via
# e-mail when performance is poor.
# Useage: Execute the script from crontab at 30 minute intervals.
# Dependencies: None
# Outputs: Logfiles and e-mail
# CRONTAB EXAMPLE (Mon - Fri 7am - 6pm):
# 17,47 7-18 * * 1-5 /opt/admin/scripts/mon_prf.sh
#
#**************************************************************************
PATH=$PATH:/usr/sbin:/usr/bin
# Define the server's hostname
SRVNM=`uname -n`
# The directory this script resides in
ADMINDIR=/opt/admin/scripts
# Create log directory
DATDIR=/var/adm/log/mon_perf
if [ ! -d $DATDIR ] ; then
mkdir -p $DATDIR
fi
# The next variable can be set for multiple addresses
MAILADD=tunji.salami@anglia.ac.uk
# vmstat VMDAT=`vmstat 1 2 | tail -1`
# CPU Performance (vmstat - r column)
# When the 'r' or run queue column reaches above 3 processes per CPU,
# there is insufficient CPU power, and jobs are spending an
# increasing amount of time in the queue before being assigned to a CPU.
# This reduces throughput and increases interactive response time.
CPUPERF=`echo $VMDAT | awk '{ print $1 }'`
if [ "$CPUPERF" -gt "3" ]; then
mail $MAILADD <<EOF
From:$SRVNM
To: $MAILADD
Subject: CPU Performance on $SRVNM
The vmstat run queue column has exceeded 3 processes per CPU on $SRVNM. There is insufficient CPU power for the load placed
on the server.
EOF
fi
# CPU Performance (vmstat - cpu id column)
# The cpu id column indicates what % the cpu is idle
CPUSTAT=`echo $VMDAT | awk '{ print $22 }`
if [ "$CPUSTAT" -lt "10" ]; then
mail $MAILADD <<EOF
From:$SRVNM
To: $MAILADD
Subject: CPU Performance on $SRVNM
The vmstat cpu id column is less than 10 on $SRVNM.
The CPU is idle $CPUSTAT % of the time.
EOF
fi
# Memory Performance (vmstat - sr column)
# The experts say that when the 'sr' or scan rate column reaches above 200,
# the system is scanning through memory looking for pages to free at a high
# rate. This indicates active pages might be stolen from processes. A high
# scan rate can cause your system to consume more cpu resources than it
# normally would.
MEMSTAT=`echo $VMDAT | tail -1 | awk '{ print $12 }'`
if [ "$MEMSTAT" -gt "200" ]; then
mail $MAILADD <<EOF
From:$SRVNM
To: $MAILADD
Subject: Memory Performance on $SRVNM
According to vmstat, the scanrate on $SRVNM is
$MEMSTAT. This indicates that there is not enough
memory to meet the server's current load.
EOF
fi
# TCP Connections
# TCPCON=`netstat -aP tcp | tail +39 | wc -l`
if [ "$TCPCON" -gt "900" ]; then
mail $MAILADD <<EOF
From:$SRVNM
To: $MAILADD
Subject: TCP Connections on $SRVNM
According to netstat -a, there are currently $TCPCON
TCP connections on $SRVNM. This may or may not be cause for concern.
EOF
fi
# NIC Input Errors
#
# netstat -i
#NETIDAT=`netstat -i | grep ce0`
#NICIE=`echo $NETIDAT | awk {'print $6'}`
# if [ "$NICIE" -gt "10" ]; then
# mail $MAILADD <<EOF
#From:$SRVNM
#To: $MAILADD
#Subject: NIC Input Errors on $SRVNM
#According to netstat -i, there are currently $NICIE
#input errors on $SRVNM ce0 NIC.
#EOF
#fi
# NIC Output Errors
#
#NICOE=`echo $NETIDAT | awk {'print $8'}`
# if [ "$NICOE" -gt "10" ]; then
# mail $MAILADD <<EOF
#From: $SRVNM
#To: $MAILADD
#Subject: NIC Output Errors on $SRVNM
#According to netstat -i, there are currently $NICOE
#output errors on $SRVNM ce0 NIC.
#EOF
#fi
# iostat
# Disk performance
# Create iostat data file
#DATFILE=$DATDIR/iostat.dat
#cp $DATFILE $DATFILE.old
#cp /dev/null $DATFILE
# Checking the iostat util column
#IODAT=`iostat -Dl 20 -n | tail -1`
#DSKSTAT=`echo $IODAT | awk '{ print $3, $6, $9, $12, $15, $18, $21, $24, $27, $ 30, $33, $36, $39, $42, $45, $48, $51, $54,
$57, $60 }'`
# Will need to edit the next line to resolve this problem
#echo $DSKSTAT >> $DATFILE
#cat iostat.dat | awk {'print $2'}
#while read -r
#do
# if [ "$REPLY" -gt "3" ]; then
# mail $MAILADD <<EOF
#From: $SRVNM
#To: $MAILADD
#Subject: Disk Performance on $SRVNM
#According to iostat, the disk utilization on $SRVNM is
#greater than 3 on one of the server's hard disks. This
#indicates that the disk is being heavily used.
#EOF
#fi
#done < $DATFILE
# netstat
# CPU Data
#mpstat
# swap
#swap -l
# /tmp (Running out of swap space)
# du -sk /tmp
exit 0
#
if [ "$MEMSTAT" -gt "200" ]; then
mail $MAILADD <<EOF
echo "
From:$SRVNM
To: $MAILADD
Subject: Memory Performance on $SRVNM
According to vmstat, the scanrate on $SRVNM is
$MEMSTAT. This indicates that there is not enough
memory to meet the server's current load. "
EOF
Let know how it goes. Atleast if you get another error, we can resolve the problem.