Skip to content

Commit f6bcfb5

Browse files
committed
work around for capacity metrics
Signed-off-by: hwassman <[email protected]>
1 parent 889c94f commit f6bcfb5

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

source/queryHandler/Query.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,10 @@ class Query(object):
4949
"operation", "protocol", "waiters_time_threshold", "export",
5050
"nodegroup", "account", "filesystem", "tct_csap", "tct_operation", "cloud_nodeclass"])
5151

52+
DISK_CAP_METRICS = set(["gpfs_disk_disksize", "gpfs_disk_free_fullkb", "gpfs_disk_free_fragkb",
53+
"gpfs_pool_disksize", "gpfs_pool_free_fragkb", "gpfs_pool_free_fullkb",
54+
"gpfs_fs_inode_used", "gpfs_fs_inode_free", "gpfs_fs_inode_alloc", "gpfs_fs_inode_max"])
55+
5256
def __init__(self, metrics=None, bucketsize=1, filters=None, groupby=None, includeDiskData=False):
5357
'''
5458
Constructor, filters and groupby must be preformmated
@@ -184,7 +188,11 @@ def addMeasurement(self, meassure):
184188
def __str__(self):
185189
# dd = '-a' if self.includeDiskData else ''
186190
# Workaround for RTC Defect 280368: Zimon capacity query does not return all results (seen on CNSA)
187-
if (self.metrics and any('gpfs_disk_' in metric for metric in self.metrics)) or (self.sensor and self.sensor == "GPFSDiskCap"):
191+
if (self.metrics and
192+
any(str(metric) in self.DISK_CAP_METRICS for metric in self.metrics)
193+
) or (self.sensor and
194+
self.sensor in ("GPFSDiskCap","GPFSPoolCap", "GPFSInodeCap")
195+
):
188196
dd = '-ar'
189197
elif self.includeDiskData:
190198
dd = '-a'

tests/test_query.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from source.queryHandler.Query import Query
2+
from source.__version__ import __version__ as version
3+
from nose2.tools.decorators import with_setup
4+
5+
6+
def my_setup():
7+
global metrics, metrics1
8+
metrics = ['cpu_user']
9+
metrics1 = ['gpfs_fs_inode_used']
10+
11+
@with_setup(my_setup)
12+
def test_case01():
13+
query = Query(metrics)
14+
assert len(str(query)) > 0
15+
assert "cpu_user" in str(query)
16+
assert "-ar" not in str(query)
17+
18+
@with_setup(my_setup)
19+
def test_case02():
20+
query = Query(metrics1)
21+
assert "-ar" in str(query)

0 commit comments

Comments
 (0)