aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Poznyakoff <gray@nxc.no>2018-02-03 10:21:33 +0100
committerSergey Poznyakoff <gray@nxc.no>2018-02-03 10:21:33 +0100
commit82822c0a336018e33658aebb166819c960e92140 (patch)
tree9a31d964db56cbe447ebd4c26577b3ee500341df
parente750e533397d27186c13d16cac9c9cc64fe1a387 (diff)
downloadvarnish-mib-82822c0a336018e33658aebb166819c960e92140.tar.gz
varnish-mib-82822c0a336018e33658aebb166819c960e92140.tar.bz2
Redo varnish_translate_table and varnish_translate
-rw-r--r--src/varnish_mib.mib2c193
1 files changed, 99 insertions, 94 deletions
diff --git a/src/varnish_mib.mib2c b/src/varnish_mib.mib2c
index 404f511..7084476 100644
--- a/src/varnish_mib.mib2c
+++ b/src/varnish_mib.mib2c
@@ -25,114 +25,119 @@
@enddefine@
@startperl@
$vars{'varnish_translate_table'} = {
- 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 => [ 'DICT', 'MAIN.client_req' ],
- clientRequests400 => [ 'DICT', 'MAIN.client_req_400' ],
- clientRequests411 => [ 'NULL' ],
- clientRequests413 => [ 'NULL' ],
- clientRequests417 => [ 'DICT', 'MAIN.client_req_417' ],
+ 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 => '',
+ set_action => 'varnish_ban' ],
+
+ clientRequestsReceived => [ DICT => 'MAIN.client_req' ],
+ clientRequests400 => [ DICT => 'MAIN.client_req_400' ],
+ clientRequests411 => [ NULL ],
+ clientRequests413 => [ NULL ],
+ clientRequests417 => [ DICT => 'MAIN.client_req_417' ],
- 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' ],
- backendConnRetry => [ 'DICT', 'MAIN.backend_retry' ],
- backendRequests => [ 'DICT', '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 ],
+ backendConnRetry => [ DICT => 'MAIN.backend_retry' ],
+ backendRequests => [ DICT => 'MAIN.backend_req' ],
- 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' ],
+ 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 => [ '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' ],
-
- objectsCount => [ 'DICT', 'MAIN.n_object' ],
- objectsVampire => [ 'DICT', 'MAIN.n_vampireobject' ],
- objectsCore => [ 'DICT', 'MAIN.n_objectcore' ],
- objectsHead => [ 'DICT', 'MAIN.n_objecthead' ],
- objectsExpired => [ 'DICT', 'MAIN.n_expired' ],
- objectsLRUNuked => [ 'DICT', 'MAIN.n_lru_nuked' ],
- objectsLRUMoved => [ 'DICT', 'MAIN.n_lru_moved' ],
- objectsPurges => [ 'DICT', 'MAIN.n_purges' ],
- objectsObjPurged => [ 'DICT', 'MAIN.n_obj_purged' ],
- objectsGzip => [ 'DICT', 'MAIN.n_gzip' ],
- objectsGunzip => [ 'DICT', 'MAIN.n_gunzip' ],
-
- vclTotal => [ 'DICT', 'MAIN.n_vcl' ],
- vclAvail => [ 'DICT', 'MAIN.n_vcl_avail' ],
- vclDiscard => [ 'DICT', 'MAIN.n_vcl_discard' ],
- vclFail => [ 'DICT', 'MAIN.vcl_fail' ],
+ 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' ],
+
+ objectsCount => [ DICT => 'MAIN.n_object' ],
+ objectsVampire => [ DICT => 'MAIN.n_vampireobject' ],
+ objectsCore => [ DICT => 'MAIN.n_objectcore' ],
+ objectsHead => [ DICT => 'MAIN.n_objecthead' ],
+ objectsExpired => [ DICT => 'MAIN.n_expired' ],
+ objectsLRUNuked => [ DICT => 'MAIN.n_lru_nuked' ],
+ objectsLRUMoved => [ DICT => 'MAIN.n_lru_moved' ],
+ objectsPurges => [ DICT => 'MAIN.n_purges' ],
+ objectsObjPurged => [ DICT => 'MAIN.n_obj_purged' ],
+ objectsGzip => [ DICT => 'MAIN.n_gzip' ],
+ objectsGunzip => [ DICT => 'MAIN.n_gunzip' ],
+
+ vclTotal => [ DICT => 'MAIN.n_vcl' ],
+ vclAvail => [ DICT => 'MAIN.n_vcl_avail' ],
+ vclDiscard => [ DICT => 'MAIN.n_vcl_discard' ],
+ vclFail => [ DICT => 'MAIN.vcl_fail' ],
};
+my @reset_names;
+
$vars{'varnish_translate'} = sub {
my $name = shift;
- my $r = $vars{'varnish_translate_table'}->{$name};
- if (!defined($r)) {
+ unless (exists($vars{'varnish_translate_table'}->{$name})) {
print STDERR "no translation for $name!\n";
exit(1);
}
+ my @r = @{$vars{'varnish_translate_table'}->{$name}};
+
+ delete @vars{@reset_names} if @reset_names;
- $vars{'varnish_type'} = $r->[0];
- $vars{'varnish_member'} = $r->[1];
- if ($#{$r} == 2) {
- @vars{keys %{$r->[2]}} = values %{$r->[2]};
+ if (($vars{varnish_type} = shift @r) eq 'NULL') {
+ @reset_names = ();
} else {
- delete $vars{$setkw};
+ $vars{varnish_member} = shift @r;
}
+ my %a = @r;
+ @reset_names = map { 'varnish_' . $_ } keys %a;
+ @vars{@reset_names} = values %a;
return 0;
};
@@ -273,7 +278,7 @@ handle_$i(netsnmp_mib_handler *handler,
if (!varnish_get_vsm_data())
return SNMP_ERR_NOSUCHNAME;
- switch(reqinfo->mode) {
+ switch (reqinfo->mode) {
case MODE_GET:
@if $varnish_type eq 'DICT'@
{

Return to:

Send suggestions and report system problems to the System administrator.