ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/projects/cms/source/ihost/libstatgrab/memory_stats.c
(Generate patch)

Comparing projects/cms/source/ihost/libstatgrab/memory_stats.c (file contents):
Revision 1.6 by pajs, Tue May 21 16:16:41 2002 UTC vs.
Revision 1.9 by tdb, Tue May 28 14:40:41 2002 UTC

# Line 1 | Line 1
1   /*
2   * i-scream central monitoring system
3 + * http://www.i-scream.org.uk
4   * Copyright (C) 2000-2002 i-scream
5   *
6   * This program is free software; you can redistribute it and/or
# Line 41 | Line 42 | char *get_memory_stats(){
42   #ifdef LINUX
43          FILE *f;
44          char *line;
45 <        long buffers;
45 >        long long buffers;
46   #endif
47   #ifdef SOLARIS
48          kstat_ctl_t *kc;
# Line 67 | Line 68 | char *get_memory_stats(){
68          }
69          while((line=fpgetline(f)) != NULL){
70                  if (((strncmp(line,"Mem:",4)) == 0)) {
71 <                        if((sscanf(line, "%*s %ld %ld %ld %*s %ld %ld", &total, &used, &free, &buffers, &cache)) != 5){
71 >                        if((sscanf(line, "%*s %lld %lld %lld %*s %lld %lld", &total, &used, &free, &buffers, &cache)) != 5){
72                                  errf("Failed to read memory details (%m)");
73                                  return NULL;
74                          }
# Line 80 | Line 81 | char *get_memory_stats(){
81          }
82  
83          cache=cache+buffers;
84 <        used=total-(free+cache);
84 >        used=total-free;
85  
86          total=(total/1024)/1024;
87          used=(used/1024)/1024;
88          free=(free/1024)/1024;
89 <        cache=(free/1024)/1024;
89 >        cache=(cache/1024)/1024;
90   #endif
91   #ifdef SOLARIS
92          if((pagesize=sysconf(_SC_PAGESIZE)) == -1){
# Line 173 | Line 174 | char *get_memory_stats(){
174            
175   #endif
176  
177 <        
178 <        if((xml_memory_stats=strf("<memory><total>%ld</total><free>%ld</free><used>%ld</used><cache>%ld</cache></memory>", total, free, used, cache)) == NULL){
177 >        /* casting these from a long long to a long is a KLUDGE! please fix it :) */    
178 >        if((xml_memory_stats=strf("<memory><total>%ld</total><free>%ld</free><used>%ld</used><cache>%ld</cache></memory>", (long)total, (long)free, (long)used, (long)cache)) == NULL){
179                  errf("strf failed (%m)");
180                  return NULL;
181          }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines