Documentation ¶
Index ¶
- Constants
- Variables
- func CheckClockRole(role MetricRole, aIf string, nodeName *string) (err error)
- func CheckClockRoleAndOffset(ptpConfig *ptpv1.PtpConfig, label, nodeName *string) (err error)
- func CheckClockState(state MetricClockState, aIf string, nodeName *string) (err error)
- func GetCadvisorScrapeInterval() (int, error)
- func GetPrometheusPod() (*corev1.Pod, error)
- func GetPrometheusResultFloatValue(promValue []interface{}) (value float64, tsMillis int64, err error)
- func GetPtpOffeset(aIf string, nodeName *string) (metric int, err error)
- func InitEnvIntParamConfig(envString string, defaultInt int, param *int) error
- func RunPrometheusQuery(prometheusPod *corev1.Pod, query string, response *PrometheusQueryResponse) error
- func RunPrometheusQueryWithRetries(prometheusPod *corev1.Pod, query string, rateTimeWindow time.Duration, ...) error
- type MetricClockState
- type MetricRole
- type PrometheusQueryResponse
- type PrometheusVectorResult
Constants ¶
const ( OpenshiftPtpInterfaceRole = "openshift_ptp_interface_role" OpenshiftPtpClockState = "openshift_ptp_clock_state" OpenshiftPtpFrequencyStatus = "openshift_ptp_frequency_status" OpenshiftPtpPhaseStatus = "openshift_ptp_phase_status" OpenshiftPtpOffsetNs = "openshift_ptp_offset_ns" OpenshiftPtpProcessStatus = "openshift_ptp_process_status" OpenshiftPtpClockClass = "openshift_ptp_clock_class" OpenshiftPtpNMEAStatus = "openshift_ptp_nmea_status" OpenshiftPtpThreshold = "openshift_ptp_threshold" MaxOffsetDefaultNs = 100 MinOffsetDefaultNs = -100 )
const ( MetricRolePassiveString = "PASSIVE" MetricRoleSlaveString = "SLAVE" MetricRoleMasterString = "MASTER" MetricRoleFaultyString = "FAULTY" MetricRoleUnknownString = "UNKNOWN" )
const ( MetricClockStateFreeRunString = "FREERUN" MetricClockStateLockedString = "LOCKED" MetricClockStateHoldOverString = "HOLDOVER" )
const ( PrometheusQueryRetries = 10 PrometheusQueryRetryInterval = 1 * time.Second )
Variables ¶
var MaxOffsetNs int
var MinOffsetNs int
Functions ¶
func CheckClockRole ¶
func CheckClockRole(role MetricRole, aIf string, nodeName *string) (err error)
This method checks the state of the clock with specified interface
func CheckClockRoleAndOffset ¶
Checks the accuracy of the clock defined by the ptpconfig passsed as a parameter: - checks the ptp offset to be less than MaxOffsetDefaultNs or any value passed by the user - check that the role of each interfaces in the ptpconfig matches the metric
func CheckClockState ¶
func CheckClockState(state MetricClockState, aIf string, nodeName *string) (err error)
func GetCadvisorScrapeInterval ¶
GetCadvisorScrapeInterval returns the current scrape internval (in secs) of cadvisor target configured in kubelet's prometheus ServiceMonitor.
func GetPrometheusPod ¶
GetPrometheusPod is a helper function that returns the first pod of the prometheus statefulset.
func GetPrometheusResultFloatValue ¶
func GetPrometheusResultFloatValue(promValue []interface{}) (value float64, tsMillis int64, err error)
GetPrometheusResultFloatValue returns the float value and timestamp from a prometheus value vector. The value is a vector with [ float, string ], where the timestamp is the float datum (in seconds) and the strings hold the actual, like in: [ 1674137739.625, "0.0015089738179757707" ]
func InitEnvIntParamConfig ¶
gets the user configured maximum offset in nanoseconds
func RunPrometheusQuery ¶
func RunPrometheusQuery(prometheusPod *corev1.Pod, query string, response *PrometheusQueryResponse) error
RunPrometheusQuery runs a prometheus query in a prometheus pod and unmarshals the response in a given struct. Fails if the curl command failed, the prometheus response is not a "success" or it cannot be unmarshaled.
func RunPrometheusQueryWithRetries ¶
func RunPrometheusQueryWithRetries(prometheusPod *corev1.Pod, query string, rateTimeWindow time.Duration, retries int, retryInterval time.Duration, response *PrometheusQueryResponse, checkerFunc func(response *PrometheusQueryResponse) bool) error
RunPrometheusQueryWithRetries runs RunPrometheusQuery but retries in case of failure, waiting retryInterval perdiod before the next attempt.
Types ¶
type MetricClockState ¶
type MetricClockState int
type and display for OpenshiftPtpClockState metric. Values: 0 = FREERUN, 1 = LOCKED, 2 = HOLDOVER
const ( MetricClockStateFreeRun MetricClockState = iota MetricClockStateLocked MetricClockStateHoldOver )
func (MetricClockState) String ¶
func (role MetricClockState) String() string
Stringer for MetricClockState
type MetricRole ¶
type MetricRole int
type and display for OpenshiftPtpInterfaceRole metric. Values: 0 = PASSIVE, 1 = SLAVE, 2 = MASTER, 3 = FAULTY, 4 = UNKNOWN
const ( MetricRolePassive MetricRole = iota MetricRoleSlave MetricRoleMaster MetricRoleFaulty MetricRoleUnknown )