Hello,
Looks like I could be missing something simple in here, I have perl script running on my production server that is giving partial output. I run 2 scripts, one will backup the server to TSM and another (check_dsmsched.pl as seen below) will parse the TSM schedule log from /var/log/dsmsched.log and emails the results.
I could see it is generating the log correctly but not emailing the complete results.
===========================================
check_dsmsched.pl
=================================
#!/usr/bin/perl –w
#
# check_dsmsched.pl
# This script will parse the TSM schedule log, and E-mail results.
# It is invoked by the TSM scheduler process, postschedulecmd option.
use Mail::Sender;
chomp ($HOSTNAME=`hostname`);
$DAY=24*60*60; # seconds in a day
%rcpt=(
'MAILSVCS', 'barkath@gmail.com',
);
@sched_out=();
sub check_dsmsched_log # subr uses 1 param (an integer)
{
@t=localtime(time-$DAY*$_[0]); # build localtime array (T-x)
$t[4]++; # month
$t[5]-=100; # year
$t[3]="0$t[3]" if ($t[3] < 10); # pad a zero
$t[4]="0$t[4]" if ($t[4] < 10); # pad z zero
$t[5]="0$t[5]" if ($t[5] < 10); # pad z zero
$date="$t[4]/$t[3]/$t[5]";
$DSMSCHED="/var/log/dsmsched.log";
$DSMPRUNE="/tmp/dsmprune.log";
$index=1;
$sched_out[0]="CUSTOM IDX/CACHE backup PART 1 results:\n\n";
################################ PRUNING PASS 1 ###############################
# Prunes everything not matching the $date string
# open (INFILE,"<$DSMSCHED");
# open (OUTFILE,">$DSMPRUNE");
# while (<INFILE>)
# {
# if (/^$date/)
# {
# print OUTFILE;
# }
# }
# close INFILE;
# close OUTFILE;
################################ PRUNING PASS 2 ###############################
# Prunes everything but the results of CUSTOM_IDX_PART_1
open (INFILE,"<$DSMPRUNE");
while (<INFILE>)
{
next while (! /SCHEDULEREC OBJECT BEGIN CUSTOM_IDX_PART_1/);
while (<INFILE>)
{
last if (/SCHEDULEREC OBJECT END CUSTOM_IDX_PART_1/);
next if (/Normal File/ || /Expiring/ || /Special File/ || /Directory/ || /Symbolic Link/ || /Updating/ || /ANS1898I/ );
$sched_out[$index]=$_; # build the results array
$index++;
}
last;
}
close INFILE;
}
check_dsmsched_log(0); # run on current day (T - 0)
# Run on yesterday (T - 1) if (T - 0) yielded no results.
check_dsmsched_log(1) if (! defined $sched_out[1]);
chomp ($date=`date +"%A, %B %d, %Y, %H:%M:%S"`);
$sender = new Mail::Sender({
smtp => '10.10.10.10',
from => "idx_backup\@$HOSTNAME",
subject => "IDX Backup status $date"
});
$sender->MailMsg({
msg => "@sched_out",
to => "${$rcpt{'MAILSVCS'}}"
});
============================================
/var/log/dsmsched.log file
============================================
10/24/07 08:28:15 --- SCHEDULEREC STATUS BEGIN
10/24/07 08:28:15 Session established with server AIXTSM1: AIX-RS/6000
10/24/07 08:28:15 Server Version 5, Release 2, Level 4.4
10/24/07 08:28:15 Server date/time: 10/24/07 08:28:15 Last access: 10/23/07 21:01:18
10/24/07 08:28:15 Total number of objects inspected: 121,958
10/24/07 08:28:15 Total number of objects backed up: 752
10/24/07 08:28:15 Total number of objects updated: 0
10/24/07 08:28:15 Total number of objects rebound: 0
10/24/07 08:28:15 Total number of objects deleted: 0
10/24/07 08:28:15 Total number of objects expired: 231
10/24/07 08:28:15 Total number of objects failed: 3
10/24/07 08:28:15 Total number of bytes transferred: 485.23 GB
10/24/07 08:28:15 Data transfer time: 23,474.35 sec
10/24/07 08:28:15 Network data transfer rate: 21,674.99 KB/sec
10/24/07 08:28:15 Aggregate data transfer rate: 12,330.80 KB/sec
10/24/07 08:28:15 Objects compressed by: 0%
10/24/07 08:28:15 Elapsed processing time: 11:27:43
10/24/07 08:28:15 --- SCHEDULEREC STATUS END
10/24/07 08:28:15 --- SCHEDULEREC OBJECT END CUSTOM_IDX_PART_1 10/23/07 21:00:00
10/24/07 08:28:15
Executing Operating System command or script:
/usr/local/sbin/check_dsmsched.pl
10/24/07 08:28:16 Finished command. Return code is: 0
10/24/07 08:28:16 Scheduled event 'CUSTOM_IDX_PART_1' completed successfully.
10/24/07 08:28:16 Sending results for scheduled event 'CUSTOM_IDX_PART_1'.
10/24/07 08:28:16 Session established with server AIXTSM1: AIX-RS/6000
10/24/07 08:28:16 Server Version 5, Release 2, Level 4.4
10/24/07 08:28:16 Server date/time: 10/24/07 08:28:16 Last access: 10/24/07 08:28:15
10/24/07 08:28:16 Results sent to server for scheduled event 'CUSTOM_IDX_PART_1'.
10/24/07 08:28:16 ANS1483I Schedule log pruning started.
10/24/07 08:28:17 ANS1484I Schedule log pruning finished successfully.
10/24/07 08:28:17 Querying server for next scheduled event.
10/24/07 08:28:17 Node Name: AIXIDX
10/24/07 08:28:17 Session established with server AIXTSM1: AIX-RS/6000
10/24/07 08:28:17 Server Version 5, Release 2, Level 4.4
10/24/07 08:28:17 Server date/time: 10/24/07 08:28:17 Last access: 10/24/07 08:28:16
10/24/07 08:28:17 --- SCHEDULEREC QUERY BEGIN
10/24/07 08:28:17 --- SCHEDULEREC QUERY END
10/24/07 08:28:17 Next operation scheduled:
10/24/07 08:28:17 ------------------------------------------------------------
10/24/07 08:28:17 Schedule Name: CUSTOM_IDX_PART_1
10/24/07 08:28:17 Action: Incremental
10/24/07 08:28:17 Objects: / /var /home /usr /opt /winshare /transfer /ftp /mjournal /dbu /arc /winshare2 /dbb
10/24/07 08:28:17 Options:
10/24/07 08:28:17 Server Window Start: 21:00:00 on 10/24/07
10/24/07 08:28:17 ------------------------------------------------------------
10/24/07 08:28:17 Waiting to be contacted by the server.
10/24/07 21:00:02 Querying server for next scheduled event.
10/24/07 21:00:02 Node Name: AIXIDX
10/24/07 21:00:02 Session established with server AIXTSM1: AIX-RS/6000
10/24/07 21:00:02 Server Version 5, Release 2, Level 4.4
10/24/07 21:00:02 Server date/time: 10/24/07 21:00:02 Last access: 10/24/07 08:28:17
10/24/07 21:00:02 --- SCHEDULEREC QUERY BEGIN
10/24/07 21:00:02 --- SCHEDULEREC QUERY END
10/24/07 21:00:02 Next operation scheduled:
10/24/07 21:00:02 ------------------------------------------------------------
10/24/07 21:00:02 Schedule Name: CUSTOM_IDX_PART_1
10/24/07 21:00:02 Action: Incremental
10/24/07 21:00:02 Objects: / /var /home /usr /opt /winshare /transfer /ftp /mjournal /dbu /arc /winshare2 /dbb
10/24/07 21:00:02 Options:
10/24/07 21:00:02 Server Window Start: 21:00:00 on 10/24/07
10/24/07 21:00:02 ------------------------------------------------------------
10/24/07 21:00:02
Executing scheduled command now.
10/24/07 21:00:02
Executing Operating System command or script:
/usr/local/sbin/backup_cache.pl
10/24/07 21:00:33 Finished command. Return code is: 0
10/24/07 21:00:33 --- SCHEDULEREC OBJECT BEGIN CUSTOM_IDX_PART_1 10/24/07 21:00:00
10/24/07 21:00:33 Incremental backup of volume '/'
10/24/07 21:00:33 Incremental backup of volume '/var'
10/24/07 21:00:33 Incremental backup of volume '/home'
10/24/07 21:00:33 Incremental backup of volume '/usr'
10/24/07 21:00:33 Incremental backup of volume '/opt'
10/24/07 21:00:33 Incremental backup of volume '/winshare'
10/24/07 21:00:33 Incremental backup of volume '/transfer'
10/24/07 21:00:33 Incremental backup of volume '/ftp'
10/24/07 21:00:33 Incremental backup of volume '/mjournal'
10/24/07 21:00:48 Successful incremental backup of '/var'
10/24/07 21:00:51 ANS1898I ***** Processed 9,000 files *****
10/24/07 21:00:51 Successful incremental backup of '/home'
10/24/07 21:00:51 Successful incremental backup of '/opt'
.
.
.
============================================
Currently am getting Incomplete Results:
=========================
CUSTOM IDX/CACHE backup PART 1 results:
10/29/07 21:00:31 Incremental backup of volume '/'
10/29/07 21:00:31 Incremental backup of volume '/var'
10/29/07 21:00:31 Incremental backup of volume '/home'
10/29/07 21:00:31 Incremental backup of volume '/usr'
10/29/07 21:00:31 Incremental backup of volume '/opt'
10/29/07 21:01:43 Successful incremental backup of '/arc'
.
.
.
10/29/07 21:01:43 Successful incremental backup of '/winshare2'
10/29/07 21:03:07 Successful incremental backup of '/mjournal'
10/29/07 22:35:09 ANS1228E Sending of object '/dbb/ugreg/CACHE.DAT' failed
10/29/07 22:35:09 ANS4037E File '/dbb/ugreg/CACHE.DAT' changed during processing. File skipped.
10/29/07 22:59:02 ANS1228E Sending of object '/dbb/upgrade/CACHE.DAT' failed
10/29/07 22:59:02 ANS4037E File '/dbb/upgrade/CACHE.DAT' changed during processing. File skipped.
=============================================
whereas the correct output should look like below:
====================================
CUSTOM IDX/CACHE backup PART 1 results:
10/05/07 21:00:32 Incremental backup of volume '/'
10/05/07 21:00:32 Incremental backup of volume '/var'
10/05/07 21:00:32 Incremental backup of volume '/home'
10/05/07 21:00:32 Incremental backup of volume '/usr'
10/05/07 21:00:32 Incremental backup of volume '/opt'
.
.
.
10/05/07 21:03:15 Successful incremental backup of '/dbu'
10/05/07 22:56:51 Successful incremental backup of '/dbb'
10/05/07 22:56:51 --- SCHEDULEREC STATUS BEGIN
10/05/07 22:56:51 Session established with server AIXTSM1: AIX-RS/6000
10/05/07 22:56:51 Server Version 5, Release 2, Level 4.4
10/05/07 22:56:51 Server date/time: 10/05/07 22:56:51 Last access: 10/05/07 21:03:20
10/05/07 22:56:51 Total number of objects inspected: 121,820
10/05/07 22:56:51 Total number of objects backed up: 768
10/05/07 22:56:51 Total number of objects updated: 1
10/05/07 22:56:51 Total number of objects rebound: 0
10/05/07 22:56:51 Total number of objects deleted: 0
10/05/07 22:56:51 Total number of objects expired: 297
10/05/07 22:56:51 Total number of objects failed: 0
10/05/07 22:56:51 Total number of bytes transferred: 186.92 GB
10/05/07 22:56:51 Data transfer time: 4,671.86 sec
10/05/07 22:56:51 Network data transfer rate: 41,955.16 KB/sec
10/05/07 22:56:51 Aggregate data transfer rate: 28,083.22 KB/sec
10/05/07 22:56:51 Objects compressed by: 0%
10/05/07 22:56:51 Elapsed processing time: 01:56:19
10/05/07 22:56:51 --- SCHEDULEREC STATUS END
Thanks for looking at this long email and for ur response.
--Barkath
Looks like I could be missing something simple in here, I have perl script running on my production server that is giving partial output. I run 2 scripts, one will backup the server to TSM and another (check_dsmsched.pl as seen below) will parse the TSM schedule log from /var/log/dsmsched.log and emails the results.
I could see it is generating the log correctly but not emailing the complete results.
===========================================
check_dsmsched.pl
=================================
#!/usr/bin/perl –w
#
# check_dsmsched.pl
# This script will parse the TSM schedule log, and E-mail results.
# It is invoked by the TSM scheduler process, postschedulecmd option.
use Mail::Sender;
chomp ($HOSTNAME=`hostname`);
$DAY=24*60*60; # seconds in a day
%rcpt=(
'MAILSVCS', 'barkath@gmail.com',
);
@sched_out=();
sub check_dsmsched_log # subr uses 1 param (an integer)
{
@t=localtime(time-$DAY*$_[0]); # build localtime array (T-x)
$t[4]++; # month
$t[5]-=100; # year
$t[3]="0$t[3]" if ($t[3] < 10); # pad a zero
$t[4]="0$t[4]" if ($t[4] < 10); # pad z zero
$t[5]="0$t[5]" if ($t[5] < 10); # pad z zero
$date="$t[4]/$t[3]/$t[5]";
$DSMSCHED="/var/log/dsmsched.log";
$DSMPRUNE="/tmp/dsmprune.log";
$index=1;
$sched_out[0]="CUSTOM IDX/CACHE backup PART 1 results:\n\n";
################################ PRUNING PASS 1 ###############################
# Prunes everything not matching the $date string
# open (INFILE,"<$DSMSCHED");
# open (OUTFILE,">$DSMPRUNE");
# while (<INFILE>)
# {
# if (/^$date/)
# {
# print OUTFILE;
# }
# }
# close INFILE;
# close OUTFILE;
################################ PRUNING PASS 2 ###############################
# Prunes everything but the results of CUSTOM_IDX_PART_1
open (INFILE,"<$DSMPRUNE");
while (<INFILE>)
{
next while (! /SCHEDULEREC OBJECT BEGIN CUSTOM_IDX_PART_1/);
while (<INFILE>)
{
last if (/SCHEDULEREC OBJECT END CUSTOM_IDX_PART_1/);
next if (/Normal File/ || /Expiring/ || /Special File/ || /Directory/ || /Symbolic Link/ || /Updating/ || /ANS1898I/ );
$sched_out[$index]=$_; # build the results array
$index++;
}
last;
}
close INFILE;
}
check_dsmsched_log(0); # run on current day (T - 0)
# Run on yesterday (T - 1) if (T - 0) yielded no results.
check_dsmsched_log(1) if (! defined $sched_out[1]);
chomp ($date=`date +"%A, %B %d, %Y, %H:%M:%S"`);
$sender = new Mail::Sender({
smtp => '10.10.10.10',
from => "idx_backup\@$HOSTNAME",
subject => "IDX Backup status $date"
});
$sender->MailMsg({
msg => "@sched_out",
to => "${$rcpt{'MAILSVCS'}}"
});
============================================
/var/log/dsmsched.log file
============================================
10/24/07 08:28:15 --- SCHEDULEREC STATUS BEGIN
10/24/07 08:28:15 Session established with server AIXTSM1: AIX-RS/6000
10/24/07 08:28:15 Server Version 5, Release 2, Level 4.4
10/24/07 08:28:15 Server date/time: 10/24/07 08:28:15 Last access: 10/23/07 21:01:18
10/24/07 08:28:15 Total number of objects inspected: 121,958
10/24/07 08:28:15 Total number of objects backed up: 752
10/24/07 08:28:15 Total number of objects updated: 0
10/24/07 08:28:15 Total number of objects rebound: 0
10/24/07 08:28:15 Total number of objects deleted: 0
10/24/07 08:28:15 Total number of objects expired: 231
10/24/07 08:28:15 Total number of objects failed: 3
10/24/07 08:28:15 Total number of bytes transferred: 485.23 GB
10/24/07 08:28:15 Data transfer time: 23,474.35 sec
10/24/07 08:28:15 Network data transfer rate: 21,674.99 KB/sec
10/24/07 08:28:15 Aggregate data transfer rate: 12,330.80 KB/sec
10/24/07 08:28:15 Objects compressed by: 0%
10/24/07 08:28:15 Elapsed processing time: 11:27:43
10/24/07 08:28:15 --- SCHEDULEREC STATUS END
10/24/07 08:28:15 --- SCHEDULEREC OBJECT END CUSTOM_IDX_PART_1 10/23/07 21:00:00
10/24/07 08:28:15
Executing Operating System command or script:
/usr/local/sbin/check_dsmsched.pl
10/24/07 08:28:16 Finished command. Return code is: 0
10/24/07 08:28:16 Scheduled event 'CUSTOM_IDX_PART_1' completed successfully.
10/24/07 08:28:16 Sending results for scheduled event 'CUSTOM_IDX_PART_1'.
10/24/07 08:28:16 Session established with server AIXTSM1: AIX-RS/6000
10/24/07 08:28:16 Server Version 5, Release 2, Level 4.4
10/24/07 08:28:16 Server date/time: 10/24/07 08:28:16 Last access: 10/24/07 08:28:15
10/24/07 08:28:16 Results sent to server for scheduled event 'CUSTOM_IDX_PART_1'.
10/24/07 08:28:16 ANS1483I Schedule log pruning started.
10/24/07 08:28:17 ANS1484I Schedule log pruning finished successfully.
10/24/07 08:28:17 Querying server for next scheduled event.
10/24/07 08:28:17 Node Name: AIXIDX
10/24/07 08:28:17 Session established with server AIXTSM1: AIX-RS/6000
10/24/07 08:28:17 Server Version 5, Release 2, Level 4.4
10/24/07 08:28:17 Server date/time: 10/24/07 08:28:17 Last access: 10/24/07 08:28:16
10/24/07 08:28:17 --- SCHEDULEREC QUERY BEGIN
10/24/07 08:28:17 --- SCHEDULEREC QUERY END
10/24/07 08:28:17 Next operation scheduled:
10/24/07 08:28:17 ------------------------------------------------------------
10/24/07 08:28:17 Schedule Name: CUSTOM_IDX_PART_1
10/24/07 08:28:17 Action: Incremental
10/24/07 08:28:17 Objects: / /var /home /usr /opt /winshare /transfer /ftp /mjournal /dbu /arc /winshare2 /dbb
10/24/07 08:28:17 Options:
10/24/07 08:28:17 Server Window Start: 21:00:00 on 10/24/07
10/24/07 08:28:17 ------------------------------------------------------------
10/24/07 08:28:17 Waiting to be contacted by the server.
10/24/07 21:00:02 Querying server for next scheduled event.
10/24/07 21:00:02 Node Name: AIXIDX
10/24/07 21:00:02 Session established with server AIXTSM1: AIX-RS/6000
10/24/07 21:00:02 Server Version 5, Release 2, Level 4.4
10/24/07 21:00:02 Server date/time: 10/24/07 21:00:02 Last access: 10/24/07 08:28:17
10/24/07 21:00:02 --- SCHEDULEREC QUERY BEGIN
10/24/07 21:00:02 --- SCHEDULEREC QUERY END
10/24/07 21:00:02 Next operation scheduled:
10/24/07 21:00:02 ------------------------------------------------------------
10/24/07 21:00:02 Schedule Name: CUSTOM_IDX_PART_1
10/24/07 21:00:02 Action: Incremental
10/24/07 21:00:02 Objects: / /var /home /usr /opt /winshare /transfer /ftp /mjournal /dbu /arc /winshare2 /dbb
10/24/07 21:00:02 Options:
10/24/07 21:00:02 Server Window Start: 21:00:00 on 10/24/07
10/24/07 21:00:02 ------------------------------------------------------------
10/24/07 21:00:02
Executing scheduled command now.
10/24/07 21:00:02
Executing Operating System command or script:
/usr/local/sbin/backup_cache.pl
10/24/07 21:00:33 Finished command. Return code is: 0
10/24/07 21:00:33 --- SCHEDULEREC OBJECT BEGIN CUSTOM_IDX_PART_1 10/24/07 21:00:00
10/24/07 21:00:33 Incremental backup of volume '/'
10/24/07 21:00:33 Incremental backup of volume '/var'
10/24/07 21:00:33 Incremental backup of volume '/home'
10/24/07 21:00:33 Incremental backup of volume '/usr'
10/24/07 21:00:33 Incremental backup of volume '/opt'
10/24/07 21:00:33 Incremental backup of volume '/winshare'
10/24/07 21:00:33 Incremental backup of volume '/transfer'
10/24/07 21:00:33 Incremental backup of volume '/ftp'
10/24/07 21:00:33 Incremental backup of volume '/mjournal'
10/24/07 21:00:48 Successful incremental backup of '/var'
10/24/07 21:00:51 ANS1898I ***** Processed 9,000 files *****
10/24/07 21:00:51 Successful incremental backup of '/home'
10/24/07 21:00:51 Successful incremental backup of '/opt'
.
.
.
============================================
Currently am getting Incomplete Results:
=========================
CUSTOM IDX/CACHE backup PART 1 results:
10/29/07 21:00:31 Incremental backup of volume '/'
10/29/07 21:00:31 Incremental backup of volume '/var'
10/29/07 21:00:31 Incremental backup of volume '/home'
10/29/07 21:00:31 Incremental backup of volume '/usr'
10/29/07 21:00:31 Incremental backup of volume '/opt'
10/29/07 21:01:43 Successful incremental backup of '/arc'
.
.
.
10/29/07 21:01:43 Successful incremental backup of '/winshare2'
10/29/07 21:03:07 Successful incremental backup of '/mjournal'
10/29/07 22:35:09 ANS1228E Sending of object '/dbb/ugreg/CACHE.DAT' failed
10/29/07 22:35:09 ANS4037E File '/dbb/ugreg/CACHE.DAT' changed during processing. File skipped.
10/29/07 22:59:02 ANS1228E Sending of object '/dbb/upgrade/CACHE.DAT' failed
10/29/07 22:59:02 ANS4037E File '/dbb/upgrade/CACHE.DAT' changed during processing. File skipped.
=============================================
whereas the correct output should look like below:
====================================
CUSTOM IDX/CACHE backup PART 1 results:
10/05/07 21:00:32 Incremental backup of volume '/'
10/05/07 21:00:32 Incremental backup of volume '/var'
10/05/07 21:00:32 Incremental backup of volume '/home'
10/05/07 21:00:32 Incremental backup of volume '/usr'
10/05/07 21:00:32 Incremental backup of volume '/opt'
.
.
.
10/05/07 21:03:15 Successful incremental backup of '/dbu'
10/05/07 22:56:51 Successful incremental backup of '/dbb'
10/05/07 22:56:51 --- SCHEDULEREC STATUS BEGIN
10/05/07 22:56:51 Session established with server AIXTSM1: AIX-RS/6000
10/05/07 22:56:51 Server Version 5, Release 2, Level 4.4
10/05/07 22:56:51 Server date/time: 10/05/07 22:56:51 Last access: 10/05/07 21:03:20
10/05/07 22:56:51 Total number of objects inspected: 121,820
10/05/07 22:56:51 Total number of objects backed up: 768
10/05/07 22:56:51 Total number of objects updated: 1
10/05/07 22:56:51 Total number of objects rebound: 0
10/05/07 22:56:51 Total number of objects deleted: 0
10/05/07 22:56:51 Total number of objects expired: 297
10/05/07 22:56:51 Total number of objects failed: 0
10/05/07 22:56:51 Total number of bytes transferred: 186.92 GB
10/05/07 22:56:51 Data transfer time: 4,671.86 sec
10/05/07 22:56:51 Network data transfer rate: 41,955.16 KB/sec
10/05/07 22:56:51 Aggregate data transfer rate: 28,083.22 KB/sec
10/05/07 22:56:51 Objects compressed by: 0%
10/05/07 22:56:51 Elapsed processing time: 01:56:19
10/05/07 22:56:51 --- SCHEDULEREC STATUS END
Thanks for looking at this long email and for ur response.
--Barkath