Beispiel #1
0
        public static ICollection <ChartInfo> ListAllChartsForSqlDatabaseServer(string servername, string username, string password)
        {
            var client = SQLDatabaseUsageClient.CreateServerUsagesClient(servername, username, password);

            Func <string, string, string, ChartInfo> initChartInfo = (databaseName, uriPath, counterName) =>
                                                                     new ChartInfo {
                ResourceName = databaseName,
                ResourceType = "database",
                ServiceName  = servername,
                ServiceType  = "Azure SQL Database",
                Name         = string.Format("{0} {1} (SQL Database)", databaseName, counterName),
                Uri          = string.Format("wadgraphes://sql-database/{0}/{1}/{2}", client.ServerName, databaseName, uriPath)
            };


            var res = new List <ChartInfo>();

            foreach (var database in client.ListDatabases())
            {
                res.Add(initChartInfo(database, "logio", "Log I/O"));
                res.Add(initChartInfo(database, "dataio", "Data I/O"));
                res.Add(initChartInfo(database, "cpu", "CPU"));
                res.Add(initChartInfo(database, "storage", "Storage"));
                res.Add(initChartInfo(database, "memory", "Memory"));
                res.Add(initChartInfo(database, "sessions", "Sessions"));
            }

            return(res);
        }
Beispiel #2
0
        private Task <ChartData> GetSQLDatabaseChartData(TimeSpan interval)
        {
            var client = SQLDatabaseUsageClient.CreateServerUsagesClient(_path[0], SqlCredentialsProvider(_path[0]).Username, SqlCredentialsProvider(_path[0]).Password);
            var usages = client.GetUsages(DateTime.UtcNow.Add(interval.Negate()));

            var serverName = _path[0];
            var counter    = _path[_path.Length - 1];
            var database   = _path[_path.Length - 2];

            switch (counter)
            {
            case "logio":
                return(FilterSQLUsages(usages, serverName, database, "Log I/O", "avg_log_write_percent"));

            case "dataio":
                return(FilterSQLUsages(usages, serverName, database, "Data I/O", "avg_physical_data_read_percent", "avg_data_io_percent"));

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

            case "storage":
                return(FilterSQLUsages(usages, serverName, database, "Storage", "storage_in_megabytes"));

            case "memory":
                return(FilterSQLUsages(usages, serverName, database, "Memory", "active_memory_used_kb"));

            case "sessions":
                return(FilterSQLUsages(usages, serverName, database, "Sessions", "active_session_count"));

            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);
        }
Beispiel #4
0
 private static string GetVersionFromSession(AddSQLDatabaseSession session)
 {
     return(SQLDatabaseUsageClient.CreateServerUsagesClient(session.Servername, session.Username, session.Password).GetVersionString());
 }
Beispiel #5
0
 internal static TestConnectionResult TestConnection(MVC.Commands.CreateAzureSQLDatabaseCommand cmd)
 {
     return(SQLDatabaseUsageClient.CreateServerUsagesClient(cmd.Servername, cmd.Username, cmd.Password).TestConnection());
 }
Beispiel #6
0
 private ICollection <UsageObject> GetDatabaseUsages(DataAccess.SQLDatabase database)
 {
     return(SQLDatabaseUsageClient.CreateServerUsagesClient(database.Servername, database.Username, database.Password).GetUsages(DateTime.UtcNow.AddHours(-1)));
 }