[ZBXNEXT-1855] Support of setproctitle on Linux, Windows, HP-UX and Darwin OSs Created: 2013 Jun 27  Updated: 2013 Oct 28  Resolved: 2013 Oct 28

Status: Closed
Project: ZABBIX FEATURE REQUESTS
Component/s: Agent (G), Proxy (P), Server (S)
Affects Version/s: 2.1.0
Fix Version/s: 2.1.8

Type: Change Request Priority: Minor
Reporter: Alexey Pustovalov Assignee: Unassigned
Resolution: Fixed Votes: 5
Labels: patch, usability
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File 2013-06-26 в 22.47.31.png     PNG File 2013-06-27 в 1.33.44.png     File setproctitle.c     Text File zbx_proctitle.patch    
Issue Links:
Duplicate
is duplicated by ZBXNEXT-1803 Custom process names on Linux for Zab... Closed

 Description   

Currently we support setproctitle only on FreeBSD OS. Would be great to support the feature on all systems.

Information about setproctitle on Linux OSs: http://stupefydeveloper.blogspot.com/2008/10/linux-change-process-name.html

The feature can help to determine process type and current state of processes without any additional tools (strace, log files and etc).



 Comments   
Comment by Alexey Pustovalov [ 2013 Jun 27 ]

Please find attached setproctitle.c and patch for 2.0.7rc1.

Comment by richlv [ 2013 Jun 27 ]

see ZBX-232 for previous decision on this

Comment by Alexey Pustovalov [ 2013 Jul 01 ]

(1) pinger uses progname variable which modified by the patch. So all items related with PING are not processed correctly.

igorsh FIXED in r38008
I made a copy of argv[0] which won't be be overwritten by the setproctitle routine.

andris CLOSED

Comment by Igors Homjakovs (Inactive) [ 2013 Aug 19 ]

I have also tested new setproctitle on Solaris (patch had the implementation for Solaris), but it doesn't work well. What i experienced is that the main process had the new title set, but other processes remained with the default name.

The ps documentation says:

args:

The command with all its arguments as a string. The implementation may truncate this value to the field width; it is implementation-dependent whether any further truncation occurs. It is unspecified whether the string represented is a version of the argument list as it was passed to the command when it started, or is a version of the arguments as they may have been modified by the application. Applications cannot depend on being able to modify their argument list and having that modification be reflected in the output of ps. The Solaris implementation limits the string to 80 bytes; the string is the version of the argument list as it was passed to the command when it started.

Comment by Igors Homjakovs (Inactive) [ 2013 Aug 20 ]

According to:

http://www.scalingbits.com/content/solaris-11-changes-where-bsd-style-ps-command

there are two types of ps command on Solaris: BSD-type (e.g. ps aux) and regular type (e.g. ps -ef).

