summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCosta Tsaousis <costa@tsaousis.gr>2018-07-08 02:45:19 +0300
committerGitHub <noreply@github.com>2018-07-08 02:45:19 +0300
commit723651c4fdac9e38c7f4a2f4ceb8d4e2920e81b6 (patch)
treedd69c9dc065e5ce16ddfe42b2e84bac4382947fb
parent3fa750306772e3d5f0b0e43d4c1a764b5ec3f383 (diff)
parent07f25d0ae94c7e4fd1fd8c4463c62d31f6a0be42 (diff)
Merge branch 'master' into ms_team_notification_support
-rw-r--r--CONTRIBUTORS.md5
-rw-r--r--conf.d/Makefile.am1
-rw-r--r--conf.d/health.d/apcupsd.conf40
-rw-r--r--configs.signatures1
-rwxr-xr-xplugins.d/charts.d.plugin2
-rw-r--r--python.d/redis.chart.py2
-rw-r--r--python.d/tomcat.chart.py18
-rw-r--r--src/main.c1
-rw-r--r--src/rrdpush.c28
-rw-r--r--src/web_server.c1
-rw-r--r--src/web_server.h1
-rw-r--r--web/index.html4
12 files changed, 91 insertions, 13 deletions
diff --git a/CONTRIBUTORS.md b/CONTRIBUTORS.md
index 05b736569d..b8d4cad0d2 100644
--- a/CONTRIBUTORS.md
+++ b/CONTRIBUTORS.md
@@ -88,4 +88,9 @@ username|name|email (optional)
@davidak|David Kleuker|netdata-contributors+vyff@davidak.de
@ccremer|Christian Cremer|
@jimcooley|Jim Cooley|jim.cooley@healthvana.com
+@Chocobo1|Mike Tzou|
+@cosmix|Dimosthenis Kaponis|
+@shadycuz|Levi Blaney|shadycuz+spam@gmail.com
+@Flums|Philip Gabrielsen|philip@digno.no
+@domschl|Dominik Schlösser|dominik.schloesser@gmail.com
@tioumen|Guillaume Hospital
diff --git a/conf.d/Makefile.am b/conf.d/Makefile.am
index 72807b6804..7bd3622f65 100644
--- a/conf.d/Makefile.am
+++ b/conf.d/Makefile.am
@@ -88,6 +88,7 @@ healthconfigdir=$(configdir)/health.d
dist_healthconfig_DATA = \
health.d/apache.conf \
+ health.d/apcupsd.conf \
health.d/backend.conf \
health.d/bcache.conf \
health.d/beanstalkd.conf \
diff --git a/conf.d/health.d/apcupsd.conf b/conf.d/health.d/apcupsd.conf
new file mode 100644
index 0000000000..214974e230
--- /dev/null
+++ b/conf.d/health.d/apcupsd.conf
@@ -0,0 +1,40 @@
+# you can disable an alarm notification by setting the 'to' line to: silent
+
+template: 10min_ups_load
+ on: apcupsd.load
+ os: *
+ hosts: *
+ lookup: average -10m unaligned of percentage
+ units: %
+ every: 1m
+ warn: $this > (($status >= $WARNING) ? (70) : (80))
+ crit: $this > (($status == $CRITICAL) ? (85) : (95))
+ delay: down 10m multiplier 1.5 max 1h
+ info: average UPS load for the last 10 minutes
+ to: sitemgr
+
+# Discussion in https://github.com/firehol/netdata/pull/3928:
+# Fire the alarm as soon as it's going on battery (99% charge) and clear only when full.
+template: ups_charge
+ on: apcupsd.charge
+ os: *
+ hosts: *
+ lookup: average -60s unaligned of charge
+ units: %
+ every: 60s
+ warn: $this < 100
+ crit: $this < (($status == $CRITICAL) ? (60) : (50))
+ delay: down 10m multiplier 1.5 max 1h
+ info: current UPS charge, averaged over the last 60 seconds to reduce measurement errors
+ to: sitemgr
+
+template: apcupsd_last_collected_secs
+ on: apcupsd.load
+ calc: $now - $last_collected_t
+ every: 10s
+ units: seconds ago
+ warn: $this > (($status >= $WARNING) ? ($update_every) : ( 5 * $update_every))
+ crit: $this > (($status == $CRITICAL) ? ($update_every) : (60 * $update_every))
+ delay: down 5m multiplier 1.5 max 1h
+ info: number of seconds since the last successful data collection
+ to: sitemgr
diff --git a/configs.signatures b/configs.signatures
index 1c6b7fc908..04b2a79205 100644
--- a/configs.signatures
+++ b/configs.signatures
@@ -586,6 +586,7 @@ declare -A configs_signatures=(
['ce0fa3485a0d8d3aa80b25ab0c70cc5a']='charts.d/apcupsd.conf'
['ce2e8768964a936f58c4c2144aee8a01']='health_alarm_notify.conf'
['ce3b65eac6c472b21905f7f72104f4c9']='python.d/nginx.conf'
+ ['ce937f8b9ab7820b61ce9fcde6b946e8']='charts.d/nut.conf'
['cf2c9096b3a8c506a3ec76fa52574395']='charts.d/phpfpm.conf'
['cf46545065f7698c4d529fdc77955274']='python.d/puppet.conf'
['cf48dfd828af70bea04db7a809f94358']='health.d/haproxy.conf'
diff --git a/plugins.d/charts.d.plugin b/plugins.d/charts.d.plugin
index 544f863215..4a390a85fd 100755
--- a/plugins.d/charts.d.plugin
+++ b/plugins.d/charts.d.plugin
@@ -297,7 +297,7 @@ run() {
{
printf "$(logdate): ${PROGRAM_NAME}: ${status}: ${MODULE_NAME}: command '"
printf "%q " "${@}"
- printf "' failed:\n --- BEGIN TRACE ---\n"
+ printf "' failed with code ${ret}:\n --- BEGIN TRACE ---\n"
cat "${TMP_DIR}/run.${pid}"
printf " --- END TRACE ---\n"
} >&2
diff --git a/python.d/redis.chart.py b/python.d/redis.chart.py
index a40932b3aa..f924d55bf5 100644
--- a/python.d/redis.chart.py
+++ b/python.d/redis.chart.py
@@ -152,7 +152,7 @@ class Service(SocketService):
resp = self._get_raw_data(request=self.auth_request)
if not resp:
return False
- if not resp.strip() != '+OK':
+ if resp.strip() != '+OK':
self.error("invalid password")
return False
return True
diff --git a/python.d/tomcat.chart.py b/python.d/tomcat.chart.py
index 148e5db546..7699c582f6 100644
--- a/python.d/tomcat.chart.py
+++ b/python.d/tomcat.chart.py
@@ -54,21 +54,21 @@ CHARTS = {
'options': [None, "Eden Memory Usage", "MB", "memory", "tomcat.jvm_eden", "area"],
'lines': [
["eden_used", 'used', "absolute", 1, 1048576],
- ["eden_commited", 'commited', "absolute", 1, 1048576],
+ ["eden_committed", 'committed', "absolute", 1, 1048576],
["eden_max", 'max', "absolute", 1, 1048576]
]},
'jvm_survivor': {
'options': [None, "Survivor Memory Usage", "MB", "memory", "tomcat.jvm_survivor", "area"],
'lines': [
["survivor_used", 'used', "absolute", 1, 1048576],
- ["survivor_commited", 'commited', "absolute", 1, 1048576],
+ ["survivor_committed", 'committed', "absolute", 1, 1048576],
["survivor_max", 'max', "absolute", 1, 1048576]
]},
'jvm_tenured': {
'options': [None, "Tenured Memory Usage", "MB", "memory", "tomcat.jvm_tenured", "area"],
'lines': [
["tenured_used", 'used', "absolute", 1, 1048576],
- ["tenured_commited", 'commited', "absolute", 1, 1048576],
+ ["tenured_committed", 'committed', "absolute", 1, 1048576],
["tenured_max", 'max', "absolute", 1, 1048576]
]},
}
@@ -116,27 +116,27 @@ class Service(UrlService):
name = pool.get('name')
if 'Eden Space' in name:
data['eden_used'] = pool.get('usageUsed')
- data['eden_commited'] = pool.get('usageCommitted')
+ data['eden_committed'] = pool.get('usageCommitted')
data['eden_max'] = pool.get('usageMax')
elif 'Survivor Space' in name:
data['survivor_used'] = pool.get('usageUsed')
- data['survivor_commited'] = pool.get('usageCommitted')
+ data['survivor_committed'] = pool.get('usageCommitted')
data['survivor_max'] = pool.get('usageMax')
elif 'Tenured Gen' in name or 'Old Gen' in name:
data['tenured_used'] = pool.get('usageUsed')
- data['tenured_commited'] = pool.get('usageCommitted')
+ data['tenured_committed'] = pool.get('usageCommitted')
data['tenured_max'] = pool.get('usageMax')
elif name == 'Code Cache':
data['code_cache_used'] = pool.get('usageUsed')
- data['code_cache_commited'] = pool.get('usageCommitted')
+ data['code_cache_committed'] = pool.get('usageCommitted')
data['code_cache_max'] = pool.get('usageMax')
elif name == 'Compressed':
data['compressed_used'] = pool.get('usageUsed')
- data['compressed_commited'] = pool.get('usageCommitted')
+ data['compressed_committed'] = pool.get('usageCommitted')
data['compressed_max'] = pool.get('usageMax')
elif name == 'Metaspace':
data['metaspace_used'] = pool.get('usageUsed')
- data['metaspace_commited'] = pool.get('usageCommitted')
+ data['metaspace_committed'] = pool.get('usageCommitted')
data['metaspace_max'] = pool.get('usageMax')
if connector:
diff --git a/src/main.c b/src/main.c
index 277ffcdae2..9443095561 100644
--- a/src/main.c
+++ b/src/main.c
@@ -102,6 +102,7 @@ void web_server_threading_selection(void) {
void web_server_config_options(void) {
web_client_timeout = (int) config_get_number(CONFIG_SECTION_WEB, "disconnect idle clients after seconds", web_client_timeout);
web_client_first_request_timeout = (int) config_get_number(CONFIG_SECTION_WEB, "timeout for first request", web_client_first_request_timeout);
+ web_client_streaming_rate_t = config_get_number(CONFIG_SECTION_WEB, "accept a streaming request every seconds", web_client_streaming_rate_t);
respect_web_browser_do_not_track_policy = config_get_boolean(CONFIG_SECTION_WEB, "respect do not track policy", respect_web_browser_do_not_track_policy);
web_x_frame_options = config_get(CONFIG_SECTION_WEB, "x-frame-options response header", "");
diff --git a/src/rrdpush.c b/src/rrdpush.c
index 68def2247b..c28512ee05 100644
--- a/src/rrdpush.c
+++ b/src/rrdpush.c
@@ -1006,6 +1006,14 @@ int rrdpush_receiver_permission_denied(struct web_client *w) {
return 401;
}
+int rrdpush_receiver_too_busy_now(struct web_client *w) {
+ // we always respond with the same message and error code
+ // to prevent an attacker from gaining info about the error
+ buffer_flush(w->response.data);
+ buffer_sprintf(w->response.data, "The server is too busy now to accept this request. Try later.");
+ return 503;
+}
+
int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url) {
(void)host;
@@ -1111,6 +1119,26 @@ int rrdpush_receiver_thread_spawn(RRDHOST *host, struct web_client *w, char *url
}
}
+ if(unlikely(web_client_streaming_rate_t > 0)) {
+ static netdata_mutex_t stream_rate_mutex = NETDATA_MUTEX_INITIALIZER;
+ static volatile time_t last_stream_accepted_t = 0;
+
+ netdata_mutex_lock(&stream_rate_mutex);
+ time_t now = now_realtime_sec();
+
+ if(unlikely(last_stream_accepted_t == 0))
+ last_stream_accepted_t = now;
+
+ if(now - last_stream_accepted_t < web_client_streaming_rate_t) {
+ netdata_mutex_unlock(&stream_rate_mutex);
+ error("STREAM [receive from [%s]:%s]: too busy to accept new streaming request. Will be allowed in %ld secs.", w->client_ip, w->client_port, (long)(web_client_streaming_rate_t - (now - last_stream_accepted_t)));
+ return rrdpush_receiver_too_busy_now(w);
+ }
+
+ last_stream_accepted_t = now;
+ netdata_mutex_unlock(&stream_rate_mutex);
+ }
+
struct rrdpush_thread *rpt = callocz(1, sizeof(struct rrdpush_thread));
rpt->fd = w->ifd;
rpt->key = strdupz(key);
diff --git a/src/web_server.c b/src/web_server.c
index 8c0aae46b5..ee8dddf7b9 100644
--- a/src/web_server.c
+++ b/src/web_server.c
@@ -409,6 +409,7 @@ static struct web_client *web_client_create_on_listenfd(int listener) {
int web_client_timeout = DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS;
int web_client_first_request_timeout = DEFAULT_TIMEOUT_TO_RECEIVE_FIRST_WEB_REQUEST;
+long web_client_streaming_rate_t = 0L;
static void multi_threaded_web_client_worker_main_cleanup(void *ptr) {
struct web_client *w = ptr;
diff --git a/src/web_server.h b/src/web_server.h
index 3542f30b26..3b7db2214a 100644
--- a/src/web_server.h
+++ b/src/web_server.h
@@ -43,5 +43,6 @@ extern int api_listen_sockets_setup(void);
#define DEFAULT_DISCONNECT_IDLE_WEB_CLIENTS_AFTER_SECONDS 60
extern int web_client_timeout;
extern int web_client_first_request_timeout;
+extern long web_client_streaming_rate_t;
#endif /* NETDATA_WEB_SERVER_H */
diff --git a/web/index.html b/web/index.html
index 29e2a292c0..42a9a1007b 100644
--- a/web/index.html
+++ b/web/index.html
@@ -4406,7 +4406,7 @@
});
NETDATA.requiredJs.push({
- url: NETDATA.serverStatic + 'dashboard_info.js?v20180622-1',
+ url: NETDATA.serverStatic + 'dashboard_info.js?v20180628-1',
async: false,
isAlreadyLoaded: function() { return false; }
});
@@ -5728,6 +5728,6 @@
</div>
</div>
<div id="hiddenDownloadLinks" style="display: none;" hidden></div>
- <script type="text/javascript" src="dashboard.js?v20180622-1"></script>
+ <script type="text/javascript" src="dashboard.js?v20180628-1"></script>
</body>
</html>