Ad Widget

Collapse

PHP-FPM multiple processes names

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Massimiliano Micol
    Junior Member
    • Feb 2022
    • 2

    #1

    PHP-FPM multiple processes names

    Greetings,
    I need to monitor several FPM processes (which are using Apache). I added the "PHP-FPM by Zabbix agent" template and it is working. There are several keys (such as proc.cpu.util["{$PHP_FPM.PROCESS_NAME}"]) where the process's name is required, but I have several processes with different names ("php-fpm: pool web325", "php-fpm: pool web326"...), names that can (and will) change over time. Is there a way to automatically discover the several names without having to write hacky shell scripts?
  • Massimiliano Micol
    Junior Member
    • Feb 2022
    • 2

    #2
    I have been able to autodiscover the names by adding a UserParameter named "php.fpm.discovery" in my remote agent which executes this command:
    Code:
    ps aux | grep "[p]hp-fpm: pool" | awk '{printf("%s %s %s\n", $(NF - 2), $(NF - 1), $(NF))}'
    Then I added a new discovery rule to php.fpm.discovery with two preprocessing rules, the first being JavaScript that executes
    Code:
    return JSON.stringify(value.split("\n").filter(function(name) {
    return name !== 'php-fpm: pool www';
    }).map(function (name) {
    return ({"{#PHP_FPM.PROCESS_NAME}": name});
    }));
    and then a Discard rule to remove old items. Then I created an item prototype with name
    Code:
    PHP-FPM: CPU utilization {#PHP_FPM.PROCESS_NAME}
    and key
    Code:
    proc.cpu.util["{#PHP_FPM.PROCESS_NAME}"]
    ---
    Now I need a hand. Some processes have the same name. What is returned by
    Code:
    proc.cpu.util
    when querying about a process name? What does it return? The values I'm getting seem to differ from the htop ones, what is happening behind the scenes? I tried to look at the source code but I didn't understand much.
    Thank you for any help

    Comment

    Working...