sadm_wrapper.sh

2 minute read

$SADMIN/bin/sadm_wrapper.sh - Version v1.6
Posted 2018-02-11 - Updated 2021-05-05
Supported on Linux, Aix, MacOS

NAME

sadm_wrapper.sh - Wrapper to run your existing scripts and benefit of SADMIN tools.

SYNOPSIS

sadm_wrapper.sh [-d 0-9] [-h] [-v]

DESCRIPTION

The SADMIN script wrapper is used to run your existing script and see the benefits of it. After you used it once, take a look at the log (in $SADMIN/log) and .rch ($SADMIN/dat/rch) files from the command line or from the web interface. Let’s see it in action, first let’s create a test script, with the editor of your choice, create the file $SADMIN/usr/bin/show_date.sh

/sadmin/usr/bin$ vi show_date.sh   
#! /usr/bin/env sh  
echo "Today is `date`"   

Run it using the SADMIN wrapper

sadmin/usr/bin$ $SADMIN/bin/sadm_wrapper.sh $SADMIN/usr/bin/show_date.sh
================================================================================
Starting show_date.sh V1.6 - SADM Lib. V2.50
Server Name: holmes.maison.ca - Type: LINUX
CENTOS 7.5.1804 Kernel 3.10.0-862.14.4.el7.x86_64
==================================================
 
Executing /sadmin/usr/bin/show_date.sh 
  
==================================================
Script return code is 0
Script execution time is 00:00:00
Trim History /sadmin/dat/rch/holmes_show_date.rch to 125 lines
Requested alert only if script fail (Won't send alert)
Trim log /sadmin/log/holmes_show_date.log to 2000 lines
Sat Nov  3 13:47:37 EDT 2018 - End of show_date.sh
================================================================================
/sadmin/usr/bin$ 

EXAMPLE

/sadmin/usr/bin$ cat $SADMIN/log/holmes_show_date.log
 
2018.11.03 13:47:37 ================================================================================
2018.11.03 13:47:37 Starting show_date.sh V1.6 - SADM Lib. V2.50
2018.11.03 13:47:37 Server Name: holmes.maison.ca - Type: LINUX
2018.11.03 13:47:37 CENTOS 7.5.1804 Kernel 3.10.0-862.14.4.el7.x86_64
2018.11.03 13:47:37 ==================================================
2018.11.03 13:47:37  
2018.11.03 13:47:37   
2018.11.03 13:47:37 Executing /sadmin/usr/bin/show_date.sh 
2018.11.03 13:47:37   
Today is Sat Nov  3 13:47:37 EDT 2018
2018.11.03 13:47:37  
2018.11.03 13:47:37 ==================================================
2018.11.03 13:47:37 Script return code is 0
2018.11.03 13:47:37 Script execution time is 00:00:00
2018.11.03 13:47:37 Trim History /sadmin/dat/rch/holmes_show_date.rch to 125 lines
2018.11.03 13:47:37 Requested alert only if script fail (Won't send alert)
2018.11.03 13:47:37 Trim log /sadmin/log/holmes_show_date.log to 2000 lines
2018.11.03 13:47:37 Sat Nov  3 13:47:37 EDT 2018 - End of show_date.sh
2018.11.03 13:47:37 ================================================================================
2018.11.03 13:47:37  
/sadmin/usr/bin$ 

View the generated Result Code History (*.rch) file

/sadmin/usr/bin$ cat $SADMIN/dat/rch/holmes_show_date.rch 
holmes 2018.11.03 13:47:37 2018.11.03 13:47:37 00:00:00 show_date default 1 0
/sadmin/usr/bin$ 

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_template.sh - Using SADMIN Shell script template
sadm_template.py - Using SADMIN Python script template
sadm_template_menu.sh - Using SADMIN shell menu template