Beispiel #1
0
        public ConfigureTelemetry(CloudMediaContext myContext, IMonitoringConfiguration monitorconfig)
        {
            InitializeComponent();
            this.Icon = Bitmaps.Azure_Explorer_ico;

            _context       = myContext;
            _monitorconfig = monitorconfig;

            PrepareControls();
        }
Beispiel #2
0
        public void Start(IMonitoringConfiguration config)
        {
            _config = config;
            _metricCollectorStatsD = new MetricCollector(MetricCollection.StatsD);
            _senderThread          = new Thread(WriterThread)
            {
                Name = "carbon-sender", IsBackground = true
            };

            _senderThread.Start();
        }
 public MonitoringService(
     IMonitoringConfiguration configuration,
     IIndex <MonitoringType, IMonitoringCommandHandler> commandHandlers,
     IMonitoringFactory monitoringFactory,
     IConnectionManager connectionManager)
 {
     _configuration     = configuration;
     _commandHandlers   = commandHandlers;
     _monitoringFactory = monitoringFactory;
     _connectionManager = connectionManager;
 }
Beispiel #4
0
        static void Main(string[] args)
        {
            AzureAdTokenCredentials tokenCredentials =
                new AzureAdTokenCredentials(_AADTenantDomain,
                                            new AzureAdClientSymmetricKey(_AMSClientId, _AMSClientSecret),
                                            AzureEnvironments.AzureCloudEnvironment);

            var tokenProvider = new AzureAdTokenProvider(tokenCredentials);

            _context = new CloudMediaContext(new Uri(_RESTAPIEndpoint), tokenProvider);


            Console.WriteLine("Please choose your Azure Media Services telemety sources");
            _streamingEndpoint = ChooseStreamingEndpointForTelemetry();
            _channel           = ChooseLiveChannelForTelemetry();

            var monitoringConfigurations = _context.MonitoringConfigurations;
            IMonitoringConfiguration monitoringConfiguration = null;

            // No more than one monitoring configuration settings is allowed.
            // Once we have created it, it is the one that we shall use in future iterations...
            // you can use monitoringConfiguration.Delete(); to delete the monitoring configuration.
            if (monitoringConfigurations.ToArray().Length != 0)
            {
                monitoringConfiguration = _context.MonitoringConfigurations.FirstOrDefault();
            }
            else
            {
                INotificationEndPoint notificationEndPoint =
                    _context.NotificationEndPoints.Create("monitoring",
                                                          NotificationEndPointType.AzureTable, GetTableEndPoint());

                monitoringConfiguration = _context.MonitoringConfigurations.Create(notificationEndPoint.Id,
                                                                                   new List <ComponentMonitoringSetting>()
                {
                    new ComponentMonitoringSetting(MonitoringComponent.Channel, MonitoringLevel.Verbose),
                    new ComponentMonitoringSetting(MonitoringComponent.StreamingEndpoint, MonitoringLevel.Verbose)
                });
            }

            //Print metrics for a Streaming Endpoint.
            PrintMetrics();

            Console.WriteLine("\npress any key to exit...");
            Console.ReadKey();
        }
Beispiel #5
0
        public static void DeleteEntities(string authToken, bool allEntities, bool liveOnly)
        {
            User        authUser    = new User(authToken);
            MediaClient mediaClient = new MediaClient(authToken);

            if (liveOnly)
            {
                DeleteLive(authToken, authUser.MediaAccount.Id, mediaClient);
            }
            else if (!allEntities)
            {
                IAsset[] assets = mediaClient.GetEntities(MediaEntity.Asset) as IAsset[];
                foreach (IAsset asset in assets)
                {
                    if (asset.ParentAssets.Count > 0)
                    {
                        DeleteAsset(authToken, authUser.MediaAccount.Id, mediaClient, asset);
                    }
                }
            }
            else
            {
                DeleteLive(authToken, authUser.MediaAccount.Id, mediaClient);
                IIngestManifest[] manifests = mediaClient.GetEntities(MediaEntity.Manifest) as IIngestManifest[];
                foreach (IIngestManifest manifest in manifests)
                {
                    manifest.Delete();
                }
                IJobTemplate[] jobTemplates = mediaClient.GetEntities(MediaEntity.JobTemplate) as IJobTemplate[];
                foreach (IJobTemplate jobTemplate in jobTemplates)
                {
                    jobTemplate.Delete();
                }
                IJob[] jobs = mediaClient.GetEntities(MediaEntity.Job) as IJob[];
                foreach (IJob job in jobs)
                {
                    DeleteJob(authUser.MediaAccount.Id, job);
                }
                INotificationEndPoint[] notificationEndpoints = mediaClient.GetEntities(MediaEntity.NotificationEndpoint) as INotificationEndPoint[];
                foreach (INotificationEndPoint notificationEndpoint in notificationEndpoints)
                {
                    if (notificationEndpoint.EndPointType == NotificationEndPointType.AzureTable)
                    {
                        IMonitoringConfiguration monitoringConfig = mediaClient.GetEntityById(MediaEntity.MonitoringConfiguration, notificationEndpoint.Id) as IMonitoringConfiguration;
                        if (monitoringConfig != null)
                        {
                            monitoringConfig.Delete();
                        }
                    }
                    notificationEndpoint.Delete();
                }
                IAsset[] assets = mediaClient.GetEntities(MediaEntity.Asset) as IAsset[];
                foreach (IAsset asset in assets)
                {
                    DeleteAsset(authToken, authUser.MediaAccount.Id, mediaClient, asset);
                }
                IAccessPolicy[] accessPolicies = mediaClient.GetEntities(MediaEntity.AccessPolicy) as IAccessPolicy[];
                foreach (IAccessPolicy accessPolicy in accessPolicies)
                {
                    accessPolicy.Delete();
                }
                IAssetDeliveryPolicy[] deliveryPolicies = mediaClient.GetEntities(MediaEntity.DeliveryPolicy) as IAssetDeliveryPolicy[];
                foreach (IAssetDeliveryPolicy deliveryPolicy in deliveryPolicies)
                {
                    deliveryPolicy.Delete();
                }
                IContentKeyAuthorizationPolicy[] contentKeyAuthPolicies = mediaClient.GetEntities(MediaEntity.ContentKeyAuthPolicy) as IContentKeyAuthorizationPolicy[];
                foreach (IContentKeyAuthorizationPolicy contentKeyAuthPolicy in contentKeyAuthPolicies)
                {
                    contentKeyAuthPolicy.Delete();
                }
                IContentKeyAuthorizationPolicyOption[] contentKeyAuthPolicyOptions = mediaClient.GetEntities(MediaEntity.ContentKeyAuthPolicyOption) as IContentKeyAuthorizationPolicyOption[];
                foreach (IContentKeyAuthorizationPolicyOption contentKeyAuthPolicyOption in contentKeyAuthPolicyOptions)
                {
                    contentKeyAuthPolicyOption.Delete();
                }
                IContentKey[] contentKeys = mediaClient.GetEntities(MediaEntity.ContentKey) as IContentKey[];
                foreach (IContentKey contentKey in contentKeys)
                {
                    contentKey.Delete();
                }
            }
        }
