001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.actuate.autoconfigure.metrics.export.ganglia;
018
019import java.time.Duration;
020import java.util.concurrent.TimeUnit;
021
022import info.ganglia.gmetric4j.gmetric.GMetric;
023
024import org.springframework.boot.context.properties.ConfigurationProperties;
025
026/**
027 * {@link ConfigurationProperties} for configuring Ganglia metrics export.
028 *
029 * @author Jon Schneider
030 * @author Stephane Nicoll
031 * @since 2.0.0
032 */
033@ConfigurationProperties(prefix = "management.metrics.export.ganglia")
034public class GangliaProperties {
035
036        /**
037         * Whether exporting of metrics to Ganglia is enabled.
038         */
039        private boolean enabled = true;
040
041        /**
042         * Step size (i.e. reporting frequency) to use.
043         */
044        private Duration step = Duration.ofMinutes(1);
045
046        /**
047         * Base time unit used to report rates.
048         */
049        private TimeUnit rateUnits = TimeUnit.SECONDS;
050
051        /**
052         * Base time unit used to report durations.
053         */
054        private TimeUnit durationUnits = TimeUnit.MILLISECONDS;
055
056        /**
057         * Ganglia protocol version. Must be either 3.1 or 3.0.
058         */
059        private String protocolVersion = "3.1";
060
061        /**
062         * UDP addressing mode, either unicast or multicast.
063         */
064        private GMetric.UDPAddressingMode addressingMode = GMetric.UDPAddressingMode.MULTICAST;
065
066        /**
067         * Time to live for metrics on Ganglia. Set the multi-cast Time-To-Live to be one
068         * greater than the number of hops (routers) between the hosts.
069         */
070        private Integer timeToLive = 1;
071
072        /**
073         * Host of the Ganglia server to receive exported metrics.
074         */
075        private String host = "localhost";
076
077        /**
078         * Port of the Ganglia server to receive exported metrics.
079         */
080        private Integer port = 8649;
081
082        public boolean isEnabled() {
083                return this.enabled;
084        }
085
086        public void setEnabled(boolean enabled) {
087                this.enabled = enabled;
088        }
089
090        public Duration getStep() {
091                return this.step;
092        }
093
094        public void setStep(Duration step) {
095                this.step = step;
096        }
097
098        public TimeUnit getRateUnits() {
099                return this.rateUnits;
100        }
101
102        public void setRateUnits(TimeUnit rateUnits) {
103                this.rateUnits = rateUnits;
104        }
105
106        public TimeUnit getDurationUnits() {
107                return this.durationUnits;
108        }
109
110        public void setDurationUnits(TimeUnit durationUnits) {
111                this.durationUnits = durationUnits;
112        }
113
114        public String getProtocolVersion() {
115                return this.protocolVersion;
116        }
117
118        public void setProtocolVersion(String protocolVersion) {
119                this.protocolVersion = protocolVersion;
120        }
121
122        public GMetric.UDPAddressingMode getAddressingMode() {
123                return this.addressingMode;
124        }
125
126        public void setAddressingMode(GMetric.UDPAddressingMode addressingMode) {
127                this.addressingMode = addressingMode;
128        }
129
130        public Integer getTimeToLive() {
131                return this.timeToLive;
132        }
133
134        public void setTimeToLive(Integer timeToLive) {
135                this.timeToLive = timeToLive;
136        }
137
138        public String getHost() {
139                return this.host;
140        }
141
142        public void setHost(String host) {
143                this.host = host;
144        }
145
146        public Integer getPort() {
147                return this.port;
148        }
149
150        public void setPort(Integer port) {
151                this.port = port;
152        }
153
154}