Ad Widget

Collapse

Regular expression proc.num[]

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • kbentlage
    Junior Member
    • Oct 2020
    • 2

    #1

    Regular expression proc.num[]

    Hi There,

    I want to use a regular expression with proc.num to get the number of child-processes of FPM-Pools. Because we have several pools that have the same string in them i need a regular expression that matches the exact string.
    For example we have:
    - PHP Pool: prod
    - PHP Pool: prod_sitename1
    - PHP Pool: prod_sitename2

    When I use proc.num[] on "prod" i'll also get the processes of prod_sitename1 and prod_sitename2, i only need the count of the "prod" pool.

    As of these documentation it should be possible to use a regex in the cmdline field of proc.num[]:


    I tried several things but i cannot get this to work. What i tried:
    Code:
    proc.num["php-fpm",,,"^(myPoolName$)"]
    proc.num["php-fpm",,,"^myPoolName$"]
    proc.num["php-fpm",,,"myPoolName$"]
    All give "0" as result.

    For the time being i resolved this issue with a system.run[] check which executes the following command which works perfectly:
    Code:
    system.run[ps -ef | grep php-fpm | grep myPoolName$ | wc -l]
    I would live to have this fixed with the proc.num[] check because this is more "native" and less "dirty".

    Please let me know what i can do to get this fixed.

    Thanks!
  • Hamardaban
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • May 2019
    • 2713

    #2
    to read again: https://www.zabbix.com/documentation..._mem_num_notes
    to do: proc.num[,,,"^.*myPoolName.*$"]
    Most likely, your expression doesn't work because the regular expression handler treats $ as a special end-of-line character.
    Last edited by Hamardaban; 20-10-2020, 19:29.

    Comment

    • kbentlage
      Junior Member
      • Oct 2020
      • 2

      #3
      Hi Hamardaban,

      I tried your suggestion, but it will still give the total amount of processes (including _sitename1 and _sitename2)

      Code:
      zabbix_agentd --test proc.num["php-fpm",,,"^.*myPoolName.*$"]
      Seems like the $ does not work yet.

      Comment

      • Hamardaban
        Senior Member
        Zabbix Certified SpecialistZabbix Certified Professional
        • May 2019
        • 2713

        #4
        You need to make the regex expression more precise
        Show the output of the «ps -auxw | grep php-fpm»

        Comment

        Working...