summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorslioch <slioch@eng-140.vyatta.com>2008-12-16 10:48:05 -0800
committerslioch <slioch@eng-140.vyatta.com>2008-12-16 10:48:05 -0800
commit6cdf75f94d9040e1509bb31e355aa019b50c92a7 (patch)
tree8ca781d5cd93c5815dd90834b064bd875861fd0c
parentc8bd14ea81ab8a684fd63945e66582951c7ca5d4 (diff)
downloadvyatta-wanloadbalance-6cdf75f94d9040e1509bb31e355aa019b50c92a7.tar.gz
vyatta-wanloadbalance-6cdf75f94d9040e1509bb31e355aa019b50c92a7.zip
fix for bug 3968. enhanced show wan load balance according to preferred design in bug listing. Also exposed time of last
interface status change.
-rw-r--r--src/lbdata.cc5
-rw-r--r--src/lbdata.hh2
-rw-r--r--src/lboutput.cc71
3 files changed, 46 insertions, 32 deletions
diff --git a/src/lbdata.cc b/src/lbdata.cc
index bfaffcd..4764266 100644
--- a/src/lbdata.cc
+++ b/src/lbdata.cc
@@ -173,6 +173,11 @@ LBData::state_changed()
while (h_iter != _iface_health_coll.end()) {
if (h_iter->second.state_changed()) {
string tmp = (h_iter->second._is_active ? string("ACTIVE") : string("FAILED"));
+
+ struct timeval tv;
+ gettimeofday(&tv,NULL);
+ h_iter->second._last_time_state_changed = (unsigned long)tv.tv_sec;
+
syslog(LOG_WARNING, "Interface %s has changed state to %s",h_iter->first.c_str(),tmp.c_str());
overall_state = true;
}
diff --git a/src/lbdata.hh b/src/lbdata.hh
index d9a6091..25f0f80 100644
--- a/src/lbdata.hh
+++ b/src/lbdata.hh
@@ -75,6 +75,7 @@ class LBHealth {
_hresults(10),
_is_active(true),
_state_changed(true),
+ _last_time_state_changed(0),
_interface_index(interface_index)
{}
@@ -100,6 +101,7 @@ class LBHealth {
LBHealthHistory _hresults;
bool _is_active;
bool _state_changed;
+ unsigned long _last_time_state_changed;
int _interface_index;
string _address;
};
diff --git a/src/lboutput.cc b/src/lboutput.cc
index 0ae0ae5..629de3e 100644
--- a/src/lboutput.cc
+++ b/src/lboutput.cc
@@ -21,7 +21,6 @@ LBOutput::write(const LBData &lbdata)
gettimeofday(&tv,NULL);
string wlb_out = _output_path + "/wlb.out";
- string wlb_app_out = _output_path + "/wlb_app.out";
//open file
FILE *fp = fopen(wlb_out.c_str(), "w");
@@ -33,28 +32,36 @@ LBOutput::write(const LBData &lbdata)
return;
}
- //dump out the health data
- LBData::InterfaceHealthConstIter iter = lbdata._iface_health_coll.begin();
- while (iter != lbdata._iface_health_coll.end()) {
- if (_debug) {
- cout << iter->first << " "; //interface
- cout << string(iter->second._is_active ? "true" : "false") << " "; //status
- cout << tv.tv_sec - iter->second.last_success() << " "; //last success
- cout << tv.tv_sec - iter->second.last_failure() << " "; //last failure
- cout << endl;
+ if (_debug) {
+ //dump out the health data
+ LBData::InterfaceHealthConstIter iter = lbdata._iface_health_coll.begin();
+ while (iter != lbdata._iface_health_coll.end()) {
+ if (_debug) {
+ cout << iter->first << " "; //interface
+ cout << string(iter->second._is_active ? "true" : "false") << " "; //status
+ cout << tv.tv_sec - iter->second.last_success() << " "; //last success
+ cout << tv.tv_sec - iter->second.last_failure() << " "; //last failure
+ cout << endl;
+ }
+ ++iter;
}
- ++iter;
}
- string line("Interface\tStatus\tLast Success\tLast Failure\tNum Failure\n");
- fputs(line.c_str(),fp);
- iter = lbdata._iface_health_coll.begin();
-
+ string space(" ");
timeval cur_t;
gettimeofday(&cur_t,NULL);
-
+ LBData::InterfaceHealthConstIter iter = lbdata._iface_health_coll.begin();
while (iter != lbdata._iface_health_coll.end()) {
- line = string(iter->first) + "\t\t" + string(iter->second._is_active?"active":"failed") + "\t";
+ string line = string("Interface: ") + iter->first + "\n";
+ line += space + string("Status: ") + string(iter->second._is_active?"active":"failed") + "\n";
+
+ const time_t t = (time_t)(iter->second._last_time_state_changed);
+ char *tbuf = ctime(&t);
+
+ line += space + string("Last Status Change: ") + string(tbuf);
+
+ line += space + string("Target: Ping ") + iter->second._ping_target + "\n";
+
char btmp[256];
string time_buf;
@@ -93,16 +100,16 @@ LBOutput::write(const LBData &lbdata)
sprintf(btmp,"%ld",secs);
time_buf += string(btmp) + "s";
+ string success_time;
if (iter->second.last_success() == 0) {
- line += string("n/a") + string("\t\t");
+ success_time = string("n/a") + string("\t\t");
}
else {
- line += time_buf + string("\t");
- if (time_buf.size() < 6) {
- line += string("\t");
- }
+ success_time = time_buf + string("\t");
}
+ line += space + space + string("Last Ping Success: ") + success_time + "\n";
+
time_buf = "";
if (iter->second.last_failure() > 0) {
@@ -137,21 +144,21 @@ LBOutput::write(const LBData &lbdata)
sprintf(btmp,"%ld",secs);
time_buf += string(btmp) + "s";
+ string failure_time;
if (iter->second.last_failure() == 0) {
- line += string("n/a") + string("\t\t");
+ failure_time = string("n/a") + string("\t\t");
}
else {
- line += time_buf + string("\t");
- if (time_buf.size() < 6) {
- line += string("\t");
- }
+ failure_time = time_buf + string("\t");
}
+ line += space + space + string("Last Ping Failure: ") + failure_time + "\n";
+
+
//now failure count
sprintf(btmp, "%ld", iter->second._hresults._failure_count);
- line += string(btmp);
- line += "\n";
+ line += space + space + string("# Ping Failure(s): ") + string(btmp) + "\n\n";
fputs(line.c_str(),fp);
++iter;
@@ -160,9 +167,9 @@ LBOutput::write(const LBData &lbdata)
//dump out the application data
- LBData::LBRuleConstIter r_iter = lbdata._lb_rule_coll.begin();
- while (r_iter != lbdata._lb_rule_coll.end()) {
- if (_debug) {
+ if (_debug) {
+ LBData::LBRuleConstIter r_iter = lbdata._lb_rule_coll.begin();
+ while (r_iter != lbdata._lb_rule_coll.end()) {
cout << "squirt out results here." << endl;
}
++r_iter;