예제 #1
0
        private void reportServiceUtilizationData()
        {
            log.Debug("Fetching performance data for machine: {0}, service: {1}", this.machineName, this.serviceName);
            PerformanceCounterService service = new PerformanceCounterService(machineName, serviceName);

            service.initPerformanceCounters();
            ServiceCounters counter = service.getProcessDetails();

            if (counter == null)
            {
                log.Error("Error gettting performace data for service: {0}, Null counter returned.", this.serviceName);
            }
            ReportMetric(this.machineName + "/" + this.serviceName + "/status", "#", counter.status);
            foreach (var pair in counter.performanceValues)
            {
                string metricName = this.machineName + "/" + this.serviceName + "/" + pair.Key;
                ReportMetric(metricName, "#", pair.Value);
            }
        }
        public ServiceCounters getProcessDetails()
        {
            try
            {
                ServiceCounters details = new ServiceCounters();
                details.status    = (int)controller.Status;
                details.name      = instanceName;
                details.processId = processId;

                details.performanceValues = new List <KeyValuePair <string, float> >();
                foreach (var item in counters)
                {
                    details.performanceValues.Add(new KeyValuePair <string, float>(item.Key, item.Value.NextValue()));
                }
                return(details);
            }
            catch (Exception ex)
            {
                log.Error("Error getting performance data for machine: {0}, service: {1}", this.machineName, this.serviceName);
                log.Error(ex.Message);
                return(null);
            }
        }