Skip to content

Commit

Permalink
Fix netusage query to get proc w/o netdata too
Browse files Browse the repository at this point in the history
  • Loading branch information
ydkhatri committed Aug 1, 2021
1 parent 7e4cbc3 commit 480934b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
4 changes: 3 additions & 1 deletion plugins/helpers/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ def ReadMacAbsoluteTime(mac_abs_time): # Mac Absolute time is time epoch beginni
try:
if isinstance(mac_abs_time, str):
mac_abs_time = float(mac_abs_time)
if mac_abs_time > 0xFFFFFFFF: # more than 32 bits, this should be nano-second resolution timestamp (seen only in HighSierra)
if mac_abs_time in (-63114076800, -63114076800000000000) : # MS & Python considers -63113904000 as 01-01-0001, Apple considers -63114076800
return datetime.datetime(1,1,1)
if abs(mac_abs_time) > 0xFFFFFFFF: # more than 32 bits, this should be nano-second resolution timestamp (seen only in HighSierra)
return datetime.datetime(2001, 1, 1) + datetime.timedelta(seconds=mac_abs_time/1000000000.)
return datetime.datetime(2001, 1, 1) + datetime.timedelta(seconds=mac_abs_time)
except (ValueError, OverflowError, TypeError) as ex:
Expand Down
2 changes: 1 addition & 1 deletion plugins/netusage.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def ReadNetUsageDb(db, netusage_items, source):
"p.ztimestamp as last_seen_date, "\
" lu.ztimestamp as usage_since, "\
"lu.zwifiin, lu.zwifiout,lu.zwiredin,lu.zwiredout,lu.zwwanin,lu.zwwanout "\
"FROM zliveusage lu LEFT JOIN zprocess p ON p.z_pk = lu.zhasprocess "\
"FROM zprocess p LEFT JOIN zliveusage lu ON p.z_pk = lu.zhasprocess "\
"LEFT JOIN z_primarykey pk ON p.z_ent = pk.z_ent "\
"ORDER BY process_name"
db.row_factory = sqlite3.Row
Expand Down

0 comments on commit 480934b

Please sign in to comment.