Exemplo n.º 1
0
        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);
            }
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public async void DeviceDataSourceTests2()
        {
            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU").ConfigureAwait(false);

            // Get all windows devices in the datacenter
            var devices = await PortalClient.GetDevicesByDeviceGroupFullPathAsync(DeviceGroupFullPath, true).ConfigureAwait(false);

            Assert.NotEmpty(devices);
            // We have devices

            // Find datacenter devices with WinCPU datasource
            var deviceDataSources = new List <DeviceDataSource>();

            foreach (var device in devices)
            {
                var deviceDataSourceByDeviceIdAndDataSourceId = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false);

                if (deviceDataSourceByDeviceIdAndDataSourceId == null)
                {
                    continue;
                }
                deviceDataSources.Add(deviceDataSourceByDeviceIdAndDataSourceId);
            }

            Assert.NotEmpty(deviceDataSources);
        }
Exemplo n.º 4
0
        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);
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 6
0
        public async void GetDataSourceByUniqueName_ValidNameWithSpaces_Ok()
        {
            const string DataSourceName = "IP Addresses";
            var          dataSource     = await PortalClient.GetDataSourceByUniqueNameAsync(DataSourceName).ConfigureAwait(false);

            Assert.NotNull(dataSource);
            Assert.Equal(DataSourceName, dataSource.Name);
        }
Exemplo n.º 7
0
        public async void GetXml()
        {
            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU").ConfigureAwait(false);

            var xml = await PortalClient.GetDataSourceXmlAsync(dataSource.Id).ConfigureAwait(false);

            Assert.NotNull(xml);
        }
Exemplo n.º 8
0
        public async void GetDataSourceMetadata()
        {
            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinVolumeUsage-").ConfigureAwait(false);

            Assert.NotNull(dataSource);
            Assert.NotEqual(0, dataSource.Id);
            var logicModuleMetadata = await PortalClient.GetLogicModuleMetadata(LogicModuleType.DataSource, dataSource.Id).ConfigureAwait(false);

            CheckMetadata(logicModuleMetadata);
        }
Exemplo n.º 9
0
        public async void WindowsServerDisks()
        {
            var device = await GetWindowsDeviceAsync().ConfigureAwait(false);

            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinVolumeUsage-").ConfigureAwait(false);

            var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false);

            Assert.Equal(device.Id, deviceDataSource.DeviceId);
            Assert.Equal(dataSource.Id, deviceDataSource.DataSourceId);
        }
Exemplo n.º 10
0
        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);
        }
Exemplo n.º 11
0
        public async void GetDevicesAndInstancesAssociatedWithDataSourceById()
        {
            // Get the dataSourceId
            var dataSourceId = (await PortalClient.GetDataSourceByUniqueNameAsync("WinVolumeUsage-").ConfigureAwait(false))?.Id;

            Assert.NotNull(dataSourceId);

            // Get the information
            var info = await PortalClient.GetDevicesAndInstancesAssociatedWithDataSourceByIdPageAsync((int)dataSourceId, new Filter <DeviceWithDataSourceInstanceInformation> {
                Skip = 0, Take = 300
            }).ConfigureAwait(false);

            // Check
            Assert.NotNull(info);
            //Assert.True(allPulsantDevices.TotalCount >= topFolderDevices.TotalCount);
            //Assert.True(allPulsantDevices.All(d=>d.DisplayName!=null));
        }
Exemplo n.º 12
0
        public async void GetDataPointThresholdDetailsForDeviceDataSourceInstance()
        {
            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.GetDeviceDataSourceInstancesPageAsync(device.Id, deviceDataSource.Id, new Filter <DeviceDataSourceInstance> {
                Skip = 0, Take = 10
            }).ConfigureAwait(false);

            var deviceDataSourceInstance = deviceDataSourceInstances.Items[0];
            var dataPointDetails         = await PortalClient.GetDeviceDataSourceInstanceDataPointConfigurationAsync(device.Id, deviceDataSource.Id, deviceDataSourceInstance.Id).ConfigureAwait(false);

            var dataPointConfiguration = dataPointDetails.Items[0];

            Assert.NotNull(dataPointConfiguration?.GlobalAlertExpr);
        }
Exemplo n.º 13
0
        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));
        }
