| Server IP : 112.74.42.100 / Your IP : 216.73.216.142 Web Server : nginx/1.20.2 System : Linux iZwz96lx4pjqiy84w4hni7Z 5.10.134-17.3.al8.x86_64 #1 SMP Thu Oct 31 14:29:57 CST 2024 x86_64 User : www ( 1000) PHP Version : 8.0.26 Disable Function : passthru,exec,system,putenv,chroot,chgrp,chown,shell_exec,popen,proc_open,pcntl_exec,ini_alter,ini_restore,dl,openlog,syslog,readlink,symlink,popepassthru,pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,imap_open,apache_setenv MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/local/sysak/.sysak_components/tools/ossre_set/tools/ |
Upload File : |
# -*- coding: utf-8 -*-
# @Author: shiyan
import os
import sys
import datetime,time
import subprocess
import re
import socket
import json
import traceback
import importlib
import loadcheck,semcheck,rwsemcheck,mutexcheck,alidiagnose,perf
from time import sleep
sys.path.append(os.path.dirname(os.path.abspath(__file__)))
sys.path.append("%s/../"%(os.path.dirname(os.path.abspath(__file__))))
import utils
import collect_data
if sys.version[0] == '2':
reload(sys)
sys.setdefaultencoding('utf8')
def main():
sn = ''
data = {}
ret = {}
ret['return'] = False
ret['solution'] = {}
ret['solution']['detail'] = []
ret['solution']['summary'] = ''
hotfix = ''
try:
for subdir, dirs, files in os.walk("%s/../rules"%(os.path.dirname(os.path.abspath(__file__)))):
for file in files:
filepath = subdir + os.sep + file
if os.path.isfile(filepath) and file.endswith('.py'):
rule_mod = file[:-3]
try:
mod = importlib.import_module(rule_mod)
if (hasattr(mod, "get_category") and mod.get_category()=="systemd"):
print( filepath)
result = mod.query(sn, data)
if result['return']:
ret['return'] = True
ret['solution']['detail'].append(result)
ret['solution']['summary'] += ("%s\n"%(result['solution']))
except Exception as e:
traceback.print_exc()
pass
if len(ret['solution']['summary']) <= 0:
ret['solution']['summary'] = '未发现异常'
print json.dumps(ret,ensure_ascii=False)
f = open("/tmp/systemdcheck.log", "w+")
f.write(json.dumps(ret,ensure_ascii=False))
f.close()
except:
ret['solution']['summary'] += "解析异常!\n"
f = open("/tmp/systemdcheck.log", "w+")
f.write(json.dumps(ret,ensure_ascii=False))
f.close()
traceback.print_exc()
print "systemdcheck exception!"
if __name__ == "__main__":
if os.path.isfile("/tmp/systemdcheck.log"):
cmd = 'echo "" > /tmp/systemdcheck.log'
output = os.popen(cmd)
output.close()
print "/tmp/systemdcheck.log exist"
else:
print "/tmp/systemdcheck.log not exist"
main()