local-listeners: use host prefix in read_cmdline (#15320)
* local-listeners: use host prefix in read_cmdline * automatically use stderr instead of stderror --------- Co-authored-by: Costa Tsaousis <costa@netdata.cloud>
Ilya Mashchenko committed
Jul 6, 2023 at 18:25 UTC
3cc220ff5e38ef5cd96a64596c7e0c370d0fa074
2 files changed
+4
-4
collectors/plugins.d/local_listeners.c
+1
-1
@@ -42,7 +42,7 @@ static inline const char *protocol_name(PROC_NET_PROTOCOLS protocol) {
42
43
static inline int read_cmdline(pid_t pid, char* buffer, size_t bufferSize) {
44
char path[FILENAME_MAX + 1];
45
- snprintfz(path, FILENAME_MAX, "/proc/%d/cmdline", pid);
45
+ snprintfz(path, FILENAME_MAX, "%s/proc/%d/cmdline", netdata_configured_host_prefix, pid);
46
47
FILE* file = fopen(path, "r");
48
if (!file) {
libnetdata/log/log.c
+3
-3
@@ -634,7 +634,7 @@ int error_log_limit(int reset) {
634
static time_t start = 0;
635
static unsigned long counter = 0, prevented = 0;
636
637
- FILE *fp = stderror;
637
+ FILE *fp = stderror ? stderror : stderr;
638
639
// fprintf(fp, "FLOOD: counter=%lu, allowed=%lu, backup=%lu, period=%llu\n", counter, error_log_errors_per_period, error_log_errors_per_period_backup, (unsigned long long)error_log_throttle_period);
640
@@ -841,7 +841,7 @@ static const char *strerror_result_string(const char *a, const char *b) { (void)
841
#endif
842
843
void error_limit_int(ERROR_LIMIT *erl, const char *prefix, const char *file __maybe_unused, const char *function __maybe_unused, const unsigned long line __maybe_unused, const char *fmt, ... ) {
844
- FILE *fp = stderror;
844
+ FILE *fp = stderror ? stderror : stderr;
845
846
if(erl->sleep_ut)
847
sleep_usec(erl->sleep_ut);
@@ -975,7 +975,7 @@ static void print_call_stack(void) {
975
#endif
976
977
void fatal_int( const char *file, const char *function, const unsigned long line, const char *fmt, ... ) {
978
- FILE *fp = stderror;
978
+ FILE *fp = stderror ? stderror : stderr;
979
980
// save a copy of errno - just in case this function generates a new error
981
int __errno = errno;