Exemplo n.º 1
0
        /// <summary>
        /// remove this category
        /// </summary>
        public CategoryInstallerRefeshResult DeleteCatagory(string categoryName)
        {
            CategoryInstallerRefeshResult result = CategoryInstallerRefeshResult.CatagoryDeleted;

            _performanceCounterCategoryProxy.Delete(categoryName);

            return(result);
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            DisplayBanner();
            if (args.Length > 0 && args[0].ToUpperInvariant() != "DEL" && args[0].ToUpperInvariant() != "TEST")
            {
                DisplayHelp();
                return;
            }

            _iocContainer = InitializeIocContainer();

            var installer = _iocContainer.Resolve <ICategoryInstaller>();
            CategoryInstallerRefeshResult result = CategoryInstallerRefeshResult.Unknown;

            if (args.Length > 0 && args[0].ToUpperInvariant() == "DEL")
            {
                result = installer.DeleteCatagory(CategoryInstaller.PodcastUtilitiesCommonCounterCategory);
            }
            else if (args.Length > 0 && args[0].ToUpperInvariant() == "TEST")
            {
                TestCounters();
                return;
            }
            else
            {
                installer.AddCounter(CategoryInstaller.AverageTimeToDownload, "Measures ms for the download call", PerformanceCounterType.AverageCount64);
                installer.AddCounter(CategoryInstaller.AverageTimeToDownload + "Base", "Measures ms for the download call", PerformanceCounterType.AverageBase);
                installer.AddCounter(CategoryInstaller.NumberOfDownloads, "Total number of downloads", PerformanceCounterType.NumberOfItems64);
                installer.AddCounter(CategoryInstaller.AverageMBDownload, "Measures MB for the download call", PerformanceCounterType.AverageCount64);
                installer.AddCounter(CategoryInstaller.AverageMBDownload + "Base", "Measures MB for the download call", PerformanceCounterType.AverageBase);
                installer.AddCounter(CategoryInstaller.SizeOfDownloads, "Total size of downloads in kb", PerformanceCounterType.NumberOfItems64);

                result = installer.RefreshCatagoryWithCounters(CategoryInstaller.PodcastUtilitiesCommonCounterCategory, "PodcastUtilities.Common counters");
            }

            switch (result)
            {
            case CategoryInstallerRefeshResult.CatagoryCreated:
                Console.WriteLine("{0} catagory created", CategoryInstaller.PodcastUtilitiesCommonCounterCategory);
                break;

            case CategoryInstallerRefeshResult.CatagoryUpdated:
                Console.WriteLine("{0} catagory updated", CategoryInstaller.PodcastUtilitiesCommonCounterCategory);
                break;

            case CategoryInstallerRefeshResult.CatagoryDeleted:
                Console.WriteLine("{0} catagory deleted", CategoryInstaller.PodcastUtilitiesCommonCounterCategory);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// refresh the catagory (creating if needed) and then update the catagory to contain all the counters that have been added to the installer
        /// </summary>
        public CategoryInstallerRefeshResult RefreshCatagoryWithCounters(string categoryName, string categoryDescription)
        {
            CategoryInstallerRefeshResult result = CategoryInstallerRefeshResult.CatagoryCreated;

            if (_performanceCounterCategoryProxy.Exists(categoryName))
            {
                _performanceCounterCategoryProxy.Delete(categoryName);
                result = CategoryInstallerRefeshResult.CatagoryUpdated;
            }

            _performanceCounterCategoryProxy.Create(categoryName,
                                                    categoryDescription,
                                                    PerformanceCounterCategoryType.SingleInstance, _counters);
            return(result);
        }