make it simpler
This commit is contained in:
25
lld_php_fpm_url.py
Executable file
25
lld_php_fpm_url.py
Executable file
@@ -0,0 +1,25 @@
|
||||
#jinja2:variable_start_string:'[%',variable_end_string:'%]',comment_start_string:'<%',comment_end_string:'%>'
|
||||
#! [% discovered_interpreter_python %]
|
||||
import json
|
||||
import os
|
||||
import re
|
||||
import glob
|
||||
|
||||
dir="/etc/httpd/conf.d/"
|
||||
|
||||
phpfpm_status_url="ncstatus"
|
||||
|
||||
# we get all url from apache config files
|
||||
# we know that name of site == name of file
|
||||
if __name__ == "__main__":
|
||||
filelist = glob.glob( dir + '*.conf' )
|
||||
result=[]
|
||||
for file in filelist:
|
||||
poolname=os.path.basename( file )
|
||||
poolname=re.sub( '\.conf$', '', poolname )
|
||||
for line in open(file):
|
||||
res=re.search( phpfpm_status_url, line)
|
||||
if res:
|
||||
url=re.sub( r'\.conf$', '', os.path.basename(file) )
|
||||
result.append({ "{#POOLNAME}": poolname, "{#POOLURL}": 'https://' +url +"/"+ phpfpm_status_url})
|
||||
print(json.dumps({"data": result}, indent=4))
|
||||
Reference in New Issue
Block a user