Script To Generate HTML output


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Script To Generate HTML output
# 1  
Old 11-13-2012
Script To Generate HTML output

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

Code:
#!/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.

Code:
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

Code:
[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.

Code:
[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
# 2  
Old 11-13-2012
What is your OS version ?

Have you checked over the net to see whether there are some existing product that can already produce such kind of report ?
(I don't know if they do that, but maybe you can have a look at cfg2html & config2html)?
# 3  
Old 11-13-2012
If you ssh into the other box and run the command(s) from the command line does it work ok?
You can also try it like this so that the sort and uniq are ran on the local box:
Code:
ssh xmp@tswebpxmp3 '/opt/xmp/bin/logscan -in /var/xmp/log/XMP_*.log | grep HTA_ResponseStatus' | sort | uniq -c

Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Script to generate HTML output format listing like orasnap

Hi, Is there any UNIX scripts out there that generates a listing output of some sort similar to OraSnap At the moment, I have a script that I run on multiple servers that has multiple databases and just querying the database sizes of those databases. It generates a text files that contains... (0 Replies)
Discussion started by: newbie_01
0 Replies

2. Shell Programming and Scripting

How to generate HTML page from UNIX script out-put?

Hi All. This my first post to this forum, and i assuming it will be best out-of all. I am quite new to Unix scripting so please excuse me for any silly questions - I am trying to create on Unix script in which it telnet to my server, check the connectivity of the server and then it... (2 Replies)
Discussion started by: HHarsh
2 Replies

3. UNIX for Dummies Questions & Answers

How to generate html reports through LINUX Scripting?

Hi All, I am trying to generate a weekly HTML report using LINUX Scripting. This will have record counts of some files. (like below) touch path/filename.html echo "Weekly Summary Report for Business Date : $P_BUS_DT">path/filename.html export A1=`cat path/filename1.txt |wc -l` echo "A1... (6 Replies)
Discussion started by: dsfreddie
6 Replies

4. Shell Programming and Scripting

Linux - Script to generate the output delimited by Comma/Pipe

Hi All, I have a requirement where I need to go to a directory, list all the files that start with person* (for eg) & read the most recent file from the list of files. While browsing through the forum, i found that the command ls -t will list the files. I am trying to generate the output... (1 Reply)
Discussion started by: dsfreddie
1 Replies

5. Shell Programming and Scripting

shell script output in HTML or with table like results

Hello, Currently i have a ksh script which will disply the results in plain text format. I want to format the result in more readable format like Making bold headings and format with colors etc. Something like html or excel format and send that content as email. Please help me how i can do... (2 Replies)
Discussion started by: kotasateesh
2 Replies

6. Shell Programming and Scripting

script to output curl result as html

hi, new to scripting and would like to know how can I have a script which will curl a few URLs and have the results such as the URLs being curled, dns lookup time, connection time, total time, etc save in a html format in a form of table with column and rows. thank you. (4 Replies)
Discussion started by: squidusr
4 Replies

7. Shell Programming and Scripting

have a shell script done in pl/sql and want output in html

I have this shell script where I have both pl/sql and sql. But want to have a snigle output file where the result of each cursors are in HTML tables. I was able to do that on my old script but it was only sql scripts (no pl/sql). Can I do have such outputs now with my new script where I... (2 Replies)
Discussion started by: arobert
2 Replies

8. Shell Programming and Scripting

Generate report in HTML file from Oracle DB

Hi Team, I need a suggestion/comments for my below requirement. I have a procedure which performs some DDL operations & loads data into a Oracle table. This status contains Audit data. What i wanted to do is, once the procedure is completed (daily), shell script should retrive the data from the... (4 Replies)
Discussion started by: Amit.Sagpariya
4 Replies

9. Shell Programming and Scripting

how to generate html file using script?

Hi Friends I have an requirement that i need to generate html file using script. and the script output shold keep adding to that html file like tablewise. can anyone please help me out in this. thanks Krish. (2 Replies)
Discussion started by: kittusri9
2 Replies

10. Shell Programming and Scripting

awk script to search an html file and output links

hello. i want to make an awk script to search an html file and output all the links (e.g .html, .htm, .jpg, .doc, .pdf, etc..) inside it. also, i want the links that will be output to be split into 3 groups (separated by an empty line), the first group with links to other webpages (.html .htm etc),... (8 Replies)
Discussion started by: kyris
8 Replies
Login or Register to Ask a Question