Ad Widget

Collapse

Proper process names in Linux

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nelsonab
    Senior Member
    Zabbix Certified SpecialistZabbix Certified Professional
    • Sep 2006
    • 1233

    #1

    Proper process names in Linux

    For a long time the lack of useful process names for the Zabbix server and agent has bothered me. Today I decided to fix that. :-)

    If you are running the Linux kernel 2.6.9 or above you can use the following to accomplish this. I haven't had the chance to test this on the server, just the agent, but it should work. There is a limitation however, Linux will allow for a maximum of 16 characters when changing the process name.

    Agent running on a system:
    Code:
    top - 15:21:14 up 22 days, 13:51, 11 users,  load average: 0.03, 0.06, 0.02
    Tasks: 138 total,   1 running, 137 sleeping,   0 stopped,   0 zombie
    Cpu(s):  0.5%us,  0.8%sy,  0.2%ni, 97.8%id,  0.3%wa,  0.0%hi,  0.3%si,  0.0%st
    Mem:   4044004k total,  1569728k used,  2474276k free,   278096k buffers
    Swap:  2104472k total,        0k used,  2104472k free,   741940k cached
    
      PID USER      PR  NI  VIRT  RES  SHR S %CPU %MEM    TIME+  COMMAND
    25402 zabbix    22   5  9032  604  472 S    1  0.0   0:06.62 main process
    25401 zabbix    30   5  9032  560  428 S    0  0.0   0:00.00 main process
    25403 zabbix    20   5  9040  760  600 S    0  0.0   0:00.28 Listening
    25404 zabbix    20   5  9040  760  600 S    0  0.0   0:00.33 Listening
    25405 zabbix    20   5  9040  760  600 S    0  0.0   0:00.30 Listening
    25406 zabbix    22   5  9040  596  424 S    0  0.0   0:00.00 poller [sleepin
    first diff for src/libs/zbxcommon/misc.c:
    Code:
    nelsonab:~/zabbix-1.6.1/src/libs/zbxcommon> rcsdiff -r1.1 misc.c
    ===================================================================
    RCS file: misc.c,v
    retrieving revision 1.1
    diff -r1.1 misc.c
    22a23,24
    > #include <sys/prctl.h>
    >
    143,144d144
    < #ifdef HAVE_FUNCTION_SETPROCTITLE
    <
    152a153,154
    > #ifdef HAVE_FUNCTION_SETPROCTITLE
    >
    155a158,161
    >
    >   zabbix_log(LOG_LEVEL_DEBUG,"zbx_set_proctitle(\"%s\")",title);
    >
    >   prctl(PR_SET_NAME, title, NULL, NULL, NULL);
    Second diff for src/zabbix_agent/listener.c:
    Code:
    nelsonab:~/zabbix-1.6.1/src/zabbix_agent> rcsdiff -r1.1 listener.c
    ===================================================================
    RCS file: listener.c,v
    retrieving revision 1.1
    diff -r1.1 listener.c
    96a97
    >               zbx_setproctitle("Listening");
    Last edited by nelsonab; 09-01-2009, 01:39. Reason: note about process name limititation.
    RHCE, author of zbxapi
    Ansible, the missing piece (Zabconf 2017): https://www.youtube.com/watch?v=R5T9NidjjDE
    Zabbix and SNMP on Linux (Zabconf 2015): https://www.youtube.com/watch?v=98PEHpLFVHM

Working...