mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-25 18:38:30 +00:00
Merge pull request #530 from ak4t0sh/master
Moodle : fix and new plugin
This commit is contained in:
commit
cb3b953b2b
6 changed files with 130 additions and 13 deletions
|
@ -45,9 +45,6 @@ if (count($argv) === 2 && $argv[1] === 'config') {
|
||||||
echo "forum_posts.label posts\n";
|
echo "forum_posts.label posts\n";
|
||||||
echo "forum_posts.min 0\n";
|
echo "forum_posts.min 0\n";
|
||||||
echo "forum_posts.draw AREA\n";
|
echo "forum_posts.draw AREA\n";
|
||||||
echo "forum_discussion.draw STACK\n";
|
|
||||||
echo "forum_discussion.min 0\n";
|
|
||||||
echo "forum_discussion.label discussions\n";
|
|
||||||
exit(0);
|
exit(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,13 +57,7 @@ try {
|
||||||
}
|
}
|
||||||
|
|
||||||
$nb = 0;
|
$nb = 0;
|
||||||
if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}forum_posts WHERE timemodified > $graph_period")) != false) {
|
if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}forum_posts WHERE modified > $graph_period")) != false) {
|
||||||
$nb = $stmt->fetchColumn();
|
$nb = $stmt->fetchColumn();
|
||||||
}
|
}
|
||||||
echo "forum_posts.value $nb\n";
|
echo "forum_posts.value $nb\n";
|
||||||
|
|
||||||
$nb = 0;
|
|
||||||
if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}forum_discussions WHERE timemodified > $graph_period")) != false) {
|
|
||||||
$nb = $stmt->fetchColumn();
|
|
||||||
}
|
|
||||||
echo "forum_discussions.value $nb\n";
|
|
63
plugins/moodle/modules/moodle_mod_quiz.php
Normal file
63
plugins/moodle/modules/moodle_mod_quiz.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Moodle module quiz
|
||||||
|
* Munin plugin to count new quiz attempts
|
||||||
|
*
|
||||||
|
* It's required to define a container entry for this plugin in your
|
||||||
|
* /etc/munin/plugin-conf.d/munin-node (or a separate and dedicated file).
|
||||||
|
*
|
||||||
|
* @example Example entry for configuration:
|
||||||
|
* [moodle*]
|
||||||
|
* env.type mysql
|
||||||
|
* env.db moodle
|
||||||
|
* env.user mysql_user
|
||||||
|
* env.pass mysql_pass
|
||||||
|
* env.host localhost
|
||||||
|
* env.port 3306
|
||||||
|
* env.table_prefix mdl_
|
||||||
|
*
|
||||||
|
* @author Arnaud Trouvé <ak4t0sh@free.fr>
|
||||||
|
* @version 1.0 2014
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$dbh = null;
|
||||||
|
$db = getenv('db');
|
||||||
|
$type = getenv('type');
|
||||||
|
$host = getenv('host');
|
||||||
|
$user = getenv('user');
|
||||||
|
$pass = getenv('pass');
|
||||||
|
$table_prefix = getenv('table_prefix');
|
||||||
|
$port = getenv('port');
|
||||||
|
if (!$port)
|
||||||
|
$port = 3306;
|
||||||
|
//$graph_period = getenv('graph_period');
|
||||||
|
$graph_period = time() - 5*60;
|
||||||
|
|
||||||
|
|
||||||
|
if (count($argv) === 2 && $argv[1] === 'config') {
|
||||||
|
echo "graph_title Moodle Quiz Attempts\n";
|
||||||
|
echo "graph_args --base 1000 --lower-limit 0\n";
|
||||||
|
echo "graph_vlabel attempts\n";
|
||||||
|
echo "graph_category Moodle\n";
|
||||||
|
echo "graph_scale no\n";
|
||||||
|
echo "graph_info Displays the sum quiz attempts in your Moodle site\n";
|
||||||
|
echo "quiz_attempts.label attempts\n";
|
||||||
|
echo "quiz_attempts.min 0\n";
|
||||||
|
echo "quiz_attempts.draw AREA\n";
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dsn = $type . ':host=' . $host . ';port=' . $port . ';dbname=' . $db;
|
||||||
|
$dbh = new PDO($dsn, $user, $pass);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Connection failed\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
$nb = 0;
|
||||||
|
if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}quiz_attempts where timemodified > $graph_period")) != false) {
|
||||||
|
$nb = $stmt->fetchColumn();
|
||||||
|
}
|
||||||
|
echo "quiz_attempts.value $nb\n";
|
63
plugins/moodle/moodle_logs.php
Normal file
63
plugins/moodle/moodle_logs.php
Normal file
|
@ -0,0 +1,63 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Moodle Logs
|
||||||
|
* Munin plugin to count logs entries
|
||||||
|
*
|
||||||
|
* It's required to define a container entry for this plugin in your
|
||||||
|
* /etc/munin/plugin-conf.d/munin-node (or a separate and dedicated file).
|
||||||
|
*
|
||||||
|
* @example Example entry for configuration:
|
||||||
|
* [moodle*]
|
||||||
|
* env.type mysql
|
||||||
|
* env.db moodle
|
||||||
|
* env.user mysql_user
|
||||||
|
* env.pass mysql_pass
|
||||||
|
* env.host localhost
|
||||||
|
* env.port 3306
|
||||||
|
* env.table_prefix mdl_
|
||||||
|
*
|
||||||
|
* @author Arnaud Trouvé <ak4t0sh@free.fr>
|
||||||
|
* @version 1.0 2014
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$dbh = null;
|
||||||
|
$db = getenv('db');
|
||||||
|
$type = getenv('type');
|
||||||
|
$host = getenv('host');
|
||||||
|
$user = getenv('user');
|
||||||
|
$pass = getenv('pass');
|
||||||
|
$table_prefix = getenv('table_prefix');
|
||||||
|
$port = getenv('port');
|
||||||
|
if (!$port)
|
||||||
|
$port = 3306;
|
||||||
|
//$graph_period = getenv('graph_period');
|
||||||
|
$graph_period = time() - 5*60;
|
||||||
|
|
||||||
|
if (count($argv) === 2 && $argv[1] === 'config') {
|
||||||
|
echo "graph_title Moodle Logs\n";
|
||||||
|
echo "graph_args --base 1000 --lower-limit 0\n";
|
||||||
|
echo "graph_vlabel logs\n";
|
||||||
|
echo "graph_category Moodle\n";
|
||||||
|
echo "graph_scale no\n";
|
||||||
|
echo "graph_info Displays the number of new logs written\n";
|
||||||
|
echo "logs.label logs\n";
|
||||||
|
echo "logs.min 0\n";
|
||||||
|
echo "logs.draw AREA";
|
||||||
|
exit(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$dsn = $type . ':host=' . $host . ';port=' . $port . ';dbname=' . $db;
|
||||||
|
$dbh = new PDO($dsn, $user, $pass);
|
||||||
|
} catch (Exception $e) {
|
||||||
|
echo "Connection failed\n";
|
||||||
|
exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
//Online users
|
||||||
|
$nb = 0;
|
||||||
|
if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}log WHERE time > $graph_period")) != false) {
|
||||||
|
$nbusers = $stmt->fetchColumn();
|
||||||
|
}
|
||||||
|
echo "logs.value $nb\n";
|
|
@ -67,4 +67,4 @@ if (count($argv) === 2 && $argv[1] === 'config') {
|
||||||
foreach($data as $entry) {
|
foreach($data as $entry) {
|
||||||
echo "modules_".$entry->modulename.".label ".$entry->modulename."\n";
|
echo "modules_".$entry->modulename.".label ".$entry->modulename."\n";
|
||||||
echo "modules_".$entry->modulename.".value ".$entry->moduleinstance."\n";
|
echo "modules_".$entry->modulename.".value ".$entry->moduleinstance."\n";
|
||||||
}
|
}
|
||||||
|
|
|
@ -61,4 +61,4 @@ $nbusers = 0;
|
||||||
if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}user WHERE lastaccess > $graph_period")) != false) {
|
if (($stmt = $dbh->query("SELECT count(id) FROM {$table_prefix}user WHERE lastaccess > $graph_period")) != false) {
|
||||||
$nbusers = $stmt->fetchColumn();
|
$nbusers = $stmt->fetchColumn();
|
||||||
}
|
}
|
||||||
echo "users_online.value $nbusers\n";
|
echo "users_online.value $nbusers\n";
|
||||||
|
|
|
@ -81,4 +81,4 @@ $nbusers = 0;
|
||||||
if (($stmt = $dbh->query("SELECT COUNT(id) FROM {$table_prefix}user WHERE deleted=1")) != false) {
|
if (($stmt = $dbh->query("SELECT COUNT(id) FROM {$table_prefix}user WHERE deleted=1")) != false) {
|
||||||
$nbusers = $stmt->fetchColumn();
|
$nbusers = $stmt->fetchColumn();
|
||||||
echo "users_deleted.value $nbusers\n";
|
echo "users_deleted.value $nbusers\n";
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue