diff --git a/Makefile b/Makefile index 545c3fc..5ca2ab4 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,5 @@ PROG= subagent_ntpd -SRCS= subagent_ntpd.c log.c +SRCS= subagent_ntpd.c mib.c log.c MAN= CFLAGS+= -Wall -I${.CURDIR} diff --git a/mib.c b/mib.c new file mode 100644 index 0000000..f755f7b --- /dev/null +++ b/mib.c @@ -0,0 +1,22 @@ +#include "mib.h" +#include "log.h" + + +static void mib_hottisntpdcounter(struct agentx_varbind *vb) { + long long ticks = 200169; + + agentx_varbind_counter64(vb, ticks); +} + +void mib_register(struct agentx_context *sac) { + struct agentx_region *hottis; + struct agentx_object *hottisNtpdCounter; + + if ((hottis = agentx_region(sac, AGENTX_OID(HOTTIS_MIB), 0)) == NULL) + fatal("agentx_region"); + + if ((hottisNtpdCounter = agentx_object(hottis, AGENTX_OID(HOTTIS_NTPD_COUNTER), + NULL, 0, 0, mib_hottisntpdcounter)) == NULL) + fatal("agentx_object"); +} + diff --git a/mib.h b/mib.h index 5a81e2a..cad6fef 100644 --- a/mib.h +++ b/mib.h @@ -17,9 +17,17 @@ * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ + +#ifndef _MIB_H_ +#define _MIB_H_ + #include +void mib_register(struct agentx_context *sac); + #define ENTERPRISE_MIB 1,3,6,1,4,1 #define HOTTIS_MIB ENTERPRISE_MIB, 9676 #define HOTTIS_NTPD HOTTIS_MIB, 1 #define HOTTIS_NTPD_COUNTER HOTTIS_NTPD, 1 + +#endif // _MIB_H_ diff --git a/subagent_ntpd.c b/subagent_ntpd.c index 030bf95..3390ea5 100644 --- a/subagent_ntpd.c +++ b/subagent_ntpd.c @@ -35,6 +35,7 @@ #include #include #include +// #include MUST BE INCLUDED ONLY ONCE, WILL BE INCLUDED IN mib.h #include "mib.h" #include "log.h" @@ -45,24 +46,6 @@ void snmp_tryconnect(int, short, void *); void snmp_read(int, short, void *); -static void mib_hottisntpdcounter(struct agentx_varbind *vb) { - long long ticks = 200169; - - agentx_varbind_counter64(vb, ticks); -} - -static void mib_register(struct agentx_context *sac) { - struct agentx_region *hottis; - struct agentx_object *hottisNtpdCounter; - - if ((hottis = agentx_region(sac, AGENTX_OID(HOTTIS_MIB), 0)) == NULL) - fatal("agentx_region"); - - if ((hottisNtpdCounter = agentx_object(hottis, AGENTX_OID(HOTTIS_NTPD_COUNTER), - NULL, 0, 0, mib_hottisntpdcounter)) == NULL) - fatal("agentx_object"); -} - int main(int argc, char *argv[]) {