コード例 #1
0
        protected HealthInfoPersisted GetDagHealthInfo(string serverToQueryFqdn)
        {
            HealthInfoPersisted hip = null;
            Exception           ex  = MonitoringServiceClient.HandleException(delegate
            {
                TimeSpan timeSpan = TimeSpan.FromSeconds((double)this.TimeoutInSeconds);
                using (MonitoringServiceClient monitoringServiceClient = MonitoringServiceClient.Open(serverToQueryFqdn, timeSpan, timeSpan, timeSpan, MonitoringServiceClient.ReceiveTimeout))
                {
                    Task <HealthInfoPersisted> dagHealthInfoAsync = monitoringServiceClient.GetDagHealthInfoAsync();
                    if (!dagHealthInfoAsync.Wait(timeSpan))
                    {
                        throw new TimeoutException(Strings.GetDagHealthInfoRequestTimedOut(this.TimeoutInSeconds));
                    }
                    hip = dagHealthInfoAsync.Result;
                }
            });

            if (ex != null)
            {
                base.WriteError(new GetDagHealthInfoRequestException(serverToQueryFqdn, ex.Message, ex), ErrorCategory.InvalidResult, serverToQueryFqdn);
                return(null);
            }
            hip.ToString();
            return(hip);
        }
コード例 #2
0
        private Task <Tuple <string, T> >[] ExecuteRemoteCallForServers <T>(string operationTraceName, IEnumerable <string> serverFqdnsToContact, Func <MonitoringServiceClient, Task <Tuple <string, T> > > remoteOperation)
        {
            int num = serverFqdnsToContact.Count <string>();

            if (num == 0)
            {
                DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "{0}(): There are no servers to contact. Returning <NULL>.", operationTraceName);
                return(null);
            }
            Task <Tuple <string, T> >[] array = new Task <Tuple <string, T> > [num];
            int num2 = 0;

            Task <Tuple <string, T> >[] result;
            using (DisposeGuard disposeGuard = default(DisposeGuard))
            {
                foreach (string serverName in serverFqdnsToContact)
                {
                    MonitoringServiceClient monitoringServiceClient = MonitoringServiceClient.Open(serverName);
                    disposeGuard.Add <MonitoringServiceClient>(monitoringServiceClient);
                    Task <Tuple <string, T> > task = remoteOperation(monitoringServiceClient);
                    array[num2++] = task;
                }
                try
                {
                    TimeSpan timeSpan = TimeSpan.FromSeconds(30.0);
                    if (!Task.WaitAll((Task[])array, timeSpan))
                    {
                        DatabaseHealthTracker.Tracer.TraceError <string, TimeSpan>((long)this.GetHashCode(), "{0}(): One or more calls timed out after '{1}'.", operationTraceName, timeSpan);
                        ReplayCrimsonEvents.DHTRemoteOperationTimedOut.LogPeriodic <string, TimeSpan>(operationTraceName, DateTimeHelper.OneHour, operationTraceName, timeSpan);
                    }
                    else
                    {
                        DatabaseHealthTracker.Tracer.TraceDebug <string>((long)this.GetHashCode(), "{0}(): All calls were issued successfully.", operationTraceName);
                    }
                }
                catch (AggregateException ex)
                {
                    foreach (Exception ex2 in ex.Flatten().InnerExceptions)
                    {
                        DatabaseHealthTracker.Tracer.TraceError <string, Exception>((long)this.GetHashCode(), "{0}() got Exception: {1}", operationTraceName, ex2);
                        ReplayCrimsonEvents.DHTRemoteOperationFailed.LogPeriodic <string, string, Exception>(ex2.Message, DateTimeHelper.OneHour, operationTraceName, ex2.Message, ex2);
                    }
                }
                result = array;
            }
            return(result);
        }
