void init_diskio(void) { /* * Define a 'variable' structure that is a representation of our mib. */ /* * first, we have to pick the variable type. They are all defined in * the var_struct.h file in the agent subdirectory. I'm picking the * variable2 structure since the longest sub-component of the oid I * want to load is .2.1 and .2.2 so I need at most 2 spaces in the * last entry. */ struct variable2 diskio_variables[] = { {DISKIO_INDEX, ASN_INTEGER, RONLY, var_diskio, 1, {1}}, {DISKIO_DEVICE, ASN_OCTET_STR, RONLY, var_diskio, 1, {2}}, {DISKIO_NREAD, ASN_COUNTER, RONLY, var_diskio, 1, {3}}, {DISKIO_NWRITTEN, ASN_COUNTER, RONLY, var_diskio, 1, {4}}, {DISKIO_READS, ASN_COUNTER, RONLY, var_diskio, 1, {5}}, {DISKIO_WRITES, ASN_COUNTER, RONLY, var_diskio, 1, {6}}, #if defined(freebsd4) || defined(freebsd5) {DISKIO_LA1, ASN_INTEGER, RONLY, var_diskio, 1, {9}}, {DISKIO_LA5, ASN_INTEGER, RONLY, var_diskio, 1, {10}}, {DISKIO_LA15, ASN_INTEGER, RONLY, var_diskio, 1, {11}}, #endif {DISKIO_NREADX, ASN_COUNTER64, RONLY, var_diskio, 1, {12}}, {DISKIO_NWRITTENX, ASN_COUNTER64, RONLY, var_diskio, 1, {13}}, }; /* * Define the OID pointer to the top of the mib tree that we're * registering underneath. */ oid diskio_variables_oid[] = { 1, 3, 6, 1, 4, 1, 2021, 13, 15, 1, 1 }; /* * register ourselves with the agent to handle our mib tree * * This is a macro defined in ../../snmp_vars.h. The arguments are: * * descr: A short description of the mib group being loaded. * var: The variable structure to load. * vartype: The variable structure used to define it (variable2, variable4, ...) * theoid: A *initialized* *exact length* oid pointer. * (sizeof(theoid) *must* return the number of elements!) */ REGISTER_MIB("diskio", diskio_variables, variable2, diskio_variables_oid); #ifdef solaris2 kc = kstat_open(); if (kc == NULL) snmp_log(LOG_ERR, "diskio: Couldn't open kstat\n"); #endif #ifdef darwin /* * Get the I/O Kit communication handle. */ IOMasterPort(bootstrap_port, &masterPort); #endif #if defined(aix4) || defined(aix5) || defined(aix6) /* * initialize values to gather information on first request */ ps_numdisks = 0; ps_disk = NULL; #endif #if defined (freebsd4) || defined(freebsd5) devla_getstats(0, NULL); /* collect LA data regularly */ snmp_alarm_register(DISKIO_SAMPLE_INTERVAL, SA_REPEAT, devla_getstats, NULL); #endif }
void init_diskio(void) { /* * Define a 'variable' structure that is a representation of our mib. */ /* * first, we have to pick the variable type. They are all defined in * the var_struct.h file in the agent subdirectory. I'm picking the * variable2 structure since the longest sub-component of the oid I * want to load is .2.1 and .2.2 so I need at most 2 spaces in the * last entry. */ struct variable2 diskio_variables[] = { {DISKIO_INDEX, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {1}}, {DISKIO_DEVICE, ASN_OCTET_STR, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {2}}, {DISKIO_NREAD, ASN_COUNTER, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {3}}, {DISKIO_NWRITTEN, ASN_COUNTER, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {4}}, {DISKIO_READS, ASN_COUNTER, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {5}}, {DISKIO_WRITES, ASN_COUNTER, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {6}}, #if defined(HAVE_GETDEVS) || defined(HAVE_DEVSTAT_GETDEVS) || defined(linux) {DISKIO_LA1, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {9}}, {DISKIO_LA5, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {10}}, {DISKIO_LA15, ASN_INTEGER, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {11}}, #endif {DISKIO_NREADX, ASN_COUNTER64, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {12}}, {DISKIO_NWRITTENX, ASN_COUNTER64, NETSNMP_OLDAPI_RONLY, var_diskio, 1, {13}}, }; /* * Define the OID pointer to the top of the mib tree that we're * registering underneath. */ oid diskio_variables_oid[] = { 1, 3, 6, 1, 4, 1, 2021, 13, 15, 1, 1 }; /* * register ourselves with the agent to handle our mib tree * * This is a macro defined in ../../snmp_vars.h. The arguments are: * * descr: A short description of the mib group being loaded. * var: The variable structure to load. * vartype: The variable structure used to define it (variable2, variable4, ...) * theoid: A *initialized* *exact length* oid pointer. * (sizeof(theoid) *must* return the number of elements!) */ REGISTER_MIB("diskio", diskio_variables, variable2, diskio_variables_oid); #ifdef solaris2 kc = kstat_open(); if (kc == NULL) snmp_log(LOG_ERR, "diskio: Couldn't open kstat\n"); #endif #ifdef darwin /* * Get the I/O Kit communication handle. */ IOMasterPort(bootstrap_port, &masterPort); #endif #if defined(aix4) || defined(aix5) || defined(aix6) || defined(aix7) /* * initialize values to gather information on first request */ ps_numdisks = 0; ps_disk = NULL; #endif #if defined (HAVE_GETDEVS) || defined(HAVE_DEVSTAT_GETDEVS) || defined(linux) devla_getstats(0, NULL); /* collect LA data regularly */ snmp_alarm_register(DISKIO_SAMPLE_INTERVAL, SA_REPEAT, devla_getstats, NULL); #endif #ifdef linux char *app = netsnmp_ds_get_string(NETSNMP_DS_LIBRARY_ID, NETSNMP_DS_LIB_APPTYPE); netsnmp_ds_register_config(ASN_BOOLEAN, app, "diskio_exclude_fd", NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_DISKIO_NO_FD); netsnmp_ds_register_config(ASN_BOOLEAN, app, "diskio_exclude_loop", NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_DISKIO_NO_LOOP); netsnmp_ds_register_config(ASN_BOOLEAN, app, "diskio_exclude_ram", NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_DISKIO_NO_RAM); /* or possible an exclusion pattern? */ snmp_register_callback(SNMP_CALLBACK_APPLICATION, SNMPD_CALLBACK_PRE_UPDATE_CONFIG, diskio_free_config, NULL); #endif }