Tuesday, 26 August 2014

LDOMS configuratin auto generated mails

# cat /usr/bin/genpactldmconfig
#!/usr/bin/bash
#ldom script
Node=`uname -n`
echo "From:chittibabu.miriyala@gmail.com" >"/tmp/output1"
echo "To:chittibabu.miriyala@gmail.com">>"/tmp/output1"
#Reply-To:chittibabu.miriyala@gmail.com
echo "Subject:Guest VM Config Info: $Node">>"/tmp/output1"
echo "Content-type: text/html">>"/tmp/output1"
echo "<html>">>"/tmp/output1"
echo "<body>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
#echo "<tr BGCOLOR="#FFFF00"><td colspan="6"> <h1>NAME</h1> </td></tr>">>"/tmp/o                                                                              utput1"
echo "<tr BGCOLOR="#FFFF00"><td> <h6>NAME</h6> </td><td> <h6>STATE</h6> </td><td                                                                              > <h6>FLAGS</h6></td><td> <h6>CONS</h6> </td><td> <h6>VCPU</h6></td><td><h6>MEMO                                                                              RYU</h6> </td><td> <h6>UTIL</h6> </td><td colspan="3"><h6>UPTIME</h6></td></tr>"                                                                              >>"/tmp/output1"
LDM=`ldm list |grep -v NAME  |awk '{print $1}'`
for i in `echo $LDM`
do
if [ "`ldm list $i|grep -v NAME|awk '{print $2}'`" == "active" ]
then
        echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
        f=`ldm list $i|grep -v NAME`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
else
        echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
        f=`ldm list $i|grep -v NAME`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
fi
done
echo "</table>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
#echo "<tr BGCOLOR="#FFFF00"><td colspan="6"> <h1> $Node</h1> </td></tr>">>"/tmp                                                                              /output1"
echo "<tr BGCOLOR="#FFFF00"><td> <h6>Pool NAME</h6> </td><td> <h6>SIZE</h6> </td                                                                              ><td> <h6>ALLOC</h6></td><td> <h6>FREE</h6> </td><td> <h6>CAP</h6></td><td><h6>D                                                                              EDUP</h6> </td><td> <h6>HEALTH</h6> </td><td> <h6>ALTROOT</h6> </td></tr>">>"/tm                                                                              p/output1"
POOL=`zpool list|grep -v NAME  |awk '{print $1}'`
for i in `echo $POOL`
do
if [ `zpool list $i |grep -v NAME|awk '{print $7}'` == "ONLINE" ]
then
        echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
        f=`zpool list $i|grep -v NAME`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
else
        echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
        f=`zpool list $i|grep -v NAME`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
fi
done
echo "</table>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
#echo "<tr BGCOLOR="#FFFF00"><td colspan="6"> <h1>NAME</h1> </td></tr>">>"/tmp/o                                                                              utput1"
echo "<tr BGCOLOR="#FFFF00"><td> <h6>NAME</h6> </td><td> <h6>STATE</h6> </td><td                                                                              > <h6>FLAGS</h6></td><td> <h6>CONS</h6> </td><td> <h6>VCPU</h6></td><td><h6>MEMO                                                                              RYU</h6> </td><td> <h6>UTIL</h6> </td><td colspan="3"><h6>UPTIME</h6></td></tr>"                                                                              >>"/tmp/output1"
LDM=`ldm list |grep -v NAME  |awk '{print $1}'`
for i in `echo $LDM`
do
if [ "`ldm list $i|grep -v NAME|awk '{print $2}'`" == "active" ]
then
        echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
        f=`ldm list $i|grep -v NAME`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
        echo "<TR BGCOLOR="#CCEEFF">">>"/tmp/output1"
        echo "<td colspan=10><pre>">>"/tmp/output1"
        ldm list -l $i >>"/tmp/output1"
        echo " </pre></td>">>"/tmp/output1"
        echo "</tr>">>"/tmp/output1"

