diff --git a/smmapdfw/config.h.in b/smmapdfw/config.h.in index 28b62e6..c39c328 100644 --- a/smmapdfw/config.h.in +++ b/smmapdfw/config.h.in @@ -1,5 +1,8 @@ /* config.h.in. Generated from configure.ac by autoheader. */ +/* enable stats */ +#undef ENABLE_STATS + /* enable verify cache */ #undef ENABLE_VERIFY_CACHE @@ -48,6 +51,9 @@ /* Define to 1 if you have the `resolv' library (-lresolv). */ #undef HAVE_LIBRESOLV +/* have libsnmp */ +#undef HAVE_LIBSNMP + /* Define to 1 if you have the `socket' library (-lsocket). */ #undef HAVE_LIBSOCKET diff --git a/smmapdfw/configure b/smmapdfw/configure index ba17d0a..62fbfa7 100755 --- a/smmapdfw/configure +++ b/smmapdfw/configure @@ -1028,6 +1028,7 @@ Optional Features: --enable-FEATURE[=ARG] include FEATURE [ARG=yes] --enable-maintainer-mode enable make rules and dependencies not useful (and sometimes confusing) to the casual installer + --enable-stats Enables statistics collection. (default=no) --enable-shared[=PKGS] build shared libraries [default=yes] --enable-static[=PKGS] @@ -1043,6 +1044,8 @@ Optional Packages: --with-bdb-inc-dir Directory for Berkeley include files --with-djbdns-lib-dir Directory for Bernstein's djbdns library files --with-djbdns-inc-dir Directory for Bernstein's djbdns include files + --with-netsnmp-lib-dir Directory for Net-SNMP library files + --with-netsnmp-inc-dir Directory for Net-SNMP include files --with-gnu-ld assume the C compiler uses GNU ld [default=no] --with-pic try to use only PIC/non-PIC objects [default=use both] @@ -1917,14 +1920,57 @@ if test "${with_djbdns_inc_dir+set}" = set; then fi; +WITHOUT_NETSNMP=0 + +# Check whether --with-netsnmp-lib-dir or --without-netsnmp-lib-dir was given. +if test "${with_netsnmp_lib_dir+set}" = set; then + withval="$with_netsnmp_lib_dir" + case "$withval" in + no) + WITHOUT_NETSNMP=1 + ;; + yes) + ;; + *) + LDFLAGS="$LDFLAGS -L$withval -R$withval" + ;; + esac + +fi; + + +# Check whether --with-netsnmp-inc-dir or --without-netsnmp-inc-dir was given. +if test "${with_netsnmp_inc_dir+set}" = set; then + withval="$with_netsnmp_inc_dir" + case "$withval" in + no) + WITHOUT_NETSNMP=1 + ;; + yes) + ;; + *) + CPPFLAGS="$CPPFLAGS -I$withval" + ;; + esac + +fi; + ENABLE_VERIFY_CACHE=1 +ENABLE_STATS=0 +# Check whether --enable-stats or --disable-stats was given. +if test "${enable_stats+set}" = set; then + enableval="$enable_stats" + if test "x$enableval" = xyes; then ENABLE_STATS=1; fi + if test "x$enableval" = xno; then ENABLE_STATS=0; fi +fi; + # Checks for programs. ac_ext=c ac_cpp='$CPP $CPPFLAGS' @@ -3449,7 +3495,7 @@ ia64-*-hpux*) ;; *-*-irix6*) # Find out which ABI we are using. - echo '#line 3452 "configure"' > conftest.$ac_ext + echo '#line 3498 "configure"' > conftest.$ac_ext if { (eval echo "$as_me:$LINENO: \"$ac_compile\"") >&5 (eval $ac_compile) 2>&5 ac_status=$? @@ -4904,7 +4950,7 @@ fi # Provide some information about the compiler. -echo "$as_me:4907:" \ +echo "$as_me:4953:" \ "checking for Fortran 77 compiler version" >&5 ac_compiler=`set X $ac_compile; echo $2` { (eval echo "$as_me:$LINENO: \"$ac_compiler --version &5\"") >&5 @@ -5936,11 +5982,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:5939: $lt_compile\"" >&5) + (eval echo "\"\$as_me:5985: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:5943: \$? = $ac_status" >&5 + echo "$as_me:5989: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6169,11 +6215,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6172: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6218: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:6176: \$? = $ac_status" >&5 + echo "$as_me:6222: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -6229,11 +6275,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:6232: $lt_compile\"" >&5) + (eval echo "\"\$as_me:6278: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:6236: \$? = $ac_status" >&5 + echo "$as_me:6282: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -8417,7 +8463,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:10741: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:10699: \$? = $ac_status" >&5 + echo "$as_me:10745: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -10752,11 +10798,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:10755: $lt_compile\"" >&5) + (eval echo "\"\$as_me:10801: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:10759: \$? = $ac_status" >&5 + echo "$as_me:10805: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -12121,7 +12167,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <&5) + (eval echo "\"\$as_me:13095: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:13053: \$? = $ac_status" >&5 + echo "$as_me:13099: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -13106,11 +13152,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:13109: $lt_compile\"" >&5) + (eval echo "\"\$as_me:13155: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:13113: \$? = $ac_status" >&5 + echo "$as_me:13159: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -15151,11 +15197,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15154: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15200: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15158: \$? = $ac_status" >&5 + echo "$as_me:15204: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -15384,11 +15430,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15387: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15433: $lt_compile\"" >&5) (eval "$lt_compile" 2>conftest.err) ac_status=$? cat conftest.err >&5 - echo "$as_me:15391: \$? = $ac_status" >&5 + echo "$as_me:15437: \$? = $ac_status" >&5 if (exit $ac_status) && test -s "$ac_outfile"; then # The compiler can only warn and ignore the option if not recognized # So say no if there are warnings @@ -15444,11 +15490,11 @@ else -e 's:.*FLAGS}? :&$lt_compiler_flag :; t' \ -e 's: [^ ]*conftest\.: $lt_compiler_flag&:; t' \ -e 's:$: $lt_compiler_flag:'` - (eval echo "\"\$as_me:15447: $lt_compile\"" >&5) + (eval echo "\"\$as_me:15493: $lt_compile\"" >&5) (eval "$lt_compile" 2>out/conftest.err) ac_status=$? cat out/conftest.err >&5 - echo "$as_me:15451: \$? = $ac_status" >&5 + echo "$as_me:15497: \$? = $ac_status" >&5 if (exit $ac_status) && test -s out/conftest2.$ac_objext then # The compiler can only warn and ignore the option if not recognized @@ -17632,7 +17678,7 @@ else lt_dlunknown=0; lt_dlno_uscore=1; lt_dlneed_uscore=2 lt_status=$lt_dlunknown cat > conftest.$ac_ext < conftest.$ac_ext <>confdefs.h <<_ACEOF _ACEOF +cat >>confdefs.h <<_ACEOF +#define ENABLE_STATS ${ENABLE_STATS} +_ACEOF + + +cat >>confdefs.h <<_ACEOF +#define HAVE_LIBSNMP ${HAVE_LIBSNMP} +_ACEOF + + diff --git a/smmapdfw/configure.ac b/smmapdfw/configure.ac index 4ac0b0c..73aefc3 100644 --- a/smmapdfw/configure.ac +++ b/smmapdfw/configure.ac @@ -75,6 +75,37 @@ AC_ARG_WITH(djbdns-inc-dir, esac ] ) +WITHOUT_NETSNMP=0 +AC_ARG_WITH(netsnmp-lib-dir, + [AC_HELP_STRING(--with-netsnmp-lib-dir, [ + Directory for Net-SNMP library files])], + [ case "$withval" in + no) + WITHOUT_NETSNMP=1 + ;; + yes) + ;; + *) + LDFLAGS="$LDFLAGS -L$withval -R$withval" + ;; + esac ] +) + +AC_ARG_WITH(netsnmp-inc-dir, + [AC_HELP_STRING(--with-netsnmp-inc-dir, [ + Directory for Net-SNMP include files])], + [ case "$withval" in + no) + WITHOUT_NETSNMP=1 + ;; + yes) + ;; + *) + CPPFLAGS="$CPPFLAGS -I$withval" + ;; + esac ] +) + ENABLE_VERIFY_CACHE=1 dnl AC_ARG_ENABLE(verify-cache, @@ -110,7 +141,15 @@ dnl (default=no)])], dnl cyrus_BUILD=libcyrus_worker.la dnl ) +ENABLE_STATS=0 +AC_ARG_ENABLE(stats, + [AC_HELP_STRING(--enable-stats, [ + Enables statistics collection. + (default=no)])], + if test "x$enableval" = xyes; then ENABLE_STATS=1; fi + if test "x$enableval" = xno; then ENABLE_STATS=0; fi +) # Checks for programs. AC_PROG_CC @@ -138,6 +177,12 @@ if test "x$WITHOUT_DJBDNS" = "x0"; then AC_CHECK_LIB([djbdns], [dns_transmit_start]) fi +if test "x$WITHOUT_NETSNMP" = "x0"; then +NETSNMP_LIBS=`net-snmp-config --netsnmp-agent-libs` +LIBS="$LIBS $NETSNMP_LIBS" +HAVE_LIBSNMP=1 +fi + # Checks for header files. @@ -189,6 +234,8 @@ if test "x$BDB_NOT_FOUND" = "x1"; then fi AC_DEFINE_UNQUOTED(ENABLE_VERIFY_CACHE, ${ENABLE_VERIFY_CACHE}, [enable verify cache]) +AC_DEFINE_UNQUOTED(ENABLE_STATS, ${ENABLE_STATS}, [enable stats]) +AC_DEFINE_UNQUOTED(HAVE_LIBSNMP, ${HAVE_LIBSNMP}, [have libsnmp]) diff --git a/smmapdfw/libsmmapdfw/Makefile.in b/smmapdfw/libsmmapdfw/Makefile.in index 215be5d..afa3ee2 100644 --- a/smmapdfw/libsmmapdfw/Makefile.in +++ b/smmapdfw/libsmmapdfw/Makefile.in @@ -87,9 +87,9 @@ RC = @RC@ STRIP = @STRIP@ VERSION = @VERSION@ -include_HEADERS = containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h htmalloc.h +include_HEADERS = containers_public.h queue.h smtp.h cfg.h count.h safe_write.h sunos_comp.h htdns.h smmapd.h htmalloc.h stats.h lib_LTLIBRARIES = libsmmapdfw.la -libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c +libsmmapdfw_la_SOURCES = cfg.c queue.c count.c safe_write.c config_public.c htdns.c smtp.c htmalloc.c stats.c mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs CONFIG_HEADER = ../config.h CONFIG_CLEAN_FILES = @@ -103,7 +103,7 @@ LIBS = @LIBS@ libsmmapdfw_la_LDFLAGS = libsmmapdfw_la_LIBADD = libsmmapdfw_la_OBJECTS = cfg.lo queue.lo count.lo safe_write.lo \ -config_public.lo htdns.lo smtp.lo htmalloc.lo +config_public.lo htdns.lo smtp.lo htmalloc.lo stats.lo CFLAGS = @CFLAGS@ COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS) @@ -120,7 +120,7 @@ TAR = tar GZIP_ENV = --best DEP_FILES = .deps/cfg.P .deps/config_public.P .deps/count.P \ .deps/htdns.P .deps/htmalloc.P .deps/queue.P .deps/safe_write.P \ -.deps/smtp.P +.deps/smtp.P .deps/stats.P SOURCES = $(libsmmapdfw_la_SOURCES) OBJECTS = $(libsmmapdfw_la_OBJECTS) diff --git a/smmapdfw/libsmmapdfw/stats.c b/smmapdfw/libsmmapdfw/stats.c index 78f1a8c..a50b25e 100644 --- a/smmapdfw/libsmmapdfw/stats.c +++ b/smmapdfw/libsmmapdfw/stats.c @@ -21,26 +21,67 @@ #include +#include "config.h" + +#define _STATS_C_ #include "stats.h" -count_t statCounter[STAT_CNT_MAXNUM]; +#include "count.h" +#if ENABLE_STATS==1 +count_t statCounter[STAT_CNT_MAXNUM]; +#endif + void initStatCounter() { +#if ENABLE_STATS==1 int i; for (i=0; i= 0) && (cnt_idx < STAT_CNT_MAXNUM)); return count_get(&statCounter[cnt_idx]); +#else + return 0; +#endif } void incStatCounter(int cnt_idx) { +#if ENABLE_STATS==1 assert((cnt_idx >= 0) && (cnt_idx < STAT_CNT_MAXNUM)); count_inc(&statCounter[cnt_idx]); +#endif } +void decStatCounter(int cnt_idx) { +#if ENABLE_STATS==1 + assert((cnt_idx >= 0) && (cnt_idx < STAT_CNT_MAXNUM)); + count_dec(&statCounter[cnt_idx]); +#endif +} + +void outputStats(int nice) { +#if ENABLE_STATS==1 + int i; + + if (nice) + printf("---------------------------------------------------------\n"); + + for (i=0; iclientSock, inet_ntoa(t->clientAddr.sin_addr), @@ -181,6 +208,8 @@ void * networker(void * arg) { syslog(LOG_DEBUG, "networker: dispatcher result: %d, answer: %s", dispatcher_result, answer); } + incStatCounter(dispatcher_result + STAT_CNT_OFFSET); + result_text = (dispatcher_result > SMM_MAX_NUM) ? T_SMM_RESULTS[0] : T_SMM_RESULTS[dispatcher_result]; @@ -222,7 +251,9 @@ int server() { networkerThread_t *thread; pthread_t tid; int optval = 1; - + int enableStats; + int enableSnmp; + char *cfg_address, *cfg_port; serverSock = socket(AF_INET, SOCK_STREAM, 0); @@ -266,6 +297,21 @@ int server() { queue_init(&terminated_networker_queue); pthread_create(&cleanerThread, NULL, &cleaner, NULL); +#if ENABLE_STATS==1 + enableStats = atoi(findcfgx(cfg, "global", "enable_stats", "0")); + if (enableStats) { + syslog(LOG_INFO, "server: starting stats thread"); + pthread_create(&statsThread, NULL, &statser, NULL); + } +#endif /* ENABLE_STATS */ + +#if HAVE_LIBSNMP==1 + enableSnmp = atoi(findcfgx(cfg, "global", "enable_snmp", "0")); + if (enableSnmp) { + syslog(LOG_INFO, "server: starting snmp subagent thread"); + pthread_create(&snmpThread, NULL, &snmper, NULL); + } +#endif /* HAVE_LIBSNMP */ while (1) { syslog(LOG_DEBUG, "server: Waiting for connection"); @@ -274,11 +320,13 @@ int server() { syslog(LOG_DEBUG, "server: Got a connection %d", clientSock); if (-1 == clientSock) { + incStatCounter(STAT_CNT_FAILED); syslog(LOG_ERR, "server: failure when accepting connection: %d, %s", errno, strerror(errno)); continue; } + incStatCounter(STAT_CNT_ACCEPTED); thread = (networkerThread_t *) htmalloc(sizeof(networkerThread_t)+10); if (NULL == thread) { @@ -293,10 +341,13 @@ int server() { thread->clientAddrLen = clientAddrLen; count_inc(&thread_counter); + incStatCounter(STAT_CNT_NETWORKER_THREADS); res = pthread_create(&tid, NULL, &networker, thread); if (0 != res) { syslog(LOG_ERR, "server: unable to start networker thread"); free(thread); + decStatCounter(STAT_CNT_NETWORKER_THREADS); + incStatCounter(STAT_CNT_NETWORKER_THREADS_FAILED); count_dec(&thread_counter); continue; } diff --git a/smmapdfw/smmapd/smmapd.ini b/smmapdfw/smmapd/smmapd.ini index c7dc076..2427ff5 100644 --- a/smmapdfw/smmapd/smmapd.ini +++ b/smmapdfw/smmapd/smmapd.ini @@ -6,6 +6,15 @@ port = 8887 ; plugin_dir = /home/who/Sources/sf/smmapdfw ; plugins = test_worker1 test_worker2 verifier cyruscheck lua_worker plugins = verifier +enable_stats = 1 +; enable_snmp = 0 + +[snmp] + +[stats] +nice = 1 +period = 5 + [test_worker1] obj = libtest_workers.so diff --git a/smmapdfw/smmapd/snmp_subagent.c b/smmapdfw/smmapd/snmp_subagent.c new file mode 100644 index 0000000..4960daa --- /dev/null +++ b/smmapdfw/smmapd/snmp_subagent.c @@ -0,0 +1,164 @@ +#include "config.h" + +#ifdef HAVE_LIBSNMP +#include +#include +#include + +int +handle_it(netsnmp_mib_handler *handler, + netsnmp_handler_registration *reginfo, + netsnmp_agent_request_info *reqinfo, + netsnmp_request_info *requests) +{ + static int the_number = 42; + + /* + * We are never called for a GETNEXT if it's registered as a + * "instance", as it's "magically" handled for us. + */ + + /* + * a instance handler also only hands us one request at a time, so + * we don't need to loop over a list of requests; we'll only get one. + */ + + switch (reqinfo->mode) { + + case MODE_GET: + snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER, + (u_char *) + /* XXX: a pointer to the scalar's data */ + &the_number + , + /* + * XXX: the length of the data in bytes + */ + sizeof(the_number)); + break; + + + default: + /* + * we should never get here, so this is a really bad error + */ + return SNMP_ERR_GENERR; + } + + return SNMP_ERR_NOERROR; +} + + + +void +init_subagent(void) +{ + static oid dhsIllegalInputFailure_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 9 }; + static oid dhsOKReturned_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 5 }; + static oid dhsTEMPReturned_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 6 }; + static oid dhsNetStringFailure_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 12 }; + static oid dhsRunningNwThreads_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 3 }; + static oid dhsFailedNwThreads_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 4 }; + static oid dhsUnknownClassFailure_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 10 }; + static oid dhsFailed_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 2 }; + static oid dhsNOTFOUNDReturned_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 8 }; + static oid dhsAccepted_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 1 }; + static oid dhsPERMReturned_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 7 }; + static oid dhsTimeoutFailure_oid[] = + { 1, 3, 6, 1, 4, 1, 9676, 2, 1, 1, 11 }; + + DEBUGMSGTL(("smmapd_snmp_subagent", "Initializing\n")); + + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsIllegalInputFailure", + handle_it, + dhsIllegalInputFailure_oid, + OID_LENGTH(dhsIllegalInputFailure_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsOKReturned", handle_it, + dhsOKReturned_oid, + OID_LENGTH(dhsOKReturned_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsTEMPReturned", handle_it, + dhsTEMPReturned_oid, + OID_LENGTH(dhsTEMPReturned_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsNetStringFailure", + handle_it, + dhsNetStringFailure_oid, + OID_LENGTH(dhsNetStringFailure_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsRunningNwThreads", + handle_it, + dhsRunningNwThreads_oid, + OID_LENGTH(dhsRunningNwThreads_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsFailedNwThreads", + handle_it, + dhsFailedNwThreads_oid, + OID_LENGTH(dhsFailedNwThreads_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsUnknownClassFailure", + handle_it, + dhsUnknownClassFailure_oid, + OID_LENGTH(dhsUnknownClassFailure_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsFailed", handle_it, dhsFailed_oid, + OID_LENGTH(dhsFailed_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsNOTFOUNDReturned", + handle_it, + dhsNOTFOUNDReturned_oid, + OID_LENGTH(dhsNOTFOUNDReturned_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsAccepted", handle_it, + dhsAccepted_oid, OID_LENGTH(dhsAccepted_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsPERMReturned", handle_it, + dhsPERMReturned_oid, + OID_LENGTH(dhsPERMReturned_oid), + HANDLER_CAN_RONLY)); + netsnmp_register_scalar(netsnmp_create_handler_registration + ("dhsTimeoutFailure", handle_it, + dhsTimeoutFailure_oid, + OID_LENGTH(dhsTimeoutFailure_oid), + HANDLER_CAN_RONLY)); +} + +void snmp_subagent_main () { + snmp_enable_stderrlog(); + netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1); + init_agent("smmapd_subagent"); + init_subagent(); + init_snmp("smmapd_subagent"); + + /* main loop here... */ + while(1) { + agent_check_and_process(1); + } + + /* at shutdown time */ + snmp_shutdown("mysubagent"); +} +#endif diff --git a/smmapdfw/smmapd/snmp_subagent.h b/smmapdfw/smmapd/snmp_subagent.h new file mode 100644 index 0000000..0dced41 --- /dev/null +++ b/smmapdfw/smmapd/snmp_subagent.h @@ -0,0 +1,34 @@ +/* + Copyright (C) 2004, Wolfgang Hottgenroth + + This file is part of smmapdfw. + + smmapdfw is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + smmapdfw is distributed in the hope that it will be useful, but WITHOUT + ANY WARRANTY; without even the implied warranty of MERCHANTABILITY + or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public + License for more details. + + You should have received a copy of the GNU General Public License + along with smmapdfw. If not, write to the Free Software Foundation, 59 + Temple Place - Suite 330, Boston, MA 02111-1307, USA. +*/ + + + +#ifndef _SNMP_SUBAGENT_H_ +#define _SNMP_SUBAGENT_H_ + +#include "config.h" + +#ifdef HAVE_LIBSNMP +void snmp_subagent_main(); +#endif + +#endif /* _SNMP_SUBAGENT_H_ */ + +