Hi arif5303!
Here's an alternative to Nagios that may be closer to what you're looking for. It's a fairly simple server/service monitor with a web based interface.
phpservermonIf you really want to do something simple for yourself though, I say go for it! Where are you stuck? Do you just need a starting point, or do you have something written that isn't working the way you like?
EDIT: I never posted the link! Also, here's a simple port monitoring script using 'netcat':
Code:
## The host we want to monitor
host=yourdomain.com
## The email that receives alerts
addy=youremail@somemailhost.net
## The ports we want to check
ports="80 25 53 443 143 110"
## For each port number...
for port in $ports; do
## See if we can make a connection
if ! nc -z $host $port; then
## Make a list of dead ports
down="${down} $port"
fi
done
## If there are any dead ports
## (if $down is not emtpy)
if [ -n "$down" ]; then
## Send an email
echo "Unresponsive ports: $down" | mail -s "Port monitor alert!" $addy
fi