aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xegyéb/munin/mayor_munin.php120
-rw-r--r--egyéb/nextcloud/mayor-nextcloud.php2
2 files changed, 80 insertions, 42 deletions
diff --git a/egyéb/munin/mayor_munin.php b/egyéb/munin/mayor_munin.php
index ed59b5c2..f0021a9a 100755
--- a/egyéb/munin/mayor_munin.php
+++ b/egyéb/munin/mayor_munin.php
@@ -11,7 +11,7 @@ $set['t_active'] = "10"; //pl: 10 perc (Az elmúlt x percben aktívak voltak)
$ret = array();
-if (isset($argv[1]) and $argv[1] == "config"){
+if (isset($argv[1]) and $argv[1] == "config"){
$cf = "host_name ".$set['naplo_host']."\n";
$cf .= "graph_title Napló rendszerterhelés (Mayor)\n";
@@ -50,7 +50,15 @@ if (isset($argv[1]) and $argv[1] == "config"){
$cf .= "mayor_a_tt.label Aktív: tétlen\n";
$cf .= "mayor_a_tt.draw LINE1\n";
- $cf .= "mayor_a_tt.info Tétlen, de bejelentkezett felhasználók\n";
+ $cf .= "mayor_a_tt.info Tétlen, de bejelentkezett felhasználók\n";
+
+ $cf .= "mayor_villam.label Villámgyors\n";
+ $cf .= "mayor_villam.draw LINE1\n";
+ $cf .= "mayor_villam.info Azok a villámgyors felhasználók, akik kevesebb mint 5 perc alatt, be, és ki is jelentkeztenk.\n";
+
+ $cf .= "mayor_s_len.label Sikertelen\n";
+ $cf .= "mayor_s_len.draw LINE1\n";
+ $cf .= "mayor_s_len.info Sikertelen bejelentkezések\n";
echo iconv("UTF-8", "ISO-8859-2", $cf), PHP_EOL;
@@ -64,58 +72,88 @@ if (isset($argv[1]) and $argv[1] == "config"){
$ret['p_par'] = 0;
$ret['a_t1'] = 0;
$ret['a_t2'] = 0;
- $ret['a_tt'] = 0;
+ $ret['a_tt'] = 0;
+ $ret['villam'] = 0;
+ $ret['s_len'] = 0;
$l = mysqli_connect($set['db_host'], $set['db_user'], $set['db_pass'], $set['db_db']);
if(!$l){
-// echo "hiba\n ";
- $ret['ip_b'] = "U";
- $ret['ip_k'] = "U";
- $ret['p_pri'] = "U";
- $ret['p_par'] = "U";
- $ret['a_t1'] = "U";
- $ret['a_t2'] = "U";
- $ret['a_tt'] = "U";
-
+ // echo "hiba\n ";
+ $ret['ip_b'] = "U";
+ $ret['ip_k'] = "U";
+ $ret['p_pri'] = "U";
+ $ret['p_par'] = "U";
+ $ret['a_t1'] = "U";
+ $ret['a_t2'] = "U";
+ $ret['a_tt'] = "U";
+ $ret['villam'] = "U";
+ $ret['s_len'] = "U";
} else{
- mysqli_set_charset($l, "utf8");
- $r = mysqli_query($l," SELECT session.userAccount,session.policy, UNIX_TIMESTAMP(session.activity) AS activity, loginLog.ip
- FROM mayor_login.session, mayor_login.loginLog
- WHERE session.dt = loginLog.dt AND session.userAccount=loginLog.userAccount AND loginLog.flag=0; ");
+ mysqli_set_charset($l, "utf8");
+ $r = mysqli_query($l,"SELECT session.userAccount,session.policy, UNIX_TIMESTAMP(session.activity) AS activity, loginLog.ip
+ FROM mayor_login.session, mayor_login.loginLog
+ WHERE UNIX_TIMESTAMP(loginLog.dt) >= (UNIX_TIMESTAMP()-36000)
+ AND ( ABS(UNIX_TIMESTAMP(session.dt) - UNIX_TIMESTAMP(loginLog.dt))<2
+ AND session.userAccount=loginLog.userAccount ) AND loginLog.flag=0
+ GROUP BY session.sessionId ORDER BY activity ;"
+ );
+ while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
+ if($row['policy'] == "private") {
+ $ret['p_pri'] ++;
+ }
+ if($row['policy'] == "parent") {
+ $ret['p_par'] ++;
+ }
- while ($row = mysqli_fetch_array($r, MYSQLI_ASSOC)) {
- if($row['policy'] == "private") {
- $ret['p_pri'] ++;
- }
- if($row['policy'] == "parent") {
- $ret['p_par'] ++;
- }
-
- if( $row['activity'] >= time()-$set['t_active']*60){ //Az elmúlt x percben aktívak voltak
- $ret['a_t1']++;
- } else if( $row['activity'] >= time()-$set['t_active']*2*60){ //Az elmúlt 2*x percben aktívak voltak
- $ret['a_t2']++;
- } else {
- $ret['a_tt']++;
- }
-
- if( preg_match('/^((10\.)|(192\.168\.)|(172\.16\.)|(fd..\:)).*/', $row['ip']) ){
- $ret['ip_b']++ ;
- } else{
- $ret['ip_k']++ ;
+ if( $row['activity'] >= time()-$set['t_active']*60){ //Az elmúlt x percben aktívak voltak
+ $ret['a_t1']++;
+ } else if( $row['activity'] >= time()-$set['t_active']*2*60){ //Az elmúlt 2*x percben aktívak voltak
+ $ret['a_t2']++;
+ } else {
+ $ret['a_tt']++;
+ }
+
+ if( preg_match('/^((10\.)|(192\.168\.)|(172\.16\.)|(fd..\:)).*/', $row['ip']) ){
+ $ret['ip_b']++ ;
+ } else{
+ $ret['ip_k']++ ;
+ }
+
+ $ret['ip_sum']++; //Mindenki
}
+ @mysqli_free_result($r);
+
+ $r = mysqli_query($l,"SELECT COUNT(*) AS cnt FROM loginLog
+ WHERE UNIX_TIMESTAMP(dt) >= (UNIX_TIMESTAMP() - 300)
+ AND userAccount NOT IN (SELECT userAccount FROM session)
+ AND flag=0
+ ORDER BY dt desc ;"
+ );
+ $ret['villam'] = mysqli_fetch_array($r, MYSQLI_ASSOC)['cnt'];
+ $ret['ip_sum'] += $ret['villam'];
+ @mysqli_free_result($r);
+
+
+ $r = mysqli_query($l,"SELECT COUNT(*) AS cnt FROM loginLog
+ WHERE UNIX_TIMESTAMP(dt) >= (UNIX_TIMESTAMP() - 300)
+ AND userAccount NOT IN (SELECT userAccount FROM session)
+ AND flag!=0
+ ORDER BY dt desc ;"
+ );
+ $ret['s_len'] = mysqli_fetch_array($r, MYSQLI_ASSOC)['cnt'];
+ @mysqli_free_result($r);
}
- }
- @mysqli_free_result($r);
@mysqli_close($l);
- echo "mayor_ip_sum.value ".($ret['ip_b']+$ret['ip_k'])."\n". "mayor_ip_k.value ".$ret['ip_k']."\n". "mayor_ip_b.value ".$ret['ip_b']."\n" ;
+ echo "mayor_ip_sum.value ".($ret['ip_sum'])."\n". "mayor_ip_k.value ".$ret['ip_k']."\n". "mayor_ip_b.value ".$ret['ip_b']."\n" ;
echo "mayor_p_pri.value ".$ret['p_pri']."\n". "mayor_p_par.value ".$ret['p_par']."\n";
- echo "mayor_a_t1.value ".$ret['a_t1']."\n". "mayor_a_t2.value ".$ret['a_t2']."\n". "mayor_a_tt.value ".$ret['a_tt']."\n" ;
+ echo "mayor_a_t1.value ".$ret['a_t1']."\n". "mayor_a_t2.value ".$ret['a_t2']."\n". "mayor_a_tt.value ".$ret['a_tt']."\n" ;
+ echo "mayor_villam.value ".$ret['villam']."\n". "mayor_s_len.value ".$ret['s_len']."\n";
- } else{
+ } else{ // függvény/PHP hiány külön kezelve
echo "mayor_ip_sum.value U\n". "mayor_ip_b.value U\n". "mayor_ip_k.value U\n" ;
echo "mayor_p_pri.value U\n". "mayor_p_par.value U\n";
echo "mayor_a_t1.value U\n". "mayor_a_t2.value U\n". "mayor_a_tt.value U\n";
+ echo "mayor_villam.value U\n". "mayor_s_len.value U\n";
}
}
diff --git a/egyéb/nextcloud/mayor-nextcloud.php b/egyéb/nextcloud/mayor-nextcloud.php
index ed009cf2..a613c2ac 100644
--- a/egyéb/nextcloud/mayor-nextcloud.php
+++ b/egyéb/nextcloud/mayor-nextcloud.php
@@ -722,7 +722,7 @@ if (function_exists('mysqli_connect') and PHP_MAJOR_VERSION >= 7) { //MySQLi (Im
}
//-------------------------------------------------------------------------------------------------------------------------------
- if(true) { echo "\n\n######## Mayor-Nextcloud Script ########\n"; echo "######## (".date("Y-m-d H:i:s").")\n\n"; $t_start = microtime(true); }
+ if(true) { echo "\n\n######## Mayor-Nextcloud Script ########\n"; echo "######## (".date("Y-m-d H:i:s").") ########\n\n"; $t_start = microtime(true); }
if( file_exists($cfgfile)===TRUE ){