Skip to content

Commit

Permalink
feat: Harvest should collect CIFS clients (#1935)
Browse files Browse the repository at this point in the history
* feat: Harvest should collect CIFS clients

Fixes: #1826

```bash
curl -s http://localhost:12990/metrics | rg -v "#|metadata_" | sort | prom
cifs_clients_labels{
  client_ip = "10.249.154.33",
  client_port = "50322",
  cluster = "ocum-infinity",
  datacenter = "nane1",
  identifier = "153417359",
  network_context_id = "9",
  node = "ocum-infinity-01",
  server_ip = "10.231.176.184",
  svm = "vs1_nfs_cifs",
} 1.0
```
  • Loading branch information
cgrinds authored and Hardikl committed Apr 17, 2023
1 parent 8524bad commit 70e3dfb
Show file tree
Hide file tree
Showing 5 changed files with 72 additions and 8 deletions.
26 changes: 18 additions & 8 deletions cmd/tools/template/template_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,17 +360,17 @@ func TestMetricsAreSortedAndNoDuplicates(t *testing.T) {
// check sorted exported instance keys
sortedKeys := checkSortedKeyLabels(model.ExportOptions.InstanceKeys)
if sortedKeys.got != sortedKeys.want {
t.Errorf("keys should be sorted path=[%s]", shortPath(path))
t.Errorf("use this instead")
t.Errorf("%s", sortedKeys.want)
t.Errorf("instance_keys should be sorted path=[%s]", shortPath(path))
t.Errorf("use this instead\n")
t.Errorf("\n%s", sortedKeys.want)
}

// check sorted exported instance labels
sortedLabels := checkSortedKeyLabels(model.ExportOptions.InstanceLabels)
if sortedLabels.got != sortedLabels.want {
t.Errorf("labels should be sorted path=[%s]", shortPath(path))
t.Errorf("use this instead")
t.Errorf("%s", sortedLabels.want)
t.Errorf("instance_labels should be sorted path=[%s]", shortPath(path))
t.Errorf("use this instead\n")
t.Errorf("\n%s", sortedLabels.want)
}

}, allTemplatesButEms...)
Expand Down Expand Up @@ -470,12 +470,22 @@ func sortZapiCounters(counters []metric) {
}

func checkSortedKeyLabels(keyLabels []string) sorted {
got := strings.Join(keyLabels, ",")
got := labelsToString(keyLabels)
sort.Strings(keyLabels)
want := strings.Join(keyLabels, ",")
want := labelsToString(keyLabels)
return sorted{got: got, want: want}
}

func labelsToString(labels []string) string {
b := strings.Builder{}
for _, label := range labels {
b.WriteString(" - ")
b.WriteString(label)
b.WriteString("\n")
}
return b.String()
}

var sigilReplacer = strings.NewReplacer("^", "", "- ", "")

func visitTemplates(t *testing.T, eachTemplate func(path string, model TemplateModel), dirs ...string) {
Expand Down
24 changes: 24 additions & 0 deletions conf/rest/9.8.0/cifs_clients.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: CIFSClients
query: api/private/cli/vserver/cifs/connection
object: cifs_clients

counters:
- ^^connection_id => identifier
- ^^lif_ip => server_ip
- ^^network_context_id => network_context_id
- ^^node => node
- ^^vserver => svm
- ^^workstation_ip => client_ip
- ^^workstation_port => client_port

export_options:
instance_keys:
- client_ip
- client_port
- identifier
- network_context_id
- node
- server_ip
- svm
instance_labels:
- svm
1 change: 1 addition & 0 deletions conf/rest/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ schedule:

objects:
Aggregate: aggr.yaml
CIFSClients: cifs_clients.yaml
CloudTarget: cloud_target.yaml
ClusterPeer: clusterpeer.yaml
Disk: disk.yaml
Expand Down
28 changes: 28 additions & 0 deletions conf/zapi/cdot/9.8.0/cifs_clients.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@

name: CIFSClients
query: cifs-connection-get-iter
object: cifs_clients

counters:
cifs-connection:
- ^^connection-id => identifier
- ^lif-ip => server_ip
- ^network-context-id => network_context_id
- ^node => node
- ^vserver => svm
- ^workstation-ip => client_ip
- ^workstation-port => client_port

collect_only_labels: true

export_options:
instance_keys:
- client_ip
- client_port
- identifier
- network_context_id
- node
- server_ip
- svm
instance_labels:
- svm
1 change: 1 addition & 0 deletions conf/zapi/default.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ schedule:
objects:
Aggregate: aggr.yaml
AggregateEfficiency: aggr_efficiency.yaml
CIFSClients: cifs_clients.yaml
ClusterPeer: clusterpeer.yaml
Disk: disk.yaml
Lun: lun.yaml
Expand Down

0 comments on commit 70e3dfb

Please sign in to comment.