new = calloc(1, sizeof(*new));
if (new == NULL) {
ERROR("processes plugin: ps_list_register: calloc failed.");
new = calloc(1, sizeof(*new));
if (new == NULL) {
ERROR("processes plugin: ps_list_register: calloc failed.");
} /* void ps_list_register */
/* try to match name against entry, returns 1 if success */
} /* void ps_list_register */
/* try to match name against entry, returns 1 if success */
} /* int ps_list_match */
static void ps_update_counter(derive_t *group_counter, derive_t *curr_counter,
} /* int ps_list_match */
static void ps_update_counter(derive_t *group_counter, derive_t *curr_counter,
+ if ((entry->io_diskr != -1) && (entry->io_diskw != -1)) {
+ ps_update_counter(&ps->io_diskr, &pse->io_diskr, entry->io_diskr);
+ ps_update_counter(&ps->io_diskw, &pse->io_diskw, entry->io_diskw);
+ }
+
if ((entry->cswitch_vol != -1) && (entry->cswitch_vol != -1)) {
ps_update_counter(&ps->cswitch_vol, &pse->cswitch_vol,
entry->cswitch_vol);
if ((entry->cswitch_vol != -1) && (entry->cswitch_vol != -1)) {
ps_update_counter(&ps->cswitch_vol, &pse->cswitch_vol,
entry->cswitch_vol);
vl.values[0].derive = ps->io_syscr;
vl.values[1].derive = ps->io_syscw;
vl.values_len = 2;
plugin_dispatch_values(&vl);
}
vl.values[0].derive = ps->io_syscr;
vl.values[1].derive = ps->io_syscw;
vl.values_len = 2;
plugin_dispatch_values(&vl);
}
+ if ((ps->io_diskr != -1) && (ps->io_diskw != -1)) {
+ sstrncpy(vl.type, "disk_octets", sizeof(vl.type));
+ vl.values[0].derive = ps->io_diskr;
+ vl.values[1].derive = ps->io_diskw;
+ vl.values_len = 2;
+ plugin_dispatch_values(&vl);
+ }
+
if (ps->num_fd > 0) {
sstrncpy(vl.type, "file_handles", sizeof(vl.type));
vl.values[0].gauge = ps->num_fd;
if (ps->num_fd > 0) {
sstrncpy(vl.type, "file_handles", sizeof(vl.type));
vl.values[0].gauge = ps->num_fd;
"cpu_user_counter = %" PRIi64 "; cpu_system_counter = %" PRIi64 "; "
"io_rchar = %" PRIi64 "; io_wchar = %" PRIi64 "; "
"io_syscr = %" PRIi64 "; io_syscw = %" PRIi64 "; "
"cpu_user_counter = %" PRIi64 "; cpu_system_counter = %" PRIi64 "; "
"io_rchar = %" PRIi64 "; io_wchar = %" PRIi64 "; "
"io_syscr = %" PRIi64 "; io_syscw = %" PRIi64 "; "
"cswitch_vol = %" PRIi64 "; cswitch_invol = %" PRIi64 ";",
ps->name, ps->num_proc, ps->num_lwp, ps->num_fd, ps->vmem_size,
ps->vmem_rss, ps->vmem_data, ps->vmem_code, ps->vmem_minflt_counter,
ps->vmem_majflt_counter, ps->cpu_user_counter, ps->cpu_system_counter,
"cswitch_vol = %" PRIi64 "; cswitch_invol = %" PRIi64 ";",
ps->name, ps->num_proc, ps->num_lwp, ps->num_fd, ps->vmem_size,
ps->vmem_rss, ps->vmem_data, ps->vmem_code, ps->vmem_minflt_counter,
ps->vmem_majflt_counter, ps->cpu_user_counter, ps->cpu_system_counter,
- ps->io_rchar, ps->io_wchar, ps->io_syscr, ps->io_syscw, ps->cswitch_vol,
- ps->cswitch_invol);
+ ps->io_rchar, ps->io_wchar, ps->io_syscr, ps->io_syscw, ps->io_diskr,
+ ps->io_diskw, ps->cswitch_vol, ps->cswitch_invol);
- ssnprintf(dirname, sizeof(dirname), "/proc/%li/task", ps->id);
+ snprintf(dirname, sizeof(dirname), "/proc/%li/task", ps->id);
if ((dh = opendir(dirname)) == NULL) {
DEBUG("Failed to open directory `%s'", dirname);
if ((dh = opendir(dirname)) == NULL) {
DEBUG("Failed to open directory `%s'", dirname);
- ssnprintf(filename, sizeof(filename), "/proc/%li/task/%s/status", ps->id,
- tpid);
+ if (snprintf(filename, sizeof(filename), "/proc/%li/task/%s/status", ps->id,
+ tpid) >= sizeof(filename)) {
+ DEBUG("Filename too long: `%s'", filename);
+ continue;
+ }
+
if ((fh = fopen(filename, "r")) == NULL) {
DEBUG("Failed to open file `%s'", filename);
continue;
if ((fh = fopen(filename, "r")) == NULL) {
DEBUG("Failed to open file `%s'", filename);
continue;
- ssnprintf(filename, sizeof(filename), "/proc/%li/status", pid);
+ snprintf(filename, sizeof(filename), "/proc/%li/status", pid);
- ssnprintf(filename, sizeof(filename), "/proc/%li/io", ps->id);
+ snprintf(filename, sizeof(filename), "/proc/%li/io", ps->id);
if ((fh = fopen(filename, "r")) == NULL) {
DEBUG("ps_read_io: Failed to open file `%s'", filename);
if ((fh = fopen(filename, "r")) == NULL) {
DEBUG("ps_read_io: Failed to open file `%s'", filename);
char errbuf[1024];
WARNING("processes: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
}
char errbuf[1024];
WARNING("processes: fclose: %s", sstrerror(errno, errbuf, sizeof(errbuf)));
}
- ssnprintf(dirname, sizeof(dirname), "/proc/%i/fd", pid);
+ snprintf(dirname, sizeof(dirname), "/proc/%i/fd", pid);
if ((dh = opendir(dirname)) == NULL) {
DEBUG("Failed to open directory `%s'", dirname);
if ((dh = opendir(dirname)) == NULL) {
DEBUG("Failed to open directory `%s'", dirname);
} /* int ps_count_fd (pid) */
static void ps_fill_details(const procstat_t *ps, process_entry_t *entry) {
} /* int ps_count_fd (pid) */
static void ps_fill_details(const procstat_t *ps, process_entry_t *entry) {
- ssnprintf(filename, sizeof(filename), "/proc/%li/stat", pid);
+ snprintf(filename, sizeof(filename), "/proc/%li/stat", pid);
if (name_start_pos >= name_end_pos) {
ERROR("processes plugin: name_start_pos = %zu >= name_end_pos = %zu",
name_start_pos, name_end_pos);
if (name_start_pos >= name_end_pos) {
ERROR("processes plugin: name_start_pos = %zu >= name_end_pos = %zu",
name_start_pos, name_end_pos);
sstrncpy(ps->name, &buffer[name_start_pos + 1], name_len + 1);
if ((buffer_len - name_end_pos) < 2)
sstrncpy(ps->name, &buffer[name_start_pos + 1], name_len + 1);
if ((buffer_len - name_end_pos) < 2)
buffer_ptr = &buffer[name_end_pos + 2];
fields_len = strsplit(buffer_ptr, fields, STATIC_ARRAY_SIZE(fields));
buffer_ptr = &buffer[name_end_pos + 2];
fields_len = strsplit(buffer_ptr, fields, STATIC_ARRAY_SIZE(fields));
DEBUG("processes plugin: ps_read_process (pid = %li):"
" `%s' has only %i fields..",
pid, filename, fields_len);
DEBUG("processes plugin: ps_read_process (pid = %li):"
" `%s' has only %i fields..",
pid, filename, fields_len);
} /* int ps_read_process (...) */
static char *ps_get_cmdline(long pid, char *name, char *buf, size_t buf_len) {
} /* int ps_read_process (...) */
static char *ps_get_cmdline(long pid, char *name, char *buf, size_t buf_len) {
- ssnprintf(file, sizeof(file), "/proc/%li/cmdline", pid);
+ snprintf(file, sizeof(file), "/proc/%li/cmdline", pid);
- ssnprintf(buf, buf_len, "[%s]", name);
+ snprintf(buf, buf_len, "[%s]", name);
char errbuf[1024];
ERROR("processes plugin: fopen (/proc/stat) failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
char errbuf[1024];
ERROR("processes plugin: fopen (/proc/stat) failed: %s",
sstrerror(errno, errbuf, sizeof(errbuf)));
"while reading \"%s\": "
"Returned %zd but expected %zu.",
path, status, buffer_size);
"while reading \"%s\": "
"Returned %zd but expected %zu.",
path, status, buffer_size);
}
info.pr_psargs[sizeof(info.pr_psargs) - 1] = 0;
sstrncpy(buffer, info.pr_psargs, buffer_size);
}
info.pr_psargs[sizeof(info.pr_psargs) - 1] = 0;
sstrncpy(buffer, info.pr_psargs, buffer_size);
ps->io_wchar = myUsage->pr_oublk * chars_per_block;
ps->io_syscr = myUsage->pr_sysc;
ps->io_syscw = myUsage->pr_sysc;
ps->io_wchar = myUsage->pr_oublk * chars_per_block;
ps->io_syscr = myUsage->pr_sysc;
ps->io_syscw = myUsage->pr_sysc;
mib[3] = *pid;
kp_size = sizeof(kp);
if (sysctl(mib, 4, &kp, &kp_size, NULL, 0) != 0)
mib[3] = *pid;
kp_size = sizeof(kp);
if (sysctl(mib, 4, &kp, &kp_size, NULL, 0) != 0)
}
#endif /* HAVE_THREAD_INFO */
/* ------- end of additional functions for KERNEL_LINUX/HAVE_THREAD_INFO -------
}
#endif /* HAVE_THREAD_INFO */
/* ------- end of additional functions for KERNEL_LINUX/HAVE_THREAD_INFO -------
if ((proc = opendir("/proc")) == NULL) {
char errbuf[1024];
ERROR("Cannot open `/proc': %s", sstrerror(errno, errbuf, sizeof(errbuf)));
if ((proc = opendir("/proc")) == NULL) {
char errbuf[1024];
ERROR("Cannot open `/proc': %s", sstrerror(errno, errbuf, sizeof(errbuf)));
kd = kvm_openfiles(NULL, "/dev/null", NULL, 0, errbuf);
if (kd == NULL) {
ERROR("processes plugin: Cannot open kvm interface: %s", errbuf);
kd = kvm_openfiles(NULL, "/dev/null", NULL, 0, errbuf);
if (kd == NULL) {
ERROR("processes plugin: Cannot open kvm interface: %s", errbuf);
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
if (kd == NULL) {
ERROR("processes plugin: Cannot open kvm interface: %s", errbuf);
kd = kvm_openfiles(NULL, NULL, NULL, KVM_NO_FILES, errbuf);
if (kd == NULL) {
ERROR("processes plugin: Cannot open kvm interface: %s", errbuf);