several changes in statistics, fix in verifier
This commit is contained in:
parent
75734d2899
commit
47ff192c6a
@ -1,3 +1,3 @@
|
|||||||
SUBDIRS = libsmmapdfw smmapd verify_worker test_worker cyrus_worker doc m4 mib
|
SUBDIRS = libsmmapdfw smmapd verify_worker test_worker cyrus_worker doc m4
|
||||||
|
|
||||||
|
|
||||||
|
@ -87,7 +87,7 @@ RC = @RC@
|
|||||||
STRIP = @STRIP@
|
STRIP = @STRIP@
|
||||||
VERSION = @VERSION@
|
VERSION = @VERSION@
|
||||||
|
|
||||||
SUBDIRS = libsmmapdfw smmapd verify_worker test_worker cyrus_worker doc m4 mib
|
SUBDIRS = libsmmapdfw smmapd verify_worker test_worker cyrus_worker doc m4
|
||||||
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
|
||||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
||||||
CONFIG_HEADER = config.h
|
CONFIG_HEADER = config.h
|
||||||
|
@ -179,3 +179,5 @@
|
|||||||
|
|
||||||
/* Define as `fork' if `vfork' does not work. */
|
/* Define as `fork' if `vfork' does not work. */
|
||||||
#undef vfork
|
#undef vfork
|
||||||
|
|
||||||
|
|
||||||
|
8428
smmapdfw/configure
vendored
8428
smmapdfw/configure
vendored
File diff suppressed because it is too large
Load Diff
@ -36,9 +36,27 @@
|
|||||||
#define SMM_LOCAL_OK 103
|
#define SMM_LOCAL_OK 103
|
||||||
|
|
||||||
|
|
||||||
|
counterDef_t *cyrus_counterDefs = NULL;
|
||||||
|
void cyrus_setupCounterList() {
|
||||||
|
cyrus_counterDefs = addOneCounterDef(cyrus_counterDefs, SMM_TYPE_COUNTER, "Cyrus: checker");
|
||||||
|
cyrus_counterDefs = addOneCounterDef(cyrus_counterDefs, SMM_TYPE_COUNTER, "Cyrus: illegal input");
|
||||||
|
cyrus_counterDefs = addOneCounterDef(cyrus_counterDefs, SMM_TYPE_COUNTER, "Cyrus: depot dns failure");
|
||||||
|
cyrus_counterDefs = addOneCounterDef(cyrus_counterDefs, SMM_TYPE_COUNTER, "Cyrus: returned OK");
|
||||||
|
cyrus_counterDefs = addOneCounterDef(cyrus_counterDefs, SMM_TYPE_COUNTER, "Cyrus: returned NOK");
|
||||||
|
cyrus_counterDefs = addOneCounterDef(cyrus_counterDefs, SMM_TYPE_COUNTER, "Cyrus: returned TNOK");
|
||||||
|
};
|
||||||
|
|
||||||
|
#define STAT_CNT_CYRUS_WORKER 0
|
||||||
|
#define STAT_CNT_CYRUS_ILLEGAL_INPUT 1
|
||||||
|
#define STAT_CNT_CYRUS_DEPOT_DNS_FAILURE 2
|
||||||
|
#define STAT_CNT_CYRUS_RETURNED_OK 3
|
||||||
|
#define STAT_CNT_CYRUS_RETURNED_NOK 4
|
||||||
|
#define STAT_CNT_CYRUS_RETURNED_TNOK 5
|
||||||
|
|
||||||
|
|
||||||
struct cyrus_container_handle_s {
|
struct cyrus_container_handle_s {
|
||||||
cfgl_t *cfg;
|
cfgl_t *cfg;
|
||||||
|
statCounter_t *statCounter;
|
||||||
int timeout;
|
int timeout;
|
||||||
char *sender_address;
|
char *sender_address;
|
||||||
char *lhlo_arg;
|
char *lhlo_arg;
|
||||||
@ -86,6 +104,9 @@ int cyrus_init(cfgl_t *cfg, void **handle) {
|
|||||||
cch->lhlo_arg = findcfglx(cch->cfg, "lhlo_arg", "local");
|
cch->lhlo_arg = findcfglx(cch->cfg, "lhlo_arg", "local");
|
||||||
cch->lmtp_port = atoi(findcfglx(cch->cfg, "lmtp_port", "24"));
|
cch->lmtp_port = atoi(findcfglx(cch->cfg, "lmtp_port", "24"));
|
||||||
|
|
||||||
|
cyrus_setupCounterList();
|
||||||
|
cch->statCounter = initStatCounter("cyrus", cyrus_counterDefs);
|
||||||
|
|
||||||
*handle = cch;
|
*handle = cch;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -127,13 +148,13 @@ int cyrus_work(void *handle, void *work_handle, char *input, htbuffer_t *output)
|
|||||||
|
|
||||||
syslog(LOG_DEBUG, "cyrus_work: (%04x) going to check %s", log_id, input);
|
syslog(LOG_DEBUG, "cyrus_work: (%04x) going to check %s", log_id, input);
|
||||||
|
|
||||||
incStatCounter(STAT_CNT_CYRUS_WORKER);
|
incStatCounter(cch->statCounter, STAT_CNT_CYRUS_WORKER);
|
||||||
|
|
||||||
depot_uid = input;
|
depot_uid = input;
|
||||||
if (NULL == (depot_host = strchr(depot_uid, ' '))) {
|
if (NULL == (depot_host = strchr(depot_uid, ' '))) {
|
||||||
// snprintf(output, ANSWER_BUFSIZE, ILLEGAL_INPUT);
|
// snprintf(output, ANSWER_BUFSIZE, ILLEGAL_INPUT);
|
||||||
htbuffer_strcpy(output, ILLEGAL_INPUT);
|
htbuffer_strcpy(output, ILLEGAL_INPUT);
|
||||||
incStatCounter(STAT_CNT_CYRUS_ILLEGAL_INPUT);
|
incStatCounter(cch->statCounter, STAT_CNT_CYRUS_ILLEGAL_INPUT);
|
||||||
return SMM_PERM_NOK;
|
return SMM_PERM_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -147,7 +168,7 @@ int cyrus_work(void *handle, void *work_handle, char *input, htbuffer_t *output)
|
|||||||
log_id, depot_host);
|
log_id, depot_host);
|
||||||
// snprintf(output, ANSWER_BUFSIZE, DEPOT_DNS_ERROR);
|
// snprintf(output, ANSWER_BUFSIZE, DEPOT_DNS_ERROR);
|
||||||
htbuffer_strcpy(output, DEPOT_DNS_ERROR);
|
htbuffer_strcpy(output, DEPOT_DNS_ERROR);
|
||||||
incStatCounter(STAT_CNT_CYRUS_DEPOT_DNS_FAILURE);
|
incStatCounter(cch->statCounter, STAT_CNT_CYRUS_DEPOT_DNS_FAILURE);
|
||||||
return SMM_TEMP_NOK;
|
return SMM_TEMP_NOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -248,7 +269,7 @@ int cyrus_work(void *handle, void *work_handle, char *input, htbuffer_t *output)
|
|||||||
htbuffer_strcat(output, ">");
|
htbuffer_strcat(output, ">");
|
||||||
//snprintf(output, ANSWER_BUFSIZE, "<TNOK><%s>", response_text);
|
//snprintf(output, ANSWER_BUFSIZE, "<TNOK><%s>", response_text);
|
||||||
result = SMM_OK;
|
result = SMM_OK;
|
||||||
incStatCounter(STAT_CNT_CYRUS_RETURNED_TNOK);
|
incStatCounter(cch->statCounter, STAT_CNT_CYRUS_RETURNED_TNOK);
|
||||||
break;
|
break;
|
||||||
case SMM_LOCAL_PERM_NOK:
|
case SMM_LOCAL_PERM_NOK:
|
||||||
htbuffer_strcat(output, "<NOK><");
|
htbuffer_strcat(output, "<NOK><");
|
||||||
@ -256,7 +277,7 @@ int cyrus_work(void *handle, void *work_handle, char *input, htbuffer_t *output)
|
|||||||
htbuffer_strcat(output, ">");
|
htbuffer_strcat(output, ">");
|
||||||
//snprintf(output, ANSWER_BUFSIZE, "<NOK><%s>", response_text);
|
//snprintf(output, ANSWER_BUFSIZE, "<NOK><%s>", response_text);
|
||||||
result = SMM_OK;
|
result = SMM_OK;
|
||||||
incStatCounter(STAT_CNT_CYRUS_RETURNED_NOK);
|
incStatCounter(cch->statCounter, STAT_CNT_CYRUS_RETURNED_NOK);
|
||||||
break;
|
break;
|
||||||
case SMM_LOCAL_OK:
|
case SMM_LOCAL_OK:
|
||||||
htbuffer_strcat(output, "<OK><");
|
htbuffer_strcat(output, "<OK><");
|
||||||
@ -264,7 +285,7 @@ int cyrus_work(void *handle, void *work_handle, char *input, htbuffer_t *output)
|
|||||||
htbuffer_strcat(output, ">");
|
htbuffer_strcat(output, ">");
|
||||||
//snprintf(output, ANSWER_BUFSIZE, "<OK><%s>", response_text);
|
//snprintf(output, ANSWER_BUFSIZE, "<OK><%s>", response_text);
|
||||||
result = SMM_OK;
|
result = SMM_OK;
|
||||||
incStatCounter(STAT_CNT_CYRUS_RETURNED_OK);
|
incStatCounter(cch->statCounter, STAT_CNT_CYRUS_RETURNED_OK);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
htbuffer_strcpy(output, response_text);
|
htbuffer_strcpy(output, response_text);
|
||||||
|
@ -36,6 +36,8 @@
|
|||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
#include "htmalloc.h"
|
#include "htmalloc.h"
|
||||||
|
|
||||||
|
@ -84,7 +84,7 @@ htbuffer_t *htbuffer_memcpy_w_offset(htbuffer_t *dest, unsigned int offset, cons
|
|||||||
exit(154);
|
exit(154);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("htbuffer (%p) htbuffer_memcpy_w_offset: increase buffer from %d to %d\n",
|
syslog(LOG_INFO, "htbuffer (%p) htbuffer_memcpy_w_offset: increase buffer from %d to %d\n",
|
||||||
dest, dest->current_buf_size, new_buf_size);
|
dest, dest->current_buf_size, new_buf_size);
|
||||||
dest->buf = (char*) htrealloc(dest->buf, sizeof(char) * new_buf_size);
|
dest->buf = (char*) htrealloc(dest->buf, sizeof(char) * new_buf_size);
|
||||||
memset(dest->buf + dest->current_buf_size, 0, new_buf_size - dest->current_buf_size);
|
memset(dest->buf + dest->current_buf_size, 0, new_buf_size - dest->current_buf_size);
|
||||||
@ -96,6 +96,7 @@ htbuffer_t *htbuffer_memcpy_w_offset(htbuffer_t *dest, unsigned int offset, cons
|
|||||||
return dest;
|
return dest;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
htbuffer_t *htbuffer_clear(htbuffer_t *dest) {
|
htbuffer_t *htbuffer_clear(htbuffer_t *dest) {
|
||||||
memset(dest->buf, 0, dest->current_buf_size);
|
memset(dest->buf, 0, dest->current_buf_size);
|
||||||
return dest;
|
return dest;
|
||||||
|
@ -54,8 +54,6 @@ htbuffer_t *htbuffer_strcat(htbuffer_t *dest, const char *src);
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* _HTBUFFER_H_ */
|
#endif /* _HTBUFFER_H_ */
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <string.h>
|
||||||
#include "htmalloc.h"
|
#include "htmalloc.h"
|
||||||
|
|
||||||
|
|
||||||
|
@ -21,86 +21,129 @@
|
|||||||
|
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "cfg.h"
|
||||||
|
|
||||||
|
|
||||||
#define _STATS_C_
|
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
|
|
||||||
#include "count.h"
|
#include "count.h"
|
||||||
|
#include "htmalloc.h"
|
||||||
|
|
||||||
|
|
||||||
#if ENABLE_STATS==1
|
statCounterEntry_t *statCounterList = NULL;
|
||||||
count_t statCounter[STAT_CNT_MAXNUM];
|
unsigned int statCounterListLen = 0;
|
||||||
#endif
|
|
||||||
|
|
||||||
void initStatCounter() {
|
counterDef_t *addOneCounterDef(counterDef_t *counterDef, unsigned int type, const char* name) {
|
||||||
#if ENABLE_STATS==1
|
int counterCnt = 0;
|
||||||
int i;
|
if (counterDef != NULL) {
|
||||||
|
counterDef_t *curCounterDef;
|
||||||
for (i=0; i<STAT_CNT_MAXNUM; i++) {
|
for (curCounterDef = counterDef; curCounterDef->type != SMM_TYPE_NULL; curCounterDef++, counterCnt++);
|
||||||
count_init(&statCounter[i]);
|
|
||||||
}
|
}
|
||||||
#endif
|
counterDef_t *newCounterDef = (counterDef_t*) htrealloc(counterDef, sizeof(counterDef_t) * (counterCnt + 2));
|
||||||
|
(newCounterDef + counterCnt)->type = type;
|
||||||
|
(newCounterDef + counterCnt)->name = name;
|
||||||
|
(newCounterDef + counterCnt + 1)->type = SMM_TYPE_NULL;
|
||||||
|
(newCounterDef + counterCnt + 1)->name = NULL;
|
||||||
|
return newCounterDef;
|
||||||
}
|
}
|
||||||
|
|
||||||
unsigned int getStatCounter(int cnt_idx) {
|
statCounter_t *initStatCounter(const char *moduleName, counterDef_t *counterDefs) {
|
||||||
#if ENABLE_STATS==1
|
counterDef_t *curCounterDef;
|
||||||
assert((cnt_idx >= 0) && (cnt_idx < STAT_CNT_MAXNUM));
|
unsigned i = 0;
|
||||||
return count_get(&statCounter[cnt_idx]);
|
for (curCounterDef = counterDefs; curCounterDef->type != SMM_TYPE_NULL; curCounterDef++, i++);
|
||||||
#else
|
statCounter_t *statCounter = (statCounter_t*) htmalloc(sizeof(statCounter_t) * (i + 1));
|
||||||
|
statCounter_t *curStatCounter;
|
||||||
|
for (curCounterDef = counterDefs, curStatCounter = statCounter; curCounterDef->type != SMM_TYPE_NULL; curCounterDef++, curStatCounter++) {
|
||||||
|
curStatCounter->magic = STAT_COUNTER_MAGIC;
|
||||||
|
curStatCounter->counter = (count_t*) htmalloc(sizeof(count_t));
|
||||||
|
count_init(curStatCounter->counter);
|
||||||
|
}
|
||||||
|
curStatCounter->magic = STAT_COUNTER_MAGIC;
|
||||||
|
curStatCounter->counter = NULL;
|
||||||
|
|
||||||
|
|
||||||
|
statCounterList = (statCounterEntry_t*) htrealloc(statCounterList, sizeof(statCounterEntry_t) * (statCounterListLen + 1));
|
||||||
|
(statCounterList + statCounterListLen)->moduleName = moduleName;
|
||||||
|
(statCounterList + statCounterListLen)->counterDefs = counterDefs;
|
||||||
|
(statCounterList + statCounterListLen)->statCounters = statCounter;
|
||||||
|
statCounterListLen++;
|
||||||
|
|
||||||
|
return statCounter;
|
||||||
|
}
|
||||||
|
|
||||||
|
unsigned int getStatCounter(statCounter_t *statCounter, int cnt_idx) {
|
||||||
|
statCounter_t *curStatCounter = statCounter + cnt_idx;
|
||||||
|
if (curStatCounter == NULL || curStatCounter->magic != STAT_COUNTER_MAGIC) {
|
||||||
|
syslog(LOG_CRIT, "STAT_COUNTER_MAGIC not matching in getStatCounter!!!");
|
||||||
return 0;
|
return 0;
|
||||||
#endif
|
} else {
|
||||||
|
return count_get(curStatCounter->counter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void incStatCounter(int cnt_idx) {
|
void incStatCounter(statCounter_t *statCounter, int cnt_idx) {
|
||||||
#if ENABLE_STATS==1
|
statCounter_t *curStatCounter = statCounter + cnt_idx;
|
||||||
assert((cnt_idx >= 0) && (cnt_idx < STAT_CNT_MAXNUM));
|
if (curStatCounter == NULL || curStatCounter->magic != STAT_COUNTER_MAGIC) {
|
||||||
count_inc(&statCounter[cnt_idx]);
|
syslog(LOG_CRIT, "STAT_COUNTER_MAGIC not matching in incStatCounter!!!");
|
||||||
#endif
|
} else {
|
||||||
|
count_inc(curStatCounter->counter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void decStatCounter(int cnt_idx) {
|
void decStatCounter(statCounter_t *statCounter, int cnt_idx) {
|
||||||
#if ENABLE_STATS==1
|
statCounter_t *curStatCounter = statCounter + cnt_idx;
|
||||||
assert((cnt_idx >= 0) && (cnt_idx < STAT_CNT_MAXNUM));
|
if (curStatCounter == NULL || curStatCounter->magic != STAT_COUNTER_MAGIC) {
|
||||||
count_dec(&statCounter[cnt_idx]);
|
syslog(LOG_CRIT, "STAT_COUNTER_MAGIC not matching in decStatCounter!!!");
|
||||||
#endif
|
} else {
|
||||||
|
count_dec(curStatCounter->counter);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define SYSLOG_BUF_SIZE 1024
|
||||||
void outputStats(int stdout_nice, int syslog_nice) {
|
void outputStats(int stdout_nice, int syslog_nice) {
|
||||||
#if ENABLE_STATS==1
|
char syslogBuf[SYSLOG_BUF_SIZE];
|
||||||
char buf[1024];
|
int remainsSyslogBufLen = SYSLOG_BUF_SIZE - 1;
|
||||||
char buf2[64];
|
|
||||||
int i, v;
|
|
||||||
|
|
||||||
*buf = '\0';
|
statCounterEntry_t *curStatCounterEntry;
|
||||||
*buf2 = '\0';
|
unsigned int i;
|
||||||
|
for (curStatCounterEntry = statCounterList, i = 0; i < statCounterListLen; curStatCounterEntry++, i++) {
|
||||||
strcat(buf, "Stats: ");
|
if (stdout_nice == 1)
|
||||||
|
printf("%s: ", curStatCounterEntry->moduleName);
|
||||||
if (2 == stdout_nice)
|
else if (stdout_nice == 2)
|
||||||
printf("---------------------------------------------------------\n");
|
printf("moduleName: %s\n", curStatCounterEntry->moduleName);
|
||||||
|
if (syslog_nice == 1) {
|
||||||
for (i=1; i<STAT_CNT_MAXNUM; i++) {
|
snprintf(syslogBuf, remainsSyslogBufLen, "%s: ", curStatCounterEntry->moduleName);
|
||||||
v = getStatCounter(i);
|
remainsSyslogBufLen -= strlen(syslogBuf);
|
||||||
if (2 == stdout_nice)
|
} else if (syslog_nice == 2) {
|
||||||
printf("%44s = %5d\n", stat_cnt_names[i], v);
|
snprintf(syslogBuf, remainsSyslogBufLen, "moduleName: %s\n", curStatCounterEntry->moduleName);
|
||||||
if (2 == syslog_nice)
|
remainsSyslogBufLen -= strlen(syslogBuf);
|
||||||
syslog(LOG_DEBUG, "%44s = %5d\n", stat_cnt_names[i], v);
|
}
|
||||||
if ((1 == stdout_nice) || (1 == syslog_nice)) {
|
statCounter_t *curStatCounter;
|
||||||
sprintf(buf2, "%d ", v);
|
counterDef_t *curCounterDef;
|
||||||
strcat(buf, buf2);
|
for (curStatCounter = curStatCounterEntry->statCounters, curCounterDef = curStatCounterEntry->counterDefs;
|
||||||
|
curStatCounter->counter != NULL;
|
||||||
|
curStatCounter++, curCounterDef++) {
|
||||||
|
if (stdout_nice == 1)
|
||||||
|
printf("%d ", count_get(curStatCounter->counter));
|
||||||
|
else if (stdout_nice == 2)
|
||||||
|
printf(" %s: %d\n", curCounterDef->name, count_get(curStatCounter->counter));
|
||||||
|
if (syslog_nice == 1) {
|
||||||
|
snprintf(syslogBuf, remainsSyslogBufLen, "%d ", count_get(curStatCounter->counter));
|
||||||
|
remainsSyslogBufLen -= strlen(syslogBuf);
|
||||||
|
} else if (syslog_nice == 2) {
|
||||||
|
snprintf(syslogBuf, remainsSyslogBufLen, " %s: %d\n", curCounterDef->name, count_get(curStatCounter->counter));
|
||||||
|
remainsSyslogBufLen -= strlen(syslogBuf);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (stdout_nice == 1 || stdout_nice == 2)
|
||||||
if (stdout_nice)
|
|
||||||
printf("\n");
|
printf("\n");
|
||||||
|
if (syslog_nice == 1 || syslog_nice == 2)
|
||||||
if (1 == stdout_nice)
|
syslog(LOG_INFO, syslogBuf);
|
||||||
printf("%s\n\n", buf);
|
}
|
||||||
if (1 == syslog_nice)
|
|
||||||
syslog(LOG_DEBUG, buf);
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -23,81 +23,36 @@
|
|||||||
#define _STATS_H_
|
#define _STATS_H_
|
||||||
|
|
||||||
#include "smmapd.h"
|
#include "smmapd.h"
|
||||||
|
#include "count.h"
|
||||||
#ifdef _STATS_C_
|
#include "cfg.h"
|
||||||
char *stat_cnt_names[] = {
|
|
||||||
"",
|
|
||||||
"Server: accepted",
|
|
||||||
"Server: failed",
|
|
||||||
"Server: running networker threads",
|
|
||||||
"Server: networker threads",
|
|
||||||
"Server: failed to start, networker threads",
|
|
||||||
|
|
||||||
"Verifier: entries in cache",
|
|
||||||
"Verifier: running worker threads",
|
|
||||||
"Verifier: worker threads",
|
|
||||||
"Verifier: failed to start, worker threads",
|
|
||||||
"Verifier: timed out worker threads",
|
|
||||||
"Verifier: running checker threads",
|
|
||||||
"Verifier: checker threads",
|
|
||||||
"Verifier: failed to start, checker threads",
|
|
||||||
"Verifier: answered from cache",
|
|
||||||
"Verifier: returned OK",
|
|
||||||
"Verifier: returned NOK",
|
|
||||||
"Verifier: returned TNOK",
|
|
||||||
|
|
||||||
"Cyrus: checker",
|
|
||||||
"Cyrus: illegal input",
|
|
||||||
"Cyrus: depot dns failure",
|
|
||||||
"Cyrus: returned OK",
|
|
||||||
"Cyrus: returned NOK",
|
|
||||||
"Cyrus: returned TNOK",
|
|
||||||
|
|
||||||
"Server: returned OK",
|
|
||||||
"Server: returned TEMP_NOK",
|
|
||||||
"Server: returned PERM_NOK",
|
|
||||||
"Server: returned NOT_FOUND_NOK",
|
|
||||||
"Server: returned illegal input",
|
|
||||||
"Server: returned unknown class",
|
|
||||||
"Server: returned TIMEOUT_NOK",
|
|
||||||
"Server: returned netstring unparsable",
|
|
||||||
};
|
|
||||||
#endif /* _STATS_C_ */
|
|
||||||
|
|
||||||
|
|
||||||
#define STAT_CNT_ACCEPTED 1
|
#define SMM_TYPE_NULL 0
|
||||||
#define STAT_CNT_FAILED 2
|
#define SMM_TYPE_COUNTER 1
|
||||||
#define STAT_CNT_NETWORKER_R_THREADS 3
|
#define SMM_TYPE_GAUGE 2
|
||||||
#define STAT_CNT_NETWORKER_THREADS 4
|
|
||||||
#define STAT_CNT_NETWORKER_THREADS_FAILED 5
|
|
||||||
|
|
||||||
#define STAT_CNT_VERIFIER_CACHE 6
|
#define STAT_COUNTER_MAGIC 0x27061972
|
||||||
#define STAT_CNT_VERIFIER_WORKER_R_THREADS 7
|
|
||||||
#define STAT_CNT_VERIFIER_WORKER_THREADS 8
|
|
||||||
#define STAT_CNT_VERIFIER_WORKER_THREADS_FAILED 9
|
|
||||||
#define STAT_CNT_VERIFIER_WORKER_THREADS_TIMEOUT 10
|
|
||||||
#define STAT_CNT_VERIFIER_CHECKER_R_THREADS 11
|
|
||||||
#define STAT_CNT_VERIFIER_CHECKER_THREADS 12
|
|
||||||
#define STAT_CNT_VERIFIER_CHECKER_THREADS_FAILED 13
|
|
||||||
#define STAT_CNT_VERIFIER_ANSWERED_FROM_CACHE 14
|
|
||||||
#define STAT_CNT_VERIFIER_RETURNED_OK 15
|
|
||||||
#define STAT_CNT_VERIFIER_RETURNED_NOK 16
|
|
||||||
#define STAT_CNT_VERIFIER_RETURNED_TNOK 17
|
|
||||||
|
|
||||||
#define STAT_CNT_CYRUS_WORKER 18
|
typedef struct counterDef_s {
|
||||||
#define STAT_CNT_CYRUS_ILLEGAL_INPUT 19
|
unsigned int type;
|
||||||
#define STAT_CNT_CYRUS_DEPOT_DNS_FAILURE 20
|
const char *name;
|
||||||
#define STAT_CNT_CYRUS_RETURNED_OK 21
|
} counterDef_t;
|
||||||
#define STAT_CNT_CYRUS_RETURNED_NOK 22
|
|
||||||
#define STAT_CNT_CYRUS_RETURNED_TNOK 23
|
|
||||||
|
|
||||||
#define STAT_CNT_OFFSET 23
|
typedef struct statCounter_s {
|
||||||
#define STAT_CNT_MAXNUM STAT_CNT_OFFSET + SMM_MAX_NUM
|
unsigned int magic;
|
||||||
|
count_t *counter;
|
||||||
|
} statCounter_t;
|
||||||
|
|
||||||
|
typedef struct statCounterEntry_s {
|
||||||
|
const char *moduleName;
|
||||||
|
counterDef_t *counterDefs;
|
||||||
|
statCounter_t *statCounters;
|
||||||
|
} statCounterEntry_t;
|
||||||
|
|
||||||
void initStatCounter();
|
counterDef_t *addOneCounterDef(counterDef_t *counterDef, unsigned int type, const char* name);
|
||||||
unsigned int getStatCounter(int cnt_idx);
|
statCounter_t *initStatCounter(const char *moduleName, counterDef_t *counterDefs);
|
||||||
void incStatCounter(int cnt_idx);
|
unsigned int getStatCounter(statCounter_t *statCounter, int cnt_idx);
|
||||||
void decStatCounter(int cnt_idx);
|
void incStatCounter(statCounter_t *statCounter, int cnt_idx);
|
||||||
|
void decStatCounter(statCounter_t *statCounter, int cnt_idx);
|
||||||
void outputStats(int stdout_nice, int syslog_nice);
|
void outputStats(int stdout_nice, int syslog_nice);
|
||||||
#endif /* _STATS_H_ */
|
#endif /* _STATS_H_ */
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
DE-HOTTIS-MIB DEFINITIONS ::= BEGIN
|
|
||||||
|
|
||||||
IMPORTS
|
|
||||||
MODULE-IDENTITY, OBJECT-TYPE, Integer32, enterprises FROM SNMPv2-SMI
|
|
||||||
;
|
|
||||||
|
|
||||||
deHottis MODULE-IDENTITY
|
|
||||||
LAST-UPDATED "200411040000Z" -- 04 Nov 2004, midnight
|
|
||||||
ORGANIZATION "hottis.de"
|
|
||||||
CONTACT-INFO "postal: Wolfgang Hottgenroth
|
|
||||||
Eupenstr. 20
|
|
||||||
45259 Essen
|
|
||||||
Germany
|
|
||||||
|
|
||||||
email: woho@hottis.de
|
|
||||||
"
|
|
||||||
DESCRIPTION "My main MIB
|
|
||||||
"
|
|
||||||
::= { enterprises 9676 }
|
|
||||||
|
|
||||||
END
|
|
@ -1,354 +0,0 @@
|
|||||||
DE-HOTTIS-SMMAPD-MIB DEFINITIONS ::= BEGIN
|
|
||||||
|
|
||||||
IMPORTS
|
|
||||||
MODULE-IDENTITY, OBJECT-TYPE, Counter32 FROM SNMPv2-SMI
|
|
||||||
deHottis FROM DE-HOTTIS-MIB
|
|
||||||
;
|
|
||||||
|
|
||||||
deHottisSmmapdMIB MODULE-IDENTITY
|
|
||||||
LAST-UPDATED "200411040000Z" -- 04 Nov 2004, midnight
|
|
||||||
ORGANIZATION "hottis.de"
|
|
||||||
CONTACT-INFO "postal: Wolfgang Hottgenroth
|
|
||||||
Eupenstr. 20
|
|
||||||
45259 Essen
|
|
||||||
Germany
|
|
||||||
|
|
||||||
email: woho@hottis.de
|
|
||||||
"
|
|
||||||
DESCRIPTION "MIB for gathering statistics from smmapd
|
|
||||||
"
|
|
||||||
::= { deHottis 2 }
|
|
||||||
|
|
||||||
dhsSmmapdStats OBJECT IDENTIFIER ::= { deHottisSmmapdMIB 1 }
|
|
||||||
|
|
||||||
dhsNumber1 OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"number1"
|
|
||||||
::= { dhsSmmapdStats 1 }
|
|
||||||
|
|
||||||
|
|
||||||
DhsServerStat ::=
|
|
||||||
SEQUENCE {
|
|
||||||
dhsAccepted Counter32,
|
|
||||||
dhsFailed Counter32,
|
|
||||||
dhsRunningNwThreads Integer32,
|
|
||||||
dhsNwThreads Counter32,
|
|
||||||
dhsFailedNwThreads Counter32,
|
|
||||||
dhsOKReturned Counter32,
|
|
||||||
dhsTEMPReturned Counter32,
|
|
||||||
dhsPERMReturned Counter32,
|
|
||||||
dhsNOTFOUNDReturned Counter32,
|
|
||||||
dhsIllegalInputFailure Counter32,
|
|
||||||
dhsUnknownClassFailure Counter32,
|
|
||||||
dhsTimeoutFailure Counter32,
|
|
||||||
dhsNetStringFailure Counter32
|
|
||||||
}
|
|
||||||
|
|
||||||
dhsServerStat OBJECT-TYPE
|
|
||||||
SYNTAX DhsServerStat
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Statistics of the server"
|
|
||||||
::= { dhsSmmapdStats 2 }
|
|
||||||
|
|
||||||
|
|
||||||
dhsAccepted OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Connections accepted by the server"
|
|
||||||
::= { dhsServerStat 1 }
|
|
||||||
|
|
||||||
dhsFailed OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Connections the server failed to accept"
|
|
||||||
::= { dhsServerStat 2 }
|
|
||||||
|
|
||||||
dhsRunningNwThreads OBJECT-TYPE
|
|
||||||
SYNTAX Integer32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Running networker threads"
|
|
||||||
::= { dhsServerStat 3 }
|
|
||||||
|
|
||||||
dhsNwThreads OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Networker threads"
|
|
||||||
::= { dhsServerStat 4 }
|
|
||||||
|
|
||||||
dhsFailedNwThreads OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Networker threads failed to start"
|
|
||||||
::= { dhsServerStat 5 }
|
|
||||||
|
|
||||||
dhsOKReturned OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"OK returned to sendmail"
|
|
||||||
::= { dhsServerStat 6 }
|
|
||||||
|
|
||||||
dhsTEMPReturned OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"TEMP failure returned to sendmail"
|
|
||||||
::= { dhsServerStat 7 }
|
|
||||||
|
|
||||||
dhsPERMReturned OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"PERM failure returned to sendmail"
|
|
||||||
::= { dhsServerStat 8 }
|
|
||||||
|
|
||||||
dhsNOTFOUNDReturned OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"NOTFOUND returned to sendmail"
|
|
||||||
::= { dhsServerStat 9 }
|
|
||||||
|
|
||||||
dhsIllegalInputFailure OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Class not found (PERM) returned to sendmail"
|
|
||||||
::= { dhsServerStat 10 }
|
|
||||||
|
|
||||||
dhsUnknownClassFailure OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Class not found (PERM) returned to sendmail"
|
|
||||||
::= { dhsServerStat 11 }
|
|
||||||
|
|
||||||
dhsTimeoutFailure OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Timeout failure returned to sendmail"
|
|
||||||
::= { dhsServerStat 12 }
|
|
||||||
|
|
||||||
dhsNetStringFailure OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"NetString (NOK) returned to sendmail"
|
|
||||||
::= { dhsServerStat 13 }
|
|
||||||
|
|
||||||
|
|
||||||
DhsVerifierStat ::=
|
|
||||||
SEQUENCE {
|
|
||||||
dhsVCacheEntries Integer32,
|
|
||||||
dhsVRunningWorkerThreads Integer32,
|
|
||||||
dhsVWorkerThreads Counter32,
|
|
||||||
dhsVFailedWorkerThreads Counter32,
|
|
||||||
dhsVTimedOutWorkerThreads Counter32,
|
|
||||||
dhsVRunningCheckerThreads Integer32,
|
|
||||||
dhsVCheckerThreads Counter32,
|
|
||||||
dhsVFailedCheckerThreads Counter32,
|
|
||||||
dhsVAnsweredFromCache Counter32,
|
|
||||||
dhsVReturnedOK Counter32,
|
|
||||||
dhsVReturnedNOK Counter32,
|
|
||||||
dhsVReturnedTNOK Counter32
|
|
||||||
}
|
|
||||||
|
|
||||||
dhsVerifierStat OBJECT-TYPE
|
|
||||||
SYNTAX DhsVerifierStat
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Statistics of the verifier"
|
|
||||||
::= { dhsSmmapdStats 3 }
|
|
||||||
|
|
||||||
|
|
||||||
dhsVCacheEntries OBJECT-TYPE
|
|
||||||
SYNTAX Integer32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Entries in verifier cache"
|
|
||||||
::= { dhsVerifierStat 1 }
|
|
||||||
|
|
||||||
dhsVRunningWorkerThreads OBJECT-TYPE
|
|
||||||
SYNTAX Integer32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Running verifier worker threads"
|
|
||||||
::= { dhsVerifierStat 2 }
|
|
||||||
|
|
||||||
dhsVWorkerThreads OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"verifier worker threads"
|
|
||||||
::= { dhsVerifierStat 3 }
|
|
||||||
|
|
||||||
dhsVFailedWorkerThreads OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"failed to start verifier worker threads"
|
|
||||||
::= { dhsVerifierStat 4 }
|
|
||||||
|
|
||||||
dhsVTimedOutWorkerThreads OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"timed out verifier worker threads"
|
|
||||||
::= { dhsVerifierStat 5 }
|
|
||||||
|
|
||||||
dhsVRunningCheckerThreads OBJECT-TYPE
|
|
||||||
SYNTAX Integer32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Running verifier checker threads"
|
|
||||||
::= { dhsVerifierStat 6 }
|
|
||||||
|
|
||||||
dhsVCheckerThreads OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"verifier checker threads"
|
|
||||||
::= { dhsVerifierStat 7 }
|
|
||||||
|
|
||||||
dhsVFailedCheckerThreads OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"failed to start verifier checker threads"
|
|
||||||
::= { dhsVerifierStat 8 }
|
|
||||||
|
|
||||||
dhsVAnsweredFromCache OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"answers taken directly from cache"
|
|
||||||
::= { dhsVerifierStat 9 }
|
|
||||||
|
|
||||||
dhsVReturnedOK OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"verifier returned OK"
|
|
||||||
::= { dhsVerifierStat 10 }
|
|
||||||
|
|
||||||
dhsVReturnedNOK OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"verifier returned NOK"
|
|
||||||
::= { dhsVerifierStat 11 }
|
|
||||||
|
|
||||||
dhsVReturnedTNOK OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"verifier returned TNOK"
|
|
||||||
::= { dhsVerifierStat 12 }
|
|
||||||
|
|
||||||
|
|
||||||
DhsCyrusStat ::=
|
|
||||||
SEQUENCE {
|
|
||||||
dhsCWorker Counter32,
|
|
||||||
dhsCIllegalInput Counter32,
|
|
||||||
dhsCDepotDNSFailure Counter32,
|
|
||||||
dhsCReturnedOK Counter32,
|
|
||||||
dhsCReturnedNOK Counter32,
|
|
||||||
dhsCReturnedTNOK Counter32
|
|
||||||
}
|
|
||||||
|
|
||||||
dhsCyrusStat OBJECT-TYPE
|
|
||||||
SYNTAX DhsCyrusStat
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"Statistics of the cyrus checker"
|
|
||||||
::= { dhsSmmapdStats 4 }
|
|
||||||
|
|
||||||
|
|
||||||
dhsCWorker OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"cyrus checkers"
|
|
||||||
::= { dhsCyrusStat 1 }
|
|
||||||
|
|
||||||
dhsCIllegalInput OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"cyrus checkers with illegal input"
|
|
||||||
::= { dhsCyrusStat 2 }
|
|
||||||
|
|
||||||
dhsCDepotDNSFailure OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"cyrus checkers with depot DNS failure"
|
|
||||||
::= { dhsCyrusStat 3 }
|
|
||||||
|
|
||||||
dhsCReturnedOK OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"cyrus checkers returned OK"
|
|
||||||
::= { dhsCyrusStat 4 }
|
|
||||||
|
|
||||||
dhsCReturnedNOK OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"cyrus checkers returned NOK"
|
|
||||||
::= { dhsCyrusStat 5 }
|
|
||||||
|
|
||||||
dhsCReturnedTNOK OBJECT-TYPE
|
|
||||||
SYNTAX Counter32
|
|
||||||
MAX-ACCESS read-only
|
|
||||||
STATUS current
|
|
||||||
DESCRIPTION
|
|
||||||
"cyrus checkers returned TNOK"
|
|
||||||
::= { dhsCyrusStat 6 }
|
|
||||||
|
|
||||||
|
|
||||||
END
|
|
@ -1,2 +0,0 @@
|
|||||||
data_DATA = DE-HOTTIS-MIB.txt DE-HOTTIS-SMMAPD-MIB.txt
|
|
||||||
EXTRA_DIST = DE-HOTTIS-MIB.txt DE-HOTTIS-SMMAPD-MIB.txt
|
|
@ -1,221 +0,0 @@
|
|||||||
# Makefile.in generated automatically by automake 1.4-p6 from Makefile.am
|
|
||||||
|
|
||||||
# Copyright (C) 1994, 1995-8, 1999, 2001 Free Software Foundation, Inc.
|
|
||||||
# This Makefile.in is free software; the Free Software Foundation
|
|
||||||
# gives unlimited permission to copy and/or distribute it,
|
|
||||||
# with or without modifications, as long as this notice is preserved.
|
|
||||||
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
|
|
||||||
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
# PARTICULAR PURPOSE.
|
|
||||||
|
|
||||||
|
|
||||||
SHELL = @SHELL@
|
|
||||||
|
|
||||||
srcdir = @srcdir@
|
|
||||||
top_srcdir = @top_srcdir@
|
|
||||||
VPATH = @srcdir@
|
|
||||||
prefix = @prefix@
|
|
||||||
exec_prefix = @exec_prefix@
|
|
||||||
|
|
||||||
bindir = @bindir@
|
|
||||||
sbindir = @sbindir@
|
|
||||||
libexecdir = @libexecdir@
|
|
||||||
datadir = @datadir@
|
|
||||||
sysconfdir = @sysconfdir@
|
|
||||||
sharedstatedir = @sharedstatedir@
|
|
||||||
localstatedir = @localstatedir@
|
|
||||||
libdir = @libdir@
|
|
||||||
infodir = @infodir@
|
|
||||||
mandir = @mandir@
|
|
||||||
includedir = @includedir@
|
|
||||||
oldincludedir = /usr/include
|
|
||||||
|
|
||||||
DESTDIR =
|
|
||||||
|
|
||||||
pkgdatadir = $(datadir)/@PACKAGE@
|
|
||||||
pkglibdir = $(libdir)/@PACKAGE@
|
|
||||||
pkgincludedir = $(includedir)/@PACKAGE@
|
|
||||||
|
|
||||||
top_builddir = ..
|
|
||||||
|
|
||||||
ACLOCAL = @ACLOCAL@
|
|
||||||
AUTOCONF = @AUTOCONF@
|
|
||||||
AUTOMAKE = @AUTOMAKE@
|
|
||||||
AUTOHEADER = @AUTOHEADER@
|
|
||||||
|
|
||||||
INSTALL = @INSTALL@
|
|
||||||
INSTALL_PROGRAM = @INSTALL_PROGRAM@ $(AM_INSTALL_PROGRAM_FLAGS)
|
|
||||||
INSTALL_DATA = @INSTALL_DATA@
|
|
||||||
INSTALL_SCRIPT = @INSTALL_SCRIPT@
|
|
||||||
transform = @program_transform_name@
|
|
||||||
|
|
||||||
NORMAL_INSTALL = :
|
|
||||||
PRE_INSTALL = :
|
|
||||||
POST_INSTALL = :
|
|
||||||
NORMAL_UNINSTALL = :
|
|
||||||
PRE_UNINSTALL = :
|
|
||||||
POST_UNINSTALL = :
|
|
||||||
host_alias = @host_alias@
|
|
||||||
host_triplet = @host@
|
|
||||||
AR = @AR@
|
|
||||||
AS = @AS@
|
|
||||||
BDB_LIBS = @BDB_LIBS@
|
|
||||||
CC = @CC@
|
|
||||||
CXX = @CXX@
|
|
||||||
CXXCPP = @CXXCPP@
|
|
||||||
DLLTOOL = @DLLTOOL@
|
|
||||||
ECHO = @ECHO@
|
|
||||||
EGREP = @EGREP@
|
|
||||||
EXEEXT = @EXEEXT@
|
|
||||||
F77 = @F77@
|
|
||||||
GCJ = @GCJ@
|
|
||||||
GCJFLAGS = @GCJFLAGS@
|
|
||||||
HAVE_LIB = @HAVE_LIB@
|
|
||||||
LIB = @LIB@
|
|
||||||
LIBTOOL = @LIBTOOL@
|
|
||||||
LN_S = @LN_S@
|
|
||||||
LTLIB = @LTLIB@
|
|
||||||
MAINT = @MAINT@
|
|
||||||
MAKEINFO = @MAKEINFO@
|
|
||||||
OBJDUMP = @OBJDUMP@
|
|
||||||
OBJEXT = @OBJEXT@
|
|
||||||
PACKAGE = @PACKAGE@
|
|
||||||
RANLIB = @RANLIB@
|
|
||||||
RC = @RC@
|
|
||||||
STRIP = @STRIP@
|
|
||||||
VERSION = @VERSION@
|
|
||||||
|
|
||||||
data_DATA = DE-HOTTIS-MIB.txt DE-HOTTIS-SMMAPD-MIB.txt
|
|
||||||
EXTRA_DIST = DE-HOTTIS-MIB.txt DE-HOTTIS-SMMAPD-MIB.txt
|
|
||||||
mkinstalldirs = $(SHELL) $(top_srcdir)/mkinstalldirs
|
|
||||||
CONFIG_HEADER = ../config.h
|
|
||||||
CONFIG_CLEAN_FILES =
|
|
||||||
DATA = $(data_DATA)
|
|
||||||
|
|
||||||
DIST_COMMON = Makefile.am Makefile.in
|
|
||||||
|
|
||||||
|
|
||||||
DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST)
|
|
||||||
|
|
||||||
TAR = tar
|
|
||||||
GZIP_ENV = --best
|
|
||||||
all: all-redirect
|
|
||||||
.SUFFIXES:
|
|
||||||
$(srcdir)/Makefile.in: @MAINTAINER_MODE_TRUE@ Makefile.am $(top_srcdir)/configure.ac $(ACLOCAL_M4)
|
|
||||||
cd $(top_srcdir) && $(AUTOMAKE) --gnu mib/Makefile
|
|
||||||
|
|
||||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES)
|
|
||||||
cd $(top_builddir) \
|
|
||||||
&& CONFIG_FILES=$(subdir)/$@ CONFIG_HEADERS= $(SHELL) ./config.status
|
|
||||||
|
|
||||||
|
|
||||||
install-dataDATA: $(data_DATA)
|
|
||||||
@$(NORMAL_INSTALL)
|
|
||||||
$(mkinstalldirs) $(DESTDIR)$(datadir)
|
|
||||||
@list='$(data_DATA)'; for p in $$list; do \
|
|
||||||
if test -f $(srcdir)/$$p; then \
|
|
||||||
echo " $(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(datadir)/$$p"; \
|
|
||||||
$(INSTALL_DATA) $(srcdir)/$$p $(DESTDIR)$(datadir)/$$p; \
|
|
||||||
else if test -f $$p; then \
|
|
||||||
echo " $(INSTALL_DATA) $$p $(DESTDIR)$(datadir)/$$p"; \
|
|
||||||
$(INSTALL_DATA) $$p $(DESTDIR)$(datadir)/$$p; \
|
|
||||||
fi; fi; \
|
|
||||||
done
|
|
||||||
|
|
||||||
uninstall-dataDATA:
|
|
||||||
@$(NORMAL_UNINSTALL)
|
|
||||||
list='$(data_DATA)'; for p in $$list; do \
|
|
||||||
rm -f $(DESTDIR)$(datadir)/$$p; \
|
|
||||||
done
|
|
||||||
tags: TAGS
|
|
||||||
TAGS:
|
|
||||||
|
|
||||||
|
|
||||||
distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir)
|
|
||||||
|
|
||||||
subdir = mib
|
|
||||||
|
|
||||||
distdir: $(DISTFILES)
|
|
||||||
here=`cd $(top_builddir) && pwd`; \
|
|
||||||
top_distdir=`cd $(top_distdir) && pwd`; \
|
|
||||||
distdir=`cd $(distdir) && pwd`; \
|
|
||||||
cd $(top_srcdir) \
|
|
||||||
&& $(AUTOMAKE) --include-deps --build-dir=$$here --srcdir-name=$(top_srcdir) --output-dir=$$top_distdir --gnu mib/Makefile
|
|
||||||
@for file in $(DISTFILES); do \
|
|
||||||
d=$(srcdir); \
|
|
||||||
if test -d $$d/$$file; then \
|
|
||||||
cp -pr $$d/$$file $(distdir)/$$file; \
|
|
||||||
else \
|
|
||||||
test -f $(distdir)/$$file \
|
|
||||||
|| ln $$d/$$file $(distdir)/$$file 2> /dev/null \
|
|
||||||
|| cp -p $$d/$$file $(distdir)/$$file || :; \
|
|
||||||
fi; \
|
|
||||||
done
|
|
||||||
info-am:
|
|
||||||
info: info-am
|
|
||||||
dvi-am:
|
|
||||||
dvi: dvi-am
|
|
||||||
check-am: all-am
|
|
||||||
check: check-am
|
|
||||||
installcheck-am:
|
|
||||||
installcheck: installcheck-am
|
|
||||||
install-exec-am:
|
|
||||||
install-exec: install-exec-am
|
|
||||||
|
|
||||||
install-data-am: install-dataDATA
|
|
||||||
install-data: install-data-am
|
|
||||||
|
|
||||||
install-am: all-am
|
|
||||||
@$(MAKE) $(AM_MAKEFLAGS) install-exec-am install-data-am
|
|
||||||
install: install-am
|
|
||||||
uninstall-am: uninstall-dataDATA
|
|
||||||
uninstall: uninstall-am
|
|
||||||
all-am: Makefile $(DATA)
|
|
||||||
all-redirect: all-am
|
|
||||||
install-strip:
|
|
||||||
$(MAKE) $(AM_MAKEFLAGS) AM_INSTALL_PROGRAM_FLAGS=-s install
|
|
||||||
installdirs:
|
|
||||||
$(mkinstalldirs) $(DESTDIR)$(datadir)
|
|
||||||
|
|
||||||
|
|
||||||
mostlyclean-generic:
|
|
||||||
|
|
||||||
clean-generic:
|
|
||||||
|
|
||||||
distclean-generic:
|
|
||||||
-rm -f Makefile $(CONFIG_CLEAN_FILES)
|
|
||||||
-rm -f config.cache config.log stamp-h stamp-h[0-9]*
|
|
||||||
|
|
||||||
maintainer-clean-generic:
|
|
||||||
mostlyclean-am: mostlyclean-generic
|
|
||||||
|
|
||||||
mostlyclean: mostlyclean-am
|
|
||||||
|
|
||||||
clean-am: clean-generic mostlyclean-am
|
|
||||||
|
|
||||||
clean: clean-am
|
|
||||||
|
|
||||||
distclean-am: distclean-generic clean-am
|
|
||||||
-rm -f libtool
|
|
||||||
|
|
||||||
distclean: distclean-am
|
|
||||||
|
|
||||||
maintainer-clean-am: maintainer-clean-generic distclean-am
|
|
||||||
@echo "This command is intended for maintainers to use;"
|
|
||||||
@echo "it deletes files that may require special tools to rebuild."
|
|
||||||
|
|
||||||
maintainer-clean: maintainer-clean-am
|
|
||||||
|
|
||||||
.PHONY: uninstall-dataDATA install-dataDATA tags distdir info-am info \
|
|
||||||
dvi-am dvi check check-am installcheck-am installcheck install-exec-am \
|
|
||||||
install-exec install-data-am install-data install-am install \
|
|
||||||
uninstall-am uninstall all-redirect all-am all installdirs \
|
|
||||||
mostlyclean-generic distclean-generic clean-generic \
|
|
||||||
maintainer-clean-generic clean mostlyclean distclean maintainer-clean
|
|
||||||
|
|
||||||
|
|
||||||
# Tell versions [3.59,3.63) of GNU make to not export all variables.
|
|
||||||
# Otherwise a system limit (for SysV at least) may be exceeded.
|
|
||||||
.NOEXPORT:
|
|
@ -85,6 +85,36 @@
|
|||||||
#define RELEASE_ID "0.9"
|
#define RELEASE_ID "0.9"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
counterDef_t *server_counterDefs;
|
||||||
|
void server_setupCounterList() {
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: accepted");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: failed");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_GAUGE, "Server: running networker threads");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: networker threads");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: failed to start, networker threads");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: returned OK");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: returned TEMP_NOK");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: returned PERM_NOK");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: returned NOT_FOUND_NOK");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: returned illegal input");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: returned unknown class");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: returned TIMEOUT_NOK");
|
||||||
|
server_counterDefs = addOneCounterDef(server_counterDefs, SMM_TYPE_COUNTER, "Server: returned netstring unparsable");
|
||||||
|
};
|
||||||
|
|
||||||
|
#define STAT_CNT_ACCEPTED 0
|
||||||
|
#define STAT_CNT_FAILED 1
|
||||||
|
#define STAT_CNT_NETWORKER_R_THREADS 2
|
||||||
|
#define STAT_CNT_NETWORKER_THREADS 3
|
||||||
|
#define STAT_CNT_NETWORKER_THREADS_FAILED 4
|
||||||
|
#define STAT_CNT_OFFSET 5 - 1
|
||||||
|
|
||||||
|
statCounter_t *globalStatCounter;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct networkerThread_s {
|
struct networkerThread_s {
|
||||||
int result;
|
int result;
|
||||||
struct sockaddr_in clientAddr;
|
struct sockaddr_in clientAddr;
|
||||||
@ -142,7 +172,7 @@ void * cleaner(void * arg) {
|
|||||||
count_get(&thread_counter));
|
count_get(&thread_counter));
|
||||||
t = (networkerThread_t*) queue_get_wait(&terminated_networker_queue);
|
t = (networkerThread_t*) queue_get_wait(&terminated_networker_queue);
|
||||||
count_dec(&thread_counter);
|
count_dec(&thread_counter);
|
||||||
decStatCounter(STAT_CNT_NETWORKER_R_THREADS);
|
decStatCounter(globalStatCounter, STAT_CNT_NETWORKER_R_THREADS);
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "cleaner: Networker serving %d (address: %s, port: %d), result %d",
|
syslog(LOG_DEBUG, "cleaner: Networker serving %d (address: %s, port: %d), result %d",
|
||||||
t->clientSock, inet_ntoa(t->clientAddr.sin_addr),
|
t->clientSock, inet_ntoa(t->clientAddr.sin_addr),
|
||||||
@ -178,7 +208,7 @@ void * networker(void * arg) {
|
|||||||
networkerThread_t * thread = (networkerThread_t *) arg;
|
networkerThread_t * thread = (networkerThread_t *) arg;
|
||||||
thread->pthread = pthread_self();
|
thread->pthread = pthread_self();
|
||||||
|
|
||||||
incStatCounter(STAT_CNT_NETWORKER_THREADS);
|
incStatCounter(globalStatCounter, STAT_CNT_NETWORKER_THREADS);
|
||||||
|
|
||||||
syslog(LOG_DEBUG, "networker: serving %d (address: %s, port: %d) started",
|
syslog(LOG_DEBUG, "networker: serving %d (address: %s, port: %d) started",
|
||||||
thread->clientSock, inet_ntoa(thread->clientAddr.sin_addr),
|
thread->clientSock, inet_ntoa(thread->clientAddr.sin_addr),
|
||||||
@ -226,7 +256,7 @@ void * networker(void * arg) {
|
|||||||
syslog(LOG_DEBUG, "networker: dispatcher result: %d, answer: %s", dispatcher_result, answer->buf);
|
syslog(LOG_DEBUG, "networker: dispatcher result: %d, answer: %s", dispatcher_result, answer->buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
incStatCounter(dispatcher_result + STAT_CNT_OFFSET);
|
incStatCounter(globalStatCounter, dispatcher_result + STAT_CNT_OFFSET);
|
||||||
|
|
||||||
result_text = (dispatcher_result > SMM_MAX_NUM) ?
|
result_text = (dispatcher_result > SMM_MAX_NUM) ?
|
||||||
T_SMM_RESULTS[0] :
|
T_SMM_RESULTS[0] :
|
||||||
@ -280,6 +310,7 @@ int server() {
|
|||||||
|
|
||||||
char *cfg_address, *cfg_port;
|
char *cfg_address, *cfg_port;
|
||||||
|
|
||||||
|
|
||||||
netstring_disabled = atoi(findcfgx(cfg, CFG_SECTION_GLOBAL, CFG_NETSTRING_DISABLED, "0"));
|
netstring_disabled = atoi(findcfgx(cfg, CFG_SECTION_GLOBAL, CFG_NETSTRING_DISABLED, "0"));
|
||||||
|
|
||||||
|
|
||||||
@ -347,13 +378,13 @@ int server() {
|
|||||||
syslog(LOG_DEBUG, "server: Got a connection %d", clientSock);
|
syslog(LOG_DEBUG, "server: Got a connection %d", clientSock);
|
||||||
|
|
||||||
if (-1 == clientSock) {
|
if (-1 == clientSock) {
|
||||||
incStatCounter(STAT_CNT_FAILED);
|
incStatCounter(globalStatCounter, STAT_CNT_FAILED);
|
||||||
syslog(LOG_ERR, "server: failure when accepting connection: %d, %s",
|
syslog(LOG_ERR, "server: failure when accepting connection: %d, %s",
|
||||||
errno, strerror(errno));
|
errno, strerror(errno));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
incStatCounter(STAT_CNT_ACCEPTED);
|
incStatCounter(globalStatCounter, STAT_CNT_ACCEPTED);
|
||||||
|
|
||||||
thread = (networkerThread_t *) htmalloc(sizeof(networkerThread_t)+10);
|
thread = (networkerThread_t *) htmalloc(sizeof(networkerThread_t)+10);
|
||||||
if (NULL == thread) {
|
if (NULL == thread) {
|
||||||
@ -368,13 +399,13 @@ int server() {
|
|||||||
thread->clientAddrLen = clientAddrLen;
|
thread->clientAddrLen = clientAddrLen;
|
||||||
|
|
||||||
count_inc(&thread_counter);
|
count_inc(&thread_counter);
|
||||||
incStatCounter(STAT_CNT_NETWORKER_R_THREADS);
|
incStatCounter(globalStatCounter, STAT_CNT_NETWORKER_R_THREADS);
|
||||||
res = pthread_create(&tid, NULL, &networker, thread);
|
res = pthread_create(&tid, NULL, &networker, thread);
|
||||||
if (0 != res) {
|
if (0 != res) {
|
||||||
syslog(LOG_ERR, "server: unable to start networker thread");
|
syslog(LOG_ERR, "server: unable to start networker thread");
|
||||||
free(thread);
|
free(thread);
|
||||||
decStatCounter(STAT_CNT_NETWORKER_R_THREADS);
|
decStatCounter(globalStatCounter, STAT_CNT_NETWORKER_R_THREADS);
|
||||||
incStatCounter(STAT_CNT_NETWORKER_THREADS_FAILED);
|
incStatCounter(globalStatCounter, STAT_CNT_NETWORKER_THREADS_FAILED);
|
||||||
count_dec(&thread_counter);
|
count_dec(&thread_counter);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -422,6 +453,8 @@ int main(int argc, char **argv) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
openlog("smmapd", LOG_PID, LOG_LOCAL2);
|
openlog("smmapd", LOG_PID, LOG_LOCAL2);
|
||||||
syslog(LOG_INFO, "main: started");
|
syslog(LOG_INFO, "main: started");
|
||||||
cfg = readcfg((cfg_file == NULL) ? DEFAULT_SMMAPD_INI : cfg_file);
|
cfg = readcfg((cfg_file == NULL) ? DEFAULT_SMMAPD_INI : cfg_file);
|
||||||
@ -430,6 +463,7 @@ int main(int argc, char **argv) {
|
|||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
do_fork = atoi(findcfgx(cfg, "global", "do_fork", "1"));
|
do_fork = atoi(findcfgx(cfg, "global", "do_fork", "1"));
|
||||||
pid = ((1 == do_fork) && (0 == foreground)) ? fork() : 0;
|
pid = ((1 == do_fork) && (0 == foreground)) ? fork() : 0;
|
||||||
|
|
||||||
@ -449,6 +483,8 @@ int main(int argc, char **argv) {
|
|||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
server_setupCounterList();
|
||||||
|
globalStatCounter = initStatCounter("global", server_counterDefs);
|
||||||
|
|
||||||
if (0 != (err = server())) {
|
if (0 != (err = server())) {
|
||||||
syslog(LOG_ERR, "main: server fails: %d", err);
|
syslog(LOG_ERR, "main: server fails: %d", err);
|
||||||
|
@ -6,7 +6,7 @@ port = 8887
|
|||||||
; plugin_dir = /home/who/Sources/sf/smmapdfw
|
; plugin_dir = /home/who/Sources/sf/smmapdfw
|
||||||
; plugins = test_worker1 test_worker2 verifier cyruscheck lua_worker
|
; plugins = test_worker1 test_worker2 verifier cyruscheck lua_worker
|
||||||
plugins = verifier
|
plugins = verifier
|
||||||
enable_stats = 0
|
enable_stats = 1
|
||||||
enable_snmp = 1
|
enable_snmp = 1
|
||||||
|
|
||||||
; disables the netstring codec, only for debugging in the development
|
; disables the netstring codec, only for debugging in the development
|
||||||
|
@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Copyright (C) 2004, Wolfgang Hottgenroth
|
Copyright (C) 2004, Wolfgang Hottgenroth
|
||||||
|
|
||||||
@ -28,179 +27,145 @@
|
|||||||
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||||
|
|
||||||
#include <syslog.h>
|
#include <syslog.h>
|
||||||
|
#include <string.h>
|
||||||
|
|
||||||
|
#include "snmp_subagent.h"
|
||||||
#include "stats.h"
|
#include "stats.h"
|
||||||
#include "smmapd.h"
|
#include "smmapd.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
|
#include "htmalloc.h"
|
||||||
|
|
||||||
|
extern cfg_t *cfg;
|
||||||
|
|
||||||
typedef struct var_cnt_map_s {
|
|
||||||
char* var;
|
|
||||||
int cnt;
|
|
||||||
} var_cnt_map_t;
|
|
||||||
|
|
||||||
int number1 = 42;
|
|
||||||
int counter32 = 1;
|
|
||||||
int integer32 = 1;
|
|
||||||
|
|
||||||
var_cnt_map_t *var_cnt_map = NULL;
|
|
||||||
int num_var_cnt_map = 0;
|
|
||||||
|
|
||||||
char *agentx_socket = NULL;
|
char *agentx_socket = NULL;
|
||||||
|
|
||||||
|
extern statCounterEntry_t *statCounterList;
|
||||||
|
extern unsigned int statCounterListLen;
|
||||||
|
registrationEntry_t *registrationList = NULL;
|
||||||
|
unsigned int registrationListLen = 0;
|
||||||
|
|
||||||
int
|
int handler(netsnmp_mib_handler *handler,
|
||||||
handle_number1(netsnmp_mib_handler *handler,
|
netsnmp_handler_registration *registrationInfo,
|
||||||
netsnmp_handler_registration *reginfo,
|
netsnmp_agent_request_info *requestInfo,
|
||||||
netsnmp_agent_request_info *reqinfo,
|
netsnmp_request_info *requests) {
|
||||||
netsnmp_request_info *requests)
|
|
||||||
{
|
|
||||||
switch(reqinfo->mode) {
|
|
||||||
|
|
||||||
case MODE_GET:
|
char *sep = strchr(registrationInfo->handlerName, '_');
|
||||||
snmp_set_var_typed_value(requests->requestvb, ASN_COUNTER,
|
if (sep == NULL) {
|
||||||
(u_char *) &number1,
|
return SNMP_ERR_GENERR;
|
||||||
sizeof(number1));
|
}
|
||||||
|
int num = atoi(sep+1);
|
||||||
|
|
||||||
|
|
||||||
|
u_char *valuePtr = NULL;
|
||||||
|
size_t valueLen = 0;
|
||||||
|
u_char type = ASN_NULL;
|
||||||
|
|
||||||
|
if (strncmp(registrationInfo->handlerName, "value", sep - registrationInfo->handlerName) == 0) {
|
||||||
|
int tmpVal = count_get((registrationList + num)->counter);
|
||||||
|
valuePtr = (u_char*) &tmpVal;
|
||||||
|
valueLen = sizeof(tmpVal);
|
||||||
|
switch ((registrationList + num)->type) {
|
||||||
|
case SMM_TYPE_GAUGE:
|
||||||
|
type = ASN_GAUGE;
|
||||||
|
break;
|
||||||
|
case SMM_TYPE_COUNTER:
|
||||||
|
type = ASN_COUNTER;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return SNMP_ERR_GENERR;
|
return SNMP_ERR_GENERR;
|
||||||
}
|
}
|
||||||
|
} else if (strncmp(registrationInfo->handlerName, "name", sep - registrationInfo->handlerName) == 0) {
|
||||||
return SNMP_ERR_NOERROR;
|
valuePtr = (u_char*) (registrationList + num)->name;
|
||||||
}
|
valueLen = strlen((registrationList + num)->name);
|
||||||
|
type = ASN_OCTET_STR;
|
||||||
|
|
||||||
int
|
|
||||||
handle_it(netsnmp_mib_handler *handler,
|
|
||||||
netsnmp_handler_registration *reginfo,
|
|
||||||
netsnmp_agent_request_info *reqinfo,
|
|
||||||
netsnmp_request_info *requests,
|
|
||||||
u_char type)
|
|
||||||
{
|
|
||||||
int i, cnt, value, res;
|
|
||||||
for (i=0; i<num_var_cnt_map; i++)
|
|
||||||
if (0 == strcmp(reginfo->handlerName, var_cnt_map[i].var)) {
|
|
||||||
cnt = var_cnt_map[i].cnt;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (MODE_GET == reqinfo->mode) {
|
|
||||||
value = getStatCounter(cnt);
|
|
||||||
snmp_set_var_typed_value(requests->requestvb, type,
|
|
||||||
(u_char *) &value,
|
|
||||||
sizeof(value));
|
|
||||||
res = SNMP_ERR_NOERROR;
|
|
||||||
} else {
|
} else {
|
||||||
res = SNMP_ERR_GENERR;
|
return SNMP_ERR_GENERR;
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
if (MODE_GET == requestInfo->mode) {
|
||||||
|
snmp_set_var_typed_value(requests->requestvb, type,
|
||||||
|
valuePtr, valueLen);
|
||||||
|
return SNMP_ERR_NOERROR;
|
||||||
|
} else {
|
||||||
|
return SNMP_ERR_GENERR;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
handle_counter32(netsnmp_mib_handler *handler,
|
strToOid(const char *baseOid, int oidIdx1, int oidIdx2, int oidIdx3, oid **argOid, int *argOidLen) {
|
||||||
netsnmp_handler_registration *reginfo,
|
oid *myOid = (oid*) htmalloc(sizeof(oid) * 128);
|
||||||
netsnmp_agent_request_info *reqinfo,
|
char *tmpBaseOidPtr = htstrdup(baseOid);
|
||||||
netsnmp_request_info *requests)
|
char *rememberTmpBaseOidPtr = tmpBaseOidPtr;
|
||||||
{
|
char *token;
|
||||||
return handle_it(handler, reginfo, reqinfo, requests, ASN_COUNTER);
|
int i = 0;
|
||||||
|
|
||||||
|
while ((token = strtok(tmpBaseOidPtr, ".")) != NULL) {
|
||||||
|
tmpBaseOidPtr = NULL;
|
||||||
|
myOid[i++] = atoi(token);
|
||||||
|
}
|
||||||
|
myOid[i++] = oidIdx1;
|
||||||
|
myOid[i++] = oidIdx2;
|
||||||
|
myOid[i++] = oidIdx3;
|
||||||
|
|
||||||
|
free(rememberTmpBaseOidPtr);
|
||||||
|
*argOid = myOid;
|
||||||
|
*argOidLen = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
|
||||||
handle_integer32(netsnmp_mib_handler *handler,
|
|
||||||
netsnmp_handler_registration *reginfo,
|
#define NAME_BUF_SIZE 128
|
||||||
netsnmp_agent_request_info *reqinfo,
|
void init_dhsMIBObjects(cfg_t *cfg) {
|
||||||
netsnmp_request_info *requests)
|
/* setup the registration list */
|
||||||
{
|
const char *baseOid= findcfgx(cfg, "snmp", "base_oid", "1.3.6.1.4.1.9676.1.2");
|
||||||
return handle_it(handler, reginfo, reqinfo, requests, ASN_INTEGER);
|
char nameBuf[NAME_BUF_SIZE];
|
||||||
|
statCounterEntry_t *curStatCounterEntry;
|
||||||
|
unsigned int i;
|
||||||
|
for (curStatCounterEntry = statCounterList, i = 0; i < statCounterListLen; curStatCounterEntry++, i++) {
|
||||||
|
statCounter_t *curStatCounter;
|
||||||
|
counterDef_t *curCounterDef;
|
||||||
|
for (curStatCounter = curStatCounterEntry->statCounters, curCounterDef = curStatCounterEntry->counterDefs;
|
||||||
|
curStatCounter->counter != NULL;
|
||||||
|
curStatCounter++, curCounterDef++) {
|
||||||
|
registrationList = (registrationEntry_t*) htrealloc(registrationList, sizeof(registrationEntry_t) * (registrationListLen + 1));
|
||||||
|
strToOid(baseOid, i+1, 1, registrationListLen+1,
|
||||||
|
&(registrationList + registrationListLen)->nameOid, &(registrationList + registrationListLen)->nameOidLen);
|
||||||
|
snprintf(nameBuf, NAME_BUF_SIZE, "name_%d", registrationListLen);
|
||||||
|
(registrationList + registrationListLen)->nameRegistrationName = htstrdup(nameBuf);
|
||||||
|
strToOid(baseOid, i+1, 2, registrationListLen+1,
|
||||||
|
&(registrationList + registrationListLen)->valueOid, &(registrationList + registrationListLen)->valueOidLen);
|
||||||
|
snprintf(nameBuf, NAME_BUF_SIZE, "value_%d", registrationListLen);
|
||||||
|
(registrationList + registrationListLen)->valueRegistrationName = htstrdup(nameBuf);
|
||||||
|
(registrationList + registrationListLen)->type = curCounterDef->type;
|
||||||
|
(registrationList + registrationListLen)->counter = curStatCounter->counter;
|
||||||
|
(registrationList + registrationListLen)->moduleName = curStatCounterEntry->moduleName;
|
||||||
|
(registrationList + registrationListLen)->name = curCounterDef->name;
|
||||||
|
|
||||||
|
netsnmp_handler_registration *rinfo =
|
||||||
|
netsnmp_create_handler_registration((registrationList + registrationListLen)->nameRegistrationName,
|
||||||
|
handler,
|
||||||
|
(registrationList + registrationListLen)->nameOid ,
|
||||||
|
(registrationList + registrationListLen)->nameOidLen,
|
||||||
|
HANDLER_CAN_RONLY);
|
||||||
|
netsnmp_register_instance(rinfo);
|
||||||
|
|
||||||
|
rinfo =
|
||||||
|
netsnmp_create_handler_registration((registrationList + registrationListLen)->valueRegistrationName,
|
||||||
|
handler,
|
||||||
|
(registrationList + registrationListLen)->valueOid ,
|
||||||
|
(registrationList + registrationListLen)->valueOidLen,
|
||||||
|
HANDLER_CAN_RONLY);
|
||||||
|
netsnmp_register_instance(rinfo);
|
||||||
|
|
||||||
|
registrationListLen++;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void map_var_cnt(int cnt, char* var) {
|
|
||||||
var_cnt_map = (var_cnt_map_t*) realloc(var_cnt_map, sizeof(var_cnt_map_t) * (num_var_cnt_map + 1));
|
|
||||||
var_cnt_map[num_var_cnt_map].var = var;
|
|
||||||
var_cnt_map[num_var_cnt_map].cnt = cnt;
|
|
||||||
num_var_cnt_map++;
|
|
||||||
}
|
|
||||||
|
|
||||||
#define NETSNMP_REGISTER_SCALAR(A, B, C) netsnmp_register_scalar(netsnmp_create_handler_registration(#A, B, A##_oid, OID_LENGTH(A##_oid), HANDLER_CAN_RONLY)); map_var_cnt(C, #A)
|
|
||||||
|
|
||||||
void
|
|
||||||
init_dhsMIBObjects(void)
|
|
||||||
{
|
|
||||||
static oid dhsNumber1_oid[] = { 1,3,6,1,4,1,9676,2,1,1 };
|
|
||||||
static oid dhsAccepted_oid[] = { 1,3,6,1,4,1,9676,2,1,2,1 };
|
|
||||||
static oid dhsFailed_oid[] = { 1,3,6,1,4,1,9676,2,1,2,2 };
|
|
||||||
static oid dhsRunningNwThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,2,3 };
|
|
||||||
static oid dhsNwThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,2,4 };
|
|
||||||
static oid dhsFailedNwThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,2,5 };
|
|
||||||
static oid dhsOKReturned_oid[] = { 1,3,6,1,4,1,9676,2,1,2,6 };
|
|
||||||
static oid dhsTEMPReturned_oid[] = { 1,3,6,1,4,1,9676,2,1,2,7 };
|
|
||||||
static oid dhsPERMReturned_oid[] = { 1,3,6,1,4,1,9676,2,1,2,8 };
|
|
||||||
static oid dhsNOTFOUNDReturned_oid[] = { 1,3,6,1,4,1,9676,2,1,2,9 };
|
|
||||||
static oid dhsIllegalInputFailure_oid[] = { 1,3,6,1,4,1,9676,2,1,2,10 };
|
|
||||||
static oid dhsUnknownClassFailure_oid[] = { 1,3,6,1,4,1,9676,2,1,2,11 };
|
|
||||||
static oid dhsTimeoutFailure_oid[] = { 1,3,6,1,4,1,9676,2,1,2,12 };
|
|
||||||
static oid dhsNetStringFailure_oid[] = { 1,3,6,1,4,1,9676,2,1,2,13 };
|
|
||||||
|
|
||||||
static oid dhsVCacheEntries_oid[] = { 1,3,6,1,4,1,9676,2,1,3,1 };
|
|
||||||
static oid dhsVRunningWorkerThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,3,2 };
|
|
||||||
static oid dhsVWorkerThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,3,3 };
|
|
||||||
static oid dhsVFailedWorkerThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,3,4 };
|
|
||||||
static oid dhsVTimedOutWorkerThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,3,5 };
|
|
||||||
static oid dhsVRunningCheckerThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,3,6 };
|
|
||||||
static oid dhsVCheckerThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,3,7 };
|
|
||||||
static oid dhsVFailedCheckerThreads_oid[] = { 1,3,6,1,4,1,9676,2,1,3,8 };
|
|
||||||
static oid dhsVAnsweredFromCache_oid[] = { 1,3,6,1,4,1,9676,2,1,3,9 };
|
|
||||||
static oid dhsVReturnedOK_oid[] = { 1,3,6,1,4,1,9676,2,1,3,10 };
|
|
||||||
static oid dhsVReturnedNOK_oid[] = { 1,3,6,1,4,1,9676,2,1,3,11 };
|
|
||||||
static oid dhsVReturnedTNOK_oid[] = { 1,3,6,1,4,1,9676,2,1,3,12 };
|
|
||||||
|
|
||||||
static oid dhsCWorker_oid[] = { 1,3,6,1,4,1,9676,2,1,4,1 };
|
|
||||||
static oid dhsCIllegalInput_oid[] = { 1,3,6,1,4,1,9676,2,1,4,2 };
|
|
||||||
static oid dhsCDepotDNSFailure_oid[] = { 1,3,6,1,4,1,9676,2,1,4,3 };
|
|
||||||
static oid dhsCReturnedOK_oid[] = { 1,3,6,1,4,1,9676,2,1,4,4 };
|
|
||||||
static oid dhsCReturnedNOK_oid[] = { 1,3,6,1,4,1,9676,2,1,4,5 };
|
|
||||||
static oid dhsCReturnedTNOK_oid[] = { 1,3,6,1,4,1,9676,2,1,4,6 };
|
|
||||||
|
|
||||||
|
|
||||||
DEBUGMSGTL(("dhsMIBObjects", "Initializing\n"));
|
|
||||||
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsNumber1, handle_number1, 0);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsAccepted, handle_counter32, STAT_CNT_ACCEPTED);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsFailed, handle_counter32, STAT_CNT_FAILED);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsRunningNwThreads, handle_integer32, STAT_CNT_NETWORKER_R_THREADS);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsNwThreads, handle_counter32, STAT_CNT_NETWORKER_THREADS);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsFailedNwThreads, handle_counter32, STAT_CNT_NETWORKER_THREADS_FAILED);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsOKReturned, handle_counter32, SMM_OK+STAT_CNT_OFFSET);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsTEMPReturned, handle_counter32, SMM_TEMP_NOK+STAT_CNT_OFFSET);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsPERMReturned, handle_counter32, SMM_PERM_NOK+STAT_CNT_OFFSET);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsNOTFOUNDReturned, handle_counter32, SMM_NOT_FOUND_NOK+STAT_CNT_OFFSET);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsIllegalInputFailure, handle_counter32, SMM_ILLEGAL_INPUT+STAT_CNT_OFFSET);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsUnknownClassFailure, handle_counter32, SMM_UNKNOWN_CLASS+STAT_CNT_OFFSET);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsTimeoutFailure, handle_counter32, SMM_TIMEOUT_NOK+STAT_CNT_OFFSET);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsNetStringFailure, handle_counter32, SMM_NETSTRING_UNPARSABLE+STAT_CNT_OFFSET);
|
|
||||||
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVCacheEntries, handle_integer32, STAT_CNT_VERIFIER_CACHE);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVRunningWorkerThreads, handle_integer32, STAT_CNT_VERIFIER_WORKER_R_THREADS);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVWorkerThreads, handle_counter32, STAT_CNT_VERIFIER_WORKER_THREADS);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVFailedWorkerThreads, handle_counter32, STAT_CNT_VERIFIER_WORKER_THREADS_FAILED);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVTimedOutWorkerThreads, handle_counter32, STAT_CNT_VERIFIER_WORKER_THREADS_TIMEOUT);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVRunningCheckerThreads, handle_integer32, STAT_CNT_VERIFIER_CHECKER_R_THREADS);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVCheckerThreads, handle_counter32, STAT_CNT_VERIFIER_CHECKER_THREADS);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVFailedCheckerThreads, handle_counter32, STAT_CNT_VERIFIER_CHECKER_THREADS_FAILED);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVAnsweredFromCache, handle_counter32, STAT_CNT_VERIFIER_ANSWERED_FROM_CACHE);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVReturnedOK, handle_counter32, STAT_CNT_VERIFIER_RETURNED_OK);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVReturnedNOK, handle_counter32, STAT_CNT_VERIFIER_RETURNED_NOK);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsVReturnedTNOK, handle_counter32, STAT_CNT_VERIFIER_RETURNED_TNOK);
|
|
||||||
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsCWorker, handle_counter32, STAT_CNT_CYRUS_WORKER);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsCIllegalInput, handle_counter32, STAT_CNT_CYRUS_ILLEGAL_INPUT);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsCDepotDNSFailure, handle_counter32, STAT_CNT_CYRUS_DEPOT_DNS_FAILURE);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsCReturnedOK, handle_counter32, STAT_CNT_CYRUS_RETURNED_OK);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsCReturnedNOK, handle_counter32, STAT_CNT_CYRUS_RETURNED_NOK);
|
|
||||||
NETSNMP_REGISTER_SCALAR(dhsCReturnedTNOK, handle_counter32, STAT_CNT_CYRUS_RETURNED_TNOK);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
void snmp_subagent_main(cfg_t *cfg) {
|
void snmp_subagent_main(cfg_t *cfg) {
|
||||||
snmp_enable_syslog_ident("smmapd", LOG_LOCAL2);
|
snmp_enable_syslog_ident("smmapd", LOG_LOCAL2);
|
||||||
@ -210,7 +175,7 @@ void snmp_subagent_main(cfg_t *cfg) {
|
|||||||
|
|
||||||
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
|
netsnmp_ds_set_boolean(NETSNMP_DS_APPLICATION_ID, NETSNMP_DS_AGENT_ROLE, 1);
|
||||||
init_agent("smmapd_subagent");
|
init_agent("smmapd_subagent");
|
||||||
init_dhsMIBObjects();
|
init_dhsMIBObjects(cfg);
|
||||||
init_snmp("smmapd_subagent");
|
init_snmp("smmapd_subagent");
|
||||||
|
|
||||||
while(1) {
|
while(1) {
|
||||||
@ -220,3 +185,5 @@ void snmp_subagent_main(cfg_t *cfg) {
|
|||||||
snmp_shutdown("mysubagent");
|
snmp_shutdown("mysubagent");
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -24,9 +24,29 @@
|
|||||||
#define _SNMP_SUBAGENT_H_
|
#define _SNMP_SUBAGENT_H_
|
||||||
|
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
#include "count.h"
|
||||||
#include "cfg.h"
|
#include "cfg.h"
|
||||||
|
|
||||||
|
|
||||||
#if ENABLE_NETSNMP==1
|
#if ENABLE_NETSNMP==1
|
||||||
|
#include <net-snmp/net-snmp-config.h>
|
||||||
|
#include <net-snmp/net-snmp-includes.h>
|
||||||
|
#include <net-snmp/agent/net-snmp-agent-includes.h>
|
||||||
|
|
||||||
|
|
||||||
|
typedef struct registrationEntry_s {
|
||||||
|
oid *nameOid;
|
||||||
|
int nameOidLen;
|
||||||
|
char *nameRegistrationName;
|
||||||
|
oid *valueOid;
|
||||||
|
int valueOidLen;
|
||||||
|
char *valueRegistrationName;
|
||||||
|
int type;
|
||||||
|
count_t *counter;
|
||||||
|
const char *moduleName;
|
||||||
|
const char *name;
|
||||||
|
} registrationEntry_t;
|
||||||
|
|
||||||
void snmp_subagent_main(cfg_t *cfg);
|
void snmp_subagent_main(cfg_t *cfg);
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[Global]
|
[Global]
|
||||||
Host: ddev8.eng.emea.uu.net
|
Host: 127.0.0.1
|
||||||
Port: 389
|
Port: 8887
|
||||||
Threads: 20
|
Threads: 20
|
||||||
|
|
||||||
[Verifier]
|
[Verifier]
|
||||||
|
@ -55,8 +55,42 @@
|
|||||||
#define SMM_LOCAL_OK 103
|
#define SMM_LOCAL_OK 103
|
||||||
|
|
||||||
|
|
||||||
|
/* --- statistics counter --- */
|
||||||
|
|
||||||
|
#define STAT_CNT_VERIFIER_CACHE 0
|
||||||
|
#define STAT_CNT_VERIFIER_WORKER_R_THREADS 1
|
||||||
|
#define STAT_CNT_VERIFIER_WORKER_THREADS 2
|
||||||
|
#define STAT_CNT_VERIFIER_WORKER_THREADS_FAILED 3
|
||||||
|
#define STAT_CNT_VERIFIER_WORKER_THREADS_TIMEOUT 4
|
||||||
|
#define STAT_CNT_VERIFIER_CHECKER_R_THREADS 5
|
||||||
|
#define STAT_CNT_VERIFIER_CHECKER_THREADS 6
|
||||||
|
#define STAT_CNT_VERIFIER_CHECKER_THREADS_FAILED 7
|
||||||
|
#define STAT_CNT_VERIFIER_ANSWERED_FROM_CACHE 8
|
||||||
|
#define STAT_CNT_VERIFIER_RETURNED_OK 9
|
||||||
|
#define STAT_CNT_VERIFIER_RETURNED_NOK 10
|
||||||
|
#define STAT_CNT_VERIFIER_RETURNED_TNOK 11
|
||||||
|
|
||||||
|
counterDef_t *verify_counterDefs = NULL;
|
||||||
|
void verify_setupCounterList() {
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_GAUGE, "Verifier: entries in cache");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_GAUGE, "Verifier: running worker threads");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: worker threads");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: failed to start, worker threads");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: timed out worker threads");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_GAUGE, "Verifier: running checker threads");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: checker threads");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: failed to start, checker threads");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: answered from cache");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: returned OK");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: returned NOK");
|
||||||
|
verify_counterDefs = addOneCounterDef(verify_counterDefs, SMM_TYPE_COUNTER, "Verifier: returned TNOK");
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
struct verify_container_handle_s {
|
struct verify_container_handle_s {
|
||||||
cfgl_t *cfg;
|
cfgl_t *cfg;
|
||||||
|
statCounter_t *statCounter;
|
||||||
int timeout_result;
|
int timeout_result;
|
||||||
int timeout_dialog;
|
int timeout_dialog;
|
||||||
|
|
||||||
@ -181,7 +215,13 @@ int verify_init(cfgl_t *cfg, void **handle) {
|
|||||||
vch->cache = NULL;
|
vch->cache = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
verify_setupCounterList();
|
||||||
|
vch->statCounter = initStatCounter("verifier", verify_counterDefs);
|
||||||
|
|
||||||
*handle = vch;
|
*handle = vch;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,6 +234,8 @@ int verify_destroy(void *handle) {
|
|||||||
htcache_destroy(vch->cache);
|
htcache_destroy(vch->cache);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* FIXME The statCounter structure should be freed too, however, as this won't ever be called ... */
|
||||||
|
|
||||||
free(vch);
|
free(vch);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@ -239,7 +281,7 @@ int verify_work_destroy(void *handle, void *work_handle) {
|
|||||||
/* clean up the checker stuff */
|
/* clean up the checker stuff */
|
||||||
|
|
||||||
pthread_join(ct->thread, NULL);
|
pthread_join(ct->thread, NULL);
|
||||||
decStatCounter(STAT_CNT_VERIFIER_CHECKER_R_THREADS);
|
decStatCounter(vwh->vch->statCounter, STAT_CNT_VERIFIER_CHECKER_R_THREADS);
|
||||||
syslog(LOG_DEBUG, "verify (%p) verify_work_destroy, checker_thread (id=%d) joined",
|
syslog(LOG_DEBUG, "verify (%p) verify_work_destroy, checker_thread (id=%d) joined",
|
||||||
work_handle, ct->id);
|
work_handle, ct->id);
|
||||||
|
|
||||||
@ -250,7 +292,7 @@ int verify_work_destroy(void *handle, void *work_handle) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
err = pthread_join(wt->thread, NULL);
|
err = pthread_join(wt->thread, NULL);
|
||||||
decStatCounter(STAT_CNT_VERIFIER_WORKER_R_THREADS);
|
decStatCounter(vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_R_THREADS);
|
||||||
syslog(LOG_DEBUG, "verify (%p) verify_work_destroy, worker_thread (id=%d) joined",
|
syslog(LOG_DEBUG, "verify (%p) verify_work_destroy, worker_thread (id=%d) joined",
|
||||||
work_handle, wt->id);
|
work_handle, wt->id);
|
||||||
free(wt->input);
|
free(wt->input);
|
||||||
@ -349,11 +391,13 @@ int cache_lookup(verify_work_handle_t *vwh, const char* address, int *result, ch
|
|||||||
|
|
||||||
#define PERM_NOK_RETURN(msg) \
|
#define PERM_NOK_RETURN(msg) \
|
||||||
syslog(LOG_ERR, "verify (%p) verify_work: %s", vwh, msg); \
|
syslog(LOG_ERR, "verify (%p) verify_work: %s", vwh, msg); \
|
||||||
snprintf(output, ANSWER_BUFSIZE, "verify_work: %s", msg); \
|
htbuffer_strcat(output, "verify_work: "); \
|
||||||
|
htbuffer_strcat(output, msg); \
|
||||||
return SMM_PERM_NOK;
|
return SMM_PERM_NOK;
|
||||||
#define TEMP_NOK_RETURN(msg) \
|
#define TEMP_NOK_RETURN(msg) \
|
||||||
syslog(LOG_ERR, "verify (%p) verify_work: %s", vwh, msg); \
|
syslog(LOG_ERR, "verify (%p) verify_work: %s", vwh, msg); \
|
||||||
snprintf(output, ANSWER_BUFSIZE, "verify_work: %s", msg); \
|
htbuffer_strcat(output, "verify_work: "); \
|
||||||
|
htbuffer_strcat(output, msg); \
|
||||||
return SMM_TEMP_NOK;
|
return SMM_TEMP_NOK;
|
||||||
|
|
||||||
int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output) {
|
int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output) {
|
||||||
@ -390,7 +434,7 @@ int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output
|
|||||||
pthread_mutex_lock(vwh->result_mutex);
|
pthread_mutex_lock(vwh->result_mutex);
|
||||||
err = pthread_create(&tid, NULL, &worker_thread, wt);
|
err = pthread_create(&tid, NULL, &worker_thread, wt);
|
||||||
if (-1 == err) {
|
if (-1 == err) {
|
||||||
incStatCounter(STAT_CNT_VERIFIER_WORKER_THREADS_FAILED);
|
incStatCounter(vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_THREADS_FAILED);
|
||||||
free(wt->input);
|
free(wt->input);
|
||||||
free(wt);
|
free(wt);
|
||||||
PERM_NOK_RETURN("unable to create worker thread");
|
PERM_NOK_RETURN("unable to create worker thread");
|
||||||
@ -402,7 +446,7 @@ int verify_work(void *handle, void *work_handle, char *input, htbuffer_t *output
|
|||||||
err = pthread_cond_timedwait(vwh->result_cond, vwh->result_mutex, &ts);
|
err = pthread_cond_timedwait(vwh->result_cond, vwh->result_mutex, &ts);
|
||||||
pthread_mutex_unlock(vwh->result_mutex);
|
pthread_mutex_unlock(vwh->result_mutex);
|
||||||
if (ETIMEDOUT == err) {
|
if (ETIMEDOUT == err) {
|
||||||
incStatCounter(STAT_CNT_VERIFIER_WORKER_THREADS_TIMEOUT);
|
incStatCounter(vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_THREADS_TIMEOUT);
|
||||||
TEMP_NOK_RETURN("worker thread timed out");
|
TEMP_NOK_RETURN("worker thread timed out");
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -478,8 +522,8 @@ static void *checker_thread(void *arg) {
|
|||||||
|
|
||||||
ct->thread = pthread_self();
|
ct->thread = pthread_self();
|
||||||
|
|
||||||
incStatCounter(STAT_CNT_VERIFIER_CHECKER_THREADS);
|
incStatCounter(ct->vwh->vch->statCounter, STAT_CNT_VERIFIER_CHECKER_THREADS);
|
||||||
incStatCounter(STAT_CNT_VERIFIER_CHECKER_R_THREADS);
|
incStatCounter(ct->vwh->vch->statCounter, STAT_CNT_VERIFIER_CHECKER_R_THREADS);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Connect to ct->ip_address using ct->email_address,
|
Connect to ct->ip_address using ct->email_address,
|
||||||
@ -604,8 +648,8 @@ static void *worker_thread(void *arg) {
|
|||||||
|
|
||||||
wt->thread = pthread_self();
|
wt->thread = pthread_self();
|
||||||
|
|
||||||
incStatCounter(STAT_CNT_VERIFIER_WORKER_R_THREADS);
|
incStatCounter(wt->vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_R_THREADS);
|
||||||
incStatCounter(STAT_CNT_VERIFIER_WORKER_THREADS);
|
incStatCounter(wt->vwh->vch->statCounter, STAT_CNT_VERIFIER_WORKER_THREADS);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -618,7 +662,7 @@ static void *worker_thread(void *arg) {
|
|||||||
if (0 == cache_lookup(wt->vwh, wt->input, &result, &cached_output)) {
|
if (0 == cache_lookup(wt->vwh, wt->input, &result, &cached_output)) {
|
||||||
syslog(LOG_DEBUG, "verify (%p) worker_thread: got a cached result for %s -> %d, %s",
|
syslog(LOG_DEBUG, "verify (%p) worker_thread: got a cached result for %s -> %d, %s",
|
||||||
wt->vwh, wt->input, result, cached_output);
|
wt->vwh, wt->input, result, cached_output);
|
||||||
incStatCounter(STAT_CNT_VERIFIER_ANSWERED_FROM_CACHE);
|
incStatCounter(wt->vwh->vch->statCounter, STAT_CNT_VERIFIER_ANSWERED_FROM_CACHE);
|
||||||
wt->output = cached_output;
|
wt->output = cached_output;
|
||||||
} else {
|
} else {
|
||||||
domain_part += 1;
|
domain_part += 1;
|
||||||
@ -650,7 +694,7 @@ static void *worker_thread(void *arg) {
|
|||||||
|
|
||||||
err = pthread_create(&tid, NULL, &checker_thread, ct);
|
err = pthread_create(&tid, NULL, &checker_thread, ct);
|
||||||
if (-1 == err) {
|
if (-1 == err) {
|
||||||
incStatCounter(STAT_CNT_VERIFIER_CHECKER_THREADS_FAILED);
|
incStatCounter(ct->vwh->vch->statCounter, STAT_CNT_VERIFIER_CHECKER_THREADS_FAILED);
|
||||||
syslog(LOG_ERR, "verify (%p) worker_thread: unable to create checker thread", wt->vwh);
|
syslog(LOG_ERR, "verify (%p) worker_thread: unable to create checker thread", wt->vwh);
|
||||||
free(ct);
|
free(ct);
|
||||||
} else {
|
} else {
|
||||||
@ -670,7 +714,7 @@ static void *worker_thread(void *arg) {
|
|||||||
wt->input, ct->result, ct->output);
|
wt->input, ct->result, ct->output);
|
||||||
|
|
||||||
pthread_join(ct->thread, NULL);
|
pthread_join(ct->thread, NULL);
|
||||||
decStatCounter(STAT_CNT_VERIFIER_CHECKER_R_THREADS);
|
decStatCounter(ct->vwh->vch->statCounter, STAT_CNT_VERIFIER_CHECKER_R_THREADS);
|
||||||
syslog(LOG_DEBUG, "verify (%p) worker_thread: checker thread joined", wt->vwh);
|
syslog(LOG_DEBUG, "verify (%p) worker_thread: checker thread joined", wt->vwh);
|
||||||
|
|
||||||
if ((SMM_LOCAL_TEMP_NOK != ct->result) &&
|
if ((SMM_LOCAL_TEMP_NOK != ct->result) &&
|
||||||
@ -710,17 +754,17 @@ static void *worker_thread(void *arg) {
|
|||||||
switch (result) {
|
switch (result) {
|
||||||
case SMM_LOCAL_TEMP_NOK:
|
case SMM_LOCAL_TEMP_NOK:
|
||||||
sprintf(wt->result->output, "<TNOK><%s>", wt->output);
|
sprintf(wt->result->output, "<TNOK><%s>", wt->output);
|
||||||
incStatCounter(STAT_CNT_VERIFIER_RETURNED_TNOK);
|
incStatCounter(wt->vwh->vch->statCounter, STAT_CNT_VERIFIER_RETURNED_TNOK);
|
||||||
result = SMM_OK;
|
result = SMM_OK;
|
||||||
break;
|
break;
|
||||||
case SMM_LOCAL_PERM_NOK:
|
case SMM_LOCAL_PERM_NOK:
|
||||||
sprintf(wt->result->output, "<NOK><%s>", wt->output);
|
sprintf(wt->result->output, "<NOK><%s>", wt->output);
|
||||||
incStatCounter(STAT_CNT_VERIFIER_RETURNED_NOK);
|
incStatCounter(wt->vwh->vch->statCounter, STAT_CNT_VERIFIER_RETURNED_NOK);
|
||||||
result = SMM_OK;
|
result = SMM_OK;
|
||||||
break;
|
break;
|
||||||
case SMM_LOCAL_OK:
|
case SMM_LOCAL_OK:
|
||||||
sprintf(wt->result->output, "<OK><%s>", wt->output);
|
sprintf(wt->result->output, "<OK><%s>", wt->output);
|
||||||
incStatCounter(STAT_CNT_VERIFIER_RETURNED_OK);
|
incStatCounter(wt->vwh->vch->statCounter, STAT_CNT_VERIFIER_RETURNED_OK);
|
||||||
result = SMM_OK;
|
result = SMM_OK;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user