Guest User!

You are not Sophos Staff.

This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

[SOLVED]Enable/Disable a QoS rule automatically

Hi All,

You've probably seen my approach to Download Throttling - for example, where the customer needs to reserve 5000 kbps for VoIP on a 50 Mbps downlink:
[LIST=1]Limit inbound VoIP traffic to 100000 kbps
  • Limit Any-Any-Any to 45000 kbps
[/LIST]
At several clients where they have two different ISPs, using Uplink Balancing, one WAN connection is dedicated to VoIP and the other to all other traffic.  The problem is what to do with the second rule above on the non-VoIP interface.  If you leave it enabled, then you permanently reduce the downlink for non-VoIP traffic to 45000 kbps.  If you leave it disabled and the VoIP WAN connection fails, VoIP is not guaranteed any downlink bandwidth on the non-VoIP WAN connection.

I made a Download Throttling rule named "Test" and was able to enable/disable from the command line with:

 cc change_object REF_QosIngTest status 1
cc change_object REF_QosIngTest status 0


I got the link status of the interface with:

cc get_object REF_uKneYMaTmg | grep 'link'


When a WAN connection fails, SNMP and email messages "[WARN-032] Internet uplink is down" are sent.  Is there a way to piggyback the enabling command onto those actions or to capture the same signal and execute a script or ...?

Cheers - Bob


This thread was automatically locked due to age.
  • Hi Bob,

    I'm not a shell script guru but in theory maybe this way:
    A shell script in cron looks through the logfile for the notification entries and then starts the cc action - somehow. Maybe one of shell gurus knows how to do that.

    Regards
    Manfred
  • I didn't see a way to hook into /usr/local/bin/notifier.plx with a cursory glance on my home system.

    You don't want to add another system to take a trap and act upon it?

    With bash (by no means a complete list):

    Get object REF_uKneYMaTmg, grep for text, toss the output and act upon the exit code of grep:
    (cc get_object REF_uKneYMaTmg | grep "'link' => 1" )> /dev/null && echo true


    In the case of grep there is also -q which saves the redirection to /dev/null:
    cc get_object REF_uKneYMaTmg | grep -q "'link' => 1" && echo true


    Also "if... then... else":
     if ( cc get_object REF_uKneYMaTmg  | grep -q "'link' => 1" ) ; then echo link is one ; else echo link is not one ; fi


    To cron or daemonize/psudo-daemonize depends on the sensitivity to delay between the change in condition and action.

    In addition to bash, perl is present and on newer versions of UTM python is installed too.
  • I knew I could count on teched's expertise!  I don't think it's worth adding code when a crontab-static solution will do so Manfred and teched, I'm not  going to try fancier alternatives.

    I'm looking for feedback...

    The automatic enabling of the QoS rule needs to be fairly soon after the Uplink failover.  I set that cronjob at every minute which is probably quicker than people can re-establish the interrupted phone calls.

    Another complication is that the default persistence of Uplink Balancing is "1 hour."  My thought is that the automatic disabling of the rule can happen in the wee hours of the morning or that the admin can make the change manually when he sees fit.

    So, what do y'all think of:
    * * * * * root /usr/local/bin/confd-client.plx get_object REF_uKneYMaTmg | grep -q "'link' => 0" && /usr/local/bin/confd-client.plx change_object REF_QosIngTest status 1
    * 2 * * * root /usr/local/bin/confd-client.plx get_object REF_uKneYMaTmg | grep -q "'link' => 1" && /usr/local/bin/confd-client.plx change_object REF_QosIngTest status 0

    Cheers - Bob
     
    Sophos UTM Community Moderator
    Sophos Certified Architect - UTM
    Sophos Certified Engineer - XG
    Gold Solution Partner since 2005
    MediaSoft, Inc. USA
  • This is not working in a cron job.  I've tried cc and /usr/local/bin/confd-client.plx, but neither wants to execute in a cron job.

    Silly me.  I changed crontab-static, but not crontab.  After 4:15 this morning, the commands with /usr/local/bin/confd-client.plx worked, but did not work with just cc.

    Cheers - Bob
     
    Sophos UTM Community Moderator
    Sophos Certified Architect - UTM
    Sophos Certified Engineer - XG
    Gold Solution Partner since 2005
    MediaSoft, Inc. USA
Share Feedback
×

Submitted a Tech Support Case lately from the Support Portal?