This repository has been archived by the owner on Aug 3, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #241 from cjellick/blkio
Add supprt for iops
- Loading branch information
Showing
8 changed files
with
193 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
image: rancher/dind:v1.9.0-rancher1 | ||
image: rancher/dind:v1.10.3-rancher1 | ||
script: | ||
- ./scripts/ci |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
FROM rancher/dind:v1.9.0-rancher1 | ||
FROM rancher/dind:v1.10.3-rancher1 | ||
COPY ./scripts/bootstrap /scripts/bootstrap | ||
RUN /scripts/bootstrap | ||
WORKDIR /source |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
import logging | ||
import platform | ||
import json | ||
|
||
log = logging.getLogger('iops') | ||
|
||
|
||
class IopsCollector(object): | ||
def __init__(self): | ||
self.data = {} | ||
|
||
def _get_iops_data(self, read_or_write): | ||
with open('/var/lib/rancher/state/' + read_or_write + '.json') as f: | ||
return json.load(f) | ||
|
||
def _parse_iops_file(self): | ||
data = {} | ||
|
||
try: | ||
read_json_data = self._get_iops_data('read') | ||
write_json_data = self._get_iops_data('write') | ||
except IOError: | ||
# File doesn't exist. Silently skip. | ||
return {} | ||
|
||
read_iops = read_json_data['jobs'][0]['read']['iops'] | ||
write_iops = write_json_data['jobs'][0]['write']['iops'] | ||
device = read_json_data['disk_util'][0]['name'] | ||
key = '/dev/' + device.encode('ascii', 'ignore') | ||
data[key] = {'read': read_iops, 'write': write_iops} | ||
return data | ||
|
||
def key_name(self): | ||
return "iopsInfo" | ||
|
||
def get_data(self): | ||
if platform.system() == 'Linux': | ||
if not self.data: | ||
self.data = self._parse_iops_file() | ||
return self.data | ||
else: | ||
return {} | ||
|
||
def get_default_disk(self): | ||
data = self.get_data() | ||
if not data: | ||
return None | ||
|
||
# Return the first and only item in the dict | ||
return data[data.keys()[0]] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters