0

私はクラウド監視アプリケーションのコーディングを行っていますが、AZURE php SDK ドキュメント (CPU 使用率、ディスク使用率、RAM 使用率など) からパフォーマンス カウンターを取得するための有用なロジックを見つけることができませんでした。

誰か助けてくれませんか??

define('PRODUCTION_SITE', false); // Controls connections to cloud or local storage 
define('AZURE_STORAGE_KEY', '<your_storage_key>'); 
define('AZURE_SERVICE', '<your_domain_extension>'); 
define('ROLE_ID', $_SERVER['RoleDeploymentID'] . '/' . $_SERVER['RoleName'] . '/' . $_SERVER['RoleInstanceID']); 
define('PERF_IN_SEC', 30); // How many seconds between times dumping performance metrics to table storage

/** Microsoft_WindowsAzure_Storage_Blob */
require_once 'Microsoft/WindowsAzure/Storage/Blob.php';

/** Microsoft_WindowsAzure_Diagnostics_Manager **/
require_once 'Microsoft/WindowsAzure/Diagnostics/Manager.php'; 
/** Microsoft_WindowsAzure_Storage_Table */
require_once 'Microsoft/WindowsAzure/Storage/Table.php';

if(PRODUCTION_SITE) { 
  $blob = new Microsoft_WindowsAzure_Storage_Blob( 
    'blob.core.windows.net', 
    AZURE_SERVICE, 
    AZURE_STORAGE_KEY 
  ); 
  $table = new Microsoft_WindowsAzure_Storage_Table( 
    'table.core.windows.net', 
    AZURE_SERVICE, 
    AZURE_STORAGE_KEY 
  ); 
} else { 
// Connect to local Storage Emulator 
    $blob = new Microsoft_WindowsAzure_Storage_Blob(); 
    $table = new Microsoft_WindowsAzure_Storage_Table(); 
}

$manager = new Microsoft_WindowsAzure_Diagnostics_Manager($blob);

//////////////////////////////

// Bring in global include file
require_once('setup.php');

// Performance counters to subscribe to
$counters = array(
    '\Processor(_Total)\% Processor Time',
    '\TCPv4\Connections Established',
);

// Retrieve the current configuration information for the running role
$configuration = $manager->getConfigurationForRoleInstance(ROLE_ID);

// Add each subscription counter to the configuration
foreach($counters as $c) {
    $configuration->DataSources->PerformanceCounters->addSubscription($c, PERF_IN_SEC);
}

// These settings are required by the diagnostics manager to know when to transfer the metrics to the storage table
$configuration->DataSources->OverallQuotaInMB = 10;
$configuration->DataSources->PerformanceCounters->BufferQuotaInMB = 10;
$configuration->DataSources->PerformanceCounters->ScheduledTransferPeriodInMinutes = 1;

// Update the configuration for the current running role
$manager->setConfigurationForRoleInstance(ROLE_ID,$configuration);

 ///////////////////////////////////////

 // Bring in global include file 
//require_once('setup.php'); 

// Grab all entities from the metrics table 
$metrics = $table->retrieveEntities('WADPerformanceCountersTable'); 

// Loop through metric entities and display results 
foreach($metrics AS $m) { 
    echo $m->RoleInstance . " - " . $m->CounterName . ": " . $m->CounterValue . "<br/>"; 
}

これは、プロセッサ情報を抽出するために作成したコードです...

4

2 に答える 2

0

Storage Analytics Metrics は、ストレージ アカウントのトランザクション データと容量データを集計します。Blob、Table、および Queue サービスのトランザクション メトリックが記録されます。現在、キャパシティ メトリックは BLOB サービスに対してのみ記録されます。トランザクション データと容量データは、次のテーブルに格納されます。

$MetricsCapacityBlob

$MetricsTransactionsBlob

$MetricsTransactionsTable

$MetricsTransactionsQueue

ListTables メソッドなどのリスト操作が実行された場合、上記のテーブルは表示されません。各テーブルには直接アクセスする必要があります。

メトリックを取得するときは、これらのテーブルを使用します。
元:

$metrics = $table->retrieveEntities('$MetricsCapacityBlob');


URL: http://msdn.microsoft.com/en-us/library/windowsazure/hh343264.aspx

于 2013-10-22T04:28:52.517 に答える