mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Updated daily.sh/daily.php to support removing users that have not logged in for X days - Radius only for now
This commit is contained in:
18
daily.php
18
daily.php
@@ -30,7 +30,7 @@ Take a look at https://dev.mysql.com/doc/refman/5.6/en/innodb-buffer-pool.html f
|
||||
|
||||
The ' . $config['project_name'] . ' team.';
|
||||
send_mail($config['alert']['default_mail'],$subject,$message,$html=false);
|
||||
}
|
||||
}
|
||||
echo warn_innodb_buffer($innodb_buffer);
|
||||
exit(2);
|
||||
}
|
||||
@@ -110,3 +110,19 @@ if ($options['f'] === 'device_perf') {
|
||||
if ($options['f'] === 'notifications') {
|
||||
include_once 'notifications.php';
|
||||
}
|
||||
|
||||
if ($options['f'] === 'purgeusers') {
|
||||
$purge = 0;
|
||||
if (is_numeric($config['radius']['users_purge']) && $config['auth_mechanism'] === 'radius') {
|
||||
$purge = $config['radius']['users_purge'];
|
||||
}
|
||||
if ($purge > 0) {
|
||||
foreach (dbFetchRows("SELECT DISTINCT(`user`) FROM `authlog` WHERE `datetime` >= DATE_SUB(NOW(), INTERVAL ? DAY)", array($purge)) as $user) {
|
||||
$users[] = $user['user'];
|
||||
}
|
||||
$del_users = '"'.implode('","',$users).'"';
|
||||
if (dbDelete('users', "username NOT IN ($del_users)",array($del_users))) {
|
||||
echo "Removed users that haven't logged in for $purge days";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user