Skip to content

Commit

Permalink
[procdockerstatsd] Fix CMD field in dB (sonic-net#4335)
Browse files Browse the repository at this point in the history
* Fix the CMD for the PROCESSSTATS entries so that
  there is a space between the command name and the
  arguments.

Signed-off-by: Garrick He <garrick_he@dell.com>
  • Loading branch information
GarrickHe authored and tiantianlv committed Apr 24, 2020
1 parent 185b8f6 commit 6329f3d
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions files/image_config/procdockerstatsd/procdockerstatsd
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ class ProcDockerStats:

def __init__(self):
self.state_db = swsssdk.SonicV2Connector(host=REDIS_HOSTIP)
self.state_db.connect("STATE_DB")
self.state_db.connect("STATE_DB")

def run_command(self, cmd):
proc = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE)
(stdout, stderr) = proc.communicate()
Expand Down Expand Up @@ -75,7 +75,7 @@ class ProcDockerStats:
# To remove extra space before UID
val = list(filter(None, values1))
# Merging extra columns created due to space in cmd ouput
val[8:] = [''.join(val[8:])]
val[8:] = [' '.join(val[8:])]
process_data = dict(zip(keylist, val))
process_data_list.append(process_data)
return process_data_list
Expand Down Expand Up @@ -109,10 +109,10 @@ class ProcDockerStats:
for row in dict_list[0:]:
cid = row.get('CONTAINER ID')
if cid:
key = 'DOCKER_STATS|' + str(cid)
key = 'DOCKER_STATS|' + str(cid)
dockerdict[key] = {}
dockerdict[key]['NAME'] = row.get('NAME')

splitcol = row.get('CPU %')
cpu = re.split("%", str(splitcol))
dockerdict[key]['CPU%'] = str(cpu[0])
Expand All @@ -131,7 +131,7 @@ class ProcDockerStats:
netio = re.split(" / ", str(splitcol))
dockerdict[key]['NET_IN_BYTES'] = str(self.convert_to_bytes(netio[0]))
dockerdict[key]['NET_OUT_BYTES'] = str(self.convert_to_bytes(netio[1]))

splitcol = row.get('BLOCK I/O')
blockio = re.split(" / ", str(splitcol))
dockerdict[key]['BLOCK_IN_BYTES'] = str(self.convert_to_bytes(blockio[0]))
Expand Down

0 comments on commit 6329f3d

Please sign in to comment.