public async void GetForecastGraphData() { var device = await GetWindowsDeviceAsync().ConfigureAwait(false); var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU").ConfigureAwait(false); var dataSourceGraphs = await PortalClient.GetDataSourceGraphsAsync(dataSource.Id).ConfigureAwait(false); var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false); var deviceDataSourceInstances = await PortalClient.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id).ConfigureAwait(false); var deviceDataSourceInstance = deviceDataSourceInstances[0]; var dataSourceGraph = dataSourceGraphs[0]; var virtualDataPoint = dataSourceGraph.DataPoints[0]; var forecastGraphData = await PortalClient.GetForecastGraphDataAsync(new ForecastDataRequest { TrainingTimePeriod = TrainingTimePeriod.SixMonths, ForecastTimePeriod = ForecastTimePeriod.OneMonth, DataSourceInstanceId = deviceDataSourceInstance.Id, GraphId = dataSourceGraph.Id, DataPointLabel = virtualDataPoint.Name }).ConfigureAwait(false); Assert.Single(forecastGraphData.TrainingGraphData.Lines); Assert.Equal(3, forecastGraphData.ForecastedGraphData.Lines.Count); }
public async void GetWinCpuDeviceDataSourceInstancesFromDev() { var device = await GetWindowsDeviceAsync().ConfigureAwait(false); var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU").ConfigureAwait(false); var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false); var deviceDataSourceInstances = await PortalClient .GetAllDeviceDataSourceInstancesAsync( device.Id, deviceDataSource.Id, new Filter <DeviceDataSourceInstance> { Take = 300, ExtraFilters = new List <FilterItem <DeviceDataSourceInstance> > { new Eq <DeviceDataSourceInstance>(nameof(DeviceDataSourceInstance.StopMonitoring), false) }, Order = new Order <DeviceDataSourceInstance> { Property = nameof(DeviceDataSourceInstance.Name), Direction = OrderDirection.Asc } }).ConfigureAwait(false); Assert.NotNull(deviceDataSourceInstances); Assert.NotEmpty(deviceDataSourceInstances); }
public async Task GetGraphData() { var utcNow = DateTime.UtcNow; var startDateTime = utcNow.FirstDayOfLastMonth(); var device = await GetWindowsDeviceAsync().ConfigureAwait(false); Assert.NotNull(device); var dataSource = await PortalClient .GetDataSourceByUniqueNameAsync("WinCPU") .ConfigureAwait(false); Assert.NotNull(dataSource); var dataSourceGraph = await PortalClient .GetDataSourceGraphByNameAsync(dataSource.Id, "CPU Usage") .ConfigureAwait(false); Assert.NotNull(dataSourceGraph); var deviceDataSource = await PortalClient .GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id) .ConfigureAwait(false); Assert.NotNull(deviceDataSource); var deviceDataSourceInstances = await PortalClient .GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id, new Filter <DeviceDataSourceInstance>()) .ConfigureAwait(false); Assert.NotNull(deviceDataSourceInstances); Assert.NotEmpty(deviceDataSourceInstances); var deviceGraphDataRequest = new DeviceDataSourceInstanceGraphDataRequest { DeviceDataSourceInstanceId = deviceDataSourceInstances.Single().Id, DataSourceGraphId = dataSourceGraph.Id, TimePeriod = TimePeriod.Zoom, StartDateTime = startDateTime, EndDateTime = utcNow.LastDayOfLastMonth() }; // Ensure Caching is enabled PortalClient.UseCache = true; var graphData = await PortalClient.GetGraphDataAsync(deviceGraphDataRequest).ConfigureAwait(false); Assert.NotEmpty(graphData.Lines); Assert.Equal(startDateTime, graphData.StartTimeUtc); Assert.NotNull(graphData.Lines[0].ColorString); // Ensure that subsequent fetches are fast var stopwatch = Stopwatch.StartNew(); graphData = await PortalClient.GetGraphDataAsync(deviceGraphDataRequest).ConfigureAwait(false); Assert.NotNull(graphData); stopwatch.Stop(); Assert.True(stopwatch.ElapsedMilliseconds < 50); }
public async void GetGraphData_X250() { PortalClient.UseCache = true; var utcNow = DateTime.UtcNow; var startDateTime = utcNow.FirstDayOfLastMonth(); var device = await GetWindowsDeviceAsync().ConfigureAwait(false); var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU").ConfigureAwait(false); var dataSourceGraph = await PortalClient.GetDataSourceGraphByNameAsync(dataSource.Id, "CPU Usage").ConfigureAwait(false); Assert.NotNull(dataSourceGraph); var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false); var deviceDataSourceInstances = await PortalClient.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id, new Filter <DeviceDataSourceInstance>()).ConfigureAwait(false); var deviceGraphDataRequest = new DeviceDataSourceInstanceGraphDataRequest { DeviceDataSourceInstanceId = deviceDataSourceInstances.Single().Id, DataSourceGraphId = dataSourceGraph.Id, TimePeriod = TimePeriod.Zoom, StartDateTime = startDateTime, EndDateTime = utcNow.LastDayOfLastMonth() }; var sw = Stopwatch.StartNew(); for (var n = 0; n < 250; n++) { Logger.LogInformation($"{n:000}: {sw.ElapsedMilliseconds:00000}ms"); await PortalClient.GetGraphDataAsync(deviceGraphDataRequest).ConfigureAwait(false); } }
public async void GetRawData() { var device = await GetWindowsDeviceAsync().ConfigureAwait(false); var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinOS").ConfigureAwait(false); var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false); var deviceDataSourceInstance = (await PortalClient.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id).ConfigureAwait(false) ).Single(); var rawData = await PortalClient.GetRawDataSetAsync(device.Id, deviceDataSource.Id, deviceDataSourceInstance.Id).ConfigureAwait(false); Assert.NotNull(rawData); }
public async void FetchInstanceData() { var device = await GetWindowsDeviceAsync().ConfigureAwait(false); var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinIf-").ConfigureAwait(false); var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false); var deviceDataSourceInstances = await PortalClient.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id).ConfigureAwait(false); var end = DateTime.UtcNow; var start = end.AddHours(-2); var rawData = await PortalClient.GetFetchDataResponseAsync(deviceDataSourceInstances.Select(ddsi => ddsi.Id).ToList(), start, end).ConfigureAwait(false); Assert.NotNull(rawData); Assert.Equal(deviceDataSourceInstances.Count, rawData.TotalCount); Assert.Equal(deviceDataSourceInstances.Count, rawData.InstanceFetchDataResponses.Count); Assert.All(rawData.InstanceFetchDataResponses, response => Assert.Equal(dataSource.DataSourceDataPoints.Count, response.DataPoints.Length)); }
public async void OnlyMonitoredInstances() { var device = await GetSnmpDeviceAsync().ConfigureAwait(false); var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("snmp64_If-").ConfigureAwait(false); var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false); var deviceDataSourceInstances = await PortalClient.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id, new Filter <DeviceDataSourceInstance> { Order = new Order <DeviceDataSourceInstance> { Direction = OrderDirection.Asc, Property = nameof(DeviceDataSourceInstance.DisplayName) }, ExtraFilters = new List <FilterItem <DeviceDataSourceInstance> > { new Eq <DeviceDataSourceInstance>(nameof(DeviceDataSourceInstance.StopMonitoring), false) } }).ConfigureAwait(false); Assert.All(deviceDataSourceInstances, dsi => Assert.False(dsi.StopMonitoring)); }
public async void GetRawDataTimeConstrained() { var utcNow = DateTime.UtcNow; var yesterday = utcNow - TimeSpan.FromDays(1); var device = await GetWindowsDeviceAsync().ConfigureAwait(false); var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinOS").ConfigureAwait(false); var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false); var deviceDataSourceInstance = (await PortalClient.GetAllDeviceDataSourceInstancesAsync(device.Id, deviceDataSource.Id).ConfigureAwait(false) ).Single(); var rawData = await PortalClient.GetRawDataSetAsync(device.Id, deviceDataSource.Id, deviceDataSourceInstance.Id, yesterday, utcNow).ConfigureAwait(false); Assert.NotNull(rawData); Assert.All(rawData.UtcTimeStamps, r => { var dataDateTime = r.ToDateTimeUtcFromMs(); Assert.True(yesterday <= dataDateTime && dataDateTime <= utcNow); }); }
public async void GetAllDeviceDataSourceInstancesForOneDeviceDataSourceAsync() { var _ = await PortalClient.GetAllDeviceDataSourceInstancesAsync(WindowsDeviceId, WindowsDeviceLargeDeviceDataSourceId).ConfigureAwait(false); }