sadm_server_housekeeping.sh

3 minute read

NAME

sadm_server_housekeeping.sh
Enforce security SADMIN Web interface & crontab files

SYNOPSIS

sadm_server_housekeeping.sh [-d 0-9] [-h] [-v]
$SADMIN/bin/sadm_server_housekeeping.sh - v1.48
Posted 2021-05-27 - Updated 2021-05-27
Supported on Linux
Can only be run on SADMIN Server.

DESCRIPTION

The function of this script is to perform various housekeeping, such as making sure permission and owner/group are correctly set on the SADMIN web site. It also make sure the SADMIN various crontab in “/etc/cron.d” are set to the proper permission. Finally, alerts older than 7 days are move to the alert archive file.

Here is a list of the various functions executed by this script

  • Make sure all the Web directories and files have proper owner, group and permission
  • Archive alert older than 7 days to $SADMIN/cfg/alert_archive.txt
  • Remove temporary performance graphics files.

Back to the top

EXAMPLE

# sadm_server_housekeeping.sh 
================================================================================
Sat May 29 11:02:37 EDT 2021 - sadm_server_housekeeping.sh V2.8 - SADM Lib. V3.70
Server Name: holmes.maison.ca - Type: LINUX
CENTOS 7.9.2009 Kernel 3.10.0-1160.25.1.el7.x86_64
==================================================
 
Move Alert older than 7 days to the alert history file.
They are move from /sadmin/cfg/alert_history.txt to /sadmin/cfg/alert_archive.txt file.
Archiving Alert: 2021.05.22 08:10 holmes Success of 'sa_rsync_ds410_to_ds409' on holmes. 
[ OK ] Alert archiving done.

Server Directories HouseKeeping.
[ OK ] find /sadmin/www -type d -exec chmod -R 775 {} \;
[ OK ] find /sadmin/www -exec chown -R apache:apache {} \;

Server Files HouseKeeping.
Make sure SADMIN crontab file have proper permission and owner
[ OK ] running chmod 0644 /etc/cron.d/sadm_server && chown root:root /etc/cron.d/sadm_server
[ OK ] running chmod 0644 /etc/cron.d/sadm_osupdate && chown root:root /etc/cron.d/sadm_osupdate
[ OK ] running chmod 0644 /etc/cron.d/sadm_backup && chown root:root /etc/cron.d/sadm_backup

Setting permissions in the website directories.
[ OK ] running find /sadmin/www/images -type f -exec chmod 664 {} \;
[ OK ] running find /sadmin/www -type f -name *.php -exec chmod 664 {} \;
[ OK ] running find /sadmin/www -type f -name *.css -exec chmod 664 {} \;
[ OK ] running find /sadmin/www -type f -name *.js -exec chmod 664 {} \; 
[ OK ] running find /sadmin/www -type f -name *.rrd -exec chmod 664 {} \; 
[ OK ] running find /sadmin/www -type f -name *.pdf -exec chmod 664 {} \;
[ OK ] running find /sadmin/www/dat -type f -exec chmod 664 {} \;

Delete any *.png files older than 5 days in /sadmin/www/tmp/perf.
[ OK ] running find /sadmin/www/tmp/perf -type f -mtime +5 -name '*.png' -exec rm -f {} \;

==================================================
Script exit code is 0 (Success) and execution time is 00:00:09
History (/sadmin/dat/rch/holmes_sadm_server_housekeeping.rch) trim to 35 lines.
Script will send an alert only when it terminate with error ($SADM_ALERT_TYPE=1).
Script succeeded, no alert will be send to 'default' alert group.
New log (/sadmin/log/holmes_sadm_server_housekeeping.log) created ($SADM_LOG_APPEND='N').
End of sadm_server_housekeeping.sh - Sat May 29 11:02:43 EDT 2021
================================================================================

Back to the top

OPTIONS

Options Description
[ -d 0-9 ] Set debug level from 0 to 9 (Default is 0)
[ -h ] Display this help and exit.
[ -v ] Output version information and exit.

ENVIRONMENT

  • The “$SADMIN” environment variable must be defined and contains the root directory of the SADMIN tools (normally /opt/sadmin). It should be already done, the setup script have updated the ‘/etc/profile.d/sadmin.sh’ and the ‘/etc/environment’ files.
  • The SADMIN configuration file, is needed and loaded in memory at the beginning of every scripts. This file should already exist and contains your SADMIN configuration and preference setting.
  • For Shell script the Shell Library is used and for Python script the Python Library is used.

EXIT STATUS

Exit Code Description
0 An exit status of zero indicates success.
1 Failure is indicated by a nonzero value, typically ‘1’.

AUTHOR

Jacques Duplessis
Any suggestions or bug report can be submitted at the support page

Copyright © 2021 Free Software Foundation, Inc. License GPLv3+: GNU GPL version 3 or later
This is free software, you are free to change and redistribute it.
There is NO WARRANTY to the extent permitted by law.

SEE ALSO

sadm_client_housekeeping.sh - Purge old log,rch,nmon files and check $SADMIN permission
sadm_server_housekeeping.sh - Enforce security SADMIN Web interface & crontab files sadm_daily_farm_fetch.sh - Collect Hardware/Software/Performance data from actives servers
sadm_database_update.py - Take data collected from clients and update database
sadm_nmon_rrd_update.sh - Daily performance database update
sadm_subnet-lookup.py - Scan network selected subnet & store info in database
sadm_backupdb.sh - Backup one or all MySQL/MariaDB databases on the system
sadmin.cfg - SADMIN main configuration file
System Information File - Documentation about the system information file