Scripts Informix
Em qualquer banco de dados temos comandos para fazer muitas coisas, tem comandos complexos e comandos simples, eu sempre curti simplificar a coisa, depois de muito tempo usando comandos para rodar no informix resolvi criar um script e dentro dele faço diversas coisas.
1 - A base alvo deve possuir a VIEW abaixo:
+-------------------------+-------+
| Total de Logical Logs | 52 |
+-------------------------+-------+
| Necessita de Backup | 0 |
+-------------------------+-------+
| LLOG Salvas | 51 |
+-------------------------+-------+--------------+
| LLOG Atual/% Utilizacao | 45 | 67.326171875 |
+-------------------------+-------+--------------+
Ultimas Mensagens do Log
06/05/12 02:10:15 Logical Log 453 - Backup Started
06/05/12 02:13:19 Logical Log 453 - Backup Completed
06/07/12 00:46:41 Logical Log 454 Complete, timestamp: 0xc9cacca7.
06/07/12 00:46:42 Logical Log 454 - Backup Started
06/07/12 00:49:21 Logical Log 454 - Backup Completed
06/09/12 03:41:31 Logical Log 455 Complete, timestamp: 0x30beff4e.
06/09/12 03:41:32 Logical Log 455 - Backup Started
06/09/12 03:47:12 Logical Log 455 - Backup Completed
06/10/12 03:06:44 Logical Log 456 - Backup Started
06/10/12 03:06:44 Logical Log 456 Complete, timestamp: 0x74b06008.
06/10/12 03:10:21 Logical Log 456 - Backup Completed
06/12/12 00:32:59 Logical Log 457 Complete, timestamp: 0xd860f6e8.
06/12/12 00:33:00 Logical Log 457 - Backup Started
06/12/12 00:35:38 Logical Log 457 - Backup Completed
06/13/12 23:00:44 Logical Log 458 Complete, timestamp: 0xeae86cbf.
06/13/12 23:00:44 Logical Log 458 - Backup Started
06/13/12 23:18:15 Logical Log 458 - Backup Completed
06/16/12 02:39:22 Logical Log 459 Complete, timestamp: 0x9e7661f7.
06/16/12 02:39:23 Logical Log 459 - Backup Started
06/16/12 02:41:37 Logical Log 459 - Backup Completed
[s106:informix]$/export/home/informix
Script Completo
# ==============================================================================================================
# No linux crie um arquivo com o nome proc_menu e grave todo este script lá, saia e depois de permissao
# para rodar chmod 755 proc_menu e depois rode ele como comando ./proc_menu
#
#
# ==============================================================================================================
# Descobrir estatisticas sobre a Logical Log
# ==============================================================================================================
LOG1="/tmp/1234_pode_deletar_1234_0.log"
LOG2="/tmp/1234_pode_deletar_1234_1.log"
LOG3="/tmp/1234_pode_deletar_1234_2.log"
LOG4="/tmp/1234_pode_deletar_1234_3.log"
LOG5="/tmp/1234_pode_deletar_1234_4.log"
LOG6="/tmp/1234_pode_deletar_1234_5.log"
echo
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
dbaccess sysmaster > /dev/null <<+
unload to $LOG1
select count (*) from syslogs where is_backed_up = '1';
+
cat $LOG1 | awk -F "|" '{
t_iso2=$2
if ($2 == "0")
{ t_iso2=" NAO " }
if ($2 == "1")
{ t_iso2=" SIM " }
printf("| LLOG Salvas | %-5d | \n",$1)}' > $LOG2
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
dbaccess sysmaster > /dev/null <<+
unload to $LOG1
select number, ((size - used) / size)*100 from syslogs where is_current = '1'
+
cat $LOG1 | awk -F "|" '{
t_iso3=$3
if ($3 == "0")
{ t_iso3=" Online " }
if ($3 == "1")
{ t_iso3=" Offline " }
printf("| LLOG Atual/% Utilizacao | %-2s | %-6s | \n",$1,$2)}' >> $LOG3
# ------------------------------ ------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
dbaccess sysmaster > /dev/null <<+
unload to $LOG1
select count (*) from syslogs where is_backed_up = '0' and is_current = '0'
+
cat $LOG1 | awk -F "|" '{
t_iso3=$3
if ($3 == "0")
{ t_iso3=" Online " }
if ($3 == "1")
{ t_iso3=" Offline " }
printf("| Necessita de Backup | %-2d | \n",$1)}' >> $LOG4
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
# ------------------------------------------------------------------------------------------------------
dbaccess sysmaster > /dev/null <<+
unload to $LOG1
select count (*) from syslogs
+
cat $LOG1 | awk -F "|" '{
t_iso3=$3
if ($3 == "0")
{ t_iso3=" Online " }
if ($3 == "1")
{ t_iso3=" Offline " }
printf("| Total de Logical Logs | %-2d | \n",$1)}' >> $LOG5
clear
echo "+-------------------------+-------+"
cat $LOG5
echo "+-------------------------+-------+"
cat $LOG4
echo "+-------------------------+-------+"
cat $LOG2
echo "+-------------------------+-------+--------------+"
cat $LOG3
echo "+-------------------------+-------+--------------+"
echo
echo "Ultimas Mensagens do Log"
echo
LOG="$(onstat -c | grep MSGPATH | grep / | awk '{print $2}')"
cat $LOG | grep "Logical Log" > $LOG6 ; tail -n 20 $LOG6; rm $LOG6
rm $LOG1
rm $LOG2
rm $LOG3
rm $LOG4
rm $LOG5
echo
0 comentários:
Enviar um comentário