コード例 #1
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);
            }
        }
コード例 #2
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);
            }
        }
コード例 #3
0
        public override HealthCheckResponse CheckResponse()
        {
            _data.Clear();

            if (_urls == null)
            {
                return(null);
            }

            response.Up();

            foreach (string url in _urls)
            {
                checkHttpStatus(ref response, url);
            }

            response.Data = _data;
            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);
            }
        }