2025-04-10 15:31:39 +01:00

115 lines
3.2 KiB
Plaintext

from mystic_bbs import *
from datetime import datetime
import os, subprocess
from time import sleep
now = datetime.now()
TEXT = str(getcfg()['text'])
DATE = now.strftime("%a, %b %e %Y, %H:%M")
CFG = str(getcfg())
USER = str(getuser())
HANDLE = str(getuser()['handle'])
KEY_ESCAPE = chr(27)
def dispHeader():
A = mci2str('AV')
V = mci2str('IL')
if A == "Yes":
AVAIL = "|10YES"
else:
AVAIL = "|12NO "
if V == "On":
INVIS = "|12 NO"
else:
INVIS = "|10YES"
gotoxy(2,1); write("|10"+DATE)
gotoxy(35,1); write("|$C15"+HANDLE)
gotoxy(57,1); write("|02Avl: "+AVAIL)
gotoxy(72,1); write("|02Vis: "+INVIS)
def dispTotals():
gotoxy(64,12); write("|08|$l14.|15|TC")
def dispSysInfo():
MEMTOTLKB = os.popen("free|grep Mem|awk '{print $2}'").read().strip('\n')
MEMUSEDKB = os.popen("free|grep Mem|awk '{print $3}'").read().strip('\n')
MEMTOTLMB = int(MEMTOTLKB) / 1024
MEMUSEDMB = int(MEMUSEDKB) / 1024
gotoxy(10,13); write("|15"+str(MEMUSEDMB)+"MB|08/|15"+str(MEMTOTLMB)+"MB |03used")
NUMPROCS = os.popen('nproc').read().strip('\n')
LOADAVG = os.popen('uptime|grep -oE "average:.*"').read().split(':')[1].strip('\n').split(',')
UPTIMES = float(os.popen("cat /proc/uptime|awk '{print $1}'").read().strip('\n'))
UPTIMEM = UPTIMES / 60
UPTIMEH = UPTIMEM / 60
UPTIMED = UPTIMEH / 24
PROCESS = os.popen('ps auxwww|grep -v PID|wc -l').read().strip('\n')
gotoxy(10,14); write("|151m "+LOADAVG[0].strip(' ')+" |08/|15 5m "+LOADAVG[1].strip(' ')+" |08/|15 15m "+LOADAVG[2].strip(' '))
gotoxy(10,15); write("|15Up: "+str(int(UPTIMED))+"d "+str(int(UPTIMEH) % 24)+"h "+str(int(UPTIMEM) % 60)+"m / Running "+str(int(PROCESS)))
def dispQuickLog(log="mis"):
LOGDIR = "/mystic/logs"
if log.lower() == "mis":
logFile = 'grep -avE "HTTP|BINKP|HostName|Blocked|Connect|EVENT" `ls -1hrt '+LOGDIR+'/mis.*.log|tail -1`|tail -n5|head -n4|cut -c -76'
logFileStatus = ' |14MIS.LOG|07 '
elif log.lower() == "mutil":
logFile = 'tail -n4 '+LOGDIR+'/mutil.latest.log|cut -c -76'
logFileStatus = ' |14MUTIL.LOG|07 '
else:
logFile = 'tail -n4 '+LOGDIR+'/node'+log+'.log|cut -c -76'
logFileStatus = ' |14NODE'+log+'.LOG|07 '
gotoxy(20,18); write(logFileStatus)
SY = 19
OS = 0
lines = os.popen('grep -avE "HTTP|BINKP|HostName|Blocked|Connect|EVENT" `ls -1hrt '+LOGDIR+'/mis.*.log|tail -1`|tail -n5|head -n4|cut -c -76').readlines()
lines = os.popen(logFile).readlines()
lines = map(lambda s: s.strip(), lines)
for line in lines:
gotoxy(3,SY+OS); write("|17|15"+line.ljust(76)+"|16")
OS = OS + 1
def init():
writeln("|[0|CL")
menucmd('GD','@0@NONE@'+TEXT+'wfc/main.ans')
dispHeader()
dispTotals()
dispSysInfo()
dispQuickLog('mis')
init()
def main():
timer = 0
finished = False
while not finished:
dispHeader()
dispTotals()
dispSysInfo()
dispQuickLog('mis')
sleep(5);
#timer = timer + 1
#if timer > 5:
# finished = True
for _ in range(5):
key, ext = getkey()
if not ext:
if key.upper() == 'Q' or key == KEY_ESCAPE:
finished = True
break
sleep(1)
if __name__ == "__main__":
main()
gotoxy(1,24); writeln("|[1|PA")