JavaBlog.fr / Java.lu Documentum,powershell,TOOLS DCTM Documentum : Starting, Stopping, Status Probing of DCTM Services, PowerShell Script

Documentum : Starting, Stopping, Status Probing of DCTM Services, PowerShell Script

Hello,

In this post, I would like expose the starting/stopping order and the status probing of DCTM services (PART I) (Content Server, globalr docbase, custom docbase, java method server, DFS…). In a second part (PART II), we will see a way to probe these DCTM services via a POWERSHELL script.
 


PART I


Stopping order:

  1. Documentum Java Method Server
  2. EMC Documentum Foundation Services
  3. Documentum Docbase Service mydemat
  4. Documentum Docbase Service globalr
  5. Documentum DocBroker Service Docbroker/DmDocbroker

 
Starting order:

  1. Documentum DocBroker Service Docbroker/DmDocbroker
  2. Documentum Docbase Service globalr
  3. Documentum Docbase Service mydemat
  4. Documentum Java Method Server
  5. EMC Documentum Foundation Services

 
Under Windows, there are the WINDOWS services for the starting/stopping of DocBroker, docbases and Java Method Server. But there are also some tools provided by DCTM for the probing status of these DCTM elements:
Docbroker :

  • START : Direct use of the WINDOWS service
  • STOP : Direct use of the WINDOWS service
  • STATUS : Use of DCTM tool dmqdocbroker.bat provided by DCTM to check the status of docbroker (ping-test on port 1489) ex : “D:\Documentum\product\7.2\bin\dmqdocbroker.bat -t mydctmserver -s -c ping -p 1489”

 
Docbase :

  • START : Direct use of the WINDOWS service
  • STOP : Direct use of the WINDOWS service
  • STATUS : Use of DCTM tool IDQL provided by DCTM (connection test) ex : “D:\Documentum\product\7.2\bin\idql.exe globalr -U$userLogin -P$userPassword -RC:\dummy.dql”

 
Java Method Server (JMS) :

  • START : Direct use of the WINDOWS service
  • STOP : Direct use of the WINDOWS service
  • STATUS : Probe the URL of JMS http://myDctmServer:9080/DmMethods/servlet/DoMethod which returns the value “Documentum Java Method Server”
    OR Use of DCTM tool dctmServerStatus.bat (see DmMethodServer.xml) provided by DCTM to check the status of JMS (ping-test on port 9084) ex : “D:\Documentum\jboss7.1.1\bin\dctmServerStatus.bat mydctmserver 9084” => Server is running.

 
Accelerated Content Server (ACS):

  • START : Automatically with JMS WINDOWS service
  • STOP : Automatically with JMS WINDOWS service
  • STATUS : Probe the URL of ACS http://myDctmServer:9080/ACS/servlet/ACS which returns the version of ACS “ACS Server Is Running – Version : 7.1.0190.0156”.

 
Documentum Mail Servlet (DMS):

  • START : Automatically with JMS WINDOWS service
  • STOP : Automatically with JMS WINDOWS service
  • STATUS : Probe the URL of DMS http://myDctmServer:9080/DmMail/servlet/DoMail which returns the value “Documentum Mail Servlet”.

 
Business Process Management (BPM):

  • START : Automatically with JMS WINDOWS service
  • STOP : Automatically with JMS WINDOWS service
  • STATUS : Probe the URL of BPM http://myDctmServer:9080/bpm/servlet/DoMethod which returns the value “Documentum Java Method Server”.

 


PART II


In this part, we will see a way to probe the DCTM services via a POWERSHELL script.
 
Presentation of the POWERSHELL:
Windows PowerShell, formerly Microsoft Command Shell (MSH), is a task automation and configuration management framework from Microsoft, consisting of a command-line shell. Included in Windows 7 and associated to scripting language, it is built on the .NET Framework. PowerShell is closer to object-oriented scripting languages like Perl than shell languages, such as Bash. There is no resemblance between the PowerShell and the batch language of .BAT files on DOS/Windows. The goal of Microsoft is to make a fully integrated scripting language, with as many features as exist under Unix (and Linux) and with the same level of security. If there is no possibility to run powershell script with UC4, you must create a .bat containing the following command:
powershell.exe -ExecutionPolicy Bypass -Command “Path\xxx.ps1 …”

More information : https://en.wikipedia.org/wiki/PowerShell
 
Windows PowerShell ISE / Simple example
It is possible to test a POWERSHELL script directly from the “Windows PowerShell ISE” editor:

So here’s a simple POWERSHELL script test.ps1:

