sadm_client_housekeeping.sh
NAME
sadm_client_housekeeping.sh - Set $SADMIN owner/group/permission, prune old log & rch files,check sadmin account.
SYNOPSIS
sadm_client_housekeeping.sh [-d 0-9] [-h] [-v]
DESCRIPTION
The function of this script is to perform various housekeeping, such as deleting old logs and history files not used for a number of days specified in the SADMIN configuration file. It also make sure that the permission within the $SADMIN are in good condition to allow proper utilization of the SADMIN tools.
Here is a list of the various functions executed by this script
- Make sure all the server files in “$SADMIN” have proper owner, group and permission
- Remove files older than 7 days in “$SADMIN/tmp” directory
- Remove pid files (once a day) in “$SADMIN/tmp” that prevent script from not running
- Remove *.rch files in “${SADMIN}/dat/rch” older than “${SADM_RCH_KEEPDAYS}”
- Remove *.log files in “${SADMIN}/log” older than “${SADM_LOG_KEEPDAYS}”
- Remove *.nmon files in “${SADMIN}/dat/nmon” older than “${SADM_NMON_KEEPDAYS}”
- Check existence on the server of “$SADMIN_USER” and “$SADMIN_GROUP”
- Verify if “$SADMIN_USER” is not lock or the password is expired
EXAMPLE
root@holmes:~ # sadm_client_housekeeping.sh
================================================================================
Thu 28 Jul 2022 13:00:24 - sadm_client_housekeeping.sh v2.06 - Library v4.03
Desc: Set $SADMIN owner/group/permission, prune old log,rch files ,check sadmin account.
Host: sherlock.maison.ca - User: root - Arch: x86_64 - SADMIN: /opt/sadmin
Almalinux Linux release 9.0 - Kernel 5.14.0-70.17.1.el9_0.x86_64
==================================================
SADMIN Client Directories Housekeeping.
- chmod 0775 /opt/sadmin [ OK ]
- chown sadmin:sadmin /opt/sadmin [ OK ]
- chmod 0775 /opt/sadmin/bin [ OK ]
- chown sadmin:sadmin /opt/sadmin/bin [ OK ]
- chmod 0775 /opt/sadmin/cfg [ OK ]
- chown sadmin:sadmin /opt/sadmin/cfg [ OK ]
- chmod 0775 /opt/sadmin/dat [ OK ]
- chown sadmin:sadmin /opt/sadmin/dat [ OK ]
- chmod 0775 /opt/sadmin/doc [ OK ]
- chown sadmin:sadmin /opt/sadmin/doc [ OK ]
- chmod 0775 /opt/sadmin/lib [ OK ]
- chown sadmin:sadmin /opt/sadmin/lib [ OK ]
- chmod 0775 /opt/sadmin/log [ OK ]
- chown sadmin:sadmin /opt/sadmin/log [ OK ]
- chmod 775 /opt/sadmin/pkg [ OK ]
- chown sadmin:sadmin /opt/sadmin/pkg [ OK ]
- chmod 775 /opt/sadmin/setup [ OK ]
- chown sadmin:sadmin /opt/sadmin/setup [ OK ]
- chmod 0775 /opt/sadmin/sys [ OK ]
- chown sadmin:sadmin /opt/sadmin/sys [ OK ]
- chmod 1777 /opt/sadmin/tmp [ OK ]
- chown sadmin:sadmin /opt/sadmin/tmp [ OK ]
- chmod 0775 /opt/sadmin/usr [ OK ]
- chown sadmin:sadmin /opt/sadmin/usr [ OK ]
- chmod 0775 /opt/sadmin/usr/bin [ OK ]
- chown sadmin:sadmin /opt/sadmin/usr/bin [ OK ]
- chmod 0775 /opt/sadmin/usr/lib [ OK ]
- chown sadmin:sadmin /opt/sadmin/usr/lib [ OK ]
- chmod 0775 /opt/sadmin/usr/doc [ OK ]
- chown sadmin:sadmin /opt/sadmin/usr/doc [ OK ]
- chmod 0775 /opt/sadmin/usr/mon [ OK ]
- chown sadmin:sadmin /opt/sadmin/usr/mon [ OK ]
- chmod 0775 /opt/sadmin/dat/nmon [ OK ]
- chown sadmin:sadmin /opt/sadmin/dat/nmon [ OK ]
- chmod 0775 /opt/sadmin/dat/dr [ OK ]
- chown sadmin:sadmin /opt/sadmin/dat/dr [ OK ]
- chmod 0775 /opt/sadmin/dat/rch [ OK ]
- chown sadmin:sadmin /opt/sadmin/dat/rch [ OK ]
- chmod 0775 /opt/sadmin/dat/dbb [ OK ]
- chown sadmin:sadmin /opt/sadmin/dat/dbb [ OK ]
- chmod 0775 /opt/sadmin/dat/net [ OK ]
- chown sadmin:sadmin /opt/sadmin/dat/net [ OK ]
SADMIN Client Files Housekeeping.
- chmod 0644 /etc/cron.d/sadm_client [ OK ]
- chown root:root /etc/cron.d/sadm_client [ OK ]
- chmod 0644 /etc/cron.d/sadm_server [ OK ]
- chown root:root /etc/cron.d/sadm_server [ OK ]
- chmod 0644 /etc/cron.d/sadm_osupdate [ OK ]
- chown root:root /etc/cron.d/sadm_osupdate [ OK ]
- chmod 0644 /etc/cron.d/sadm_backup [ OK ]
- chown root:root /etc/cron.d/sadm_backup [ OK ]
- chmod 0644 /etc/cron.d/sadm_rear_backup [ OK ]
- chown root:root /etc/cron.d/sadm_rear_backup [ OK ]
- chmod 0664 /opt/sadmin/readme.md [ OK ]
- chown sadmin:sadmin /opt/sadmin/readme.md [ OK ]
- chmod 0664 /opt/sadmin/license [ OK ]
- chown sadmin:sadmin /opt/sadmin/license [ OK ]
- chmod 0664 /opt/sadmin/changelog.md [ OK ]
- chown sadmin:sadmin /opt/sadmin/changelog.md [ OK ]
- chmod 0640 /opt/sadmin/cfg/.dbpass [ OK ]
- chown sadmin:sadmin /opt/sadmin/cfg/.dbpass [ OK ]
- chmod 0640 /opt/sadmin/cfg/.gmpw [ OK ]
- chown sadmin:sadmin /opt/sadmin/cfg/.gmpw [ OK ]
- chmod 0600 /etc/postfix/sasl_passwd [ OK ]
- chown root:root /etc/postfix/sasl_passwd [ OK ]
- chmod 0600 /etc/postfix/sasl_passwd.db [ OK ]
- chown root:root /etc/postfix/sasl_passwd.db [ OK ]
- find /opt/sadmin/tmp -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/tmp -type f -exec chmod 1777{} \; [ OK ]
- find /opt/sadmin/dat -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/dat -type f -exec chmod 0664{} \; [ OK ]
- find /opt/sadmin/log -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/log -type f -exec chmod 0666{} \; [ OK ]
- find /opt/sadmin/usr -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/usr -type f -exec chmod 0644{} \; [ OK ]
- find /opt/sadmin/usr/bin -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/usr/bin -type f -exec chmod 0775{} \; [ OK ]
- find /opt/sadmin/usr/lib -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/usr/lib -type f -exec chmod 0775{} \; [ OK ]
- find /opt/sadmin/usr/mon -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/usr/mon -type f -exec chmod 0775{} \; [ OK ]
- find /opt/sadmin/cfg -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/cfg -type f -exec chmod 0664{} \; [ OK ]
- find /opt/sadmin/sys -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/sys -type f -exec chmod 0770{} \; [ OK ]
- find /opt/sadmin/bin -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/bin -type f -exec chmod 0775{} \; [ OK ]
- find /opt/sadmin/lib -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/lib -type f -exec chmod 0775{} \; [ OK ]
- find /opt/sadmin/pkg -type f -exec chown sadmin:sadmin {} \; [ OK ]
- find /opt/sadmin/pkg -type f -exec chmod 0755{} \; [ OK ]
SADMIN Files Pruning.
- Remove unmodified file(s) for more than 7 days in /opt/sadmin/tmp.
- find /opt/sadmin/tmp -type f -mtime +7 -exec rm -f {} \; [ OK ]
- Remove all pid files once a day - This prevent script from not running.
- find /opt/sadmin/tmp -type f -name '*.pid' -exec rm -f {} \; [ OK ]
- Remove any unmodified *.rch file(s) for more than 40 days in /opt/sadmin/dat/rch.
- find /opt/sadmin/dat/rch -type f -mtime +40 -name '*.rch' -exec rm -f {} \; [ OK ]
- Remove any unmodified *.log file(s) for more than 40 days in /opt/sadmin/log.
- find /opt/sadmin/log -type f -mtime +40 -name '*.log' -exec rm -f {} \; [ OK ]
- Remove any unmodified *.nmon file(s) for more than 40 days in /opt/sadmin/dat/nmon.
- find /opt/sadmin/dat/nmon -mtime +40 -type f -name '*.nmon' -exec rm {} \; [ OK ]
Check status of account 'sadmin' ...
- Making sure account 'sadmin' doesn't expire.
- Making sure password for 'sadmin' doesn't expire.
- We recommend changing 'sadmin' password at regular interval.
- No problem with 'sadmin' account. [ OK ]
Check SADMIN client 'sadmin' crontab & System monitor config file ...
- Make sure sadm_client crontab (/etc/cron.d/sadm_client) have 'sadm_nmon_watcher.sh' line.
- Yes, crontab (/etc/cron.d/sadm_client) already got 'sadm_nmon_watcher.sh' line.
- Making sure that script:swatch_nmon.sh is no longer in /opt/sadmin/cfg/sherlock.smon
==================================================
Script exit code is 0 (Success) and execution time is 00:00:07
History file '$SADMIN/dat/rch/sherlock_sadm_client_housekeeping.rch' trim to 35 lines.
Script is set to send an alert only when it terminate with error.
Script succeeded, no alert will be send ($SADM_ALERT_TYPE=1).
New log created '$SADMIN/log/sherlock_sadm_client_housekeeping.log'.
End of sadm_client_housekeeping.sh - Thu 28 Jul 2022 01:00:25 PM EDT
================================================================================
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
Copyright © 2022 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_create_sysinfo.sh - Collect hardware & software information about the system
System Information File - Documentation about the system information file
sadm_client_sunset.sh - Clients end of day housekeeping and producing system information files
sadm_fetch_clients.sh - rsync all .rch/.log/.rpt from actives clients to the SADMIN server.