GUACAMOLE-2283: Runtime observability: add guacd process & thread naming.#674
Conversation
necouchman
left a comment
There was a problem hiding this comment.
Overall looks pretty good to me, and I think this is a very useful addition to the code. I do have a few comments - mainly related to doing a few more #define constants and documenting things, but also one related to compatibility of the code across non-Linux UNIX-like platforms.
cc61626 to
7935214
Compare
eugen-keeper
left a comment
There was a problem hiding this comment.
The formatted process titles expose connection metadata (username, host, port) in ps and /proc, where other local users may potentially see it. Do we consider that acceptable for typical guacd deployments?
I had concerns as well, especially for the username, as the other information is readily available to non-root users.. My thought is that because of the Guacamole deployment model, I added a comment to |
7935214 to
3acab76
Compare
This is probably okay - I would tend to agree that typical deployments are not going to grant just anyone access to the system running guacd (or a system running a set of containers that includes guacd). Curious what @mike-jumper @corentin-soriano @sschiffli think about this, particularly if there are any objections? |
If there are objections, I could show the UID instead of the username. Another possibility is showing the connection name. |
Yeah - or, here's another idea that occurred to me, if the goal is to aid in "runtime observability", what a socket opened by guacd that could be read from that contains information on the guacd process(es)? This could be one of the following variants:
I'm kind of channeling the way HAProxy provides a statistics socket that can be read from and will output the information in various formats. This seems like it might achieve some of the observability requirements, but has the advantage of being able to use filesystem permissions to limit who can read the data and interact with the socket. I'm throwing that out as an idea - I'm not saying it necessarily should completely replace what you're doing, here, I still think this PR, as-is, is useful, and provided there aren't any objections to this information being accessible to anyone logged into the guacd system, I'm still okay with it. I'm just throwing it out as an idea, perhaps for a future change or to address some of the potential concerns, here. |
Overview
Add runtime process and thread naming support to
guacd. Connection processes now expose descriptive names (e.g.,vnc user@host:5900) and threads expose meaningful names for easier debugging, profiling, and monitoring.This change adds process title and thread naming support to guacd through three new APIs:
-
guac_process_title_init(): captures the process's original argv/environ region at startup and prepares it for later process title updates.--
guac_process_title_set(): updates the process title shown by tools such as ps, top, and htop, and also updates the main thread's comm name so process-oriented views reflect the active connection.--
guac_thread_name_set(): assigns a descriptive name to the calling thread using the platform's thread naming facilities.guac_process_title_set()rewrites the argv/environ memory region captured at startup, replacing the original command line with a connection-specific title. Because Linux exposes this region through/proc/<pid>/cmdline, tools such as ps, top, and htop automatically display the updated title. The main thread's comm name is also updated to keep process-oriented views consistent.Child processes can use
guac_process_title_set()to expose connection-specific names, while threads created can useguac_thread_name_set()to publish names such asvnc-main,user-input, orrdp-audio. This improves observability when debugging, profiling, or monitoring runningguacdprocesses.Thread Names
Example Output