未验证 提交 e9205c6e 编写于 作者: G Gao Hongtao 提交者: GitHub

Add check health command (#43)

上级 c7e2b3fa
# Licensed to Apache Software Foundation (ASF) under one or more contributor
# license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright
# ownership. Apache Software Foundation (ASF) licenses this file to you under
# the Apache License, Version 2.0 (the "License"); you may
# not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
query {
checkHealth {
score
details
}
}
......@@ -21,6 +21,7 @@ import (
"io/ioutil"
"os"
"github.com/apache/skywalking-cli/commands/common"
"github.com/apache/skywalking-cli/commands/trace"
"github.com/apache/skywalking-cli/commands/metrics"
......@@ -87,6 +88,7 @@ func main() {
service.Command,
metrics.Command,
trace.Command,
common.Command,
}
app.Before = interceptor.BeforeChain([]cli.BeforeFunc{
......
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package common
import (
"github.com/urfave/cli"
"github.com/apache/skywalking-cli/display"
"github.com/apache/skywalking-cli/display/displayable"
"github.com/apache/skywalking-cli/graphql/common"
)
var Command = cli.Command{
Name: "checkHealth",
Aliases: []string{"ch"},
Usage: "Check the health status of OAP server",
Action: func(ctx *cli.Context) error {
healthStatus := common.CheckHealth(ctx)
return display.Display(ctx, &displayable.Displayable{Data: healthStatus})
},
}
// Licensed to Apache Software Foundation (ASF) under one or more contributor
// license agreements. See the NOTICE file distributed with
// this work for additional information regarding copyright
// ownership. Apache Software Foundation (ASF) licenses this file to you under
// the Apache License, Version 2.0 (the "License"); you may
// not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing,
// software distributed under the License is distributed on an
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
// KIND, either express or implied. See the License for the
// specific language governing permissions and limitations
// under the License.
package common
import (
"github.com/machinebox/graphql"
"github.com/urfave/cli"
"github.com/apache/skywalking-cli/assets"
"github.com/apache/skywalking-cli/graphql/client"
"github.com/apache/skywalking-cli/graphql/schema"
)
// CheckHealth intends to query the health status of OAP server
func CheckHealth(ctx *cli.Context) schema.HealthStatus {
var response map[string]schema.HealthStatus
request := graphql.NewRequest(assets.Read("graphqls/common/checkHealth.graphql"))
client.ExecuteQueryOrFail(ctx, request, &response)
return response["checkHealth"]
}
......@@ -29,7 +29,6 @@ var StepFormats = map[schema.Step]string{
schema.StepMinute: "2006-01-02 1504",
schema.StepHour: "2006-01-02 15",
schema.StepDay: "2006-01-02",
schema.StepMonth: "2006-01",
}
// StepDuration is a mapping from schema.Step to its time.Duration
......@@ -38,5 +37,4 @@ var StepDuration = map[schema.Step]time.Duration{
schema.StepMinute: time.Minute,
schema.StepHour: time.Hour,
schema.StepDay: time.Hour * 24,
schema.StepMonth: time.Hour * 24 * 30,
}
query-protocol @ 563bb51c
Subproject commit 06373bf0d1204b6d3f410c0daf4c7f72529f28a0
Subproject commit 563bb51c71922f017911345d7cd5c62a7ac8995c
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册