Skip to content

Instantly share code, notes, and snippets.

@earnhardt3rd
Created June 19, 2023 13:56
Show Gist options
  • Select an option

  • Save earnhardt3rd/05591dc092fdfbb12e37a4549892f286 to your computer and use it in GitHub Desktop.

Select an option

Save earnhardt3rd/05591dc092fdfbb12e37a4549892f286 to your computer and use it in GitHub Desktop.
require 'getopts.pl';
Getopts('m:d:t');
my $MODE = uc($opt_m) || "";
my $DEBUG = $opt_d || 0;
if (defined $opt_t) { my %TEST = &D_USD_SEV_1_NOTIFICATIONS();}
1;
sub D_USD_SEV_1_NOTIFICATIONS {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "Export Special Sev1 Notifications";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "pdm_extract -f \"select * from ca_contact where last_name = 'zSYSTEM_MGTISEV1'\" >> %data%\n";
print DAFH "pdm_extract -f \"select * from ca_contact where last_name = 'SLA-HelpDeskManagers'\" >> %data%\n";
print DAFH "pdm_extract -f \"select * from ca_contact where last_name = 'Priority 1 Notifications'\" >> %data%\n";
print DAFH "pdm_extract -f \"select * from usp_contact where ldap_dn = 'zSYSTEM'\" >> %data%\n";
print DAFH "pdm_extract -f \"select l_attr,l_persid,l_sql,r_attr,r_persid,r_sql from Lrel_Table where r_persid = 'cnt:A613A56BD506A944969CD76A96F427E2'\" >> %data%\n";
close(DAFH);
return $ret_msg;
}
sub D_USD_SCORE_BOARD {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "Export Complete Scoreboard";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "pdm_extract User_Query >> %data%\n";
print DAFH "pdm_extract Cr_Stored_Queries >> %data%\n";
close(DAFH);
return $ret_msg;
}
sub D_USD_TRIGGERS {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
return "ERROR!$cRef NOT IMPLEMENTED!";
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "set wsp=wsp_%COMPUTERNAME%-%TODAY%-%TIME%\n";
print DAFH "pdm_extract wspcol > %wsp%\n";
print DAFH "pdm_extract wsptbl >> %wsp%\n";
close(DAFH);
#REM NEW TRIGGERS
#pdm_extract -f "select * from Act_Type where sym ='MMC Priority 1'" >> %new%
#pdm_extract -f "select * from Act_Type where sym = 'MMC Priority 1 Down'" >> %new%
#pdm_extract -f "select * from Act_Type where sym ='MMC Priority 1 Reassign'" >> %new%
#pdm_extract -f "select * from Act_Type where sym = 'MMC Priority 1 Resolve'" >> %new%
#
#pdm_extract -f "select * from Act_Type_Assoc where sym ='MMC Priority 1'" >> %new%
#pdm_extract -f "select * from Act_Type_Assoc where sym ='MMC Priority 1 Down'" >> %new%
#pdm_extract -f "select * from Act_Type_Assoc where sym ='MMC Priority 1 Reassign'" >> %new%
#pdm_extract -f "select * from Act_Type_Assoc where sym ='MMC Priority 1 Resolve'" >> %new%
#
#REM { "MMC Priority 1" ,"macro:400033" }
#REM { "MMC Priority 1 Down" ,"macro:400038" }
#REM { "MMC Priority 1 Reassign" ,"macro:400053" }
#REM { "MMC Priority 1 Resolve" ,"macro:400058" }
#
#pdm_extract -f "select * from Spell_Macro where id = '400033'" >> %new%
#pdm_extract -f "select * from Spell_Macro where id = '400038'" >> %new%
#pdm_extract -f "select * from Spell_Macro where id = '400053'" >> %new%
#pdm_extract -f "select * from Spell_Macro where id = '400058'" >> %new%
#
#REM zSYSTEM_MGTISEV1 Group Record
#pdm_extract -f "select * from Lrel_Table where r_persid = 'cnt:A613A56BD506A944969CD76A96F427E2'" > %data%
#
#REM Event Macros
#REM pdm_extract -f "select * from Spell_Macro where type = 'BHVNOTIFY_MANY'" >> %data%
#pdm_extract -f "select * from Spell_Macro where type = 'BHVNOTIFY_MANY' and sym = 'Priority 1 and 2 Alert'" >> %data%
#pdm_extract -f "select * from Spell_Macro where type = 'BHVNOTIFY_MANY' and sym = 'SLA-Violation-TTA'" >> %data%
#pdm_extract -f "select * from Spell_Macro where type = 'BHVNOTIFY_MANY' and sym = 'SLA-Violation-TTF'" >> %data%
#pdm_extract -f "select * from Spell_Macro where type = 'BHVNOTIFY_MANY' and sym = 'SLA-Warning-TTF'" >> %data%
#
#
#REM pdm_extract -f "select * from Act_Type where notify = '1' and flag1 = '1'and del = '0'" >> %data%
#REM FROM PRODUCTION
#REM { "Close Requested" }
#REM { "Escalate" }
#REM { "Initial" }
#REM { "Manual Notify" }
#REM { "Reassign" }
#REM { "Reopen" }
#REM { "Resolved" }
#
#pdm_extract -f "select * from Act_Type where sym ='Close'" >> %data%
#pdm_extract -f "select * from Act_Type where sym ='Close Requested'" >> %data%
#pdm_extract -f "select * from Act_Type where sym ='Escalate'" >> %data%
#pdm_extract -f "select * from Act_Type where sym ='Initial'" >> %data%
#pdm_extract -f "select * from Act_Type where sym ='Manual Notify'" >> %data%
#pdm_extract -f "select * from Act_Type where sym ='Reassign'" >> %data%
#pdm_extract -f "select * from Act_Type where sym ='Reopen'" >> %data%
#pdm_extract -f "select * from Act_Type where sym ='Resolved'" >> %data%
return $ret_msg;
}
sub D_USD_URGENCY {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "Export Urgency";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "pdm_extract Urgency >>%data%\n";
close(DAFH);
return $ret_msg;
}
sub D_USD_WSP {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "Export WSP Tables";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "set wsp=_wsp_%COMPUTERNAME%-%TODAY%-%TIME%.ca\n";
print DAFH "pdm_extract wspcol > %wsp%\n";
print DAFH "pdm_extract wsptbl >> %wsp%\n";
print DAFH "echo -------------------------------------\n";
print DAFH "echo Export Complete\n";
print DAFH "echo -------------------------------------\n";
print DAFH "echo Run pdm_load -r -f %wsp%\n";
print DAFH "echo Then pdm_load -f 'FILE FROM PACKAGE'\n";
print DAFH "echo Trick WSP\n";
print DAFH "echo Run stopusd\n";
print DAFH "echo Run pdm_publish\n";
print DAFH "echo Run startusd\n";
close(DAFH);
return $ret_msg . "\n ***** Please Add Field Names and Types HERE! *****";
}
sub D_USD_CR_STATUS {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "Export Incident-Problem-Request Status Codes";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "pdm_extract Cr_Status >> %data%\n";
close(DAFH);
return $ret_msg;
}
sub D_USD_Z_SOURCE {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "Export z_source Codes";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "pdm_extract z_source >> %data%\n";
close(DAFH);
return $ret_msg;
}
sub D_USD_MAILBOX {
my $cRef = $_[0];
my $dFile = $_[1];
my $ret_msg = "Export Mail Boxes";
if (! -f $dFile) {return "ERROR! Unable to Locate Data File ($dFile) \@ $cRef";}
my @M_BOXES = &_PDM_EXTRACT("select id,description,userid from usp_mailbox");
if (scalar(@M_BOXES) > 0) {
print " Select Mailboxes to add to package\n";
@M_BOXES = &fromARRAY(@M_BOXES);
if (scalar(@M_BOXES) > 0) {
my $mBoxList="";
for (my $i=0;$i<=scalar(@M_BOXES)-1 ;$i++) {
my ($mId,$mDesc,$mUsr) = split(',',$M_BOXES[$i]);
if ($mBoxList eq "") {
$mBoxList="'$mId'";
} else {
$mBoxList.=",'$mId'";
}
}
my $rulInc = &Ask("Do you want to include Mailbox Rules?","Yes","No","Exit");
if ($rulInc eq "Exit") {&_EXIT_CLEAN();}
open (DAFH,">> $dFile");
print DAFH "\n";
print DAFH "REM ### $ret_msg ###\n";
print DAFH "pdm_extract -f \"select * from usp_mailbox where id in ($mBoxList)\" >> %data%\n";
if ($rulInc eq "Yes") {
print DAFH "pdm_extract -f \"select * from usp_mailbox_rule where mailbox in ($mBoxList)\" >> %data%\n";
}
close(DAFH);
}
} else {
print " ERROR! Unable to continue data build without results from extract!\n";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment