vmstat_hpux.c
上传用户:wxp200602
上传日期:2007-10-30
资源大小:4028k
文件大小:21k
源码类别:

SNMP编程

开发平台:

Unix_Linux

  1. /*
  2.  *  vmstat_hpux.c
  3.  *  UCD SNMP module for systemStats section of UCD-SNMP-MIB for HPUX 10.x/11.x
  4.  */
  5. /*
  6.  * To make lint skip the debug code and stop complaining 
  7.  */
  8. #ifdef __lint
  9. #define SNMP_NO_DEBUGGING 1
  10. #endif
  11. /*
  12.  * Includes start here 
  13.  */
  14. /*
  15.  * UCD-SNMP config details 
  16.  */
  17. #include <net-snmp/net-snmp-config.h>
  18. /*
  19.  * Standard includes 
  20.  */
  21. #include <stdlib.h>
  22. #include <unistd.h>
  23. #include <sys/types.h>
  24. #include <sys/time.h>
  25. #include <string.h>
  26. /*
  27.  * pstat and sysinfo structs 
  28.  */
  29. #include <sys/pstat.h>
  30. #include <sys/dk.h>
  31. /*
  32.  * Includes needed for all modules 
  33.  */
  34. #include <net-snmp/net-snmp-includes.h>
  35. #include <net-snmp/agent/net-snmp-agent-includes.h>
  36. #include "mibdefs.h"
  37. /*
  38.  * Utility functions for UCD-SNMP 
  39.  */
  40. #include "util_funcs.h"
  41. /*
  42.  * Header file for this module 
  43.  */
  44. #include "vmstat.h"
  45. #include "vmstat_hpux.h"
  46. /*
  47.  * Includes end here 
  48.  */
  49. /*
  50.  * Global structures start here 
  51.  */
  52. /*
  53.  * A structure to save data gathered from the kernel pstat interface to.
  54.  * CPUSTATES are defined as (see sys/dk.h):
  55.  * #define CPUSTATES       9       -- number of CPU states
  56.  * #define CP_USER         0       -- user mode of USER process
  57.  * #define CP_NICE         1       -- user mode of USER process at nice priority
  58.  * #define CP_SYS          2       -- kernel mode of USER process
  59.  * #define CP_IDLE         3       -- IDLE mode
  60.  * #define CP_WAIT         4       
  61.  * #define CP_BLOCK        5       -- time blocked on a spinlock
  62.  * #define CP_SWAIT        6       -- time blocked on the kernel semaphore
  63.  * #define CP_INTR         7       -- INTERRUPT mode
  64.  * #define CP_SSYS         8       -- kernel mode of KERNEL process
  65.  */
  66. struct cpu_stat_snapshot {
  67.     time_t          css_time;
  68.     unsigned int    css_cpus;
  69.     unsigned long long css_swapin;
  70.     unsigned long long css_swapout;
  71.     unsigned long long css_blocks_read;
  72.     unsigned long long css_blocks_write;
  73.     unsigned long long css_interrupts;
  74.     unsigned long long css_context_sw;
  75.     unsigned long long css_cpu[CPUSTATES];
  76. };
  77. /*
  78.  * Define a structure to hold kernel static information 
  79.  */
  80. struct pst_static pst;
  81. /*
  82.  * Global structures end here 
  83.  */
  84. /*
  85.  * Global variables start here 
  86.  */
  87. /*
  88.  * Variables for the calculated values, filled in update_stats    
  89.  * Need to be global since we need them in more than one function 
  90.  */
  91. static unsigned long swapin;
  92. static unsigned long swapout;
  93. static unsigned long blocks_read;
  94. static unsigned long blocks_write;
  95. static unsigned long interrupts;
  96. static unsigned long context_sw;
  97. /*
  98.  * Since MIB wants CPU_SYSTEM, which is CP_SYS + CP_WAIT (see sys/dk.h) 
  99.  */
  100. static long     cpu_perc[CPUSTATES + 1];
  101. /*
  102.  * How many snapshots we have already taken, needed for the first 
  103.  * POLL_INTERVAL * POLL_VALUES seconds of agent running 
  104.  */
  105. static unsigned int number_of_snapshots;
  106. /*
  107.  * The place to store the snapshots of system data in 
  108.  */
  109. static struct cpu_stat_snapshot snapshot[POLL_VALUES + 1];
  110. /*
  111.  * And one for the raw counters, which we fill when the raw values are 
  112.  * requested, as opposed to the absolute values, which are taken every 
  113.  * POLL_INTERVAL seconds and calculated over POLL_INTERVAL * POLL_VALUES time 
  114.  */
  115. static struct cpu_stat_snapshot raw_values;
  116. /*
  117.  * Global variables end here 
  118.  */
  119. /*
  120.  * Functions start here 
  121.  */
  122. /*
  123.  * Function prototype 
  124.  */
  125. static void     update_stats(unsigned int registrationNumber,
  126.                              void *clientarg);
  127. static int      take_snapshot(struct cpu_stat_snapshot *css);
  128. /*
  129.  * init_vmstat_hpux starts here 
  130.  */
  131. /*
  132.  * Init function for this module, from prototype 
  133.  * Defines variables handled by this module, defines root OID for 
  134.  * this module and registers it with the agent 
  135.  */
  136. FindVarMethod var_extensible_vmstat;
  137. void
  138. init_vmstat_hpux(void)
  139. {
  140.     /*
  141.      * Which variables do we service ? 
  142.      */
  143.     struct variable2 extensible_vmstat_variables[] = {
  144.         {MIBINDEX, ASN_INTEGER, RONLY, var_extensible_vmstat, 1,
  145.          {MIBINDEX}},
  146.         {ERRORNAME, ASN_OCTET_STR, RONLY, var_extensible_vmstat, 1,
  147.          {ERRORNAME}},
  148.         {SWAPIN, ASN_INTEGER, RONLY, var_extensible_vmstat, 1, {SWAPIN}},
  149.         {SWAPOUT, ASN_INTEGER, RONLY, var_extensible_vmstat, 1, {SWAPOUT}},
  150.         {IOSENT, ASN_INTEGER, RONLY, var_extensible_vmstat, 1, {IOSENT}},
  151.         {IORECEIVE, ASN_INTEGER, RONLY, var_extensible_vmstat, 1,
  152.          {IORECEIVE}},
  153.         {SYSINTERRUPTS, ASN_INTEGER, RONLY, var_extensible_vmstat, 1,
  154.          {SYSINTERRUPTS}},
  155.         {SYSCONTEXT, ASN_INTEGER, RONLY, var_extensible_vmstat, 1,
  156.          {SYSCONTEXT}},
  157.         {CPUUSER, ASN_INTEGER, RONLY, var_extensible_vmstat, 1, {CPUUSER}},
  158.         {CPUSYSTEM, ASN_INTEGER, RONLY, var_extensible_vmstat, 1,
  159.          {CPUSYSTEM}},
  160.         {CPUIDLE, ASN_INTEGER, RONLY, var_extensible_vmstat, 1, {CPUIDLE}},
  161.         {CPURAWUSER, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
  162.          {CPURAWUSER}},
  163.         {CPURAWNICE, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
  164.          {CPURAWNICE}},
  165.         {CPURAWSYSTEM, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
  166.          {CPURAWSYSTEM}},
  167.         {CPURAWIDLE, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
  168.          {CPURAWIDLE}},
  169.         {CPURAWWAIT, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
  170.          {CPURAWWAIT}},
  171.         {CPURAWKERNEL, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
  172.          {CPURAWKERNEL}},
  173.         {IORAWSENT, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
  174.          {IORAWSENT}},
  175.         {IORAWRECEIVE, ASN_COUNTER, RONLY, var_extensible_vmstat, 1,
  176.          {IORAWRECEIVE}},
  177.         /*
  178.          * Future use: 
  179.          */
  180.         /*
  181.          * {ERRORFLAG, ASN_INTEGER, RONLY, var_extensible_vmstat, 1, {ERRORFLAG }},
  182.          * {ERRORMSG, ASN_OCTET_STR, RONLY, var_extensible_vmstat, 1, {ERRORMSG }}
  183.          */
  184.     };
  185.     /*
  186.      * Define the OID pointer to the top of the mib tree that we're 
  187.      * registering underneath 
  188.      */
  189.     oid             vmstat_variables_oid[] = { UCDAVIS_MIB, 11 };
  190.     /*
  191.      * register ourselves with the agent to handle our mib tree 
  192.      */
  193.     /*
  194.      * LINTED Trust me, I know what I'm doing 
  195.      */
  196.     REGISTER_MIB("ucd-snmp/vmstat", extensible_vmstat_variables, variable2,
  197.                  vmstat_variables_oid);
  198.     /*
  199.      * Start with some useful data 
  200.      */
  201.     update_stats(0, NULL);
  202.     /*
  203.      * update_stats is run every POLL_INTERVAL seconds using this routine 
  204.      * (see 'man snmp_alarm') 
  205.      * This is only executed once to get some useful data in the beginning 
  206.      */
  207.     if (snmp_alarm_register(5, NULL, update_stats, NULL) == 0) {
  208.         snmp_log(LOG_WARNING,
  209.                  "vmstat_hpux (init): snmp_alarm_register failed.n");
  210.     }
  211.     /*
  212.      * This is the one that runs update_stats every POLL_INTERVAL seconds 
  213.      */
  214.     if (snmp_alarm_register(POLL_INTERVAL, SA_REPEAT, update_stats, NULL)
  215.         == 0) {
  216.         snmp_log(LOG_ERR,
  217.                  "vmstat_hpux (init): snmp_alarm_register failed, cannot service requests.n");
  218.     }
  219. }                               /* init_vmstat_hpux ends here */
  220. /*
  221.  * Data collection function take_snapshot starts here 
  222.  * Get data from kernel and save into the snapshot strutcs 
  223.  * Argument is the snapshot struct to save to. Global anyway, but looks nicer 
  224.  */
  225. static int
  226. take_snapshot(struct cpu_stat_snapshot *css)
  227. {
  228.     /*
  229.      * Variables start here 
  230.      */
  231.     struct pst_dynamic psd;
  232.     struct pst_processor *psp;
  233.     struct pst_vminfo psv;
  234.     /*
  235.      * time counter 
  236.      */
  237.     time_t          current_time;
  238.     /*
  239.      * The usual stuff to count on, err, by 
  240.      */
  241.     int             i;
  242.     /*
  243.      * Variables end here 
  244.      */
  245.     /*
  246.      * Function starts here 
  247.      */
  248.     /*
  249.      * Get time 
  250.      */
  251.     time(&current_time);
  252.     /*
  253.      * If we have just gotten the data, return the values from last run (skip if-clause) 
  254.      * This happens on a snmpwalk request.  No need to read the pstat again 
  255.      * if we just did it less than 2 seconds ago 
  256.      * Jumps into if-clause either when snapshot is empty or when too old 
  257.      */
  258.     if ((css->css_time == 0) || (current_time > css->css_time + 2)) {
  259.         /*
  260.          * Make sure we clean up before we put new data into snapshot 
  261.          */
  262.         memset(css, 0, sizeof *css);
  263.         /*
  264.          * Update timer 
  265.          */
  266.         css->css_time = current_time;
  267.         if (pstat_getdynamic(&psd, sizeof(psd), (size_t) 1, 0) != -1) {
  268.             css->css_cpus = psd.psd_proc_cnt;
  269.             DEBUGMSGTL(("take_snapshot", "*** Number of CPUs: %dn",
  270.                         css->css_cpus));
  271.             /*
  272.              * We need a for-loop for the CPU values 
  273.              */
  274.             for (i = 0; i < CPUSTATES; i++) {
  275.                 css->css_cpu[i] = (unsigned long long) psd.psd_cpu_time[i];
  276.                 DEBUGMSGTL(("take_snapshot",
  277.                             "*** Time for CPU state %d: %dn", i,
  278.                             psd.psd_cpu_time[i]));
  279.             }
  280.             psp =
  281.                 (struct pst_processor *) malloc(css->css_cpus *
  282.                                                 sizeof(*psp));
  283.             if (pstat_getprocessor(psp, sizeof(*psp), css->css_cpus, 0) !=
  284.                 -1) {
  285.                 int             i;
  286.                 for (i = 0; i < css->css_cpus; i++) {
  287.                     css->css_blocks_read = psp[i].psp_phread;
  288.                     css->css_blocks_write = psp[i].psp_phwrite;
  289.                 }
  290.             } else
  291.                 snmp_log(LOG_ERR,
  292.                          "vmstat_hpux (take_snapshot): pstat_getprocessor failed!n");
  293.         } else
  294.             snmp_log(LOG_ERR,
  295.                      "vmstat_hpux (take_snapshot): pstat_getdynamic failed!n");
  296.         if (pstat_getvminfo(&psv, sizeof(psv), (size_t) 1, 0) != -1) {
  297.             css->css_swapin = psv.psv_sswpin;
  298.             css->css_swapout = psv.psv_sswpout;
  299.             css->css_interrupts = psv.psv_sintr;
  300.             css->css_context_sw = psv.psv_sswtch;
  301.         } else
  302.             snmp_log(LOG_ERR,
  303.                      "vmstat_hpux (take_snapshot): pstat_getvminfo failed!n");
  304.     }
  305.     /*
  306.      * All engines running at warp speed, no problems (if there are any engines, that is) 
  307.      */
  308.     return (css->css_cpus > 0 ? 0 : -1);
  309. }                               /* take_snapshot ends here */
  310. /*
  311.  * This gets called every POLL_INTERVAL seconds to update the snapshots.  It takes a new snapshot and 
  312.  * drops the oldest one.  This way we move the time window so we always take the values over 
  313.  * POLL_INTERVAL * POLL_VALUES seconds and update the data used every POLL_INTERVAL seconds 
  314.  * The alarm timer is in the init function of this module (snmp_alarm_register) 
  315.  */
  316. /*
  317.  * ARGSUSED0 
  318.  */
  319. static void
  320. update_stats(unsigned int registrationNumber, void *clientarg)
  321. {
  322.     /*
  323.      * The time between the samples we compare 
  324.      */
  325.     time_t          time_diff;
  326.     /*
  327.      * Easier to use these than the snapshots, short hand pointers 
  328.      */
  329.     struct cpu_stat_snapshot *css_old, *css_new;
  330.     /*
  331.      * The usual stuff to count on, err, by 
  332.      */
  333.     int             i;
  334.     /*
  335.      * The sum of the CPU ticks that have passed on the different CPU states, so we can calculate 
  336.      * the percentages of each state 
  337.      */
  338.     unsigned long long cpu_sum = 0;
  339.     DEBUGMSGTL(("ucd-snmp/vmstat_hpux.c:update_stats",
  340.                 "updating statsn"));
  341.     /*
  342.      * Take the current snapshot 
  343.      */
  344.     if (take_snapshot(&snapshot[0]) == -1) {
  345.         snmp_log(LOG_WARNING,
  346.                  "vmstat_hpux (update_stats): Something went wrong with take_snapshot.n");
  347.         return;
  348.     }
  349.     /*
  350.      * Do we have some data we can use ?  An issue right after the start of the agent 
  351.      */
  352.     if (number_of_snapshots > 0) {
  353.         /*
  354.          * Huh, the number of CPUs changed during run time.  That is indeed s.th. worth noting, we 
  355.          * output a humorous (more or less) syslog message and need to retake the snapshots 
  356.          */
  357.         if (snapshot[0].css_cpus != snapshot[1].css_cpus) {
  358.             if (snapshot[0].css_cpus > snapshot[1].css_cpus) {
  359.                 snmp_log(LOG_NOTICE,
  360.                          "vmstat_hpux (update_stats): Cool ! Number of CPUs increased, must be hot-pluggable.n");
  361.             } else {
  362.                 snmp_log(LOG_NOTICE,
  363.                          "vmstat_hpux (update_stats): Lost at least one CPU, RIP.n");
  364.             }
  365.             /*
  366.              * Make all snapshots but the current one invalid 
  367.              */
  368.             number_of_snapshots = 1;
  369.             /*
  370.              * Move the current one in the "first" [1] slot 
  371.              */
  372.             memmove(&snapshot[1], &snapshot[0], sizeof snapshot[0]);
  373.             /*
  374.              * Erase the current one 
  375.              */
  376.             memset(&snapshot[0], 0, sizeof snapshot[0]);
  377.             /*
  378.              * Try to get a new snapshot in five seconds so we can return s.th. useful 
  379.              */
  380.             if (snmp_alarm_register(5, NULL, update_stats, NULL) == 0) {
  381.                 snmp_log(LOG_WARNING,
  382.                          "vmstat_hpux (update_stats): snmp_alarm_register failed.n");
  383.             }
  384.             return;
  385.         }
  386.         /*
  387.          * Short hand pointers 
  388.          */
  389.         css_new = &snapshot[0];
  390.         css_old = &snapshot[number_of_snapshots];
  391.         /*
  392.          * How much time has passed between the snapshots we get the values from ? 
  393.          */
  394.         time_diff =
  395.             (snapshot[0].css_time -
  396.              snapshot[number_of_snapshots].css_time);
  397.         DEBUGMSGTL(("ucd-snmp/vmstat_hpux.c:update_stats",
  398.                     "time_diff: %lldn", time_diff));
  399.         /*
  400.          * swapin and swapout are in pages, MIB wants kB/s,so we just need to get kB and seconds 
  401.          * For the others we need to get value per second 
  402.          * Retreive static information to obtain memory page_size 
  403.          */
  404.         if (pstat_getstatic(&pst, sizeof(pst), (size_t) 1, 0) == -1) {
  405.             snmp_log(LOG_ERR, "vmstat_hpux: pstat_getstatic failed!n");
  406.         }
  407.         /*
  408.          * LINTED cast needed, really 
  409.          */
  410.         swapin =
  411.             (unsigned int) ((css_new->css_swapin - css_old->css_swapin) *
  412.                             pst.page_size / 1024 / time_diff);
  413.         /*
  414.          * LINTED cast needed, really 
  415.          */
  416.         swapout =
  417.             (unsigned int) ((css_new->css_swapout - css_old->css_swapout) *
  418.                             pst.page_size / 1024 / time_diff);
  419.         /*
  420.          * LINTED cast needed, really 
  421.          */
  422.         blocks_read =
  423.             (unsigned
  424.              int) ((css_new->css_blocks_read -
  425.                     css_old->css_blocks_read) / time_diff);
  426.         /*
  427.          * LINTED cast needed, really 
  428.          */
  429.         blocks_write =
  430.             (unsigned
  431.              int) ((css_new->css_blocks_write -
  432.                     css_old->css_blocks_write) / time_diff);
  433.         /*
  434.          * LINTED cast needed, really 
  435.          */
  436.         interrupts =
  437.             (unsigned
  438.              int) ((css_new->css_interrupts -
  439.                     css_old->css_interrupts) / time_diff);
  440.         /*
  441.          * LINTED cast needed, really 
  442.          */
  443.         context_sw =
  444.             (unsigned
  445.              int) ((css_new->css_context_sw -
  446.                     css_old->css_context_sw) / time_diff);
  447.         /*
  448.          * Loop thru all the CPUSTATES and get the differences 
  449.          */
  450.         for (i = 0; i < CPUSTATES; i++) {
  451.             cpu_sum += (css_new->css_cpu[i] - css_old->css_cpu[i]);
  452.         }
  453.         /*
  454.          * Now calculate the absolute percentage values 
  455.          * Looks somewhat complicated sometimes but tries to get around using floats to increase speed 
  456.          */
  457.         for (i = 0; i < CPUSTATES; i++) {
  458.             /*
  459.              * Since we don't return fractions we use + 0.5 to get between 99 and 101 percent adding the values 
  460.              * together, otherwise we would get less than 100 most of the time 
  461.              */
  462.             /*
  463.              * LINTED has to be 'long' 
  464.              */
  465.             cpu_perc[i] =
  466.                 (long) (((css_new->css_cpu[i] -
  467.                           css_old->css_cpu[i]) * 100 +
  468.                          (cpu_sum / 2)) / cpu_sum);
  469.         }
  470.         /*
  471.          * As said before, MIB wants CPU_SYSTEM which is CP_SYS + CP_WAIT 
  472.          */
  473.         /*
  474.          * LINTED has to be 'long' 
  475.          */
  476.         cpu_perc[CPU_SYSTEM] =
  477.             (long) ((((css_new->css_cpu[CP_SYS] - css_old->css_cpu[CP_SYS])
  478.                       + (css_new->css_cpu[CP_WAIT] -
  479.                          css_old->css_cpu[CP_WAIT]))
  480.                      * 100 + (cpu_sum / 2)) / cpu_sum);
  481.     }
  482.     /*
  483.      * Make the current one the first one and move the whole thing one place down 
  484.      */
  485.     memmove(&snapshot[1], &snapshot[0],
  486.             (size_t) (((char *) &snapshot[POLL_VALUES]) -
  487.                       ((char *) &snapshot[0])));
  488.     /*
  489.      * Erase the current one 
  490.      */
  491.     memset(&snapshot[0], 0, sizeof snapshot[0]);
  492.     /*
  493.      * Only important on start up, we keep track of how many snapshots we have taken so far 
  494.      */
  495.     if (number_of_snapshots < POLL_VALUES) {
  496.         number_of_snapshots++;
  497.     }
  498. }                               /* update_stats ends here */
  499. /*
  500.  * *var_extensible_vmstat starts here 
  501.  * The guts of the module, this routine gets called to service a request 
  502.  */
  503. unsigned char *
  504. var_extensible_vmstat(struct variable *vp,
  505.                       oid * name,
  506.                       size_t * length,
  507.                       int exact,
  508.                       size_t * var_len, WriteMethod ** write_method)
  509. {
  510.     /*
  511.      * Needed for returning the values 
  512.      */
  513.     static long     long_ret;
  514.     static char     errmsg[300];
  515.     /*
  516.      * set to 0 as default 
  517.      */
  518.     long_ret = 0;
  519.     /*
  520.      * generic check whether the options passed make sense and whether the 
  521.      * right variable is requested 
  522.      */
  523.     if (header_generic(vp, name, length, exact, var_len, write_method) !=
  524.         MATCH_SUCCEEDED) {
  525.         return (NULL);
  526.     }
  527.     /*
  528.      * The function that actually returns s.th. 
  529.      */
  530.     switch (vp->magic) {
  531.     case MIBINDEX:
  532.         long_ret = 1;
  533.         return ((u_char *) (&long_ret));
  534.     case ERRORNAME:            /* dummy name */
  535.         sprintf(errmsg, "systemStats");
  536.         *var_len = strlen(errmsg);
  537.         return ((u_char *) (errmsg));
  538.     case SWAPIN:
  539.         return ((u_char *) (&swapin));
  540.     case SWAPOUT:
  541.         return ((u_char *) (&swapout));
  542.     case IOSENT:
  543.         return ((u_char *) (&blocks_write));
  544.     case IORECEIVE:
  545.         return ((u_char *) (&blocks_read));
  546.     case SYSINTERRUPTS:
  547.         return ((u_char *) (&interrupts));
  548.     case SYSCONTEXT:
  549.         return ((u_char *) (&context_sw));
  550.     case CPUUSER:
  551.         return ((u_char *) (&cpu_perc[CP_USER]));
  552.     case CPUSYSTEM:
  553.         return ((u_char *) (&cpu_perc[CPU_SYSTEM]));
  554.     case CPUIDLE:
  555.         return ((u_char *) (&cpu_perc[CP_IDLE]));
  556.     case CPURAWUSER:
  557.         take_snapshot(&raw_values);
  558.         /*
  559.          * LINTED has to be 'long' 
  560.          */
  561.         long_ret =
  562.             (long) (raw_values.css_cpu[CP_USER] / raw_values.css_cpus);
  563.         return ((u_char *) (&long_ret));
  564.     case CPURAWNICE:
  565.         take_snapshot(&raw_values);
  566.         /*
  567.          * LINTED has to be 'long' 
  568.          */
  569.         long_ret =
  570.             (long) (raw_values.css_cpu[CP_NICE] / raw_values.css_cpus);
  571.         return ((u_char *) (&long_ret));
  572.     case CPURAWSYSTEM:
  573.         take_snapshot(&raw_values);
  574.         /*
  575.          * LINTED has to be 'long' 
  576.          */
  577.         long_ret =
  578.             (long) ((raw_values.css_cpu[CP_SYS] +
  579.                      raw_values.css_cpu[CP_WAIT]) / raw_values.css_cpus);
  580.         return ((u_char *) (&long_ret));
  581.     case CPURAWIDLE:
  582.         take_snapshot(&raw_values);
  583.         /*
  584.          * LINTED has to be 'long' 
  585.          */
  586.         long_ret =
  587.             (long) (raw_values.css_cpu[CP_IDLE] / raw_values.css_cpus);
  588.         return ((u_char *) (&long_ret));
  589.     case CPURAWWAIT:
  590.         take_snapshot(&raw_values);
  591.         /*
  592.          * LINTED has to be 'long' 
  593.          */
  594.         long_ret =
  595.             (long) (raw_values.css_cpu[CP_WAIT] / raw_values.css_cpus);
  596.         return ((u_char *) (&long_ret));
  597.     case CPURAWKERNEL:
  598.         take_snapshot(&raw_values);
  599.         /*
  600.          * LINTED has to be 'long' 
  601.          */
  602.         long_ret =
  603.             (long) (raw_values.css_cpu[CP_SYS] / raw_values.css_cpus);
  604.         return ((u_char *) (&long_ret));
  605.     case IORAWSENT:
  606.         take_snapshot(&raw_values);
  607.         /*
  608.          * LINTED has to be 'long' 
  609.          */
  610.         long_ret = (long) (raw_values.css_blocks_write);
  611.         return ((u_char *) (&long_ret));
  612.     case IORAWRECEIVE:
  613.         take_snapshot(&raw_values);
  614.         /*
  615.          * LINTED has to be 'long' 
  616.          */
  617.         long_ret = (long) (raw_values.css_blocks_read);
  618.         return ((u_char *) (&long_ret));
  619.         /*
  620.          * reserved for future use 
  621.          */
  622.         /*
  623.          * case ERRORFLAG:
  624.          * return((u_char *) (&long_ret));
  625.          * case ERRORMSG:
  626.          * return((u_char *) (&long_ret));
  627.          */
  628.     default:
  629.         snmp_log(LOG_ERR,
  630.                  "vmstat_hpux: Error in request, no match found.n");
  631.     }
  632.     return (NULL);
  633. }                               /* *var_extensible_vmstat ends here */
  634. /*
  635.  * Functions end here 
  636.  */
  637. /*
  638.  * Program ends here 
  639.  */