コード例 #3
0
        protected override void InternalRun()
        {
            if (!ReplicationCheckGlobals.MonitoringServiceCheckHasRun)
            {
                ReplicationCheckGlobals.MonitoringServiceCheckHasRun = true;
            }
            else
            {
                ExTraceGlobals.HealthChecksTracer.TraceDebug((long)this.GetHashCode(), "MonitoringServiceCheck skipping because it has already been run once.");
                base.Skip();
            }
            if ((ReplicationCheckGlobals.ServerConfiguration & ServerConfig.Stopped) == ServerConfig.Stopped)
            {
                ExTraceGlobals.HealthChecksTracer.TraceDebug <string>((long)this.GetHashCode(), "Stopped server! Skipping {0}.", base.Title);
                base.Skip();
            }
            TimeSpan  timeout = TimeSpan.FromSeconds(5.0);
            Exception ex      = MonitoringServiceClient.HandleException(delegate
            {
                using (MonitoringServiceClient monitoringServiceClient = MonitoringServiceClient.Open(this.ServerName, timeout, timeout, timeout, timeout))
                {
                    Task <ServiceVersion> versionAsync = monitoringServiceClient.GetVersionAsync();
                    if (!versionAsync.Wait(timeout))
                    {
                        ExTraceGlobals.HealthChecksTracer.TraceError <string, TimeSpan>((long)this.GetHashCode(), "MonitoringServiceCheck: GetVersionAsync() call to server '{0}' timed out after '{1}'", this.ServerName, timeout);
                        this.Fail(Strings.MonitoringServiceRequestTimedout(this.ServerName, timeout));
                    }
                    else
                    {
                        ExTraceGlobals.HealthChecksTracer.TraceDebug <string, long>((long)this.GetHashCode(), "MonitoringServiceCheck: GetVersionAsync() call to server '{0}' returned: {1}", this.ServerName, versionAsync.Result.Version);
                    }
                }
            });

            if (ex != null)
            {
                ExTraceGlobals.HealthChecksTracer.TraceError <string, Exception>((long)this.GetHashCode(), "MonitoringServiceCheck: GetVersionAsync() call to server '{0}' failed with exception: {1}", base.ServerName, ex);
                base.Fail(Strings.MonitoringServiceRequestFailed(base.ServerName, ex.Message));
            }
        }
コード例 #4
0
        static void Main(string[] args)
        {
            MonitoringServiceClient proxy = new MonitoringServiceClient(
                //"netTcpEndpoint"
                "httpEndpoint"
                );

            proxy.Open();
            while (true)
            {
                Thread.Sleep(TimeSpan.FromSeconds(1));


                MonitoringValues values  = proxy.CurrentValues();
                bool             isAlive = proxy.isAlive();


                Console.WriteLine("Maschinenstatus: {0}\nGutmengen: {1}\nAusschussmengen: {2}",
                                  values.Maschinenstatus, values.Gutmengen, values.Ausschussmengen);
//                Console.ReadLine();
            }
            proxy.Close();
        }
コード例 #5
0
		public bool CheckServerState(VMForPCSettingsName control, string connString, string connName)
		{
			bool ret = false;

			try
			{
				switch (control)
				{
					case VMForPCSettingsName.SCVMMServer:
						{
							if (!IsNullOrWhiteSpaceString(connString)
								&& !IsNullOrWhiteSpaceString(connName))
							{
								EndpointAddress endPointAddress = GetEndPointAddress(connString, connName);

								using (VirtualMachineManagementServiceClient check = new VirtualMachineManagementServiceClient(new WSHttpBinding("WSHttpBinding_IVirtualMachineManagementService"), endPointAddress))
								{
									check.Open();
									ret = true;
									check.Close();
								}
							}
							break;
						}
					case VMForPCSettingsName.SCOMServer:
						{
							if (!IsNullOrWhiteSpaceString(connString)
								&& !IsNullOrWhiteSpaceString(connName))
							{
								EndpointAddress endPointAddress = GetEndPointAddress(connString, connName);

								using (MonitoringServiceClient checkMonitoring = new MonitoringServiceClient(new WSHttpBinding("WSHttpBinding_IMonitoringService"), endPointAddress))
								{
									checkMonitoring.Open();
									ret = true;
									checkMonitoring.Close();
								}
							}
							break;
						}
				}
			}
			catch (Exception ex)
			{
				//
				Log.WriteError("Could not check server state", ex);
				//
				ret = false;
				//
				throw;
			}
			return ret;
		}