def v_nginx(req): cdic = dict( conf = None, pid = None, process = None ) try: cdic['conf'] = read_file(config.NGINX['CONF_PATH']) except IOError: pass if cdic['conf']: conf_file = StringIO(cdic['conf']) for line in conf_file: rep = re.compile(ur'^pid\s(?P<path>.*);') res = rep.search(line) if res: pid_path = res.group('path') pid_raw = read_file(pid_path) cdic['pid'] = TextFilter(int).clean(pid_raw) print cdic['pid'] conf_file.close() if cdic['pid']: cdic['process'] = cmd_output('ps u p %s' % cdic['pid']) print cdic['process'] return HttpResponse('xx')
def v_cmd_ajax_exec(req): cmd = req.POST.get('cmd') if not cmd: return HttpResponse('No CMD Output', status='404') cmdOutput = cmd_output(cmd) if not cmdOutput: return HttpResponse('Uneffect CMD', status='400') return HttpResponse(cmdOutput)