Shell script to find filesystem capacity on 50 servers


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Shell script to find filesystem capacity on 50 servers
# 8  
Old 06-04-2011
Code:
vtierfile=/home/m69642/vtierlist.txt
i=0
j=0
#################array of servers/usage######################
for server in `cat $vtierfile`;
do
vtier[$i]=$server
usage[$i]=`sshcmd -u ${vtier[$i]} -s ${vtier[$i]} " df -k ." |  awk '{ print $5 " " $6 }' | cut -d " " -f1|tail -1`
echo server=${vtier[$i]} and usage = ${usage[$i]}
i=$i+1
done
##############print the server and usage######################
while [ $j -le $i ]
do
echo server=${vtier[$j]} and usage = ${usage[$j]}
j=$j+1
done | /usr/ucb/Mail -s "usage report" `cat /home/m69642/maillist`


Last edited by Franklin52; 06-07-2011 at 06:17 AM.. Reason: code tags
# 9  
Old 06-05-2011
You have any specific HTML format, or anything which is formatted into html is fine ?
# 10  
Old 06-05-2011
thanks Kumar,I am looking for the output in tabular form.
# 11  
Old 06-06-2011
Can you post your sample output, because we can't execute your script here and see the output.
# 12  
Old 06-06-2011
my output in email is :
Code:
server=server1 and usage=10%
server=server2 and usage=20%
server=server3 and usage=30%
server=server4 and usage=40%

I want this output in tabular form in the mail like:
Code:
server                                 usage
server1                                  20%
server2                                  30%
server3                                  40%

I tried html tags in echo, but its not working.
Code:
vtierfile=/home/m69642/vtierlist.txt
genhtml=/home/m69642/genhtml.html

i=0
j=0
#################array of servers/usage######################

for server in `cat $vtierfile`;
do
vtier[$i]=$server
usage[$i]=`sshcmd -u ${vtier[$i]} -s ${vtier[$i]} " df -k ." |  awk '{ print $5 " " $6 }' | cut -d " " -f1|tail -1`
echo server=${vtier[$i]} and usage = ${usage[$i]}
i=$i+1
done

##############print the server and usage######################
while [ $j -le $i ]
do
echo "<table>" >>$genhtml
echo -e "\t<tr>" >>$genhtml
echo -e "\t\t <td>server=${vtier[$j]}</td> >>$genhtml
echo -e "\t\t<td>usage = ${usage[$j]} </td> >>$genhtml
echo -e "\t</tr> >>$genhtml
echo "</table>" >>$genhtml
echo "<br />" >>$genhtml
echo "</table>" >>$genhtml
j=$j+1
done | /usr/ucb/Mail -s "usage report" `cat /home/m69642/maillist`


Last edited by Franklin52; 06-07-2011 at 06:17 AM.. Reason: Please use code tags
# 13  
Old 06-06-2011
I have modified the below part, just remove the part and use the code
Code:
##############print the server and usage######################
while [ $j -le $i ]
do
echo "<table>" >>$genhtml
echo -e "\t<tr>" >>$genhtml
echo -e "\t\t <td>server=${vtier[$j]}</td> >>$genhtml
echo -e "\t\t<td>usage = ${usage[$j]} </td> >>$genhtml
echo -e "\t</tr> >>$genhtml
echo "</table>" >>$genhtml
echo "<br />" >>$genhtml
echo "</table>" >>$genhtml
j=$j+1
done | /usr/ucb/Mail -s "usage report" `cat /home/m69642/maillist`

Use this code and try,
Code:
echo "<html>" >>$genhtml
echo "<body>" >>$genhtml
echo "<table border=\"1\">" >>$genhtml
echo "<tr>" >>$genhtml
echo "<td><b> Server </b></td>" >>$genhtml
echo "<td><b> Usage </b></td>" >>$genhtml
echo "<\tr>" >>$genhtml

while [ $j -le $i ]
do
echo " <tr>" >>$genhtml
echo  " <td> ${vtier[$j]}</td>" >>$genhtml
echo " <td>  ${usage[$j]} </td>"  >>$genhtml
echo "</tr> >>$genhtml
j=$j+1
done 

echo "</table>" >>$genhtml
echo "</body>" >>$genhtml
echo "</html>" >>$genhtml

/usr/ucb/mail -s "Usage Report" `cat /home/m69642/maillist` <$genhtml