Exemplo n.º 14
0
        public async void GetDeviceGroupDeviceDataSourceInstances()
        {
            var deviceGroup = await PortalClient.GetDeviceGroupByFullPathAsync(DeviceGroupFullPath).ConfigureAwait(false);

            Assert.NotNull(deviceGroup);
            Assert.NotEqual(0, deviceGroup.Id);
            // We have the device group

            // Determine the DataSources
            var dataSourcesIds = new List <DataSource>
            {
                await PortalClient.GetDataSourceByUniqueNameAsync("Ping").ConfigureAwait(false),
                await PortalClient.GetDataSourceByUniqueNameAsync("dns").ConfigureAwait(false)
            }
            .Select(ds => ds.Id)
            .ToList();

            var deviceDataSourceInstances = await PortalClient
                                            .GetInstancesAsync(LogicModuleType.DataSource, deviceGroup.Id, dataSourcesIds)
                                            .ConfigureAwait(false);

            Assert.NotNull(deviceDataSourceInstances);
            Assert.NotEmpty(deviceDataSourceInstances);

            var sum = 0;

            foreach (var deviceDataSourceInstance in deviceDataSourceInstances)
            {
                var device = await PortalClient
                             .GetAsync <Device>(deviceDataSourceInstance.DeviceId.Value)
                             .ConfigureAwait(false);

                var refetchedDeviceDataSourceInstanceCount = (await PortalClient
                                                              .GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(deviceDataSourceInstance.DeviceId.Value, deviceDataSourceInstance.DataSourceId.Value)
                                                              .ConfigureAwait(false)).InstanceCount;

                Assert.NotEqual(0, refetchedDeviceDataSourceInstanceCount);
                sum += refetchedDeviceDataSourceInstanceCount;
            }
            Assert.Equal(deviceDataSourceInstances.Count, sum);
        }
        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));
        }
Exemplo n.º 16
0
        public async void GetOverviewGraphData()
        {
            var device = await GetSnmpDeviceAsync().ConfigureAwait(false);

            Assert.NotNull(device);
            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("snmp64_If-").ConfigureAwait(false);

            Assert.NotNull(dataSource);
            var deviceDataSource = await PortalClient.GetDeviceDataSourceByDeviceIdAndDataSourceIdAsync(device.Id, dataSource.Id).ConfigureAwait(false);

            Assert.NotNull(deviceDataSource);
            var deviceDataSourceInstanceGroups = await PortalClient.GetDeviceDataSourceInstanceGroupsAsync(device.Id, deviceDataSource.Id).ConfigureAwait(false);

            Assert.NotNull(deviceDataSourceInstanceGroups);
            Assert.NotEmpty(deviceDataSourceInstanceGroups);
            var deviceDataSourceInstanceGroup        = deviceDataSourceInstanceGroups.Skip(1).First();
            var deviceDataSourceInstanceGroupRefetch = await PortalClient.GetDeviceDataSourceInstanceGroupByNameAsync(device.Id, deviceDataSource.Id, deviceDataSourceInstanceGroup.Name).ConfigureAwait(false);

            Assert.NotNull(deviceDataSourceInstanceGroupRefetch);
            Assert.Equal(deviceDataSourceInstanceGroup.Name, deviceDataSourceInstanceGroupRefetch.Name);

            var overviewGraph = await PortalClient.GetDeviceOverviewGraphByNameAsync(device.Id, deviceDataSource.Id, "Top 10 Interfaces by Total Packets").ConfigureAwait(false);

            Assert.NotNull(overviewGraph);
            var graphDataRequest = new DeviceDataSourceGraphDataRequest
            {
                DataSourceInstanceGroupId = deviceDataSourceInstanceGroup.Id,
                OverviewGraphId           = overviewGraph.Id,
                StartDateTime             = DateTime.UtcNow.FirstDayOfLastMonth(),
                EndDateTime = DateTime.UtcNow.LastDayOfLastMonth(),
                TimePeriod  = TimePeriod.Zoom,
                Width       = 500
            };

            graphDataRequest.Validate();
            var graphData = await PortalClient.GetGraphDataAsync(graphDataRequest).ConfigureAwait(false);

            Assert.NotNull(graphData);
        }
Exemplo n.º 17
0
        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);
            });
        }
Exemplo n.º 18
0
        public async void GetDataSourceByUniqueName_BadName_Null()
        {
            var dataSource = await PortalClient.GetDataSourceByUniqueNameAsync("WinCPU-").ConfigureAwait(false);

            Assert.Null(dataSource);
        }