Friday, March 25, 2016

TaskAudit and DataAudit Automation in Hyperion Financial Management (HFM)

Automation of TaskAudit and DataAudit in HFM


Table of Contents


1.       Introduction
2.       Scheduling the Command Script via Task Scheduler
3.       Invoking the Main Script TaskAudit_Email_Final.cmd
4.       Task and Data Audit Core Script
5.       Powershell Script for sending Reports as attachment
6.       Archive Folder
7.       Script Details



1.   Introduction

Task and Data Audit is data which every organization need on particular timeframe. In order to mitigate the risk to run over the Production Manual, script is been used to run on the specific time which reduce the Manual Work Load and intervention.

2.   Scheduling the Command Script via Windows Task Scheduler

Using the Windows Task Scheduler this script is scheduled to run the script every 1st of Month at 6 AM.

Location of Script: <Drive>:\TaskAuditAutomation


3.        Invoking the Main Script TaskAudit_Email_Final.cmd

Task Scheduler is going to invoke the TaskAudit_Email_Final.cmd script which consists of 2 scripts.

a)    TaskAudit.cmd
b)   final_sendemail.PS1

4.        Task and Data Audit Core Script

TaskAudit.cmd is the core script which generate the Task Audit and Data Audit in below mentioned folder. You can choose any folder like <Drive>:\TaskAuditAutomation\Reports folder

Data Parameter is defined in TaskAudit.cmd which will take last month 1st Day and last month last day, so that it will satisfy the required of taking Task Audit and Data Audit for last month.

5.        Powershell Script for sending Reports as attachment

final_sendemail.PS1 is PowerShell script which will take the report from the <Drive>:\TaskAuditAutomation\Reports folder and send to the desired recipients.

6.        Archive Folder


Once the mail is sent then TaskAudit_Email_Final.cmd script will archive the Reports which are generated to <Drive>:\TaskAuditAutomation\Reports\Archive Folder.



7.        Script Details

a.     TaskAudit.cmd
<Drive>:\Oracle\Middleware\EPMSystem11R1\products\FinancialManagement\Utilities\hfmauditextractcmdline_x64.exe -u "<Drive>:\Oracle\Middleware\EPMSystem11R1\products\FinancialManagement\Server Working Folder\<HFM_Server>.udl" -d <Drive>:\TaskAuditAutomation\Reports -a <HFM_Application_Name> -l; -s %moon% -e %sun% -t Enabled -x Enabled

b.     final_sendemail.PS1
$files=Get-ChildItem “<Drive>:\TaskAuditAutomation\Reports\” | Where {-NOT $_.PSIsContainer}
$smtpServer = "(Exchange Server or MailBox Server Name)"
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$msg.From = "Your email id or Mailbox id"
$msg.To.Add("Your email id or Receipent Email id")
$msg.Subject = "TaskAudit and DataAudit Report"
$msg.Body = "<b>Greeting for the day!!!</b><br><br><br>Please find the attachment for the TaskAudit and DataAudit for the last month <b>$Server</b><br><br><br> Have a Nice DAY! <br><br><br>Best Regards, <br>Hyperion Team"
$msg.IsBodyHtml = 1
Foreach($file in $files)
{
Write-Host “Attaching File :- ” $file
$attachment = New-Object Net.Mail.Attachment –ArgumentList <Drive>:\TaskAuditAutomation\Reports\$file
$msg.Attachments.Add($attachment)
}
$smtp.Send($msg)
$attachment.Dispose()
$msg.Dispose()


c.      TaskAudit_Email_Final.cmd 


echo off

call <Drive>:\TaskAuditAutomation\TaskAudit.cmd

Timeout /t 5

PowerShell -NoProfile -ExecutionPolicy Bypass -Command "& '<Drive>:\TaskAuditAutomation\final_sendemail'"

Timeout /t 5

move <Drive>:\TaskAuditAutomation\Reports\*.* <Drive>:\TaskAuditAutomation\Reports\Archive

Tuesday, February 23, 2016

Creating Windows Service for Weblogic Admin Server 10.3.6+

I am sure that you have gone through with many blogs and links which tell about how to create the Windows Services.


