Files
zabbix_scripts/lld_php_fpm_url.py
2025-10-07 14:38:54 +02:00

25 lines
743 B
Python
Executable File

#! /usr/bin/env python3
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))