Beispiel #1
0
        private Task <ChartData> GetRealTimeData(string serverName, string database, string counter)
        {
            var client = SQLDatabaseUsageClient.CreateDatabaseUsagesClient(
                serverName,
                database,
                SqlCredentialsProvider(_path[0]).Username,
                SqlCredentialsProvider(_path[0]).Password);

            var usages = client.GetUsages();

            switch (counter)
            {
            case "logwrite":
                return(FilterSQLRealTimeUsages(usages, serverName, database, "Log write %", "avg_log_write_percent"));

            case "cpu":
                return(FilterSQLRealTimeUsages(usages, serverName, database, "CPU %", "avg_cpu_percent"));

            case "dataio":
                return(FilterSQLRealTimeUsages(usages, serverName, database, "Data IO %", "avg_data_io_percent"));

            case "memory":
                return(FilterSQLRealTimeUsages(usages, serverName, database, "Memory %", "avg_memory_usage_percent"));

            default:
                throw new Exception("Unknown counter " + counter);
            }
        }
        private ICollection <UsageObject> GetDatabaseUsages(DataAccess.SQLDatabase database)
        {
            var result = new List <UsageObject>();

            result.AddRange(SQLDatabaseUsageClient.CreateServerUsagesClient(database.Servername, database.Username, database.Password).GetUsages(DateTime.UtcNow.AddHours(-1)));

            var databaseNames = SQLDatabaseUsageClient.ListUserDatabases(database.Servername, database.Username, database.Password);

            foreach (var dbName in databaseNames)
            {
                result.AddRange(SQLDatabaseUsageClient.CreateDatabaseUsagesClient(database.Servername, dbName, database.Username, database.Password).GetUsages());
            }

            return(result);
        }