Goal
This document describes how to create a Windows PowerShell script that can be used to alert if a Denodo Virtual DataPort (VDP) server is stopped and to attempt to start it again. The script will also store the historical status of the VDP server to a log file.
Keep in mind that this article applies to Denodo servers started as Windows services. If you start your server as a Process, refer to the Automating status check and startup of Denodo processes article.
Content
Sample script
The following script will check the status of the Virtual DataPort service and will try to restart it if stopped. A similar script can be used to check the status of any Denodo service.
#################################################### # # # Virtual DataPort service status notifier # # # #################################################### #-------------------Configuration------------------ Param( [string]$vdpServiceName, [string]$denodoHome, [string]$logFilePath ) #------------------------------------------------- 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 = ("VDP Server is " + $status) $objNotifyIcon.BalloonTipTitle = "Denodo Platform 8.0" $objNotifyIcon.Visible = $True $objNotifyIcon.ShowBalloonTip(10000) } function logStatus($status){ $status = ((Get-Date).ToString() + " " +$status) Add-Content $logFilePath $status } if((Get-Service -Name $vdpServiceName).Status -eq "Stopped"){ taskbarNotification("stopped") logStatus("VDP Server is stopped") Start-Service $vdpServiceName if((Get-Service -Name $vdpServiceName).Status -eq "Running"){ taskbarNotification("running") logStatus("VDP Server is running") Exit } else{ taskbarNotification("stopped. Unable to start the service.") logStatus("VDP Server is stopped. Unable to start the service.") Exit } } else{ logStatus("VDP Server is running") } |
Running the script
1. Copy it to a text editor and save it to any location, for instance: C:\vdpService.ps1
2. Open a command prompt as an Administrator and execute the following:
powershell -ExecutionPolicy Bypass -File C:\vdpService.ps1 -vdpServiceName "vdpserver80" -denodoHome "C:\Denodo\80" -logFilePath "C:\vdpService.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
- -vdpServiceName: The service name for the VDP Server. To get the name of the service go to Start > Run and run services.msc. Double click on the service name, for instance, for Denodo VDP 8.0 the service name will be "Denodo VQL Server 8.0". The name to be used in the script will be the value for "Service name" in the pop-up window under the “General” tab. In a default installation of Denodo Platform 8.0, this value will be vdpserver80.
- -denodoHome: The path to the Denodo Platform installation. For instance “C:\Denodo\80”.
- -logFilePath: The path where the log file will be saved. For instance “C:\vdpService.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:\vdpService.ps1 -vdpServiceName "vdpserver80" -denodoHome "C:\Denodo\80" -logFilePath "C:\vdpService.log" |
6. Save the task.
Note: For Denodo Platform 7.0 and 8.0, make sure to change the configuration in both Denodo Solution Manager and Denodo Platform.