Automating status check and startup of Denodo processes
You can translate the document:Goal
The Denodo servers can be started either as services or as a process. In this article, an example script is shown to automate the start of a Windows process, and restart it if down. This script can be applied to any Denodo server started as a Process.
Keep in mind that there is another article describing how to perform this task when the Denodo servers are started as Windows Services instead of as a Process. You can check the article here: Automating status check of Denodo services.
Content
Sample script
The following script will check the status of the Denodo Virtual DataPort (VDP) Server process and will try to restart it if stopped. A similar script can be developed to check the status of any Denodo service.
|
####################################################
# #
# VDP Server service status notifier #
# #
####################################################
#-------------------Configuration------------------
Param(
[string]$denodoHome, [string]$logFilePath
)
$serviceName="VDP Server" $startupScriptName="vqlserver_startup.bat"
#-------------------------------------------------
function taskbarNotification($status){
[void] [System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms")
$objNotifyIcon = New-Object System.Windows.Forms.NotifyIcon
$objNotifyIcon.Icon = ($denodoHome + "\resources\denodo\ico\denodo_platform.ico")
$objNotifyIcon.BalloonTipText = ($serviceName + " " + $status)
$objNotifyIcon.BalloonTipTitle = "Denodo Platform 9.0"
$objNotifyIcon.Visible = $True
$objNotifyIcon.ShowBalloonTip(10000)
}
function logStatus($status){
$status = ((Get-Date).ToString() + " " +$status)
Add-Content $logFilePath $status
}
if (Get-WmiObject Win32_Process -Filter "CommandLine like '%$serviceName%'" | Select-Object CommandLine){
taskbarNotification("running")
logStatus($serviceName + " is running")
Exit } else{
taskbarNotification("stopped")
logStatus($serviceName + " is stopped")
$startupScriptPath = $denodoHome + "\bin\" + $startupScriptName
invoke-expression -Command $startupScriptPath
if (Get-WmiObject Win32_Process -Filter "CommandLine like '%$serviceName%'" | Select-Object CommandLine){
taskbarNotification("running")
logStatus($serviceName + " is running")
Exit } else{
taskbarNotification("stopped. Unable to start the service.")
logStatus($serviceName + " is stopped. Unable to start the service.")
Exit
}
}
|
Running the script
1. Copy it to a text editor and save it to any location, for instance:
C:\vqlserverver.ps1
2. Open a command prompt as an Administrator and execute the following.
powershell -ExecutionPolicy Bypass -File C:\vqlserverver.ps1 -denodoHome "C:\Denodo\DenodoPlatform9.0" -logFilePath "C:\vqlserverver.log"
where:
- powershell: The program to run
- -ExecutionPolicy Bypass: By default, unsigned PowerShell scripts are prevented from execution. This option allows bypassing this restriction.
- -File: Path to the PowerShell script. For instance C:\vqlserverver.ps1
- -denodoHome: The path to the Denodo Platform installation. For instance “C:\Denodo\DenodoPlatform9.0”.
- -logFilePath: The path where the log file will be saved. For instance “C:\vqlserverver.log”.
Automating the execution of the script
1. Open the Windows Task Scheduler (Control Panel > Administrative Tools > Task Scheduler).
2. Click on "Create Task..." in the right side pane.
3. Type in the name and description in the "General" tab and check "Run with highest privileges".
4. Use the "Trigger" tab to schedule when this task should run.
5. In the "Actions" tab, for the "Program/script" option, type the same command as for the manual execution:
powershell -ExecutionPolicy Bypass -File C:\vqlserverver.ps1 -denodoHome "C:\Denodo\DenodoPlatform9.0" -logFilePath "C:\vqlserverver.log"
6. Save the task.
The information provided in the Denodo Knowledge Base is intended to assist our users in advanced uses of Denodo. Please note that the results from the application of processes and configurations detailed in these documents may vary depending on your specific environment. Use them at your own discretion.
For an official guide of supported features, please refer to the User Manuals. For questions on critical systems or complex environments we recommend you to contact your Denodo Customer Success Manager.