Beispiel #6
0
 public HealthChecker(IMonitoringConfiguration configuration)
 {
     this.configuration = configuration;
 }
Beispiel #7
0
 public static string CreateUrl(this IMonitoringConfiguration configuration)
 {
     return($"http://{configuration.BaseAddress}:{configuration.Port ?? 8888}/");
 }
Beispiel #8
0
 public static void Init(IMonitoringConfiguration configuration)
 {
     _config     = configuration;
     _client     = new UdpClient();
     _ipEndPoint = new IPEndPoint(IPAddress.Parse(_config.StatsDHost), _config.StatsDPort);
 }
Beispiel #9
0
		public Status(IMonitoringConfiguration configuration)
		{
			this.configuration = configuration;
			jsonFormatter = new JsonMediaTypeFormatter();
			jsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();
		}
 public MonitoringFactory(IMonitoringConfiguration configuration)
 {
     _configuration = configuration;
 }
Beispiel #11
0
 public static void ClearAccount(MediaClient mediaClient, bool allEntities)
 {
     if (allEntities)
     {
         IProgram[] programs = mediaClient.GetEntities(MediaEntity.Program) as IProgram[];
         foreach (IProgram program in programs)
         {
             program.Delete();
         }
         IChannel[] channels = mediaClient.GetEntities(MediaEntity.Channel) as IChannel[];
         foreach (IChannel channel in channels)
         {
             channel.Delete();
         }
         IIngestManifest[] manifests = mediaClient.GetEntities(MediaEntity.Manifest) as IIngestManifest[];
         foreach (IIngestManifest manifest in manifests)
         {
             manifest.Delete();
         }
     }
     IJob[] jobs = mediaClient.GetEntities(MediaEntity.Job) as IJob[];
     foreach (IJob job in jobs)
     {
         job.Delete();
     }
     INotificationEndPoint[] notificationEndpoints = mediaClient.GetEntities(MediaEntity.NotificationEndpoint) as INotificationEndPoint[];
     foreach (INotificationEndPoint notificationEndpoint in notificationEndpoints)
     {
         if (notificationEndpoint.EndPointType == NotificationEndPointType.AzureTable)
         {
             IMonitoringConfiguration monitoringConfig = mediaClient.GetEntityById(MediaEntity.MonitoringConfiguration, notificationEndpoint.Id) as IMonitoringConfiguration;
             if (monitoringConfig != null)
             {
                 monitoringConfig.Delete();
             }
         }
         notificationEndpoint.Delete();
     }
     IAsset[] assets = mediaClient.GetEntities(MediaEntity.Asset) as IAsset[];
     foreach (IAsset asset in assets)
     {
         if (asset.ParentAssets.Count > 0 || allEntities)
         {
             DeleteAsset(mediaClient, asset);
         }
     }
     if (allEntities)
     {
         IAccessPolicy[] accessPolicies = mediaClient.GetEntities(MediaEntity.AccessPolicy) as IAccessPolicy[];
         foreach (IAccessPolicy accessPolicy in accessPolicies)
         {
             accessPolicy.Delete();
         }
         IAssetDeliveryPolicy[] deliveryPolicies = mediaClient.GetEntities(MediaEntity.DeliveryPolicy) as IAssetDeliveryPolicy[];
         foreach (IAssetDeliveryPolicy deliveryPolicy in deliveryPolicies)
         {
             deliveryPolicy.Delete();
         }
         IContentKeyAuthorizationPolicy[] contentKeyAuthPolicies = mediaClient.GetEntities(MediaEntity.ContentKeyAuthPolicy) as IContentKeyAuthorizationPolicy[];
         foreach (IContentKeyAuthorizationPolicy contentKeyAuthPolicy in contentKeyAuthPolicies)
         {
             contentKeyAuthPolicy.Delete();
         }
         IContentKeyAuthorizationPolicyOption[] contentKeyAuthPolicyOptions = mediaClient.GetEntities(MediaEntity.ContentKeyAuthPolicyOption) as IContentKeyAuthorizationPolicyOption[];
         foreach (IContentKeyAuthorizationPolicyOption contentKeyAuthPolicyOption in contentKeyAuthPolicyOptions)
         {
             contentKeyAuthPolicyOption.Delete();
         }
     }
 }