trouble with outputting html to check vmfs volumes


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting trouble with outputting html to check vmfs volumes
# 1  
Old 05-14-2009
trouble with outputting html to check vmfs volumes

Hi - I found a script on the web to check vmfs volumes on ESX servers and create an html file for the output. Sometimes the script works fine, but sometimes it seems to break at the "vdf -h -P" line. More often than not, when I run it myself it works - but when run from chron it usually fails. If you have any ideas on what I've done wrong, thanks in advance.

Here's the script:

######## vmfs_check.sh ##########
#!/bin/bash
LOGLOC="/var/log/"
LOG="${LOGLOC}vdf.html"
MYDATE=$(date +%d-%b-%Y)
VMFSYELLOW=85
VMFSRED=90
cat /dev/null > "${LOG}"
echo "<html>" >> "${LOG}"
echo "<head>" >> "${LOG}"
echo "<style>" >> "${LOG}"
echo "body {margin: 10px; width: 600px; font-family:arial; font-size: 11px;}" >> "${LOG}"
echo "div#footer {font-size: 9px;}" >> "${LOG}"
echo "</style>" >> "${LOG}"
echo "</head>" >> "${LOG}"
echo "<body>" >> "${LOG}"
echo "<table cellspacing="0" cellpadding="2" border="1"; style='border-collapse:collapse; background-color: white; color: black'>" >> "${LOG}"
echo "<tr><th colspan='5'; align='left'; style='background-color: rgb(179,179,179); color: black'>" >> "${LOG}"
echo "VMFS Disk Usage - $MYDATE</th></tr>" >> "${LOG}"
echo "" >> "${LOG}"
echo "<tr>" >> "${LOG}"
echo "<td width=200><b>VMFS Volume</b></td><td><b>Disk Size</b></td><td><b>Used</b></td><td><b>Available</b></td><td><b>Percentage</b></td>" >> "${LOG}"
echo "</tr>" >> "${LOG}"
vdf -h -P | grep -E '^/vmfs/volumes/' | awk '{ print $2 " " $3 " " $4 " " $5 " " $6 " " $7 }' | while read output ; do
DISKSIZE=$(echo $output | awk '{ print $1 }' )
DISKUSED=$(echo $output | awk '{ print $2 }' )
DISKAVAILABLE=$(echo $output | awk '{ print $3 }' )
PERCENTINUSE=$(echo $output | awk '{ print $4 }' )
VOLNAME=$(echo $output | awk '{ print $5 " " $6}' )
CUTPERC=$(echo $PERCENTINUSE | cut -d'%' -f1 )
WARNING="white"
if [ $CUTPERC -ge $VMFSYELLOW ] ; then
WARNING="yellow"
fi
if [ $CUTPERC -ge $VMFSRED ] ; then
WARNING="red"
fi
echo "<tr><td style='background-color: ${WARNING}'>$VOLNAME</td>" >> "${LOG}"
echo "<td bgcolor='${WARNING}'>$DISKSIZE</td>" >> "${LOG}"
echo "<td bgcolor='${WARNING}'>$DISKUSED</td>" >> "${LOG}"
echo "<td bgcolor='${WARNING}'>$DISKAVAILABLE</td>" >> "${LOG}"
echo "<td bgcolor='${WARNING}'>$PERCENTINUSE</td></tr>" >> "${LOG}"
done
echo "</table>" >> "${LOG}"
echo "<div id='footer'> </div>" >> "${LOG}"
echo "</body>" >> "${LOG}"
echo "</html>" >> "${LOG}"


###########################
Here's the output I get when things break:

<html>
<head>
<style>
body {margin: 10px; width: 600px; font-family:arial; font-size: 11px;}
div#footer {font-size: 9px;}
</style>
</head>
<body>
<table cellspacing=0 cellpadding=2 border=1; style='border-collapse:collapse; background-color: white; color: black'>
<tr><th colspan='5'; align='left'; style='background-color: rgb(179,179,179); color: black'>
VMFS Disk Usage - 13-May-2009</th></tr>
<tr>
<td width=200><b>VMFS Volume</b></td><td><b>Disk Size</b></td><td><b>Used</b></td><td><b>Available</b></td><td><b>Percentage</b></td>
</tr>
</table>
<div id='footer'> </div>
</body>
</html>


###############################
Here's the output I get when all goes well:

