Hi! 😊

Bash monitoring scripts on Apache to check processes

Bash monitoring scripts on Apache to check processes

Monitoring Script on bash which is accessible via CGI apache which is hosted on raspberryPI running raspbian and Apache

A simple interface (HTML 1.0 like) 😀

Simple bash script:-

#!/bin/bash
#Script To display Status of Applications!

echo "Content-type: text/html"
echo
echo "<html><head><title>Monitoring Local Applications</title>"
echo '<link rel="stylesheet" type="text/css" href="PaTHTO/monitoring.css"></head>'
echo "<body>"
echo "Status of Applications!!"
echo "<ul>"
##Check processes
for i in tor nfs tweet tweet2 rpcbind transmission node-red minidlnad smbd named apache
do 
 echo "<li>"
 result=`ps faux |grep $i|grep -v grep |wc -l`
 if [ $result -gt 0 ]; then
 echo "<h2>$i is running</h2>"
 else
 echo -e "<h1>$i Offline</h1>"
 fi
 echo "</li>"
done
echo "</ul>"
echo "Status of Networked Applications!!"
network_device=(IP1 IP2 IP3 IP4)
network_ip=(1x.x.x.x 10.0.0.1x 10.0.0.x 12.x.x.x)
echo "<ul>"
index=0
for j in ${network_ip[@]}
do 
 echo "<li>"
 result=`ping -c 1 $j >/dev/null 2>&1 && echo 1`
 if [ $result == 1 > /dev/null 2>&1 ]; then
 echo "<h2> ${network_device[$index]} is running</h2>"
 else
 echo "<h1>${network_device[$index]} Offline</h1>"
 fi
 echo "</li>"
 let index+=1
done
echo "</ul>"
echo "</body></html>"

 

CSS:

body {
 background-color: lightblue;
}

h1 {
 color: #F05208;
 line-height:0.1;
}

h2 {
 color: navy;
 line-height:0.1;
}

More scripts to come, stop/start applications via apache and everything is available via a URL with ssl ON

 

Made with ♡ ♥💕❤ from Mauritius