diff --git a/ykval-munin-queuelength.php b/ykval-munin-queuelength.php index 1779cd4..ac50acc 100755 --- a/ykval-munin-queuelength.php +++ b/ykval-munin-queuelength.php @@ -1,7 +1,7 @@ #!/usr/bin/php addField('ip', $_SERVER['REMOTE_ADDR']); + +$db = Db::GetDatabaseHandle($baseParams, 'ykval-munin-queuelength'); +if (!$db->connect()) { + logdie($myLog, 'ERROR Database connect error (1)'); } -$len = $sync->getQueueLength (); -echo "queuelength.value $len\n"; +$res = $db->customQuery('select server,count(server) as count from queue group by server'); +if ($res) { + $r = $res->fetchAll(PDO::FETCH_ASSOC); +} else { + logdie($myLog, 'ERROR getting data from db'); +} + +foreach ($shortnames as $shortname) { + $count = 0; + foreach ($r as $result) { + if(strpos($result['server'], "$shortname.") !== FALSE) { + $count = $result['count']; + break; + } + } + echo "queuelength_${shortname}.value $count\n"; +} #%# family=auto #%# capabilities=autoconf