else
        echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
        f=`ldm list $i|grep -v NAME`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
        echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
        echo "<td colspan=10><pre>">>"/tmp/output1"
        ldm list -l $i >>"/tmp/output1"
        echo " </pre></td>">>"/tmp/output1"
        echo "</tr>">>"/tmp/output1"
fi
done
echo "</table>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
#echo "<tr BGCOLOR="#FFFF00"><td colspan="6"> <h1> $Node</h1> </td></tr>">>"/tmp                                                                              /output1"
echo "<tr BGCOLOR="#FFFF00"><td> <h6>Pool NAME</h6> </td><td> <h6>SIZE</h6> </td                                                                              ><td> <h6>ALLOC</h6></td><td> <h6>FREE</h6> </td><td> <h6>CAP</h6></td><td><h6>D                                                                              EDUP</h6> </td><td> <h6>HEALTH</h6> </td><td> <h6>ALTROOT</h6> </td></tr>">>"/tm                                                                              p/output1"
POOL=`zpool list|grep -v NAME  |awk '{print $1}'`
for i in `echo $POOL`
do
if [ `zpool list $i |grep -v NAME|awk '{print $7}'` == "ONLINE" ]
then
        echo "<TR BGCOLOR="#00FF00">">>"/tmp/output1"
        f=`zpool list $i|grep -v NAME`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
        echo "<TR BGCOLOR="#CCEEFF">">>"/tmp/output1"
        echo "<td colspan=10><pre>">>"/tmp/output1"
        zpool status -v  $i >>"/tmp/output1"
        echo " </pre></td>">>"/tmp/output1"
        echo "</tr>">>"/tmp/output1"

else
        echo "<TR BGCOLOR="#FF0000">">>"/tmp/output1"
        f=`zpool list $i|grep -v NAME`
        for y in `echo $f`
        do
        echo "<td> $y</td>">>"/tmp/output1"
        done
        echo "</tr>">>"/tmp/output1"
        echo "<TR BGCOLOR="#CCEEFF">">>"/tmp/output1"
        echo "<td colspan=10><pre>">>"/tmp/output1"
        zpool status -v  $i >>"/tmp/output1"
        echo " </pre></td>">>"/tmp/output1"
        echo "</tr>">>"/tmp/output1"

fi
done
echo "</table>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
echo "<tr BGCOLOR="#FFFF00"> <h6>LDOM CONFIGURATION INFORMATION </h6> </td></tr>                                                                              ">>"/tmp/output1"
echo "<TR BGCOLOR="#CCEEFF">">>"/tmp/output1"
echo "<td><pre>">>"/tmp/output1"
ldm list-config >>"/tmp/output1"
echo " </pre></td>">>"/tmp/output1"
echo "</tr>">>"/tmp/output1"
echo "</table>">>"/tmp/output1"
echo "</table>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
echo "<tr BGCOLOR="#FFFF00"> <h6>LDOM SERVICE INFORMATION </h6> </td></tr>">>"/t                                                                              mp/output1"
echo "<TR BGCOLOR="#CCEEFF">">>"/tmp/output1"
echo "<td><pre>">>"/tmp/output1"
ldm list-services >>"/tmp/output1"
echo " </pre></td>">>"/tmp/output1"
echo "</tr>">>"/tmp/output1"
echo "</table>">>"/tmp/output1"
echo "<table width=100%>">>"/tmp/output1"
echo "<tr BGCOLOR="#FFFF00"> <h6>LDOM I/O INFORMATION </h6> </td></tr>">>"/t                                                                              mp/output1"
echo "<TR BGCOLOR="#CCEEFF">">>"/tmp/output1"
echo "<td><pre>">>"/tmp/output1"
ldm list-io -l >>"/tmp/output1"
echo " </pre></td>">>"/tmp/output1"
echo "</tr>">>"/tmp/output1"
echo "</table>">>"/tmp/output1"
echo "</body>">>"/tmp/output1"
echo "</html>">>"/tmp/output1"
cat "/tmp/output1"|mail chittibabu.miriyala@gmail.com

No comments:

Post a Comment