aboutsummaryrefslogtreecommitdiff
path: root/src/mysqlstat-mib.mib2c
diff options
context:
space:
mode:
Diffstat (limited to 'src/mysqlstat-mib.mib2c')
-rw-r--r--src/mysqlstat-mib.mib2c250
1 files changed, 250 insertions, 0 deletions
diff --git a/src/mysqlstat-mib.mib2c b/src/mysqlstat-mib.mib2c
new file mode 100644
index 0000000..fb6e80b
--- /dev/null
+++ b/src/mysqlstat-mib.mib2c
@@ -0,0 +1,250 @@
+# This file is part of Mysqlstat -*- autoconf -*-
+# Copyright (C) 2014-2016 Sergey Poznyakoff
+#
+# Mysqlstat is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 3, or (at your option)
+# any later version.
+#
+# Mysqlstat is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with Mysqlstat. If not, see <http://www.gnu.org/licenses/>.
+
+@define ROCOM@
+/* Local variables:
+ buffer-read-only: t
+ End:
+ vi: set ro:
+*/
+@enddefine@
+@startperl@
+$vars{'mysqlstat_translate_table'} = {
+ replSlaveIOState => [
+ 'MYSQLSTAT_CACHE_REPL', 'Slave_IO_State' ],
+ replMasterLogFile => [
+ 'MYSQLSTAT_CACHE_REPL', 'Master_Log_File' ],
+ replReadMasterLogPos => [
+ 'MYSQLSTAT_CACHE_REPL', 'Read_Master_Log_Pos' ],
+ replRelayLogFile => [
+ 'MYSQLSTAT_CACHE_REPL', 'Relay_Log_File' ],
+ replRelayLogPos => [
+ 'MYSQLSTAT_CACHE_REPL', 'Relay_Log_Pos' ],
+ replRelayMasterLogFile => [
+ 'MYSQLSTAT_CACHE_REPL', 'Relay_Master_Log_File' ],
+ replSlaveIORunning => [
+ 'MYSQLSTAT_CACHE_REPL', 'Slave_IO_Running' ],
+ replSlaveSQLRunning => [
+ 'MYSQLSTAT_CACHE_REPL', 'Slave_SQL_Running' ],
+ replLastSQLErrno => [
+ 'MYSQLSTAT_CACHE_REPL', 'Last_SQL_Errno' ],
+ replLastSQLError => [
+ 'MYSQLSTAT_CACHE_REPL', 'Last_SQL_Error' ],
+ replLastIOErrno => [
+ 'MYSQLSTAT_CACHE_REPL', 'Last_IO_Errno' ],
+ replLastIOError => [
+ 'MYSQLSTAT_CACHE_REPL', 'Last_IO_Error' ],
+ replExecMasterLogPos => [
+ 'MYSQLSTAT_CACHE_REPL', 'Exec_Master_Log_Pos' ],
+ replRelayLogSpace => [
+ 'MYSQLSTAT_CACHE_REPL', 'Relay_Log_Space' ],
+ replSecondsBehindMaster => [
+ 'MYSQLSTAT_CACHE_REPL', 'Seconds_Behind_Master' ]
+};
+
+$vars{'mysqlstat_translate'} = sub {
+ my ($name) = @_;
+
+ my $r = $vars{'mysqlstat_translate_table'}->{$name};
+ if (!defined($r)) {
+ print STDERR "no translation for $name!\n";
+ exit(1);
+ }
+
+ $vars{'mysqlstat_id'} = $r->[0];
+ $vars{'mysqlstat_name'} = $r->[1];
+# $vars{'mysqlstat_type'} = $r->[2];
+ return 0;
+};
+
+$vars{'modulename'} = $vars{'name'};
+$vars{'modulename'} =~ s#.*/##;
+$vars{'modulename'} =~ s/\.c$//;
+#print "$vars{'modulename'}\n";
+
+0;
+@endperl@
+@open ${name}@
+/* THIS FILE IS GENERATED AUTOMATICALLY. PLEASE DO NOT EDIT. */
+
+#include "mysqlstat.h"
+
+/* Variable handlers.
+
+ An instance handler only hands us one request at a time, unwrapping
+ any eventual GETNEXT requests.
+*/
+
+@foreach $i scalar@
+ @startperl@
+ &{$vars{'mysqlstat_translate'}}($vars{'i'});
+ @endperl@
+
+static int
+handle_$i(netsnmp_mib_handler *handler,
+ netsnmp_handler_registration *reginfo,
+ netsnmp_agent_request_info *reqinfo,
+ netsnmp_request_info *requests)
+{
+ @if $i.settable@
+ int ret;
+ @end@
+ char const *val = mysqlstat_get($varnish_id, "$varnish_name");
+
+ if (!val)
+ return SNMP_ERR_NOSUCHNAME;
+
+ switch(reqinfo->mode) {
+ case MODE_GET:
+ @if $i.type eq 'ASN_COUNTER64'@
+ {
+ struct counter64 ctr;
+ uint64_t n = strtoull(val, NULL, 10);
+ ctr.high = n >> 32;
+ ctr.low = n & 0xffffffff;
+ snmp_set_var_typed_value(requests->requestvb, $i.type,
+ &ctr,
+ sizeof(ctr));
+ }
+ @elsif $i.type eq 'ASN_OCTET_STR'@
+ snmp_set_var_typed_value(requests->requestvb, $i.type,
+ val, strlen(val));
+ break;
+ @elsif $i.type eq 'ASN_COUNTER32'@
+ {
+ uint32_t n = strtoul(val, NULL, 10);
+ snmp_set_var_typed_value(requests->requestvb, $i.type,
+ &n,
+ sizeof(n));
+ }
+ @elsif $i.type eq 'ASN_INTEGER32'@
+ {
+ uint32_t n = strtoul(val, NULL, 10);
+ snmp_set_var_typed_value(requests->requestvb, $i.type,
+ &n,
+ sizeof(n));
+ }
+ @else@
+ @printf "unrecognized type %s for %s" $i.type $i@
+ @end@
+ break;
+
+ @if $i.settable@
+ /*
+ * SET REQUEST
+ *
+ * multiple states in the transaction. See:
+ * http://www.net-snmp.org/tutorial-5/toolkit/mib_module/set-actions.jpg
+ */
+ case MODE_SET_RESERVE1:
+ /* or you could use netsnmp_check_vb_type_and_size instead */
+ ret = netsnmp_check_vb_type(requests->requestvb, $i.type);
+ if (ret != SNMP_ERR_NOERROR)
+ netsnmp_set_request_error(reqinfo, requests, ret);
+ break;
+
+ case MODE_SET_RESERVE2:
+ @if $mysqlstat_set_reserve2 ne ''@
+ if ($mysqlstat_set_reserve2 (reqinfo, requests, vd)) {
+ netsnmp_set_request_error(reqinfo, requests,
+ SNMP_ERR_RESOURCEUNAVAILABLE);
+ }
+ @end@
+ break;
+
+ case MODE_SET_FREE:
+ @if $mysqlstat_set_free ne ''@
+ # Free resources allocated in RESERVE1 and/or
+ # RESERVE2. Something failed somewhere, and the states
+ # below won't be called.
+ $varnish_set_free(reqinfo, requests, vd);
+ @end@
+ break;
+
+ case MODE_SET_ACTION:
+ @if $mysqlstat_set_action ne ''@
+ ret = $mysqlstat_set_action(reqinfo, requests, vd);
+ if (ret != SNMP_ERR_NOERROR)
+ netsnmp_set_request_error(reqinfo, requests, ret);
+ @end@
+ break;
+
+ case MODE_SET_COMMIT:
+ @if $mysqlstat_set_commit ne ''@
+ # delete temporary storage
+ if ($mysqlstat_set_commit(reqinfo, requests, vd))
+ netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_COMMITFAILED);
+ @end@
+ break;
+
+ case MODE_SET_UNDO:
+ @if $mysqlstat_set_undo ne ''@
+ # UNDO and return to previous value for the object
+ if ($mysqlstat_set_undo(reqinfo, requests, vd))
+ netsnmp_set_request_error(reqinfo, requests, SNMP_ERR_UNDOFAILED);
+ @end@
+ break;
+ @end@
+
+ default:
+ /* we should never get here, so this is a really bad error */
+ snmp_log(LOG_ERR, "unknown mode (%d) in handle_${i}\n", reqinfo->mode );
+ return SNMP_ERR_GENERR;
+ }
+
+ return SNMP_ERR_NOERROR;
+}
+@end@
+
+/** Initializes the $name module */
+void
+init_$modulename(void)
+{
+ @foreach $i scalar@
+ @startperl@
+ &{$vars{'mysqlstat_translate'}}($vars{'i'});
+ @endperl@
+$varnish_if
+ const oid ${i}_oid[] = { $i.commaoid };
+$varnish_endif
+ @end@
+
+ DEBUGMSGTL(("$modulename", "Initializing\n"));
+
+ @foreach $i scalar@
+ @startperl@
+ &{$vars{'mysqlstat_translate'}}($vars{'i'});
+ @endperl@
+ netsnmp_register_scalar(
+ netsnmp_create_handler_registration("$i", handle_$i,
+ ${i}_oid, OID_LENGTH(${i}_oid),
+ @if !$i.settable@
+ HANDLER_CAN_RONLY
+ @end@
+ @if $i.settable@
+ HANDLER_CAN_RWRITE
+ @end@
+ ));
+}
+
+void
+deinit_$modulename(void)
+{
+ /* Nothing */
+}
+@calldefine ROCOM@
+
+

Return to:

Send suggestions and report system problems to the System administrator.