Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add daemon which periodically pushes process and docker stats to State DB #3525

Merged
merged 21 commits into from
Nov 27, 2019
Merged
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 9 additions & 7 deletions files/image_config/procdockerstats/procdockerstats
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@ procdockerstats
Daemon which periodically gathers process and docker statistics and pushes the data to STATE_DB
'''

import sys
import os
import time
import syslog
import subprocess
import re
import swsssdk
import subprocess
import sys
import syslog
import time
from datetime import datetime

import swsssdk

VERSION = '1.0'

SYSLOG_IDENTIFIER = "procdockerstats"
Expand Down Expand Up @@ -154,6 +155,7 @@ class ProcDockerStats:
for k1,v1 in dockerdata.iteritems():
for k2,v2 in v1.iteritems():
self.update_state_db(k1, k2, v2)
pra-moh marked this conversation as resolved.
Show resolved Hide resolved
return True
jleveque marked this conversation as resolved.
Show resolved Hide resolved

def update_processstats_command(self):
data = self.run_command("ps -eo uid,pid,ppid,%mem,%cpu,stime,tty,time,cmd --sort -%cpu | head -5")
Expand Down Expand Up @@ -189,9 +191,9 @@ class ProcDockerStats:
self.update_dockerstats_command()
datetimeobj = datetime.now()
# Adding key to store latest update time.
self.update_state_db('Docker_Stats|LastUpdateTime', 'lastupdate', datetimeobj)
self.update_state_db('DOCKER_STATS|LastUpdateTime', 'lastupdate', datetimeobj)
self.update_processstats_command()
self.update_state_db('Process_Stats|LastUpdateTime', 'lastupdate', datetimeobj)
self.update_state_db('PROCESS_STATS|LastUpdateTime', 'lastupdate', datetimeobj)

# main start
def main():
Expand Down