01# Script permettant de checker que l'infra Documentum est fonctionnelle
02#
03 
04#Variables
05$ServerUrl="http://localhost/"
06 
07####################### CHECK #######################
08function checkServer(){
09write-host "checking server on $env:computername..."
10 
11#server up ?
12Invoke-WebRequest $ServerUrl > $null
13 
14if ($?){ #check that server is up
15write-host "server is up"
16}else{
17# send email
18write-host "server is down, notification email sent"
19}
20}
21 
22#main
23checkServer

 

If you try and run a Powershell script, you could get this helpful error message.

01PS C:\temp> powershell ./test.ps1
02 
03PS C:\temp> C:\temp\test.ps1
04...
05File C:\temp\test.ps1 cannot be loaded because the execution of scripts is disabled on this system.
06Impossible de charger le fichier C:\temp\test.ps1, car l’exécution de scripts est désactivée sur ce système.
07+ CategoryInfo          : Erreur de sécurité : (:) [], ParentContainsErrorRecordException
08+ FullyQualifiedErrorId : UnauthorizedAccess
09+ CategoryInfo          : NotSpecified: (:) [], PSSecurityException
10+ FullyQualifiedErrorId : RuntimeException
11...

It is necessary to change the Execution Policy on computer using a simple Powershell command (see http://go.microsoft.com/fwlink/?LinkID=135170).

  1. Start the « Windows PowerShell ISE » with administrator
  2. Confirm the modificatoin of execution’s strategy by “Yes for all”
  3. PS C:\temp> Set-ExecutionPolicy Unrestricted
    • Unrestricted – No restrictions; all Windows PowerShell scripts can be run.
    • Restricted – No scripts can be run. Windows PowerShell can be used only in interactive mode (This is the default).
    • AllSigned – Only scripts signed by a trusted publisher can be run.
    • RemoteSigned – Downloaded scripts must be signed by a trusted publisher before they can be run.
  4. Re-execute the script

 
It is also possible to execute a PS script due to a BATCH script test.bat:

1@ECHO OFF
2D:
3CD "C:\temp"
4powershell .\test.ps1

 
 
EXAMPLE 1 : Script “RestartMyDctmServices.ps1”
So here’s a POWERSHELL script in order to restart the DCTM services : docbroker, docbases et JMS.

01# RestartMyDctmServices.ps1
02# Service names
03$ServiceNames = New-Object System.Collections.ArrayList
04$ServiceNames.Add('DmServerGLOBALR') > $null
05$ServiceNames.Add('DmServerMY_DOCBASE1_DEV') > $null
06$ServiceNames.Add('DmServerMY_DOCBASE2_DEV') > $null
07 
08$ComputerNames = New-Object System.Collections.ArrayList
09$ComputerNames.Add('MYDCTMSERVER') > $null
10 
11foreach ($ComputerName in $ComputerNames) {
12 
13Write-Host "Restarting DmDocbroker on host $ComputerName"
14 
15$ServiceObj = Get-Service -Name "DmDocbroker" -ComputerName $ComputerName
16Restart-Service -InputObj $ServiceObj
17 
18Write-Host "Stopping DmMethodServer on host $ComputerName"
19 
20$ServiceObj = Get-Service -Name "DmMethodServer" -ComputerName $ComputerName
21Stop-Service -InputObj $ServiceObj
22 
23foreach ($ServiceName in $ServiceNames) {
24 
25Write-Host "Restarting $ServiceName on host $ComputerName"
26 
27$ServiceObj = Get-Service -Name $ServiceName -ComputerName $ComputerName
28Restart-Service -InputObj $ServiceObj
29 
30}
31 
32Write-Host "Starting DmMethodServer on host $ComputerName"
33 
34$ServiceObj = Get-Service -Name "DmMethodServer" -ComputerName $ComputerName
35Start-Service -InputObj $ServiceObj
36}

 
 
EXAMPLE 2 : Script “check_dctm_services.ps1”
So here’s a POWERSHELL script in order to probe the status of the DCTM services : docbroker, docbases et JMS.

01# check_dctm_services.ps1
02#
03#Variables
05$userLogin="dmadminUSER"
06$userPassword="pwd4dmadmin"
07 
08####################### CHECK #######################
09function checkDocBroker(){
10write-host "checking Docbroker on $env:computername..."
11 
12#docbroker up ?
13$statusDocbrok= invoke-expression "D:\Documentum\product\7.2\bin\dmqdocbroker.bat -t mydctmserver -s -c ping -p 1489"
14if ($LASTEXITCODE -eq 0){
15write-host "Docbroker is up"
16}else{
17# send email
18write-host "Docbroker is down, notification email sent"
19}
20}
21 
22function checkGlobalR(){
23write-host "checking docbase globalr on $env:computername..."
24 
25#docbase up ?
26$out=(invoke-expression "D:\Documentum\product\7.2\bin\idql.exe globalr -U$userLogin -P$userPassword -RC:\dummy.dql") 2> $null #dummy script (doesn't exist), for testing docbase connection
27 
28if ($out -match "Connected to Documentum server"){ #check that docbase is up
29write-host "docbase globalr is up"
30}else{
31# send email
32write-host "docbase globalr is down, notification email sent"
33}
34}
35 
36function checkMyDocbase(){
37write-host "checking docbase mydocbase on $env:computername..."
38 
39#docbase up ?
40$out=(invoke-expression "D:\Documentum\product\7.2\bin\idql.exe mydocbase -U$userLogin -P$userPassword -RC:\dummy.dql") 2> $null #dummy script (doesn't exist), for testing docbase connection
41 
42if ($out -match "Connected to Documentum server"){ #check that docbase is up
43write-host "docbase mydocbase is up"
44}else{
45# send email
46write-host "docbase mydocbase is down, notification email sent"
47}
48}
49 
50function checkJMS(){
51write-host "checking Java Method Server on $env:computername..."
52 
53#JMS up ?
54Invoke-WebRequest $JMSUrl > $null
55 
56if ($?){ #check that JMS is up
57write-host "JMS is up"
58}else{
59# send email
60write-host "JMS is down, notification email sent"
61}
62}
63 
64#main
65checkDocBroker
66checkGlobalR
67checkMyDocbase
68checkJMS

 

Example of script’s execution via WINDOWS POWERSHELL on the DCTM server MYDCTMSERVER :

1C:\Scripts>powershell ./check_dctm_services.ps1
2checking Docbroker on MYDCTMSERVER...
3Docbroker is up
4checking docbase globalr on MYDCTMSERVER...
5docbase globalr is up
6checking docbase mydocbase on MYDCTMSERVER...
7docbase mydocbase is down, notification email sent
8checking Java Method Server on MYDCTMSERVER...
9JMS is up

 
 
EXAMPLE 3 : Script “check_restart_dctm_services.ps1”
So here’s a POWERSHELL script in order to probe the status of JMS components (ACS, Mail, BPM) hosted on local Jboss Server. If there is a problem, the script kills all java.exe processes containing the “jboss7.1.1” command, restarts the JMS service and sends mail. This script could be executed every 5 minutes via a batch launched from a task in “Windows Task Scheduler”.

01# check_restart_dctm_services.ps1
02#
03function SendMyReport
04{
05param ([String] $report)
06 
07$sender = "noreply@java.lu"
08$to = "contact@java.lu"
09$server = "mysmtpserver.java.lu"
10$subject = "[ERROR] Th Java Method Server on $env:computername has been restarted"
11 
12$message = new-object System.Net.Mail.MailMessage $sender, $to, $subject, $report
13 
14$SMTPclient = new-object System.Net.Mail.SmtpClient $server
15$SMTPclient.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
16 
17$SMTPclient.Send($message)
18}
19 
20function CheckJMSComponentsStatus
21{
22$Urls = New-Object System.Collections.ArrayList
26$Urls.Add('http://localhost:9080/ACS/servlet/ACS') > $null
27 
28$Problems = New-Object System.Collections.ArrayList
29 
30foreach ($Url in $Urls) {
31Write-Host "My Testing of $Url";
32try
33{
34$status = [int][Net.WebRequest]::Create($Url).GetResponse().Statuscode
35if ($status -ne 200){
36Write-Host "$Url is not responding."
37$Problems.Add($Url) > $null
38}
39}
40catch
41{
42$Problems.Add($Url) > $null
43}
44}
45 
46if ($Problems.Count -gt 0){
47$Matches = New-Object System.Collections.ArrayList
48$Matches.Add('jboss7\.1\.1') > $null
49 
50foreach($Match in $Matches){
51foreach($ProcessId in (Get-WmiObject Win32_Process -Filter "name = 'java.exe'" | Where-Object { $_.CommandLine -match $Match } | Select-Object ProcessId)){
52Write-Host "Killing process"$ProcessId.ProcessId
53Get-Process -Id $ProcessId.ProcessId | Kill
54}
55}
56 
57$ServiceName = "DmMethodServer"
58 
59$ServiceObj = Get-Service -Name $ServiceName
60Start-Service -InputObj $ServiceObj
61 
62SendMyReport -Report "The service $ServiceName has been restarted."
63}else{
64Write-Host "OK, no problem!"
65}
66}
67 
68CheckJMSComponentsStatus

 
 

 
 

That’s all!!!!!

Huseyin OZVEREN

Leave a Reply

Your email address will not be published.

Time limit is exhausted. Please reload CAPTCHA.

Related Post