|
5 | 5 | "log" |
6 | 6 | "strconv" |
7 | 7 |
|
8 | | - "github.com/prometheus/client_golang/prometheus" |
9 | 8 | "github.com/cern-eos/eos_exporter/eosclient" |
| 9 | + "github.com/prometheus/client_golang/prometheus" |
10 | 10 |
|
11 | 11 | //"os" |
12 | 12 | //"bufio" |
@@ -54,6 +54,10 @@ type NSCollector struct { |
54 | 54 | Total_files_changelog_avg_entry_size *prometheus.GaugeVec |
55 | 55 | Total_files_changelog_size *prometheus.GaugeVec |
56 | 56 | Uptime *prometheus.GaugeVec |
| 57 | + Cache_files_requests *prometheus.GaugeVec |
| 58 | + Cache_files_hits *prometheus.GaugeVec |
| 59 | + Cache_containers_requests *prometheus.GaugeVec |
| 60 | + Cache_containers_hits *prometheus.GaugeVec |
57 | 61 | } |
58 | 62 |
|
59 | 63 | type NSActivityCollector struct { |
@@ -430,6 +434,42 @@ func NewNSCollector(opts *CollectorOpts) *NSCollector { |
430 | 434 | }, |
431 | 435 | []string{}, |
432 | 436 | ), |
| 437 | + Cache_files_requests: prometheus.NewGaugeVec( |
| 438 | + prometheus.GaugeOpts{ |
| 439 | + Namespace: namespace, |
| 440 | + Name: "ns_cache_files_requests_total", |
| 441 | + Help: "Cache_files_requests: Number of cache file requests.", |
| 442 | + ConstLabels: labels, |
| 443 | + }, |
| 444 | + []string{}, |
| 445 | + ), |
| 446 | + Cache_files_hits: prometheus.NewGaugeVec( |
| 447 | + prometheus.GaugeOpts{ |
| 448 | + Namespace: namespace, |
| 449 | + Name: "ns_cache_files_hits_total", |
| 450 | + Help: "Cache_files_hits: Number of cache file hits.", |
| 451 | + ConstLabels: labels, |
| 452 | + }, |
| 453 | + []string{}, |
| 454 | + ), |
| 455 | + Cache_containers_requests: prometheus.NewGaugeVec( |
| 456 | + prometheus.GaugeOpts{ |
| 457 | + Namespace: namespace, |
| 458 | + Name: "ns_cache_container_requests_total", |
| 459 | + Help: "Cache_container_requests: Number of cache container requests.", |
| 460 | + ConstLabels: labels, |
| 461 | + }, |
| 462 | + []string{}, |
| 463 | + ), |
| 464 | + Cache_containers_hits: prometheus.NewGaugeVec( |
| 465 | + prometheus.GaugeOpts{ |
| 466 | + Namespace: namespace, |
| 467 | + Name: "ns_cache_container_hits_total", |
| 468 | + Help: "Cache_container_hits: Number of cache container hits.", |
| 469 | + ConstLabels: labels, |
| 470 | + }, |
| 471 | + []string{}, |
| 472 | + ), |
433 | 473 | Hanging_since: prometheus.NewGaugeVec( |
434 | 474 | prometheus.GaugeOpts{ |
435 | 475 | Namespace: namespace, |
@@ -595,6 +635,10 @@ func (o *NSCollector) collectorList() []prometheus.Collector { |
595 | 635 | o.Total_files_changelog_avg_entry_size, |
596 | 636 | o.Total_files_changelog_size, |
597 | 637 | o.Uptime, |
| 638 | + o.Cache_files_requests, |
| 639 | + o.Cache_files_hits, |
| 640 | + o.Cache_containers_requests, |
| 641 | + o.Cache_containers_hits, |
598 | 642 | } |
599 | 643 | } |
600 | 644 |
|
@@ -915,6 +959,30 @@ func (o *NSCollector) collectNSDF() error { |
915 | 959 | if err == nil { |
916 | 960 | o.Hanging_since.WithLabelValues().Set(hanging_since) |
917 | 961 | } |
| 962 | + |
| 963 | + // Cache_files_requests |
| 964 | + cache_files_requests, err := strconv.ParseFloat(m.Cache_files_requests, 64) |
| 965 | + if err == nil { |
| 966 | + o.Cache_files_requests.WithLabelValues().Set(cache_files_requests) |
| 967 | + } |
| 968 | + |
| 969 | + // Cache_files_hits |
| 970 | + cache_files_hits, err := strconv.ParseFloat(m.Cache_files_hits, 64) |
| 971 | + if err == nil { |
| 972 | + o.Cache_files_hits.WithLabelValues().Set(cache_files_hits) |
| 973 | + } |
| 974 | + |
| 975 | + // Cache_containers_requests |
| 976 | + cache_containers_requests, err := strconv.ParseFloat(m.Cache_containers_requests, 64) |
| 977 | + if err == nil { |
| 978 | + o.Cache_containers_requests.WithLabelValues().Set(cache_containers_requests) |
| 979 | + } |
| 980 | + |
| 981 | + // Cache_containers_hits |
| 982 | + cache_containers_hits, err := strconv.ParseFloat(m.Cache_containers_hits, 64) |
| 983 | + if err == nil { |
| 984 | + o.Cache_containers_hits.WithLabelValues().Set(cache_containers_hits) |
| 985 | + } |
918 | 986 | } |
919 | 987 |
|
920 | 988 | return nil |
|
0 commit comments