mirror of
https://github.com/librenms/librenms.git
synced 2024-09-21 10:28:13 +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:
parent
dcf4d0f378
commit
58d585e6fe
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";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
5
daily.sh
5
daily.sh
@ -4,12 +4,12 @@
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
@ -64,6 +64,7 @@ else
|
||||
php daily.php -f perf_times
|
||||
php daily.php -f callback
|
||||
php daily.php -f device_perf
|
||||
php daily.php -f purgeusers
|
||||
;;
|
||||
submodules)
|
||||
# Init+Update our submodules
|
||||
|
Loading…
Reference in New Issue
Block a user