static int process_station (int sk, const char *dev, struct ieee80211req_sta_info *si) { struct iwreq iwr; static char mac[DATA_MAX_NAME_LEN]; struct ieee80211req_sta_stats stats; const struct ieee80211_nodestats *ns = &stats.is_stats; int status; macaddr_to_str (mac, sizeof (mac), si->isi_macaddr); if (item_watched (STAT_NODE_TX_RATE)) submit_gauge (dev, "node_tx_rate", mac, NULL, (si->isi_rates[si->isi_txrate] & IEEE80211_RATE_VAL) / 2); if (item_watched (STAT_NODE_RSSI)) submit_gauge (dev, "node_rssi", mac, NULL, si->isi_rssi); memset (&iwr, 0, sizeof (iwr)); sstrncpy(iwr.ifr_name, dev, sizeof (iwr.ifr_name)); iwr.u.data.pointer = (void *) &stats; iwr.u.data.length = sizeof (stats); memcpy(stats.is_u.macaddr, si->isi_macaddr, IEEE80211_ADDR_LEN); status = ioctl(sk, IEEE80211_IOCTL_STA_STATS, &iwr); if (status < 0) { /* Silent, because not all interfaces support all ioctls. */ DEBUG ("madwifi plugin: Sending IO-control " "IEEE80211_IOCTL_STA_STATS to device %s " "failed with status %i.", dev, status); return (status); } /* These two stats are handled as a special case as they are a pair of 64bit values */ if (item_watched (STAT_NODE_OCTETS)) submit_derive2 (dev, "node_octets", mac, NULL, ns->ns_rx_bytes, ns->ns_tx_bytes); /* This stat is handled as a special case, because it is stored as uin64_t, but we will ignore upper half */ if (item_watched (STAT_NS_RX_BEACONS)) submit_derive (dev, "node_stat", "ns_rx_beacons", mac, (ns->ns_rx_beacons & 0xFFFFFFFF)); /* All other node statistics */ process_stat_struct (NOD_STAT, ns, dev, mac, "node_stat", "ns_misc"); return (0); }
static int process_stations (int sk, const char *dev) { uint8_t buf[24*1024]; struct iwreq iwr; uint8_t *cp; int nodes; size_t len; int status; memset (&iwr, 0, sizeof (iwr)); sstrncpy (iwr.ifr_name, dev, sizeof (iwr.ifr_name)); iwr.u.data.pointer = (void *) buf; iwr.u.data.length = sizeof (buf); status = ioctl (sk, IEEE80211_IOCTL_STA_INFO, &iwr); if (status < 0) { /* Silent, because not all interfaces support all ioctls. */ DEBUG ("madwifi plugin: Sending IO-control " "IEEE80211_IOCTL_STA_INFO to device %s " "failed with status %i.", dev, status); return (status); } len = iwr.u.data.length; cp = buf; nodes = 0; while (len >= sizeof (struct ieee80211req_sta_info)) { struct ieee80211req_sta_info *si = (void *) cp; process_station(sk, dev, si); cp += si->isi_len; len -= si->isi_len; nodes++; } if (item_watched (STAT_ATH_NODES)) submit_gauge (dev, "ath_nodes", NULL, NULL, nodes); return (0); }
static int apache_read_host (user_data_t *user_data) /* {{{ */ { int i; char *ptr; char *saveptr; char *lines[16]; int lines_num = 0; char *fields[4]; int fields_num; apache_t *st; st = user_data->data; assert (st->url != NULL); /* (Assured by `config_add') */ if (st->curl == NULL) { int status; status = init_host (st); if (status != 0) return (-1); } assert (st->curl != NULL); st->apache_buffer_fill = 0; if (curl_easy_perform (st->curl) != CURLE_OK) { ERROR ("apache: curl_easy_perform failed: %s", st->apache_curl_error); return (-1); } /* fallback - server_type to apache if not set at this time */ if (st->server_type == -1) { WARNING ("apache plugin: Unable to determine server software " "automatically. Will assume Apache."); st->server_type = APACHE; } ptr = st->apache_buffer; saveptr = NULL; while ((lines[lines_num] = strtok_r (ptr, "\n\r", &saveptr)) != NULL) { ptr = NULL; lines_num++; if (lines_num >= 16) break; } for (i = 0; i < lines_num; i++) { fields_num = strsplit (lines[i], fields, 4); if (fields_num == 3) { if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "Accesses:") == 0)) submit_derive ("apache_requests", "", atoll (fields[2]), st); else if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "kBytes:") == 0)) submit_derive ("apache_bytes", "", 1024LL * atoll (fields[2]), st); } else if (fields_num == 2) { if (strcmp (fields[0], "Scoreboard:") == 0) submit_scoreboard (fields[1], st); else if ((strcmp (fields[0], "BusyServers:") == 0) /* Apache 1.* */ || (strcmp (fields[0], "BusyWorkers:") == 0) /* Apache 2.* */) submit_gauge ("apache_connections", NULL, atol (fields[1]), st); else if ((strcmp (fields[0], "IdleServers:") == 0) /* Apache 1.x */ || (strcmp (fields[0], "IdleWorkers:") == 0) /* Apache 2.x */) submit_gauge ("apache_idle_workers", NULL, atol (fields[1]), st); } } st->apache_buffer_fill = 0; return (0); } /* }}} int apache_read_host */
static void submit_scoreboard (char *buf, apache_t *st) { /* * Scoreboard Key: * "_" Waiting for Connection, "S" Starting up, * "R" Reading Request for apache and read-POST for lighttpd, * "W" Sending Reply, "K" Keepalive (read), "D" DNS Lookup, * "C" Closing connection, "L" Logging, "G" Gracefully finishing, * "I" Idle cleanup of worker, "." Open slot with no current process * Lighttpd specific legends - * "E" hard error, "." connect, "h" handle-request, * "q" request-start, "Q" request-end, "s" response-start * "S" response-end, "r" read */ long long open = 0LL; long long waiting = 0LL; long long starting = 0LL; long long reading = 0LL; long long sending = 0LL; long long keepalive = 0LL; long long dnslookup = 0LL; long long closing = 0LL; long long logging = 0LL; long long finishing = 0LL; long long idle_cleanup = 0LL; /* lighttpd specific */ long long hard_error = 0LL; long long lighttpd_read = 0LL; long long handle_request = 0LL; long long request_start = 0LL; long long request_end = 0LL; long long response_start = 0LL; long long response_end = 0LL; int i; for (i = 0; buf[i] != '\0'; i++) { if (buf[i] == '.') open++; else if (buf[i] == '_') waiting++; else if (buf[i] == 'S') starting++; else if (buf[i] == 'R') reading++; else if (buf[i] == 'W') sending++; else if (buf[i] == 'K') keepalive++; else if (buf[i] == 'D') dnslookup++; else if (buf[i] == 'C') closing++; else if (buf[i] == 'L') logging++; else if (buf[i] == 'G') finishing++; else if (buf[i] == 'I') idle_cleanup++; else if (buf[i] == 'r') lighttpd_read++; else if (buf[i] == 'h') handle_request++; else if (buf[i] == 'E') hard_error++; else if (buf[i] == 'q') request_start++; else if (buf[i] == 'Q') request_end++; else if (buf[i] == 's') response_start++; else if (buf[i] == 'S') response_end++; } if (st->server_type == APACHE) { submit_gauge ("apache_scoreboard", "open" , open, st); submit_gauge ("apache_scoreboard", "waiting" , waiting, st); submit_gauge ("apache_scoreboard", "starting" , starting, st); submit_gauge ("apache_scoreboard", "reading" , reading, st); submit_gauge ("apache_scoreboard", "sending" , sending, st); submit_gauge ("apache_scoreboard", "keepalive", keepalive, st); submit_gauge ("apache_scoreboard", "dnslookup", dnslookup, st); submit_gauge ("apache_scoreboard", "closing" , closing, st); submit_gauge ("apache_scoreboard", "logging" , logging, st); submit_gauge ("apache_scoreboard", "finishing", finishing, st); submit_gauge ("apache_scoreboard", "idle_cleanup", idle_cleanup, st); } else { submit_gauge ("apache_scoreboard", "connect" , open, st); submit_gauge ("apache_scoreboard", "close" , closing, st); submit_gauge ("apache_scoreboard", "hard_error" , hard_error, st); submit_gauge ("apache_scoreboard", "read" , lighttpd_read, st); submit_gauge ("apache_scoreboard", "read_post" , reading, st); submit_gauge ("apache_scoreboard", "write" , sending, st); submit_gauge ("apache_scoreboard", "handle_request", handle_request, st); submit_gauge ("apache_scoreboard", "request_start" , request_start, st); submit_gauge ("apache_scoreboard", "request_end" , request_end, st); submit_gauge ("apache_scoreboard", "response_start", response_start, st); submit_gauge ("apache_scoreboard", "response_end" , response_end, st); } }
static int memcached_read (user_data_t *user_data) { char buf[4096]; char *fields[3]; char *ptr; char *line; char *saveptr; int fields_num; gauge_t bytes_used = NAN; gauge_t bytes_total = NAN; gauge_t hits = NAN; gauge_t gets = NAN; gauge_t incr_hits = NAN; derive_t incr = 0; gauge_t decr_hits = NAN; derive_t decr = 0; derive_t rusage_user = 0; derive_t rusage_syst = 0; derive_t octets_rx = 0; derive_t octets_tx = 0; memcached_t *st; st = user_data->data; /* get data from daemon */ if (memcached_query_daemon (buf, sizeof (buf), st) < 0) { return -1; } #define FIELD_IS(cnst) \ (((sizeof(cnst) - 1) == name_len) && (strcmp (cnst, fields[1]) == 0)) ptr = buf; saveptr = NULL; while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL) { int name_len; ptr = NULL; fields_num = strsplit(line, fields, 3); if (fields_num != 3) continue; name_len = strlen(fields[1]); if (name_len == 0) continue; /* * For an explanation on these fields please refer to * <https://github.com/memcached/memcached/blob/master/doc/protocol.txt> */ /* * CPU time consumed by the memcached process */ if (FIELD_IS ("rusage_user")) { rusage_user = atoll (fields[2]); } else if (FIELD_IS ("rusage_system")) { rusage_syst = atoll(fields[2]); } /* * Number of threads of this instance */ else if (FIELD_IS ("threads")) { submit_gauge2 ("ps_count", NULL, NAN, atof (fields[2]), st); } /* * Number of items stored */ else if (FIELD_IS ("curr_items")) { submit_gauge ("memcached_items", "current", atof (fields[2]), st); } /* * Number of bytes used and available (total - used) */ else if (FIELD_IS ("bytes")) { bytes_used = atof (fields[2]); } else if (FIELD_IS ("limit_maxbytes")) { bytes_total = atof(fields[2]); } /* * Connections */ else if (FIELD_IS ("curr_connections")) { submit_gauge ("memcached_connections", "current", atof (fields[2]), st); } else if (FIELD_IS ("listen_disabled_num")) { submit_derive ("memcached_connections", "listen_disabled", atof (fields[2]), st); } /* * Commands */ else if ((name_len > 4) && (strncmp (fields[1], "cmd_", 4) == 0)) { const char *name = fields[1] + 4; submit_derive ("memcached_command", name, atoll (fields[2]), st); if (strcmp (name, "get") == 0) gets = atof (fields[2]); } /* * Increment/Decrement */ else if (FIELD_IS("incr_misses")) { derive_t incr_count = atoll (fields[2]); submit_derive ("memcached_ops", "incr_misses", incr_count, st); incr += incr_count; } else if (FIELD_IS ("incr_hits")) { derive_t incr_count = atoll (fields[2]); submit_derive ("memcached_ops", "incr_hits", incr_count, st); incr_hits = atof (fields[2]); incr += incr_count; } else if (FIELD_IS ("decr_misses")) { derive_t decr_count = atoll (fields[2]); submit_derive ("memcached_ops", "decr_misses", decr_count, st); decr += decr_count; } else if (FIELD_IS ("decr_hits")) { derive_t decr_count = atoll (fields[2]); submit_derive ("memcached_ops", "decr_hits", decr_count, st); decr_hits = atof (fields[2]); decr += decr_count; } /* * Operations on the cache, i. e. cache hits, cache misses and evictions of items */ else if (FIELD_IS ("get_hits")) { submit_derive ("memcached_ops", "hits", atoll (fields[2]), st); hits = atof (fields[2]); } else if (FIELD_IS ("get_misses")) { submit_derive ("memcached_ops", "misses", atoll (fields[2]), st); } else if (FIELD_IS ("evictions")) { submit_derive ("memcached_ops", "evictions", atoll (fields[2]), st); } /* * Network traffic */ else if (FIELD_IS ("bytes_read")) { octets_rx = atoll (fields[2]); } else if (FIELD_IS ("bytes_written")) { octets_tx = atoll (fields[2]); } } /* while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL) */ if (!isnan (bytes_used) && !isnan (bytes_total) && (bytes_used <= bytes_total)) submit_gauge2 ("df", "cache", bytes_used, bytes_total - bytes_used, st); if ((rusage_user != 0) || (rusage_syst != 0)) submit_derive2 ("ps_cputime", NULL, rusage_user, rusage_syst, st); if ((octets_rx != 0) || (octets_tx != 0)) submit_derive2 ("memcached_octets", NULL, octets_rx, octets_tx, st); if (!isnan (gets) && !isnan (hits)) { gauge_t rate = NAN; if (gets != 0.0) rate = 100.0 * hits / gets; submit_gauge ("percent", "hitratio", rate, st); } if (!isnan (incr_hits) && incr != 0) { gauge_t incr_rate = 100.0 * incr_hits / incr; submit_gauge ("percent", "incr_hitratio", incr_rate, st); submit_derive ("memcached_ops", "incr", incr, st); } if (!isnan (decr_hits) && decr != 0) { gauge_t decr_rate = 100.0 * decr_hits / decr; submit_gauge ("percent", "decr_hitratio", decr_rate, st); submit_derive ("memcached_ops", "decr", decr, st); } return 0; } /* int memcached_read */
static int memcached_read (void) /* {{{ */ { char buf[1024]; char *fields[3]; char *ptr; char *line; char *saveptr; int fields_num; gauge_t bytes_used = NAN; gauge_t bytes_total = NAN; gauge_t hits = NAN; gauge_t gets = NAN; counter_t rusage_user = 0; counter_t rusage_syst = 0; counter_t octets_rx = 0; counter_t octets_tx = 0; /* get data from daemon */ if (memcached_query_daemon (buf, sizeof (buf)) < 0) { return -1; } #define FIELD_IS(cnst) \ (((sizeof(cnst) - 1) == name_len) && (strcmp (cnst, fields[1]) == 0)) ptr = buf; saveptr = NULL; while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL) { int name_len; ptr = NULL; fields_num = strsplit(line, fields, 3); if (fields_num != 3) continue; name_len = strlen(fields[1]); if (name_len == 0) continue; /* * For an explanation on these fields please refer to * <http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt> */ /* * CPU time consumed by the memcached process */ if (FIELD_IS ("rusage_user")) { rusage_user = atoll (fields[2]); } else if (FIELD_IS ("rusage_system")) { rusage_syst = atoll(fields[2]); } /* * Number of threads of this instance */ else if (FIELD_IS ("threads")) { submit_gauge2 ("ps_count", NULL, NAN, atof (fields[2])); } /* * Number of items stored */ else if (FIELD_IS ("curr_items")) { submit_gauge ("memcached_items", "current", atof (fields[2])); } /* * Number of bytes used and available (total - used) */ else if (FIELD_IS ("bytes")) { bytes_used = atof (fields[2]); } else if (FIELD_IS ("limit_maxbytes")) { bytes_total = atof(fields[2]); } /* * Connections */ else if (FIELD_IS ("curr_connections")) { submit_gauge ("memcached_connections", "current", atof (fields[2])); } /* * Commands */ else if ((name_len > 4) && (strncmp (fields[1], "cmd_", 4) == 0)) { const char *name = fields[1] + 4; submit_counter ("memcached_command", name, atoll (fields[2])); if (strcmp (name, "get") == 0) gets = atof (fields[2]); } /* * Operations on the cache, i. e. cache hits, cache misses and evictions of items */ else if (FIELD_IS ("get_hits")) { submit_counter ("memcached_ops", "hits", atoll (fields[2])); hits = atof (fields[2]); } else if (FIELD_IS ("get_misses")) { submit_counter ("memcached_ops", "misses", atoll (fields[2])); } else if (FIELD_IS ("evictions")) { submit_counter ("memcached_ops", "evictions", atoll (fields[2])); } /* * Network traffic */ else if (FIELD_IS ("bytes_read")) { octets_rx = atoll (fields[2]); } else if (FIELD_IS ("bytes_written")) { octets_tx = atoll (fields[2]); } } /* while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL) */ if (!isnan (bytes_used) && !isnan (bytes_total) && (bytes_used <= bytes_total)) submit_gauge2 ("df", "cache", bytes_used, bytes_total - bytes_used); if ((rusage_user != 0) || (rusage_syst != 0)) submit_counter2 ("ps_cputime", NULL, rusage_user, rusage_syst); if ((octets_rx != 0) || (octets_tx != 0)) submit_counter2 ("memcached_octets", NULL, octets_rx, octets_tx); if (!isnan (gets) && !isnan (hits)) { gauge_t rate = NAN; if (gets != 0.0) rate = 100.0 * hits / gets; submit_gauge ("percent", "hitratio", rate); } return 0; }
static int vserver_read (void) { #if NAME_MAX < 1024 # define DIRENT_BUFFER_SIZE (sizeof (struct dirent) + 1024 + 1) #else # define DIRENT_BUFFER_SIZE (sizeof (struct dirent) + NAME_MAX + 1) #endif DIR *proc; struct dirent *dent; /* 42 */ char dirent_buffer[DIRENT_BUFFER_SIZE]; errno = 0; proc = opendir (PROCDIR); if (proc == NULL) { char errbuf[1024]; ERROR ("vserver plugin: fopen (%s): %s", PROCDIR, sstrerror (errno, errbuf, sizeof (errbuf))); return (-1); } while (42) { int len; char file[BUFSIZE]; FILE *fh; char buffer[BUFSIZE]; struct stat statbuf; char *cols[4]; int status; status = readdir_r (proc, (struct dirent *) dirent_buffer, &dent); if (status != 0) { char errbuf[4096]; ERROR ("vserver plugin: readdir_r failed: %s", sstrerror (errno, errbuf, sizeof (errbuf))); closedir (proc); return (-1); } else if (dent == NULL) { /* end of directory */ break; } if (dent->d_name[0] == '.') continue; len = ssnprintf (file, sizeof (file), PROCDIR "/%s", dent->d_name); if ((len < 0) || (len >= BUFSIZE)) continue; status = stat (file, &statbuf); if (status != 0) { char errbuf[4096]; WARNING ("vserver plugin: stat (%s) failed: %s", file, sstrerror (errno, errbuf, sizeof (errbuf))); continue; } if (!S_ISDIR (statbuf.st_mode)) continue; /* socket message accounting */ len = ssnprintf (file, sizeof (file), PROCDIR "/%s/cacct", dent->d_name); if ((len < 0) || ((size_t) len >= sizeof (file))) continue; if (NULL == (fh = fopen (file, "r"))) { char errbuf[1024]; ERROR ("Cannot open '%s': %s", file, sstrerror (errno, errbuf, sizeof (errbuf))); } while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh))) { derive_t rx; derive_t tx; char *type_instance; if (strsplit (buffer, cols, 4) < 4) continue; if (0 == strcmp (cols[0], "UNIX:")) type_instance = "unix"; else if (0 == strcmp (cols[0], "INET:")) type_instance = "inet"; else if (0 == strcmp (cols[0], "INET6:")) type_instance = "inet6"; else if (0 == strcmp (cols[0], "OTHER:")) type_instance = "other"; else if (0 == strcmp (cols[0], "UNSPEC:")) type_instance = "unspec"; else continue; rx = vserver_get_sock_bytes (cols[1]); tx = vserver_get_sock_bytes (cols[2]); /* cols[3] == errors */ traffic_submit (dent->d_name, type_instance, rx, tx); } /* while (fgets) */ if (fh != NULL) { fclose (fh); fh = NULL; } /* thread information and load */ len = ssnprintf (file, sizeof (file), PROCDIR "/%s/cvirt", dent->d_name); if ((len < 0) || ((size_t) len >= sizeof (file))) continue; if (NULL == (fh = fopen (file, "r"))) { char errbuf[1024]; ERROR ("Cannot open '%s': %s", file, sstrerror (errno, errbuf, sizeof (errbuf))); } while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh))) { int n = strsplit (buffer, cols, 4); if (2 == n) { char *type_instance; gauge_t value; if (0 == strcmp (cols[0], "nr_threads:")) type_instance = "total"; else if (0 == strcmp (cols[0], "nr_running:")) type_instance = "running"; else if (0 == strcmp (cols[0], "nr_unintr:")) type_instance = "uninterruptable"; else if (0 == strcmp (cols[0], "nr_onhold:")) type_instance = "onhold"; else continue; value = atof (cols[1]); submit_gauge (dent->d_name, "vs_threads", type_instance, value); } else if (4 == n) { if (0 == strcmp (cols[0], "loadavg:")) { gauge_t snum = atof (cols[1]); gauge_t mnum = atof (cols[2]); gauge_t lnum = atof (cols[3]); load_submit (dent->d_name, snum, mnum, lnum); } } } /* while (fgets) */ if (fh != NULL) { fclose (fh); fh = NULL; } /* processes and memory usage */ len = ssnprintf (file, sizeof (file), PROCDIR "/%s/limit", dent->d_name); if ((len < 0) || ((size_t) len >= sizeof (file))) continue; if (NULL == (fh = fopen (file, "r"))) { char errbuf[1024]; ERROR ("Cannot open '%s': %s", file, sstrerror (errno, errbuf, sizeof (errbuf))); } while ((fh != NULL) && (NULL != fgets (buffer, BUFSIZE, fh))) { char *type = "vs_memory"; char *type_instance; gauge_t value; if (strsplit (buffer, cols, 2) < 2) continue; if (0 == strcmp (cols[0], "PROC:")) { type = "vs_processes"; type_instance = ""; value = atof (cols[1]); } else { if (0 == strcmp (cols[0], "VM:")) type_instance = "vm"; else if (0 == strcmp (cols[0], "VML:")) type_instance = "vml"; else if (0 == strcmp (cols[0], "RSS:")) type_instance = "rss"; else if (0 == strcmp (cols[0], "ANON:")) type_instance = "anon"; else continue; value = atof (cols[1]) * pagesize; } submit_gauge (dent->d_name, type, type_instance, value); } /* while (fgets) */ if (fh != NULL) { fclose (fh); fh = NULL; } } /* while (readdir) */ closedir (proc); return (0); } /* int vserver_read */
static int apache_read_host (user_data_t *user_data) /* {{{ */ { char *ptr; char *saveptr; char *line; char *fields[4]; int fields_num; apache_t *st; st = user_data->data; int status; char *content_type; static const char *text_plain = "text/plain"; assert (st->url != NULL); /* (Assured by `config_add') */ if (st->curl == NULL) { status = init_host (st); if (status != 0) return (-1); } assert (st->curl != NULL); st->apache_buffer_fill = 0; if (curl_easy_perform (st->curl) != CURLE_OK) { ERROR ("apache: curl_easy_perform failed: %s", st->apache_curl_error); return (-1); } /* fallback - server_type to apache if not set at this time */ if (st->server_type == -1) { WARNING ("apache plugin: Unable to determine server software " "automatically. Will assume Apache."); st->server_type = APACHE; } status = curl_easy_getinfo (st->curl, CURLINFO_CONTENT_TYPE, &content_type); if ((status == CURLE_OK) && (content_type != NULL) && (strncasecmp (content_type, text_plain, strlen (text_plain)) != 0)) { WARNING ("apache plugin: `Content-Type' response header is not `%s' " "(received: `%s'). Expecting unparseable data. Please check `URL' " "parameter (missing `?auto' suffix ?)", text_plain, content_type); } ptr = st->apache_buffer; saveptr = NULL; while ((line = strtok_r (ptr, "\n\r", &saveptr)) != NULL) { ptr = NULL; fields_num = strsplit (line, fields, STATIC_ARRAY_SIZE (fields)); if (fields_num == 3) { if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "Accesses:") == 0)) submit_derive ("apache_requests", "", atoll (fields[2]), st); else if ((strcmp (fields[0], "Total") == 0) && (strcmp (fields[1], "kBytes:") == 0)) submit_derive ("apache_bytes", "", 1024LL * atoll (fields[2]), st); } else if (fields_num == 2) { if (strcmp (fields[0], "Scoreboard:") == 0) submit_scoreboard (fields[1], st); else if ((strcmp (fields[0], "BusyServers:") == 0) /* Apache 1.* */ || (strcmp (fields[0], "BusyWorkers:") == 0) /* Apache 2.* */) submit_gauge ("apache_connections", NULL, atol (fields[1]), st); else if ((strcmp (fields[0], "IdleServers:") == 0) /* Apache 1.x */ || (strcmp (fields[0], "IdleWorkers:") == 0) /* Apache 2.x */) submit_gauge ("apache_idle_workers", NULL, atol (fields[1]), st); } } st->apache_buffer_fill = 0; return (0); } /* }}} int apache_read_host */