Forums

Resolved
0 votes
Hello to all,
I wanted to know if there was the way to know, with a multi-wan connection, when one of the two lines falls off and then have an e-mail alert
I tried to run on the settings but I can not find anything.
Thanks so much
Tuesday, July 03 2018, 08:14 AM
Share this post:
Responses (8)
  • Accepted Answer

    Friday, July 06 2018, 06:08 AM - #Permalink
    Resolved
    0 votes
    Thanks Ben - might be the "right way"[TM] on a ClearOS system - but running here non ClearOS systems such as CentOS, Ubuntu and Fedora - prefer to use "generic" code. Not prepared to spend time on code applicable for only one platform.
    Just to check my script - I've "eaten my own dog food". Had a failure yesterday and this is the resulting email...

    From: root@emma.sraellis.com
    Subject: ping failures on emma.sraellis.com
    To: admin@sraellis.no-ip.com

    Thu Jul 5 23:07:07 2018 debug: enp1s0f1 - ping check on server #1 failed - 8.8.8.8 (ping size: 1)
    Thu Jul 5 23:07:09 2018 info: enp1s0f1 - ping check on server #1 failed - 8.8.8.8
    Thu Jul 5 23:07:16 2018 info: enp1s0f1 - ping check on server #2 failed - 54.152.208.245
    Thu Jul 5 23:07:30 2018 info: enp1s0f1 - ping check on gateway failed - 192.168.0.1
    Thu Jul 5 23:07:32 2018 debug: enp1s0f1 - ping check on server #1 failed - 8.8.8.8 (ping size: 1)
    Thu Jul 5 23:07:34 2018 info: enp1s0f1 - ping check on server #1 failed - 8.8.8.8
    Thu Jul 5 23:07:41 2018 info: enp1s0f1 - ping check on server #2 failed - 54.152.208.245
    Thu Jul 5 23:07:53 2018 debug: enp1s0f1 - ping check on server #1 failed - 8.8.8.8 (ping size: 1)
    Thu Jul 5 23:07:55 2018 info: enp1s0f1 - ping check on server #1 failed - 8.8.8.8
    Thu Jul 5 23:08:02 2018 info: enp1s0f1 - ping check on server #2 failed - 54.152.208.245
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, July 03 2018, 02:16 PM - #Permalink
    Resolved
    0 votes
    The "right way"[TM] to do this would be to add an event to the event system.

    Then, everything you want will happen automatically....the downed interface will get logged to the report/event database, and if a user has set critical (or warn) events to be sent out as an email notification, it will all happen through the global framework.

    I don't know how to do this...in fact, I think there's exactly one person on the planet that does (good thing there's a push to add/improve our developer documentation!).

    There's example configlets in here:

    /etc/clearos/events.d/

    I know you also would have to register your own event:


    [root@gw events.d]# eventsctl -h
    Events Control v1.2
    Copyright (C) 2014 ClearFoundation [Nov 21 2017 12:56:53]
    -V, --version
    Display program version and license information.
    -c <file>, --config <file>
    Specify an alternate configuration file.
    -d, --debug
    Enable debugging messages and remain in the foreground.

    Send an alert:
    # eventsctl -s <options> <description text>

    -s, --send
    Send an alert.
    -t <type>, --type <type>
    Specify an alert type. Specify "list" to show registered types.
    -l <level>, --level <level>
    Specify an alert level; NORMal, WARNing, or CRITical.
    -u <user>, --user <user>
    Specify an optional username or UID.
    -U <uuid>, --uuid <uuid>
    Specify an optional UUID.
    -o <origin>, --origin <origin>
    Specify an optional origin.
    -b <basename>, --basename <basename>
    Specify an optional basename.
    -a, --auto-resolve
    Alert will auto-resolve (ex: firewall panic mode).

    Mark alert type as resolved:
    -r, --mark-resolved
    -t <type>, --type <type>
    Specify an alert type to resolve.

    List all alerts:
    -L, --list

    Custom type registration:
    -R, --register
    Register a custom alert type.
    -D, --deregister
    De-register a custom alert type.
    -t <type>, --type <type>
    Specify a custom alert type to register/de-register.
    -b <basename>, --basename <basename>
    Specify a custom alert type basename (registration mode only).

    Set alert level override:
    -S, --set-override
    -t <type>, --type <type>
    Specify an alert type override to set.
    -l <level>, --level <level>
    Specify an alert level override; NORMal, WARNing, CRITical, or IGNORE.

    Clear alert level override:
    -S, --set-override
    -t <type>, --type <type>
    Specify an alert type override to clear.


    There's also a PHP wrapper, but I don't think you'd use it in this case. Seems like a pretty straightforward case of monitoring the syswatch log file.

    B.
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, July 03 2018, 01:11 PM - #Permalink
    Resolved
    0 votes
    sorry for the double answer, but I did not see my previous post
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, July 03 2018, 12:31 PM - #Permalink
    Resolved
    0 votes
    Thank you so much to everyone, really very kind!
    Tony I'll try with your advice and I'll know if it works.
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, July 03 2018, 11:29 AM - #Permalink
    Resolved
    1 votes
    While waiting for an official addition to Webconfig, something like this run every 5 minutes from an entry in crontab would do the job. Increase the "count" in [[ $COUNT -gt 1 ]] to be less sensitive to the odd ping failure... This requires your email to be setup and the mailx rpm installed... edit "user@yourmail.com" to suit.

    #!/bin/sh
    # Version 1.0 Created 03.07.2018 - Tony G Ellis

    tmp_file="/tmp/ping_failures.txt"
    COUNT=0
    FIVE_MINUTES_AGO=$(date -d "-302 seconds" +%s)
    grep "failed" /var/log/syswatch | \
    awk '{print $1, $3, $2, $5, $4}' > $tmp_file

    while read line; do
    FAILURE_DATE=$(date --date="$line" +%s)
    if [[ $FAILURE_DATE -gt $FIVE_MINUTES_AGO ]]; then
    COUNT=$((COUNT+1))
    fi
    done < $tmp_file

    if [[ $COUNT -gt 1 ]]; then
    grep "failed" /var/log/syswatch | tail -n $COUNT > $tmp_file
    cat $tmp_file | mail -s "ping failures on $HOSTNAME" \
    user@yourmail.com
    fi

    EDIT: Fixed typo
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, July 03 2018, 09:26 AM - #Permalink
    Resolved
    1 votes
    Rather than send an email choose to track in a web-page... Here's the report for just one of my machines...

    http://www.sraellis.tk/frame.php?number=16&monitor=syswatch_status

    Would only take a simple change to the code monitoring /var/log/syswatch to send an email instead...
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, July 03 2018, 09:00 AM - #Permalink
    Resolved
    1 votes
    I was writing when Tony replied:

    As far as I am aware there is nothing although it would possibly be a good feature request if any backup line became active. You can get an idea if you watch /var/log/syswatch. I have filed a feature request, but with the development pressure at the moment I would not hold out much hope.
    The reply is currently minimized Show
  • Accepted Answer

    Tuesday, July 03 2018, 08:56 AM - #Permalink
    Resolved
    1 votes
    Check /var/log/syswatch - an example..

    Sun Jul 1 11:47:41 2018 info: system - heartbeat...
    Sun Jul 1 11:52:42 2018 info: system - heartbeat...
    Sun Jul 1 11:57:43 2018 info: system - heartbeat...
    Sun Jul 1 12:01:06 2018 debug: enp1s0f1 - ping check on server #1 failed - 8.8.8.8 (ping size: 1)
    Sun Jul 1 12:01:08 2018 info: enp1s0f1 - ping check on server #1 failed - 8.8.8.8
    Sun Jul 1 12:01:15 2018 info: enp1s0f1 - ping check on server #2 failed - 54.152.208.245
    Sun Jul 1 12:01:15 2018 warn: enp1s0f1 - connection warning
    Sun Jul 1 12:01:29 2018 info: enp1s0f1 - ping check on gateway failed - 192.168.0.1
    Sun Jul 1 12:01:31 2018 debug: enp1s0f1 - ping check on server #1 failed - 8.8.8.8 (ping size: 1)
    Sun Jul 1 12:01:33 2018 info: enp1s0f1 - ping check on server #1 failed - 8.8.8.8
    Sun Jul 1 12:01:40 2018 info: enp1s0f1 - ping check on server #2 failed - 54.152.208.245
    Sun Jul 1 12:01:40 2018 warn: enp1s0f1 - connection warning
    Sun Jul 1 12:01:52 2018 debug: enp1s0f1 - ping check on server #1 failed - 8.8.8.8 (ping size: 1)
    Sun Jul 1 12:01:54 2018 info: enp1s0f1 - ping check on server #1 failed - 8.8.8.8
    Sun Jul 1 12:02:01 2018 info: enp1s0f1 - ping check on server #2 failed - 54.152.208.245
    Sun Jul 1 12:02:01 2018 warn: enp1s0f1 - upstream connection problems with your ISP
    Sun Jul 1 12:02:01 2018 info: system - changing active WAN list - enp1s0f0 (was enp1s0f1 enp1s0f0)
    Sun Jul 1 12:02:01 2018 info: system - current WANs in use - enp1s0f0
    Sun Jul 1 12:02:01 2018 info: system - restarting firewall
    Sun Jul 1 12:02:14 2018 info: system - dynamic DNS updated
    Sun Jul 1 12:02:24 2018 info: enp1s0f1 - ping check on server #1 passed - 8.8.8.8
    Sun Jul 1 12:02:24 2018 info: system - changing active WAN list - enp1s0f1 enp1s0f0 (was enp1s0f0)
    Sun Jul 1 12:02:24 2018 info: system - current WANs in use - enp1s0f1 enp1s0f0
    Sun Jul 1 12:02:24 2018 info: system - restarting firewall
    Sun Jul 1 12:02:34 2018 info: system - dynamic DNS updated
    Sun Jul 1 12:03:14 2018 info: system - heartbeat...
    Sun Jul 1 12:08:15 2018 info: system - heartbeat...
    Sun Jul 1 12:13:16 2018 info: system - heartbeat...
    The reply is currently minimized Show
Your Reply