205
205
extern int fscount;
206
206
#define HRFS_statfs statvfs
207
207
#define HRFS_mount f_mntonname
208
#define HRFS_HAS_FRSIZE STRUCT_STATVFS_HAS_F_FRSIZE
208
#define HRFS_HAS_FRSIZE HAVE_STRUCT_STATVFS_F_FRSIZE
210
#elif defined(HAVE_STATVFS) && defined(STRUCT_STATVFS_HAS_MNT_DIR)
210
#elif defined(HAVE_STATVFS) && defined(HAVE_STRUCT_STATVFS_MNT_DIR)
212
212
extern struct mntent *HRFS_entry;
213
213
extern int fscount;
214
214
#define HRFS_statfs statvfs
215
215
#define HRFS_mount mnt_dir
216
#define HRFS_HAS_FRSIZE HAVE_STRUCT_STATVFS_F_FRSIZE
218
#elif defined(HAVE_GETFSSTAT) && !defined(HAVE_STATFS) && defined(HAVE_STATVFS)
220
extern struct statfs *HRFS_entry;
222
#define HRFS_statfs statvfs
223
#define HRFS_mount f_mntonname
216
224
#define HRFS_HAS_FRSIZE STRUCT_STATVFS_HAS_F_FRSIZE
218
226
#elif defined(HAVE_GETFSSTAT)
263
272
#define HRSTORE_USED 7
264
273
#define HRSTORE_FAILS 8
266
struct variable4 hrstore_variables[] = {
267
{HRSTORE_MEMSIZE, ASN_INTEGER, RONLY, var_hrstore, 1, {2}},
268
{HRSTORE_INDEX, ASN_INTEGER, RONLY, var_hrstore, 3, {3, 1, 1}},
269
{HRSTORE_TYPE, ASN_OBJECT_ID, RONLY, var_hrstore, 3, {3, 1, 2}},
270
{HRSTORE_DESCR, ASN_OCTET_STR, RONLY, var_hrstore, 3, {3, 1, 3}},
271
{HRSTORE_UNITS, ASN_INTEGER, RONLY, var_hrstore, 3, {3, 1, 4}},
272
{HRSTORE_SIZE, ASN_INTEGER, RONLY, var_hrstore, 3, {3, 1, 5}},
273
{HRSTORE_USED, ASN_INTEGER, RONLY, var_hrstore, 3, {3, 1, 6}},
274
{HRSTORE_FAILS, ASN_COUNTER, RONLY, var_hrstore, 3, {3, 1, 7}}
275
struct variable2 hrstore_variables[] = {
276
{HRSTORE_INDEX, ASN_INTEGER, NETSNMP_OLDAPI_RONLY,
277
var_hrstore, 1, {1}},
278
{HRSTORE_TYPE, ASN_OBJECT_ID, NETSNMP_OLDAPI_RONLY,
279
var_hrstore, 1, {2}},
280
{HRSTORE_DESCR, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY,
281
var_hrstore, 1, {3}},
282
{HRSTORE_UNITS, ASN_INTEGER, NETSNMP_OLDAPI_RONLY,
283
var_hrstore, 1, {4}},
284
{HRSTORE_SIZE, ASN_INTEGER, NETSNMP_OLDAPI_RONLY,
285
var_hrstore, 1, {5}},
286
{HRSTORE_USED, ASN_INTEGER, NETSNMP_OLDAPI_RONLY,
287
var_hrstore, 1, {6}},
288
{HRSTORE_FAILS, ASN_COUNTER, NETSNMP_OLDAPI_RONLY,
276
291
oid hrstore_variables_oid[] = { 1, 3, 6, 1, 2, 1, 25, 2 };
292
oid hrMemorySize_oid[] = { 1, 3, 6, 1, 2, 1, 25, 2, 2 };
293
oid hrStorageTable_oid[] = { 1, 3, 6, 1, 2, 1, 25, 2, 3, 1 };
284
REGISTER_MIB("host/hr_storage", hrstore_variables, variable4,
285
hrstore_variables_oid);
301
netsnmp_register_scalar(
302
netsnmp_create_handler_registration("host/hrMemorySize", handle_memsize,
303
hrMemorySize_oid, OID_LENGTH(hrMemorySize_oid),
305
REGISTER_MIB("host/hr_storage", hrstore_variables, variable2,
287
308
appname = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID,
288
309
NETSNMP_DS_LIB_APPTYPE);
332
header_hrstore(struct variable *vp,
335
int exact, size_t * var_len, WriteMethod ** write_method)
337
#define HRSTORE_NAME_LENGTH 9
338
oid newname[MAX_OID_LEN];
341
DEBUGMSGTL(("host/hr_storage", "var_hrstore: "));
342
DEBUGMSGOID(("host/hr_storage", name, *length));
343
DEBUGMSG(("host/hr_storage", " %d\n", exact));
345
memcpy((char *) newname, (char *) vp->name, vp->namelen * sizeof(oid));
346
newname[HRSTORE_NAME_LENGTH] = 0;
347
result = snmp_oid_compare(name, *length, newname, vp->namelen + 1);
348
if ((exact && (result != 0)) || (!exact && (result >= 0)))
349
return (MATCH_FAILED);
350
memcpy((char *) name, (char *) newname,
351
(vp->namelen + 1) * sizeof(oid));
352
*length = vp->namelen + 1;
355
*var_len = sizeof(long); /* default to 'long' results */
356
return (MATCH_SUCCEEDED);
360
353
header_hrstoreEntry(struct variable *vp,
490
483
*********************/
492
static const char *hrs_descr[] = {
494
"Memory Buffers", /* HRS_TYPE_MBUF */
495
"Real Memory", /* HRS_TYPE_MEM */
496
"Swap Space" /* HRS_TYPE_SWAP */
486
handle_memsize(netsnmp_mib_handler *handler,
487
netsnmp_handler_registration *reginfo,
488
netsnmp_agent_request_info *reqinfo,
489
netsnmp_request_info *requests)
491
netsnmp_memory_info *mem_info;
495
* We just need to handle valid GET requests, as invalid instances
496
* are rejected automatically, and (valid) GETNEXT requests are
497
* converted into the appropriate GET request.
499
* We also only ever receive one request at a time.
501
switch (reqinfo->mode) {
503
netsnmp_memory_load();
504
mem_info = netsnmp_memory_get_byIdx( NETSNMP_MEM_TYPE_PHYSMEM, 0 );
505
if ( !mem_info || mem_info->size == -1 || mem_info->units == -1 )
506
netsnmp_set_request_error( reqinfo, requests, SNMP_NOSUCHOBJECT );
508
val = mem_info->size; /* memtotal */
509
val *= (mem_info->units/1024);
510
snmp_set_var_typed_value(requests->requestvb, ASN_INTEGER,
511
(u_char *)&val, sizeof(val));
513
return SNMP_ERR_NOERROR;
517
* we should never get here, so this is a really bad error
519
snmp_log(LOG_ERR, "unknown mode (%d) in handle_memsize\n",
521
return SNMP_ERR_GENERR;
524
return SNMP_ERR_NOERROR;
525
546
store_idx = name[ HRSTORE_ENTRY_NAME_LENGTH ];
527
store_idx > NETSNMP_MEM_TYPE_MAX &&
528
netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
529
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
530
Check_HR_FileSys_NFS())
532
547
if (store_idx > NETSNMP_MEM_TYPE_MAX ) {
548
if ( netsnmp_ds_get_boolean(NETSNMP_DS_APPLICATION_ID,
549
NETSNMP_DS_AGENT_SKIPNFSINHOSTRESOURCES) &&
550
Check_HR_FileSys_NFS())
551
return NULL; /* or goto try_next; */
533
552
if (HRFS_statfs(HRFS_entry->HRFS_mount, &stat_buf) < 0) {
534
553
snmp_log_perror(HRFS_entry->HRFS_mount);