Skip to content

Commit

Permalink
configurable timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
labkode committed Feb 14, 2024
1 parent 9ee9179 commit 81f1ac6
Show file tree
Hide file tree
Showing 15 changed files with 122 additions and 100 deletions.
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ descr:
@echo "You are building the EOS exporter binary."

build:
./get_build_info.sh
go generate
go build .

Expand Down
6 changes: 6 additions & 0 deletions collector/collector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package collector

type CollectorOpts struct {
Cluster string
Timeout int
}
5 changes: 4 additions & 1 deletion collector/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
)

type FSCollector struct {
*CollectorOpts
Host *prometheus.GaugeVec
Port *prometheus.GaugeVec
Id *prometheus.GaugeVec
Expand Down Expand Up @@ -63,11 +64,13 @@ type FSCollector struct {

// NewFSCollector creates an cluster of the FSCollector and instantiates
// the individual metrics that show information about the FS.
func NewFSCollector(cluster string) *FSCollector {
func NewFSCollector(opts *CollectorOpts) *FSCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &FSCollector{
CollectorOpts: opts,
StatBoot: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
5 changes: 4 additions & 1 deletion collector/fsck.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ import (
)

type FsckCollector struct {
*CollectorOpts
Count *prometheus.GaugeVec
}

// NewFSCollector creates an cluster of the FSCollector and instantiates
// the individual metrics that show information about the FS.
func NewFsckCollector(cluster string) *FsckCollector {
func NewFsckCollector(opts *CollectorOpts) *FsckCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &FsckCollector{
CollectorOpts: opts,
Count: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
5 changes: 4 additions & 1 deletion collector/fusex.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,19 @@ blockedfunc=none
*/

type FusexCollector struct {
*CollectorOpts
Info *prometheus.GaugeVec
}

// NewFSCollector creates an cluster of the FSCollector and instantiates
// the individual metrics that show information about the FS.
func NewFusexCollector(cluster string) *FusexCollector {
func NewFusexCollector(opts *CollectorOpts) *FusexCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &FusexCollector{
CollectorOpts: opts,
Info: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
8 changes: 6 additions & 2 deletions collector/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

type GroupCollector struct {
*CollectorOpts
Name *prometheus.GaugeVec
CfgStatus *prometheus.GaugeVec
Nofs *prometheus.GaugeVec
Expand Down Expand Up @@ -38,11 +39,13 @@ type GroupCollector struct {

// NewGroupCollector creates an cluster of the GroupCollector and instantiates
// the individual metrics that show information about the Group.
func NewGroupCollector(cluster string) *GroupCollector {
func NewGroupCollector(opts *CollectorOpts) *GroupCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &GroupCollector{
CollectorOpts: opts,
CfgStatus: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "eos",
Expand Down Expand Up @@ -292,7 +295,8 @@ func (o *GroupCollector) collectGroupDF() error {

mds, err := client.ListGroup(context.Background(), "root")
if err != nil {
panic(err)
log.Println(err)
return err
}

// Reset gauge metrics to remove metrics of deleted groups
Expand Down
5 changes: 4 additions & 1 deletion collector/inspector.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,16 +10,19 @@ import (
)

type InspectorLayoutCollector struct {
*CollectorOpts
Volume *prometheus.GaugeVec
}

// NewFSCollector creates an cluster of the FSCollector and instantiates
// the individual metrics that show information about the FS.
func NewInspectorLayoutCollector(cluster string) *InspectorLayoutCollector {
func NewInspectorLayoutCollector(opts *CollectorOpts) *InspectorLayoutCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &InspectorLayoutCollector{
CollectorOpts: opts,
Volume: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
16 changes: 10 additions & 6 deletions collector/io.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
)

type IOInfoCollector struct {
*CollectorOpts
Total_bwd_seeks *prometheus.GaugeVec
Total_bytes_bwd_wseek *prometheus.GaugeVec
Total_bytes_deleted *prometheus.GaugeVec
Expand All @@ -36,6 +37,7 @@ type IOInfoCollector struct {
}

type IOAppInfoCollector struct {
*CollectorOpts
Total_in *prometheus.GaugeVec
Total_out *prometheus.GaugeVec
//Last_60s *prometheus.GaugeVec
Expand All @@ -44,13 +46,14 @@ type IOAppInfoCollector struct {
//Last_86400s *prometheus.GaugeVec
}

//NewIOInfoCollector creates an cluster of the IOInfoCollector
func NewIOInfoCollector(cluster string) *IOInfoCollector {
// NewIOInfoCollector creates an cluster of the IOInfoCollector
func NewIOInfoCollector(opts *CollectorOpts) *IOInfoCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &IOInfoCollector{

CollectorOpts: opts,
Total_bwd_seeks: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down Expand Up @@ -207,13 +210,14 @@ func NewIOInfoCollector(cluster string) *IOInfoCollector {
}
}

//NewIOAppInfoCollector creates an cluster of the IOAppInfoCollector
func NewIOAppInfoCollector(cluster string) *IOAppInfoCollector {
// NewIOAppInfoCollector creates an cluster of the IOAppInfoCollector
func NewIOAppInfoCollector(opts *CollectorOpts) *IOAppInfoCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &IOAppInfoCollector{

CollectorOpts: opts,
Total_in: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
6 changes: 4 additions & 2 deletions collector/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const (
)

type NodeCollector struct {

*CollectorOpts
// UsedBytes displays the total used bytes in the Node
Host *prometheus.GaugeVec
Port *prometheus.GaugeVec
Expand Down Expand Up @@ -82,11 +82,13 @@ cfg.gw.ntx=10
*/

// NewNodeCollector creates an cluster of the NodeCollector
func NewNodeCollector(cluster string) *NodeCollector {
func NewNodeCollector(opts *CollectorOpts) *NodeCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster

return &NodeCollector{
CollectorOpts: opts,
Status: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: "eos",
Expand Down
21 changes: 15 additions & 6 deletions collector/ns.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (
)

type NSCollector struct {
*CollectorOpts
Boot_file_time *prometheus.GaugeVec
Boot_status *prometheus.GaugeVec
Boot_time *prometheus.GaugeVec
Expand Down Expand Up @@ -50,6 +51,7 @@ type NSCollector struct {
}

type NSActivityCollector struct {
*CollectorOpts
Sum *prometheus.GaugeVec
Last_5s *prometheus.GaugeVec
Last_60s *prometheus.GaugeVec
Expand All @@ -58,6 +60,7 @@ type NSActivityCollector struct {
}

type NSBatchCollector struct {
*CollectorOpts
Sum *prometheus.GaugeVec
Last_5s *prometheus.GaugeVec
Last_60s *prometheus.GaugeVec
Expand All @@ -79,13 +82,15 @@ var err error
}
}*/

//NewNSCollector creates an instance of the NSCollector and instantiates
// NewNSCollector creates an instance of the NSCollector and instantiates
// the individual metrics that show information about the NS.
func NewNSCollector(cluster string) *NSCollector {
func NewNSCollector(opts *CollectorOpts) *NSCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &NSCollector{
CollectorOpts: opts,
Boot_file_time: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down Expand Up @@ -377,13 +382,15 @@ func NewNSCollector(cluster string) *NSCollector {
}
}

//NewNSActivityCollector creates an instance of the NSActivityCollector and instantiates
// NewNSActivityCollector creates an instance of the NSActivityCollector and instantiates
// the individual metrics that show information about the NS activity.
func NewNSActivityCollector(cluster string) *NSActivityCollector {
func NewNSActivityCollector(opts *CollectorOpts) *NSActivityCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &NSActivityCollector{
CollectorOpts: opts,
Sum: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down Expand Up @@ -432,13 +439,15 @@ func NewNSActivityCollector(cluster string) *NSActivityCollector {
}
}

//NewNSBatchCollector creates an instance of the NSBatchCollector and instantiates
// NewNSBatchCollector creates an instance of the NSBatchCollector and instantiates
// the individual metrics that show information about the NS activity.
func NewNSBatchCollector(cluster string) *NSBatchCollector {
func NewNSBatchCollector(opts *CollectorOpts) *NSBatchCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &NSBatchCollector{
CollectorOpts: opts,
Sum: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
7 changes: 5 additions & 2 deletions collector/recycle.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,21 @@ import (
// recycle-bin=/eos/homecanary/proc/recycle/ usedbytes=365327522885 maxbytes=100000000000000 volumeusage=0.37% inodeusage=1.19% lifetime=15552000 ratio=0.800000

type RecycleCollector struct {
*CollectorOpts
UsedBytes *prometheus.GaugeVec
MaxBytes *prometheus.GaugeVec
Lifetime *prometheus.GaugeVec
Ratio *prometheus.GaugeVec
}

//NewRecycleCollector creates an cluster of the RecycleCollector
func NewRecycleCollector(cluster string) *RecycleCollector {
// NewRecycleCollector creates an cluster of the RecycleCollector
func NewRecycleCollector(opts *CollectorOpts) *RecycleCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &RecycleCollector{
CollectorOpts: opts,
UsedBytes: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
8 changes: 5 additions & 3 deletions collector/space.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ sum.stat.disk.bw?configstatus@rw=63069
*/

type SpaceCollector struct {
*CollectorOpts
CfgGroupSize *prometheus.GaugeVec
CfgGroupMod *prometheus.GaugeVec
Nofs *prometheus.GaugeVec
Expand Down Expand Up @@ -76,12 +77,13 @@ type SpaceCollector struct {
}

// NewSpaceCollector creates an cluster of the SpaceCollector
func NewSpaceCollector(cluster string) *SpaceCollector {
func NewSpaceCollector(opts *CollectorOpts) *SpaceCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster
namespace := "eos"
return &SpaceCollector{

CollectorOpts: opts,
CfgGroupSize: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down Expand Up @@ -385,7 +387,7 @@ func (o *SpaceCollector) collectorList() []prometheus.Collector {
func (o *SpaceCollector) collectSpaceDF() error {
ins := getEOSInstance()
url := "root://" + ins
opt := &eosclient.Options{URL: url}
opt := &eosclient.Options{URL: url, Timeout: o.Timeout}
client, err := eosclient.New(opt)
if err != nil {
panic(err)
Expand Down
7 changes: 5 additions & 2 deletions collector/who.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,14 @@ import (
// This collector provides metrics based on c)

type WhoCollector struct {
*CollectorOpts
SessionNumber *prometheus.GaugeVec
file *os.File
}

//NewWhoCollector creates an cluster of the WhoCollector
func NewWhoCollector(cluster string) *WhoCollector {
// NewWhoCollector creates an cluster of the WhoCollector
func NewWhoCollector(opts *CollectorOpts) *WhoCollector {
cluster := opts.Cluster
labels := make(prometheus.Labels)
labels["cluster"] = cluster

Expand All @@ -45,6 +47,7 @@ func NewWhoCollector(cluster string) *WhoCollector {

return &WhoCollector{
//file: f,
CollectorOpts: opts,
SessionNumber: prometheus.NewGaugeVec(
prometheus.GaugeOpts{
Namespace: namespace,
Expand Down
Loading

0 comments on commit 81f1ac6

Please sign in to comment.