akips 0.2.1__tar.gz → 0.2.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
''' Base module '''
|
|
2
|
-
__version__ = '0.
|
|
2
|
+
__version__ = '0.2.2'
|
|
3
3
|
|
|
4
4
|
import io
|
|
5
5
|
import re
|
|
@@ -230,12 +230,12 @@ class AKIPS:
|
|
|
230
230
|
return data
|
|
231
231
|
return None
|
|
232
232
|
|
|
233
|
-
|
|
233
|
+
# Time-series commands
|
|
234
234
|
|
|
235
235
|
def get_series(self, period='last1h', device='*', attribute='*', group_filter='any', groups=[], get_dict=True):
|
|
236
236
|
''' Pull a series of values. Command syntax:
|
|
237
|
-
cseries avg
|
|
238
|
-
time {time filter
|
|
237
|
+
cseries avg
|
|
238
|
+
time {time filter} type parent child attribute
|
|
239
239
|
[any|all|not group {group name} ...] '''
|
|
240
240
|
params = {
|
|
241
241
|
'cmds': f'cseries avg time {period} * {device} * {attribute}'
|
|
@@ -258,7 +258,27 @@ class AKIPS:
|
|
|
258
258
|
return csv_to_list
|
|
259
259
|
return None
|
|
260
260
|
|
|
261
|
-
|
|
261
|
+
def get_aggregate(self, operator='avg', interval='300', period='last1h', device='*', attribute='*', group_filter='any', groups=[]):
|
|
262
|
+
''' Aggregate stats in intervals over a period of time. Command syntax:
|
|
263
|
+
aggregate interval {avg|total seconds}
|
|
264
|
+
time {time filter} type parent child attribute
|
|
265
|
+
[any|all|not group {group name} ...] '''
|
|
266
|
+
params = {
|
|
267
|
+
'cmds': f'aggregate interval {operator} {interval} time {period} * {device} * {attribute}'
|
|
268
|
+
}
|
|
269
|
+
if groups:
|
|
270
|
+
group_list = " ".join(groups)
|
|
271
|
+
params['cmds'] += f" {group_filter} group {group_list}"
|
|
272
|
+
text = self._get(params=params)
|
|
273
|
+
if text:
|
|
274
|
+
# Text should be one CSV line followed by one blank line
|
|
275
|
+
lines = text.split('\n')
|
|
276
|
+
values = lines[0].split(',')
|
|
277
|
+
logger.debug("Found {} aggregate values".format(len(values)))
|
|
278
|
+
return values
|
|
279
|
+
return None
|
|
280
|
+
|
|
281
|
+
# Base operations
|
|
262
282
|
|
|
263
283
|
def _get(self, section='/api-db/', params=None, timeout=30):
|
|
264
284
|
''' Call HTTP GET against the AKiPS server '''
|
|
@@ -266,6 +286,8 @@ class AKIPS:
|
|
|
266
286
|
params['username'] = self.username
|
|
267
287
|
params['password'] = self.password
|
|
268
288
|
|
|
289
|
+
if 'cmds' in params:
|
|
290
|
+
logger.debug("akips command: {}".format(params['cmds']))
|
|
269
291
|
try:
|
|
270
292
|
r = self.session.get(server_url, params=params, verify=self.verify, timeout=timeout)
|
|
271
293
|
r.raise_for_status()
|
|
@@ -287,4 +309,5 @@ class AKIPS:
|
|
|
287
309
|
logger.error("Web API request failed: {}".format(r.text))
|
|
288
310
|
raise AkipsError(message=r.text)
|
|
289
311
|
else:
|
|
312
|
+
logger.debug("akips output: {}".format(r.text))
|
|
290
313
|
return r.text
|
|
File without changes
|
|
File without changes
|
|
File without changes
|