Hello All,
I need help here with a script. I have a script here which generates a html output with set of commands and is working fine.
Now i want to add a new command/function which would run on all the remote blades and output should be included in this html file. Here is the script
#!/bin/bash
#########################################################################################################
# Shellscript : my_script.sh - Generate HTML Output of System Stats
# Version : V1.0
# Owner : Siddhesh Khavnekar <siddhesh.khavnekar@mobixell.com>
# Date : 2012-09-10
# Category : Files Management
#########################################################################################################
# Description : This scipt will collect system stats from all blades and put that in a HTML file.
#
#########################################################################################################
# make_page - A script to produce an HTML file
####Constants
TITLE=" System Information for ALL BLADES"
RIGHT_NOW=$(date +"%x %r %Z")
TIME_STAMP="Updated on $RIGHT_NOW by $USER"
if [ $(id -u) != "501" ]; then
echo "You must be "XMP" to run this script" >&2
exit 1
fi
###Functions
#function Show_Sar
#{
# echo "<h2>CPU Usage for All Blade in last 2 hours</h2>"
# echo "<pre>"
# onall sar -f /var/log/sa/sa`date +%d` -s `date --date='2 hours ago' +%H`:00:00
# echo "</pre>"
#}
function Show_Uptime
{
echo "<h2>System Uptime</h2>"
echo "<pre>"
onall uptime
echo "</pre>"
}
function Show_Machine
{
echo "<h2>Machine Status</h2>"
echo "<pre>"
xms show machine
echo "</pre>"
}
function Show_Process
{
echo "<h2>Process Status</h2>"
echo "<pre>"
xms show pr
echo "</pre>"
}
function Show_Radius
{
echo "<h2>Radius Status</h2>"
echo "<pre>"
radstats
echo "</pre>"
}
function Show_Presense
{
echo "<h2>PSE Status</h2>"
echo "<pre>"
psesessions
echo "</pre>"
}
function Drive_Space
{
echo "<h2>File System Space</h2>"
echo "<pre>"
onall df -kh
echo "</pre>"
}
function Detail_Streams_Blade3_HTA
{
echo "<h2>HTA Stream Utlizations on Blade 3</h2>"
echo "<pre>"
for (( c=1; c<20; c++ )); do cmu -O HTA -d HTTP-PROXY.tswebpxmp3.$c | grep -i active; done
echo "</pre>"
}
function Detail_Streams_Blade4_HTA
{
echo "<h2>HTA Stream Utlizations on Blade 4</h2>"
echo "<pre>"
for (( c=1; c<20; c++ )); do cmu -O HTA -d HTTP-PROXY.tswebpxmp4.$c | grep -i active; done
echo "</pre>"
}
function Detail_Streams_Blade5_HTA
{
echo "<h2>HTA Stream Utlizations on Blade 5</h2>"
echo "<pre>"
for (( c=1; c<20; c++ )); do cmu -O HTA -d HTTP-PROXY.tswebpxmp5.$c | grep -i active; done
echo "</pre>"
}
function Detail_Streams_Blade9_HTA
{
echo "<h2>HTA Stream Utlizations on Blade 9</h2>"
echo "<pre>"
for (( c=1; c<20; c++ )); do cmu -O HTA -d HTTP-PROXY.tswebpxmp9.$c | grep -i active; done
echo "</pre>"
}
function Detail_Streams_Blade3_HTG
{
echo "<h2>HTG Stream Utlizations on Blade 3</h2>"
echo "<pre>"
for (( c=1; c<20; c++ )); do cmu -O HTG -d HTTP-PROXY.tswebpxmp3.$c | grep -i active; done
echo "</pre>"
}
function Detail_Streams_Blade4_HTG
{
echo "<h2>HTG Stream Utlizations on Blade 4</h2>"
echo "<pre>"
for (( c=1; c<20; c++ )); do cmu -O HTG -d HTTP-PROXY.tswebpxmp4.$c | grep -i active; done
echo "</pre>"
}
function Detail_Streams_Blade5_HTG
{
echo "<h2>HTG Stream Utlizations on Blade 5</h2>"
echo "<pre>"
for (( c=1; c<20; c++ )); do cmu -O HTG -d HTTP-PROXY.tswebpxmp5.$c | grep -i active; done
echo "</pre>"
}
function Detail_Streams_Blade9_HTG
{
echo "<h2>HTG Stream Utlizations on Blade 9</h2>"
echo "<pre>"
for (( c=1; c<20; c++ )); do cmu -O HTG -d HTTP-PROXY.tswebpxmp9.$c | grep -i active; done
echo "</pre>"
}
function Tps_Details
{
echo "<h2>Total TPS</h2>"
echo "<pre>"
curtps
echo "</pre>"
}
function Tps_Proxy
{
echo "<h2>TPS on Proxy Blades</h2>"
echo "<pre>"
/home/xmp/siddhesh/tpscount.sh proxy |grep Proxy
echo "</pre>"
}
function Tps_Transperent
{
echo "<h2>TPS on Transperent Blades</h2>"
echo "<pre>"
/home/xmp/siddhesh/tpscount.sh tcp |grep Trans
echo "</pre>"
}
function Cpu_Details
{
echo "<h2>CPU Utilizations Per Blade</h2>"
echo "<pre>"
onall top -b -n 1 | grep Cpu
echo "</pre>"
}
function Memory_Details
{
echo "<h2>Memory Utilization Per Blade</h2>"
echo "<pre>"
onall top -b -n 1 | grep Mem
echo "</pre>"
}
# end of home space
function write_page
{
cat <<- _EOF_
<html>
<hear>
<title>$TITLE</title>
</head>
<body>
<h1>$TITLE</h1>
<p>$TIME_STAMP</p>
$(Show_Uptime)
$(Show_Machine)
$(Show_Process)
$(Show_Radius)
$(Show_Presense)
$(Drive_Space)
$(Detail_Streams_Blade3_HTA)
$(Detail_Streams_Blade4_HTA)
$(Detail_Streams_Blade5_HTA)
$(Detail_Streams_Blade9_HTA)
$(Detail_Streams_Blade3_HTG)
$(Detail_Streams_Blade4_HTG)
$(Detail_Streams_Blade5_HTG)
$(Detail_Streams_Blade9_HTG)
$(Tps_Details)
$(Tps_Proxy)
$(Tps_Transperent)
$(Cpu_Details)
$(Memory_Details)
</body>
</html>
_EOF_
}
function usage
{
echo "usage: system_page [[[-f file ] [-i]] | [-h]]"
}
##MAIN
interactive=1
filename=~/system_page.html
while [ "$1" != "" ]; do
case $1 in
-f | --file ) shift
filename=$1
;;
-i | --interactive ) interactive=1
;;
-h | --help ) usage
exit
;;
* ) usage
exit 1
esac
shift
done
# Test code to verify command line processing
if [ "$interactive" = "1" ]; then
echo "interactive is on"
else
echo "interactive is off"
fi
echo "output file = $filename"
# Write page (comment out until testing is complete)
write_page > $filename
if [ "$interactive" = "1" ]; then
response=
echo -n "Enter name of output file [$filename] > "
read response
if [ -n "$response" ]; then
filename=$response
fi
if [ -f $filename ]; then
echo -n "Output file exists. Overwrite? (y/n) > "
read response
if [ "$response" != "y" ]; then
echo "Exiting program."
exit 1
fi
fi
fi
exit 0
The command which i am trying to include is as below and this would run on all other blades.
logscan -in /var/xmp/log/XMP_*.log |grep HTA_ResponseStatus |sort |uniq -c
I have password less login enabled on all the servers..Please advice.
-Siddhesh
---------- Post updated at 05:01 PM ---------- Previous update was at 04:24 PM ----------
When i try to run this from remote system it gives this error
[xmp@tswebpxmpadmin siddhesh]$ ssh xmp@tswebpxmp3 /opt/xmp/bin/logscan -in /var/xmp/log/XMP_*.log |grep HTA_ResponseStatus |sort |uniq -c
buffer_append_space: len 1533963 not supported
When i run it on local system it works fine as expected.
[xmp@tswebpxmp3 ~]$ /opt/xmp/bin/logscan -in /var/xmp/log/XMP_*.log |grep HTA_ResponseStatus |sort |uniq -c
149898 HTA_ResponseStatus: 200
6 HTA_ResponseStatus: 201
12 HTA_ResponseStatus: 202
2573 HTA_ResponseStatus: 204
1040 HTA_ResponseStatus: 206
489 HTA_ResponseStatus: 301
3185 HTA_ResponseStatus: 302
9 HTA_ResponseStatus: 303
3109 HTA_ResponseStatus: 304
115 HTA_ResponseStatus: 400
23 HTA_ResponseStatus: 401
1 HTA_ResponseStatus: 402
490 HTA_ResponseStatus: 403
2549 HTA_ResponseStatus: 404
5 HTA_ResponseStatus: 405
30 HTA_ResponseStatus: 406
682 HTA_ResponseStatus: 408
3 HTA_ResponseStatus: 410
2 HTA_ResponseStatus: 413
6 HTA_ResponseStatus: 416
107 HTA_ResponseStatus: 500
682 HTA_ResponseStatus: 502
184 HTA_ResponseStatus: 503
2087 HTA_ResponseStatus: 504
18 HTA_ResponseStatus: 512
Please advice.
-Siddhesh