diff options
author | gimpei <gim.kobayashi@gmail.com> | 2017-08-13 07:23:45 +0900 |
---|---|---|
committer | gimpei <gim.kobayashi@gmail.com> | 2017-08-13 07:23:45 +0900 |
commit | a7dd2368c76e52028fa9d11b98a242d75ead4a75 (patch) | |
tree | 6dff05dc8bf95e5211408c8596b1b9546ad98848 | |
parent | 9b7b935f7944206fdd3581a5c5da4b3c1dd39f8a (diff) | |
download | kawaii-term-a7dd2368c76e52028fa9d11b98a242d75ead4a75.tar.gz |
a
-rw-r--r-- | kawaii-term.py | 21 |
1 files changed, 20 insertions, 1 deletions
diff --git a/kawaii-term.py b/kawaii-term.py index f868fb9..6370d24 100644 --- a/kawaii-term.py +++ b/kawaii-term.py @@ -7,6 +7,25 @@ if '--mem' in sys.argv: line = line.strip() # デフォルトではKB表現だから、メガバイトで表現する mem = re.split(r'\s{1,}', line)[-2] - mem = '%d MB'%(int(mem)//1000) + mem = 'Mem=%d MB'%(int(mem)//1000) print( mem ) break + +if '--vmstat' in sys.argv: + buff = os.popen('vmstat').read().split('\n') + keys = re.split(r'\s{1,}', buff[1]) + vals = re.split(r'\s{1,}', buff[2]) + obj = dict( zip(keys, vals) ) + ucpu = '💻 ={0:03d}%'.format( int(obj['us']) ) + print( ucpu ) + +if '--disk' in sys.argv: + buff =os.popen('df -hT').read().split('\n') + # 末尾が/で終わるのが、ルートディレクトリ表示 + keys = re.split(r'\s{1,}', buff[0]) + vals = re.split(r'\s{1,}', list( filter(lambda x:len(x) != 0 and x[-1] == '/', buff[1:]) )[0] ) + obj = dict(zip( keys, vals) ) + use = obj['Use%'] + free = obj['Avail'] + result = 'DiskUse%={}, DiskAvail={}'.format(use, free) + print(result) |