root/trunk/table_growth/table_growth_report.sh

Revision 146, 1.2 kB (checked in by ssteinpreis, 4 years ago)

Removed fully qualified pathname for psql.

Line 
1 #!/bin/bash
2
3 ############################################################################
4 # Module Name   : table_growth                                             #
5 # Module Type   : Shell script                                             #
6 # Synopsis      : This script will send table growth monitor report.       #
7 # Copyright     : 2008, OmniTI Inc.                                        #
8 #                                                                          #
9 ############################################################################
10
11 LOGFILE=/home/postgres/logs/table_growth.rpt
12 DNAME=your_real_postgres_db_name
13
14 psql -d ${DNAME} -c "select 'Top 10 Tables Growth For:-  '||to_char(current_date - '1 month'::interval,'Mon-YYYY') as Month; select table_owner, schema_name, table_name, pg_size_pretty(growth_size::bigint) as Growth_size_MB from otools.table_growth where sum_flag = 2 and to_char(capture_time,'mm/yyyy')=to_char((current_date - '1 month'::interval),'mm/yyyy') order by growth_size desc limit 10;" > $LOGFILE
15
16 if [ -s "$LOGFILE" ]; then
17   M_HOSTNAME=$(hostname)'.'$(cat /etc/resolv.conf | grep domain | cut -f2 -d' ')
18   mailx -s "Tablegrowth Monitor Report for ${DNAME} on ${M_HOSTNAME}" dba@omniti.com < $LOGFILE
19 fi
20 rm $LOGFILE
21 exit
22
Note: See TracBrowser for help on using the browser.