Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New parser: php-fpm8.2 -tt #546

Open
chriscroome opened this issue Feb 25, 2024 · 2 comments
Open

New parser: php-fpm8.2 -tt #546

chriscroome opened this issue Feb 25, 2024 · 2 comments
Labels

Comments

@chriscroome
Copy link
Contributor

The PHP-FPM configuration for a specific version of PHP is returned as standard error with:

/usr/sbin/php-fpm8.2 -tt
[25-Feb-2024 20:25:25] NOTICE: [global]
[25-Feb-2024 20:25:25] NOTICE:  pid = /run/php/php8.2-fpm.pid
[25-Feb-2024 20:25:25] NOTICE:  error_log = /var/log/php8.2-fpm.log
[25-Feb-2024 20:25:25] NOTICE:  syslog.ident = php-fpm
[25-Feb-2024 20:25:25] NOTICE:  syslog.facility = 24
[25-Feb-2024 20:25:25] NOTICE:  log_buffering = yes
[25-Feb-2024 20:25:25] NOTICE:  log_level = unknown value
[25-Feb-2024 20:25:25] NOTICE:  log_limit = 1024
[25-Feb-2024 20:25:25] NOTICE:  emergency_restart_interval = 0s
[25-Feb-2024 20:25:25] NOTICE:  emergency_restart_threshold = 0
[25-Feb-2024 20:25:25] NOTICE:  process_control_timeout = 0s
[25-Feb-2024 20:25:25] NOTICE:  process.max = 0
[25-Feb-2024 20:25:25] NOTICE:  process.priority = undefined
[25-Feb-2024 20:25:25] NOTICE:  daemonize = yes
[25-Feb-2024 20:25:25] NOTICE:  rlimit_files = 0
[25-Feb-2024 20:25:25] NOTICE:  rlimit_core = 0
[25-Feb-2024 20:25:25] NOTICE:  events.mechanism = epoll
[25-Feb-2024 20:25:25] NOTICE:  systemd_interval = 10s
[25-Feb-2024 20:25:25] NOTICE:  
[25-Feb-2024 20:29:38] NOTICE: [www]
[25-Feb-2024 20:29:38] NOTICE:  prefix = undefined
[25-Feb-2024 20:29:38] NOTICE:  user = www-data
[25-Feb-2024 20:29:38] NOTICE:  group = www-data
[25-Feb-2024 20:29:38] NOTICE:  listen = /run/php/php8.2-fpm.sock
[25-Feb-2024 20:29:38] NOTICE:  listen.backlog = -1
[25-Feb-2024 20:29:38] NOTICE:  listen.acl_users = undefined
[25-Feb-2024 20:29:38] NOTICE:  listen.acl_groups = undefined
[25-Feb-2024 20:29:38] NOTICE:  listen.owner = www-data
[25-Feb-2024 20:29:38] NOTICE:  listen.group = www-data
[25-Feb-2024 20:29:38] NOTICE:  listen.mode = undefined
[25-Feb-2024 20:29:38] NOTICE:  listen.allowed_clients = undefined
[25-Feb-2024 20:29:38] NOTICE:  process.priority = undefined
[25-Feb-2024 20:29:38] NOTICE:  process.dumpable = no
[25-Feb-2024 20:29:38] NOTICE:  pm = dynamic
[25-Feb-2024 20:29:38] NOTICE:  pm.max_children = 4
[25-Feb-2024 20:29:38] NOTICE:  pm.start_servers = 1
[25-Feb-2024 20:29:38] NOTICE:  pm.min_spare_servers = 1
[25-Feb-2024 20:29:38] NOTICE:  pm.max_spare_servers = 1
[25-Feb-2024 20:29:38] NOTICE:  pm.max_spawn_rate = 32
[25-Feb-2024 20:29:38] NOTICE:  pm.process_idle_timeout = 10
[25-Feb-2024 20:29:38] NOTICE:  pm.max_requests = 1000
[25-Feb-2024 20:29:38] NOTICE:  pm.status_path = undefined
[25-Feb-2024 20:29:38] NOTICE:  pm.status_listen = undefined
[25-Feb-2024 20:29:38] NOTICE:  ping.path = undefined
[25-Feb-2024 20:29:38] NOTICE:  ping.response = undefined
[25-Feb-2024 20:29:38] NOTICE:  access.log = undefined
[25-Feb-2024 20:29:38] NOTICE:  access.format = undefined
[25-Feb-2024 20:29:38] NOTICE:  slowlog = undefined
[25-Feb-2024 20:29:38] NOTICE:  request_slowlog_timeout = 0s
[25-Feb-2024 20:29:38] NOTICE:  request_slowlog_trace_depth = 20
[25-Feb-2024 20:29:38] NOTICE:  request_terminate_timeout = 0s
[25-Feb-2024 20:29:38] NOTICE:  request_terminate_timeout_track_finished = no
[25-Feb-2024 20:29:38] NOTICE:  rlimit_files = 0
[25-Feb-2024 20:29:38] NOTICE:  rlimit_core = 0
[25-Feb-2024 20:29:38] NOTICE:  chroot = undefined
[25-Feb-2024 20:29:38] NOTICE:  chdir = undefined
[25-Feb-2024 20:29:38] NOTICE:  catch_workers_output = no
[25-Feb-2024 20:29:38] NOTICE:  decorate_workers_output = yes
[25-Feb-2024 20:29:38] NOTICE:  clear_env = yes
[25-Feb-2024 20:29:38] NOTICE:  security.limit_extensions = .php .phar
[25-Feb-2024 20:29:38] NOTICE:  
[25-Feb-2024 20:29:38] NOTICE: configuration file /etc/php/8.2/fpm/php-fpm.conf test is successful

