Syed Jahanzaib Personal Blog to Share Knowledge !

November 12, 2009

Linux SMS / PC Monitoring Script !

Filed under: Linux Related — Tags: , , , , — Syed Jahanzaib / Pinochio~:) @ 10:06 AM


This is a script I made just to check if remote PC is ON or OFF, then it can take specific action according to your requirement.

Either Alert you using Echo, EMAIL or SMS. You can modify it according to your need, Below script will send sms

A=`nmap -sP $1 |grep "Nmap done" | awk '{print $6}' | sed "s/(//" | sed "s/1/5/" | sed "s/0/1/"`
 B=`echo $A`
 if [ "$B" == "5" ]; then
 echo "PC is working fine. no need to send SMS"
 #       echo "DOWN"
 echo "POTUS ALERT: PC Down. Please check SERVER Room / zaib " | gnokii --sendsms 03002357367
 echo "POTUS ALERT: PC Down. Please check SERVER Room / zaib " | gnokii --sendsms 03333021909
 #echo $B
 #echo PC Down.


This is a gnooki config file I modified according to my setup.
I used NOKIA 9300i Communicator mobile.

 port = /dev/ttyACM0
 model = 6230
 initlength = default
 connection = dku2libusb
 use_locking = no
 serial_baudrate = 19200
 smsc_timeout = 10
 allow_breakage = 0
 TELEPHONE = 03333021909
 debug = on
 rlpdebug = off
 xdebug = off
 port = foobar
 model = fake
 connection = serial


Following script will check SQUID service status , and if it found squid stop, it will start it auto, if the squid is already running , it will do nothing 🙂

"s/1/5/" | sed "s/0/1/"`
A=`service squid status | awk '{print $3}' | sed "s/process/5/"`
B=`echo $A`
if [ "$B" == "5" ]; then
echo "SQUID is working fine. Zaib"
#       echo "DOWN"
echo "SQUID Down, starting SQUID"
service squid start

You can create its cron entry to run it after every 5 minutes.

For example, add it using CRON by following

crontab -e

and add following line

*/5 * * * * /etc/

Now save and exit.


  1. do u have any script to use with any api like clickatell and takes the expired dates of the radius database and sents the users a sms 5 days before their account has expired .

    will u do it in the far future if not …
    Wish u all the best


    Comment by Nori — January 1, 2012 @ 11:21 PM

    • Hmm I guess you are using Mikrotik’s base User Manager , If YES, there are limited chances that it will work.
      I will test it and let you know when I will get time, currently busy in few projects.

      3rd party RADIUS supports this function that they send Alert for accounts whose expiry is near. For example DMASOFTLAB RM. I am using the same.


      Comment by Syed Jahanzaib / Pinochio~:) — January 2, 2012 @ 10:02 AM

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: