From a85fc2d5ed4e9412c47446645c6e2c7aedb9e92e Mon Sep 17 00:00:00 2001 From: Ewald van Geffen Date: Sun, 22 May 2016 00:41:01 +0200 Subject: - Bug 590 increase success‐count MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lbdatafactory.cc | 4 ++-- .../wan/interface-health/node.tag/failure-count/node.def | 4 ++-- .../wan/interface-health/node.tag/success-count/node.def | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lbdatafactory.cc b/src/lbdatafactory.cc index 9729e62..bf49b36 100644 --- a/src/lbdatafactory.cc +++ b/src/lbdatafactory.cc @@ -265,7 +265,7 @@ void LBDataFactory::process_health_interface(const string &key, const string &value) { if (key == "success-ct") { - int num = strtoul(value.c_str(), NULL, 10); + int num = strtoul(value.c_str(), NULL, 10000); if (num > 0) { _health_iter->second._success_ct = num; } @@ -277,7 +277,7 @@ LBDataFactory::process_health_interface(const string &key, const string &value) } } else if (key == "failure-ct") { - int num = strtoul(value.c_str(), NULL, 10); + int num = strtoul(value.c_str(), NULL, 10000); if (num > 0) { _health_iter->second._failure_ct = num; } diff --git a/templates/load-balancing/wan/interface-health/node.tag/failure-count/node.def b/templates/load-balancing/wan/interface-health/node.tag/failure-count/node.def index 89ca474..1dd24f7 100644 --- a/templates/load-balancing/wan/interface-health/node.tag/failure-count/node.def +++ b/templates/load-balancing/wan/interface-health/node.tag/failure-count/node.def @@ -1,5 +1,5 @@ type: u32 default: 1 -syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 10; "failure count must be between 1-10" +syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 10000; "failure count must be between 1-10000" help: Failure count -val_help: u32:1-10; Failure count +val_help: u32:1-10000; Failure count diff --git a/templates/load-balancing/wan/interface-health/node.tag/success-count/node.def b/templates/load-balancing/wan/interface-health/node.tag/success-count/node.def index 8d8a6b7..6047b27 100644 --- a/templates/load-balancing/wan/interface-health/node.tag/success-count/node.def +++ b/templates/load-balancing/wan/interface-health/node.tag/success-count/node.def @@ -1,6 +1,6 @@ type: u32 default: 1 -syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 10; "success count must be between 1 and 10" +syntax:expression: $VAR(@) >= 0 && $VAR(@) <= 10000; "success count must be between 1 and 10000" help: Success count -val_help: u32:1-10; Success count +val_help: u32:1-10000; Success count -- cgit v1.2.3 From eec6443e2dbfed079b295a5d60fd08cf80aad698 Mon Sep 17 00:00:00 2001 From: Ewald van Geffen Date: Sun, 22 May 2016 01:02:07 +0200 Subject: - Bug 363 support for post-hook: allows to run script once route/firewall change have been applied. --- scripts/vyatta-wanloadbalance.pl | 5 +++++ src/lbdata.hh | 1 + src/lbdatafactory.cc | 11 +++++++++++ src/lbdatafactory.hh | 3 +++ src/lbdecision.cc | 19 +++++++++++++++++++ templates/load-balancing/wan/post-hook/node.def | 4 ++++ 6 files changed, 43 insertions(+) create mode 100644 templates/load-balancing/wan/post-hook/node.def diff --git a/scripts/vyatta-wanloadbalance.pl b/scripts/vyatta-wanloadbalance.pl index 9603c48..58f1cf3 100644 --- a/scripts/vyatta-wanloadbalance.pl +++ b/scripts/vyatta-wanloadbalance.pl @@ -49,6 +49,11 @@ sub write_health { print FILE_LCK "health {\n"; + my $post_hook = $config->returnValue("load-balancing wan post-hook"); + if (defined $post_hook) { + print FILE_LCK "post-hook \"" . $post_hook . "\"\n"; + } + $config->setLevel("load-balancing wan interface-health"); my @eths = $config->listNodes(); foreach my $ethNode (@eths) { diff --git a/src/lbdata.hh b/src/lbdata.hh index 0b4175c..aaaa896 100644 --- a/src/lbdata.hh +++ b/src/lbdata.hh @@ -227,6 +227,7 @@ class LBData { bool _flush_conntrack; bool _sticky_inbound_connections; string _hook; + string _post_hook; }; #endif //__LBDATA_HH__ diff --git a/src/lbdatafactory.cc b/src/lbdatafactory.cc index bf49b36..6870737 100644 --- a/src/lbdatafactory.cc +++ b/src/lbdatafactory.cc @@ -157,6 +157,9 @@ LBDataFactory::process(const vector &path, int depth, const string &key, else if (path[0] == "hook") { process_hook(l_key,l_value); } + else if (path[0] == "post-hook") { + process_post_hook(l_key,l_value); + } else if (path[0] == "health") { if (depth == 2 && key == "interface") { process_health(l_key,l_value); @@ -249,6 +252,14 @@ LBDataFactory::process_hook(const string &key, const string &value) } } +void +LBDataFactory::process_post_hook(const string &key, const string &value) +{ + if (value.empty() == false) { + _lb_data._post_hook = value; + } +} + void LBDataFactory::process_health(const string &key, const string &value) { diff --git a/src/lbdatafactory.hh b/src/lbdatafactory.hh index 9178e00..f213993 100644 --- a/src/lbdatafactory.hh +++ b/src/lbdatafactory.hh @@ -58,6 +58,9 @@ private: void process_hook(const string &key, const string &value); + void + process_post_hook(const string &key, const string &value); + void process_health_interface(const string &key, const string &value); diff --git a/src/lbdecision.cc b/src/lbdecision.cc index d66849c..a86a878 100644 --- a/src/lbdecision.cc +++ b/src/lbdecision.cc @@ -433,6 +433,25 @@ LBDecision::run(LBData &lb_data) } ++iter; } + + map::iterator post_iter = state_changed_coll.begin(); + while (post_iter != state_changed_coll.end()) { + //set state + //set interface + if (lb_data._post_hook.empty() == false) { + setenv("WLB_INTERFACE_NAME",post_iter->first.c_str(),1); + setenv("WLB_INTERFACE_STATE",post_iter->second.c_str(),1); + + syslog(LOG_WARNING, "executing script: %s",lb_data._post_hook.c_str()); + + execute(lb_data._post_hook, stdout); + //unset state + //unset interface + unsetenv("WLB_INTERFACE_NAME"); + unsetenv("WLB_INTERFACE_STATE"); + } + ++post_iter; + } } /** diff --git a/templates/load-balancing/wan/post-hook/node.def b/templates/load-balancing/wan/post-hook/node.def new file mode 100644 index 0000000..2666930 --- /dev/null +++ b/templates/load-balancing/wan/post-hook/node.def @@ -0,0 +1,4 @@ +type: txt +help: Script to be executed on interface status change after the firewall rules have been activated. +syntax:expression: exec "/opt/vyatta/sbin/check_file_in_config_dir $VAR(@) '/config/scripts'" +val_help: Script in /config/scripts \ No newline at end of file -- cgit v1.2.3 From 69a6a8a153b8c53de66bfb9c72a113bd42afa989 Mon Sep 17 00:00:00 2001 From: Ewald van Geffen Date: Sat, 11 Jun 2016 20:37:49 +0200 Subject: Base10 is the prefered system --- src/lbdatafactory.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lbdatafactory.cc b/src/lbdatafactory.cc index 6870737..682b0b4 100644 --- a/src/lbdatafactory.cc +++ b/src/lbdatafactory.cc @@ -276,7 +276,7 @@ void LBDataFactory::process_health_interface(const string &key, const string &value) { if (key == "success-ct") { - int num = strtoul(value.c_str(), NULL, 10000); + int num = strtoul(value.c_str(), NULL, 10); if (num > 0) { _health_iter->second._success_ct = num; } @@ -288,7 +288,7 @@ LBDataFactory::process_health_interface(const string &key, const string &value) } } else if (key == "failure-ct") { - int num = strtoul(value.c_str(), NULL, 10000); + int num = strtoul(value.c_str(), NULL, 10); if (num > 0) { _health_iter->second._failure_ct = num; } -- cgit v1.2.3