I have to send status of 3 servers in HTML table format using shell script. Here is the output below:
---------------------------------------
| Daily Status |
---------------------------------------
| Ad Status | |
---------------------------------------
| Servers | Ser1 | Ser2 | Ser3 |
---------------------------------------
| Serv. Status | | | |
---------------------------------------
| DB Server | | | |
---------------------------------------
| Other Status |
---------------------------------------
| Usage | | | |
---------------------------------------
| Final Stats |
---------------------------------------
| Total | | | |
---------------------------------------
| Success | | | |
---------------------------------------
| Fail | | | |
---------------------------------------
| Overall | |
---------------------------------------
I tried as sample script to do this but getting output not like above table-
#!/bin/sh
spawn ssh [email protected]
interact
......
ad_status=$(echo .....)
if [[ $ad_status == "yes" ]]; then
ad_status=$(echo "OK")
elif [[ $ad_status != "yes" ]]; then
ad_status=$(echo "NOK")
fi
.... <same for all variable which mention in below table format>
echo "
<html>
<body>
<table>
<tr>
<th>Daily Status</th>
<tr><td>Ad Status</td><td colspan=3>$ad_status</td></tr>
<tr><td>Servers</td><td>ser1</td><td>ser2</td><td>ser3</td></tr>
<tr><td>Serv. Status</td><td>$server_status</td><td></td><td></td></tr>
<tr><td>DB Server</td><td>$db_status</td><td></td><td></td></tr>
.............
</tr>
</table>
</body>
</html>" > abc.html
(uuencode abc.html abc.html) | cat abc.html | mail -s "$(echo -e "Status\nContent-Type: text/html")" [email protected]
exit 0
Issue is with print value which is in script in other server. Here 171.234.67.89 is IP address of other server2. I have to print variable ad_status
which is in /path/script/test.sh of Server2 & Server3 as well. Main script is running in Server1 so i have already use password less authentication to connect to other server. In mail content value of other servers also print. Could you please help me on this.
if [[ $ad_status == "yes" ]]; then
OK/NOK
in UNIX terminal but in mail i am getting content of valueat_status
(eg: Trying 171.123.34.67 to telnet ....) not asOK/NOK
. I want in mail if "Yes" then "OK" if Not Yes then "NOK".