Skip to content

Commit

Permalink
Add support for proc/stat path under "OTHERS" target
Browse files Browse the repository at this point in the history
  • Loading branch information
jipanyang authored and lguohan committed Mar 24, 2018
1 parent 1bf24e7 commit 6dd1fbd
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
4 changes: 2 additions & 2 deletions doc/grpc_telemetry.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Some data like COUNTERS table in COUNTERS_DB doesn't have key, but field and val

Refer to [SONiC data schema](https://github.com/Azure/sonic-swss-common/blob/master/common/schema.h) for more info about DB and table.

For data not available in DBs, we designate top name "OTHERS" for that category of data, paths like platform/cpu or proc/loadavg follow it to represent the full path.
For data not available in DBs, Target name "OTHERS" is designated for that category of data, paths like platform/cpu or proc/loadavg under "OTHERS" target may be used get/subscribe the data.

# gRPC operations for data telemetry in SONiC
As mentioned at the beginning, SONiC gRPC data telemetry is largely based on gNMI protocol, the GetRquest/GetResponse and SubscribeRequest/SubscribeResponse RPC have been implemented. Since SONiC doesn't have complete YANG data model yet, the DB, TABLE, KEY and Field path hierarchy is used as path to uniquely identify the configuration/state and counter data.
Expand Down Expand Up @@ -342,7 +342,7 @@ sendQueryAndDisplay: GROUP poll [[COUNTERS Ethernet9 SAI_PORT_STAT_PFC_7_RX_PKTS
}
```

The data not available in DB also support poll subscription and get. So far under "OTHERS" target, platform/cpu, proc/meminfo, proc/loadavg, proc/vmstat, and proc/diskstats are the paths supported.
The data not available in DB also support poll subscription and get. So far under "OTHERS" target, platform/cpu, proc/stat, proc/meminfo, proc/loadavg, proc/vmstat, and proc/diskstats are the paths supported.
```
jipan@sonicvm1:~/work/go/src/github.com/jipanyang/gnmi/cmd/gnmi_cli$ ./gnmi_cli -client_types=gnmi -a 30.57.185.38:8080 -t OTHERS -logtostderr -insecure -qt p -pi 10s -q proc/loadavg
sendQueryAndDisplay: GROUP poll [[proc loadavg]]
Expand Down
15 changes: 15 additions & 0 deletions sonic_data_client/non_db_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,10 @@ var (
path: []string{"OTHERS", "proc", "vmstat"},
getFunc: dataGetFunc(getProcVmstat),
},
{ // Get proc stat
path: []string{"OTHERS", "proc", "stat"},
getFunc: dataGetFunc(getProcStat),
},
}
)

Expand Down Expand Up @@ -231,6 +235,17 @@ func getProcVmstat() ([]byte, error) {
return b, nil
}

func getProcStat() ([]byte, error) {
stat, _ := linuxproc.ReadStat("/proc/stat")
b, err := json.Marshal(stat)
if err != nil {
log.V(2).Infof("%v", err)
return b, err
}
log.V(4).Infof("getProcStat, output %v", string(b))
return b, nil
}

func pollStats() {
for {
stat, err := linuxproc.ReadStat("/proc/stat")
Expand Down

0 comments on commit 6dd1fbd

Please sign in to comment.