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

« back to all changes in this revision

Viewing changes to agent/mibgroup/ucd-snmp/loadave.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2007-12-08 14:59:50 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20071208145950-u1tykhpw56nyzqik
Tags: 5.4.1~dfsg-4ubuntu1
* Merge from debian unstable.
* Remaining Ubuntu changes:
  - Remove stop links from rc0 and rc6
  - Munge Maintainer field as per spec.
* Ubuntu changes dropped:
  - Symlink common files between the packages, CDBS ought to handle that
    for us automatically.
* The latest Debian changes has dropped history from the changelog. Slot in
  the Ubuntu changes as best I can. 

Show diffs side-by-side

added added

removed removed

Lines of Context:
122
122
#if defined(aix4) || defined(aix5)
123
123
#include <libperfstat.h>
124
124
#endif
 
125
#if HAVE_SYS_SYSGET_H
 
126
#include <sys/sysget.h>
 
127
#endif
125
128
 
126
129
#include <net-snmp/net-snmp-includes.h>
127
130
#include <net-snmp/agent/net-snmp-agent-includes.h>
153
156
         {LOADMAXVAL}},
154
157
        {LOADAVEINT, ASN_INTEGER, RONLY, var_extensible_loadave, 1,
155
158
         {LOADAVEINT}},
156
 
#ifdef OPAQUE_SPECIAL_TYPES
 
159
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
157
160
        {LOADAVEFLOAT, ASN_OPAQUE_FLOAT, RONLY, var_extensible_loadave, 1,
158
161
         {LOADAVEFLOAT}},
159
162
#endif
168
171
     * registering underneath 
169
172
     */
170
173
    oid             loadave_variables_oid[] =
171
 
        { UCDAVIS_MIB, LOADAVEMIBNUM, 1 };
 
174
        { NETSNMP_UCDAVIS_MIB, NETSNMP_LOADAVEMIBNUM, 1 };
172
175
 
173
176
    /*
174
177
     * register ourselves with the agent to handle our mib tree 
202
205
    int             i;
203
206
 
204
207
    for (i = 0; i <= 2; i++)
205
 
        maxload[i] = DEFMAXLOADAVE;
 
208
        maxload[i] = NETSNMP_DEFMAXLOADAVE;
206
209
}
207
210
 
208
211
/*
232
235
    perfstat_cpu_total_t cs;
233
236
#endif
234
237
#if defined(hpux10) || defined(hpux11)
235
 
  struct pst_dynamic pst_buf;
236
 
#endif
237
 
#endif  /* HAVE_GETLOADAVG */
 
238
    struct pst_dynamic pst_buf;
 
239
#endif
 
240
#ifdef irix6
 
241
    int             i, favenrun[3];
 
242
    sgt_cookie_t    cookie;
 
243
#endif
 
244
#endif  /* !HAVE_GETLOADAVG */
238
245
 
239
246
#ifdef HAVE_GETLOADAVG
240
247
    if (getloadavg(pave, s_ave) == -1)
261
268
    r_ave[0] = pst_buf.psd_avg_1_min;
262
269
    r_ave[1] = pst_buf.psd_avg_5_min;
263
270
    r_ave[2] = pst_buf.psd_avg_15_min;
264
 
#elif !defined(cygwin)
265
 
#ifdef CAN_USE_NLIST
266
 
#if defined(aix4) || defined(aix5)
 
271
#elif defined(aix4) || defined(aix5)
267
272
    if(perfstat_cpu_total((perfstat_id_t *)NULL, &cs, sizeof(perfstat_cpu_total_t), 1) > 0) {
268
273
        r_ave[0] = cs.loadavg[0] / 65536.0;
269
274
        r_ave[1] = cs.loadavg[1] / 65536.0;
270
275
        r_ave[2] = cs.loadavg[2] / 65536.0;
271
276
    }
272
 
    return 0;
273
 
#else
 
277
#elif defined(irix6)
 
278
    SGT_COOKIE_INIT(&cookie);
 
279
    SGT_COOKIE_SET_KSYM(&cookie, "avenrun");
 
280
    sysget(SGT_KSYM, (char*)favenrun, sizeof(favenrun), SGT_READ, &cookie);
 
281
    for (i = 0; i < s_ave; i++)
 
282
      r_ave[i] = favenrun[i] / 1000.0;
 
283
    DEBUGMSGTL(("ucd-snmp/loadave", "irix6: %d %d %d\n", favenrun[0], favenrun[1], favenrun[2]));
 
284
#elif !defined(cygwin)
 
285
#if defined(NETSNMP_CAN_USE_NLIST) && defined(LOADAVE_SYMBOL)
274
286
    if (auto_nlist(LOADAVE_SYMBOL, (char *) pave, sizeof(double) * s_ave)
275
287
        == 0)
276
288
#endif
277
 
#endif
278
289
        return (-1);
279
290
#endif
280
291
    /*
339
350
    case LOADAVEINT:
340
351
        long_ret = (u_long) (avenrun[name[*length - 1] - 1] * 100);
341
352
        return ((u_char *) (&long_ret));
342
 
#ifdef OPAQUE_SPECIAL_TYPES
 
353
#ifdef NETSNMP_WITH_OPAQUE_SPECIAL_TYPES
343
354
    case LOADAVEFLOAT:
344
355
        float_ret = (float) avenrun[name[*length - 1] - 1];
345
356
        *var_len = sizeof(float_ret);