Exemplo n.º 1
0
 /// <summary>
 /// Update data for the metrics. Called immediately before the metrics are scraped.
 /// </summary>
 public void UpdateMetrics()
 {
     foreach (var drive in DriveInfo.GetDrives().Where(x => _driveTypes.Contains(x.DriveType)))
     {
         try
         {
             DiskSpace.WithLabels(drive.Name, drive.DriveFormat).Set(drive.AvailableFreeSpace);
             Size.WithLabels(drive.Name, drive.DriveFormat).Set(drive.TotalSize);
         }
         catch (Exception ex)
         {
             _logger.LogWarning("Could not get information for disk {0}: {1}", drive.Name, ex.Message);
         }
     }
 }