Beispiel #1
0
        public static MRSHealthCheckOutcome VerifyServiceIsRespondingToRPCPing(string serverName, TestMRSHealth testMRSCmdlet = null)
        {
            MRSHealthCheckOutcome outcome = null;

            CommonUtils.CatchKnownExceptions(delegate
            {
                MailboxReplicationServiceClient mailboxReplicationServiceClient2;
                MailboxReplicationServiceClient mailboxReplicationServiceClient = mailboxReplicationServiceClient2 = MailboxReplicationServiceClient.Create(serverName);
                try
                {
                    outcome = new MRSHealthCheckOutcome(serverName, MRSHealthCheckId.RPCPingCheck, true, Strings.MailboxReplicationServiceIsRespondingToRPCPing(mailboxReplicationServiceClient.ServerVersion.ToString()));
                }
                finally
                {
                    if (mailboxReplicationServiceClient2 != null)
                    {
                        ((IDisposable)mailboxReplicationServiceClient2).Dispose();
                    }
                }
            }, delegate(Exception ex)
            {
                if (testMRSCmdlet != null)
                {
                    testMRSCmdlet.MonitoringData.Events.Add(new MonitoringEvent("MSExchange Monitoring MRSHealth", 1002, EventTypeEnumeration.Error, Strings.MailboxReplicationServiceNotResponding(CommonUtils.FullExceptionMessage(ex, true))));
                }
                outcome = new MRSHealthCheckOutcome(serverName, MRSHealthCheckId.RPCPingCheck, false, Strings.MailboxReplicationServiceNotResponding(CommonUtils.FullExceptionMessage(ex, true)));
            });
            return(outcome);
        }
 protected override void InternalProcessRecord()
 {
     TaskLogger.LogEnter();
     try
     {
         MRSHealthCheckOutcome mrshealthCheckOutcome = MRSHealth.VerifyServiceIsUp(this.serverName, this.DataObject.Fqdn, this);
         base.WriteObject(mrshealthCheckOutcome);
         bool flag = mrshealthCheckOutcome.Passed;
         if (flag)
         {
             mrshealthCheckOutcome = MRSHealth.VerifyServiceIsRespondingToRPCPing(this.serverName, this);
             base.WriteObject(mrshealthCheckOutcome);
             if (mrshealthCheckOutcome.Passed)
             {
                 try
                 {
                     mrshealthCheckOutcome = MRSHealth.VerifyMRSProxyIsRespondingToWCFPing(this.serverName, this.MRSProxyServer, (this.MRSProxyCredentials == null) ? null : this.MRSProxyCredentials.GetNetworkCredential(), this);
                 }
                 catch (UnsupportedRemoteServerVersionWithOperationPermanentException)
                 {
                     mrshealthCheckOutcome = new MRSHealthCheckOutcome(this.serverName, MRSHealthCheckId.MRSProxyPingCheck, true, Strings.MRSProxyPingSkipped(this.serverName));
                 }
                 base.WriteObject(mrshealthCheckOutcome);
             }
             flag = mrshealthCheckOutcome.Passed;
             mrshealthCheckOutcome = MRSHealth.VerifyServiceIsScanningForJobs(this.serverName, (long)this.MaxQueueScanAgeSeconds, this);
             base.WriteObject(mrshealthCheckOutcome);
             flag &= mrshealthCheckOutcome.Passed;
         }
         if (flag)
         {
             this.MonitoringData.Events.Add(new MonitoringEvent("MSExchange Monitoring MRSHealth", 1000, EventTypeEnumeration.Success, Strings.MRSHealthPassed));
         }
     }
     catch (ConfigurationSettingsException exception)
     {
         this.WriteErrorAndMonitoringEvent(exception, ErrorCategory.InvalidOperation, 1001);
     }
     finally
     {
         if (this.MonitoringContext)
         {
             base.WriteObject(this.MonitoringData);
         }
         TaskLogger.LogExit();
     }
 }
Beispiel #3
0
        public static MRSHealthCheckOutcome VerifyServiceIsUp(string serverName, string fqdn, TestMRSHealth testMRSCmdlet = null)
        {
            MRSHealthCheckOutcome result;

            try
            {
                using (ManagementObject serviceObject = WmiWrapper.GetServiceObject(fqdn, "MSExchangeMailboxReplication"))
                {
                    if (serviceObject == null)
                    {
                        if (testMRSCmdlet != null)
                        {
                            testMRSCmdlet.MonitoringData.Events.Add(new MonitoringEvent("MSExchange Monitoring MRSHealth", 1001, EventTypeEnumeration.Error, Strings.MailboxReplicationServiceNotInstalled));
                        }
                        result = new MRSHealthCheckOutcome(serverName, MRSHealthCheckId.ServiceCheck, false, Strings.MailboxReplicationServiceNotInstalled);
                    }
                    else if (!StringComparer.InvariantCultureIgnoreCase.Equals(serviceObject["State"] as string, "Running"))
                    {
                        if (testMRSCmdlet != null)
                        {
                            testMRSCmdlet.MonitoringData.Events.Add(new MonitoringEvent("MSExchange Monitoring MRSHealth", 1001, EventTypeEnumeration.Error, Strings.MailboxReplicationServiceNotRunning));
                        }
                        result = new MRSHealthCheckOutcome(serverName, MRSHealthCheckId.ServiceCheck, false, Strings.MailboxReplicationServiceNotRunning);
                    }
                    else
                    {
                        result = new MRSHealthCheckOutcome(serverName, MRSHealthCheckId.ServiceCheck, true, Strings.MailboxReplicationServiceIsRunning);
                    }
                }
            }
            catch (WmiException ex)
            {
                ServiceHealthWmiFailureException ex2 = new ServiceHealthWmiFailureException(ex.Message, ex);
                if (testMRSCmdlet != null)
                {
                    testMRSCmdlet.WriteErrorAndMonitoringEvent(ex2, ErrorCategory.ReadError, 1001);
                }
                result = new MRSHealthCheckOutcome(serverName, MRSHealthCheckId.ServiceCheck, false, CommonUtils.FullExceptionMessage(ex2, true));
            }
            return(result);
        }