I want to put the following SQL statements into a shell script using only one variable that I can mail to 3 people as part of my daily health checks on our client side. Please help me out with the ideas here. I also want to add 2 commands to check the diaglog and space.
!df -h;
!db2diag -f;
SELECT DB_STATUS as "DB Status",
LAST_BACKUP as "Last Backup",
APPLS_CUR_CONS "No. of Current Connections"
FROM TABLE(MON_GET_DATABASE(-2));
select
NUM_INDOUBT_TRANS as "Indoubt Transactions"
from table(mon_get_transaction_log(-2));
SELECT lock_name,
hld_member,
lock_status,
hld_application_handle
FROM TABLE (MON_GET_APPL_LOCKWAIT(NULL, -2));
select
varchar(tbsp_name, 30) as tbsp_name,
varchar(tbsp_state, 40) as tbsp_state
from table(mon_get_tablespace('',-2));
So far I have the following:
connect to DBNAME
Health=`db2 -x "SELECT DB_STATUS as "DB Status",
LAST_BACKUP as "Last Backup",
APPLS_CUR_CONS "No. of Current Connections"
FROM TABLE(MON_GET_DATABASE(-2))"`
echo $Health
mail -s "health Check" mail@who.co.za <<< "$Health"
Getting the below error. Even when taking out the " " I still receive the same errors. Please help
SQL0104N An unexpected token "Status" was found following "ECT DB_STATUS as DB". Expected tokens may include: "". SQLSTATE=42601