diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-06-04 09:09:38 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2016-06-04 09:09:38 +0300 |
commit | 66be1da761f3aadf11b882c12df2d9d5f4c4f469 (patch) | |
tree | 95e42257ba84f73a752e57aa86e15fc06c6f151b /src | |
parent | ccfe04cf8c3c903013dcacf5681d0d826b222224 (diff) | |
download | mysqlstat-66be1da761f3aadf11b882c12df2d9d5f4c4f469.tar.gz mysqlstat-66be1da761f3aadf11b882c12df2d9d5f4c4f469.tar.bz2 |
Minor changes
* configure.ac: Look for libraries in lib64 on 64-bit OSs
* src/mysqlstat.c: Convert values of Slave_IO_Running and
Slave_SQL_Running.
Diffstat (limited to 'src')
-rw-r--r-- | src/mysqlstat.c | 34 | ||||
-rw-r--r-- | src/mysqlstat_mib.mib2c | 8 |
2 files changed, 35 insertions, 7 deletions
diff --git a/src/mysqlstat.c b/src/mysqlstat.c index c50ae65..76e7791 100644 --- a/src/mysqlstat.c +++ b/src/mysqlstat.c @@ -278,6 +278,26 @@ mysqlstat_cache_get(struct mysqlstat_cache *cache, char const *name) return hashtab_lookup(cache->ht, name); } +static char const * +val_Slave_IO_Running(char const *val) +{ + if (strcmp(val, "Yes") == 0) + return "1"; + else if (strcmp(val, "No") == 0) + return "2"; + else if (strcmp(val, "Connected") == 0) + return "3"; + return 4; +} + +static char const * +val_Slave_SQL_Running(char const *val) +{ + if (strcmp(val, "Yes") == 0) + return "1"; + return "2"; +} + static void populate_repl(struct hashtab *ht) { @@ -307,9 +327,17 @@ populate_repl(struct hashtab *ht) num_fields = mysql_num_fields(res); fields = mysql_fetch_fields(res); row = mysql_fetch_row(res); - for (i = 0; i < num_fields; i++) - if (row[i]) - hashtab_install(ht, fields[i].name, row[i]); + for (i = 0; i < num_fields; i++) { + if (row[i]) { + char const *val = row[i]; + if (strcmp(fields[i].name, "Slave_IO_Running") == 0) { + val = val_Slave_IO_Running(val); + } else if (strcmp(fields[i].name, "Slave_SQL_Running") == 0) { + val = val_Slave_SQL_Running(val); + } + hashtab_install(ht, fields[i].name, val); + } + } mysql_free_result(res); mysqlstat_disconnect(conn); } diff --git a/src/mysqlstat_mib.mib2c b/src/mysqlstat_mib.mib2c index 8f9663d..16b79bd 100644 --- a/src/mysqlstat_mib.mib2c +++ b/src/mysqlstat_mib.mib2c @@ -65,7 +65,6 @@ $vars{'mysqlstat_translate'} = sub { $vars{'mysqlstat_id'} = $r->[0]; $vars{'mysqlstat_name'} = $r->[1]; -# $vars{'mysqlstat_type'} = $r->[2]; return 0; }; @@ -119,9 +118,10 @@ handle_$i(netsnmp_mib_handler *handler, sizeof(ctr)); } @elsif $i.type eq 'ASN_OCTET_STR'@ - snmp_set_var_typed_value(requests->requestvb, $i.type, - val, strlen(val)); - break; + { + snmp_set_var_typed_value(requests->requestvb, $i.type, + val, strlen(val)); + } @elsif $i.type eq 'ASN_COUNTER'@ { uint32_t n = strtoul(val, NULL, 10); |