ehds opened a new pull request, #3602: URL: https://github.com/apache/brpc/pull/3602
### What problem does this PR solve? Issue Number: resolve Problem Summary: 1. Collecting process metrics through commands such as `ps` and `lsof` may fail due to permission restrictions in MacOS sandboxed applications. ``` brpc/src/bvar/default_variables.cpp:127 read_proc_status] Fail to sscanf: Undefined error: 0 sh: /bin/ps: Operation not permitted ``` 2. The previous implementation also leaves several process statistics unavailable, like `process_faults_minor_second`, `process_faults_minor_second`, `process_faults_major`. ### What is changed and the side effects? Changed: This change uses native macOS APIs to collect these metrics: - getpid(), getppid(), getpgrp(), and getsid() for process and session IDs. - getpriority() for the process nice value. - proc_pidinfo() with PROC_PIDTBSDINFO for process flags, state, and terminal information. - proc_pidinfo() with PROC_PIDTASKINFO for priority and thread count. - getrusage() for process and waited-child page faults and CPU times, converted to clock ticks using sysconf(_SC_CLK_TCK). - task_info() with MACH_TASK_BASIC_INFO for virtual and resident memory sizes. - proc_pidinfo() with PROC_PIDLISTFDS for open file descriptor counts. Side effects: - Performance effects: - Breaking backward compatibility: --- ### Check List: - Please make sure your changes are compilable. - When providing us with a new feature, it is best to add related tests. - Please follow [Contributor Covenant Code of Conduct](https://github.com/apache/brpc/blob/master/CODE_OF_CONDUCT.md). -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
