mirror of
https://github.com/powerline/powerline.git
synced 2025-07-31 01:35:40 +02:00
Move system_load segment code
This commit is contained in:
parent
0d097139d6
commit
f610527bea
@ -72,22 +72,6 @@ def external_ip(query_url='http://ipv4.icanhazip.com/'):
|
|||||||
return
|
return
|
||||||
|
|
||||||
|
|
||||||
def system_load(format='{avg[0]:.1f}, {avg[1]:.1f}, {avg[2]:.1f}'):
|
|
||||||
from multiprocessing import cpu_count
|
|
||||||
averages = os.getloadavg()
|
|
||||||
normalized = averages[1] / cpu_count()
|
|
||||||
if normalized < 1:
|
|
||||||
gradient = 'system_load_good'
|
|
||||||
elif normalized < 2:
|
|
||||||
gradient = 'system_load_bad'
|
|
||||||
else:
|
|
||||||
gradient = 'system_load_ugly'
|
|
||||||
return {
|
|
||||||
'contents': format.format(avg=averages),
|
|
||||||
'highlight': [gradient, 'system_load']
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
def uptime(format='{days:02d}d {hours:02d}h {minutes:02d}m'):
|
def uptime(format='{days:02d}d {hours:02d}h {minutes:02d}m'):
|
||||||
# TODO: make this work with operating systems without /proc/uptime
|
# TODO: make this work with operating systems without /proc/uptime
|
||||||
try:
|
try:
|
||||||
@ -130,6 +114,22 @@ def weather(unit='c', location_query=None):
|
|||||||
return u'{0} {1}°{2}'.format(icon, condition['temp'], unit.upper())
|
return u'{0} {1}°{2}'.format(icon, condition['temp'], unit.upper())
|
||||||
|
|
||||||
|
|
||||||
|
def system_load(format='{avg[0]:.1f}, {avg[1]:.1f}, {avg[2]:.1f}'):
|
||||||
|
from multiprocessing import cpu_count
|
||||||
|
averages = os.getloadavg()
|
||||||
|
normalized = averages[1] / cpu_count()
|
||||||
|
if normalized < 1:
|
||||||
|
gradient = 'system_load_good'
|
||||||
|
elif normalized < 2:
|
||||||
|
gradient = 'system_load_bad'
|
||||||
|
else:
|
||||||
|
gradient = 'system_load_ugly'
|
||||||
|
return {
|
||||||
|
'contents': format.format(avg=averages),
|
||||||
|
'highlight': [gradient, 'system_load']
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
def network_load(interface='eth0', measure_interval=1, suffix='B/s', binary_prefix=False):
|
def network_load(interface='eth0', measure_interval=1, suffix='B/s', binary_prefix=False):
|
||||||
import time
|
import time
|
||||||
from powerline.lib import humanize_bytes
|
from powerline.lib import humanize_bytes
|
||||||
|
Loading…
x
Reference in New Issue
Block a user