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

Feature/3387 #5482

Merged
merged 3 commits into from
Feb 26, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions plugins/inputs/ceph/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ All admin measurements will have the following tags:

*Cluster Stats*

+ ceph_health
- fields:
- status
- overall_status

- ceph_osdmap
- fields:
- epoch (float)
Expand Down Expand Up @@ -209,6 +214,7 @@ ceph_pool_usage,name=telegraf kb_used=0,bytes_used=0,objects=0 15506589110000000
ceph_pgmap_state,state=undersized+peered count=30 1550658910000000000
ceph_pgmap bytes_total=10733223936,read_op_per_sec=0,write_op_per_sec=0,num_pgs=30,data_bytes=0,bytes_avail=9654697984,read_bytes_sec=0,write_bytes_sec=0,version=0,bytes_used=1078525952 1550658910000000000
ceph_osdmap num_up_osds=1,num_in_osds=1,full=false,nearfull=false,num_remapped_pgs=0,epoch=34,num_osds=1 1550658910000000000
ceph_health status="HEALTH_WARN",overall_status="HEALTH_WARN" 1550658910000000000
```

*Admin Socket Stats*
Expand Down
15 changes: 15 additions & 0 deletions plugins/inputs/ceph/ceph.go
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,10 @@ func (c *Ceph) exec(command string) (string, error) {

// CephStatus is used to unmarshal "ceph -s" output
type CephStatus struct {
Health struct {
Status string `json:"status"`
OverallStatus string `json:"overall_status"`
} `json:"health"`
OSDMap struct {
OSDMap struct {
Epoch float64 `json:"epoch"`
Expand Down Expand Up @@ -357,6 +361,7 @@ func decodeStatus(acc telegraf.Accumulator, input string) error {
}

decoders := []func(telegraf.Accumulator, *CephStatus) error{
decodeStatusHealth,
decodeStatusOsdmap,
decodeStatusPgmap,
decodeStatusPgmapState,
Expand All @@ -371,6 +376,16 @@ func decodeStatus(acc telegraf.Accumulator, input string) error {
return nil
}

// decodeStatusHealth decodes the health portion of the output of 'ceph status'
func decodeStatusHealth(acc telegraf.Accumulator, data *CephStatus) error {
fields := map[string]interface{}{
"status": data.Health.Status,
"overall_status": data.Health.OverallStatus,
}
acc.AddFields("ceph_health", fields, map[string]string{})
return nil
}

// decodeStatusOsdmap decodes the OSD map portion of the output of 'ceph -s'
func decodeStatusOsdmap(acc telegraf.Accumulator, data *CephStatus) error {
fields := map[string]interface{}{
Expand Down