So, what is new in this post? I am covering step by step creation of Windows Service for Weblogic Admin Server and the issues which I have faced.


Step 1: Edit the installSvc.cmd file for creation of separate log files

You can find the installSvc.cmd file in your WL Home which be ideally in below folder in installation is in D Drive of Server

D:\Oracle\Middleware\wlserver_10.3\server\bin

It is been always recommend that keep the backup of Original file and do the edit the copy of that file.

Now, do the edit in your installSvc.cmd file so that it will create the new log file with the suffix of "stdout.txt". It should look like below"

"%WL_HOME%\server\bin\beasvc" -install -svcname:"%DOMAIN_NAME%_%SERVER_NAME%" -javahome:"%JAVA_HOME%" -execdir:"%USERDOMAIN_HOME%" -extrapath:"%WL_HOME%\server\bin" -password:"%WLS_PW%" -cmdline:%CMDLINE%
-log:"E:\MiddelwareHome\user_projects\domains\bifoundation_domain\%SERVER_NAME%-stdout.txt"

Step 2: Creation of launcher file, 

Write the batch file with below options:

echo off
SETLOCAL
set DOMAIN_NAME=<Domain_Name>
set USERDOMAIN_HOME=D:\Oracle\Middleware\user_projects\domains\<Domain_Name>
set SERVER_NAME=AdminServer
set PRODUCTION_MODE=true
cd %USERDOMAIN_HOME%
call %USERDOMAIN_HOME%\bin\setDomainEnv.cmd"
call "<WL_HOME>\server\bin\installSvc.cmd"
ENDLOCAL

Save the above batch file like installAdmServer_service.cmd

Run the above batch file it will create the Windows Services like:
"beasvc EPMSystem_AdminServer" it can be validated via Windows MMC (Services.msc)

Step3:  After creation of windows service you need to manually set some of the Configuration via Windows Registry

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\beasvc <your domain>_<managed server name>\Parameters

Even, we can creating all the registry settings via launcher batch file but I feel comfortable doing via registry. My intention is to create the windows services then do update the configuration so that removal of services and creation should be minimize.

Open the CmdLine in Registry and update the

-jrockit -Xms512m -Xmx1536m 
Host
Port



Since we are using jrockit JVM reason why you will see the -jrockit

Note: Make sure your server JAVA path is set to jrockit bin folder

Well, now you can start the Windows Services via Windows MMC.

If services went fine then you will see the beasvc.exe in your Task Manager.

Now, if you face the below issue similar like then follow me:

Issue1: While creating Windows Services below error can be caused by some of the Weblogic 10.3.6+ version

D:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\xqrl.jar\" -Dweblogic.Name=AdminServer -Dweblogic.management.username= -Dweblogic.ProductionModeEnabled=true -Djava.security.policy=\"D:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\webl
ogic.policy\" weblogic.Server"
'"oracle.fabric.common.classloaderurl.handler"' is not recognized as an internal
 or external command,
operable program or batch file.

This is because of multiple handlers in weblogic provided in setDomainEnv.cmd

So, follow the below workaround in installSvc.cmd file.

  1. Edit the installSvc.cmd script.
  2. Change the %JAVA_OPTIONS% string as follows:
    \"%JAVA_OPTIONS%\"
    For example, change from this:
    set CMDLINE="%JAVA_VM% %MEM_ARGS% %JAVA_OPTIONS% -classpath \"%CLASSPATH%\" -Dweblogic.Name=%SERVER_NAME% -Dweblogic.management.username=%WLS_USER% -Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE% -Djava.security.policy=\"%WL_HOME%\server\lib\weblogic.policy\" weblogic.Server"
    To this:
    set CMDLINE="%JAVA_VM% %MEM_ARGS% \"%JAVA_OPTIONS%\" -classpath \"%CLASSPATH%\" -Dweblogic.Name=%SERVER_NAME% -Dweblogic.management.username=%WLS_USER% -Dweblogic.ProductionModeEnabled=%PRODUCTION_MODE% -Djava.security.policy=\"%WL_HOME%\server\lib\weblogic.policy\" weblogic.Server"
 For complete cause of this issue you may review the Doc ID 1276229.1

