summaryrefslogtreecommitdiffabout
authorSergey Poznyakoff <gray@gnu.org.ua>2016-06-07 05:01:46 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2016-06-07 05:01:46 (GMT)
commit757b835af8984c1fa796aec1789b484bd307bb8a (patch) (unidiff)
tree7f37eec457262277ff2fe856eb2907155fded780
parentec36698ad30b99a05104952f011cf471faf83e56 (diff)
downloadmysqlstat-757b835af8984c1fa796aec1789b484bd307bb8a.tar.gz
mysqlstat-757b835af8984c1fa796aec1789b484bd307bb8a.tar.bz2
Keep MySQL connection open as long as possible. Implement new OIDs.
* src/MYSQL-STAT-MIB.txt: New OIDs: processTotalCount, processActiveCount, and processSlaveCount * src/mysqlstat.c (mysqlstat_connect): Keep connection open. (mysqlstat_disconnect): Remove. (get_process_list, process_first, process_next): New functions. Keep a cached list of processes and iterate through it. All functions updated. (process_total_count,process_active_count) (process_slave_count): New functions. * src/mysqlstat.h (process_total_count,process_active_count) (process_slave_count): New protos. * src/mysqlstat_mib.mib2c (handle_$i): Update.
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--src/MYSQL-STAT-MIB.txt127
-rw-r--r--src/mysqlstat.c220
-rw-r--r--src/mysqlstat.h27
-rw-r--r--src/mysqlstat_mib.mib2c114
4 files changed, 204 insertions, 284 deletions
diff --git a/src/MYSQL-STAT-MIB.txt b/src/MYSQL-STAT-MIB.txt
index 8fbc0e6..3c05db2 100644
--- a/src/MYSQL-STAT-MIB.txt
+++ b/src/MYSQL-STAT-MIB.txt
@@ -20,3 +20,3 @@ IMPORTS
20mysql MODULE-IDENTITY 20mysql MODULE-IDENTITY
21 LAST-UPDATED "201606061638Z" 21 LAST-UPDATED "201606070800Z"
22 ORGANIZATION "Gray Software" 22 ORGANIZATION "Gray Software"
@@ -25,3 +25,3 @@ mysql MODULE-IDENTITY
25 "This MIB module defines objects for MySQL statistics." 25 "This MIB module defines objects for MySQL statistics."
26 REVISION "201606061638Z" 26 REVISION "201606070800Z"
27 DESCRIPTION 27 DESCRIPTION
@@ -463,98 +463,2 @@ replMasterSSLVerifyServerCert OBJECT-TYPE
463-- 463--
464-- Table of Replication Slave Servers
465--
466
467 -- replSlaveCountOBJECT-TYPE
468 -- SYNTAXCounter32
469 -- MAX-ACCESS read-only
470 -- STATUS current
471 -- DESCRIPTION
472 -- "Number of active replication slaves."
473 -- ::= { replSlave 1 }
474
475 -- replSlaveTableOBJECT-TYPE
476 -- SYNTAXSEQUENCE OF ReplSlaveEntry
477 -- MAX-ACCESSnot-accessible
478 -- STATUS current
479 -- DESCRIPTION
480 -- "A table of active replication slaves."
481 -- ::= { replSlave 2 }
482
483 -- replSlaveEntryOBJECT-TYPE
484 -- SYNTAXReplSlaveEntry
485 -- MAX-ACCESSnot-accessible
486 -- STATUS current
487 -- DESCRIPTION
488 -- "An entry (conceptual row) describing a replication
489 -- slave server."
490 -- INDEX{ replSlaveIndex }
491 -- ::= { replSlaveTable 1 }
492
493 -- ReplSlaveEntry::= SEQUENCE {
494 -- replSlaveIndex Integer32,
495 -- replSlaveHost DisplayString,
496 -- replSlaveUser DisplayString,
497 -- replSlaveCommandDisplayString,
498 -- replSlaveState DisplayString,
499 -- replSlaveTime TimeStamp,
500 -- replSlaveInfo DisplayString
501-- }
502
503 -- replSlaveIndexOBJECT-TYPE
504 -- SYNTAX Integer32 (0..65535)
505 -- MAX-ACCESS not-accessible
506 -- STATUS current
507 -- DESCRIPTION
508 -- "A number uniquely identifying each slave server."
509 -- ::= { replSlaveEntry 1 }
510
511 -- replSlaveHostOBJECT-TYPE
512 -- SYNTAXDisplayString
513 -- MAX-ACCESSread-only
514 -- STATUS current
515 -- DESCRIPTION
516 -- "Hostname of the server."
517 -- ::= { replSlaveEntry 2 }
518
519 -- replSlaveUserOBJECT-TYPE
520 -- SYNTAXDisplayString
521 -- MAX-ACCESSread-only
522 -- STATUS current
523 -- DESCRIPTION
524 -- "User name used by that server."
525 -- ::= { replSlaveEntry 3 }
526
527 -- replSlaveCommandOBJECT-TYPE
528 -- SYNTAXDisplayString
529 -- MAX-ACCESSread-only
530 -- STATUS current
531 -- DESCRIPTION
532 -- "Command being run."
533 -- ::= { replSlaveEntry 4 }
534
535 -- replSlaveStateOBJECT-TYPE
536 -- SYNTAXDisplayString
537 -- MAX-ACCESSread-only
538 -- STATUS current
539 -- DESCRIPTION
540 -- "State of the connection."
541 -- ::= { replSlaveEntry 5 }
542
543 -- replSlaveTimeOBJECT-TYPE
544 -- SYNTAX TimeStamp
545 -- MAX-ACCESSread-only
546 -- STATUS current
547 -- DESCRIPTION
548 -- "Timestamp of the last status change."
549 -- ::= { replSlaveEntry 6 }
550
551 -- replSlaveInfoOBJECT-TYPE
552 -- SYNTAX DisplayString
553 -- MAX-ACCESSread-only
554 -- STATUS current
555 -- DESCRIPTION
556 -- "Additional info about the connection."
557 -- ::= { replSlaveEntry 7 }
558
559--
560-- Process List 464-- Process List
@@ -568,3 +472,3 @@ processListTable OBJECT-TYPE
568 "A table of active threads." 472 "A table of active threads."
569 ::= { processList 2 } 473 ::= { processList 1 }
570 474
@@ -662,2 +566,27 @@ processInfo OBJECT-TYPE
662 ::= { processListEntry 9 } 566 ::= { processListEntry 9 }
567
568 processTotalCountOBJECT-TYPE
569 SYNTAX Counter32
570 MAX-ACCESS read-only
571 STATUS current
572 DESCRIPTION
573 "Total number of processes (threads)."
574 ::= { processList 2 }
575
576 processActiveCountOBJECT-TYPE
577 SYNTAX Counter32
578 MAX-ACCESS read-only
579 STATUS current
580 DESCRIPTION
581 "Number of active processes (threads)."
582 ::= { processList 3 }
583
584 processSlaveCountOBJECT-TYPE
585 SYNTAX Counter32
586 MAX-ACCESS read-only
587 STATUS current
588 DESCRIPTION
589 "Number of replication slaves"
590 ::= { processList 4 }
591
663END 592END
diff --git a/src/mysqlstat.c b/src/mysqlstat.c
index 938439a..2ffd0dd 100644
--- a/src/mysqlstat.c
+++ b/src/mysqlstat.c
@@ -56,18 +56,22 @@ mysqlstat_connect(void)
56{ 56{
57 struct mysqlstat_connection *conn; 57 static struct mysqlstat_connection *conn;
58 my_bool t = 1; 58 my_bool t = 1;
59 59
60 conn = xcalloc(1, sizeof(*conn)); 60 if (!conn) {
61 mysql_init(&conn->mysql); 61 conn = xcalloc(1, sizeof(*conn));
62 if (access(config_file, F_OK) == 0) 62 mysql_init(&conn->mysql);
63 mysql_options(&conn->mysql, MYSQL_READ_DEFAULT_FILE, 63 if (access(config_file, F_OK) == 0)
64 config_file); 64 mysql_options(&conn->mysql, MYSQL_READ_DEFAULT_FILE,
65 mysql_options(&conn->mysql, MYSQL_READ_DEFAULT_GROUP, "mysqlstat"); 65 config_file);
66 mysql_options(&conn->mysql, MYSQL_OPT_RECONNECT, &t); 66 mysql_options(&conn->mysql,
67 if (!mysql_real_connect(&conn->mysql, NULL, NULL, NULL, NULL, 0, 67 MYSQL_READ_DEFAULT_GROUP, "mysqlstat");
68 NULL, 0)) { 68 mysql_options(&conn->mysql, MYSQL_OPT_RECONNECT, &t);
69 snmp_log(LOG_ERR, "can't connect to MySQL: %s\n", 69 if (!mysql_real_connect(&conn->mysql,
70 mysql_error(&conn->mysql)); 70 NULL, NULL, NULL, NULL, 0,
71 free(conn); 71 NULL, 0)) {
72 conn = NULL; 72 snmp_log(LOG_ERR, "can't connect to MySQL: %s\n",
73 mysql_error(&conn->mysql));
74 free(conn);
75 conn = NULL;
76 }
73 } 77 }
@@ -75,11 +79,2 @@ mysqlstat_connect(void)
75} 79}
76
77void
78mysqlstat_disconnect(mysqlstat_connection_t conn)
79{
80 if (!conn)
81 return;
82 mysql_close(&conn->mysql);
83 free(conn);
84}
85 80
@@ -103,3 +98,94 @@ unsigned mysqlstat_cache_timeout = CACHE_TIMEOUT;
103#define STREQ(pat,str) (strcmp(#pat, str) == 0) 98#define STREQ(pat,str) (strcmp(#pat, str) == 0)
99
100struct process_list {
101 time_t ts;
102 MYSQL_RES *res;
103 uint32_t total;
104 uint32_t active;
105 uint32_t slaves;
106 uint32_t itr;
107};
108
109enum {
110 FI_processID,
111 FI_processUser,
112 FI_processHost,
113 FI_processDatabase,
114 FI_processCommand,
115 FI_processTime,
116 FI_processState,
117 FI_processInfo
118};
104 119
120static int
121get_process_list(struct process_list **p)
122{
123 static struct process_list plist;
124 time_t now;
125
126 now = time(NULL);
127 if (!plist.res || now - plist.ts >= mysqlstat_cache_timeout) {
128 mysqlstat_connection_t conn;
129 unsigned i;
130
131 if (plist.res) {
132 mysql_free_result(plist.res);
133 plist.res = NULL;
134 plist.total = plist.active = plist.slaves = 0;
135 }
136 DEBUGMSGTL(("mysqlstat", "Getting process list\n"));
137
138 conn = mysqlstat_connect();
139 if (!conn)
140 return SNMP_ERR_GENERR;
141
142 if (mysql_query(&conn->mysql, "SHOW PROCESSLIST")) {
143 snmp_log(LOG_ERR, "can't get slave process list: %s\n",
144 mysql_error(&conn->mysql));
145 return SNMP_ERR_NOSUCHNAME;
146 }
147 plist.res = mysql_store_result(&conn->mysql);
148 plist.ts = now;
149
150 plist.total = mysql_num_rows(plist.res);
151 for (i = 0; i < plist.total; i++) {
152 MYSQL_ROW row;
153
154 mysql_data_seek(plist.res, i);
155 row = mysql_fetch_row(plist.res);
156 if (!row[FI_processState]
157 || STREQ(Sleep, row[FI_processState]))
158 continue;
159 if (row[FI_processCommand]
160 && strcmp(row[FI_processCommand], "Binlog Dump") == 0)
161 plist.slaves++;
162 else
163 plist.active++;
164 }
165 }
166 *p = &plist;
167 return 0;
168}
169
170MYSQL_ROW
171process_next(struct process_list *p)
172{
173 MYSQL_ROW row;
174 if (p->itr >= p->total)
175 return NULL;
176 mysql_data_seek(p->res, p->itr);
177 ++p->itr;
178 return mysql_fetch_row(p->res);
179}
180
181MYSQL_ROW
182process_first(struct process_list **state)
183{
184 struct process_list *p;
185 if (get_process_list(&p))
186 return NULL;
187 p->itr = 0;
188 *state = p;
189 return process_next(p);
190}
105 191
@@ -226,3 +312,2 @@ replSlaveStatusTable_load(netsnmp_cache *cache, void *vmagic)
226 mysql_error(&conn->mysql)); 312 mysql_error(&conn->mysql));
227 mysqlstat_disconnect(conn);
228 return SNMP_ERR_NOSUCHNAME; 313 return SNMP_ERR_NOSUCHNAME;
@@ -232,3 +317,3 @@ replSlaveStatusTable_load(netsnmp_cache *cache, void *vmagic)
232 if (mysql_num_rows(res) < 1) { 317 if (mysql_num_rows(res) < 1) {
233 snmp_log(LOG_INFO, "empty slave status\n"); 318 /* snmp_log(LOG_INFO, "empty slave status\n"); */
234 return 0; 319 return 0;
@@ -242,3 +327,2 @@ replSlaveStatusTable_load(netsnmp_cache *cache, void *vmagic)
242 if (!ent) { 327 if (!ent) {
243 mysqlstat_disconnect(conn);
244 return SNMP_ERR_GENERR; 328 return SNMP_ERR_GENERR;
@@ -249,3 +333,2 @@ replSlaveStatusTable_load(netsnmp_cache *cache, void *vmagic)
249 SNMP_FREE(ent); 333 SNMP_FREE(ent);
250 mysqlstat_disconnect(conn);
251 return SNMP_ERR_GENERR; 334 return SNMP_ERR_GENERR;
@@ -261,6 +344,5 @@ replSlaveStatusTable_load(netsnmp_cache *cache, void *vmagic)
261 for (i = 0; i < num_fields; i++) 344 for (i = 0; i < num_fields; i++)
262 store_slave_status_row (ent, fields[i].name, row[i]); 345 store_slave_status_row(ent, fields[i].name, row[i]);
263 346
264 mysql_free_result(res); 347 mysql_free_result(res);
265 mysqlstat_disconnect(conn);
266 return 0; 348 return 0;
@@ -297,14 +379,2 @@ replSlaveStatusTable_entry_free(void *data)
297 379
298
299enum {
300 FI_processID,
301 FI_processUser,
302 FI_processHost,
303 FI_processDatabase,
304 FI_processCommand,
305 FI_processTime,
306 FI_processState,
307 FI_processInfo
308};
309
310static void 380static void
@@ -329,4 +399,9 @@ process_list_add(netsnmp_tdata *table_data, long idx, MYSQL_ROW mysql_row)
329 ent->processID = strtol(mysql_row[FI_processID], NULL, 10); 399 ent->processID = strtol(mysql_row[FI_processID], NULL, 10);
400
330 ASSIGN_ROW(ent, processUser, mysql_row); 401 ASSIGN_ROW(ent, processUser, mysql_row);
331 ASSIGN_ROW(ent, processHost, mysql_row); 402
403 ent->processHost_len = strcspn(mysql_row[FI_processHost], ":");
404 ent->processHost = xmalloc(ent->processHost_len);
405 memcpy(ent->processHost, mysql_row[FI_processHost], ent->processHost_len);
406
332 ASSIGN_ROW(ent, processDatabase, mysql_row); 407 ASSIGN_ROW(ent, processDatabase, mysql_row);
@@ -348,35 +423,10 @@ processListTable_load(netsnmp_cache *cache, void *vmagic)
348{ 423{
349 mysqlstat_connection_t conn; 424 struct process_list *p;
350 MYSQL_RES *res;
351 unsigned int num_rows, i;
352 netsnmp_tdata *table = (netsnmp_tdata *) vmagic; 425 netsnmp_tdata *table = (netsnmp_tdata *) vmagic;
426 MYSQL_ROW row;
427 uint32_t i;
353 428
354 DEBUGMSGTL(("mysqlstat", "Getting process list\n")); 429 for (row = process_first(&p), i = 0; row; row = process_next(p), i++) {
355
356 conn = mysqlstat_connect();
357 if (!conn)
358 return SNMP_ERR_GENERR;
359
360 if (mysql_query(&conn->mysql, "SHOW PROCESSLIST")) {
361 snmp_log(LOG_ERR, "can't get slave process list: %s\n",
362 mysql_error(&conn->mysql));
363 mysqlstat_disconnect(conn);
364 return SNMP_ERR_NOSUCHNAME;
365 }
366
367 res = mysql_store_result(&conn->mysql);
368 num_rows = mysql_num_rows(res);
369
370 for (i = 0; i < num_rows; i++) {
371 MYSQL_ROW row;
372
373 mysql_data_seek(res, i);
374 row = mysql_fetch_row(res);
375
376 process_list_add(table, i, row); 430 process_list_add(table, i, row);
377 } 431 }
378
379 mysql_free_result(res);
380 mysqlstat_disconnect(conn);
381
382 return 0; 432 return 0;
@@ -395,2 +445,30 @@ processListTable_entry_free(void *data)
395 445
446uint32_t
447process_total_count(void)
448{
449 struct process_list *p;
450 if (get_process_list(&p))
451 return 0;
452 return p->total;
453}
454
455uint32_t
456process_active_count(void)
457{
458 struct process_list *p;
459 if (get_process_list(&p))
460 return 0;
461 return p->active;
462}
463
464uint32_t
465process_slave_count(void)
466{
467 struct process_list *p;
468 if (get_process_list(&p))
469 return 0;
470 return p->slaves;
471}
472
473
396#if 0 474#if 0
diff --git a/src/mysqlstat.h b/src/mysqlstat.h
index 1fc724e..f4bf137 100644
--- a/src/mysqlstat.h
+++ b/src/mysqlstat.h
@@ -29,26 +29,4 @@
29 29
30enum {
31 MYSQLSTAT_CACHE_REPL,
32 MYSQLSTAT_MAX_CACHE
33};
34
35typedef struct mysqlstat_connection *mysqlstat_connection_t; 30typedef struct mysqlstat_connection *mysqlstat_connection_t;
36 31
37struct repl_stat {
38 char *replMasterLogFile;
39 uint32_t replReadMasterLogPos;
40 char *replRelayLogFile;
41 uint32_t replRelayLogPos;
42 char *replRelayMasterLogFile;
43 int replSlaveIORunning;
44 int replSlaveSQLRunning;
45 int replLastSQLErrno;
46 char *replLastSQLError;
47 int replLastIOErrno;
48 char *replLastIOError;
49 uint32_t replExecMasterLogPos;
50 uint64_t replRelayLogSpace;
51 uint32_t replSecondsBehindMaster;
52};
53
54mysqlstat_connection_t mysqlstat_connect(void); 32mysqlstat_connection_t mysqlstat_connect(void);
@@ -56,2 +34,5 @@ void mysqlstat_disconnect(mysqlstat_connection_t);
56 34
57char const *mysqlstat_get(int id, char const *name); 35uint32_t process_total_count(void);
36uint32_t process_active_count(void);
37uint32_t process_slave_count(void);
38
diff --git a/src/mysqlstat_mib.mib2c b/src/mysqlstat_mib.mib2c
index 7f00d9b..733f977 100644
--- a/src/mysqlstat_mib.mib2c
+++ b/src/mysqlstat_mib.mib2c
@@ -25,77 +25,5 @@
25$vars{'mysqlstat_translate_table'} = { 25$vars{'mysqlstat_translate_table'} = {
26 replSlaveIOState => 26 processTotalCount => q{process_total_count()},
27 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Slave_IO_State")}, 27 processActiveCount => q{process_active_count()},
28 replMasterLogFile => 28 processSlaveCount => q{process_slave_count()}
29 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_Log_File")},
30 replReadMasterLogPos =>
31 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Read_Master_Log_Pos")},
32 replRelayLogFile =>
33 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Relay_Log_File")},
34 replRelayLogPos =>
35 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Relay_Log_Pos")},
36 replRelayMasterLogFile =>
37 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Relay_Master_Log_File")},
38 replSlaveIORunning =>
39 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Slave_IO_Running")},
40 replSlaveSQLRunning =>
41 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Slave_SQL_Running")},
42 replLastSQLErrno =>
43 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Last_SQL_Errno")},
44 replLastSQLError =>
45 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Last_SQL_Error")},
46 replLastIOErrno =>
47 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Last_IO_Errno")},
48 replLastIOError =>
49 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Last_IO_Error")},
50 replExecMasterLogPos =>
51 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Exec_Master_Log_Pos")},
52 replRelayLogSpace =>
53 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Relay_Log_Space")},
54 replSecondsBehindMaster =>
55 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Seconds_Behind_Master")},
56
57 replMasterHost =>
58 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_Host")},
59 replMasterUser =>
60 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_User")},
61 replMasterPort =>
62 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_Port")},
63 replConnectRetry=>
64 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Connect_Retry")},
65 replReplicateDoDB=>
66 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Replicate_Do_DB")},
67 replReplicateIgnoreDB=>
68 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Replicate_Ignore_DB")},
69 replReplicateDoTable=>
70 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Replicate_Do_Table")},
71 replReplicateIgnoreTable=>
72 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Replicate_Ignore_Table")},
73 replReplicateWildDoTable=>
74 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Replicate_Wild_Do_Table")},
75 replReplicateWildIgnoreTable=>
76 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Replicate_Wild_Ignore_Table")},
77 replSkipCounter =>
78 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Skip_Counter")},
79 replUntilCondition=>
80 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Until_Condition")},
81 replUntilLogFile=>
82 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Until_Log_File")},
83 replUntilLogPos =>
84 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Until_Log_Pos")},
85 replMasterServerId=>
86 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_Server_Id")},
87 replMasterSSLAllowed=>
88 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_SSL_Allowed")},
89 replMasterSSLCAFile=>
90 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_SSL_CA_File")},
91 replMasterSSLCAPath=>
92 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_SSL_CA_Path")},
93 replMasterSSLCert=>
94 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_SSL_Cert")},
95 replMasterSSLCipher=>
96 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_SSL_Cipher")},
97 replMasterSSLKey=>
98 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_SSL_Key")},
99 replMasterSSLVerifyServerCert=>
100 q{mysqlstat_get(MYSQLSTAT_CACHE_REPL, "Master_SSL_Verify_Server_Cert")}
101}; 29};
@@ -150,7 +78,15 @@ handle_$i(netsnmp_mib_handler *handler,
150 @end@ 78 @end@
151 char const *val = $mysqlstat_get; 79 @if $i.type eq 'ASN_OCTET_STR'@
80 @eval $mysqlstat_type = q{char const *};@
81 @elsif $i.type eq 'ASN_COUNTER64'@
82 @eval $mysqlstat_type = q{uint64_t};@
83 @elsif $i.type eq 'ASN_COUNTER'@
84 @eval $mysqlstat_type = q{uint32_t};@
85 @elsif $i.type eq 'ASN_INTEGER'@
86 @eval $mysqlstat_type = q{uint32_t};@
87 @elsif $i.type eq 'ASN_TIMETICKS'@
88 @eval $mysqlstat_type = q{uint32_t};@
89 @end@
90 $mysqlstat_type val = $mysqlstat_get;
152 91
153 if (!val)
154 return SNMP_ERR_NOSUCHNAME;
155
156 switch(reqinfo->mode) { 92 switch(reqinfo->mode) {
@@ -160,5 +96,4 @@ handle_$i(netsnmp_mib_handler *handler,
160 struct counter64 ctr; 96 struct counter64 ctr;
161 uint64_t n = strtoull(val, NULL, 10); 97 ctr.high = val >> 32;
162 ctr.high = n >> 32; 98 ctr.low = val & 0xffffffff;
163 ctr.low = n & 0xffffffff;
164 snmp_set_var_typed_value(requests->requestvb, $i.type, 99 snmp_set_var_typed_value(requests->requestvb, $i.type,
@@ -174,6 +109,5 @@ handle_$i(netsnmp_mib_handler *handler,
174 { 109 {
175 uint32_t n = strtoul(val, NULL, 10);
176 snmp_set_var_typed_value(requests->requestvb, $i.type, 110 snmp_set_var_typed_value(requests->requestvb, $i.type,
177 &n, 111 &val,
178 sizeof(n)); 112 sizeof(val));
179 } 113 }
@@ -181,6 +115,5 @@ handle_$i(netsnmp_mib_handler *handler,
181 { 115 {
182 uint32_t n = strtoul(val, NULL, 10);
183 snmp_set_var_typed_value(requests->requestvb, $i.type, 116 snmp_set_var_typed_value(requests->requestvb, $i.type,
184 &n, 117 &val,
185 sizeof(n)); 118 sizeof(val));
186 } 119 }
@@ -188,6 +121,5 @@ handle_$i(netsnmp_mib_handler *handler,
188 { 121 {
189 uint32_t n = strtoul(val, NULL, 10);
190 snmp_set_var_typed_value(requests->requestvb, $i.type, 122 snmp_set_var_typed_value(requests->requestvb, $i.type,
191 &n, 123 &val,
192 sizeof(n)); 124 sizeof(val));
193 } 125 }

Return to:

Send suggestions and report system problems to the System administrator.