-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcold.py
36 lines (35 loc) · 956 Bytes
/
cold.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import time
import sys
import subprocess
import os
import base64
import uuid
import datetime
import traceback
import base64
import json
from time import gmtime, strftime
import math
import random, string
import time
import psutil
import uuid
from getmac import get_mac_address
start = time.time()
uuid2 = '{0}_{1}'.format(strftime("%Y%m%d%H%M%S",gmtime()),uuid.uuid4())
end = time.time()
row = { }
row['host'] = os.uname()[1]
row['temperature'] = '70'
row['end'] = '{0}'.format( str(end ))
row['te'] = '{0}'.format(str(end-start))
row['systemtime'] = datetime.datetime.now().strftime('%m/%d/%Y %H:%M:%S')
row['cpu'] = psutil.cpu_percent(interval=1)
usage = psutil.disk_usage("/")
row['diskusage'] = "{:.1f} MB".format(float(usage.free) / 1024 / 1024)
row['memory'] = psutil.virtual_memory().percent
row['id'] = str(uuid2)
eth_mac = get_mac_address(interface="wlp2s0")
row['macaddress'] = ( str(eth_mac) )
json_string = json.dumps(row)
print(json_string)