Hi
I have a question about Opserver module in contrail-controller. There is a
little problem when I want to gather information about network traffic
(in_bytes, out_bytes per virtual machine): Returned values informs about
traffic in last hour. It would be good to be able to customize this time. I
looked at source code, to find out what can I do with this and then I saw
this:
q["query"]["start_time"] = qdict["end_time"] - (3600 * 1000000)
Could we change this to:
q["query"]["start_time"] = qdict["end_time"] - (period * 1000000)
?
Additional parameter could be passed with GET request. By default it could
be 3600 as before.
Also, there is one more problem with tests in opserver. If I run:
"scons controller/src/opserver:test"
it fails with:
PyTestSuiteCov(["build/debug/opserver/test/opserver-test"],
["build/debug/opserver/test/uveserver_test.py",
"build/debug/opserver/test/analytics_uvetest.py",
"build/debug/opserver/test/analytics_systest.py",
"build/debug/opserver/test/analytics_statstest.py",
"build/debug/opserver/test/analytics_db_test.py",
"build/debug/opserver/test/overlay_to_underlay_mapper_test.py"])
/home/ubuntu/contrail_source/build/debug/opserver/test/uveserver_test.py
PASS
/home/ubuntu/contrail_source/build/debug/opserver/test/analytics_uvetest.py
FAIL
If I run this test manually (activating analytics_test env before) I see a
lot of "Connection refused" error messages. It seems like I need to run it
in complete environment (with working controller). At least it should be
excluded from tests suite?
Have a nice day
--
Alicja Celigowska
Software Engineer
---------------------------------
M: +48 531 033 070
E: [email protected]
---------------------------------
CodiLime Sp. z o.o. - Ltd. company with its registered office in Poland,
01-167 Warsaw, ul. Zawiszy 14/97. Registered by The District Court for the
Capital City of Warsaw, XII Commercial Department of the National Court
Register. Entered into National Court Register under No. KRS 0000388871.
Tax identification number (NIP) 5272657478. Statistical number (REGON)
142974628.
-----------------------------------------
The information in this email is confidential and may be legally
privileged, it may contain information that is confidential in CodiLime Sp.
z o.o. It is intended solely for the addressee. Any access to this email by
third parties is unauthorized. If you are not the intended recipient of
this message, any disclosure, copying, distribution or any action
undertaken or neglected in reliance thereon is prohibited and may result in
your liability for damages.
diff --git a/src/opserver/opserver.py b/src/opserver/opserver.py
index dece586..8b0daf6 100644
--- a/src/opserver/opserver.py
+++ b/src/opserver/opserver.py
@@ -1400,6 +1400,10 @@ class OpServer(object):
if 'flat' in req.keys():
flat = True
+ period = 3600
+ if 'period' in req.keys():
+ period = int(req.period)
+
any_filter, kfilter, sfilter, mfilter, tfilter = \
OpServer._uve_filter_set(req)
if any_filter:
@@ -1413,7 +1417,7 @@ class OpServer(object):
for gen in self._uve_server.multi_uve_get(uve_name, flat,
kfilter, sfilter,
mfilter, tfilter,
- is_alarm):
+ is_alarm, period):
if first:
yield u'' + json.dumps(gen)
first = False
@@ -1423,7 +1427,8 @@ class OpServer(object):
else:
rsp = self._uve_server.get_uve(uve_name, flat, sfilter,
mfilter, tfilter,
- is_alarm=is_alarm)
+ is_alarm=is_alarm,
+ period=period)
yield json.dumps(rsp)
# end _uve_alarm_http_get
diff --git a/src/opserver/uveserver.py b/src/opserver/uveserver.py
index 3afe8a0..140fab2 100644
--- a/src/opserver/uveserver.py
+++ b/src/opserver/uveserver.py
@@ -221,7 +221,7 @@ class UVEServer(object):
return uves
def get_uve(self, key, flat, sfilter=None, mfilter=None,
- tfilter=None, multi=False, is_alarm=False):
+ tfilter=None, multi=False, is_alarm=False, period=3600):
state = {}
state[key] = {}
statdict = {}
@@ -339,7 +339,7 @@ class UVEServer(object):
for t,q in qmap.iteritems():
try:
q["query"]["end_time"] = OpServerUtils.utc_timestamp_usec()
- q["query"]["start_time"] = qdict["end_time"] - (3600 * 1000000)
+ q["query"]["start_time"] = qdict["end_time"] - (period * 1000000)
json_str = json.dumps(q["query"])
resp = OpServerUtils.post_url_http(url, json_str, True)
if resp is not None:
@@ -392,7 +392,7 @@ class UVEServer(object):
# end get_uve_regex
def multi_uve_get(self, key, flat, kfilter, sfilter, mfilter,
- tfilter, is_alarm=False):
+ tfilter, is_alarm=False, period=3600):
tbl_uve = key.split(':', 1)
table = tbl_uve[0]
@@ -416,7 +416,7 @@ class UVEServer(object):
continue
uve_val = self.get_uve(
table + ':' + uve_name, flat,
- sfilter, mfilter, tfilter, True, is_alarm)
+ sfilter, mfilter, tfilter, True, is_alarm, period)
if uve_val == {}:
continue
else:_______________________________________________
Dev mailing list
[email protected]
http://lists.opencontrail.org/mailman/listinfo/dev_lists.opencontrail.org