private RedisMemoryAnalysis GetDatabaseMemoryAnalysis(RedisConnectionInfo connectionInfo, int database)
        {
            var config = new ConfigurationOptions
            {
                SyncTimeout = 10 * 60 * 1000,
                AllowAdmin  = true,
                ClientName  = "Status-MemoryAnalyzer",
                Password    = connectionInfo.Password,
                Ssl         = connectionInfo.Settings.UseSSL,
                EndPoints   =
                {
                    { connectionInfo.Host, connectionInfo.Port }
                }
            };

            using var muxer = ConnectionMultiplexer.Connect(config);
            var ma = new RedisMemoryAnalysis(this, connectionInfo, database);

            if (ma.ErrorMessage.HasValue())
            {
                return(ma);
            }
            // Prep the match dictionary
            foreach (var km in KeyMatchers)
            {
                ma.KeyStats[km] = new KeyStats();
            }

            ma.Analyze(muxer);

            return(ma);
        }
Esempio n. 2
0
 public RedisInstance GetInstance(RedisConnectionInfo info)
 {
     foreach (var i in Instances)
     {
         if (i.ConnectionInfo == info)
         {
             return(i);
         }
     }
     return(null);
 }
        public RedisMemoryAnalysis(RedisAnalyzer analyzer, RedisConnectionInfo connectionInfo, int database)
        {
            CreationDate = DateTime.UtcNow;
            KeyStats     = new ConcurrentDictionary <KeyMatcher, KeyStats>();

            ConnectionInfo = connectionInfo;
            Database       = database;
            KeyMatchers    = analyzer.KeyMatchers;
            if (KeyMatchers.Count == 0)
            {
                ErrorMessage = "Could not find regexes defined for " + connectionInfo;
                return;
            }
            foreach (var km in KeyMatchers)
            {
                KeyStats[km] = new KeyStats();
            }
        }
Esempio n. 4
0
 public RedisInstance(RedisModule module, RedisConnectionInfo connectionInfo) : base(module, connectionInfo.Host + ":" + connectionInfo.Port.ToString())
 {
     ConnectionInfo        = connectionInfo;
     ShortHost             = connectionInfo.Host.Split(StringSplits.Period)[0];
     ReplicatesCrossRegion = module.Settings.Replication?.CrossRegionNameRegex?.IsMatch(ConnectionInfo.Name) ?? true;
 }
 private static string GetMemoryAnalysisKey(RedisConnectionInfo connectionInfo, int database)
 {
     return($"redis-memory-analysis-{connectionInfo.Host}:{connectionInfo.Port}:{database}");
 }