Replace global minfo with local perfstat_memory_total_t structures
Signed-off-by: Carlo Marcelo Arenas Belon <[EMAIL PROTECTED]>
---
trunk/monitor-core/libmetrics/aix/metrics.c | 62 ++++++++++++++------------
1 files changed, 33 insertions(+), 29 deletions(-)
diff --git a/trunk/monitor-core/libmetrics/aix/metrics.c
b/trunk/monitor-core/libmetrics/aix/metrics.c
index dc53c94..a4ab28b 100644
--- a/trunk/monitor-core/libmetrics/aix/metrics.c
+++ b/trunk/monitor-core/libmetrics/aix/metrics.c
@@ -78,7 +78,7 @@ struct product {
#define INFO_TIMEOUT 10
#define CPU_INFO_TIMEOUT INFO_TIMEOUT
-#define MEM_PAGESIZE 4096/1024
+#define MEM_KB_PER_PAGE (4096/1024)
struct cpu_info {
@@ -106,7 +106,6 @@ int ci_flag=0;
int ni_flag=0;
perfstat_cpu_total_t cpu_total_buffer;
-perfstat_memory_total_t minfo;
perfstat_netinterface_total_t ninfo[2],*last_ninfo, *cur_ninfo ;
@@ -153,8 +152,6 @@ metric_init(void)
sleep(CPU_INFO_TIMEOUT+1);
get_cpuinfo();
- perfstat_memory_total(NULL, &minfo, sizeof(perfstat_memory_total_t), 1);
-
update_ifdata();
bos_level(&aixver, &aixrel, &aixlev, &aixfix);
@@ -590,21 +587,20 @@ proc_run_func( void )
g_val_t val;
val.uint32 = count_procs(1);
-
return val;
}
-
-
g_val_t
mem_total_func ( void )
{
g_val_t val;
+ perfstat_memory_total_t m;
- perfstat_memory_total(NULL, &minfo, sizeof(perfstat_memory_total_t), 1);
-
- val.uint32 = minfo.real_total*MEM_PAGESIZE;
+ if (perfstat_memory_total(NULL, &m, sizeof(perfstat_memory_total_t), 1) ==
-1)
+ val.uint32 = 0;
+ else
+ val.uint32 = m.real_total * MEM_KB_PER_PAGE;
return val;
}
@@ -613,35 +609,35 @@ g_val_t
mem_free_func ( void )
{
g_val_t val;
+ perfstat_memory_total_t m;
- perfstat_memory_total(NULL, &minfo, sizeof(perfstat_memory_total_t), 1);
+ if (perfstat_memory_total(NULL, &m, sizeof(perfstat_memory_total_t), 1) ==
-1)
+ val.uint32 = 0;
+ else
+ val.uint32 = m.real_free * MEM_KB_PER_PAGE;
- val.uint32 = minfo.real_free*MEM_PAGESIZE;
return val;
}
-/*
-** AIX does not have this
-** FIXME --
-*/
+/* FIXME? */
g_val_t
mem_shared_func ( void )
{
g_val_t val;
+
val.uint32 = 0;
return val;
}
-/*
-** AIX does not have this
-** FIXME --
-*/
+/* FIXME? */
g_val_t
mem_buffers_func ( void )
{
g_val_t val;
+
val.uint32 = 0;
+
return val;
}
@@ -649,10 +645,13 @@ g_val_t
mem_cached_func ( void )
{
g_val_t val;
+ perfstat_memory_total_t m;
+
+ if (perfstat_memory_total(NULL, &m, sizeof(perfstat_memory_total_t), 1) ==
-1)
+ val.uint32 = 0;
+ else
+ val.uint32 = m.numperm * MEM_KB_PER_PAGE;
- perfstat_memory_total(NULL, &minfo, sizeof(perfstat_memory_total_t), 1);
-
- val.uint32 = minfo.numperm*MEM_PAGESIZE;
return val;
}
@@ -660,10 +659,13 @@ g_val_t
swap_total_func ( void )
{
g_val_t val;
+ perfstat_memory_total_t m;
- perfstat_memory_total(NULL, &minfo, sizeof(perfstat_memory_total_t), 1);
+ if (perfstat_memory_total(NULL, &m, sizeof(perfstat_memory_total_t), 1) ==
-1)
+ val.uint32 = 0;
+ else
+ val.uint32 = m.pgsp_total * MEM_KB_PER_PAGE;
- val.uint32 =minfo.pgsp_total*MEM_PAGESIZE;
return val;
}
@@ -672,14 +674,16 @@ g_val_t
swap_free_func ( void )
{
g_val_t val;
- perfstat_memory_total(NULL, &minfo, sizeof(perfstat_memory_total_t), 1);
-
- val.uint32 =minfo.pgsp_free*MEM_PAGESIZE;
+ perfstat_memory_total_t m;
+
+ if (perfstat_memory_total(NULL, &m, sizeof(perfstat_memory_total_t), 1) ==
-1)
+ val.uint32 = 0;
+ else
+ val.uint32 =m.pgsp_free * MEM_KB_PER_PAGE;
return val;
}
-
g_val_t
mtu_func ( void )
{
--
1.5.3.7
-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
Ganglia-developers mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ganglia-developers