Issue2: When Starting the Admin Service via Windows Service, you may be likely to get the below error:

Before merging tokens =  -Dweblogic.ProductionModeEnabled=true -XX:-FlightRecorder -da -Dplatform.home=D:\Oracle\MIDDLE~1\WLSERV~1.3 -Dwls.home=D:\Oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic.home=D:\Oracle\MIDDLE~1\WLSERV~1.3\server -DEPM_ORACLE_HOME=D:\Oracle\Middleware\EPMSystem11R1 -DEPM_ORACLE_INSTANCE=D:\Oracle\Middleware\user_projects\epmsystem1 -Dcommon.components.home=D:\Oracle\MIDDLE~1\ORACLE~1 -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=D:\Oracle\Middleware\user_projects\domains\EPMSystem -Djrockit.optfile=D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.server.config.dir=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\servers\AdminServer -Doracle.domain.config.dir=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1 -Digf.arisidbeans.carmlloc=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\carml -Digf.arisidstack.home=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\arisidprovider -Doracle.security.jps.config=D:\Oracle\Middleware\user_projects\domains\EPMSystem\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=D:\Oracle\Middleware\user_projects\domains\EPMSystem\servers\AdminServer\tmp\_WL_user -Doracle.deplo[Sun Feb 21 21:47:05 2016] [I] [ServiceStart] Thread created successfully
[Sun Feb 21 21:47:05 2016] [I] [ServiceStart] Reporting SCM of SERVICE_START_PENDING with delay=0
[Sun Feb 21 21:47:05 2016] [I] [ServiceStart] lpszHost = [10.14.74.33]
[Sun Feb 21 21:47:05 2016] [I] [ServiceStart] lpszPort = [7001]
[Sun Feb 21 21:47:05 2016] [I] [ServiceStart] pinging the host with max retry limit of 60
[Sun Feb 21 21:47:05 2016] [I] [ServiceStart] trying to open a connection to host
[Sun Feb 21 21:47:05 2016] [I] [ServiceStart] connection attempt failed. retrying
[Sun Feb 21 21:47:05 2016] [I] [StartJVM] Parsing JVM Arguments
[Sun Feb 21 21:47:05 2016] [I] [StartJVM] Initializing JVM
[Sun Feb 21 21:47:06 2016] [I] [RunJavaApp] Loading class -  -Dweblogic.ProductionModeEnabled=true -XX:-FlightRecorder -da -Dplatform.home=D:\Oracle\MIDDLE~1\WLSERV~1.3 -Dwls.home=D:\Oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic.home=D:\Oracle\MIDDLE~1\WLSERV~1.3\server -DEPM_ORACLE_HOME=D:\Oracle\Middleware\EPMSystem11R1 -DEPM_ORACLE_INSTANCE=D:\Oracle\Middleware\user_projects\epmsystem1 -Dcommon.components.home=D:\Oracle\MIDDLE~1\ORACLE~1 -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=D:\Oracle\Middleware\user_projects\domains\EPMSystem -Djrockit.optfile=D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.server.config.dir=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\servers\AdminServer -Doracle.domain.config.dir=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1 -Digf.arisidbeans.carmlloc=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\carml -Digf.arisidstack.home=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\arisidprovider -Doracle.security.jps.config=D:\Oracle\Middleware\user_projects\domains\EPMSystem\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=D:\Oracle\Middleware\user_projects\domains\EPMSystem\servers\AdminServer\tmp\_WL_user -Doracle.deployed.app.ext=\- -Dweblogic.alternateTypesDirectory=D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.ossoiap_11.1.1,D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.oamprovider_11.1.1,D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jps_11.1.1 -Djava.protocol.handler.pkgs=oracle.mds.net.protocol|oracle.fabric.common.classloaderurl.handler|oracle.fabric.common.uddiurl.handler|oracle.bpm.io.fs.protocol -Dweblogic.jdbc.remoteEnabled=false -da:org.apache.xmlbeans... -Dsoa.archives.dir=D:\Oracle\Middleware\Oracle_SOA1\soa -Dsoa.oracle.home=D:\Oracle\Middleware\Oracle_SOA1 -Dsoa.instance.home=D:\Oracle\Middleware\user_projects\domains\EPMSystem -Dtangosol.coherence.clusteraddress=227.7.7.9 -Dtangosol.coherence.clusterport=9778 -Dtangosol.coherence.log=jdk -Djavax.xml.soap.MessageFactory=oracle.j2ee.ws.saaj.soap.MessageFactoryImpl -Dweblogic.transaction.blocking.commit=true -Dweblogic.transaction.blocking.rollback=true -Djavax.net.ssl.trustStore=D:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\DemoTrust.jks -Dums.oracle.home=D:\Oracle\Middleware\Oracle_SOA1 -Dem.oracle.home=D:\Oracle\Middleware\oracle_common -Djava.awt.headless=true -Dweblogic.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=D:\Oracle\MIDDLE~1\patch_wls1036\profiles\default\sysext_manifest_classpath
Exception in thread "Main Thread" java.lang.NoClassDefFoundError:  -Dweblogic/ProductionModeEnabled=true -XX:-FlightRecorder -da -Dplatform/home=D:\Oracle\MIDDLE~1\WLSERV~1/3 -Dwls/home=D:\Oracle\MIDDLE~1\WLSERV~1/3\server -Dweblogic/home=D:\Oracle\MIDDLE~1\WLSERV~1/3\server -DEPM_ORACLE_HOME=D:\Oracle\Middleware\EPMSystem11R1 -DEPM_ORACLE_INSTANCE=D:\Oracle\Middleware\user_projects\epmsystem1 -Dcommon/components/home=D:\Oracle\MIDDLE~1\ORACLE~1 -Djrf/version=11/1/1 -Dorg/apache/commons/logging/Log=org/apache/commons/logging/impl/Jdk14Logger -Ddomain/home=D:\Oracle\Middleware\user_projects\domains\EPMSystem -Djrockit/optfile=D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle/jrf_11/1/1\jrocket_optfile/txt -Doracle/server/config/dir=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\servers\AdminServer -Doracle/domain/config/dir=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1 -Digf/arisidbeans/carmlloc=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\carml -Digf/arisidstack/home=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\arisidpr
Caused by: java.lang.ClassNotFoundException:  -Dweblogic.ProductionModeEnabled=true -XX:-FlightRecorder -da -Dplatform.home=D:\Oracle\MIDDLE~1\WLSERV~1.3 -Dwls.home=D:\Oracle\MIDDLE~1\WLSERV~1.3\server -Dweblogic.home=D:\Oracle\MIDDLE~1\WLSERV~1.3\server -DEPM_ORACLE_HOME=D:\Oracle\Middleware\EPMSystem11R1 -DEPM_ORACLE_INSTANCE=D:\Oracle\Middleware\user_projects\epmsystem1 -Dcommon.components.home=D:\Oracle\MIDDLE~1\ORACLE~1 -Djrf.version=11.1.1 -Dorg.apache.commons.logging.Log=org.apache.commons.logging.impl.Jdk14Logger -Ddomain.home=D:\Oracle\Middleware\user_projects\domains\EPMSystem -Djrockit.optfile=D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jrf_11.1.1\jrocket_optfile.txt -Doracle.server.config.dir=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\servers\AdminServer -Doracle.domain.config.dir=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1 -Digf.arisidbeans.carmlloc=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\carml -Digf.arisidstack.home=D:\Oracle\MIDDLE~1\USER_P~1\domains\EPMSYS~1\config\FMWCON~1\arisidprovider -Doracle.security.jps.config=D:\Oracle\Middleware\user_projects\domains\EPMSystem\config\fmwconfig\jps-config.xml -Doracle.deployed.app.dir=D:\Oracle\Middleware\user_projects\domains\EPMSystem\servers\AdminServer\tmp\_WL_user -Doracle.deployed.app.ext=\- -Dweblogic.alternateTypesDirectory=D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.ossoiap_11.1.1,D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.oamprovider_11.1.1,D:\Oracle\MIDDLE~1\ORACLE~1\modules\oracle.jps_11.1.1 -Djava.protocol.handler.pkgs=oracle.mds.net.protocol|oracle.fabric.common.classloaderurl.handler|oracle.fabric.common.uddiurl.handler|oracle.bpm.io.fs.protocol -Dweblogic.jdbc.remoteEnabled=false -da:org.apache.xmlbeans... -Dsoa.archives.dir=D:\Oracle\Middleware\Oracle_SOA1\soa -Dsoa.oracle.home=D:\Oracle\Middleware\Oracle_SOA1 -Dsoa.instance.home=D:\Oracle\Middleware\user_projects\domains\EPMSystem -Dtangosol.coherence.clusteraddress=227.7.7.9 -Dtangosol.coherence.clusterport=9778 -Dtangosol.coherence.log=jdk -Djavax.xml.soap.MessageFactory=oracle.j2ee.ws.saaj.soap.MessageFactoryImpl -Dweblogic.transaction.blocking.commit=true -Dweblogic.transaction.blocking.rollback=true -Djavax.net.ssl.trustStore=D:\Oracle\MIDDLE~1\WLSERV~1.3\server\lib\DemoTrust.jks -Dums.oracle.home=D:\Oracle\Middleware\Oracle_SOA1 -Dem.oracle.home=D:\Oracle\Middleware\oracle_common -Djava.awt.headless=true -Dweblogic.management.discover=true -Dwlw.iterativeDev=false -Dwlw.testConsole=false -Dwlw.logErrorsToConsole=false -Dweblogic.ext.dirs=D:\Oracle\MIDDLE~1\patch_wls1036\profiles\default\sysext_manifest_classpath
  at java.net.URLClassLoader$1.run(URLClassLoader.java:202)
  at java.net.URLClassLoader.findClass(URLClassLoader.java:190)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
  at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
  at java.lang.ClassLoader.loadClass(ClassLoader.java:247)
