mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-25 18:38:30 +00:00
initial commit
This commit is contained in:
parent
24e77a2624
commit
711726ab8f
2 changed files with 108 additions and 0 deletions
31
plugins/moodle/moodle_users_online.php
Normal file
31
plugins/moodle/moodle_users_online.php
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Moodle Users Online
|
||||||
|
* Munin plugin to count online users
|
||||||
|
*
|
||||||
|
* 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
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
$db = getenv('db');
|
||||||
|
$type = getenv('type');
|
||||||
|
$host = getenv('host');
|
||||||
|
$user = getenv('user');
|
||||||
|
$pass = getenv('pass');
|
||||||
|
$port = getenv('port');
|
||||||
|
if (!$port)
|
||||||
|
$port = 3306;
|
77
plugins/moodle/moodle_users_total.php
Normal file
77
plugins/moodle/moodle_users_total.php
Normal file
|
@ -0,0 +1,77 @@
|
||||||
|
#!/usr/bin/php
|
||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Moodle Users Total
|
||||||
|
* Munin plugin to count total users
|
||||||
|
*
|
||||||
|
* 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');
|
||||||
|
|
||||||
|
|
||||||
|
if (count($argv) === 2 && $argv[1] === 'config') {
|
||||||
|
echo "graph_title Moodle Total Users\n";
|
||||||
|
echo "graph_args --base 1000 --lower-limit 0\n";
|
||||||
|
echo "graph_vlabel Total Users Count / ${graph_period}\n";
|
||||||
|
echo "graph_category Moodle\n";
|
||||||
|
echo "graph_scale no\n";
|
||||||
|
echo "graph_info Displays the sum of users, as well as active count, in your Moodle site\n";
|
||||||
|
|
||||||
|
echo "users_total.label total users\n";
|
||||||
|
echo "users_active.label active users\n";
|
||||||
|
|
||||||
|
echo "users_total.min 0\n";
|
||||||
|
echo "users_active.min 0\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);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//All users
|
||||||
|
$nbusers = 0;
|
||||||
|
if (($stmt = $dbh->query("SELECT COUNT(id) FROM {$table_prefix}user")) != false) {
|
||||||
|
$nbusers = $stmt->fetchColumn();
|
||||||
|
}
|
||||||
|
echo "users_total.value $nbusers\n";
|
||||||
|
|
||||||
|
//Active users (not deleted or suspended)
|
||||||
|
$nbusers = 0;
|
||||||
|
if (($stmt = $dbh->query("SELECT COUNT(id) FROM {$table_prefix}user WHERE deleted=0 AND suspended=0")) != false) {
|
||||||
|
$nbusers = $stmt->fetchColumn();
|
||||||
|
echo "users_active.value $nbusers\n";
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue