Skip to content

Commit

Permalink
修改reportserver cronjob采集监控数据的间隔
Browse files Browse the repository at this point in the history
在cronjobspec中增加interval属性,通过该配置指定采集数据的间隔
  • Loading branch information
zhaoxiangchun committed May 7, 2020
1 parent aecb7eb commit fb88568
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 9 deletions.
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ require (
k8s.io/apiextensions-apiserver v0.0.0
k8s.io/apimachinery v0.17.3
k8s.io/client-go v9.0.0+incompatible
k8s.io/code-generator v0.15.12-beta.0 // indirect
k8s.io/klog v0.3.3
k8s.io/kube-openapi v0.0.0-20190603182131-db7b694dc208 // indirect
k8s.io/kubernetes v1.16.0
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/onecloud/v1alpha1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (

var (
StartingDeadlineSeconds int64 = 300
CronjobMonitorExpand float64 = 1.2
)

// ComponentType represents component type
Expand Down Expand Up @@ -297,6 +298,7 @@ type CronJobSpec struct {
ContainerSpec
Disable bool `json:"disable"`
Schedule string `json:"schedule"`
Interval string `json:"interval"`
Affinity *corev1.Affinity `json:"affinity,omitempty"`
NodeSelector map[string]string `json:"nodeSelector,omitempty"`
Tolerations []corev1.Toleration `json:"tolerations,omitempty"`
Expand Down
28 changes: 19 additions & 9 deletions pkg/manager/component/cloudmon_report_server.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package component

import (
"fmt"
"math"
"strconv"

batchv1 "k8s.io/api/batch/v1beta1"
corev1 "k8s.io/api/core/v1"
Expand Down Expand Up @@ -39,7 +41,15 @@ func (m *cloudmonReportServerManager) newCronJob(
cfg *v1alpha1.OnecloudClusterConfig,
) (*batchv1.CronJob, error) {
spec := &oc.Spec.CloudmonReportServer
spec.Schedule = "*/15 * * * *"
//spec.Schedule = "*/15 * * * *"
if spec.Schedule == ""{
spec.Schedule = "*/15 * * * *"
}
if spec.Interval == ""{
spec.Interval = "15"
}
period,_:=strconv.ParseFloat(spec.Interval,64)
monitorInterval:=strconv.FormatFloat(math.Ceil(period * v1alpha1.CronjobMonitorExpand),'f',-1,64)
configMapType := v1alpha1.APIGatewayComponentType
containersF := func(volMounts []corev1.VolumeMount) []corev1.Container {
return []corev1.Container{
Expand All @@ -52,7 +62,7 @@ func (m *cloudmonReportServerManager) newCronJob(
fmt.Sprintf("/etc/yunion/%s.conf", configMapType),
"report-server",
"--interval",
"15",
monitorInterval,
"--provider",
"Aliyun",
},
Expand All @@ -68,7 +78,7 @@ func (m *cloudmonReportServerManager) newCronJob(
fmt.Sprintf("/etc/yunion/%s.conf", configMapType),
"report-server",
"--interval",
"15",
monitorInterval,
"--provider",
"Huawei",
},
Expand All @@ -84,7 +94,7 @@ func (m *cloudmonReportServerManager) newCronJob(
fmt.Sprintf("/etc/yunion/%s.conf", configMapType),
"report-server",
"--interval",
"15",
monitorInterval,
"--provider",
"Qcloud",
},
Expand All @@ -100,7 +110,7 @@ func (m *cloudmonReportServerManager) newCronJob(
fmt.Sprintf("/etc/yunion/%s.conf", configMapType),
"report-server",
"--interval",
"15",
monitorInterval,
"--provider",
"Google",
},
Expand All @@ -116,7 +126,7 @@ func (m *cloudmonReportServerManager) newCronJob(
fmt.Sprintf("/etc/yunion/%s.conf", configMapType),
"report-server",
"--interval",
"15",
monitorInterval,
"--provider",
"Aws",
},
Expand All @@ -132,7 +142,7 @@ func (m *cloudmonReportServerManager) newCronJob(
fmt.Sprintf("/etc/yunion/%s.conf", configMapType),
"report-server",
"--interval",
"15",
monitorInterval,
"--provider",
"Azure",
},
Expand All @@ -148,7 +158,7 @@ func (m *cloudmonReportServerManager) newCronJob(
fmt.Sprintf("/etc/yunion/%s.conf", configMapType),
"report-server",
"--interval",
"15",
monitorInterval,
"--provider",
"VMware",
},
Expand All @@ -164,7 +174,7 @@ func (m *cloudmonReportServerManager) newCronJob(
fmt.Sprintf("/etc/yunion/%s.conf", configMapType),
"report-server",
"--interval",
"15",
monitorInterval,
"--provider",
"ZStack",
},
Expand Down

0 comments on commit fb88568

Please sign in to comment.