Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@ktsaou
Copy link
Member

@ktsaou ktsaou commented Apr 9, 2025

Add parent process monitoring to update status file on hard kills.

This commit adds a parent-child process architecture to improve status file accuracy when Netdata is terminated abruptly. The implementation:

  1. Creates a parent process at startup that monitors the Netdata child process
  2. Parent process changes its name to "nd_watcher" to avoid being killed by pkill
  3. When the child process is killed abruptly, the parent updates the status file
  4. Adds EXIT_REASON_HARD_KILLED flag for processes killed without a recognizable signal
  5. Forwards termination signals from parent to child
  6. Centralizes status file loading with daemon_status_file_load_latest()

With this, the process tree looks like this:

 535187 pts/4    Ss+    0:00  |       \_ nd_watcher
 535204 pts/4    Sl+   12:20  |           \_ /usr/bin/netdata -D
 535206 pts/4    S+     0:00  |               \_ spawn-plugins      
 535820 pts/4    S+     0:00  |                   \_ bash /usr/libexec/netdata/plugins.d/tc-qos-helper.sh 1
 535822 pts/4    Sl+    0:05  |                   \_ /usr/libexec/netdata/plugins.d/go.d.plugin 1
 536149 pts/4    S+     0:46  |                   |   \_ /bin/intel_gpu_top -J -s 900
 535862 pts/4    Sl+    0:01  |                   \_ /usr/libexec/netdata/plugins.d/systemd-journal.plugin 1
 535871 pts/4    S+     0:10  |                   \_ /usr/libexec/netdata/plugins.d/slabinfo.plugin 1
 535894 pts/4    Sl+    0:00  |                   \_ /usr/libexec/netdata/plugins.d/network-viewer.plugin 1
 535968 pts/4    S+     0:00  |                   |   \_ spawn-setns                                           
 535904 pts/4    S+     0:00  |                   \_ /usr/libexec/netdata/plugins.d/perf.plugin 1 all
 535911 pts/4    Sl+    0:48  |                   \_ /usr/libexec/netdata/plugins.d/apps.plugin 1
 535922 pts/4    S+     0:01  |                   \_ /usr/libexec/netdata/plugins.d/cups.plugin 1
 535935 pts/4    Sl+    0:05  |                   \_ /usr/libexec/netdata/plugins.d/debugfs.plugin 1
 535954 pts/4    S+     0:00  |                   \_ /usr/libexec/netdata/plugins.d/nfacct.plugin 1

This commit adds a parent-child process architecture to improve status file accuracy when Netdata is terminated abruptly. The implementation:

1. Creates a parent process at startup that monitors the Netdata child process
2. Parent process changes its name to "nd_watcher" to avoid being killed by pkill
3. When the child process is killed abruptly, the parent updates the status file
4. Adds EXIT_REASON_HARD_KILLED flag for processes killed without a recognizable signal
5. Forwards termination signals from parent to child
6. Centralizes status file loading with daemon_status_file_load_latest()
@ktsaou ktsaou force-pushed the feature/parent-process-monitoring branch from 7cf39eb to eb34190 Compare April 9, 2025 19:11
@ktsaou ktsaou requested a review from a team as a code owner April 9, 2025 19:11
@github-actions github-actions bot added the area/build Build system (autotools and cmake). label Apr 9, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Build system (autotools and cmake). area/daemon

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant