Skip to content
Draft
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
1 change: 1 addition & 0 deletions admin/cli/cli.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ type PMMAdminCommands struct {
Summary commands.SummaryCommand `cmd:"" help:"Fetch system data for diagnostics"`
List commands.ListCommand `cmd:"" help:"Show Services and Agents running on this Node"`
Config commands.ConfigCommand `cmd:"" help:"Configure local pmm-agent"`
Debug commands.DebugCommand `cmd:"" help:"Debug exporter data collection for a specific agent"`
Annotate commands.AnnotationCommand `cmd:"" help:"Add an annotation to Grafana charts"`
Unregister management.UnregisterCommand `cmd:"" help:"Unregister current Node from PMM Server"`
Remove management.RemoveCommand `cmd:"" help:"Remove Service from monitoring"`
Expand Down
1 change: 1 addition & 0 deletions admin/cmd/bootstrap.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,7 @@ func getDefaultKongOptions(appName string) []kong.Option {
"nodeTypeDefault": nodeTypeDefault,
"hostname": hostname,
"serviceTypesEnum": strings.Join(management.AllServiceTypesKeys, ", "),
"debugServiceTypesEnum": strings.Join(commands.DebugServiceTypesKeys, ", "),
"defaultMachineID": defaultMachineID,
"distro": nodeinfo.Distro,
"metricsModesEnum": strings.Join(management.MetricsModes, ", "),
Expand Down
27 changes: 27 additions & 0 deletions admin/commands/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ import (

"github.com/pkg/errors"
"github.com/sirupsen/logrus"

"github.com/percona/pmm/api/inventory/v1/types"
)

var (
Expand Down Expand Up @@ -198,6 +200,31 @@ func ReadFile(filePath string) (string, error) {
return string(content), nil
}

// GetAgentStatus extracts and formats agent status from API response.
// This is used in the json output. By convention, statuses must be in uppercase.
func GetAgentStatus(status *string) string {
if status == nil || *status == "" {
return "UNKNOWN"
}
res := *status
res = strings.TrimPrefix(res, "AGENT_STATUS_")
return res
}

// GetServiceTypeConstant returns the service type constant for the API based on CLI service type.
func GetServiceTypeConstant(serviceType string) string {
serviceTypes := map[string]string{
"mysql": types.ServiceTypeMySQLService,
"mongodb": types.ServiceTypeMongoDBService,
"postgresql": types.ServiceTypePostgreSQLService,
"valkey": types.ServiceTypeValkeyService,
"proxysql": types.ServiceTypeProxySQLService,
"haproxy": types.ServiceTypeHAProxyService,
"external": types.ServiceTypeExternalService,
}
return serviceTypes[serviceType]
}

// UsageTemplate is default kingping's usage template with tweaks:
// * FormatAllCommands is a copy of FormatCommands that ignores hidden flag;
// * subcommands are shown with FormatAllCommands.
Expand Down
Loading
Loading