[Sun Feb 21 21:47:10 2016] [I] [ServiceStart] trying to open a connection to host
[Sun Feb 21 21:47:10 2016] [I] [ServiceStart] connection attempt failed. retrying
[Sun Feb 21 21:47:15 2016] [I] [ServiceStart] trying to open a connection to host
[Sun Feb 21 21:47:15 2016] [I] [ServiceStart] connection attempt failed. retrying
[Sun Feb 21 21:47:20 2016] [I] [ServiceStart] trying to open a connection to host
[Sun Feb 21 21:47:20 2016] [I] [ServiceStart] connection attempt failed. retrying
[Sun Feb 21 21:47:25 2016] [I] [ServiceStart] trying to open a connection to host
[Sun Feb 21 21:47:25 2016] [I] [ServiceStart] connection attempt failed. retrying
[Sun Feb 21 21:47:30 2016] [I] [ServiceStart] trying to open a connection to host
[Sun Feb 21 21:47:30 2016] [I] [ServiceStart] connection attempt failed. retrying
[Sun Feb 21 21:47:35 2016] [I] [ServiceStart] trying to open a connection to host
[Sun Feb 21 21:47:35 2016] [I] [ServiceStart] connection attempt failed. retrying
[Sun Feb 21 21:47:40 2016] [I] [ServiceStart] trying to open a connection to host
[Sun Feb 21 21:47:40 2016] [I] [ServiceStart] connection attempt failed. retrying

So, it bit tricky the issue is due to character encoding in the CmdLine of Windows Registry, This can be fixed by below:

Loading class -  -Dweblogic.ProductionModeEnabled=true
=====> What I have already seen:

User hand-edited the script in Word, hoping it would be easier.
Word replaces "minus sign" with something else "looking like a minus sign"...

Sending the output to a UniX and "vi" usually reveals the "minus sign" problem...

Please ERASE "-D" in the above and type "-D" in the command line...

As the JVM does not recognize "looking like a minus sign"D as a property, it believes it is a class name.
Thus the error message.

After doing the above recommendation most likely service will start.

I am sure that you may gone through with so many posts/blogs of creation of Windows Service of Weblogic Admin Server but dealing with above issues are bit less hence I have covered them all.

Feel free to provide your suggestion of ask me questions if you have.

Thanks for reading my post.

Regards,
Vikram