This can be parsed using the ini parser and some pre-processing:

php-fpm8.2 -tt |& sed 's/.*NOTICE://' | sed 's/configuration file.*//' | jc --ini -p
{
  "global": {
    "pid": "/run/php/php8.2-fpm.pid",
    "error_log": "/var/log/php8.2-fpm.log",
    "syslog.ident": "php-fpm",
    "syslog.facility": "24",
    "log_buffering": "yes",
    "log_level": "unknown value",
    "log_limit": "1024",
    "emergency_restart_interval": "0s",
    "emergency_restart_threshold": "0",
    "process_control_timeout": "0s",
    "process.max": "0",
    "process.priority": "undefined",
    "daemonize": "yes",
    "rlimit_files": "0",
    "rlimit_core": "0",
    "events.mechanism": "epoll",
    "systemd_interval": "10s"
  },
  "www": {
    "prefix": "undefined",
    "user": "www-data",
    "group": "www-data",
    "listen": "/run/php/php8.2-fpm.sock",
    "listen.backlog": "-1",
    "listen.acl_users": "undefined",
    "listen.acl_groups": "undefined",
    "listen.owner": "www-data",
    "listen.group": "www-data",
    "listen.mode": "undefined",
    "listen.allowed_clients": "undefined",
    "process.priority": "undefined",
    "process.dumpable": "no",
    "pm": "dynamic",
    "pm.max_children": "4",
    "pm.start_servers": "1",
    "pm.min_spare_servers": "1",
    "pm.max_spare_servers": "1",
    "pm.max_spawn_rate": "32",
    "pm.process_idle_timeout": "10",
    "pm.max_requests": "1000",
    "pm.status_path": "undefined",
    "pm.status_listen": "undefined",
    "ping.path": "undefined",
    "ping.response": "undefined",
    "access.log": "undefined",
    "access.format": "undefined",
    "slowlog": "undefined",
    "request_slowlog_timeout": "0s",
    "request_slowlog_trace_depth": "20",
    "request_terminate_timeout": "0s",
    "request_terminate_timeout_track_finished": "no",
    "rlimit_files": "0",
    "rlimit_core": "0",
    "chroot": "undefined",
    "chdir": "undefined",
    "catch_workers_output": "no",
    "decorate_workers_output": "yes",
    "clear_env": "yes",
    "security.limit_extensions": ".php .phar"
  }
}

Would this be a suitable candidate for a dedicated parser?

@kellyjonbrazil
Copy link
Owner

Hey there! Yeah, this could be a new simple parser that wraps the ini parser. Are the datetimes important? We could keep those in, too, if needed.

Another idea might be to post "recipes" for different types of output like this. Maybe we could have a recipes section to the Discussions page, or a Wiki, and/or a blog post with various ones.

@chriscroome
Copy link
Contributor Author

chriscroome commented Feb 25, 2024

The datetime is simply the time it was run at so I don't think there is any point in saving it.

The Bash >= 4 method of sending standard error to standard out, |& would make sense in the documentation or a wiki page (for older versions 2>&1 | can be used), perhaps with examples for other shells as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants