Hi Thomas,

FYI...

          I have changed a small line in get_swapinfo function of
agent/mibgroup/hardware/memory/memory_hpux.c
Before:
   119              }
   120              mem->units = pss.pss_swapchunk;
   121              mem->size  = pss.pss_nblksenabled;    /* Or
pss_nblks      ? */
   122              mem->free  = pss.pss_nfpgs;           /* Or
pss_nblksavail ? */
   123              mem->other = -1;
   124              *total += mem->size;
   125              *free  +=mem->other;

After:
   119              }
   120              mem->units = pss.pss_swapchunk;
   121              mem->size  = pss.pss_nblksenabled;    /* Or
pss_nblks      ? */
   122              mem->free  = pss.pss_nfpgs;           /* Or
pss_nblksavail ? */
   123              mem->other = -1;
   124              *total += mem->size;
   125              *free  +=mem->free; //changed line

Then i got the following  o/p for when i run the  modified snmpwalk command


# /opt/iexpress/net-snmp/bin/snmpwalk -v 1 -c public 127.0.0.1 UCD
UCD-SNMP-MIB::memIndex.0 = INTEGER: 0
UCD-SNMP-MIB::memErrorName.0 = STRING: swap
UCD-SNMP-MIB::memTotalSwap.0 = INTEGER: 8388608 kB
UCD-SNMP-MIB::memAvailSwap.0 = INTEGER: 1464754 kB
UCD-SNMP-MIB::memTotalReal.0 = INTEGER: 4192256 kB
UCD-SNMP-MIB::memAvailReal.0 = INTEGER: 231892 kB

But my swapinfo shows

#swapinfo

             Kb      Kb      Kb   PCT  START/      Kb
TYPE      AVAIL    USED    FREE  USED   LIMIT RESERVE  PRI  NAME
dev     4194304 1264796 2929508   30%       0       -    1  /dev/vg00/lvol2
reserve       -  873836 -873836
memory  4192256 1979540 2212716   47%

So i have taken the old hpux_memory.c file present in ucd-snmp dir as
reference  and implemeted a sample program which computes the swap_space in
hp_ux.This file o/p is giving the exact value 292950

Attaching the file i used to get the swap information


Thanks & Regards,
Ravindranath

On Tue, Aug 26, 2008 at 5:00 PM, Thomas Anders
<[EMAIL PROTECTED]>wrote:

> ravindra Chavalam wrote:
> >     Thanks for the response. I can help you in finding the problem in
> > the agent/mibgroup/hardware/
> >
> >     memory/memory_hpux.c. Also can you tell me which binary tracks the
> >     changes of this file.
>
> I fail to understand your question. Please rephrase.
> In case you don't know what to do after making changes to that file: just
> run "make && make install" afterwards again.
>
> > Also there is one more memory_hpux.c file in  ./agent/mibgroup/ucd-snmp
> > ( FYI)
>
> I know, but that file isn't used (by default) in 5.4.x. You may consult it
> as a reference for the old implementation, though.
>
>
> +Thomas
>
> --
> Thomas Anders (thomas.anders at blue-cable.de)
>
#include <net-snmp/net-snmp-config.h>
#if HAVE_STRING_H
#include <string.h>
#endif
#if HAVE_STDLIB_H
#include <stdlib.h>
#endif

#include <sys/types.h>

#include <net-snmp/net-snmp-includes.h>
#include <net-snmp/agent/net-snmp-agent-includes.h>
#include <net-snmp/agent/auto_nlist.h>
#include "memory.h"             /* the module-specific header */
#include "memory_hpux.h"        /* the module-specific header */

#include <sys/pstat.h>
struct swapinfo {
    unsigned long   total_swap; /* in kilobytes */
    unsigned long   free_swap;  /* in kilobytes */
};
long  get_swapinfo(struct swapinfo *swap)
{

    struct pst_swapinfo pss;
    int             i = 0;

    while (pstat_getswap(&pss, sizeof(pss), (size_t) 1, i) != -1) {
        if (pss.pss_idx == (unsigned) i) {
            swap->total_swap += pss.pss_nblksenabled;
            swap->free_swap += 4*pss.pss_nfpgs;       /* nfpgs is in 4-byte 
blocks - who knows why? */
            i++;
        } else
            return swap->free_swap;
    }
}
int main()
{
        struct swapinfo swap;
        printf("%ld\n",get_swapinfo(&swap));
}
-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/
_______________________________________________
Net-snmp-coders mailing list
Net-snmp-coders@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/net-snmp-coders

Reply via email to