Changeset 12051 in vbox
- Timestamp:
- Sep 3, 2008 2:00:55 PM (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Frontends/VBoxManage/VBoxManage.cpp
r12025 r12051 659 659 if (u64Cmd & USAGE_METRICS) 660 660 { 661 RTPrintf("VBoxManage metrics list [*|host|<vmname> [<metric_list>]] (comma-separated) |\n" 662 " setup <period> <count> [*|host|<vmname> [<metric_list>]] |\n" 663 " query [*|host|<vmname> [<metric_list>]]\n" 661 RTPrintf("VBoxManage metrics list [*|host|<vmname> [<metric_list>]] (comma-separated)\n" 662 "VBoxManage metrics setup\n" 663 " [-period <seconds>]\n" 664 " [-samples <count>]\n" 665 " [*|host|<vmname> [<metric_list>]]\n" 666 "VBoxManage metrics query [*|host|<vmname> [<metric_list>]]\n" 667 "VBoxManage metrics collect\n" 668 " [-period <seconds>]\n" 669 " [-samples <count>]\n" 670 " [-list]\n" 671 " [-detach]\n" 672 " [*|host|<vmname> [<metric_list>]]\n" 664 673 "\n"); 665 674 } … … 7704 7713 } 7705 7714 7715 static int countMatchingMetrics(ComPtr<IVirtualBox> aVirtualBox, 7716 ComPtr<IPerformanceCollector> performanceCollector, 7717 ComSafeArrayIn(INPTR BSTR, metrics), 7718 ComSafeArrayIn(IUnknown *, objects), 7719 bool listMatches) 7720 { 7721 HRESULT rc; 7722 com::SafeIfaceArray<IPerformanceMetric> metricInfo; 7723 7724 CHECK_ERROR(performanceCollector, 7725 GetMetrics(ComSafeArrayInArg(metrics), 7726 ComSafeArrayInArg(objects), 7727 ComSafeArrayAsOutParam(metricInfo))); 7728 7729 if (metricInfo.size()) 7730 { 7731 if (listMatches) 7732 { 7733 ComPtr<IUnknown> object; 7734 Bstr metricName; 7735 RTPrintf("The following metrics will be collected:\n\n" 7736 "Object Metric\n" 7737 "---------- --------------------\n"); 7738 for (size_t i = 0; i < metricInfo.size(); i++) 7739 { 7740 CHECK_ERROR(metricInfo[i], COMGETTER(Object)(object.asOutParam())); 7741 CHECK_ERROR(metricInfo[i], COMGETTER(MetricName)(metricName.asOutParam())); 7742 RTPrintf("%-10ls %-20ls\n", 7743 getObjectName(aVirtualBox, object).raw(), metricName.raw()); 7744 } 7745 RTPrintf("\n"); 7746 } 7747 } 7748 else 7749 { 7750 RTPrintf("No metrics match the specified filter!\n"); 7751 } 7752 return metricInfo.size(); 7753 } 7754 7706 7755 /********************************************************************* 7707 7756 * list * … … 7766 7815 com::SafeArray<BSTR> baseMetrics; 7767 7816 com::SafeIfaceArray<IUnknown> objects; 7768 7769 if (argc < 3) 7770 return errorSyntax(USAGE_METRICS, "Missing parameters for '%s' subcommand", argv[0]); 7771 7772 ULONG period, count; 7773 char *endptr = NULL; 7774 7775 period = strtoul (argv[1], &endptr, 10); 7776 if (!endptr || *endptr) 7777 return errorArgument("Invalid value for 'period' parameter: '%s'", argv[1]); 7778 7779 count = strtoul (argv[2], &endptr, 10); 7780 if (!endptr || *endptr) 7781 return errorArgument("Invalid value for 'count' parameter: '%s'", argv[2]); 7782 7783 rc = parseFilterParameters(argc - 3, &argv[3], aVirtualBox, 7817 ULONG period, samples; 7818 bool listMatches = false; 7819 int i; 7820 7821 for (i = 1; i < argc; i++) 7822 { 7823 if (strcmp(argv[i], "-period") == 0) 7824 { 7825 if (argc <= i + 1) 7826 return errorArgument("Missing argument to '%s'", argv[i]); 7827 char *endptr = NULL; 7828 period = strtoul (argv[++i], &endptr, 10); 7829 if (!endptr || *endptr || !period) 7830 return errorArgument("Invalid value for 'period' parameter: '%s'", argv[i]); 7831 } 7832 else if (strcmp(argv[i], "-samples") == 0) 7833 { 7834 if (argc <= i + 1) 7835 return errorArgument("Missing argument to '%s'", argv[i]); 7836 char *endptr = NULL; 7837 samples = strtoul (argv[++i], &endptr, 10); 7838 if (!endptr || *endptr || !samples) 7839 return errorArgument("Invalid value for 'samples' parameter: '%s'", argv[i]); 7840 } 7841 else 7842 break; /* The rest of params should define the filter */ 7843 /*else if (strcmp(argv[i], "-list") == 0) 7844 listMatches = true;*/ 7845 } 7846 7847 rc = parseFilterParameters(argc - i, &argv[i], aVirtualBox, 7784 7848 ComSafeArrayAsOutParam(metrics), 7785 7849 ComSafeArrayAsOutParam(baseMetrics), … … 7788 7852 return 1; 7789 7853 7854 /* if (countMatchingMetrics(aVirtualBox, performanceCollector, 7855 ComSafeArrayAsInParam(metrics), 7856 ComSafeArrayAsInParam(objects), 7857 listMatches) == 0) 7858 return 1;*/ 7859 7790 7860 CHECK_ERROR(performanceCollector, 7791 7861 SetupMetrics(ComSafeArrayAsInParam(metrics), 7792 ComSafeArrayAsInParam(objects), period, count));7862 ComSafeArrayAsInParam(objects), period, samples)); 7793 7863 7794 7864 return 0; … … 7893 7963 com::SafeArray<BSTR> baseMetrics; 7894 7964 com::SafeIfaceArray<IUnknown> objects; 7895 ULONG period = 0, samples = 0;7965 ULONG period = 1, samples = 1; 7896 7966 bool isDetached = false, listMatches = false; 7897 7967 int i; … … 7913 7983 char *endptr = NULL; 7914 7984 samples = strtoul (argv[++i], &endptr, 10); 7915 if (!endptr || *endptr )7916 return errorArgument("Invalid value for ' period' parameter: '%s'", argv[i]);7985 if (!endptr || *endptr || !samples) 7986 return errorArgument("Invalid value for 'samples' parameter: '%s'", argv[i]); 7917 7987 } 7918 7988 else if (strcmp(argv[i], "-list") == 0) … … 7924 7994 } 7925 7995 7926 if (period == 0)7927 return errorSyntax(USAGE_METRICS, "Parameter -period is required");7928 7929 7996 rc = parseFilterParameters(argc - i, &argv[i], aVirtualBox, 7930 7997 ComSafeArrayAsOutParam(metrics), … … 7934 8001 return 1; 7935 8002 7936 com::SafeIfaceArray<IPerformanceMetric> metricInfo; 7937 7938 CHECK_ERROR(performanceCollector, 7939 GetMetrics(ComSafeArrayAsInParam(metrics), 7940 ComSafeArrayAsInParam(objects), 7941 ComSafeArrayAsOutParam(metricInfo))); 7942 7943 if (metricInfo.size()) 7944 { 7945 if (listMatches) 7946 { 7947 ComPtr<IUnknown> object; 7948 Bstr metricName; 7949 RTPrintf("The following metrics will be collected:\n\n" 7950 "Object Metric\n" 7951 "---------- --------------------\n"); 7952 for (size_t i = 0; i < metricInfo.size(); i++) 7953 { 7954 CHECK_ERROR(metricInfo[i], COMGETTER(Object)(object.asOutParam())); 7955 CHECK_ERROR(metricInfo[i], COMGETTER(MetricName)(metricName.asOutParam())); 7956 RTPrintf("%-10ls %-20ls\n", 7957 getObjectName(aVirtualBox, object).raw(), metricName.raw()); 7958 } 7959 RTPrintf("\n"); 7960 } 7961 } 7962 else 7963 { 7964 RTPrintf("No metrics match the specified filter!\n"); 8003 8004 if (countMatchingMetrics(aVirtualBox, performanceCollector, 8005 ComSafeArrayAsInParam(metrics), 8006 ComSafeArrayAsInParam(objects), 8007 listMatches) == 0) 7965 8008 return 1; 7966 }7967 8009 7968 8010 CHECK_ERROR(performanceCollector, 7969 8011 SetupMetrics(ComSafeArrayAsInParam(baseMetrics), 7970 ComSafeArrayAsInParam(objects), period, isDetached?samples:1));8012 ComSafeArrayAsInParam(objects), period, samples)); 7971 8013 7972 8014 if (isDetached) … … 7979 8021 RTPrintf("Time stamp Object Metric Value\n"); 7980 8022 7981 for ( unsigned n = 0; n < samples || samples == 0; n++)8023 for (;;) 7982 8024 { 7983 8025 RTPrintf("------------ ---------- -------------------- --------------------\n");
Note:
See TracChangeset
for help on using the changeset viewer.