コード例 #1
0
        private void checkHttpStatus(ref HealthCheckResponse response, string url)
        {
            HttpWebRequest  myRequest;
            HttpWebResponse myResponse = null;

            try
            {
                myRequest  = (HttpWebRequest)WebRequest.Create(url);
                myResponse = (HttpWebResponse)myRequest.GetResponse();
                if ((int)myResponse.StatusCode >= 200 && (int)myResponse.StatusCode < 300)
                {
                    _data.Add(url, State.UP);
                }
                else
                {
                    response.Down();
                    _data.Add(url, State.DOWN);
                }
            }
            catch
            {
                response.Down();
                _data.Add(url, State.DOWN);
            }
            finally
            {
                if (myResponse != null)
                {
                    myResponse.Close();
                }
            }
        }
コード例 #2
0
        public override HealthCheckResponse CheckResponse()
        {
            try
            {
                var options = ConfigurationOptions.Parse(_configuration);
                var conn    = ConnectionMultiplexer.Connect(options);

                while (conn != null && conn.IsConnecting)
                {
                }
                ;
                if (conn.IsConnected)
                {
                    response.Up();
                    return(response);
                }
                else
                {
                    response.Down();
                    return(response);
                }
            }
            catch
            {
                response.Down();
                return(response);
            }
        }
コード例 #3
0
        public override HealthCheckResponse CheckResponse()
        {
            try
            {
                using (var connection = new SqlConnection(_connectionString))
                {
                    connection.Open();

                    SqlConnectionStringBuilder builder = new SqlConnectionStringBuilder(_connectionString);
                    _data.Add("server", builder.DataSource);
                    _data.Add("database", builder.InitialCatalog);
                    _data.Add("integrated-security", builder.IntegratedSecurity);
                    response.Data = _data;

                    if (connection != null && connection.State == System.Data.ConnectionState.Open)
                    {
                        connection.Close();
                        response.Up();
                        return(response);
                    }
                    response.Down();
                    return(response);
                }
            }
            catch (Exception ex)
            {
                response.Down();
                return(response);
            }
        }
コード例 #4
0
        public override HealthCheckResponse CheckResponse()
        {
            try
            {
                DriveInfo driveInfo   = new DriveInfo(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
                long      usableSpace = driveInfo.AvailableFreeSpace;

                if (!_data.ContainsKey(AVAILABLE_SPACE))
                {
                    _data.Add(AVAILABLE_SPACE, usableSpace);
                }
                else
                {
                    _data[AVAILABLE_SPACE] = usableSpace;
                }

                response.Data = _data;


                if (usableSpace >= _defaultTreshold)
                {
                    response.Up();
                    return(response);
                }
                else
                {
                    response.Down();
                    return(response);
                }
            }
            catch
            {
                response.Down();
                return(response);
            }
        }