Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Script to monitor an LEB uptime (like pingdom but not)
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Script to monitor an LEB uptime (like pingdom but not)

edited December 2011 in General

I have a few of LEBs (like most here probably :)) and I was wondering if anyone knows of a script I can set up to ping/monitor HTTP from one back to another. Not bothered about RAM/CPU usage just if it's reachable. I want to put it on my 3 LEBs and have them watch each other and email me if they go down.

I was going to put together a small python app to do it but if it already exists why bother :)

Comments

  • jhjh Member

    A quick Google search revealed this, though of course you'll be reliant on another box being up to monitor it:
    http://bash.cyberciti.biz/monitoring/monitor-windows-linux-server-with-ping-script/

  • Are you serious? Just scroll down the front page a little and see the thread about OpenStatus, or use the search function and see the 284082740892704827048742089724 other threads about this.

  • Go59954Go59954 Member
    edited December 2011

    @StolenToaster said: I want to put it on my 3 LEBs and have them watch each other and email me if they go down.

    I've always thought of it through 1 VPS with excellent uptime monitoring all my VPS. But "monitoring each other" is a very good idea I believe. And OpenStatus is indeed a great work you can follow the link http://www.lowendtalk.com/discussion/781/openstatus-0.4.0-released

  • @Go59954 said: I've always thought of it through 1 VPS with excellent uptime monitoring all my VPS.

    I do monitoring from a local Linux box. Of course it fails if my Internet connection is down, but in that case I'm not going to fix anything anyway :)

  • I have 1 box doing my status page and another which monitors everything via ping. Both will email me if one is down.

  • Used this sometime back when I had few boxes. You'll have to run one for each box you want to monitor.

    Only advantage is, you can choose to ignore predetermined number of subsequent ping failures before sending a mail alert. (You will have many single ping failures on most of the boxes and it will be a real headache if you get a mail for each.)

    It also notifies back when box is online.

    #!/bin/bash
    #usage : bash pingh.sh hostname_or_ip
    interval=60 #scan interval in seconds
    fcount=0
    ignoref=2   #attempts to ignore
    alerted=0
    while true; do
    ping -c 1 $1 &>> plog.txt
    if [ $? -ne 0 ]; then
        let "fcount+=1"
        if [ "$fcount" -gt "$ignoref" ] && [ $alerted -eq 0 ]; then
            echo "`date`: $1 down!" | mail -s "$1 down" [email protected] 
            alerted=1
            fcount=0
        fi
    else 
        if [ $alerted -ne 0 ]; then
            echo "`date`: $1 online!" | mail -s "$1 online" [email protected] 
            alerted=0
            fcount=0
        fi
    fi
    sleep $interval
    done
    

    Configure to run it in the background at system startup. If you don't want a log of the ping data, replace plog.txt with /dev/null

    Thanked by 1Spirit
  • @sleddog said: I do monitoring from a local Linux box

    You can't brag about it when it's local though like many folks like to do with it. :)

  • why not use NickM's monitor script?

    Thanked by 1djvdorp
  • thekreekthekreek Member
    edited December 2011

    Sorry I posted on the wrong post.

Sign In or Register to comment.