<html>
<head>
<style>
body {margin: 10px; width: 600px; font-family:arial; font-size: 11px;}
div#footer {font-size: 9px;}
</style>
</head>
<body>
<table cellspacing=0 cellpadding=2 border=1; style='border-collapse:collapse; background-color: white; color: black'>
<tr><th colspan='5'; align='left'; style='background-color: rgb(179,179,179); color: black'>
VMFS Disk Usage - 14-May-2009</th></tr>
<tr>
<td width=200><b>VMFS Volume</b></td><td><b>Disk Size</b></td><td><b>Used</b></td><td><b>Available</b></td><td><b>Percentage</b></td>
</tr>
<tr><td style=background-color: white>/vmfs/volumes/storage1 (1)</td>
<td bgcolor='white'>60G</td>
<td bgcolor='white'>11G</td>
<td bgcolor='white'>48G</td>
<td bgcolor='white'>19%</td></tr>
<tr><td style=background-color: red>/vmfs/volumes/AXOLH VMFS1</td>
<td bgcolor='red'>399G</td>
<td bgcolor='red'>362G</td>
<td bgcolor='red'>37G</td>
<td bgcolor='red'>90%</td></tr>
<tr><td style=background-color: yellow>/vmfs/volumes/AXOLH VMFS3</td>
<td bgcolor='yellow'>399G</td>
<td bgcolor='yellow'>345G</td>
<td bgcolor='yellow'>54G</td>
<td bgcolor='yellow'>86%</td></tr>
<tr><td style=background-color: white>/vmfs/volumes/AXOLH VMFS2</td>
<td bgcolor='white'>399G</td>
<td bgcolor='white'>332G</td>
<td bgcolor='white'>67G</td>
<td bgcolor='white'>83%</td></tr>
<tr><td style=background-color: white>/vmfs/volumes/AXOLH VMFS0</td>
<td bgcolor='white'>249G</td>
<td bgcolor='white'>72G</td>
<td bgcolor='white'>177G</td>
<td bgcolor='white'>29%</td></tr>
<tr><td style=background-color: white>/vmfs/volumes/AXOLH VMFS4</td>
<td bgcolor='white'>399G</td>
<td bgcolor='white'>339G</td>
<td bgcolor='white'>60G</td>
<td bgcolor='white'>84%</td></tr>
<tr><td style=background-color: yellow>/vmfs/volumes/AXOLH VMFS5</td>
<td bgcolor='yellow'>399G</td>
<td bgcolor='yellow'>344G</td>
<td bgcolor='yellow'>55G</td>
<td bgcolor='yellow'>86%</td></tr>
<tr><td style=background-color: white>/vmfs/volumes/AXOBU1 -</td>
<td bgcolor='white'>1.8T</td>
<td bgcolor='white'>372G</td>
<td bgcolor='white'>1.5T</td>
<td bgcolor='white'>20%</td></tr>
<tr><td style=background-color: white>/vmfs/volumes/AXOIT1 -</td>
<td bgcolor='white'>59G</td>
<td bgcolor='white'>42G</td>
<td bgcolor='white'>17G</td>
<td bgcolor='white'>70%</td></tr>
</table>
<div id=footer> </div>
</body>
</html>

thanks again
# 2  
Old 05-14-2009
How would you normally run it from the command prompt. What shell does it use to run manually. The script seems to be using #!/bin/bash. You may want to fid out that first.


cheers,
Devaraj Takhellambam
# 3  
Old 05-14-2009
Linux is not my strong suit, so please bear with me. Not sure about the shell, but I run it like this from the command line:

./vmfs_check.sh

I ran "whereis bash" and bash is located at bin/bash
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Solaris

Check Solaris VM Databases metadb does not have enough information about logical volumes

Check Solaris VM Databases metadb does not have enough information about logical volumes. Current value is 0% I have checked the SVM status, all disks are good state and synched perfectly. no errors in metadb -i. what is this alert exact mean? what we have to check for the value? Please... (1 Reply)
Discussion started by: Naveen.6025
1 Replies

2. UNIX for Advanced & Expert Users

Mutt for html body and multiple html & pdf attachments

Hi all: Been racking my brain on this for the last couple of days and what has been most frustrating is that this is the last piece I need to complete a project. There are numerous posts discussing mutt in this forum and others but I have been unable to find similar issues. Running with... (1 Reply)
Discussion started by: raggmopp
1 Replies

3. Red Hat

Send HTML body and HTML attachment using MUTT command

Hi there.. I need a proper "mutt" command to send a mail with html body and html attachment at a time. Also if possible let me know the other commands to do this task. Please help me.. (2 Replies)
Discussion started by: vickramshetty
2 Replies

4. Programming

Using a script to check the login and username (html)

I made this named "confirm.sh":#/bin/sh #username and password are already given by the login form if ; then realpass=`cat /home/alex/Desktop/Myfirstsite/allpasses/$username` if ; then #continue with index.html else echo "Bad password" fi else echo "Unknown username" fi because I wanted... (4 Replies)
Discussion started by: hakermania
4 Replies

5. Solaris

No of volumes in vxvm

Anyone knows that how many volumes can be created in a Diskgroup? Thanks in advance... (1 Reply)
Discussion started by: bpsunadm
1 Replies

6. Filesystems, Disks and Memory

Raw volumes

The query is as follows : A typical server configs when using Oracle or any other type of DB is to install the OS + DB binaries on the internal disks of the relevant server e.g. Disk 1 : OS + SW + DB binaries Disk 2 : Mirror of disk 1 (used for resiliency) Then one uses an external array... (1 Reply)
Discussion started by: kekanap
1 Replies

7. Shell Programming and Scripting

outputting a text file in html

is there anyway i can paste/cat a text file into a html paragraph <p> function html_header { cat <<END <html> <head><title>${1}</title></head> <body> <p> ${2} </p> END } function html_footer { cat <<END </body> </html> END (2 Replies)
Discussion started by: magnia
2 Replies

8. UNIX for Dummies Questions & Answers

How do I extract text only from html file without HTML tag

I have a html file called myfile. If I simply put "cat myfile.html" in UNIX, it shows all the html tags like <a href=r/26><img src="http://www>. But I want to extract only text part. Same problem happens in "type" command in MS-DOS. I know you can do it by opening it in Internet Explorer,... (4 Replies)
Discussion started by: los111
4 Replies

9. UNIX for Advanced & Expert Users

Regarding volumes entries!

I want some clarifications here :) As my understanding: Physical Volumes entries exist in: /dev/dsk n /dev/rdsk with slice information. Anyway we can get the Physical volumes/disk info And for logical Volumes: /etc/mnttab, /etc/vfstab contains entries And its not generic to get all the... (0 Replies)
Discussion started by: painulyarun
0 Replies

10. News, Links, Events and Announcements

Did not know about logical volumes

I had just updated - reinstalled - my RH9 to a Fedore Core 3. I did not know about the Logical volumes that automatically combined partitions on drive 1 and 2 into one mounted volume. In my attempts to do something with the hdb2 partition - not knowing that it was already in use - I killed my... (2 Replies)
Discussion started by: gezi
2 Replies
Login or Register to Ask a Question