WARNING: THIS SITE IS A MIRROR OF GITHUB.COM / IT CANNOT LOGIN OR REGISTER ACCOUNTS / THE CONTENTS ARE PROVIDED AS-IS / THIS SITE ASSUMES NO RESPONSIBILITY FOR ANY DISPLAYED CONTENT OR LINKS / IF YOU FOUND SOMETHING MAY NOT GOOD FOR EVERYONE, CONTACT ADMIN AT ilovescratch@foxmail.com
Skip to content
This repository was archived by the owner on Jul 9, 2024. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ Help is displayed with `-h`.
| -profile | `false` | When profiling reports in gluster are enabled, set ' -profile true' to get more metrics
| -version | - | Prints version information
| -volumes | `_all` | Comma separated volume names: vol1,vol2,vol3. Default is '_all' to scrape all metrics
| -quota | `false` | When quota in gluster are enabled, set '-quota' to get more metrics
| -no-heal-scrape | `false` | The exporter will not get metrics about healing files



## Make
Expand All @@ -40,8 +43,8 @@ docker: build and run in docker container
**docker**: runs docker build and copys new builded gluster_exporter


## Relevant Gluster Metrics
Commands within the exporter are executed with `--xml`.
## Relevant Gluster Metrics
Commands within the exporter are executed with `--xml`.

### Command: `gluster volume info`

Expand Down Expand Up @@ -78,7 +81,7 @@ with `gluster volume info` this is obsolete
| volProfile.cumulativeStatus.duration | Count | implemented |
| volProfile.cumulativeStatus.totalRead | Count | implemented |
| volProfile.cumulativeStatus.totalWrite | Count | implemented |
| volProfile.cumulativeStats.fopStats.fop.Name | WRITE, STATFS, FLUSH, OPENDIR, CREATE, LOOKUP, READDIR, FINODELK, ENTRYLK, FXATTROP | pending |
| volProfile.cumulativeStats.fopStats.fop.Name | WRITE, STATFS, FLUSH, OPENDIR, CREATE, LOOKUP, READDIR, FINODELK, ENTRYLK, FXATTROP | pending |
| volProfile.cumulativeStats.fopStats.fop.hits | count | implemented |
| volProfile.cumulativeStats.fopStats.fop.avgLatency | Gauge | implemented |
| volProfile.cumulativeStats.fopStats.fop.minLatency | Gauge | implemented |
Expand Down
21 changes: 13 additions & 8 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ type Exporter struct {
volumes []string
profile bool
quota bool
noHeal bool
}

// Describe all the metrics exported by Gluster exporter. It implements prometheus.Collector.
Expand Down Expand Up @@ -327,12 +328,14 @@ func (e *Exporter) Collect(ch chan<- prometheus.Metric) {
vols = volumeList.Volume
}

for _, vol := range vols {
filesCount, volumeHealErr := ExecVolumeHealInfo(vol)
if volumeHealErr == nil {
ch <- prometheus.MustNewConstMetric(
healInfoFilesCount, prometheus.CounterValue, float64(filesCount), vol,
)
if !e.noHeal {
for _, vol := range vols {
filesCount, volumeHealErr := ExecVolumeHealInfo(vol)
if volumeHealErr == nil {
ch <- prometheus.MustNewConstMetric(
healInfoFilesCount, prometheus.CounterValue, float64(filesCount), vol,
)
}
}
}

Expand Down Expand Up @@ -473,7 +476,7 @@ func ContainsVolume(slice []string, element string) bool {
}

// NewExporter initialises exporter
func NewExporter(hostname, glusterExecPath, volumesString string, profile bool, quota bool) (*Exporter, error) {
func NewExporter(hostname, glusterExecPath, volumesString string, profile bool, quota bool, noHeal bool) (*Exporter, error) {
if len(glusterExecPath) < 1 {
log.Fatalf("Gluster executable path is wrong: %v", glusterExecPath)
}
Expand All @@ -488,6 +491,7 @@ func NewExporter(hostname, glusterExecPath, volumesString string, profile bool,
volumes: volumes,
profile: profile,
quota: quota,
noHeal: noHeal,
}, nil
}

Expand All @@ -511,6 +515,7 @@ func main() {
glusterVolumes = flag.String("volumes", allVolumes, fmt.Sprintf("Comma separated volume names: vol1,vol2,vol3. Default is '%v' to scrape all metrics", allVolumes))
profile = flag.Bool("profile", false, "When profiling reports in gluster are enabled, set ' -profile true' to get more metrics")
quota = flag.Bool("quota", false, "When quota in gluster are enabled, set ' -quota true' to get more metrics")
noHeal = flag.Bool("no-heal-scrape", false, "Do not scrape heal info")
)
flag.Parse()

Expand All @@ -522,7 +527,7 @@ func main() {
if err != nil {
log.Fatalf("While trying to get Hostname error happened: %v", err)
}
exporter, err := NewExporter(hostname, *glusterPath, *glusterVolumes, *profile, *quota)
exporter, err := NewExporter(hostname, *glusterPath, *glusterVolumes, *profile, *quota, *noHeal)
if err != nil {
log.Errorf("Creating new Exporter went wrong, ... \n%v", err)
}
Expand Down