summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 39cfe73)
raw | patch | inline | side by side (parent: 39cfe73)
author | Florian Forster <octo@huhu.verplant.org> | |
Thu, 14 Jan 2010 09:54:53 +0000 (10:54 +0100) | ||
committer | Florian Forster <octo@huhu.verplant.org> | |
Thu, 14 Jan 2010 09:54:53 +0000 (10:54 +0100) |
There values were stored in a `long', then `counter_t', then interpreted as
`derive_t'. Changed that to `derive_t' only. Hopefully this fixes a bug
reported by Mark Moseley.
`derive_t'. Changed that to `derive_t' only. Hopefully this fixes a bug
reported by Mark Moseley.
src/processes.c | patch | blob | history |
diff --git a/src/processes.c b/src/processes.c
index 8c7700af6fa5670eded43dc82b253db79acdf74a..5e176c87b8253b797672a267b612a3475c4662eb 100644 (file)
--- a/src/processes.c
+++ b/src/processes.c
unsigned long cpu_system_counter;
/* io data */
- long io_rchar;
- long io_wchar;
- long io_syscr;
- long io_syscw;
+ derive_t io_rchar;
+ derive_t io_wchar;
+ derive_t io_syscr;
+ derive_t io_syscw;
struct procstat_entry_s *next;
} procstat_entry_t;
unsigned long cpu_system_counter;
/* io data */
- long io_rchar;
- long io_wchar;
- long io_syscr;
- long io_syscw;
+ derive_t io_rchar;
+ derive_t io_wchar;
+ derive_t io_syscr;
+ derive_t io_syscw;
struct procstat *next;
struct procstat_entry_s *instances;
if ( (ps->io_rchar != -1) && (ps->io_wchar != -1) )
{
sstrncpy (vl.type, "ps_disk_octets", sizeof (vl.type));
- vl.values[0].counter = ps->io_rchar;
- vl.values[1].counter = ps->io_wchar;
+ vl.values[0].derive = ps->io_rchar;
+ vl.values[1].derive = ps->io_wchar;
vl.values_len = 2;
plugin_dispatch_values (&vl);
}
if ( (ps->io_syscr != -1) && (ps->io_syscw != -1) )
{
sstrncpy (vl.type, "ps_disk_ops", sizeof (vl.type));
- vl.values[0].counter = ps->io_syscr;
- vl.values[1].counter = ps->io_syscw;
+ vl.values[0].derive = ps->io_syscr;
+ vl.values[1].derive = ps->io_syscw;
vl.values_len = 2;
plugin_dispatch_values (&vl);
}
DEBUG ("name = %s; num_proc = %lu; num_lwp = %lu; vmem_rss = %lu; "
"vmem_minflt_counter = %lu; vmem_majflt_counter = %lu; "
"cpu_user_counter = %lu; cpu_system_counter = %lu; "
- "io_rchar = %ld; io_wchar = %ld; "
- "io_syscr = %ld; io_syscw = %ld;",
+ "io_rchar = %"PRIi64"; io_wchar = %"PRIi64"; "
+ "io_syscr = %"PRIi64"; io_syscw = %"PRIi64";",
ps->name, ps->num_proc, ps->num_lwp, ps->vmem_rss,
ps->vmem_minflt_counter, ps->vmem_majflt_counter,
ps->cpu_user_counter, ps->cpu_system_counter,
while (fgets (buffer, 1024, fh) != NULL)
{
- long *val = NULL;
+ derive_t *val = NULL;
+ long long tmp;
+ char *endptr;
if (strncasecmp (buffer, "rchar:", 6) == 0)
val = &(ps->io_rchar);
if (numfields < 2)
continue;
- *val = atol (fields[1]);
- }
+ errno = 0;
+ endptr = NULL;
+ tmp = strtoll (fields[1], &endptr, /* base = */ 10);
+ if ((errno != 0) || (endptr == fields[1]))
+ *val = -1;
+ else
+ *val = (derive_t) tmp;
+ } /* while (fgets) */
if (fclose (fh))
{