2021-12-18 18:01:29 +00:00
//go:build windows
2020-11-26 11:45:55 +00:00
// +build windows
package collector
import (
2023-03-12 23:32:17 +00:00
"github.com/alecthomas/kingpin/v2"
2023-04-22 10:17:51 +00:00
"github.com/go-kit/log"
"github.com/go-kit/log/level"
2020-11-26 11:45:55 +00:00
"github.com/prometheus/client_golang/prometheus"
)
2023-04-16 09:45:07 +00:00
const (
FlagDfsrEnabledCollectors = "collectors.dfsr.sources-enabled"
)
var dfsrEnabledCollectors * string
2020-11-26 11:45:55 +00:00
2020-12-03 06:59:15 +00:00
// DFSRCollector contains the metric and state data of the DFSR collectors.
type DFSRCollector struct {
2023-04-22 10:17:51 +00:00
logger log . Logger
2020-12-03 06:59:15 +00:00
// Connection source
ConnectionBandwidthSavingsUsingDFSReplicationTotal * prometheus . Desc
ConnectionBytesReceivedTotal * prometheus . Desc
ConnectionCompressedSizeOfFilesReceivedTotal * prometheus . Desc
ConnectionFilesReceivedTotal * prometheus . Desc
ConnectionRDCBytesReceivedTotal * prometheus . Desc
ConnectionRDCCompressedSizeOfFilesReceivedTotal * prometheus . Desc
ConnectionRDCSizeOfFilesReceivedTotal * prometheus . Desc
ConnectionRDCNumberofFilesReceivedTotal * prometheus . Desc
ConnectionSizeOfFilesReceivedTotal * prometheus . Desc
// Folder source
FolderBandwidthSavingsUsingDFSReplicationTotal * prometheus . Desc
FolderCompressedSizeOfFilesReceivedTotal * prometheus . Desc
FolderConflictBytesCleanedupTotal * prometheus . Desc
FolderConflictBytesGeneratedTotal * prometheus . Desc
FolderConflictFilesCleanedUpTotal * prometheus . Desc
FolderConflictFilesGeneratedTotal * prometheus . Desc
FolderConflictFolderCleanupsCompletedTotal * prometheus . Desc
FolderConflictSpaceInUse * prometheus . Desc
FolderDeletedSpaceInUse * prometheus . Desc
FolderDeletedBytesCleanedUpTotal * prometheus . Desc
FolderDeletedBytesGeneratedTotal * prometheus . Desc
FolderDeletedFilesCleanedUpTotal * prometheus . Desc
FolderDeletedFilesGeneratedTotal * prometheus . Desc
FolderFileInstallsRetriedTotal * prometheus . Desc
FolderFileInstallsSucceededTotal * prometheus . Desc
FolderFilesReceivedTotal * prometheus . Desc
FolderRDCBytesReceivedTotal * prometheus . Desc
FolderRDCCompressedSizeOfFilesReceivedTotal * prometheus . Desc
FolderRDCNumberofFilesReceivedTotal * prometheus . Desc
FolderRDCSizeOfFilesReceivedTotal * prometheus . Desc
FolderSizeOfFilesReceivedTotal * prometheus . Desc
FolderStagingSpaceInUse * prometheus . Desc
FolderStagingBytesCleanedUpTotal * prometheus . Desc
FolderStagingBytesGeneratedTotal * prometheus . Desc
FolderStagingFilesCleanedUpTotal * prometheus . Desc
FolderStagingFilesGeneratedTotal * prometheus . Desc
FolderUpdatesDroppedTotal * prometheus . Desc
// Volume source
VolumeDatabaseLookupsTotal * prometheus . Desc
VolumeDatabaseCommitsTotal * prometheus . Desc
VolumeUSNJournalUnreadPercentage * prometheus . Desc
VolumeUSNJournalRecordsAcceptedTotal * prometheus . Desc
VolumeUSNJournalRecordsReadTotal * prometheus . Desc
// Map of child collector functions used during collection
2020-12-09 04:45:26 +00:00
dfsrChildCollectors [ ] dfsrCollectorFunc
2020-11-26 11:45:55 +00:00
}
2020-12-09 04:45:26 +00:00
type dfsrCollectorFunc func ( ctx * ScrapeContext , ch chan <- prometheus . Metric ) error
2020-12-03 06:59:15 +00:00
// Map Perflib sources to DFSR collector names
// E.G. volume -> DFS Replication Service Volumes
func dfsrGetPerfObjectName ( collector string ) string {
prefix := "DFS "
suffix := ""
switch collector {
case "connection" :
suffix = "Replication Connections"
case "folder" :
suffix = "Replicated Folders"
case "volume" :
suffix = "Replication Service Volumes"
}
return ( prefix + suffix )
}
2023-04-16 09:45:07 +00:00
// newDFSRCollectorFlags is registered
func newDFSRCollectorFlags ( app * kingpin . Application ) {
dfsrEnabledCollectors = app . Flag ( FlagDfsrEnabledCollectors , "Comma-seperated list of DFSR Perflib sources to use." ) . Default ( "connection,folder,volume" ) . String ( )
}
2022-12-21 05:44:29 +00:00
// newDFSRCollector is registered
2023-04-22 10:17:51 +00:00
func newDFSRCollector ( logger log . Logger ) ( Collector , error ) {
2020-12-03 06:59:15 +00:00
const subsystem = "dfsr"
2023-04-22 10:17:51 +00:00
logger = log . With ( logger , "collector" , subsystem )
2023-06-08 00:29:50 +00:00
_ = level . Info ( logger ) . Log ( "msg" , "dfsr collector is in an experimental state! Metrics for this collector have not been tested." )
2020-12-03 06:59:15 +00:00
2020-12-03 10:20:28 +00:00
enabled := expandEnabledChildCollectors ( * dfsrEnabledCollectors )
2020-12-03 06:59:15 +00:00
perfCounters := make ( [ ] string , 0 , len ( enabled ) )
for _ , c := range enabled {
perfCounters = append ( perfCounters , dfsrGetPerfObjectName ( c ) )
}
addPerfCounterDependencies ( subsystem , perfCounters )
dfsrCollector := DFSRCollector {
2023-04-22 10:17:51 +00:00
logger : logger ,
2020-12-03 06:59:15 +00:00
// Connection
ConnectionBandwidthSavingsUsingDFSReplicationTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_bandwidth_savings_using_dfs_replication_bytes_total" ) ,
2021-01-28 11:58:18 +00:00
"Total bytes of bandwidth saved using DFS Replication for this connection" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
ConnectionBytesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_bytes_received_total" ) ,
2020-11-26 11:45:55 +00:00
"Total bytes received for connection" ,
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
ConnectionCompressedSizeOfFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_compressed_size_of_files_received_bytes_total" ) ,
2021-01-28 11:58:18 +00:00
"Total compressed size of files received on the connection, in bytes" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
ConnectionFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_received_files_total" ) ,
2021-12-18 18:18:16 +00:00
"Total number of files received for connection" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
ConnectionRDCBytesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_rdc_received_bytes_total" ) ,
2021-01-28 11:58:18 +00:00
"Total bytes received on the connection while replicating files using Remote Differential Compression" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
ConnectionRDCCompressedSizeOfFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_rdc_compressed_size_of_received_files_bytes_total" ) ,
2021-01-28 11:58:18 +00:00
"Total uncompressed size of files received with Remote Differential Compression for connection" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
ConnectionRDCNumberofFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_rdc_received_files_total" ) ,
2021-01-28 11:58:18 +00:00
"Total number of files received using remote differential compression" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
ConnectionRDCSizeOfFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_rdc_size_of_received_files_bytes_total" ) ,
2020-12-09 09:49:32 +00:00
"Total size of received Remote Differential Compression files, in bytes." ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
ConnectionSizeOfFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "connection_files_received_bytes_total" ) ,
2020-12-09 09:49:32 +00:00
"Total size of files received, in bytes" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
// Folder
FolderBandwidthSavingsUsingDFSReplicationTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_bandwidth_savings_using_dfs_replication_bytes_total" ) ,
2021-01-28 11:58:18 +00:00
"Total bytes of bandwidth saved using DFS Replication for this folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderCompressedSizeOfFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_compressed_size_of_received_files_bytes_total" ) ,
2021-01-28 11:58:18 +00:00
"Total compressed size of files received on the folder, in bytes" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderConflictBytesCleanedupTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_conflict_cleaned_up_bytes_total" ) ,
2021-01-28 11:58:18 +00:00
"Total size of conflict loser files and folders deleted from the Conflict and Deleted folder, in bytes" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderConflictBytesGeneratedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_conflict_generated_bytes_total" ) ,
2021-01-28 11:58:18 +00:00
"Total size of conflict loser files and folders moved to the Conflict and Deleted folder, in bytes" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderConflictFilesCleanedUpTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_conflict_cleaned_up_files_total" ) ,
2021-01-28 11:58:18 +00:00
"Number of conflict loser files deleted from the Conflict and Deleted folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderConflictFilesGeneratedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_conflict_generated_files_total" ) ,
2021-01-28 11:58:18 +00:00
"Number of files and folders moved to the Conflict and Deleted folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderConflictFolderCleanupsCompletedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_conflict_folder_cleanups_total" ) ,
2021-01-28 11:58:18 +00:00
"Number of deletions of conflict loser files and folders in the Conflict and Deleted" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderConflictSpaceInUse : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_conflict_space_in_use_bytes" ) ,
2021-01-28 11:58:18 +00:00
"Total size of the conflict loser files and folders currently in the Conflict and Deleted folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderDeletedSpaceInUse : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_deleted_space_in_use_bytes" ) ,
"Total size (in bytes) of the deleted files and folders currently in the Conflict and Deleted folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderDeletedBytesCleanedUpTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_deleted_cleaned_up_bytes_total" ) ,
"Total size (in bytes) of replicating deleted files and folders that were cleaned up from the Conflict and Deleted folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderDeletedBytesGeneratedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_deleted_generated_bytes_total" ) ,
"Total size (in bytes) of replicated deleted files and folders that were moved to the Conflict and Deleted folder after they were deleted from a replicated folder on a sending member" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderDeletedFilesCleanedUpTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_deleted_cleaned_up_files_total" ) ,
"Number of files and folders that were cleaned up from the Conflict and Deleted folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderDeletedFilesGeneratedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_deleted_generated_files_total" ) ,
"Number of deleted files and folders that were moved to the Conflict and Deleted folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderFileInstallsRetriedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_file_installs_retried_total" ) ,
"Total number of file installs that are being retried due to sharing violations or other errors encountered when installing the files" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderFileInstallsSucceededTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_file_installs_succeeded_total" ) ,
"Total number of files that were successfully received from sending members and installed locally on this server" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_received_files_total" ) ,
"Total number of files received" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderRDCBytesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_rdc_received_bytes_total" ) ,
"Total number of bytes received in replicating files using Remote Differential Compression" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderRDCCompressedSizeOfFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_rdc_compressed_size_of_received_files_bytes_total" ) ,
"Total compressed size (in bytes) of the files received with Remote Differential Compression" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderRDCNumberofFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_rdc_received_files_total" ) ,
"Total number of files received with Remote Differential Compression" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderRDCSizeOfFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_rdc_files_received_bytes_total" ) ,
"Total uncompressed size (in bytes) of the files received with Remote Differential Compression" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderSizeOfFilesReceivedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_files_received_bytes_total" ) ,
"Total uncompressed size (in bytes) of the files received" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderStagingSpaceInUse : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_staging_space_in_use_bytes" ) ,
"Total size of files and folders currently in the staging folder." ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderStagingBytesCleanedUpTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_staging_cleaned_up_bytes_total" ) ,
"Total size (in bytes) of the files and folders that have been cleaned up from the staging folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderStagingBytesGeneratedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_staging_generated_bytes_total" ) ,
"Total size (in bytes) of replicated files and folders in the staging folder created by the DFS Replication service since last restart" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderStagingFilesCleanedUpTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_staging_cleaned_up_files_total" ) ,
"Total number of files and folders that have been cleaned up from the staging folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderStagingFilesGeneratedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_staging_generated_files_total" ) ,
"Total number of times replicated files and folders have been staged by the DFS Replication service" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
FolderUpdatesDroppedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "folder_dropped_updates_total" ) ,
"Total number of redundant file replication update records that have been ignored by the DFS Replication service because they did not change the replicated file or folder" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
// Volume
VolumeDatabaseCommitsTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "volume_database_commits_total" ) ,
2020-12-03 06:59:15 +00:00
"Total number of DFSR Volume database commits" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
VolumeDatabaseLookupsTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "volume_database_lookups_total" ) ,
2020-12-03 06:59:15 +00:00
"Total number of DFSR Volume database lookups" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
VolumeUSNJournalUnreadPercentage : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "volume_usn_journal_unread_percentage" ) ,
2020-12-03 06:59:15 +00:00
"Percentage of DFSR Volume USN journal records that are unread" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
VolumeUSNJournalRecordsAcceptedTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "volume_usn_journal_accepted_records_total" ) ,
2020-12-03 06:59:15 +00:00
"Total number of USN journal records accepted" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
VolumeUSNJournalRecordsReadTotal : prometheus . NewDesc (
2021-02-03 11:07:54 +00:00
prometheus . BuildFQName ( Namespace , subsystem , "volume_usn_journal_read_records_total" ) ,
2020-12-03 06:59:15 +00:00
"Total number of DFSR Volume USN journal records read" ,
2020-11-26 11:45:55 +00:00
[ ] string { "name" } ,
nil ,
) ,
2020-12-03 06:59:15 +00:00
}
2020-12-09 04:45:26 +00:00
dfsrCollector . dfsrChildCollectors = dfsrCollector . getDFSRChildCollectors ( enabled )
2020-12-03 06:59:15 +00:00
return & dfsrCollector , nil
}
2020-12-09 04:45:26 +00:00
// Maps enabled child collectors names to their relevant collection function,
2020-12-03 06:59:15 +00:00
// for use in DFSRCollector.Collect()
2020-12-09 04:45:26 +00:00
func ( c * DFSRCollector ) getDFSRChildCollectors ( enabledCollectors [ ] string ) [ ] dfsrCollectorFunc {
var dfsrCollectors [ ] dfsrCollectorFunc
for _ , collector := range enabledCollectors {
switch collector {
case "connection" :
dfsrCollectors = append ( dfsrCollectors , c . collectConnection )
case "folder" :
dfsrCollectors = append ( dfsrCollectors , c . collectFolder )
case "volume" :
dfsrCollectors = append ( dfsrCollectors , c . collectVolume )
}
}
2020-12-03 06:59:15 +00:00
return dfsrCollectors
2020-11-26 11:45:55 +00:00
}
2020-12-03 06:59:15 +00:00
// Collect implements the Collector interface.
// Sends metric values for each metric to the provided prometheus Metric channel.
func ( c * DFSRCollector ) Collect ( ctx * ScrapeContext , ch chan <- prometheus . Metric ) error {
2020-12-09 04:45:26 +00:00
for _ , fn := range c . dfsrChildCollectors {
err := fn ( ctx , ch )
if err != nil {
return err
}
2020-11-26 11:45:55 +00:00
}
return nil
}
2020-12-03 06:59:15 +00:00
// Perflib: "DFS Replication Service Connections"
type PerflibDFSRConnection struct {
Name string
BandwidthSavingsUsingDFSReplicationTotal float64 ` perflib:"Bandwidth Savings Using DFS Replication" `
BytesReceivedTotal float64 ` perflib:"Total Bytes Received" `
CompressedSizeOfFilesReceivedTotal float64 ` perflib:"Compressed Size of Files Received" `
FilesReceivedTotal float64 ` perflib:"Total Files Received" `
RDCBytesReceivedTotal float64 ` perflib:"RDC Bytes Received" `
RDCCompressedSizeOfFilesReceivedTotal float64 ` perflib:"RDC Compressed Size of Files Received" `
RDCNumberofFilesReceivedTotal float64 ` perflib:"RDC Number of Files Received" `
RDCSizeOfFilesReceivedTotal float64 ` perflib:"RDC Size of Files Received" `
SizeOfFilesReceivedTotal float64 ` perflib:"Size of Files Received" `
}
2020-12-09 04:45:26 +00:00
func ( c * DFSRCollector ) collectConnection ( ctx * ScrapeContext , ch chan <- prometheus . Metric ) error {
2020-12-03 06:59:15 +00:00
var dst [ ] PerflibDFSRConnection
2023-04-22 10:17:51 +00:00
if err := unmarshalObject ( ctx . perfObjects [ "DFS Replication Connections" ] , & dst , c . logger ) ; err != nil {
2020-12-09 04:45:26 +00:00
return err
2020-12-03 06:59:15 +00:00
}
for _ , connection := range dst {
ch <- prometheus . MustNewConstMetric (
c . ConnectionBandwidthSavingsUsingDFSReplicationTotal ,
prometheus . CounterValue ,
connection . BandwidthSavingsUsingDFSReplicationTotal ,
connection . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . ConnectionBytesReceivedTotal ,
prometheus . CounterValue ,
connection . BytesReceivedTotal ,
connection . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . ConnectionCompressedSizeOfFilesReceivedTotal ,
prometheus . CounterValue ,
connection . CompressedSizeOfFilesReceivedTotal ,
connection . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . ConnectionFilesReceivedTotal ,
prometheus . CounterValue ,
connection . FilesReceivedTotal ,
connection . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . ConnectionRDCBytesReceivedTotal ,
prometheus . CounterValue ,
connection . RDCBytesReceivedTotal ,
connection . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . ConnectionRDCCompressedSizeOfFilesReceivedTotal ,
prometheus . CounterValue ,
connection . RDCCompressedSizeOfFilesReceivedTotal ,
connection . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . ConnectionRDCSizeOfFilesReceivedTotal ,
prometheus . CounterValue ,
connection . RDCSizeOfFilesReceivedTotal ,
connection . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . ConnectionRDCNumberofFilesReceivedTotal ,
prometheus . CounterValue ,
connection . RDCNumberofFilesReceivedTotal ,
connection . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . ConnectionSizeOfFilesReceivedTotal ,
prometheus . CounterValue ,
connection . SizeOfFilesReceivedTotal ,
connection . Name ,
)
}
2020-12-09 04:45:26 +00:00
return nil
2020-12-03 06:59:15 +00:00
}
2020-11-26 11:45:55 +00:00
// Perflib: "DFS Replicated Folder"
type PerflibDFSRFolder struct {
Name string
BandwidthSavingsUsingDFSReplicationTotal float64 ` perflib:"Bandwidth Savings Using DFS Replication" `
CompressedSizeOfFilesReceivedTotal float64 ` perflib:"Compressed Size of Files Received" `
ConflictBytesCleanedupTotal float64 ` perflib:"Conflict Bytes Cleaned Up" `
ConflictBytesGeneratedTotal float64 ` perflib:"Conflict Bytes Generated" `
ConflictFilesCleanedUpTotal float64 ` perflib:"Conflict Files Cleaned Up" `
ConflictFilesGeneratedTotal float64 ` perflib:"Conflict Files Generated" `
ConflictFolderCleanupsCompletedTotal float64 ` perflib:"Conflict Folder Cleanups Completed" `
ConflictSpaceInUse float64 ` perflib:"Conflict Space In Use" `
DeletedSpaceInUse float64 ` perflib:"Deleted Space In Use" `
DeletedBytesCleanedUpTotal float64 ` perflib:"Deleted Bytes Cleaned Up" `
DeletedBytesGeneratedTotal float64 ` perflib:"Deleted Bytes Generated" `
DeletedFilesCleanedUpTotal float64 ` perflib:"Deleted Files Cleaned Up" `
DeletedFilesGeneratedTotal float64 ` perflib:"Deleted Files Generated" `
FileInstallsRetriedTotal float64 ` perflib:"File Installs Retried" `
FileInstallsSucceededTotal float64 ` perflib:"File Installs Succeeded" `
FilesReceivedTotal float64 ` perflib:"Total Files Received" `
RDCBytesReceivedTotal float64 ` perflib:"RDC Bytes Received" `
RDCCompressedSizeOfFilesReceivedTotal float64 ` perflib:"RDC Compressed Size of Files Received" `
RDCNumberofFilesReceivedTotal float64 ` perflib:"RDC Number of Files Received" `
RDCSizeOfFilesReceivedTotal float64 ` perflib:"RDC Size of Files Received" `
SizeOfFilesReceivedTotal float64 ` perflib:"Size of Files Received" `
StagingSpaceInUse float64 ` perflib:"Staging Space In Use" `
StagingBytesCleanedUpTotal float64 ` perflib:"Staging Bytes Cleaned Up" `
StagingBytesGeneratedTotal float64 ` perflib:"Staging Bytes Generated" `
StagingFilesCleanedUpTotal float64 ` perflib:"Staging Files Cleaned Up" `
StagingFilesGeneratedTotal float64 ` perflib:"Staging Files Generated" `
UpdatesDroppedTotal float64 ` perflib:"Updates Dropped" `
}
2020-12-09 04:45:26 +00:00
func ( c * DFSRCollector ) collectFolder ( ctx * ScrapeContext , ch chan <- prometheus . Metric ) error {
2020-11-26 11:45:55 +00:00
var dst [ ] PerflibDFSRFolder
2023-04-22 10:17:51 +00:00
if err := unmarshalObject ( ctx . perfObjects [ "DFS Replicated Folders" ] , & dst , c . logger ) ; err != nil {
2020-12-09 04:45:26 +00:00
return err
2020-11-26 11:45:55 +00:00
}
for _ , folder := range dst {
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderBandwidthSavingsUsingDFSReplicationTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . BandwidthSavingsUsingDFSReplicationTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderCompressedSizeOfFilesReceivedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . CompressedSizeOfFilesReceivedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderConflictBytesCleanedupTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . ConflictBytesCleanedupTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderConflictBytesGeneratedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . ConflictBytesGeneratedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderConflictFilesCleanedUpTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . ConflictFilesCleanedUpTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderConflictFilesGeneratedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . ConflictFilesGeneratedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderConflictFolderCleanupsCompletedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . ConflictFolderCleanupsCompletedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderConflictSpaceInUse ,
2020-11-26 11:45:55 +00:00
prometheus . GaugeValue ,
folder . ConflictSpaceInUse ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderDeletedSpaceInUse ,
2020-11-26 11:45:55 +00:00
prometheus . GaugeValue ,
folder . DeletedSpaceInUse ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderDeletedBytesCleanedUpTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . DeletedBytesCleanedUpTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderDeletedBytesGeneratedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . DeletedBytesGeneratedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderDeletedFilesCleanedUpTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . DeletedFilesCleanedUpTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderDeletedFilesGeneratedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . DeletedFilesGeneratedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderFileInstallsRetriedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . FileInstallsRetriedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderFileInstallsSucceededTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . FileInstallsSucceededTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderFilesReceivedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . FilesReceivedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderRDCBytesReceivedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . RDCBytesReceivedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderRDCCompressedSizeOfFilesReceivedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . RDCCompressedSizeOfFilesReceivedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderRDCNumberofFilesReceivedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . RDCNumberofFilesReceivedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderRDCSizeOfFilesReceivedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . RDCSizeOfFilesReceivedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderSizeOfFilesReceivedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . SizeOfFilesReceivedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderStagingSpaceInUse ,
2020-11-26 11:45:55 +00:00
prometheus . GaugeValue ,
folder . StagingSpaceInUse ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderStagingBytesCleanedUpTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . StagingBytesCleanedUpTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderStagingBytesGeneratedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . StagingBytesGeneratedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderStagingFilesCleanedUpTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . StagingFilesCleanedUpTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderStagingFilesGeneratedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . StagingFilesGeneratedTotal ,
folder . Name ,
)
ch <- prometheus . MustNewConstMetric (
2020-12-03 06:59:15 +00:00
c . FolderUpdatesDroppedTotal ,
2020-11-26 11:45:55 +00:00
prometheus . CounterValue ,
folder . UpdatesDroppedTotal ,
folder . Name ,
)
}
2020-12-09 04:45:26 +00:00
return nil
2020-11-26 11:45:55 +00:00
}
2020-12-03 06:59:15 +00:00
// Perflib: "DFS Replication Service Volumes"
type PerflibDFSRVolume struct {
Name string
DatabaseCommitsTotal float64 ` perflib:"Database Commits" `
DatabaseLookupsTotal float64 ` perflib:"Database Lookups" `
USNJournalRecordsReadTotal float64 ` perflib:"USN Journal Records Read" `
USNJournalRecordsAcceptedTotal float64 ` perflib:"USN Journal Records Accepted" `
USNJournalUnreadPercentage float64 ` perflib:"USN Journal Records Unread Percentage" `
}
2020-12-09 04:45:26 +00:00
func ( c * DFSRCollector ) collectVolume ( ctx * ScrapeContext , ch chan <- prometheus . Metric ) error {
2020-12-03 06:59:15 +00:00
var dst [ ] PerflibDFSRVolume
2023-04-22 10:17:51 +00:00
if err := unmarshalObject ( ctx . perfObjects [ "DFS Replication Service Volumes" ] , & dst , c . logger ) ; err != nil {
2020-12-09 04:45:26 +00:00
return err
2020-12-03 06:59:15 +00:00
}
for _ , volume := range dst {
ch <- prometheus . MustNewConstMetric (
c . VolumeDatabaseLookupsTotal ,
prometheus . CounterValue ,
volume . DatabaseLookupsTotal ,
volume . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . VolumeDatabaseCommitsTotal ,
prometheus . CounterValue ,
volume . DatabaseCommitsTotal ,
volume . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . VolumeUSNJournalRecordsAcceptedTotal ,
prometheus . CounterValue ,
volume . USNJournalRecordsAcceptedTotal ,
volume . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . VolumeUSNJournalRecordsReadTotal ,
prometheus . CounterValue ,
volume . USNJournalRecordsReadTotal ,
volume . Name ,
)
ch <- prometheus . MustNewConstMetric (
c . VolumeUSNJournalUnreadPercentage ,
prometheus . GaugeValue ,
volume . USNJournalUnreadPercentage ,
volume . Name ,
)
}
2020-12-09 04:45:26 +00:00
return nil
2020-12-03 06:59:15 +00:00
}