diff options
Diffstat (limited to 'src/varnish_mib.mib2c')
-rw-r--r-- | src/varnish_mib.mib2c | 227 |
1 files changed, 122 insertions, 105 deletions
diff --git a/src/varnish_mib.mib2c b/src/varnish_mib.mib2c index 9d49ce9..a458723 100644 --- a/src/varnish_mib.mib2c +++ b/src/varnish_mib.mib2c @@ -1,5 +1,5 @@ # This file is part of varnish-mib -*- c -*- -# Copyright (C) 2014-2016 Sergey Poznyakoff +# Copyright (C) 2014-2018 Sergey Poznyakoff # # Varnish-mib is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -25,80 +25,79 @@ @enddefine@ @startperl@ $vars{'varnish_translate_table'} = { - uptime => [ 'MAIN', 'uptime' ], - clientAcceptedConnections => [ 'MAIN', 'sess_conn' ], - clientRequestsReceived => [ 'MAIN', 'client_req' ], - clientCacheHits => [ 'MAIN', 'cache_hit' ], - clientCacheHitsPass => [ 'MAIN', 'cache_hitpass' ], - clientCacheMisses => [ 'MAIN', 'cache_miss' ], + uptime => [ 'DICT', 'MAIN.uptime' ], + clientAcceptedConnections => [ 'DICT', 'MAIN.sess_conn' ], + clientCacheHits => [ 'DICT', 'MAIN.cache_hit' ], + clientCacheHitsPass => [ 'DICT', 'MAIN.cache_hitpass' ], + clientCacheMisses => [ 'DICT', 'MAIN.cache_miss' ], clientBan => [ 'STRING', '', { varnish_set_action => 'varnish_ban' } ], - clientRequestsReceived => [ 'MAIN', 'client_req' ], - clientRequests400 => [ 'MAIN', 'client_req_400' ], - clientRequests411 => [ 'MAIN', 'client_req_411' ], - clientRequests413 => [ 'MAIN', 'client_req_413' ], - clientRequests417 => [ 'MAIN', 'client_req_417' ], + clientRequestsReceived => [ 'DICT', 'MAIN.client_req' ], + clientRequests400 => [ 'DICT', 'MAIN.client_req_400' ], + clientRequests411 => [ 'NULL', 'MAIN.client_req_411' ], + clientRequests413 => [ 'NULL', 'MAIN.client_req_413' ], + clientRequests417 => [ 'DICT', 'MAIN.client_req_417' ], - backendConnSuccess => [ 'MAIN', 'backend_conn' ], - backendConnNotAttempted => [ 'MAIN', 'backend_unhealthy' ], - backendConnToMany => [ 'MAIN', 'backend_busy' ], - backendConnFailures => [ 'MAIN', 'backend_fail' ], - backendConnReuses => [ 'MAIN', 'backend_reuse' ], - backendConnRecycled => [ 'MAIN', 'backend_recycle' ], - backendConnUnused => [ 'MAIN', 'backend_toolate' ], - backendConnRetry => [ 'MAIN', 'backend_retry' ], - backendRequests => [ 'MAIN', 'backend_req' ], + backendConnSuccess => [ 'DICT', 'MAIN.backend_conn' ], + backendConnNotAttempted => [ 'DICT', 'MAIN.backend_unhealthy' ], + backendConnToMany => [ 'DICT', 'MAIN.backend_busy' ], + backendConnFailures => [ 'DICT', 'MAIN.backend_fail' ], + backendConnReuses => [ 'DICT', 'MAIN.backend_reuse' ], + backendConnRecycled => [ 'DICT', 'MAIN.backend_recycle' ], + backendConnUnused => [ 'NULL', 'MAIN.backend_toolate' ], + backendConnRetry => [ 'DICT', 'MAIN.backend_retry' ], + backendRequests => [ 'DICT', 'MAIN.backend_req' ], - totalSessions => [ 'MAIN', 's_sess' ], - totalRequests => [ 'MAIN', 's_req' ], - totalPipe => [ 'MAIN', 's_pipe' ], - totalPass => [ 'MAIN', 's_pass' ], - totalFetch => [ 'MAIN', 's_fetch' ], - totalRequestHeaderBytes => [ 'MAIN', 's_req_hdrbytes' ], - totalRequestBodyBytes => [ 'MAIN', 's_req_bodybytes' ], - totalResponseHeaderBytes => [ 'MAIN', 's_resp_hdrbytes' ], - totalResponseBodyBytes => [ 'MAIN', 's_resp_bodybytes' ], - totalPipeHeaderBytes => [ 'MAIN', 's_pipe_hdrbytes' ], - totalPipeIn => [ 'MAIN', 's_pipe_in' ], - totalPipeOut => [ 'MAIN', 's_pipe_out' ], + totalSessions => [ 'DICT', 'MAIN.s_sess' ], + totalRequests => [ 'DICT', 'MAIN.client_req' ], + totalPipe => [ 'DICT', 'MAIN.s_pipe' ], + totalPass => [ 'DICT', 'MAIN.s_pass' ], + totalFetch => [ 'DICT', 'MAIN.s_fetch' ], + totalRequestHeaderBytes => [ 'DICT', 'MAIN.s_req_hdrbytes' ], + totalRequestBodyBytes => [ 'DICT', 'MAIN.s_req_bodybytes' ], + totalResponseHeaderBytes => [ 'DICT', 'MAIN.s_resp_hdrbytes' ], + totalResponseBodyBytes => [ 'DICT', 'MAIN.s_resp_bodybytes' ], + totalPipeHeaderBytes => [ 'DICT', 'MAIN.s_pipe_hdrbytes' ], + totalPipeIn => [ 'DICT', 'MAIN.s_pipe_in' ], + totalPipeOut => [ 'DICT', 'MAIN.s_pipe_out' ], - sessAccepted => [ 'MAIN', 'sess_conn'], - sessQueued => [ 'MAIN', 'sess_queued'], - sessDropped => [ 'MAIN', 'sess_dropped'], - sessClosed => [ 'MAIN', 'sess_closed'], - sessPipeline => [ 'MAIN', 'sess_pipeline'], - sessReadAhead => [ 'MAIN', 'sess_readahead'], - sessHerd => [ 'MAIN', 'sess_herd'], - sessDrop => [ 'MAIN', 'sess_drop'], - sessFail => [ 'MAIN', 'sess_fail'], - sessPipeOverflow => [ 'MAIN', 'sess_pipe_overflow'], - - threadsPools => [ 'MAIN', 'pools'], - threadsTotal => [ 'MAIN', 'threads'], - threadsLimitHits => [ 'MAIN', 'threads_limited'], - threadsCreated => [ 'MAIN', 'threads_created'], - threadsDestroyed => [ 'MAIN', 'threads_destroyed'], - threadsFailed => [ 'MAIN', 'threads_failed'], - threadsQueueLength => [ 'MAIN', 'thread_queue_len'], - - bansTotal => [ 'MAIN', 'bans' ], - bansCompleted => [ 'MAIN', 'bans_completed' ], - bansObj => [ 'MAIN', 'bans_obj' ], - bansReq => [ 'MAIN', 'bans_req' ], - bansAdded => [ 'MAIN', 'bans_added' ], - bansDeleted => [ 'MAIN', 'bans_deleted' ], - bansTested => [ 'MAIN', 'bans_tested' ], - bansObjectsKilled => [ 'MAIN', 'bans_obj_killed' ], - bansLurkerTested => [ 'MAIN', 'bans_lurker_tested' ], - bansTestTested => [ 'MAIN', 'bans_tests_tested' ], - bansLurkerTestTested => [ 'MAIN', 'bans_lurker_tests_tested' ], - bansLurkerObjKilled => [ 'MAIN', 'bans_lurker_obj_killed' ], - bansDups => [ 'MAIN', 'bans_dups' ], - bansLurkerContention => [ 'MAIN', 'bans_lurker_contention' ], - bansPersistedBytes => [ 'MAIN', 'bans_persisted_bytes' ], - bansPersistedFragmentation => [ 'MAIN', 'bans_persisted_fragmentation' ], + sessAccepted => [ 'DICT', 'MAIN.sess_conn'], + sessQueued => [ 'DICT', 'MAIN.sess_queued'], + sessDropped => [ 'DICT', 'MAIN.sess_dropped'], + sessClosed => [ 'DICT', 'MAIN.sess_closed'], + sessPipeline => [ 'DICT', 'MAIN.s_pipe'], + sessReadAhead => [ 'DICT', 'MAIN.sess_readahead'], + sessHerd => [ 'DICT', 'MAIN.sess_herd'], + sessDrop => [ 'DICT', 'MAIN.sess_drop'], + sessFail => [ 'DICT', 'MAIN.sess_fail'], + sessPipeOverflow => [ 'DICT', 'MAIN.sc_pipe_overflow'], + + threadsPools => [ 'DICT', 'MAIN.pools'], + threadsTotal => [ 'DICT', 'MAIN.threads'], + threadsLimitHits => [ 'DICT', 'MAIN.threads_limited'], + threadsCreated => [ 'DICT', 'MAIN.threads_created'], + threadsDestroyed => [ 'DICT', 'MAIN.threads_destroyed'], + threadsFailed => [ 'DICT', 'MAIN.threads_failed'], + threadsQueueLength => [ 'DICT', 'MAIN.thread_queue_len'], + + bansTotal => [ 'DICT', 'MAIN.bans' ], + bansCompleted => [ 'DICT', 'MAIN.bans_completed' ], + bansObj => [ 'DICT', 'MAIN.bans_obj' ], + bansReq => [ 'DICT', 'MAIN.bans_req' ], + bansAdded => [ 'DICT', 'MAIN.bans_added' ], + bansDeleted => [ 'DICT', 'MAIN.bans_deleted' ], + bansTested => [ 'DICT', 'MAIN.bans_tested' ], + bansObjectsKilled => [ 'DICT', 'MAIN.bans_obj_killed' ], + bansLurkerTested => [ 'DICT', 'MAIN.bans_lurker_tested' ], + bansTestTested => [ 'DICT', 'MAIN.bans_tests_tested' ], + bansLurkerTestTested => [ 'DICT', 'MAIN.bans_lurker_tests_tested' ], + bansLurkerObjKilled => [ 'DICT', 'MAIN.bans_lurker_obj_killed' ], + bansDups => [ 'DICT', 'MAIN.bans_dups' ], + bansLurkerContention => [ 'DICT', 'MAIN.bans_lurker_contention' ], + bansPersistedBytes => [ 'DICT', 'MAIN.bans_persisted_bytes' ], + bansPersistedFragmentation => [ 'DICT', 'MAIN.bans_persisted_fragmentation' ], }; @@ -118,13 +117,6 @@ $vars{'varnish_translate'} = sub { } else { delete $vars{$setkw}; } - if ($vars{'varnish_type'} eq 'MAIN') { - $vars{'varnish_if'} = "#if HAVE_STRUCT_VSC_C_MAIN_" . uc($vars{'varnish_member'}); - $vars{'varnish_endif'} = '#endif'; - } else { - delete $vars{'varnish_if'}; - delete $vars{'varnish_endif'} - } return 0; }; @@ -176,16 +168,16 @@ int vcli_read_response(vcli_conn_t *conn); int vcli_vasprintf(vcli_conn_t *conn, const char *fmt, va_list ap); int vcli_asprintf(vcli_conn_t *conn, const char *fmt, ...); void vcli_disconnect(vcli_conn_t *conn); -int vcli_connect(struct VSM_data *vd, vcli_conn_t *conn); +int vcli_connect(struct vsm *vsm, vcli_conn_t *conn); -struct VSM_data *varnish_get_vsm_data(void); +struct vsm *varnish_get_vsm_data(void); int varnish_auth_response(const char *file, const char *challenge, char response[CLI_AUTH_RESPONSE_LEN + 1]); int varnish_ban(netsnmp_agent_request_info *reqinfo, netsnmp_request_info *requests, - struct VSM_data *vd); + struct vsm *vsm); int varnish_mib_timeout_parser(const char *token, char *line, unsigned *retval); @@ -193,36 +185,49 @@ int varnish_mib_timeout_parser(const char *token, char *line, void varnish_ban_table_timeout_parser(const char *token, char *line); void varnish_vcli_timeout_parser(const char *token, char *line); -void varnish_backend_table_timeout_parser(const char *token, char *line); +int dict_lookup(char const *key, uint64_t *val); +void dict_install(struct VSC_point const *pt); +void dict_load(struct vsc *vsc); @open ${name}@ /* THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */ #include "varnish_mib.h" +#include "backend.h" -static struct VSM_data *vd; +static struct vsm *vd; +static struct vsc *vsc; void varnish_snmp_init(void) { - vd = VSM_New(); + vd = VSM_New(); + if (vd) { + vsc = VSC_New(vd); + if (vsc) { + if (VSM_Attach(vd, 2)) + fprintf(stderr, "%s\n", VSM_Error(vd)); + } + } + dict_load(vsc); } void varnish_snmp_deinit(void) { - VSM_Close(vd); + /* FIXME? */ } -struct VSM_data * +struct vsm * varnish_get_vsm_data() { - if (VSM_Abandoned(vd)) { - DEBUGMSGTL(("$modulename", "reopening vd\n")); - VSM_Close(vd); - VSM_Open(vd); - } - return vd; + if (vd) { + if (VSM_Status(vd) & (VSM_MGT_CHANGED|VSM_WRK_CHANGED)) { + DEBUGMSGTL(("$modulename", "reopening vd\n")); + dict_load(vsc); + } + } + return vd; } /* Variable handlers. @@ -251,24 +256,24 @@ handle_$i(netsnmp_mib_handler *handler, switch(reqinfo->mode) { case MODE_GET: - @if $varnish_type eq 'MAIN'@ - { - struct VSC_C_main const *st = VSC_Main(vd, NULL); + @if $varnish_type eq 'DICT'@ + { + uint64_t val; + if (dict_lookup("$varnish_member", &val)) + return SNMP_ERR_NOSUCHNAME; @if $i.type eq 'ASN_COUNTER64'@ + { struct counter64 ctr; - if (!st) - return SNMP_ERR_NOSUCHNAME; - ctr.high = st->$varnish_member >> 32; - ctr.low = st->$varnish_member & 0xffffffff; + ctr.high = val >> 32; + ctr.low = val & 0xffffffff; snmp_set_var_typed_value(requests->requestvb, $i.type, &ctr, sizeof(ctr)); + } @else@ - if (!st) - return SNMP_ERR_NOSUCHNAME; snmp_set_var_typed_value(requests->requestvb, $i.type, - &st->$varnish_member, - sizeof(st->$varnish_member)); + &val, + sizeof(val)); @end@ } @elsif $varnish_type eq 'STRING'@ @@ -297,6 +302,20 @@ handle_$i(netsnmp_mib_handler *handler, snmp_set_var_typed_value(requests->requestvb, $i.type, &$varnish_member, sizeof($varnish_member)); @end@ + @elsif $varnish_type eq 'NULL'@ + { + @if $i.type eq 'ASN_COUNTER64'@ + struct counter64 ctr = { 0, 0}; + snmp_set_var_typed_value(requests->requestvb, $i.type, + &ctr, + sizeof(ctr)); + @else@ + uint64_t val; + snmp_set_var_typed_value(requests->requestvb, $i.type, + &val, + sizeof(val)); + @end@ + } @else@ @printf "unrecognized type %s for %s" $varnish_type $i@ @end@ @@ -415,11 +434,11 @@ struct ${i}_entry { @startperl@ &{$vars{'set_field_dim'}}($vars{'c'}); @endperl@ - @if $field_dim > 0@ + @if $field_dim > 0@ $c.decl ${c}[$field_dim]; - @else@ + @else@ $c.decl *$c; - @end@ + @end@ size_t ${c}_len; @else@ $c.decl $c; @@ -567,13 +586,11 @@ $varnish_endif NULL, "varnishBanTableTimeout SECONDS")) snmp_log(LOG_ERR,"can't register config handler\n"); - if (!register_config_handler("snmpd", "varnishBackendTableTimeout", varnish_backend_table_timeout_parser, NULL, "varnishBackendTableTimeout SECONDS")) snmp_log(LOG_ERR,"can't register config handler\n"); - if (!register_config_handler("snmpd", "varnishCLIPortTimeout", varnish_vcli_timeout_parser, NULL, |