Repository navigation
Conversation
Adds daemon syspoll, which updates a file to be read by CLI commands, to print system status information. This is an intermediate implementation -- once the redis DB is set up for system information, this daemon should update the DB, not a file. Signed-off-by: Howard Persh <hpersh@yahoo.com>
|
*** This is a placeholder pull-request *** |
|
Looks OK to me. Once sonic-net/sonic-utilities#745 is merged, please update the submodule in the PR. |
|
|
||
| while True: | ||
| d = {} | ||
| d['hostname'] = subprocess.check_output(['hostname']).rstrip() |
There was a problem hiding this comment.
- Why do we need to update hostname each second?
- It would be simpler to open '/etc/hostname' instead of forking and running bash to run hostname
| while True: | ||
| d = {} | ||
| d['hostname'] = subprocess.check_output(['hostname']).rstrip() | ||
| w = subprocess.check_output(['free']).split('\n')[1].split() |
There was a problem hiding this comment.
Please read this info from /proc/meminfor
| d['total'] = int(w[1]) | ||
| d['used'] = int(w[2]) | ||
| d['free'] = int(w[3]) | ||
| btime = int(subprocess.check_output(['bash', '-c', "cat /proc/stat | grep '^btime'"]).split()[1]) |
There was a problem hiding this comment.
please read the file and extract info using the python language.
| d['free'] = int(w[3]) | ||
| btime = int(subprocess.check_output(['bash', '-c', "cat /proc/stat | grep '^btime'"]).split()[1]) | ||
| cpus = [] | ||
| for li in subprocess.check_output(['bash', '-c', "cat /proc/stat | grep '^cpu'"]).rstrip().split('\n'): |
There was a problem hiding this comment.
please use python, not bash in python
| cpus.append({'user': int(w[1]) + int(w[2]), 'system': int(w[3]), 'idle': int(w[4])}) | ||
| d['cpus'] = cpus | ||
| procs = {} | ||
| for li in subprocess.check_output(['ps', 'aux']).rstrip().split('\n')[1:]: |
There was a problem hiding this comment.
Please read this from /proc
| continue | ||
| pid = w[1] | ||
| try: | ||
| w2 = subprocess.check_output(['bash', '-c', 'cat /proc/{}/stat 2>/dev/null'.format(pid)]).split() |
There was a problem hiding this comment.
please read the file using python
Adds daemon syspoll, which updates a file to be read by CLI commands, to print system status information. This is an intermediate implementation -- once the redis DB is set up for system information, this daemon should update the DB, not a file.
Signed-off-by: Howard Persh hpersh@yahoo.com
- What I did
- How I did it
- How to verify it
- Description for the changelog
- A picture of a cute animal (not mandatory but encouraged)