Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

crash on TS-264 #3

Open
McSim85 opened this issue Oct 19, 2023 · 2 comments · May be fixed by #4
Open

crash on TS-264 #3

McSim85 opened this issue Oct 19, 2023 · 2 comments · May be fixed by #4

Comments

@McSim85
Copy link

McSim85 commented Oct 19, 2023

Hey hey,

Thanks for developing such a nice exporter.
It seems like the exporter crashes when I open the page http://192.168.88.23:9094/metrics

./qnapexporter
2023/10/19 09:28:52 Listening to HTTP requests at :9094
2023/10/19 09:29:00 Reading environment...
2023/10/19 09:29:00 Hostname: MEDIA, err=<nil>
2023/10/19 09:29:00 Retrieving QTS version
2023/10/19 09:29:00 Retrieved getsysinfo path: "/sbin/getsysinfo"
2023/10/19 09:29:00 Retrieved sysdhnum: 4
2023/10/19 09:29:00 Retrieved sysfannum: 1
2023/10/19 09:29:00 Retrieved volCount: 4
2023/10/19 09:29:00 Retrieved vol_desc "[Volume SSD, Pool 1]", parsed to "SSD"
2023/10/19 09:29:00 Retrieved volume "SSD" vol_fs "EXT4"
2023/10/19 09:29:00 Retrieved volume "SSD" vol_totalsize "532.82 GB"
2023/10/19 09:29:00 Retrieved volume "SSD" vol_status "Ready"
2023/10/19 09:29:00 Retrieved vol_desc "[Volume backups, Pool 2]", parsed to "backups"
2023/10/19 09:29:01 Retrieved volume "backups" vol_fs "EXT4"
2023/10/19 09:29:01 Retrieved volume "backups" vol_totalsize "990.60 GB"
2023/10/19 09:29:01 Retrieved volume "backups" vol_status "Ready"
2023/10/19 09:29:01 Retrieved vol_desc "[Volume Volume, Pool 2]", parsed to "Volume"
2023/10/19 09:29:01 Retrieved volume "Volume" vol_fs "EXT4"
2023/10/19 09:29:01 Retrieved volume "Volume" vol_totalsize "1.01 TB"
2023/10/19 09:29:01 Retrieved volume "Volume" vol_status "Ready"
2023/10/19 09:29:01 Retrieved vol_desc "[Volume Family, Pool 2]", parsed to "Family"
2023/10/19 09:29:01 Retrieved volume "Family" vol_fs "EXT4"
2023/10/19 09:29:01 Retrieved volume "Family" vol_totalsize "3.48 TB"
2023/10/19 09:29:02 Retrieved volume "Family" vol_status "Ready"
2023/10/19 09:29:02 Found volumes [{0 EXT4 SSD Ready 0 5.7211111866368e+11} {1 EXT4 backups Ready 0 1.0636486508544e+12} {2 EXT4 Volume Ready 0 1.11050674405376e+12} {3 EXT4 Family Ready 0 3.82630046466048e+12}]
2023/10/19 09:29:02 Retrieved sysvolinfo
2023/10/19 09:29:02 Retrieved hal_app path: "/sbin/hal_app"
2023/10/19 09:29:02 Retrieving QM2 enclosures
2023/10/19 09:29:02 Retrieving network interfaces in "/sys/class/net"...
2023/10/19 09:29:02 Retrieving devices in "/dev"...
2023/10/19 09:29:02 Found devices: [nvme0n1 nvme1n1 sda sdb]
2023/10/19 09:29:02 Retrieving dm-cache devices...
2023/10/19 09:29:02 Found cache clients: [vg1-tp1_tierdata_2 vg2-tp2_tierdata_2]
2023/10/19 09:29:02 Found cache volumes: [vg256-lv256	(253:3)]
2023/10/19 09:29:02 Connecting to UPS daemon
panic: runtime error: index out of range [1] with length 1

goroutine 113 [running]:
github.com/pedropombeiro/qnapexporter/lib/exporter/prometheus.(*promExporter).getDmCacheStatsMetrics(0xc000320540)
	/github/workspace/lib/exporter/prometheus/disk.go:108 +0x545
github.com/pedropombeiro/qnapexporter/lib/exporter/prometheus.fetchMetricsWorker(0xc000043690?, 0xc0000437d0?, 0xd, 0xc000154c60?)
	/github/workspace/lib/exporter/prometheus/prometheus.go:166 +0x78
created by github.com/pedropombeiro/qnapexporter/lib/exporter/prometheus.(*promExporter).WriteMetrics
	/github/workspace/lib/exporter/prometheus/prometheus.go:126 +0x1fc

QNAP model is TS-264
image

@SkyeYoung
Copy link

I also encountered this problem. After looking at the code, it seems that the returned data is somewhat different on different devices.

func (e *promExporter) getDmCacheStatsMetrics() ([]metric, error) {
if len(e.dmCacheClients) == 0 {
return nil, nil
}
args := append([]string{"status", "--noflush"}, e.dmCacheClients...)
lines, err := utils.ExecCommandGetLines("dmsetup", args...)
if err != nil {
return nil, fmt.Errorf("get dm-cache status (dmsetup %s): %w", args, err)
}
metrics := make([]metric, 0, len(lines)+6*2)
for index, line := range lines {
tokens := strings.SplitN(line, " ", 13)
cache := e.dmCacheClients[index]
allocationRatioStr := strings.TrimSpace(tokens[3])
allocationTokens := strings.SplitN(allocationRatioStr, "/", 2)
attr := fmt.Sprintf("device=%q", cache)
metrics = appendFloatMetric(metrics, "node_flashcache_cached_blocks", allocationTokens[0], 1, "", "")
metrics = appendFloatMetric(metrics, "node_flashcache_total_blocks", allocationTokens[1], 1, "", "")
metrics = appendFloatMetric(metrics, "node_dmcache_used_bytes_total", allocationTokens[0], 1024*1024, attr, "Number of blocks resident in the cache")
metrics = appendFloatMetric(metrics, "node_dmcache_bytes_total", allocationTokens[1], 1024*1024, attr, "Total number of cache blocks")
}

Here the string with index 3 is taken directly, but it seems that on my device it should be 4

image

SkyeYoung added a commit to SkyeYoung/qnapexporter that referenced this issue Jan 21, 2024
@SkyeYoung SkyeYoung linked a pull request Jan 21, 2024 that will close this issue
@SkyeYoung
Copy link

I've pushed a PR to try to fix this, maybe you can also try compiling one yourself and give it a try.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants