Run service on 2 servers at the same time?

Topics: User Forum
Sep 2, 2009 at 4:50 PM

Is it possible to run the service on two different servers at the same time pointing at the same database?  That way if one of the servers stops running for some reason it will still run on the other one.

Thanks,

Mark

 

Oct 19, 2009 at 10:57 PM

I would be also interested in the answer. If this was not possible, then Polymon would be just a monitoring tool for a single computer. Yes, it can pull things status from other comps, but this is not all.

Thanks for an answer.

Radim

Oct 30, 2009 at 4:00 PM
Edited Oct 30, 2009 at 4:01 PM

Ahh... The old "who watches the watchdog" dilemma.  Here is my solution.

Sign up for the free service, R-U-ON at www.r-u-on.com

Now, download and install the ProcessMon monitor on your PolyMon server.  In the ProccessMon settings, set it to PolyMonExecutive.exe,1,1

This means that the PolyMonExecutive process must run and only one instance of it should run (min=1;max=1).  At any other condition, R-U-ON will notify you.  It's quick and easy and free, until PolyMon supports multiple Executives to watch or load balance each other (which to answer your question, it does not).

There is a lot of overlap between R-U-ON and PolyMon and I like to use them both for redundancy.  However, PolyMon absolutely trumps R-U-ON with flexibility, power, and reporting capabilities!  R-U-ON, on the other hand, has the advantage that it has a heartbeat to an external server, so it's great for watching your PolyMon server.  Since it has to phone home to R-U-ON central, even if the R-U-ON process crashes, you will be notified.

Also, for any advanced features, R-U-ON costs money, but as PolyMon's watchdog, it's free and works great.

Developer
Oct 30, 2009 at 4:20 PM
Edited Oct 30, 2009 at 4:20 PM

I run the following PowerShell script via Task Scheduler on the same server where PolyMon is running. It could also be adapted to use WMI and be run from a remote computer if desired. If PolyMon is not running the script will attempt to start it and send me an email telling me what happened.

 


--># Name:        Check-Service.ps1
#
Author:      Chris Harris
#
Version:     1.0
#
Updated:     10/26/2008
#
Description: Checks whether a service is running attempts to start it
#
              sends email with results of start attempt
#
Requires:    None
#
Usage:       .\check-service.ps1 -service:ServiceName
#
Todo:        Make email optional
#
              Make email more generic
#
Get Parameters
param(
[
string] $service = $(Throw "Please specify the name of the Service [-service]."),
[
bool] $email = $true
)

function send-email($SmtpServer,$From,$To,$subject,$Body){
   
$smtp = new-object system.net.mail.smtpClient($SmtpServer)
   
$mail = new-object System.Net.Mail.MailMessage
   
$mail.From = $From
   
$mail.To.Add($To)
   
$mail.Subject = $subject
   
$mail.Body = $Body
   
#$mail.IsBodyHtml = $true
    $smtp.Send($mail)
}

$service = "polymonExecutive"
$smtpServer = "MyExchangeServer"
$from = "polymon@MyPolyMonServer"
$to = "MyEmailAddress"
$subject = "PolyMon service Alert"


if ((Get-Service $service).Status -ne "Running") {
   
$Error.Clear()
   
# Attempt to start the service
    Start-Service $service
   
if ($Error){
       
$Body = "The [$service] service could not be started. The error was:"
       
$Body += `n+$Error
    }
   
else {
       
$Body = "The [$service] service was found to be stopped and has been started."
    }
   
if ($email){
       
Write-Host $body + `n
       
Write-Host "Sending email..."
       
$Error.clear
       
send-email -smtpServer $smtpServer -from $from -to $to -subject $subject -body $body
       
if (!$Error){
           
Write-Host "Email sent successfully."
        }
    }
}
else{
   
Write-Host "The [$service] service is running."
}