Update stats.py

IP and HOST were being returned with newline characters at the end causing issue #349 

I've used tr to trim the newline character from the stream.
This commit is contained in:
jsankovitch 2018-12-24 09:37:44 -06:00 committed by GitHub
parent 81556d81b3
commit 5d285cc366
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -74,9 +74,9 @@ while True:
# Shell scripts for system monitoring from here :
# https://unix.stackexchange.com/questions/119126/command-to-display-memory-usage-disk-usage-and-cpu-load
cmd = "hostname -I | cut -d\' \' -f1"
cmd = "hostname -I | cut -d\' \' -f1 | tr -d \'\\n\'"
IP = subprocess.check_output(cmd, shell=True)
cmd = "hostname"
cmd = "hostname | tr -d \'\\n\'"
HOST = subprocess.check_output(cmd, shell=True)
cmd = "top -bn1 | grep load | awk " \
"'{printf \"CPU Load: %.2f\", $(NF-2)}'"