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

Fix Ceph collector file extension #298

Merged
merged 1 commit into from
Nov 13, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 11 additions & 2 deletions pkg/collect/ceph.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,48 +21,57 @@ type CephCommand struct {
ID string
Command []string
Args []string
Format string
}

var CephCommands = []CephCommand{
{
ID: "status",
Command: []string{"ceph", "status"},
Args: []string{"-f", "json-pretty"},
Format: "json",
},
{
ID: "fs",
Command: []string{"ceph", "fs", "status"},
Args: []string{"-f", "json-pretty"},
Format: "json",
},
{
ID: "fs-ls",
Command: []string{"ceph", "fs", "ls"},
Args: []string{"-f", "json-pretty"},
Format: "json",
},
{
ID: "osd-status",
Command: []string{"ceph", "osd", "status"},
Args: []string{"-f", "json-pretty"},
Format: "txt",
},
{
ID: "osd-tree",
Command: []string{"ceph", "osd", "tree"},
Args: []string{"-f", "json-pretty"},
Format: "json",
},
{
ID: "osd-pool",
Command: []string{"ceph", "osd", "pool", "ls", "detail"},
Args: []string{"-f", "json-pretty"},
Format: "json",
},
{
ID: "health",
Command: []string{"ceph", "health", "detail"},
Args: []string{"-f", "json-pretty"},
Format: "json",
},
{
ID: "auth",
Command: []string{"ceph", "auth", "ls"},
Args: []string{"-f", "json-pretty"},
Format: "json",
},
}

Expand Down Expand Up @@ -108,9 +117,9 @@ func cephCommandExec(ctx context.Context, c *Collector, cephCollector *troublesh
pathPrefix := GetCephCollectorFilepath(cephCollector.Name, cephCollector.Namespace)
switch {
case strings.HasSuffix(filename, "-stdout.txt"):
final[path.Join(pathPrefix, fmt.Sprintf("%s.json", command.ID))] = result
final[path.Join(pathPrefix, fmt.Sprintf("%s.%s", command.ID, command.Format))] = result
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.Join only works for paths separated by forward slashes. Use filepath.Join instead.

View Rule

case strings.HasSuffix(filename, "-stderr.txt"):
final[path.Join(pathPrefix, fmt.Sprintf("%s-stderr.json", command.ID))] = result
final[path.Join(pathPrefix, fmt.Sprintf("%s-stderr.txt", command.ID))] = result
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

path.Join only works for paths separated by forward slashes. Use filepath.Join instead.

View Rule

case strings.HasSuffix(filename, "-errors.json"):
final[path.Join(pathPrefix, fmt.Sprintf("%s-errors.json", command.ID))] = result
}
Expand Down