-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathget_connected_users_5_munin_proxy.php
executable file
·69 lines (49 loc) · 1.89 KB
/
get_connected_users_5_munin_proxy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
#!/usr/bin/php
<?php
$doc = <<<CUT
=head1 NAME
chamilo_connections - Munin plugin to monitor the number of live connections on Chamilo portals.
=head1 APPLICABLE SYSTEMS
Chamilo 1.* web applications.
=head1 CONFIGURATION
The plugin needs access to the root web directory /var/www (or any other given
path) in order to scan for Chamilo installations. It also offers a way to
define subdirs if your Chamilo portals are generally stored under two folder
levels inside /var/www/. The plugin also needs the possibility to execute PHP
on the command line (php-cli package) and to connect to a MySQL database
(php5-mysql package).
=head1 INTERPRETATION
The plugin shows the number of connected users at any given time for any
Chamilo portal, indicating the URL of the corresponding portal.
=head1 MAGIC MARKERS
#%# family=auto
#%# capabilities=autoconf
=head1 BUGS
None known of
=head1 VERSION
0.2
=head1 AUTHOR
Yannick Warnier <[email protected]>
=head1 LICENSE
AGPLv3
=cut
CUT;
// Get the number of minutes from the name of this script
// (this requires maintaining the same name structure)
$scriptNameParts = preg_split('/_/', __FILE__);
$last_connect_minutes = $scriptNameParts[count($scriptNameParts) - 3];
if (intval($last_connect_minutes) != $last_connect_minutes) {
$last_connect_minutes = 5;
}
if (!empty($argv[1]) && $argv[1] == 'config') {
// Global Munin attr., see http://munin-monitoring.org/wiki/protocol-config
if (!is_file('/tmp/get_connected_users_config_'.$last_connect_minutes)) {
@exec(__DIR__.'/get_connected_users_'.$last_connect_minutes.'_munin.php config');
}
readfile('/tmp/get_connected_users_config_'.$last_connect_minutes);
exit;
}
if (!is_file('/tmp/get_connected_users_'.$last_connect_minutes)) {
@exec(__DIR__.'/get_connected_users_'.$last_connect_minutes.'_munin.php');
}
readfile('/tmp/get_connected_users_'.$last_connect_minutes);