-
-
Save maazanjum/64c8a38a58ea03d0ee2a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl -w | |
use strict; | |
use warnings; | |
use Switch; | |
################################################### | |
# Change this variables as per your environment # | |
# Alternatively, this could just as well be a # | |
# parameter that is passed to this script. # | |
# For example: # | |
# # | |
# my $ggdir = $ARGV[0] # | |
# # | |
my $ggdir = "/tmp/ggate"; | |
# # | |
################################################### | |
# | |
# GoldenGate Status, Lag etc variables | |
# | |
my $program; | |
my $status; | |
my $statusid; | |
my $group; | |
my $lagatchkpt; | |
my $timesincechkpt; | |
my $hours; | |
my $minutes; | |
my $seconds; | |
# | |
# File Variables | |
# | |
my $line; | |
#my $ggobjects = "/EXTRACT/||/REPLICAT/||/MANAGER/"; | |
# Execute GGSCI check | |
# | |
my @buf = `$ggdir/ggsci << EOF | |
info all | |
EOF`; | |
# Parse the extracted lines and display piped output | |
# GROUP|PROGRAM|STATUS|LAGATCHKPT|TIMESINCHKPT|STATUSID | |
# | |
# For Example: | |
# | |
# MANAGER|MANAGER|RUNNING|0|0 | |
# R_PRD|REPLICAT|RUNNING|0|6|0 | |
# | |
foreach $line (@buf) | |
{ | |
chomp($line); | |
if($line =~ m/(MANAGER|EXTRACT|REPLICAT)/) | |
{ | |
no warnings 'uninitialized'; | |
($program, $status, $group, $lagatchkpt, $timesincechkpt) = split(" ", $line); | |
if ($group eq "") { | |
$group = $program } | |
# Parse Lag at CheckPoint | |
if ($lagatchkpt eq "") { | |
$lagatchkpt = "00:00:00" } | |
($hours, $minutes, $seconds) = split (/:/, $lagatchkpt); | |
$lagatchkpt = ($hours*60*60)+($minutes*60)+($seconds); | |
# Parse Time Since Last CheckPoint | |
if ($timesincechkpt eq "") { | |
$timesincechkpt = "00:00:00" } | |
($hours, $minutes, $seconds) = split (/:/, $timesincechkpt); | |
$timesincechkpt = ($hours*60*60)+($minutes*60)+($seconds); | |
switch ($status) { | |
case("RUNNING") { $statusid=0; } | |
case("STOPPED") { $statusid=1; } | |
case("ABENDED") { $statusid=2; } | |
} | |
print "$group|$program|$status|$lagatchkpt|$timesincechkpt|$statusid\n"; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment