Skip to content

Commit

Permalink
Fixed issue with tests and also allowed procstats to exit gracefully
Browse files Browse the repository at this point in the history
  • Loading branch information
johann8384 committed Oct 28, 2020
1 parent fa26b07 commit f7d97a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
19 changes: 11 additions & 8 deletions collectors/0/procstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,14 +142,17 @@ def cpus_csets(cpuset_path):

def main():
"""procstats main loop"""

f_uptime = open("/proc/uptime", "r")
f_meminfo = open("/proc/meminfo", "r")
f_vmstat = open("/proc/vmstat", "r")
f_stat = open("/proc/stat", "r")
f_loadavg = open("/proc/loadavg", "r")
f_entropy_avail = open("/proc/sys/kernel/random/entropy_avail", "r")
f_interrupts = open("/proc/interrupts", "r")
try:
f_uptime = open("/proc/uptime", "r")
f_meminfo = open("/proc/meminfo", "r")
f_vmstat = open("/proc/vmstat", "r")
f_stat = open("/proc/stat", "r")
f_loadavg = open("/proc/loadavg", "r")
f_entropy_avail = open("/proc/sys/kernel/random/entropy_avail", "r")
f_interrupts = open("/proc/interrupts", "r")
except FileNotFoundError as exc:
utils.err('FileNotFoundError: %s' % (sys.exc_info()[1]))
sys.exit(1)

f_scaling = "/sys/devices/system/cpu/cpu%s/cpufreq/%s_freq"
f_scaling_min = dict([])
Expand Down
3 changes: 2 additions & 1 deletion tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,8 @@ def test_endtoend(self):
"a": tcollector.Collector("mycollector", 5, "a.py"), # pylint:disable=no-member
"b": tcollector.Collector("second", 3, "b.py"), # pylint:disable=no-member
}
server = tcollector.StatusServer("127.0.0.1", 32025, collectors) # pylint:disable=no-member
reader = {}
server = tcollector.StatusServer("127.0.0.1", 32025, collectors, reader) # pylint:disable=no-member
# runs in background until test suite exits :( but it works.
thread = threading.Thread(target=server.serve_forever)
thread.setDaemon(True)
Expand Down

0 comments on commit f7d97a7

Please sign in to comment.