File: //proc/thread-self/root/etc/zabbix/monitoring/check_qty_php.py
#!/usr/bin/env python3
import subprocess
import sys
def count_conf_files(version):
try:
# Executa o comando find usando subprocess
result = subprocess.run(
['find', f'/etc/php-fpm.d/{version}', '-type', 'f', '-name', '*.conf'],
stdout=subprocess.PIPE,
stderr=subprocess.DEVNULL,
universal_newlines=True # Substitui text=True
)
# Conta as linhas na sa_da do find (cada linha _ um arquivo encontrado)
count = len(result.stdout.splitlines())
print(f"{count}")
except Exception as e:
print(f"0")
if __name__ == "__main__":
if len(sys.argv) != 2:
sys.exit(1)
version = sys.argv[1]
count_conf_files(version)