sadm_client-housekeeping.sh

6 minute read

$SADMIN/bin/sadm_client-housekeeping.sh - v1.48
Posted 2021-05-29 - Updated 2021-05-29
Supported on Linux, Aix, MacOS

NAME

sadm_client-housekeeping.sh - Purge old log,rch,nmon files and check $SADMIN permission

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

Back to the top

EXAMPLE

root@holmes:~ # sadm_client_housekeeping.sh 
================================================================================
Sat May 29 11:13:41 EDT 2021 - sadm_client_housekeeping.sh V1.48 - 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
==================================================
 
SADMIN Client Directories Housekeeping.
  - chmod 0775 /sadmin [ OK ]
  - chown sadmin:sadmin /sadmin [ OK ]
  - chmod 0775 /sadmin/bin [ OK ]
  - chown sadmin:sadmin /sadmin/bin [ OK ]
  - chmod 0775 /sadmin/cfg [ OK ]
  - chown sadmin:sadmin /sadmin/cfg [ OK ]
  - chmod 0775 /sadmin/dat [ OK ]
  - chown sadmin:sadmin /sadmin/dat [ OK ]
  - chmod 0775 /sadmin/doc [ OK ]
  - chown sadmin:sadmin /sadmin/doc [ OK ]
  - chmod 0775 /sadmin/lib [ OK ]
  - chown sadmin:sadmin /sadmin/lib [ OK ]
  - chmod 0775 /sadmin/log [ OK ]
  - chown sadmin:sadmin /sadmin/log [ OK ]
  - chmod 775 /sadmin/pkg [ OK ]
  - chown sadmin:sadmin /sadmin/pkg [ OK ]
  - chmod 775 /sadmin/setup [ OK ]
  - chown sadmin:sadmin /sadmin/setup [ OK ]
  - chmod 0775 /sadmin/sys [ OK ]
  - chown sadmin:sadmin /sadmin/sys [ OK ]
  - chmod 1777 /sadmin/tmp [ OK ]
  - chown sadmin:sadmin /sadmin/tmp [ OK ]
  - chmod 0775 /sadmin/usr [ OK ]
  - chown sadmin:sadmin /sadmin/usr [ OK ]
  - chmod 0775 /sadmin/usr/bin [ OK ]
  - chown sadmin:sadmin /sadmin/usr/bin [ OK ]
  - chmod 0775 /sadmin/usr/lib [ OK ]
  - chown sadmin:sadmin /sadmin/usr/lib [ OK ]
  - chmod 0775 /sadmin/usr/doc [ OK ]
  - chown sadmin:sadmin /sadmin/usr/doc [ OK ]
  - chmod 0775 /sadmin/usr/mon [ OK ]
  - chown sadmin:sadmin /sadmin/usr/mon [ OK ]
  - chmod 0775 /sadmin/dat/nmon [ OK ]
  - chown sadmin:sadmin /sadmin/dat/nmon [ OK ]
  - chmod 0775 /sadmin/dat/dr [ OK ]
  - chown sadmin:sadmin /sadmin/dat/dr [ OK ]
  - chmod 0775 /sadmin/dat/rch [ OK ]
  - chown sadmin:sadmin /sadmin/dat/rch [ OK ]
  - chmod 0775 /sadmin/dat/dbb [ OK ]
  - chown sadmin:sadmin /sadmin/dat/dbb [ OK ]
  - chmod 0775 /sadmin/dat/net [ OK ]
  - chown sadmin:sadmin /sadmin/dat/net [ OK ]
  - chmod 4775 /sadmin/lost+found [ OK ]
  - chown root:root /sadmin/lost+found [ 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 /sadmin/readme.md [ OK ]
  - chown sadmin:sadmin /sadmin/readme.md [ OK ]
  - chmod 0664 /sadmin/license [ OK ]
  - chown sadmin:sadmin /sadmin/license [ OK ]
  - chmod 0664 /sadmin/changelog.md [ OK ]
  - chown sadmin:sadmin /sadmin/changelog.md [ OK ]
  - find /sadmin/dat -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/dat -type f -exec chmod 0664{} \; [ OK ]
  - find /sadmin/log -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/log -type f -exec chmod 0666{} \; [ OK ]
  - find /sadmin/usr -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/usr -type f -exec chmod 0644{} \; [ OK ]
  - find /sadmin/usr/bin -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/usr/bin -type f -exec chmod 0775{} \; [ OK ]
  - find /sadmin/usr/lib -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/usr/lib -type f -exec chmod 0775{} \; [ OK ]
  - find /sadmin/usr/mon -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/usr/mon -type f -exec chmod 0775{} \; [ OK ]
  - find /sadmin/cfg -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/cfg -type f -exec chmod 0664{} \; [ OK ]
  - find /sadmin/sys -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/sys -type f -exec chmod 0770{} \; [ OK ]
  - find /sadmin/bin -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/bin -type f -exec chmod 0775{} \; [ OK ]
  - find /sadmin/lib -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/lib -type f -exec chmod 0775{} \; [ OK ]
  - find /sadmin/pkg -type f -exec chown sadmin:sadmin {} \; [ OK ]
  - find /sadmin/pkg -type f -exec chmod 0755{} \; [ OK ]

SADMIN Files Pruning.
  - Remove any unmodified file(s) for more than 7 days in /sadmin/tmp.
    - find /sadmin/tmp  -type f -mtime +7 -exec rm -f {} \; [ OK ]
  - Remove all pid files once a day - This prevent script from not running.
    - find /sadmin/tmp  -type f -name '*.pid' -exec rm -f {} \; [ OK ]
  - Remove any unmodified *.rch file(s) for more than 40 days in /sadmin/dat/rch.
    - find /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 /sadmin/log.
    - find /sadmin/log -type f -mtime +40 -name '*.log' -exec rm -f {} \; [ OK ]
  - Remove any unmodified *.nmon file(s) for more than 40 days in /sadmin/dat/nmon.
    - find /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 ]

==================================================
Script exit code is 0 (Success) and execution time is 00:00:05
History (/sadmin/dat/rch/holmes_sadm_client_housekeeping.rch) trim to 35 lines ($SADM_MAX_RCLINE=35).
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_client_housekeeping.log) created ($SADM_LOG_APPEND='N').
End of sadm_client_housekeeping.sh - Sat May 29 11:13:42 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_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.