Skip to content

Commit

Permalink
added uptime to platform stats
Browse files Browse the repository at this point in the history
  • Loading branch information
Jason Yates authored and Jason Yates committed Jun 29, 2018
1 parent 195ac83 commit b61eb04
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion genmonlib/myplatform.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
#
#-------------------------------------------------------------------------------
from subprocess import PIPE, Popen
import os, sys, subprocess, re
import os, sys, subprocess, re, datetime
import collections
import mycommon

Expand Down Expand Up @@ -216,6 +216,14 @@ def GetLinuxInfo(self):
LinuxInfo["OS Name"] = OSReleaseInfo["NAME"]
LinuxInfo["OS Version"] = OSReleaseInfo["VERSION"]

try:
with open('/proc/uptime', 'r') as f:
uptime_seconds = float(f.readline().split()[0])
uptime_string = str(datetime.timedelta(seconds = uptime_seconds))
LinuxInfo["System Uptime"] = uptime_string.split(".")[0] # remove microseconds
except Exception as e1:
pass

try:
adapter = os.popen("ip link | grep BROADCAST | grep -v NO-CARRIER | grep -m 1 LOWER_UP | awk -F'[:. ]' '{print $3}'").readline().rstrip("\n")
#output, _error = process.communicate()
Expand Down

0 comments on commit b61eb04

Please sign in to comment.