It also appears that (http://unix.stackexchange.com/questions/3934/how-can-i-get-a-full-process-list-in-solaris-without-truncated-lines) the kernel is not required to keep track of command line arguments. When a process is started through the execve call, the kernel must copy the arguments into the process memory. After that, the kernel can discard the memory used to store the initial command line arguments. The process is allowed to overwrite its copy of the arguments. So there may simply be no trace of the arguments. This happens in the the case of regular type ps command.

For BSD-type ps command situation is different and it looks into the process to see the args as it sees them. So in this case we can set our process title as it is done in, for example, Linux.

PostgreSQL documentaion says to use /usr/ucb/ps with -ww options to get process names instead of regular /usr/bin/ps, however most of the information are hidden by /usr/ucb/ps option as well. Additionally, the original name of the process must have a shorter process name than that provided by the application. If you fail to do all three things, the ps output for each server process will be the original command line (http://www.postgresql.org/docs/9.1/static/monitoring-ps.html).

Comment by Igors Homjakovs (Inactive) [ 2013 Aug 23 ]

Setproctitle will not be added to Windows platform since Task Manager displays only the main process.

Comment by Igors Homjakovs (Inactive) [ 2013 Aug 23 ]

Fixed in development branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-1855

Comment by Alexander Vladishev [ 2013 Sep 19 ]

Related issue: ZBXNEXT-1179

Comment by Andris Mednis [ 2013 Sep 30 ]

Development is being done in svn://svn.zabbix.com/branches/dev/ZBXNEXT-1855-2.
Currently it works on Linux, FreeBSD, OpenBSD, Solaris 10 and 11, AIX, HP-UX, Darwin.

Comment by Andris Mednis [ 2013 Oct 04 ]

Support of setproctitle() is available in development branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-1855-2, starting from rev. 38973.
Development continues with solving ZBXNEXT-1179.

Comment by Andris Mednis [ 2013 Oct 08 ]

Available in the development branch svn://svn.zabbix.com/branches/dev/ZBXNEXT-1855-2. Also contains a solution for ZBXNEXT-1179. setproctitle() imitation is expected to work on Linux, AIX, HP-UX, Solaris, OS X. On FreeBSD and OpenBSD the native setproctitle() is used.

Comment by Andris Mednis [ 2013 Oct 08 ]

(1) icmp pinger process always shows 0 values:
zabbix22 5053 5022 0 10:01 ? 00:00:00 sbin/zabbix_proxy: icmp pinger #1 [got 0 values in 0.000315 sec, idle 5 sec]
andris RESOLVED in r39080

wiper CLOSED

Comment by Andris Mednis [ 2013 Oct 08 ]

(2) icmp pinger process number is not displayed during status "pinging hosts":
zabbix22 9104 9084 0 13:54 ? 00:00:00 sbin/zabbix_server: icmp pinger #1 [got 0 values in 0.000323 sec, idle 5 sec]
zabbix22 9106 9084 0 13:54 ? 00:00:00 sbin/zabbix_server: icmp pinger [pinging hosts]
zabbix22 9107 9084 0 13:54 ? 00:00:00 sbin/zabbix_server: icmp pinger #3 [got 0 values in 0.000317 sec, idle 5 sec]
andris RESOLVED in r39089

wiper CLOSED

Comment by Andris Mednis [ 2013 Oct 09 ]

Added VMware collector support in svn://svn.zabbix.com/branches/dev/ZBXNEXT-1855-2 rev. 39154.

Comment by Andris Zeila [ 2013 Oct 10 ]

(3) Some processes can write processing statistics to their titles, then sleep for 0 seconds and immediately overwrite statistics with messages like "[processing <something>]". In situations like this it would be better to accumulate the statistics and update title only every N seconds or when entering a sleep (N - the default sleep time of the specific process).

Some processes are more susceptible to the above scenario than others - for example it's a common occurrence with unreachable pollers.

The affected main loops:

  • src/zabbix_server/poller/poller.c:main_poller_loop()
  • src/zabbix_server/proxypoller/proxypoller.c:main_proxypoller_loop()
  • src/zabbix_server/dbsyncer/dbsyncer.c:main_dbsyncer_loop()
  • src/zabbix_server/discoverer/discoverer.c:main_discoverer_loop()
  • src/zabbix_server/timer/timer.c:main_timer_loop() - highly unlikely
  • src/zabbix_server/nodewatcher/nodewatcher.c:main_nodewatcher_loop()
  • src/zabbix_proxy/proxy.c:main_heart_loop() - highly unlikely
  • src/zabbix_server/vmware/vmware.c:main_vmware_loop()

andris RESOLVED in r39394.
Also main_datasender_loop(), main_dbconfig_loop() and main_escalator_loop() were modified to show old statistics while gathering new values.

wiper reviewed, please check minor changes proposed in r39403, r39414
Also realized that I've missed few more main loops with similar behavior:

  • src/zabbix_server/pinger/pinger.c:main_pinger_loop()
  • src/zabbix_server/httppoller/httppoller.c:main_httppoller_loop()

andris It was decided to leave main_pinger_loop() unchanged for now. It can be reorganized if requested.
Thanks for changes in r39403, r39414 - reviewed and accepted.

andris RESOLVED in r39422.

wiper CLOSED

Comment by Andris Zeila [ 2013 Oct 21 ]

Successfully tested

Comment by Andris Mednis [ 2013 Oct 21 ]

Fixed in version pre-2.1.8 r39449.

Comment by Andris Mednis [ 2013 Oct 22 ]

Documentation at
https://www.zabbix.com/documentation/2.2/manual/introduction/whatsnew220#dynamic_display_of_process_current_activity_and_statistics
https://www.zabbix.com/documentation/2.2/manual/appendix/performance_tuning#viewing_zabbix_process_performance_with_ps_and_top

martins-v Reviewed, with slight changes to the "what's new" part: https://www.zabbix.com/documentation/2.2/manual/introduction/whatsnew220#dynamic_display_of_current_process_activity_and_statistics

andris Thanks! Agree.

Comment by richlv [ 2013 Oct 22 ]

there are two (1)s, one of them has not been closed. let's clean this up

Generated at Fri Apr 11 21:59:53 EEST 2025 using Jira 9.12.4#9120004-sha1:625303b708afdb767e17cb2838290c41888e9ff0.