| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243 |
- // Copyright 2019 Yunion
- //
- // Licensed 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 measurements
- import (
- "fmt"
- "strings"
- "yunion.io/x/onecloud/pkg/apis/monitor"
- )
- var podCpu = SMeasurement{
- Context: []SMonitorContext{
- {
- Name: "pod_cpu",
- DisplayName: "Pod cpu",
- ResourceType: monitor.METRIC_RES_TYPE_CONTAINER,
- Database: monitor.METRIC_DATABASE_TELE,
- },
- },
- Metrics: []SMetric{
- {
- Name: "usage_rate",
- DisplayName: "Pod cpu usage rate",
- Unit: monitor.METRIC_UNIT_PERCENT,
- },
- },
- }
- var podGpu = SMeasurement{
- Context: []SMonitorContext{
- {
- Name: "pod_gpu",
- DisplayName: "Pod gpu",
- ResourceType: monitor.METRIC_RES_TYPE_CONTAINER,
- Database: monitor.METRIC_DATABASE_TELE,
- },
- },
- Metrics: []SMetric{
- {
- Name: "mem",
- DisplayName: "Pod gpu mem used",
- Unit: monitor.METRIC_UNIT_MB,
- },
- {
- Name: "mem_util",
- DisplayName: "Pod gpu mem usage",
- Unit: monitor.METRIC_UNIT_PERCENT,
- },
- },
- }
- var podMem = SMeasurement{
- Context: []SMonitorContext{
- {
- Name: "pod_mem",
- DisplayName: "Pod memory",
- ResourceType: monitor.METRIC_RES_TYPE_CONTAINER,
- Database: monitor.METRIC_DATABASE_TELE,
- },
- },
- Metrics: []SMetric{
- {
- Name: "usage_rate",
- DisplayName: "Pod memory usage rate",
- Unit: monitor.METRIC_UNIT_PERCENT,
- },
- {
- "working_set_rate",
- "Container memory working set usage rate",
- monitor.METRIC_UNIT_PERCENT,
- },
- {
- "usage_bytes",
- "Container memory usage bytes",
- monitor.METRIC_UNIT_BYTE,
- },
- {
- Name: "working_set_bytes",
- DisplayName: "Pod memory working set bytes",
- Unit: monitor.METRIC_UNIT_BYTE,
- },
- },
- }
- var podVolume = SMeasurement{
- Context: []SMonitorContext{
- {
- Name: "pod_volume",
- DisplayName: "Pod volume",
- ResourceType: monitor.METRIC_RES_TYPE_CONTAINER,
- Database: monitor.METRIC_DATABASE_TELE,
- },
- },
- Metrics: []SMetric{
- {
- Name: "free",
- DisplayName: "Pod volume free size",
- Unit: monitor.METRIC_UNIT_BYTE,
- },
- {
- Name: "used",
- DisplayName: "Pod volume used size",
- Unit: monitor.METRIC_UNIT_BYTE,
- },
- {
- Name: "used_percent",
- DisplayName: "Pod volume used percent",
- Unit: monitor.METRIC_UNIT_PERCENT,
- },
- {
- Name: "inodes_total",
- DisplayName: "Pod volume inodes total count",
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "inodes_free",
- DisplayName: "Pod volume inodes free count",
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "inodes_used",
- DisplayName: "Pod volume inodes used count",
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "inodes_used_percent",
- DisplayName: "Pod volume inodes used percent",
- Unit: monitor.METRIC_UNIT_PERCENT,
- },
- },
- }
- func newCadvisorProcessMetrics(displayType string) []SMetric {
- return []SMetric{
- {
- Name: "process_count",
- DisplayName: fmt.Sprintf("%s process count", displayType),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "threads_current",
- DisplayName: fmt.Sprintf("%s threads currently count", displayType),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "threads_max",
- DisplayName: fmt.Sprintf("Maximum number of threads allowed in %s", strings.ToLower(displayType)),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "fd_count",
- DisplayName: fmt.Sprintf("%s open file descriptors count", displayType),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "socket_count",
- DisplayName: fmt.Sprintf("%s sockets count", displayType),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- }
- }
- func newCadvisorDiskIoMetrics(displayType string) []SMetric {
- return []SMetric{
- {
- Name: "read_Bps",
- DisplayName: fmt.Sprintf("%s read bytes per second", displayType),
- Unit: monitor.METRIC_UNIT_BYTEPS,
- },
- {
- Name: "write_Bps",
- DisplayName: fmt.Sprintf("%s write bytes per second", displayType),
- Unit: monitor.METRIC_UNIT_BYTEPS,
- },
- {
- Name: "read_iops",
- DisplayName: fmt.Sprintf("%s read iops", displayType),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "write_iops",
- DisplayName: fmt.Sprintf("%s write iops", displayType),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "read_bytes",
- DisplayName: fmt.Sprintf("%s read bytes", displayType),
- Unit: monitor.METRIC_UNIT_BYTE,
- },
- {
- Name: "write_bytes",
- DisplayName: fmt.Sprintf("%s write bytes", displayType),
- Unit: monitor.METRIC_UNIT_BYTE,
- },
- {
- Name: "read_count",
- DisplayName: fmt.Sprintf("%s read count", displayType),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- {
- Name: "write_count",
- DisplayName: fmt.Sprintf("%s write count", displayType),
- Unit: monitor.METRIC_UNIT_COUNT,
- },
- }
- }
- var podProcess = SMeasurement{
- Context: []SMonitorContext{
- {
- Name: "pod_process",
- DisplayName: "Pod process",
- ResourceType: monitor.METRIC_RES_TYPE_CONTAINER,
- Database: monitor.METRIC_DATABASE_TELE,
- },
- },
- Metrics: newCadvisorProcessMetrics("Pod"),
- }
- var podDiskIo = SMeasurement{
- Context: []SMonitorContext{
- {
- Name: "pod_diskio",
- DisplayName: "Pod diskio",
- ResourceType: monitor.METRIC_RES_TYPE_CONTAINER,
- Database: monitor.METRIC_DATABASE_TELE,
- },
- },
- Metrics: newCadvisorDiskIoMetrics("Pod"),
- }
|