Examples of PerformanceSample


Examples of com.vmware.aurora.vc.VcPerformance.PerformanceSample

               }
               // Note: RP doesn't implement relative stats (cpu::usage or mem::usage), or mem::active, or net::anything
               List<String> ids = new ArrayList<String>();
               ids.add(refId);
               Map<String, PerformanceSample> result = vcp.queryLatestPerformance(ids, PerformanceType.cpuAbs);
               PerformanceSample sample= result.get(refId);
               perf = (sample == null ? "unavailable" : sample.toString());
               System.out.println("     latest cpu sample: " + perf);
            } catch (Exception e) {
               System.out.println("     perf query failed: " + e.getMessage());
            }
         }
      }

      // iterate datacenters to iterate virtual machines
      for (Datacenter dc : getDatacenters()) {
         System.out.println("DC " + dc);
         for (VirtualMachine vm: getVirtualMachines(dc)) {
            // Skip templates, which can't be powered on and have no associated performance data
            if (vm.getConfig().isTemplate()) {
               continue;
            }

            System.out.println("VM " + vm.getName() + ":");
            String refId = MoUtil.morefToString(vm._getRef());
            try {
               String perf;
               Integer[] intervals = vcp.getAllSamplingIntervals(refId);
               int resolution = intervals[0]; // fastest sampling supported
               //System.out.println("   supports sampling intervals: " + listToString(intervals));

               // NB: if you pass times (relative to present, minutes ago) 0,0 (all recent samples): get lots, some are very recent
               // if you pass 60,0 (all samples in last hour): tend to get 11 samples, missing recent one, newest sample can be 9 minutes old
               // if you pass 30,0 (all samples in last half hour): tend to get 5 samples, missing recent one, newest sample can be 9 minutes old; optimization not kicking in
               // if you pass 25,0 (all samples in last 25 min): get 5 samples, including most recent; the "optimization" apparently kicks in
               // best realtime query might be for 5,0? But that involves knowing the interval; our API should have a way to get just newest sample without knowing interval.
               // Anyway, note that 0,0, <30,0 and >30,0 are really different queries.
               Calendar start = vcp.queryVcCurrentTime();
               start.add(Calendar.MINUTE, -20);
               Calendar end = null;

               perf = samplesToString(vcp.queryPerformance(refId, PerformanceType.cpuAbs, resolution, 0, start, end));
               System.out.println("   cpu performance samples: " + perf);
               perf = samplesToString(vcp.queryPerformance(refId, PerformanceType.cpuRel, resolution, 0, start, end));
               System.out.println("   cpu performance samples: " + perf);
               perf = samplesToString(vcp.queryPerformance(refId, PerformanceType.memOccupiedAbs, resolution, 0, start, end));
               System.out.println("   mem-occupy performance samples: " + perf);
               perf = samplesToString(vcp.queryPerformance(refId, PerformanceType.memActiveAbs, resolution, 0, start, end));
               System.out.println("   mem-active performance samples: " + perf);
               perf = samplesToString(vcp.queryPerformance(refId, PerformanceType.memActiveRel, resolution, 0, start, end));
               System.out.println("   mem-active performance samples: " + perf);
               perf = samplesToString(vcp.queryPerformance(refId, PerformanceType.netAbs, resolution, 0, start, end));
               System.out.println("   net performance samples: " + perf);
               List<String> ids = new ArrayList<String>();
               ids.add(refId);
               Map<String, PerformanceSample> result = vcp.queryLatestPerformance(ids, PerformanceType.cpuAbs);
               PerformanceSample sample= result.get(refId);
               perf = (sample == null ? "unavailable" : sample.toString());
               System.out.println("   latest cpu sample: " + perf);
            } catch (Exception e) {
               System.out.println("   perf query failed: " + e.getMessage());
            }
         }
View Full Code Here

Examples of com.vmware.aurora.vc.VcPerformance.PerformanceSample

            System.out.println("   last 2 cpu performance samples: " + perf);

            List<String> ids = new ArrayList<String>();
            ids.add(refId);
            Map<String, PerformanceSample> result = vcp.queryLatestPerformance(ids, PerformanceType.cpuAbs);
            PerformanceSample sample= result.get(refId);
            perf = (sample == null ? "unavailable" : sample.toString());
            System.out.println("   'latest' cpu sample: " + perf);

            if (sample.getTimestamp().equals(slice[1].getTimestamp())) {
               // we kept the newest sample
               System.out.println("tie! kept newest sample");
            } else if (slice[1].getSample() == 0 && sample.getSample() != 0) {
               // newest sample is 0, but we didn't use it
               System.out.println("win! avoided invalid 0 sample");
            } else if (slice[1].getSample() != 0 && sample.getTimestamp().equals(slice[0].getTimestamp())) {
               // latest sample is nonzero, and we didn't use it
               System.out.println("fail! had to skip a valid sample");
            } else {
               // logic error
               System.out.println("inconceivable! not sure how to judge that one");
View Full Code Here

Examples of com.vmware.aurora.vc.VcPerformance.PerformanceSample

            for (VcResourcePool rp: getResourcePools(cluster)) {
               String refId = rp.getId();
               List<String> ids = new ArrayList<String>();
               ids.add(refId);
               Map<String, PerformanceSample> result = vcp.queryLatestPerformance(ids, PerformanceType.cpuAbs);
               PerformanceSample sample= result.get(refId);
               if (null == sample) {
                  System.out.println("     FAILED: " + rp);
               }
            }
         }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.