#!/usr/bin/php connect()) return false; $result = $db->customQuery(' SELECT server, COUNT(server) as count FROM queue GROUP BY server'); if ($result) $result = $result->fetchAll(PDO::FETCH_ASSOC); else return false; $counters = array(); foreach ($result as $row) { $counters[$row['server']] = $row['count']; } return $counters; } $urls = $baseParams['__YKVAL_SYNC_POOL__']; if ($argc == 2 && strcmp($argv[1], 'autoconf') == 0) { if (is_array($urls) && count($urls) > 0) { echo "yes\n"; exit(0); } echo "no (sync pool not configured)\n"; exit(0); } if (($endpoints = endpoints($urls)) === FALSE) { echo "Cannot parse URLs from sync pool list\n"; exit(1); } if ($argc == 2 && strcmp($argv[1], 'config') == 0) { echo "graph_title YK-VAL queue size\n"; echo "graph_vlabel sync requests in queue\n"; echo "graph_category ykval\n"; foreach ($endpoints as $endpoint) { list ($internal, $label, $url) = $endpoint; echo "${internal}_queuelength.label sync ${label}\n"; echo "${internal}_queuelength.draw AREASTACK\n"; echo "${internal}_queuelength.type GAUGE\n"; } exit(0); } if (($counters = get_db_counters()) === FALSE) { echo "Error fetching data from database\n"; exit(1); } foreach ($endpoints as $endpoint) { list ($internal, $label, $url) = $endpoint; $count = 0; if (array_key_exists($url, $counters)) $count = $counters[$url]; echo "${internal}_queuelength.value $count\n"; } exit(0);