Пример #1
0
        ///<summary>
        ///Monitors the performance.
        ///</summary>
        ///<param name="pmRef"></param>
        ///<param name="vmRef"></param>
        ///<param name="mMetrics"></param>
        ///<param name="counters"></param>
        void monitorPerformance(ManagedObjectReference pmRef,
                                ManagedObjectReference vmRef,
                                ArrayList mMetrics,
                                Hashtable counters)
        {
            PerfMetricId[] metricIds = (new PerfMetricId[] { (PerfMetricId)mMetrics[0] });
            PerfQuerySpec  qSpec     = new PerfQuerySpec();

            qSpec.entity              = vmRef;
            qSpec.maxSample           = 10;
            qSpec.maxSampleSpecified  = true;
            qSpec.metricId            = metricIds;
            qSpec.intervalId          = 20;
            qSpec.intervalIdSpecified = true;

            PerfQuerySpec[] qSpecs          = new PerfQuerySpec[] { qSpec };
            Boolean         continueDataCol = true;

            while (continueDataCol)
            {
                PerfEntityMetricBase[] pValues
                    = cb.getConnection()._service.QueryPerf(pmRef, qSpecs);
                if (pValues != null)
                {
                    displayValues(pValues, counters);
                }
                Console.WriteLine("Do you want to continue: Y/N");
                string con = Console.ReadLine();
                if (con.Equals("Y") || con.Equals("y"))
                {
                    Console.WriteLine("Sleeping 10 seconds...");
                    Thread.Sleep(10 * 1000);
                }
                else
                {
                    continueDataCol = false;
                }
            }
        }
Пример #2
0
        /// <summary>
        ///Displays the performance measurements of specified counter of specified
        ///Host System.
        /// </summary>
       private void displayHistory() {
          ManagedObjectReference hostmor 
             = cb.getServiceUtil().GetDecendentMoRef(null,"HostSystem",
                                                     cb.get_option("hostname"));
          if(hostmor == null) {
             Console.WriteLine("Host " + cb.get_option("hostname") + " not found");
             return;
          }
          ManagedObjectReference pmRef 
             = cb.getConnection()._sic.perfManager;
          CounterInfo(pmRef);

          //Retrieves all configured historical archive sampling intervals.
          PerfInterval[] intervals 
             = (PerfInterval[])cb.getServiceUtil().GetDynamicProperty(pmRef, 
                                                                     "historicalInterval");
          int interval = (int.Parse(cb.get_option("interval")));
          Boolean valid = checkInterval(intervals,interval);
          if(!valid) {
             Console.WriteLine("Invalid inerval, Specify one from above");
             return;
          }

          PerfCounterInfo pci = getCounterInfo(cb.get_option("groupname"), 
                                               cb.get_option("countername"),
                                               PerfSummaryType.average);
          if(pci == null) {
             Console.WriteLine("Incorrect Group Name and Counters Specified");
             return;
          }

          //specifies the query parameters to be used while retrieving statistics.
          //e.g. entity, maxsample etc.
          PerfQuerySpec qSpec = new PerfQuerySpec();
          qSpec.entity = hostmor;
          qSpec.maxSample= 10;
          qSpec.maxSampleSpecified = true;
          PerfQuerySpec[] qSpecs = new PerfQuerySpec[] {qSpec};

          DateTime sTime;
          DateTime eTime = cb.getConnection()._service.CurrentTime(
                              cb.getConnection().ServiceRef);

          double duration = double.Parse(cb.get_option("duration"));
          double startTime = double.Parse(cb.get_option("starttime"));


          sTime = eTime.AddMinutes(-duration);

          Console.WriteLine("Start Time " + sTime.TimeOfDay.ToString());
          Console.WriteLine("End Time   " + eTime.TimeOfDay.ToString());

          Console.WriteLine();
          //Retrieves the query available of performance metric for a host.
          PerfMetricId[] aMetrics 
             = cb.getConnection()._service.QueryAvailablePerfMetric(pmRef, 
                                                                        hostmor, 
                                                                        sTime, 
                                                                        true,
                                                                        eTime, 
                                                                        true,
                                                                        interval,true);
          PerfMetricId ourCounter = null;

          for(int index=0; index<aMetrics.Length; ++index) {
             if(aMetrics[index].counterId == pci.key) {
                ourCounter = aMetrics[index];
                break;
             }
          }
          if(ourCounter == null) {
             Console.WriteLine("No data on Host to collect. "
                               +"Has it been running for at least " 
                               + cb.get_option("duration") + " minutes");
          } else {
             qSpec = new PerfQuerySpec();
             qSpec.entity= hostmor;
             qSpec.startTime =sTime;
             qSpec.endTime= eTime;
             qSpec.metricId = (new PerfMetricId[]{ourCounter});
             qSpec.intervalId =interval;
             qSpec.intervalIdSpecified = true;
             qSpec.startTimeSpecified = true;
             qSpec.endTimeSpecified = true;
             qSpecs = new PerfQuerySpec[] {qSpec};
             //
             PerfEntityMetricBase[] samples 
                = cb.getConnection()._service.QueryPerf(pmRef, qSpecs);
             if(samples != null) {
                displayValues(samples, pci, ourCounter, interval);
             }
             else {
                Console.WriteLine("No Smaples Found");
             }
          }
       }