Before sending mails, first check whether $genhtml content is fine, try to open it in a browser. Then you can add the mail part.
# 14  
Old 06-07-2011
thanks Kumar,
but i am getting html tags in the email not in formatting.this is what I got in the mail.
I tried to define the text type also but it didn't worked. I googled a lot but didn't find anything.

<html>
<body>
<table border="1">
<tr>
<td><b> Server </b></td>
<td><b> Usage </b></td>
< r>
<tr>
<td> server1</td>
<td> 7% </td>
</tr>
<tr>
<td> server2</td>
<td> 8% </td>
</tr>
<tr>
</table>
</body>
</html>
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 find Error: rpmdb open failed on list of servers

Hello all, I have a task to patch red hat servers and some servers have a corrupted rpm database and return the error: Error: rpmdb open failed I know how to fix this when it occurs. What I'm hoping to do is scan a list of servers by IP and report back which server have this error. ... (6 Replies)
Discussion started by: greavette
6 Replies

2. Shell Programming and Scripting

Filesystem alert shell script not working!!

Hi All, My below shell script is not capturing %used value in the filesystem alert in the subject of the mail alert: Code: #!/bin/bash export DBALIST="abc@xyz.com" df -k /oradata/xyz/archive > dfk.result archive_capacity=`awk -F" " '{ print $5 }' dfk.result|grep -i %| cut -c 1-4` if... (6 Replies)
Discussion started by: harveyclayton
6 Replies

3. UNIX for Dummies Questions & Answers

Need a shell script to find 0 byte files in 5 servers

Hi..... Thanks for this wonderful forum.... My request: I have toatally 5 unix servers in which many applications are working I need to set a trap to identify 0 byte files if any are created proactively. For example: find /apps/fresco/ -mtime 1 -size 0c –print >>... (3 Replies)
Discussion started by: ChandruBala73
3 Replies

4. Homework & Coursework Questions

Disk Capacity Shell Script

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! I am pretty close I think, but stuck. I don't know how to send an email to the user specified on the command line, and I receive an error stating -ge expecting a unary value(lines... (14 Replies)
Discussion started by: polyglot0727
14 Replies

5. UNIX for Dummies Questions & Answers

hwo to find shared filesystem and local filesystem in AIX

Hi, I wanted to find out that in my database server which filesystems are shared storage and which filesystems are local. Like when I use df -k, it shows "filesystem" and "mounted on" but I want to know which one is shared and which one is local. Please tell me the commands which I can run... (2 Replies)
Discussion started by: kamranjalal
2 Replies

6. AIX

how to find out disk capacity

Hi, I would like to know how to find out disk capacity if it is assigned from the storage as a lun. as per below command , I am unable to find out disk capacity. $ bash bash-3.00$ lspv hdisk1 0001579a7fa3c086 None $ lscfg -vl hdisk1 hdisk1 ... (8 Replies)
Discussion started by: manoj.solaris
8 Replies

7. Shell Programming and Scripting

Filesystem alert shell script not working!!

Hi All, My below shell script is not capturing %used value in the filesystem alert in the subject of the mail alert: #!/bin/bash export DBALIST="abc@xyz.com" df -k /oradata/xyz/archive > dfk.result archive_capacity=`awk -F" " '{ print $5 }' dfk.result|grep -i %| cut -c 1-4` if ] then... (5 Replies)
Discussion started by: a1_win
5 Replies

8. UNIX for Dummies Questions & Answers

How to find filesystems crossed 90% capacity

Hi experts, How do i find which are the filesystems which has crossed 90% capacity in solaris box. thanks Shaan:) (4 Replies)
Discussion started by: shaan_dmp
4 Replies

9. Shell Programming and Scripting

shell script to mount filesystem

Hi, Gurus: I need your help to finish a script that will mount two file systems automatically when saver is reboot or start. I am working on a new Sun Sparc machine with Solaris 9 on it. This box got two disk. disk one has been partitioned to hold Solaris OS. disk two has been partitioned as... (6 Replies)
Discussion started by: duke0001
6 Replies

10. Filesystems, Disks and Memory

how to find memory capacity.

Hi, In Sun solaris o/s how can i find the memory space available,Swap space. By giving df command i can get the disc space. I want RAM space & swap space. If anybody assist me.that is great. Thanks (2 Replies)
Discussion started by: Mar1006
2 Replies
Login or Register to Ask a Question