Automating status check and startup of Denodo processes

Applies to: Denodo 7.0 , Denodo 6.0
Last modified on: 06 Jun 2019
Tags: Administration Monitoring

Download document

Goal

The Denodo servers can be started either as services or as a process. In this article, an example script is shown to automating 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.

ITPilot Browser Pool

In Windows 10 and Windows Server 2016 or above it is recommended to start the Browser Pool as a process. You can use this article to automate the execution of the Browser Pool.

Content

Sample script

The following script will check the status of the Browser Pool process and will try to restart it if stopped. A similar script can be developed to check the status of any Denodo service.

####################################################

#                                                  #

#      Browser Pool service status notifier        #

#                                                  #

####################################################

#-------------------Configuration------------------

Param(

         

     [string]$denodoHome,

     [string]$logFilePath

)

$serviceName="Browser Pool"

$startupScriptName="browserpool_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 = ("Browser Pool is " + $status)

        $objNotifyIcon.BalloonTipTitle = "Denodo Platform 7.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("Browser Pool is running")

    Exit

} else{

    taskbarNotification("stopped")

    logStatus("Browser Pool 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("Browser Pool is running")

        Exit

        }

        else{

        taskbarNotification("stopped. Unable to start the service.")

        logStatus("Browser Pool 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:\browserPoolProcess.ps1

2. Open a command prompt as an Administrator and execute the following.

powershell -ExecutionPolicy Bypass -File C:\browserPoolProcess.ps1 -denodoHome "C:\Denodo\70"  -logFilePath "C:\browserPoolProcess.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:\browserPoolProcess.ps1
  • -denodoHome: The path to the Denodo Platform installation. For instance “C:\Denodo\70”.
  • -logFilePath: The path where the log file will be saved. For instance “C:\browserPoolProcess.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:\browserPoolProcess.ps1 -denodoHome "C:\Denodo\70"  -logFilePath "C:\browserPoolProcess.log"

6. Save the task.

Questions

Ask a question
You must sign in to ask a question. If you do not have an account, you can register here

Featured content

DENODO TRAINING

Ready for more? Great! We offer a comprehensive set of training courses, taught by our technical instructors in small, private groups for getting a full, in-depth guided training in the usage of the Denodo Platform. Check out our training courses.

Training