Files
zabbix_scripts/lld_php_fpm_url.py
2025-03-03 14:53:30 +01:00

26 lines
868 B
Python
Executable File

#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))