~ubuntu-branches/ubuntu/trusty/net-snmp/trusty

« back to all changes in this revision

Viewing changes to agent/mibgroup/host/hr_swrun.c

  • Committer: Bazaar Package Importer
  • Author(s): Jochen Friedrich
  • Date: 2010-06-10 18:02:54 UTC
  • mto: (1.4.1 experimental)
  • mto: This revision was merged to the branch mainline in revision 44.
  • Revision ID: james.westby@ubuntu.com-20100610180254-6ezvupl2clicwdqf
ImportĀ upstreamĀ versionĀ 5.4.3~dfsg

Show diffs side-by-side

added added

removed removed

Lines of Context:
84
84
#include <net-snmp/agent/auto_nlist.h>
85
85
#include "kernel.h"
86
86
#ifdef solaris2
 
87
#if _SLASH_PROC_METHOD_ && defined _ILP32
 
88
#include <net-snmp/agent/cache_handler.h>
 
89
#include <net-snmp/agent/hardware/memory.h>
 
90
#endif
 
91
 
87
92
#include "kernel_sunos5.h"
88
93
#endif
89
94
#if defined(aix4) || defined(aix5) || defined(aix6)
742
747
            sprintf(string, "/proc/%d/status", pid);
743
748
            if ((fp = fopen(string, "r")) == NULL)
744
749
                return NULL;
745
 
            fgets(buf, sizeof(buf), fp);        /* Name: process name */
746
 
            if ( cp == NULL ) {
 
750
            if (!fgets(buf, sizeof(buf), fp)) {
747
751
                fclose(fp);
748
752
                return NULL;    /* the process probably died */
749
753
            }
1151
1155
        long_return = (lowpsinfo.pr_rssize * MMU_PAGESIZE) / 1024;
1152
1156
#elif defined(solaris2)
1153
1157
#if _SLASH_PROC_METHOD_
 
1158
#ifdef _ILP32
 
1159
        if(NULL != proc_buf && 0 == proc_buf->pr_rssize)
 
1160
        { /* Odds on that we are looking with a 32 bit app at a 64 bit psinfo.*/
 
1161
            netsnmp_memory_info *mem;
 
1162
            netsnmp_memory_load();
 
1163
            mem = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_PHYSMEM, 0 );
 
1164
            if (!mem) 
 
1165
            {
 
1166
                snmp_log(LOG_INFO, "netsnmp_memory_get_byIdx returned NULL pointer\n");
 
1167
                long_return = 0;/* Tried my best, giving up.*/
 
1168
            } 
 
1169
            else 
 
1170
            {/* 0x8000 is the maximum range of pr_pctmem. devision of 1024 is to go from B to kB*/
 
1171
                uint32_t pct_unit = (mem->size/0x8000) * (mem->units/1024);
 
1172
                long_return = proc_buf ? proc_buf->pr_pctmem * pct_unit : 0;
 
1173
            }
 
1174
        }
 
1175
        else
 
1176
        {    
 
1177
            long_return = proc_buf ? proc_buf->pr_rssize : 0;
 
1178
        
 
1179
        }
 
1180
#else /*_LP64*/
1154
1181
        long_return = proc_buf ? proc_buf->pr_rssize : 0;
 
1182
#endif /*_LP64*/
 
1183
 
1155
1184
#else
1156
1185
        long_return = proc_buf->p_swrss;
1157
1186
#endif