projects
/
collectd.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
8ee506f
)
memory plugin: Check `pagesize' when initializing, not when reading.
author
Florian Forster
<octo@huhu.verplant.org>
Sat, 18 Apr 2009 11:12:23 +0000
(13:12 +0200)
committer
Florian Forster
<octo@huhu.verplant.org>
Sat, 18 Apr 2009 11:12:23 +0000
(13:12 +0200)
src/memory.c
patch
|
blob
|
history
diff --git
a/src/memory.c
b/src/memory.c
index
0926c59
..
d6c3c88
100644
(file)
--- a/
src/memory.c
+++ b/
src/memory.c
@@
-87,6
+87,11
@@
static int memory_init (void)
#elif HAVE_SYSCTL
pagesize = getpagesize ();
#elif HAVE_SYSCTL
pagesize = getpagesize ();
+ if (pagesize <= 0)
+ {
+ ERROR ("memory plugin: Invalid pagesize: %i", pagesize);
+ return (-1);
+ }
/* #endif HAVE_SYSCTL */
#elif HAVE_SYSCTLBYNAME
/* #endif HAVE_SYSCTL */
#elif HAVE_SYSCTLBYNAME
@@
-187,12
+192,6
@@
static int memory_read (void)
struct vmtotal vmtotal;
size_t size;
struct vmtotal vmtotal;
size_t size;
- if (pagesize <= 0)
- {
- ERROR ("memory plugin: Invalid pagesize: %i", pagesize);
- return (-1);
- }
-
memset (&vmtotal, 0, sizeof (vmtotal));
size = sizeof (vmtotal);
memset (&vmtotal, 0, sizeof (vmtotal));
size = sizeof (vmtotal);
@@
-203,6
+202,7
@@
static int memory_read (void)
return (-1);
}
return (-1);
}
+ assert (pagesize > 0);
memory_submit ("active", vmtotal.t_arm * pagesize);
memory_submit ("inactive", (vmtotal.t_rm - vmtotal.t_arm) * pagesize);
memory_submit ("free", vmtotal.t_free * pagesize);
memory_submit ("active", vmtotal.t_arm * pagesize);
memory_submit ("inactive", (vmtotal.t_rm - vmtotal.t_arm) * pagesize);
memory_submit ("free", vmtotal.t_free * pagesize);