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:

# Script permettant de checker que l'infra Documentum est fonctionnelle
#

#Variables
$ServerUrl="http://localhost/"

####################### CHECK ####################### 
function checkServer(){
   write-host "checking server on $env:computername..."
   
   #server up ?
   Invoke-WebRequest $ServerUrl > $null

   if ($?){ #check that server is up
        write-host "server is up"
   }else{
        # send email
        write-host "server is down, notification email sent"
   }   
}

#main
checkServer

 

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

PS C:\temp> powershell ./test.ps1

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

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:

@ECHO OFF
D:
CD "C:\temp"
powershell .\test.ps1

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

# RestartMyDctmServices.ps1
# Service names  
$ServiceNames = New-Object System.Collections.ArrayList
$ServiceNames.Add('DmServerGLOBALR') > $null
$ServiceNames.Add('DmServerMY_DOCBASE1_DEV') > $null
$ServiceNames.Add('DmServerMY_DOCBASE2_DEV') > $null

$ComputerNames = New-Object System.Collections.ArrayList
$ComputerNames.Add('MYDCTMSERVER') > $null


foreach ($ComputerName in $ComputerNames) {

	Write-Host "Restarting DmDocbroker on host $ComputerName"

	$ServiceObj = Get-Service -Name "DmDocbroker" -ComputerName $ComputerName
	Restart-Service -InputObj $ServiceObj


	Write-Host "Stopping DmMethodServer on host $ComputerName"

	$ServiceObj = Get-Service -Name "DmMethodServer" -ComputerName $ComputerName
	Stop-Service -InputObj $ServiceObj

	foreach ($ServiceName in $ServiceNames) {

		Write-Host "Restarting $ServiceName on host $ComputerName"

		$ServiceObj = Get-Service -Name $ServiceName -ComputerName $ComputerName
		Restart-Service -InputObj $ServiceObj

	}

	Write-Host "Starting DmMethodServer on host $ComputerName"

	$ServiceObj = Get-Service -Name "DmMethodServer" -ComputerName $ComputerName
	Start-Service -InputObj $ServiceObj
}

 
 
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.

# check_dctm_services.ps1
#
#Variables
$JMSUrl="http://mydctmserver:9080/DmMethods/servlet/DoMethod"
$userLogin="dmadminUSER"
$userPassword="pwd4dmadmin"



####################### CHECK ####################### 
function checkDocBroker(){
    write-host "checking Docbroker on $env:computername..."
    
    #docbroker up ?
    $statusDocbrok= invoke-expression "D:\Documentum\product\7.2\bin\dmqdocbroker.bat -t mydctmserver -s -c ping -p 1489"
    if ($LASTEXITCODE -eq 0){ 
        write-host "Docbroker is up"
    }else{
        # send email
        write-host "Docbroker is down, notification email sent"
    }
}


function checkGlobalR(){
   write-host "checking docbase globalr on $env:computername..."
   
   #docbase up ?
   $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

   if ($out -match "Connected to Documentum server"){ #check that docbase is up
        write-host "docbase globalr is up"
   }else{
        # send email
        write-host "docbase globalr is down, notification email sent"
   }   
}


function checkMyDocbase(){
   write-host "checking docbase mydocbase on $env:computername..."
   
   #docbase up ?
   $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

   if ($out -match "Connected to Documentum server"){ #check that docbase is up
        write-host "docbase mydocbase is up"
   }else{
        # send email
        write-host "docbase mydocbase is down, notification email sent"
   }   
}




function checkJMS(){
   write-host "checking Java Method Server on $env:computername..."
   
   #JMS up ?
   Invoke-WebRequest $JMSUrl > $null

   if ($?){ #check that JMS is up
        write-host "JMS is up"
   }else{
        # send email
        write-host "JMS is down, notification email sent"
   }   
}


#main
checkDocBroker
checkGlobalR
checkMyDocbase
checkJMS

 

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

C:\Scripts>powershell ./check_dctm_services.ps1
checking Docbroker on MYDCTMSERVER...
Docbroker is up
checking docbase globalr on MYDCTMSERVER...
docbase globalr is up
checking docbase mydocbase on MYDCTMSERVER...
docbase mydocbase is down, notification email sent
checking Java Method Server on MYDCTMSERVER...
JMS 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”.

# check_restart_dctm_services.ps1
#
function SendMyReport
{   
    param ([String] $report)

    $sender = "noreply@java.lu"
    $to = "contact@java.lu"
    $server = "mysmtpserver.java.lu"
    $subject = "[ERROR] Th Java Method Server on $env:computername has been restarted"
	
    $message = new-object System.Net.Mail.MailMessage $sender, $to, $subject, $report
  
    $SMTPclient = new-object System.Net.Mail.SmtpClient $server
    $SMTPclient.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

    $SMTPclient.Send($message) 
}

function CheckJMSComponentsStatus 
{
	$Urls = New-Object System.Collections.ArrayList
	$Urls.Add('http://localhost:9080/DmMethods/servlet/DoMethod') > $null
	$Urls.Add('http://localhost:9080/DmMail/servlet/DoMail') > $null
	$Urls.Add('http://localhost:9080/bpm/servlet/DoMethod') > $null
	$Urls.Add('http://localhost:9080/ACS/servlet/ACS') > $null
	
	 
	$Problems = New-Object System.Collections.ArrayList

	foreach ($Url in $Urls) {
		Write-Host "My Testing of $Url";
		try
		{
			$status = [int][Net.WebRequest]::Create($Url).GetResponse().Statuscode
			if ($status -ne 200){
				Write-Host "$Url is not responding."
				$Problems.Add($Url) > $null
			}
		}
		catch 
		{
			$Problems.Add($Url) > $null
		}
	}

	if ($Problems.Count -gt 0){
		$Matches = New-Object System.Collections.ArrayList
		$Matches.Add('jboss7\.1\.1') > $null
		
		foreach($Match in $Matches){
			foreach($ProcessId in (Get-WmiObject Win32_Process -Filter "name = 'java.exe'" | Where-Object { $_.CommandLine -match $Match } | Select-Object ProcessId)){
				Write-Host "Killing process"$ProcessId.ProcessId
				Get-Process -Id $ProcessId.ProcessId | Kill
			}
		}

		$ServiceName = "DmMethodServer"
		
		$ServiceObj = Get-Service -Name $ServiceName
		Start-Service -InputObj $ServiceObj
		
		SendMyReport -Report "The service $ServiceName has been restarted."
	}else{
		Write-Host "OK, no problem!"
	}
}

CheckJMSComponentsStatus

 
 

 
 

That’s all!!!!!

Huseyin OZVEREN