mirror of
https://github.com/Yubico/yubikey-val.git
synced 2025-02-08 03:54:20 +01:00
refactor queuelength munin graph to show individual values
as an AREASTACK graph.
This commit is contained in:
parent
1b2dfd136c
commit
1ff2a8c810
@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/php
|
#!/usr/bin/php
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
# Copyright (c) 2010-2013 Yubico AB
|
# Copyright (c) 2010-2014 Yubico AB
|
||||||
# All rights reserved.
|
# All rights reserved.
|
||||||
#
|
#
|
||||||
# Redistribution and use in source and binary forms, with or without
|
# Redistribution and use in source and binary forms, with or without
|
||||||
@ -32,33 +32,62 @@ set_include_path(get_include_path() . PATH_SEPARATOR .
|
|||||||
"/etc/yubico/val:/usr/share/yubikey-val");
|
"/etc/yubico/val:/usr/share/yubikey-val");
|
||||||
|
|
||||||
require_once 'ykval-config.php';
|
require_once 'ykval-config.php';
|
||||||
require_once 'ykval-synclib.php';
|
require_once 'ykval-db.php';
|
||||||
require_once 'ykval-log.php';
|
|
||||||
|
function url2shortname ($url) {
|
||||||
|
if (preg_match("/^[^\/]+\/\/([a-z0-9-]+)/", $url, $name)==0){
|
||||||
|
echo "Cannot match URL hostname: " . $url . "\n";
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
return $name[1];
|
||||||
|
}
|
||||||
|
|
||||||
if ($argc==2 && strcmp($argv[1], "autoconf") == 0) {
|
if ($argc==2 && strcmp($argv[1], "autoconf") == 0) {
|
||||||
print "yes\n";
|
print "yes\n";
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$urls = $baseParams['__YKVAL_SYNC_POOL__'];
|
||||||
|
$shortnames = array_map("url2shortname", $urls);
|
||||||
|
|
||||||
if ($argc==2 && strcmp($argv[1], "config") == 0) {
|
if ($argc==2 && strcmp($argv[1], "config") == 0) {
|
||||||
|
|
||||||
echo "graph_title YK-VAL queue size\n";
|
echo "graph_title YK-VAL queue size\n";
|
||||||
echo "graph_vlabel sync requests in queue\n";
|
echo "graph_vlabel sync requests in queue\n";
|
||||||
echo "graph_category ykval\n";
|
echo "graph_category ykval\n";
|
||||||
|
|
||||||
echo "queuelength.label sync requests\n";
|
foreach ($shortnames as $shortname) {
|
||||||
echo "queuelength.draw AREA\n";
|
echo "queuelength_${shortname}.label sync ${shortname}\n";
|
||||||
|
echo "queuelength_${shortname}.draw AREASTACK\n";
|
||||||
|
echo "queuelength_${shortname}.type GAUGE\n";
|
||||||
|
}
|
||||||
|
|
||||||
exit (0);
|
exit (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
$sync = new SyncLib('ykval-verify:synclib');
|
|
||||||
if (isset($_SERVER['REMOTE_ADDR'])) {
|
$db = Db::GetDatabaseHandle($baseParams, 'ykval-munin-queuelength');
|
||||||
$sync->addField('ip', $_SERVER['REMOTE_ADDR']);
|
if (!$db->connect()) {
|
||||||
|
logdie($myLog, 'ERROR Database connect error (1)');
|
||||||
}
|
}
|
||||||
|
|
||||||
$len = $sync->getQueueLength ();
|
$res = $db->customQuery('select server,count(server) as count from queue group by server');
|
||||||
echo "queuelength.value $len\n";
|
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
|
#%# family=auto
|
||||||
#%# capabilities=autoconf
|
#%# capabilities=autoconf
|
||||||
|
Loading…
x
Reference in New Issue
Block a user