Ad Widget

Collapse

Process count with cmdline

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • UDMISHRA
    Junior Member
    • Mar 2017
    • 1

    #1

    Process count with cmdline

    Hi,

    I am trying to configure zabbix to count the number of a process.


    admin@ip-10-22-215-171:~$ ps -ef | grep feapp
    admin 12892 12774 0 22:09 pts/0 00:00:00 grep feapp
    admin 23701 13236 8 Mar21 ? 02:49:26 /home/admin/.virtualenvs/express/bin/python /home/admin/express/manage.py celery worker -n feapp --loglevel=info --without-mingle --without-gossip -Q feapp --autoscale 4,1 -P eventlet -Ofair
    admin 23702 13236 9 Mar21 ? 02:50:45 /home/admin/.virtualenvs/express/bin/python /home/admin/express/manage.py celery worker -n feapp --loglevel=info --without-mingle --without-gossip -Q feapp --autoscale 4,1 -P eventlet -Ofair

    cmdline of the process

    admin@ip-10-0-15-72:~$ cat /proc/23702/cmdline
    /home/admin/.virtualenvs/express/bin/python/home/admin/express/manage.pyceleryworker-nfeapp--loglevel=info--without-mingle--without-gossip-Qfeapp--autoscale4,1-Peventlet-Ofair

    Status file for the process

    admin@ip-10-0-15-72:~$ cat /proc/23702/status
    Name: python
    State: S (sleeping)
    Tgid: 23702
    Ngid: 0
    Pid: 23702



    Count should come 2 but it is coming 0. Please help me.

    I am able to count other processes like sshd and VBoxService but when I try this always get 0 value.
  • arikin
    Junior Member
    • Aug 2011
    • 27

    #2
    You probably already have a solution. But I will put this here for others.

    Using the proc.num zabbix command will work.

    1. Start to create your Item.
    2. For type select: Zabbix agent
    3. For Key field click the [Select] button.
    4. Scroll down to: proc.num[<name>,<user>,<state>,<cmdline>]
    Note: You may also be interested in the proc.mem and proc.info ones for another Item as well.
    5. Put in the name of the process: proc.num[manage.py]
    Note: try to specific as possible.
    6. Finish the Item.

    Notes:
    If for some reason it picks up other similarly named processes see how they show up in the ps command.
    Or create a custom command for the zabbix agent like this one:
    # sudo ps ax | grep 'manage.py celery worker' | grep -v 'grep' | wc -l | awk '{print $1}'

    That would go into this configure file:
    /etc/zabbix/zabbix_agentd.d/zabbix_agentd_userparameter.conf

    Pay attention to the $ symbol for variables.

    Comment

    Working...