]> git.ipfire.org Git - thirdparty/collectd.git/commitdiff
replace long if else with compact code
authorThomas Mieslinger <thomas.mieslinger@1und1.de>
Wed, 20 May 2020 06:09:02 +0000 (08:09 +0200)
committerThomas Mieslinger <thomas.mieslinger@1und1.de>
Wed, 20 May 2020 06:09:02 +0000 (08:09 +0200)
src/mysql.c

index b1248f19a42db359910b2ead08d8d46f40c68765..db1926d8b6e1fc622d22706362c1cceffc2db0d5 100644 (file)
@@ -472,20 +472,13 @@ static int mysql_read_slave_stats(mysql_database_t *db, MYSQL *con) {
     unsigned long long counter;
     double gauge;
 
-    if (row[SLAVE_SQL_RUNNING_IDX] == NULL) {
-      gauge_submit("slave_running", "sql", 1, db);
-    } else if (strcasecmp(row[SLAVE_SQL_RUNNING_IDX], "yes") != 0) {
-      gauge_submit("slave_running", "sql", 1, db);
-    } else {
-      gauge_submit("slave_running", "sql", 0, db);
-    }
-    if (row[SLAVE_IO_RUNNING_IDX] == NULL) {
-      gauge_submit("slave_running", "io", 1, db);
-    } else if (strcasecmp(row[SLAVE_IO_RUNNING_IDX], "yes") != 0) {
-      gauge_submit("slave_running", "io", 1, db);
-    } else {
-      gauge_submit("slave_running", "io", 0, db);
-    }
+    gauge_submit("bool", "slave-sql-running",
+      (row[SLAVE_SQL_RUNNING_IDX] != NULL) && (strcasecmp(row[SLAVE_SQL_RUNNING_IDX], "yes") == 0),
+       db);
+
+    gauge_submit("bool", "slave-io-running",
+      (row[SLAVE_IO_RUNNING_IDX] != NULL) && (strcasecmp(row[SLAVE_IO_RUNNING_IDX], "yes") == 0),
+       db);
 
     counter = atoll(row[READ_MASTER_LOG_POS_IDX]);
     derive_submit("mysql_log_position", "slave-read", counter, db);