add prod munin plugins

This commit is contained in:
Thibault Duplessis 2012-12-22 15:40:52 +01:00
parent 42809f6670
commit 5547884ba4
7 changed files with 173 additions and 0 deletions

View file

@ -0,0 +1,21 @@
#!/usr/bin/env php
<?php
if(isset($argv[1]) && 'config' == $argv[1]) {
echo "graph_title Lichess game index growth
graph_args --base 1000 -l 0
graph_vlabel games
graph_category lichess
games.label games
games.draw AREA
games.type DERIVE
";
exit;
}
echo "games.value ";
$response = file_get_contents("http://localhost:9200/lila/game/_count");
$count = json_decode($response)->count;
echo $count;
echo "\n";

32
bin/prod/munin/lichess_log_size Executable file
View file

@ -0,0 +1,32 @@
#!/usr/bin/env php
<?php
$logs = array(
"main_log" => 'cat /home/lila/logs/output.log | wc -l',
"ai_log" => 'ssh ai2.lichess.org "cat /home/lila/logs/output.log | wc -l"',
"mongo_log" => 'cat /var/log/mongodb/mongodb.log | wc -l',
"nginx_log" => 'cat /var/log/nginx/lila.error.log | wc -l'
);
if(isset($argv[1]) && 'config' == $argv[1]) {
echo "graph_title Lichess log size growth
graph_args --base 1000 --lower-limit 0.01 --logarithmic
graph_vlabel growth
graph_category lichess
";
foreach ($logs as $log => $c) {
$name = str_replace('_', ' ', $log);
echo "$log.label $name
$log.draw LINE
$log.type DERIVE
$log.min 0
";
}
exit;
}
foreach ($logs as $log => $command) {
echo "$log.value ";
echo exec($command) . "\n";
}

27
bin/prod/munin/lichess_moves Executable file
View file

@ -0,0 +1,27 @@
#!/usr/bin/env php
<?php
if(isset($argv[1]) && 'config' == $argv[1]) {
echo "graph_title Lichess moves per second
graph_args --base 1000 -l 0
graph_vlabel moves
graph_category lichess
moves.label moves
moves.draw AREA
";
exit;
}
$url = 'http://en.lichess.org/monitor/mps';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_PORT => 80,
CURLOPT_USERAGENT => 'munin',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 2
));
$moves = curl_exec($curl);
echo "moves.value ".$moves."\n";

31
bin/prod/munin/lichess_players Executable file
View file

@ -0,0 +1,31 @@
#!/usr/bin/env php
<?php
if(isset($argv[1]) && 'config' == $argv[1]) {
echo "graph_title Lichess players
graph_args --base 1000 -l 0
graph_vlabel players
graph_category lichess
players.label players
players.draw AREA
named.label named
named.draw AREA
";
exit;
}
$url = 'http://en.lichess.org/monitor/players';
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_PORT => 80,
CURLOPT_USERAGENT => 'munin',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 2
));
$value = curl_exec($curl);
list($players, $named) = explode(' ', $value);
echo "players.value ".$players."\n";
echo "named.value ".$named."\n";

View file

@ -0,0 +1,20 @@
#!/usr/bin/env php
<?php
if(isset($argv[1]) && 'config' == $argv[1]) {
echo "graph_title Lichess new players per day
graph_args --base 1000 -l 0
graph_vlabel players/day
graph_category lichess
players.label players/day
players.draw AREA
";
exit;
}
echo "players.value ";
$mongo = new Mongo();
$collection = $mongo->selectCollection('lichess', 'user2');
echo $collection->count(array('createdAt' => array('$gte' => new MongoDate(date_create('- 1 day')->getTimestamp()))));
echo "\n";

View file

@ -0,0 +1,20 @@
#!/usr/bin/env php
<?php
if(isset($argv[1]) && 'config' == $argv[1]) {
echo "graph_title Lichess Forum posts per today
graph_args --base 1000 -l 0
graph_vlabel posts/day
graph_category lichess
posts.label posts/day
posts.draw AREA
";
exit;
}
echo "posts.value ";
$mongo = new Mongo();
$collection = $mongo->selectCollection('lichess', 'f_post');
echo $collection->count(array('createdAt' => array('$gte' => new MongoDate(date_create('- 1 day')->getTimestamp()))));
echo "\n";

View file

@ -0,0 +1,22 @@
#!/usr/bin/env ruby
script = 'db.user2.group({cond:{"settings.theme":{$exists:true}},key:{"settings.theme":true},initial:{s:0},reduce:function(o,p){p.s++;}}).forEach(function(y) { print(y["settings.theme"] + ".value " + y.s);});'
command = 'mongo lichess --eval \'%s\'' % script
themes = ['green', 'brown', 'blue', 'grey', 'wood', 'canvas']
if ARGV.include? 'config'
puts "graph_title Lichess themes popularity
graph_args --base 1000 -l 0
graph_vlabel users
graph_category lichess
"
themes.each do |theme|
puts "#{theme}.label #{theme}
#{theme}.draw LINE
"
end
else
puts IO.popen(command).readlines.to_a[2..-1].join
end