aboutsummaryrefslogtreecommitdiffstats
path: root/nextcloud_munin.php
diff options
context:
space:
mode:
authorM.Gergő2020-04-08 01:19:13 +0200
committerM.Gergő2020-04-08 01:19:13 +0200
commit82506c3cfac8c6e85adc8b0e72aaad8a23bc50e0 (patch)
treee2b56f002c877e322962ccfaa687aca2c8c7dc6a /nextcloud_munin.php
parentb71aec751deb8e6bf5a08760050c2c9149f53cb5 (diff)
downloadmunin-nextcloud-82506c3cfac8c6e85adc8b0e72aaad8a23bc50e0.tar.gz
munin-nextcloud-82506c3cfac8c6e85adc8b0e72aaad8a23bc50e0.zip
count Flashing users
Diffstat (limited to 'nextcloud_munin.php')
-rwxr-xr-xnextcloud_munin.php30
1 files changed, 15 insertions, 15 deletions
diff --git a/nextcloud_munin.php b/nextcloud_munin.php
index b27e35f..4ae4d8f 100755
--- a/nextcloud_munin.php
+++ b/nextcloud_munin.php
@@ -36,7 +36,7 @@ $time_req = time()-60*$set['diff_minutes'];
$ret['g_order'] = "nxt_users_all nxt_users_web nxt_users_app";
// skeleton for returning
- foreach(array('users_all', 'users_web', 'users_app', 'users_win', 'users_linux', 'users_oos') as $key => $val){
+ foreach(array('users_all', 'users_web', 'users_app','users_flash') as $key => $val){
$ret['data'][$val]['value'] = 0;
$ret['data'][$val]['draw'] = "LINE1.2";
$ret['data'][$val]['type'] = "GAUGE";
@@ -47,12 +47,9 @@ $time_req = time()-60*$set['diff_minutes'];
$ret['data']['users_web']['info'] = "Clients logged in by webpage.";
$ret['data']['users_app']['label'] = "By App";
$ret['data']['users_app']['info'] = "Connected clients with an app.";
- $ret['data']['users_win']['label'] = "Windows";
- $ret['data']['users_win']['info'] = "Clients on windows";
- $ret['data']['users_linux']['label'] = "Linux";
- $ret['data']['users_linux']['info'] = "Clients on Linux";
- $ret['data']['users_oos']['label'] = "Other OS";
- $ret['data']['users_oos']['info'] = "Clients on other OS";
+ $ret['data']['users_flash']['label'] = "Web(<5min)";
+ $ret['data']['users_flash']['info'] = "Rapid web users (succesfully logged out in less than 5 minutes)";
+
mysqli_set_charset($l, "utf8");
$r = mysqli_query($l, "SELECT * FROM ".mysqli_real_escape_string($l, $set['db_db']).".".mysqli_real_escape_string($l, $set['db_prefix'])."authtoken
@@ -70,16 +67,19 @@ $time_req = time()-60*$set['diff_minutes'];
$ret['data']['users_app']['value']++;
}
$ret['data']['users_all']['value']++; //everybody
-
- if(stripos($row['name'], 'windows') !== false){ //If "windows" in User Agent
- $ret['data']['users_win']['value']++;
- } else if(stripos($row['name'], 'linux') !== false){ //If "Linux" in User Agent
- $ret['data']['users_linux']['value']++;
- } else { //Other OS
- $ret['data']['users_oos']['value']++;
- }
}
@mysqli_free_result($r);
+
+ $r = mysqli_query($l, "SELECT COUNT(*) AS `cnt` FROM ".mysqli_real_escape_string($l, $set['db_db']).".".mysqli_real_escape_string($l, $set['db_prefix'])."preferences
+ WHERE `configkey`='lastLogin' AND `configvalue` >= ".mysqli_real_escape_string($l, $time_req)." AND `userid` NOT IN (
+ SELECT `uid` FROM ".mysqli_real_escape_string($l, $set['db_db']).".".mysqli_real_escape_string($l, $set['db_prefix'])."authtoken
+ WHERE `last_activity` >= ".mysqli_real_escape_string($l, $time_req)." AND `type` = 0
+ );"
+ );
+ $ret['data']['users_flash']['value'] = mysqli_fetch_array($r, MYSQLI_ASSOC)['cnt'];
+ $ret['data']['users_all']['value'] += $ret['data']['users_flash']['value'];
+
+ @mysqli_free_result($r);
return $ret;
}