Пример #3
0
       ///<summary>
       ///Monitors the performance.
       ///</summary>
       ///<param name="pmRef"></param>
       ///<param name="vmRef"></param>
       ///<param name="mMetrics"></param>
       ///<param name="counters"></param>
       void monitorPerformance(ManagedObjectReference pmRef,
                                 ManagedObjectReference vmRef, 
                                 ArrayList mMetrics,
                                 Hashtable counters) {
          PerfMetricId[] metricIds = (new PerfMetricId[] { (PerfMetricId)mMetrics[0] });
          PerfQuerySpec qSpec = new PerfQuerySpec();
          qSpec.entity=vmRef;
          qSpec.maxSample = 10;
          qSpec.maxSampleSpecified = true;
          qSpec.metricId= metricIds;
          qSpec.intervalId= 20;
          qSpec.intervalIdSpecified = true;

          PerfQuerySpec[] qSpecs = new PerfQuerySpec[] {qSpec};
          Boolean continueDataCol = true;
          while (continueDataCol) {
             PerfEntityMetricBase[] pValues 
                = cb.getConnection()._service.QueryPerf(pmRef,qSpecs);
             if(pValues != null) displayValues(pValues, counters);
                 Console.WriteLine("Do you want to continue: Y/N");
                 string con = Console.ReadLine();
                  if( con.Equals("Y")||con.Equals("y")){
                 Console.WriteLine("Sleeping 10 seconds...");
                 Thread.Sleep(10*1000);
              } else{
                  continueDataCol = false;
              }
          }
       }
Пример #4
0
        /// <summary>
        ///Displays the performance measurements of specified counter of specified
        ///Host System.
        /// </summary>
        private void displayHistory()
        {
            ManagedObjectReference hostmor
                = cb.getServiceUtil().GetDecendentMoRef(null, "HostSystem",
                                                        cb.get_option("hostname"));

            if (hostmor == null)
            {
                Console.WriteLine("Host " + cb.get_option("hostname") + " not found");
                return;
            }
            ManagedObjectReference pmRef
                = cb.getConnection()._sic.perfManager;

            CounterInfo(pmRef);

            //Retrieves all configured historical archive sampling intervals.
            PerfInterval[] intervals
                = (PerfInterval[])cb.getServiceUtil().GetDynamicProperty(pmRef,
                                                                         "historicalInterval");
            int     interval = (int.Parse(cb.get_option("interval")));
            Boolean valid    = checkInterval(intervals, interval);

            if (!valid)
            {
                Console.WriteLine("Invalid inerval, Specify one from above");
                return;
            }

            PerfCounterInfo pci = getCounterInfo(cb.get_option("groupname"),
                                                 cb.get_option("countername"),
                                                 PerfSummaryType.average);

            if (pci == null)
            {
                Console.WriteLine("Incorrect Group Name and Counters Specified");
                return;
            }

            //specifies the query parameters to be used while retrieving statistics.
            //e.g. entity, maxsample etc.
            PerfQuerySpec qSpec = new PerfQuerySpec();

            qSpec.entity             = hostmor;
            qSpec.maxSample          = 10;
            qSpec.maxSampleSpecified = true;
            PerfQuerySpec[] qSpecs = new PerfQuerySpec[] { qSpec };

            DateTime sTime;
            DateTime eTime = cb.getConnection()._service.CurrentTime(
                cb.getConnection().ServiceRef);

            double duration  = double.Parse(cb.get_option("duration"));
            double startTime = double.Parse(cb.get_option("starttime"));


            sTime = eTime.AddMinutes(-duration);

            Console.WriteLine("Start Time " + sTime.TimeOfDay.ToString());
            Console.WriteLine("End Time   " + eTime.TimeOfDay.ToString());

            Console.WriteLine();
            //Retrieves the query available of performance metric for a host.
            PerfMetricId[] aMetrics
                = cb.getConnection()._service.QueryAvailablePerfMetric(pmRef,
                                                                       hostmor,
                                                                       sTime,
                                                                       true,
                                                                       eTime,
                                                                       true,
                                                                       interval, true);
            PerfMetricId ourCounter = null;

            for (int index = 0; index < aMetrics.Length; ++index)
            {
                if (aMetrics[index].counterId == pci.key)
                {
                    ourCounter = aMetrics[index];
                    break;
                }
            }
            if (ourCounter == null)
            {
                Console.WriteLine("No data on Host to collect. "
                                  + "Has it been running for at least "
                                  + cb.get_option("duration") + " minutes");
            }
            else
            {
                qSpec                     = new PerfQuerySpec();
                qSpec.entity              = hostmor;
                qSpec.startTime           = sTime;
                qSpec.endTime             = eTime;
                qSpec.metricId            = (new PerfMetricId[] { ourCounter });
                qSpec.intervalId          = interval;
                qSpec.intervalIdSpecified = true;
                qSpec.startTimeSpecified  = true;
                qSpec.endTimeSpecified    = true;
                qSpecs                    = new PerfQuerySpec[] { qSpec };
                //
                PerfEntityMetricBase[] samples
                    = cb.getConnection()._service.QueryPerf(pmRef, qSpecs);
                if (samples != null)
                {
                    displayValues(samples, pci, ourCounter, interval);
                }
                else
                {
                    Console.WriteLine("No Smaples Found");
                }
            }
        }