summaryrefslogtreecommitdiffstats
path: root/web
diff options
context:
space:
mode:
authorLennart Weller <lhw@ring0.de>2016-09-05 08:27:21 +0000
committerLennart Weller <lhw@ring0.de>2016-09-05 08:27:21 +0000
commit1746898cefcb17f58b5cf27b4dad3d28236f1152 (patch)
tree9207f191cf39bbd077a1e1c73d6e82123e2fc710 /web
parentImported Upstream version 1.2.0+dfsg (diff)
downloadnetdata-1746898cefcb17f58b5cf27b4dad3d28236f1152.tar.xz
netdata-1746898cefcb17f58b5cf27b4dad3d28236f1152.zip
Imported Upstream version 1.3.0+dfsgupstream/1.3.0+dfsg
Diffstat (limited to 'web')
-rw-r--r--web/.well-known/dnt/cookies14
-rw-r--r--web/Makefile.am13
-rw-r--r--web/Makefile.in108
-rw-r--r--web/dashboard.css13
-rw-r--r--web/dashboard.html997
-rw-r--r--web/dashboard.js11505
-rw-r--r--web/dashboard.slate.css13
-rw-r--r--web/demo.html69
-rw-r--r--web/demo2.html243
-rw-r--r--web/demosites.html1628
-rw-r--r--web/images/animated.gifbin0 -> 389597 bytes
-rw-r--r--web/images/post.pngbin0 -> 10317 bytes
-rw-r--r--web/index.html4913
-rw-r--r--web/netdata-swagger.json169
-rw-r--r--web/netdata-swagger.yaml126
-rw-r--r--web/registry.html203
-rw-r--r--web/tv.html473
-rw-r--r--web/version.txt2
18 files changed, 11156 insertions, 9333 deletions
diff --git a/web/.well-known/dnt/cookies b/web/.well-known/dnt/cookies
new file mode 100644
index 000000000..dc2fe0b4a
--- /dev/null
+++ b/web/.well-known/dnt/cookies
@@ -0,0 +1,14 @@
+{
+ "tracking": "T",
+ "compliance": ["https://github.com/firehol/netdata/wiki/cookies#compliance"],
+ "qualifiers": "afc",
+ "controller": ["https://github.com/firehol/netdata/wiki/cookies#controller"],
+ "same-party": [
+ "my-netdata.io",
+ "mynetdata.io",
+ "netdata.online",
+ "netdata.rocks",
+ "registry.my-netdata.io"
+ ],
+ "policy": "https://github.com/firehol/netdata/wiki/cookies#policy",
+}
diff --git a/web/Makefile.am b/web/Makefile.am
index 174ef229b..0432f8a58 100644
--- a/web/Makefile.am
+++ b/web/Makefile.am
@@ -16,6 +16,7 @@ dist_web_DATA = \
netdata-swagger.yaml \
netdata-swagger.json \
robots.txt \
+ registry.html \
tv.html \
version.txt \
$(NULL)
@@ -77,6 +78,8 @@ dist_webfonts_DATA = \
webimagesdir=$(webdir)/images
dist_webimages_DATA = \
+ images/animated.gif \
+ images/post.png \
images/seo-performance-16.png \
images/seo-performance-24.png \
images/seo-performance-32.png \
@@ -91,6 +94,16 @@ dist_webimages_DATA = \
images/seo-performance-multi-size.icns \
$(NULL)
+
+webwellknowndir=$(webdir)/.well-known
+dist_webwellknown_DATA = \
+ $(NULL)
+
+webdntdir=$(webdir)/.well-known/dnt
+dist_webdnt_DATA = \
+ .well-known/dnt/cookies \
+ $(NULL)
+
version.txt:
if test -d "$(top_srcdir)/.git"; then \
git --git-dir="$(top_srcdir)/.git" log -n 1 --format=%H; \
diff --git a/web/Makefile.in b/web/Makefile.in
index e95290128..6e5e46a91 100644
--- a/web/Makefile.in
+++ b/web/Makefile.in
@@ -80,8 +80,10 @@ build_triplet = @build@
host_triplet = @host@
subdir = web
DIST_COMMON = $(srcdir)/Makefile.in $(srcdir)/Makefile.am \
- $(dist_web_DATA) $(dist_webcss_DATA) $(dist_webfonts_DATA) \
- $(dist_webimages_DATA) $(dist_weblib_DATA) $(dist_webold_DATA)
+ $(dist_web_DATA) $(dist_webcss_DATA) $(dist_webdnt_DATA) \
+ $(dist_webfonts_DATA) $(dist_webimages_DATA) \
+ $(dist_weblib_DATA) $(dist_webold_DATA) \
+ $(dist_webwellknown_DATA)
ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
am__aclocal_m4_deps = $(top_srcdir)/m4/ax_pthread.m4 \
$(top_srcdir)/configure.ac
@@ -138,10 +140,13 @@ am__uninstall_files_from_dir = { \
$(am__cd) "$$dir" && rm -f $$files; }; \
}
am__installdirs = "$(DESTDIR)$(webdir)" "$(DESTDIR)$(webcssdir)" \
- "$(DESTDIR)$(webfontsdir)" "$(DESTDIR)$(webimagesdir)" \
- "$(DESTDIR)$(weblibdir)" "$(DESTDIR)$(webolddir)"
-DATA = $(dist_web_DATA) $(dist_webcss_DATA) $(dist_webfonts_DATA) \
- $(dist_webimages_DATA) $(dist_weblib_DATA) $(dist_webold_DATA)
+ "$(DESTDIR)$(webdntdir)" "$(DESTDIR)$(webfontsdir)" \
+ "$(DESTDIR)$(webimagesdir)" "$(DESTDIR)$(weblibdir)" \
+ "$(DESTDIR)$(webolddir)" "$(DESTDIR)$(webwellknowndir)"
+DATA = $(dist_web_DATA) $(dist_webcss_DATA) $(dist_webdnt_DATA) \
+ $(dist_webfonts_DATA) $(dist_webimages_DATA) \
+ $(dist_weblib_DATA) $(dist_webold_DATA) \
+ $(dist_webwellknown_DATA)
am__tagged_files = $(HEADERS) $(SOURCES) $(TAGS_FILES) $(LISP)
DISTFILES = $(DIST_COMMON) $(DIST_SOURCES) $(TEXINFOS) $(EXTRA_DIST)
ACLOCAL = @ACLOCAL@
@@ -265,6 +270,8 @@ pluginsdir = @pluginsdir@
prefix = @prefix@
program_transform_name = @program_transform_name@
psdir = @psdir@
+pythondir = @pythondir@
+registrydir = @registrydir@
sbindir = @sbindir@
sharedstatedir = @sharedstatedir@
srcdir = @srcdir@
@@ -293,6 +300,7 @@ dist_web_DATA = \
netdata-swagger.yaml \
netdata-swagger.json \
robots.txt \
+ registry.html \
tv.html \
version.txt \
$(NULL)
@@ -354,6 +362,8 @@ dist_webfonts_DATA = \
webimagesdir = $(webdir)/images
dist_webimages_DATA = \
+ images/animated.gif \
+ images/post.png \
images/seo-performance-16.png \
images/seo-performance-24.png \
images/seo-performance-32.png \
@@ -368,6 +378,15 @@ dist_webimages_DATA = \
images/seo-performance-multi-size.icns \
$(NULL)
+webwellknowndir = $(webdir)/.well-known
+dist_webwellknown_DATA = \
+ $(NULL)
+
+webdntdir = $(webdir)/.well-known/dnt
+dist_webdnt_DATA = \
+ .well-known/dnt/cookies \
+ $(NULL)
+
all: all-am
.SUFFIXES:
@@ -443,6 +462,27 @@ uninstall-dist_webcssDATA:
@list='$(dist_webcss_DATA)'; test -n "$(webcssdir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(webcssdir)'; $(am__uninstall_files_from_dir)
+install-dist_webdntDATA: $(dist_webdnt_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(dist_webdnt_DATA)'; test -n "$(webdntdir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(webdntdir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(webdntdir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(webdntdir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(webdntdir)" || exit $$?; \
+ done
+
+uninstall-dist_webdntDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(dist_webdnt_DATA)'; test -n "$(webdntdir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(webdntdir)'; $(am__uninstall_files_from_dir)
install-dist_webfontsDATA: $(dist_webfonts_DATA)
@$(NORMAL_INSTALL)
@list='$(dist_webfonts_DATA)'; test -n "$(webfontsdir)" || list=; \
@@ -527,6 +567,27 @@ uninstall-dist_weboldDATA:
@list='$(dist_webold_DATA)'; test -n "$(webolddir)" || list=; \
files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
dir='$(DESTDIR)$(webolddir)'; $(am__uninstall_files_from_dir)
+install-dist_webwellknownDATA: $(dist_webwellknown_DATA)
+ @$(NORMAL_INSTALL)
+ @list='$(dist_webwellknown_DATA)'; test -n "$(webwellknowndir)" || list=; \
+ if test -n "$$list"; then \
+ echo " $(MKDIR_P) '$(DESTDIR)$(webwellknowndir)'"; \
+ $(MKDIR_P) "$(DESTDIR)$(webwellknowndir)" || exit 1; \
+ fi; \
+ for p in $$list; do \
+ if test -f "$$p"; then d=; else d="$(srcdir)/"; fi; \
+ echo "$$d$$p"; \
+ done | $(am__base_list) | \
+ while read files; do \
+ echo " $(INSTALL_DATA) $$files '$(DESTDIR)$(webwellknowndir)'"; \
+ $(INSTALL_DATA) $$files "$(DESTDIR)$(webwellknowndir)" || exit $$?; \
+ done
+
+uninstall-dist_webwellknownDATA:
+ @$(NORMAL_UNINSTALL)
+ @list='$(dist_webwellknown_DATA)'; test -n "$(webwellknowndir)" || list=; \
+ files=`for p in $$list; do echo $$p; done | sed -e 's|^.*/||'`; \
+ dir='$(DESTDIR)$(webwellknowndir)'; $(am__uninstall_files_from_dir)
tags TAGS:
ctags CTAGS:
@@ -568,7 +629,7 @@ check-am: all-am
check: check-am
all-am: Makefile $(DATA)
installdirs:
- for dir in "$(DESTDIR)$(webdir)" "$(DESTDIR)$(webcssdir)" "$(DESTDIR)$(webfontsdir)" "$(DESTDIR)$(webimagesdir)" "$(DESTDIR)$(weblibdir)" "$(DESTDIR)$(webolddir)"; do \
+ for dir in "$(DESTDIR)$(webdir)" "$(DESTDIR)$(webcssdir)" "$(DESTDIR)$(webdntdir)" "$(DESTDIR)$(webfontsdir)" "$(DESTDIR)$(webimagesdir)" "$(DESTDIR)$(weblibdir)" "$(DESTDIR)$(webolddir)" "$(DESTDIR)$(webwellknowndir)"; do \
test -z "$$dir" || $(MKDIR_P) "$$dir"; \
done
install: install-am
@@ -623,8 +684,9 @@ info: info-am
info-am:
install-data-am: install-dist_webDATA install-dist_webcssDATA \
- install-dist_webfontsDATA install-dist_webimagesDATA \
- install-dist_weblibDATA install-dist_weboldDATA
+ install-dist_webdntDATA install-dist_webfontsDATA \
+ install-dist_webimagesDATA install-dist_weblibDATA \
+ install-dist_weboldDATA install-dist_webwellknownDATA
install-dvi: install-dvi-am
@@ -669,8 +731,9 @@ ps: ps-am
ps-am:
uninstall-am: uninstall-dist_webDATA uninstall-dist_webcssDATA \
- uninstall-dist_webfontsDATA uninstall-dist_webimagesDATA \
- uninstall-dist_weblibDATA uninstall-dist_weboldDATA
+ uninstall-dist_webdntDATA uninstall-dist_webfontsDATA \
+ uninstall-dist_webimagesDATA uninstall-dist_weblibDATA \
+ uninstall-dist_weboldDATA uninstall-dist_webwellknownDATA
.MAKE: install-am install-strip
@@ -678,17 +741,20 @@ uninstall-am: uninstall-dist_webDATA uninstall-dist_webcssDATA \
ctags-am distclean distclean-generic distdir dvi dvi-am html \
html-am info info-am install install-am install-data \
install-data-am install-dist_webDATA install-dist_webcssDATA \
- install-dist_webfontsDATA install-dist_webimagesDATA \
- install-dist_weblibDATA install-dist_weboldDATA install-dvi \
- install-dvi-am install-exec install-exec-am install-html \
- install-html-am install-info install-info-am install-man \
- install-pdf install-pdf-am install-ps install-ps-am \
- install-strip installcheck installcheck-am installdirs \
- maintainer-clean maintainer-clean-generic mostlyclean \
- mostlyclean-generic pdf pdf-am ps ps-am tags-am uninstall \
- uninstall-am uninstall-dist_webDATA uninstall-dist_webcssDATA \
+ install-dist_webdntDATA install-dist_webfontsDATA \
+ install-dist_webimagesDATA install-dist_weblibDATA \
+ install-dist_weboldDATA install-dist_webwellknownDATA \
+ install-dvi install-dvi-am install-exec install-exec-am \
+ install-html install-html-am install-info install-info-am \
+ install-man install-pdf install-pdf-am install-ps \
+ install-ps-am install-strip installcheck installcheck-am \
+ installdirs maintainer-clean maintainer-clean-generic \
+ mostlyclean mostlyclean-generic pdf pdf-am ps ps-am tags-am \
+ uninstall uninstall-am uninstall-dist_webDATA \
+ uninstall-dist_webcssDATA uninstall-dist_webdntDATA \
uninstall-dist_webfontsDATA uninstall-dist_webimagesDATA \
- uninstall-dist_weblibDATA uninstall-dist_weboldDATA
+ uninstall-dist_weblibDATA uninstall-dist_weboldDATA \
+ uninstall-dist_webwellknownDATA
version.txt:
diff --git a/web/dashboard.css b/web/dashboard.css
index 63e2b905f..eb2ed1b0d 100644
--- a/web/dashboard.css
+++ b/web/dashboard.css
@@ -6,6 +6,19 @@ body {
font-variant: normal;
}
+.morelink {
+ color: #765d9c;
+ text-decoration: none;
+}
+.morelink:hover {
+ color: #563d7c;
+ text-decoration: none;
+}
+.morelink:focus {
+ color: #765d9c;
+ text-decoration: none;
+}
+
.netdata-chart-alignment {
margin-left: 55px;
}
diff --git a/web/dashboard.html b/web/dashboard.html
index 2b6c80684..e5d01353f 100644
--- a/web/dashboard.html
+++ b/web/dashboard.html
@@ -1,15 +1,24 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <title>NetData Dashboard</title>
-
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <meta name="author" content="costa@tsaousis.gr">
+ <title>NetData Dashboard</title>
+ <meta name="application-name" content="netdata">
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+ <meta name="author" content="costa@tsaousis.gr">
+
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image" content="https://my-netdata.io/images/seo-performance-512.png"/>
+ <meta property="og:url" content="http://my-netdata.io/"/>
+ <meta property="og:type" content="website"/>
+ <meta property="og:site_name" content="netdata"/>
+ <meta property="og:title" content="netdata - real-time performance monitoring, done right!"/>
+ <meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
</head>
<body>
@@ -23,33 +32,33 @@ This is a template for building custom dashboards. To build a dashboard you just
&lt;!DOCTYPE html>
&lt;html lang="en">
&lt;head>
- &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8">
- &lt;meta charset="utf-8">
- &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- &lt;meta name="viewport" content="width=device-width, initial-scale=1">
- &lt;meta name="apple-mobile-web-app-capable" content="yes">
- &lt;meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+ &lt;meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+ &lt;meta charset="utf-8">
+ &lt;meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ &lt;meta name="viewport" content="width=device-width, initial-scale=1">
+ &lt;meta name="apple-mobile-web-app-capable" content="yes">
+ &lt;meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
&lt;/head>
&lt;body>
- &lt;div data-netdata="system.processes"
- data-chart-library="dygraph"
- data-width="600"
- data-height="200"
- data-after="-600"
- >&lt;/div>
+ &lt;div data-netdata="system.processes"
+ data-chart-library="dygraph"
+ data-width="600"
+ data-height="200"
+ data-after="-600"
+ >&lt;/div>
&lt;/body>
&lt;script type="text/javascript" src="http://netdata.server:19999/dashboard.js">&lt;/script>
&lt;/html>
</pre>
<ul>
- <li>You can host your dashboard anywhere.</li>
- <li>You can add as many charts as you like.</li>
- <li>You can have charts from many different netdata servers (add <pre>data-host="http://another.netdata.server:19999/"</pre> to each chart).</li>
- <li>You can use different chart libraries on the same page: <b>peity</b>, <b>sparkline</b>, <b>dygraph</b>, <b>google</b>, <b>morris</b></li>
- <li>You can customize each chart to your preferences. For each chart library most of their attributes can be given in <b>data-</b> attributes.</li>
- <li>Each chart can have each own duration - it is controlled with the <b>data-after</b> attribute to give that many seconds of data.</li>
- <li>Depending on the width of the chart and <b>data-after</b> attribute, netdata will automatically refresh the chart when it needs to be updated. For example giving 600 pixels for width for -600 seconds of data, using a chart library that needs 3 pixels per point, will yeld in a chart updated once every 3 seconds.</li>
+ <li>You can host your dashboard anywhere.</li>
+ <li>You can add as many charts as you like.</li>
+ <li>You can have charts from many different netdata servers (add <pre>data-host="http://another.netdata.server:19999/"</pre> to each chart).</li>
+ <li>You can use different chart libraries on the same page: <b>peity</b>, <b>sparkline</b>, <b>dygraph</b>, <b>google</b>, <b>morris</b></li>
+ <li>You can customize each chart to your preferences. For each chart library most of their attributes can be given in <b>data-</b> attributes.</li>
+ <li>Each chart can have each own duration - it is controlled with the <b>data-after</b> attribute to give that many seconds of data.</li>
+ <li>Depending on the width of the chart and <b>data-after</b> attribute, netdata will automatically refresh the chart when it needs to be updated. For example giving 600 pixels for width for -600 seconds of data, using a chart library that needs 3 pixels per point, will yeld in a chart updated once every 3 seconds.</li>
</ul>
@@ -60,61 +69,61 @@ Sparkline charts stretch the values to show the variations between values in mor
They also have mouse-hover support.
<br/>
<b>Sparklines are fantastic</b>. You can inline charts in text. For example this
- <div data-netdata="system.cpu"
- data-chart-library="sparkline"
- data-width="5%"
- data-height="20"
- data-after="-30"
- ></div> is my current cpu usage (last 30 seconds),
- while this
- <div data-netdata="netdata.net"
- data-dimensions="out"
- data-chart-library="sparkline"
- data-width="10%"
- data-height="20"
- data-after="-60"
- ></div> is the bandwidth my netdata server is currently transmitting (last minute)
- and this
- <div data-netdata="netdata.requests"
- data-chart-library="sparkline"
- data-width="20%"
- data-height="20"
- data-after="-180"
- ></div> is the requests/sec it serves (last 3 minutes).
+ <div data-netdata="system.cpu"
+ data-chart-library="sparkline"
+ data-width="5%"
+ data-height="20"
+ data-after="-30"
+ ></div> is my current cpu usage (last 30 seconds),
+ while this
+ <div data-netdata="netdata.net"
+ data-dimensions="out"
+ data-chart-library="sparkline"
+ data-width="10%"
+ data-height="20"
+ data-after="-60"
+ ></div> is the bandwidth my netdata server is currently transmitting (last minute)
+ and this
+ <div data-netdata="netdata.requests"
+ data-chart-library="sparkline"
+ data-width="20%"
+ data-height="20"
+ data-after="-180"
+ ></div> is the requests/sec it serves (last 3 minutes).
<br/>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.processes"
- data-chart-library="sparkline"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time101"
- ></div>
- <br/>
- <small>rendered in <span id="time101">X</span> ms</small>
+ <div data-netdata="system.processes"
+ data-chart-library="sparkline"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time101"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time101">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.ipv4"
- data-chart-library="sparkline"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time102"
- ></div>
- <br/>
- <small>rendered in <span id="time102">X</span> ms</small>
+ <div data-netdata="system.ipv4"
+ data-chart-library="sparkline"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time102"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time102">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.cpu"
- data-chart-library="sparkline"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time103"
- ></div>
- <br/>
- <small>rendered in <span id="time103">X</span> ms</small>
+ <div data-netdata="system.cpu"
+ data-chart-library="sparkline"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time103"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time103">X</span> ms</small>
</div>
@@ -126,37 +135,37 @@ Peity charts cannot have multiple dimensions on the charts - so netdata will use
the total of all dimensions.
<br/>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.processes"
- data-chart-library="peity"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time001"
- ></div>
- <br/>
- <small>rendered in <span id="time001">X</span> ms</small>
+ <div data-netdata="system.processes"
+ data-chart-library="peity"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time001"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time001">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.ipv4"
- data-chart-library="peity"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time002"
- ></div>
- <br/>
- <small>rendered in <span id="time002">X</span> ms</small>
+ <div data-netdata="system.ipv4"
+ data-chart-library="peity"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time002"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time002">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.cpu"
- data-chart-library="peity"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time003"
- ></div>
- <br/>
- <small>rendered in <span id="time003">X</span> ms</small>
+ <div data-netdata="system.cpu"
+ data-chart-library="peity"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time003"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time003">X</span> ms</small>
</div>
@@ -169,173 +178,173 @@ The charts are zoomable (drag their contents to pan, shift with mouse wheel to z
<b>Netdata magic!</b> Realtime charts on your web page!
<br/>
Sparklines using dygraphs
- <div data-netdata="system.processes"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-legend="no"
- data-width="15%"
- data-height="20"
- data-after="-300"
- ></div>
- are also possible! This
- <div data-netdata="system.ipv4"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-legend="no"
- data-width="15%"
- data-height="20"
- data-after="-300"
- ></div>
- is an area chart, while this
- <div data-netdata="system.cpu"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-legend="no"
- data-width="15%"
- data-height="20"
- data-after="-300"
- ></div> is a stacked area chart!
+ <div data-netdata="system.processes"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-legend="no"
+ data-width="15%"
+ data-height="20"
+ data-after="-300"
+ ></div>
+ are also possible! This
+ <div data-netdata="system.ipv4"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-legend="no"
+ data-width="15%"
+ data-height="20"
+ data-after="-300"
+ ></div>
+ is an area chart, while this
+ <div data-netdata="system.cpu"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-legend="no"
+ data-width="15%"
+ data-height="20"
+ data-after="-300"
+ ></div> is a stacked area chart!
<br/>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.processes"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time501"
- ></div>
- <br/>
- <small>rendered in <span id="time501">X</span> ms</small>
+ <div data-netdata="system.processes"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time501"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time501">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.ipv4"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time502"
- ></div>
- <br/>
- <small>rendered in <span id="time502">X</span> ms</small>
+ <div data-netdata="system.ipv4"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time502"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time502">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.cpu"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-width="100%"
- data-height="30"
- data-after="-300"
- data-dt-element-name="time503"
- ></div>
- <br/>
- <small>rendered in <span id="time503">X</span> ms</small>
+ <div data-netdata="system.cpu"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-width="100%"
+ data-height="30"
+ data-after="-300"
+ data-dt-element-name="time503"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time503">X</span> ms</small>
</div>
<br/>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.processes"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time201"
- ></div>
- <br/>
- <small>rendered in <span id="time201">X</span> ms</small>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.ipv4"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time202"
- ></div>
- <br/>
- <small>rendered in <span id="time202">X</span> ms</small>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.cpu"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time203"
- ></div>
- <br/>
- <small>rendered in <span id="time203">X</span> ms</small>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.io"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time204"
- ></div>
- <br/>
- <small>rendered in <span id="time204">X</span> ms</small>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div data-netdata="apps.cpu"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time205"
- ></div>
- <br/>
- <small>rendered in <span id="time205">X</span> ms</small>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div data-netdata="netdata.net"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time206"
- ></div>
- <br/>
- <small>rendered in <span id="time206">X</span> ms</small>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div data-netdata="netdata.server_cpu"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time207"
- ></div>
- <br/>
- <small>rendered in <span id="time207">X</span> ms</small>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div data-netdata="netdata.requests"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time208"
- ></div>
- <br/>
- <small>rendered in <span id="time208">X</span> ms</small>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div data-netdata="net.gstag0"
- data-chart-library="dygraph"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time209"
- ></div>
- <br/>
- <small>rendered in <span id="time209">X</span> ms</small>
+ <div data-netdata="system.processes"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time201"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time201">X</span> ms</small>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div data-netdata="system.ipv4"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time202"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time202">X</span> ms</small>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div data-netdata="system.cpu"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time203"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time203">X</span> ms</small>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div data-netdata="system.io"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time204"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time204">X</span> ms</small>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div data-netdata="apps.cpu"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time205"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time205">X</span> ms</small>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div data-netdata="netdata.net"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time206"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time206">X</span> ms</small>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div data-netdata="netdata.server_cpu"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time207"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time207">X</span> ms</small>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div data-netdata="netdata.requests"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time208"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time208">X</span> ms</small>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div data-netdata="net.gstag0"
+ data-chart-library="dygraph"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time209"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time209">X</span> ms</small>
</div>
@@ -344,82 +353,82 @@ Sparklines using dygraphs
<h1>EasyPieChart</h1>
<br/>
<div style="width: 33%; display: inline-block;">
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.processes"
- data-chart-library="easypiechart"
- data-width="200"
- data-height="200"
- data-after="-300"
- data-points="300"
- data-dt-element-name="time601"
- ></div>
- <br/>
- <small>rendered in <span id="time601">X</span> ms</small>
- </div>
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.processes"
- data-chart-library="easypiechart"
- data-width="150"
- data-height="150"
- data-after="-300"
- data-points="150"
- data-dt-element-name="time601a"
- ></div>
- <br/>
- <small>rendered in <span id="time601a">X</span> ms</small>
- </div>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.ipv4"
- data-chart-library="easypiechart"
- data-width="200"
- data-height="200"
- data-after="-300"
- data-points="300"
- data-dt-element-name="time602"
- ></div>
- <br/>
- <small>rendered in <span id="time602">X</span> ms</small>
- </div>
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.ipv4"
- data-chart-library="easypiechart"
- data-width="100"
- data-height="100"
- data-after="-300"
- data-points="150"
- data-dt-element-name="time602a"
- ></div>
- <br/>
- <small>rendered in <span id="time602a">X</span> ms</small>
- </div>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.cpu"
- data-chart-library="easypiechart"
- data-width="200"
- data-height="200"
- data-after="-300"
- data-points="300"
- data-dt-element-name="time603"
- ></div>
- <br/>
- <small>rendered in <span id="time603">X</span> ms</small>
- </div>
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.cpu"
- data-chart-library="easypiechart"
- data-width="75"
- data-height="75"
- data-after="-300"
- data-points="150"
- data-dt-element-name="time603a"
- ></div>
- <br/>
- <small>rendered in <span id="time603a">X</span> ms</small>
- </div>
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.processes"
+ data-chart-library="easypiechart"
+ data-width="200"
+ data-height="200"
+ data-after="-300"
+ data-points="300"
+ data-dt-element-name="time601"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time601">X</span> ms</small>
+ </div>
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.processes"
+ data-chart-library="easypiechart"
+ data-width="150"
+ data-height="150"
+ data-after="-300"
+ data-points="150"
+ data-dt-element-name="time601a"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time601a">X</span> ms</small>
+ </div>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.ipv4"
+ data-chart-library="easypiechart"
+ data-width="200"
+ data-height="200"
+ data-after="-300"
+ data-points="300"
+ data-dt-element-name="time602"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time602">X</span> ms</small>
+ </div>
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.ipv4"
+ data-chart-library="easypiechart"
+ data-width="100"
+ data-height="100"
+ data-after="-300"
+ data-points="150"
+ data-dt-element-name="time602a"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time602a">X</span> ms</small>
+ </div>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.cpu"
+ data-chart-library="easypiechart"
+ data-width="200"
+ data-height="200"
+ data-after="-300"
+ data-points="300"
+ data-dt-element-name="time603"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time603">X</span> ms</small>
+ </div>
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.cpu"
+ data-chart-library="easypiechart"
+ data-width="75"
+ data-height="75"
+ data-after="-300"
+ data-points="150"
+ data-dt-element-name="time603a"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time603a">X</span> ms</small>
+ </div>
</div>
@@ -427,82 +436,82 @@ Sparklines using dygraphs
<h1>Gauge.js</h1>
<br/>
<div style="width: 33%; display: inline-block;">
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.processes"
- data-chart-library="gauge"
- data-width="250"
- data-height="200"
- data-after="-300"
- data-points="300"
- data-dt-element-name="time701"
- ></div>
- <br/>
- <small>rendered in <span id="time701">X</span> ms</small>
- </div>
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.processes"
- data-chart-library="gauge"
- data-width="125"
- data-height="100"
- data-after="-300"
- data-points="150"
- data-dt-element-name="time701a"
- ></div>
- <br/>
- <small>rendered in <span id="time701a">X</span> ms</small>
- </div>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.ipv4"
- data-chart-library="gauge"
- data-width="250"
- data-height="200"
- data-after="-300"
- data-points="300"
- data-dt-element-name="time702"
- ></div>
- <br/>
- <small>rendered in <span id="time702">X</span> ms</small>
- </div>
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.ipv4"
- data-chart-library="gauge"
- data-width="125"
- data-height="100"
- data-after="-300"
- data-points="150"
- data-dt-element-name="time702a"
- ></div>
- <br/>
- <small>rendered in <span id="time702a">X</span> ms</small>
- </div>
-</div>
-<div style="width: 33%; display: inline-block;">
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.cpu"
- data-chart-library="gauge"
- data-width="250"
- data-height="200"
- data-after="-300"
- data-points="300"
- data-dt-element-name="time703"
- ></div>
- <br/>
- <small>rendered in <span id="time703">X</span> ms</small>
- </div>
- <div style="display: inline-block; position: relative;">
- <div data-netdata="system.cpu"
- data-chart-library="gauge"
- data-width="125"
- data-height="100"
- data-after="-300"
- data-points="150"
- data-dt-element-name="time703a"
- ></div>
- <br/>
- <small>rendered in <span id="time703a">X</span> ms</small>
- </div>
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.processes"
+ data-chart-library="gauge"
+ data-width="250"
+ data-height="200"
+ data-after="-300"
+ data-points="300"
+ data-dt-element-name="time701"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time701">X</span> ms</small>
+ </div>
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.processes"
+ data-chart-library="gauge"
+ data-width="125"
+ data-height="100"
+ data-after="-300"
+ data-points="150"
+ data-dt-element-name="time701a"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time701a">X</span> ms</small>
+ </div>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.ipv4"
+ data-chart-library="gauge"
+ data-width="250"
+ data-height="200"
+ data-after="-300"
+ data-points="300"
+ data-dt-element-name="time702"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time702">X</span> ms</small>
+ </div>
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.ipv4"
+ data-chart-library="gauge"
+ data-width="125"
+ data-height="100"
+ data-after="-300"
+ data-points="150"
+ data-dt-element-name="time702a"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time702a">X</span> ms</small>
+ </div>
+</div>
+<div style="width: 33%; display: inline-block;">
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.cpu"
+ data-chart-library="gauge"
+ data-width="250"
+ data-height="200"
+ data-after="-300"
+ data-points="300"
+ data-dt-element-name="time703"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time703">X</span> ms</small>
+ </div>
+ <div style="display: inline-block; position: relative;">
+ <div data-netdata="system.cpu"
+ data-chart-library="gauge"
+ data-width="125"
+ data-height="100"
+ data-after="-300"
+ data-points="150"
+ data-dt-element-name="time703a"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time703a">X</span> ms</small>
+ </div>
</div>
@@ -512,37 +521,37 @@ NetData was originaly developed with Google Charts.
NetData is a complete Google Visualization API provider.
<br/>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.processes"
- data-chart-library="google"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time301"
- ></div>
- <br/>
- <small>rendered in <span id="time301">X</span> ms</small>
+ <div data-netdata="system.processes"
+ data-chart-library="google"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time301"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time301">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.ipv4"
- data-chart-library="google"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time302"
- ></div>
- <br/>
- <small>rendered in <span id="time302">X</span> ms</small>
+ <div data-netdata="system.ipv4"
+ data-chart-library="google"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time302"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time302">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.cpu"
- data-chart-library="google"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time303"
- ></div>
- <br/>
- <small>rendered in <span id="time303">X</span> ms</small>
+ <div data-netdata="system.cpu"
+ data-chart-library="google"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time303"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time303">X</span> ms</small>
</div>
@@ -555,37 +564,37 @@ NetData is a complete Google Visualization API provider.
Unfortunatelly, Morris Charts are very slow. Here we force them to lower their detail to get acceptable results.
<br/>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.processes"
- data-chart-library="morris"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time401"
- ></div>
- <br/>
- <small>rendered in <span id="time401">X</span> ms</small>
+ <div data-netdata="system.processes"
+ data-chart-library="morris"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time401"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time401">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.ipv4"
- data-chart-library="morris"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time402"
- ></div>
- <br/>
- <small>rendered in <span id="time402">X</span> ms</small>
+ <div data-netdata="system.ipv4"
+ data-chart-library="morris"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time402"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time402">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.cpu"
- data-chart-library="morris"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time403"
- ></div>
- <br/>
- <small>rendered in <span id="time403">X</span> ms</small>
+ <div data-netdata="system.cpu"
+ data-chart-library="morris"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time403"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time403">X</span> ms</small>
</div>
@@ -601,37 +610,37 @@ C3 charts are not usable in large scale. They suffer from the following issues:
So, to avoid flashing the charts, we destroy and re-create the charts on each update. Also, since they manipulate the data with javascript we were forced to lower the detail they render to get acceptable speeds.
<br/>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.processes"
- data-chart-library="c3"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time801"
- ></div>
- <br/>
- <small>rendered in <span id="time801">X</span> ms</small>
+ <div data-netdata="system.processes"
+ data-chart-library="c3"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time801"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time801">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.ipv4"
- data-chart-library="c3"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time802"
- ></div>
- <br/>
- <small>rendered in <span id="time802">X</span> ms</small>
+ <div data-netdata="system.ipv4"
+ data-chart-library="c3"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time802"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time802">X</span> ms</small>
</div>
<div style="width: 33%; display: inline-block;">
- <div data-netdata="system.cpu"
- data-chart-library="c3"
- data-width="100%"
- data-height="200"
- data-after="-300"
- data-dt-element-name="time803"
- ></div>
- <br/>
- <small>rendered in <span id="time803">X</span> ms</small>
+ <div data-netdata="system.cpu"
+ data-chart-library="c3"
+ data-width="100%"
+ data-height="200"
+ data-after="-300"
+ data-dt-element-name="time803"
+ ></div>
+ <br/>
+ <small>rendered in <span id="time803">X</span> ms</small>
</div>
@@ -641,9 +650,9 @@ So, to avoid flashing the charts, we destroy and re-create the charts on each up
</div> <!-- 1st container -->
</body>
</html>
- <!-- you can set your netdata server globally, by ucommenting this -->
- <!-- you can also give a different server per chart, with the attribute: data-host="http://netdata.server:19999" -->
- <!-- <script> netdataServer = "http://box:19999"; </script> -->
+ <!-- you can set your netdata server globally, by ucommenting this -->
+ <!-- you can also give a different server per chart, with the attribute: data-host="http://netdata.server:19999" -->
+ <!-- <script> netdataServer = "http://box:19999"; </script> -->
- <!-- load the dashboard manager - it will do the rest -->
- <script type="text/javascript" src="dashboard.js?v37"></script>
+ <!-- load the dashboard manager - it will do the rest -->
+ <script type="text/javascript" src="dashboard.js?v42"></script>
diff --git a/web/dashboard.js b/web/dashboard.js
index 27847a243..67fb00b8b 100644
--- a/web/dashboard.js
+++ b/web/dashboard.js
@@ -1,20 +1,22 @@
// You can set the following variables before loading this script:
//
-// var netdataNoDygraphs = true; // do not use dygraph
-// var netdataNoSparklines = true; // do not use sparkline
-// var netdataNoPeitys = true; // do not use peity
-// var netdataNoGoogleCharts = true; // do not use google
-// var netdataNoMorris = true; // do not use morris
-// var netdataNoEasyPieChart = true; // do not use easy pie chart
-// var netdataNoGauge = true; // do not use gauge.js
-// var netdataNoD3 = true; // do not use D3
-// var netdataNoC3 = true; // do not use C3
-// var netdataNoBootstrap = true; // do not load bootstrap
-// var netdataDontStart = true; // do not start the thread to process the charts
-// var netdataErrorCallback = null; // Callback function that will be invoked upon error
-// var netdataNoRegistry = true; // Don't update the registry for this access
-// var netdataRegistryCallback = null; // Callback function that will be invoked with one param,
+// var netdataNoDygraphs = true; // do not use dygraph
+// var netdataNoSparklines = true; // do not use sparkline
+// var netdataNoPeitys = true; // do not use peity
+// var netdataNoGoogleCharts = true; // do not use google
+// var netdataNoMorris = true; // do not use morris
+// var netdataNoEasyPieChart = true; // do not use easy pie chart
+// var netdataNoGauge = true; // do not use gauge.js
+// var netdataNoD3 = true; // do not use D3
+// var netdataNoC3 = true; // do not use C3
+// var netdataNoBootstrap = true; // do not load bootstrap
+// var netdataDontStart = true; // do not start the thread to process the charts
+// var netdataErrorCallback = null; // Callback function that will be invoked upon error
+// var netdataNoRegistry = true; // Don't update the registry for this access
+// var netdataRegistryCallback = null; // Callback function that will be invoked with one param,
// the URLs from the registry
+// var netdataShowHelp = true; // enable/disable help
+// var netdataShowAlarms = true; // enable/disable help
//
// You can also set the default netdata server, using the following.
// When this variable is not set, we assume the page is hosted on your
@@ -23,5685 +25,5844 @@
//(function(window, document, undefined) {
- // ------------------------------------------------------------------------
- // compatibility fixes
-
- // fix IE issue with console
- if(!window.console) { window.console = { log: function(){} }; }
-
- // if string.endsWith is not defined, define it
- if(typeof String.prototype.endsWith !== 'function') {
- String.prototype.endsWith = function(s) {
- if(s.length > this.length) return false;
- return this.slice(-s.length) === s;
- };
- }
-
- // if string.startsWith is not defined, define it
- if(typeof String.prototype.startsWith !== 'function') {
- String.prototype.startsWith = function(s) {
- if(s.length > this.length) return false;
- return this.slice(s.length) === s;
- };
- }
-
- // global namespace
- var NETDATA = window.NETDATA || {};
-
- // ----------------------------------------------------------------------------------------------------------------
- // Detect the netdata server
-
- // http://stackoverflow.com/questions/984510/what-is-my-script-src-url
- // http://stackoverflow.com/questions/6941533/get-protocol-domain-and-port-from-url
- NETDATA._scriptSource = function() {
- var script = null;
-
- if(typeof document.currentScript !== 'undefined') {
- script = document.currentScript;
- }
- else {
- var all_scripts = document.getElementsByTagName('script');
- script = all_scripts[all_scripts.length - 1];
- }
-
- if (typeof script.getAttribute.length !== 'undefined')
- script = script.src;
- else
- script = script.getAttribute('src', -1);
-
- return script;
- };
-
- if(typeof netdataServer !== 'undefined')
- NETDATA.serverDefault = netdataServer;
- else {
- var s = NETDATA._scriptSource();
- if(s) NETDATA.serverDefault = s.replace(/\/dashboard.js(\?.*)*$/g, "");
- else {
- console.log('WARNING: Cannot detect the URL of the netdata server.');
- NETDATA.serverDefault = null;
- }
- }
-
- if(NETDATA.serverDefault === null)
- NETDATA.serverDefault = '';
- else if(NETDATA.serverDefault.slice(-1) !== '/')
- NETDATA.serverDefault += '/';
-
- // default URLs for all the external files we need
- // make them RELATIVE so that the whole thing can also be
- // installed under a web server
- NETDATA.jQuery = NETDATA.serverDefault + 'lib/jquery-1.12.0.min.js';
- NETDATA.peity_js = NETDATA.serverDefault + 'lib/jquery.peity.min.js';
- NETDATA.sparkline_js = NETDATA.serverDefault + 'lib/jquery.sparkline.min.js';
- NETDATA.easypiechart_js = NETDATA.serverDefault + 'lib/jquery.easypiechart.min.js';
- NETDATA.gauge_js = NETDATA.serverDefault + 'lib/gauge.min.js';
- NETDATA.dygraph_js = NETDATA.serverDefault + 'lib/dygraph-combined.js';
- NETDATA.dygraph_smooth_js = NETDATA.serverDefault + 'lib/dygraph-smooth-plotter.js';
- NETDATA.raphael_js = NETDATA.serverDefault + 'lib/raphael-min.js';
- NETDATA.morris_js = NETDATA.serverDefault + 'lib/morris.min.js';
- NETDATA.d3_js = NETDATA.serverDefault + 'lib/d3.min.js';
- NETDATA.c3_js = NETDATA.serverDefault + 'lib/c3.min.js';
- NETDATA.c3_css = NETDATA.serverDefault + 'css/c3.min.css';
- NETDATA.morris_css = NETDATA.serverDefault + 'css/morris.css';
- NETDATA.google_js = 'https://www.google.com/jsapi';
-
- NETDATA.themes = {
- white: {
- bootstrap_css: NETDATA.serverDefault + 'css/bootstrap.min.css',
- dashboard_css: NETDATA.serverDefault + 'dashboard.css',
- background: '#FFFFFF',
- foreground: '#000000',
- grid: '#DDDDDD',
- axis: '#CCCCCC',
- colors: [ '#3366CC', '#DC3912', '#109618', '#FF9900', '#990099', '#DD4477',
- '#3B3EAC', '#66AA00', '#0099C6', '#B82E2E', '#AAAA11', '#5574A6',
- '#994499', '#22AA99', '#6633CC', '#E67300', '#316395', '#8B0707',
- '#329262', '#3B3EAC' ],
- easypiechart_track: '#f0f0f0',
- easypiechart_scale: '#dfe0e0',
- gauge_pointer: '#C0C0C0',
- gauge_stroke: '#F0F0F0',
- gauge_gradient: false
- },
- slate: {
- bootstrap_css: NETDATA.serverDefault + 'css/bootstrap.slate.min.css',
- dashboard_css: NETDATA.serverDefault + 'dashboard.slate.css',
- background: '#272b30',
- foreground: '#C8C8C8',
- grid: '#373b40',
- axis: '#373b40',
-/* colors: [ '#55bb33', '#ff2222', '#0099C6', '#faa11b', '#adbce0', '#DDDD00',
- '#4178ba', '#f58122', '#a5cc39', '#f58667', '#f5ef89', '#cf93c0',
- '#a5d18a', '#b8539d', '#3954a3', '#c8a9cf', '#c7de8a', '#fad20a',
- '#a6a479', '#a66da8' ],
+ // ------------------------------------------------------------------------
+ // compatibility fixes
+
+ // fix IE issue with console
+ if(!window.console) { window.console = { log: function(){} }; }
+
+ // if string.endsWith is not defined, define it
+ if(typeof String.prototype.endsWith !== 'function') {
+ String.prototype.endsWith = function(s) {
+ if(s.length > this.length) return false;
+ return this.slice(-s.length) === s;
+ };
+ }
+
+ // if string.startsWith is not defined, define it
+ if(typeof String.prototype.startsWith !== 'function') {
+ String.prototype.startsWith = function(s) {
+ if(s.length > this.length) return false;
+ return this.slice(s.length) === s;
+ };
+ }
+
+ // global namespace
+ var NETDATA = window.NETDATA || {};
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Detect the netdata server
+
+ // http://stackoverflow.com/questions/984510/what-is-my-script-src-url
+ // http://stackoverflow.com/questions/6941533/get-protocol-domain-and-port-from-url
+ NETDATA._scriptSource = function() {
+ var script = null;
+
+ if(typeof document.currentScript !== 'undefined') {
+ script = document.currentScript;
+ }
+ else {
+ var all_scripts = document.getElementsByTagName('script');
+ script = all_scripts[all_scripts.length - 1];
+ }
+
+ if (typeof script.getAttribute.length !== 'undefined')
+ script = script.src;
+ else
+ script = script.getAttribute('src', -1);
+
+ return script;
+ };
+
+ if(typeof netdataServer !== 'undefined')
+ NETDATA.serverDefault = netdataServer;
+ else {
+ var s = NETDATA._scriptSource();
+ if(s) NETDATA.serverDefault = s.replace(/\/dashboard.js(\?.*)*$/g, "");
+ else {
+ console.log('WARNING: Cannot detect the URL of the netdata server.');
+ NETDATA.serverDefault = null;
+ }
+ }
+
+ if(NETDATA.serverDefault === null)
+ NETDATA.serverDefault = '';
+ else if(NETDATA.serverDefault.slice(-1) !== '/')
+ NETDATA.serverDefault += '/';
+
+ // default URLs for all the external files we need
+ // make them RELATIVE so that the whole thing can also be
+ // installed under a web server
+ NETDATA.jQuery = NETDATA.serverDefault + 'lib/jquery-1.12.0.min.js';
+ NETDATA.peity_js = NETDATA.serverDefault + 'lib/jquery.peity.min.js';
+ NETDATA.sparkline_js = NETDATA.serverDefault + 'lib/jquery.sparkline.min.js';
+ NETDATA.easypiechart_js = NETDATA.serverDefault + 'lib/jquery.easypiechart.min.js';
+ NETDATA.gauge_js = NETDATA.serverDefault + 'lib/gauge.min.js';
+ NETDATA.dygraph_js = NETDATA.serverDefault + 'lib/dygraph-combined.js';
+ NETDATA.dygraph_smooth_js = NETDATA.serverDefault + 'lib/dygraph-smooth-plotter.js';
+ NETDATA.raphael_js = NETDATA.serverDefault + 'lib/raphael-min.js';
+ NETDATA.morris_js = NETDATA.serverDefault + 'lib/morris.min.js';
+ NETDATA.d3_js = NETDATA.serverDefault + 'lib/d3.min.js';
+ NETDATA.c3_js = NETDATA.serverDefault + 'lib/c3.min.js';
+ NETDATA.c3_css = NETDATA.serverDefault + 'css/c3.min.css';
+ NETDATA.morris_css = NETDATA.serverDefault + 'css/morris.css';
+ NETDATA.google_js = 'https://www.google.com/jsapi';
+
+ NETDATA.themes = {
+ white: {
+ bootstrap_css: NETDATA.serverDefault + 'css/bootstrap.min.css',
+ dashboard_css: NETDATA.serverDefault + 'dashboard.css',
+ background: '#FFFFFF',
+ foreground: '#000000',
+ grid: '#DDDDDD',
+ axis: '#CCCCCC',
+ colors: [ '#3366CC', '#DC3912', '#109618', '#FF9900', '#990099', '#DD4477',
+ '#3B3EAC', '#66AA00', '#0099C6', '#B82E2E', '#AAAA11', '#5574A6',
+ '#994499', '#22AA99', '#6633CC', '#E67300', '#316395', '#8B0707',
+ '#329262', '#3B3EAC' ],
+ easypiechart_track: '#f0f0f0',
+ easypiechart_scale: '#dfe0e0',
+ gauge_pointer: '#C0C0C0',
+ gauge_stroke: '#F0F0F0',
+ gauge_gradient: false
+ },
+ slate: {
+ bootstrap_css: NETDATA.serverDefault + 'css/bootstrap.slate.min.css',
+ dashboard_css: NETDATA.serverDefault + 'dashboard.slate.css',
+ background: '#272b30',
+ foreground: '#C8C8C8',
+ grid: '#373b40',
+ axis: '#373b40',
+/* colors: [ '#55bb33', '#ff2222', '#0099C6', '#faa11b', '#adbce0', '#DDDD00',
+ '#4178ba', '#f58122', '#a5cc39', '#f58667', '#f5ef89', '#cf93c0',
+ '#a5d18a', '#b8539d', '#3954a3', '#c8a9cf', '#c7de8a', '#fad20a',
+ '#a6a479', '#a66da8' ],
*/
- colors: [ '#66AA00', '#FE3912', '#3366CC', '#D66300', '#0099C6', '#DDDD00',
- '#3B3EAC', '#EE9911', '#BB44CC', '#C83E3E', '#990099', '#CC7700',
- '#22AA99', '#109618', '#6633CC', '#DD4477', '#316395', '#8B0707',
- '#329262', '#3B3EFF' ],
- easypiechart_track: '#373b40',
- easypiechart_scale: '#373b40',
- gauge_pointer: '#474b50',
- gauge_stroke: '#373b40',
- gauge_gradient: false
- }
- };
-
- if(typeof netdataTheme !== 'undefined' && typeof NETDATA.themes[netdataTheme] !== 'undefined')
- NETDATA.themes.current = NETDATA.themes[netdataTheme];
- else
- NETDATA.themes.current = NETDATA.themes.white;
-
- NETDATA.colors = NETDATA.themes.current.colors;
-
- // these are the colors Google Charts are using
- // we have them here to attempt emulate their look and feel on the other chart libraries
- // http://there4.io/2012/05/02/google-chart-color-list/
- //NETDATA.colors = [ '#3366CC', '#DC3912', '#FF9900', '#109618', '#990099', '#3B3EAC', '#0099C6',
- // '#DD4477', '#66AA00', '#B82E2E', '#316395', '#994499', '#22AA99', '#AAAA11',
- // '#6633CC', '#E67300', '#8B0707', '#329262', '#5574A6', '#3B3EAC' ];
+ colors: [ '#66AA00', '#FE3912', '#3366CC', '#D66300', '#0099C6', '#DDDD00',
+ '#5054e6', '#EE9911', '#BB44CC', '#e45757', '#ef0aef', '#CC7700',
+ '#22AA99', '#109618', '#905bfd', '#f54882', '#4381bf', '#ff3737',
+ '#329262', '#3B3EFF' ],
+ easypiechart_track: '#373b40',
+ easypiechart_scale: '#373b40',
+ gauge_pointer: '#474b50',
+ gauge_stroke: '#373b40',
+ gauge_gradient: false
+ }
+ };
+
+ if(typeof netdataTheme !== 'undefined' && typeof NETDATA.themes[netdataTheme] !== 'undefined')
+ NETDATA.themes.current = NETDATA.themes[netdataTheme];
+ else
+ NETDATA.themes.current = NETDATA.themes.white;
+
+ if(typeof netdataShowHelp === 'undefined')
+ netdataShowHelp = true;
+
+ if(typeof netdataShowAlarms === 'undefined')
+ netdataShowAlarms = true;
+
+ NETDATA.colors = NETDATA.themes.current.colors;
+
+ // these are the colors Google Charts are using
+ // we have them here to attempt emulate their look and feel on the other chart libraries
+ // http://there4.io/2012/05/02/google-chart-color-list/
+ //NETDATA.colors = [ '#3366CC', '#DC3912', '#FF9900', '#109618', '#990099', '#3B3EAC', '#0099C6',
+ // '#DD4477', '#66AA00', '#B82E2E', '#316395', '#994499', '#22AA99', '#AAAA11',
+ // '#6633CC', '#E67300', '#8B0707', '#329262', '#5574A6', '#3B3EAC' ];
- // an alternative set
- // http://www.mulinblog.com/a-color-palette-optimized-for-data-visualization/
- // (blue) (red) (orange) (green) (pink) (brown) (purple) (yellow) (gray)
- //NETDATA.colors = [ '#5DA5DA', '#F15854', '#FAA43A', '#60BD68', '#F17CB0', '#B2912F', '#B276B2', '#DECF3F', '#4D4D4D' ];
+ // an alternative set
+ // http://www.mulinblog.com/a-color-palette-optimized-for-data-visualization/
+ // (blue) (red) (orange) (green) (pink) (brown) (purple) (yellow) (gray)
+ //NETDATA.colors = [ '#5DA5DA', '#F15854', '#FAA43A', '#60BD68', '#F17CB0', '#B2912F', '#B276B2', '#DECF3F', '#4D4D4D' ];
- // ----------------------------------------------------------------------------------------------------------------
- // the defaults for all charts
+ // ----------------------------------------------------------------------------------------------------------------
+ // the defaults for all charts
- // if the user does not specify any of these, the following will be used
+ // if the user does not specify any of these, the following will be used
- NETDATA.chartDefaults = {
- host: NETDATA.serverDefault, // the server to get data from
- width: '100%', // the chart width - can be null
- height: '100%', // the chart height - can be null
- min_width: null, // the chart minimum width - can be null
- library: 'dygraph', // the graphing library to use
- method: 'average', // the grouping method
- before: 0, // panning
- after: -600, // panning
- pixels_per_point: 1, // the detail of the chart
- fill_luminance: 0.8 // luminance of colors in solit areas
- };
+ NETDATA.chartDefaults = {
+ host: NETDATA.serverDefault, // the server to get data from
+ width: '100%', // the chart width - can be null
+ height: '100%', // the chart height - can be null
+ min_width: null, // the chart minimum width - can be null
+ library: 'dygraph', // the graphing library to use
+ method: 'average', // the grouping method
+ before: 0, // panning
+ after: -600, // panning
+ pixels_per_point: 1, // the detail of the chart
+ fill_luminance: 0.8 // luminance of colors in solit areas
+ };
- // ----------------------------------------------------------------------------------------------------------------
- // global options
+ // ----------------------------------------------------------------------------------------------------------------
+ // global options
- NETDATA.options = {
- pauseCallback: null, // a callback when we are really paused
+ NETDATA.options = {
+ pauseCallback: null, // a callback when we are really paused
- pause: false, // when enabled we don't auto-refresh the charts
+ pause: false, // when enabled we don't auto-refresh the charts
- targets: null, // an array of all the state objects that are
- // currently active (independently of their
- // viewport visibility)
+ targets: null, // an array of all the state objects that are
+ // currently active (independently of their
+ // viewport visibility)
- updated_dom: true, // when true, the DOM has been updated with
- // new elements we have to check.
+ updated_dom: true, // when true, the DOM has been updated with
+ // new elements we have to check.
- auto_refresher_fast_weight: 0, // this is the current time in ms, spent
- // rendering charts continiously.
- // used with .current.fast_render_timeframe
+ auto_refresher_fast_weight: 0, // this is the current time in ms, spent
+ // rendering charts continiously.
+ // used with .current.fast_render_timeframe
- page_is_visible: true, // when true, this page is visible
+ page_is_visible: true, // when true, this page is visible
- auto_refresher_stop_until: 0, // timestamp in ms - used internaly, to stop the
- // auto-refresher for some time (when a chart is
- // performing pan or zoom, we need to stop refreshing
- // all other charts, to have the maximum speed for
- // rendering the chart that is panned or zoomed).
- // Used with .current.global_pan_sync_time
+ auto_refresher_stop_until: 0, // timestamp in ms - used internaly, to stop the
+ // auto-refresher for some time (when a chart is
+ // performing pan or zoom, we need to stop refreshing
+ // all other charts, to have the maximum speed for
+ // rendering the chart that is panned or zoomed).
+ // Used with .current.global_pan_sync_time
- last_resized: new Date().getTime(), // the timestamp of the last resize request
+ last_resized: new Date().getTime(), // the timestamp of the last resize request
- last_page_scroll: 0, // the timestamp the last time the page was scrolled
+ last_page_scroll: 0, // the timestamp the last time the page was scrolled
- // the current profile
- // we may have many...
- current: {
- pixels_per_point: 1, // the minimum pixels per point for all charts
- // increase this to speed javascript up
- // each chart library has its own limit too
- // the max of this and the chart library is used
- // the final is calculated every time, so a change
- // here will have immediate effect on the next chart
- // update
+ // the current profile
+ // we may have many...
+ current: {
+ pixels_per_point: 1, // the minimum pixels per point for all charts
+ // increase this to speed javascript up
+ // each chart library has its own limit too
+ // the max of this and the chart library is used
+ // the final is calculated every time, so a change
+ // here will have immediate effect on the next chart
+ // update
- idle_between_charts: 100, // ms - how much time to wait between chart updates
+ idle_between_charts: 100, // ms - how much time to wait between chart updates
- fast_render_timeframe: 200, // ms - render continously until this time of continious
- // rendering has been reached
- // this setting is used to make it render e.g. 10
- // charts at once, sleep idle_between_charts time
- // and continue for another 10 charts.
+ fast_render_timeframe: 200, // ms - render continously until this time of continious
+ // rendering has been reached
+ // this setting is used to make it render e.g. 10
+ // charts at once, sleep idle_between_charts time
+ // and continue for another 10 charts.
- idle_between_loops: 500, // ms - if all charts have been updated, wait this
- // time before starting again.
+ idle_between_loops: 500, // ms - if all charts have been updated, wait this
+ // time before starting again.
- idle_parallel_loops: 100, // ms - the time between parallel refresher updates
+ idle_parallel_loops: 100, // ms - the time between parallel refresher updates
- idle_lost_focus: 500, // ms - when the window does not have focus, check
- // if focus has been regained, every this time
+ idle_lost_focus: 500, // ms - when the window does not have focus, check
+ // if focus has been regained, every this time
- global_pan_sync_time: 1000, // ms - when you pan or zoon a chart, the background
- // autorefreshing of charts is paused for this amount
- // of time
+ global_pan_sync_time: 1000, // ms - when you pan or zoon a chart, the background
+ // autorefreshing of charts is paused for this amount
+ // of time
- sync_selection_delay: 1500, // ms - when you pan or zoom a chart, wait this amount
- // of time before setting up synchronized selections
- // on hover.
-
- sync_selection: true, // enable or disable selection sync
-
- pan_and_zoom_delay: 50, // when panning or zooming, how ofter to update the chart
-
- sync_pan_and_zoom: true, // enable or disable pan and zoom sync
-
- pan_and_zoom_data_padding: true, // fetch more data for the master chart when panning or zooming
-
- update_only_visible: true, // enable or disable visibility management
-
- parallel_refresher: true, // enable parallel refresh of charts
-
- concurrent_refreshes: true, // when parallel_refresher is enabled, sync also the charts
-
- destroy_on_hide: false, // destroy charts when they are not visible
-
- show_help: true, // when enabled the charts will show some help
- show_help_delay_show_ms: 500,
- show_help_delay_hide_ms: 0,
-
- eliminate_zero_dimensions: true, // do not show dimensions with just zeros
-
- stop_updates_when_focus_is_lost: true, // boolean - shall we stop auto-refreshes when document does not have user focus
- stop_updates_while_resizing: 1000, // ms - time to stop auto-refreshes while resizing the charts
-
- double_click_speed: 500, // ms - time between clicks / taps to detect double click/tap
-
- smooth_plot: true, // enable smooth plot, where possible
-
- charts_selection_animation_delay: 50, // delay to animate charts when syncing selection
-
- color_fill_opacity_line: 1.0,
- color_fill_opacity_area: 0.2,
- color_fill_opacity_stacked: 0.8,
-
- pan_and_zoom_factor: 0.25, // the increment when panning and zooming with the toolbox
- pan_and_zoom_factor_multiplier_control: 2.0,
- pan_and_zoom_factor_multiplier_shift: 3.0,
- pan_and_zoom_factor_multiplier_alt: 4.0,
-
- setOptionCallback: function() { ; }
- },
-
- debug: {
- show_boxes: false,
- main_loop: false,
- focus: false,
- visibility: false,
- chart_data_url: false,
- chart_errors: false, // FIXME
- chart_timing: false,
- chart_calls: false,
- libraries: false,
- dygraph: false
- }
- };
-
- NETDATA.statistics = {
- refreshes_total: 0,
- refreshes_active: 0,
- refreshes_active_max: 0
- };
-
-
- // ----------------------------------------------------------------------------------------------------------------
- // local storage options
-
- NETDATA.localStorage = {
- default: {},
- current: {},
- callback: {} // only used for resetting back to defaults
- };
-
- NETDATA.localStorageGet = function(key, def, callback) {
- var ret = def;
-
- if(typeof NETDATA.localStorage.default[key.toString()] === 'undefined') {
- NETDATA.localStorage.default[key.toString()] = def;
- NETDATA.localStorage.callback[key.toString()] = callback;
- }
-
- if(typeof Storage !== "undefined" && typeof localStorage === 'object') {
- try {
- // console.log('localStorage: loading "' + key.toString() + '"');
- ret = localStorage.getItem(key.toString());
- if(ret === null || ret === 'undefined') {
- // console.log('localStorage: cannot load it, saving "' + key.toString() + '" with value "' + JSON.stringify(def) + '"');
- localStorage.setItem(key.toString(), JSON.stringify(def));
- ret = def;
- }
- else {
- // console.log('localStorage: got "' + key.toString() + '" with value "' + ret + '"');
- ret = JSON.parse(ret);
- // console.log('localStorage: loaded "' + key.toString() + '" as value ' + ret + ' of type ' + typeof(ret));
- }
- }
- catch(error) {
- console.log('localStorage: failed to read "' + key.toString() + '", using default: "' + def.toString() + '"');
- ret = def;
- }
- }
-
- if(typeof ret === 'undefined' || ret === 'undefined') {
- console.log('localStorage: LOADED UNDEFINED "' + key.toString() + '" as value ' + ret + ' of type ' + typeof(ret));
- ret = def;
- }
-
- NETDATA.localStorage.current[key.toString()] = ret;
- return ret;
- };
-
- NETDATA.localStorageSet = function(key, value, callback) {
- if(typeof value === 'undefined' || value === 'undefined') {
- console.log('localStorage: ATTEMPT TO SET UNDEFINED "' + key.toString() + '" as value ' + value + ' of type ' + typeof(value));
- }
-
- if(typeof NETDATA.localStorage.default[key.toString()] === 'undefined') {
- NETDATA.localStorage.default[key.toString()] = value;
- NETDATA.localStorage.current[key.toString()] = value;
- NETDATA.localStorage.callback[key.toString()] = callback;
- }
-
- if(typeof Storage !== "undefined" && typeof localStorage === 'object') {
- // console.log('localStorage: saving "' + key.toString() + '" with value "' + JSON.stringify(value) + '"');
- try {
- localStorage.setItem(key.toString(), JSON.stringify(value));
- }
- catch(e) {
- console.log('localStorage: failed to save "' + key.toString() + '" with value: "' + value.toString() + '"');
- }
- }
-
- NETDATA.localStorage.current[key.toString()] = value;
- return value;
- };
-
- NETDATA.localStorageGetRecursive = function(obj, prefix, callback) {
- for(var i in obj) {
- if(typeof obj[i] === 'object') {
- //console.log('object ' + prefix + '.' + i.toString());
- NETDATA.localStorageGetRecursive(obj[i], prefix + '.' + i.toString(), callback);
- continue;
- }
-
- obj[i] = NETDATA.localStorageGet(prefix + '.' + i.toString(), obj[i], callback);
- }
- };
-
- NETDATA.setOption = function(key, value) {
- if(key.toString() === 'setOptionCallback') {
- if(typeof NETDATA.options.current.setOptionCallback === 'function') {
- NETDATA.options.current[key.toString()] = value;
- NETDATA.options.current.setOptionCallback();
- }
- }
- else if(NETDATA.options.current[key.toString()] !== value) {
- var name = 'options.' + key.toString();
-
- if(typeof NETDATA.localStorage.default[name.toString()] === 'undefined')
- console.log('localStorage: setOption() on unsaved option: "' + name.toString() + '", value: ' + value);
-
- //console.log(NETDATA.localStorage);
- //console.log('setOption: setting "' + key.toString() + '" to "' + value + '" of type ' + typeof(value) + ' original type ' + typeof(NETDATA.options.current[key.toString()]));
- //console.log(NETDATA.options);
- NETDATA.options.current[key.toString()] = NETDATA.localStorageSet(name.toString(), value, null);
-
- if(typeof NETDATA.options.current.setOptionCallback === 'function')
- NETDATA.options.current.setOptionCallback();
- }
-
- return true;
- };
-
- NETDATA.getOption = function(key) {
- return NETDATA.options.current[key.toString()];
- };
-
- // read settings from local storage
- NETDATA.localStorageGetRecursive(NETDATA.options.current, 'options', null);
-
- // always start with this option enabled.
- NETDATA.setOption('stop_updates_when_focus_is_lost', true);
-
- NETDATA.resetOptions = function() {
- for(var i in NETDATA.localStorage.default) {
- var a = i.split('.');
-
- if(a[0] === 'options') {
- if(a[1] === 'setOptionCallback') continue;
- if(typeof NETDATA.localStorage.default[i] === 'undefined') continue;
- if(NETDATA.options.current[i] === NETDATA.localStorage.default[i]) continue;
-
- NETDATA.setOption(a[1], NETDATA.localStorage.default[i]);
- }
- else if(a[0] === 'chart_heights') {
- if(typeof NETDATA.localStorage.callback[i] === 'function' && typeof NETDATA.localStorage.default[i] !== 'undefined') {
- NETDATA.localStorage.callback[i](NETDATA.localStorage.default[i]);
- }
- }
- }
- }
-
- // ----------------------------------------------------------------------------------------------------------------
-
- if(NETDATA.options.debug.main_loop === true)
- console.log('welcome to NETDATA');
-
- NETDATA.onresize = function() {
- NETDATA.options.last_resized = new Date().getTime();
- NETDATA.onscroll();
- };
-
- NETDATA.onscroll = function() {
- // console.log('onscroll');
-
- NETDATA.options.last_page_scroll = new Date().getTime();
- if(NETDATA.options.targets === null) return;
-
- // when the user scrolls he sees that we have
- // hidden all the not-visible charts
- // using this little function we try to switch
- // the charts back to visible quickly
- var targets = NETDATA.options.targets;
- var len = targets.length;
- while(len--) targets[len].isVisible();
- };
-
- window.onresize = NETDATA.onresize;
- window.onscroll = NETDATA.onscroll;
-
- // ----------------------------------------------------------------------------------------------------------------
- // Error Handling
-
- NETDATA.errorCodes = {
- 100: { message: "Cannot load chart library", alert: true },
- 101: { message: "Cannot load jQuery", alert: true },
- 402: { message: "Chart library not found", alert: false },
- 403: { message: "Chart library not enabled/is failed", alert: false },
- 404: { message: "Chart not found", alert: false },
- 405: { message: "Cannot download charts index from server", alert: true },
- 406: { message: "Invalid charts index downloaded from server", alert: true },
- 407: { message: "Cannot HELLO netdata server", alert: false },
- 408: { message: "Netdata servers sent invalid response to HELLO", alert: false },
- 409: { message: "Cannot ACCESS netdata registry", alert: false },
- 410: { message: "Netdata registry ACCESS failed", alert: false },
- 411: { message: "Netdata registry server send invalid response to DELETE ", alert: false },
- 412: { message: "Netdata registry DELETE failed", alert: false },
- 413: { message: "Netdata registry server send invalid response to SWITCH ", alert: false },
- 414: { message: "Netdata registry SWITCH failed", alert: false }
- };
- NETDATA.errorLast = {
- code: 0,
- message: "",
- datetime: 0
- };
-
- NETDATA.error = function(code, msg) {
- NETDATA.errorLast.code = code;
- NETDATA.errorLast.message = msg;
- NETDATA.errorLast.datetime = new Date().getTime();
-
- console.log("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
-
- var ret = true;
- if(typeof netdataErrorCallback === 'function') {
- ret = netdataErrorCallback('system', code, msg);
- }
-
- if(ret && NETDATA.errorCodes[code].alert)
- alert("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
- };
-
- NETDATA.errorReset = function() {
- NETDATA.errorLast.code = 0;
- NETDATA.errorLast.message = "You are doing fine!";
- NETDATA.errorLast.datetime = 0;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // Chart Registry
-
- // When multiple charts need the same chart, we avoid downloading it
- // multiple times (and having it in browser memory multiple time)
- // by using this registry.
-
- // Every time we download a chart definition, we save it here with .add()
- // Then we try to get it back with .get(). If that fails, we download it.
-
- NETDATA.chartRegistry = {
- charts: {},
-
- fixid: function(id) {
- return id.replace(/:/g, "_").replace(/\//g, "_");
- },
-
- add: function(host, id, data) {
- host = this.fixid(host);
- id = this.fixid(id);
-
- if(typeof this.charts[host] === 'undefined')
- this.charts[host] = {};
-
- //console.log('added ' + host + '/' + id);
- this.charts[host][id] = data;
- },
-
- get: function(host, id) {
- host = this.fixid(host);
- id = this.fixid(id);
-
- if(typeof this.charts[host] === 'undefined')
- return null;
-
- if(typeof this.charts[host][id] === 'undefined')
- return null;
-
- //console.log('cached ' + host + '/' + id);
- return this.charts[host][id];
- },
-
- downloadAll: function(host, callback) {
- while(host.slice(-1) === '/')
- host = host.substring(0, host.length - 1);
-
- var self = this;
-
- $.ajax({
- url: host + '/api/v1/charts',
- async: true,
- cache: false
- })
- .done(function(data) {
- if(data !== null) {
- var h = NETDATA.chartRegistry.fixid(host);
- self.charts[h] = data.charts;
- }
- else NETDATA.error(406, host + '/api/v1/charts');
-
- if(typeof callback === 'function')
- callback(data);
- })
- .fail(function() {
- NETDATA.error(405, host + '/api/v1/charts');
-
- if(typeof callback === 'function')
- callback(null);
- });
- }
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // Global Pan and Zoom on charts
-
- // Using this structure are synchronize all the charts, so that
- // when you pan or zoom one, all others are automatically refreshed
- // to the same timespan.
-
- NETDATA.globalPanAndZoom = {
- seq: 0, // timestamp ms
- // every time a chart is panned or zoomed
- // we set the timestamp here
- // then we use it as a sequence number
- // to find if other charts are syncronized
- // to this timerange
-
- master: null, // the master chart (state), to which all others
- // are synchronized
-
- force_before_ms: null, // the timespan to sync all other charts
- force_after_ms: null,
-
- // set a new master
- setMaster: function(state, after, before) {
- if(NETDATA.options.current.sync_pan_and_zoom === false)
- return;
-
- if(this.master !== null && this.master !== state)
- this.master.resetChart(true, true);
-
- var now = new Date().getTime();
- this.master = state;
- this.seq = now;
- this.force_after_ms = after;
- this.force_before_ms = before;
- NETDATA.options.auto_refresher_stop_until = now + NETDATA.options.current.global_pan_sync_time;
- },
-
- // clear the master
- clearMaster: function() {
- if(this.master !== null) {
- var st = this.master;
- this.master = null;
- st.resetChart();
- }
-
- this.master = null;
- this.seq = 0;
- this.force_after_ms = null;
- this.force_before_ms = null;
- NETDATA.options.auto_refresher_stop_until = 0;
- },
-
- // is the given state the master of the global
- // pan and zoom sync?
- isMaster: function(state) {
- if(this.master === state) return true;
- return false;
- },
-
- // are we currently have a global pan and zoom sync?
- isActive: function() {
- if(this.master !== null && this.force_before_ms !== null && this.force_after_ms !== null && this.seq !== 0) return true;
- return false;
- },
-
- // check if a chart, other than the master
- // needs to be refreshed, due to the global pan and zoom
- shouldBeAutoRefreshed: function(state) {
- if(this.master === null || this.seq === 0)
- return false;
-
- //if(state.needsRecreation())
- // return true;
-
- if(state.tm.pan_and_zoom_seq === this.seq)
- return false;
-
- return true;
- }
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // dimensions selection
-
- // FIXME
- // move color assignment to dimensions, here
-
- dimensionStatus = function(parent, label, name_div, value_div, color) {
- this.enabled = false;
- this.parent = parent;
- this.label = label;
- this.name_div = null;
- this.value_div = null;
- this.color = NETDATA.themes.current.foreground;
-
- if(parent.selected_count > parent.unselected_count)
- this.selected = true;
- else
- this.selected = false;
-
- this.setOptions(name_div, value_div, color);
- };
-
- dimensionStatus.prototype.invalidate = function() {
- this.name_div = null;
- this.value_div = null;
- this.enabled = false;
- };
-
- dimensionStatus.prototype.setOptions = function(name_div, value_div, color) {
- this.color = color;
-
- if(this.name_div != name_div) {
- this.name_div = name_div;
- this.name_div.title = this.label;
- this.name_div.style.color = this.color;
- if(this.selected === false)
- this.name_div.className = 'netdata-legend-name not-selected';
- else
- this.name_div.className = 'netdata-legend-name selected';
- }
-
- if(this.value_div != value_div) {
- this.value_div = value_div;
- this.value_div.title = this.label;
- this.value_div.style.color = this.color;
- if(this.selected === false)
- this.value_div.className = 'netdata-legend-value not-selected';
- else
- this.value_div.className = 'netdata-legend-value selected';
- }
-
- this.enabled = true;
- this.setHandler();
- };
-
- dimensionStatus.prototype.setHandler = function() {
- if(this.enabled === false) return;
-
- var ds = this;
-
- // this.name_div.onmousedown = this.value_div.onmousedown = function(e) {
- this.name_div.onclick = this.value_div.onclick = function(e) {
- e.preventDefault();
- if(ds.isSelected()) {
- // this is selected
- if(e.shiftKey === true || e.ctrlKey === true) {
- // control or shift key is pressed -> unselect this (except is none will remain selected, in which case select all)
- ds.unselect();
-
- if(ds.parent.countSelected() === 0)
- ds.parent.selectAll();
- }
- else {
- // no key is pressed -> select only this (except if it is the only selected already, in which case select all)
- if(ds.parent.countSelected() === 1) {
- ds.parent.selectAll();
- }
- else {
- ds.parent.selectNone();
- ds.select();
- }
- }
- }
- else {
- // this is not selected
- if(e.shiftKey === true || e.ctrlKey === true) {
- // control or shift key is pressed -> select this too
- ds.select();
- }
- else {
- // no key is pressed -> select only this
- ds.parent.selectNone();
- ds.select();
- }
- }
-
- ds.parent.state.redrawChart();
- }
- };
-
- dimensionStatus.prototype.select = function() {
- if(this.enabled === false) return;
-
- this.name_div.className = 'netdata-legend-name selected';
- this.value_div.className = 'netdata-legend-value selected';
- this.selected = true;
- };
-
- dimensionStatus.prototype.unselect = function() {
- if(this.enabled === false) return;
-
- this.name_div.className = 'netdata-legend-name not-selected';
- this.value_div.className = 'netdata-legend-value hidden';
- this.selected = false;
- };
-
- dimensionStatus.prototype.isSelected = function() {
- return(this.enabled === true && this.selected === true);
- };
-
- // ----------------------------------------------------------------------------------------------------------------
-
- dimensionsVisibility = function(state) {
- this.state = state;
- this.len = 0;
- this.dimensions = {};
- this.selected_count = 0;
- this.unselected_count = 0;
- };
-
- dimensionsVisibility.prototype.dimensionAdd = function(label, name_div, value_div, color) {
- if(typeof this.dimensions[label] === 'undefined') {
- this.len++;
- this.dimensions[label] = new dimensionStatus(this, label, name_div, value_div, color);
- }
- else
- this.dimensions[label].setOptions(name_div, value_div, color);
-
- return this.dimensions[label];
- };
-
- dimensionsVisibility.prototype.dimensionGet = function(label) {
- return this.dimensions[label];
- };
-
- dimensionsVisibility.prototype.invalidateAll = function() {
- for(var d in this.dimensions)
- this.dimensions[d].invalidate();
- };
-
- dimensionsVisibility.prototype.selectAll = function() {
- for(var d in this.dimensions)
- this.dimensions[d].select();
- };
-
- dimensionsVisibility.prototype.countSelected = function() {
- var i = 0;
- for(var d in this.dimensions)
- if(this.dimensions[d].isSelected()) i++;
-
- return i;
- };
-
- dimensionsVisibility.prototype.selectNone = function() {
- for(var d in this.dimensions)
- this.dimensions[d].unselect();
- };
-
- dimensionsVisibility.prototype.selected2BooleanArray = function(array) {
- var ret = new Array();
- this.selected_count = 0;
- this.unselected_count = 0;
-
- for(var i = 0, len = array.length; i < len ; i++) {
- var ds = this.dimensions[array[i]];
- if(typeof ds === 'undefined') {
- // console.log(array[i] + ' is not found');
- ret.push(false);
- continue;
- }
-
- if(ds.isSelected()) {
- ret.push(true);
- this.selected_count++;
- }
- else {
- ret.push(false);
- this.unselected_count++;
- }
- }
-
- if(this.selected_count === 0 && this.unselected_count !== 0) {
- this.selectAll();
- return this.selected2BooleanArray(array);
- }
-
- return ret;
- };
-
-
- // ----------------------------------------------------------------------------------------------------------------
- // global selection sync
-
- NETDATA.globalSelectionSync = {
- state: null,
- dont_sync_before: 0,
- last_t: 0,
- slaves: [],
-
- stop: function() {
- if(this.state !== null)
- this.state.globalSelectionSyncStop();
- },
-
- delay: function() {
- if(this.state !== null) {
- this.state.globalSelectionSyncDelay();
- }
- }
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // Our state object, where all per-chart values are stored
-
- chartState = function(element) {
- var self = $(element);
- this.element = element;
-
- // IMPORTANT:
- // all private functions should use 'that', instead of 'this'
- var that = this;
-
- /* error() - private
- * show an error instead of the chart
- */
- var error = function(msg) {
- var ret = true;
-
- if(typeof netdataErrorCallback === 'function') {
- ret = netdataErrorCallback('chart', that.id, msg);
- }
-
- if(ret) {
- that.element.innerHTML = that.id + ': ' + msg;
- that.enabled = false;
- that.current = that.pan;
- }
- };
-
- // GUID - a unique identifier for the chart
- this.uuid = NETDATA.guid();
-
- // string - the name of chart
- this.id = self.data('netdata');
-
- // string - the key for localStorage settings
- this.settings_id = self.data('id') || null;
-
- // the user given dimensions of the element
- this.width = self.data('width') || NETDATA.chartDefaults.width;
- this.height = self.data('height') || NETDATA.chartDefaults.height;
-
- if(this.settings_id !== null) {
- this.height = NETDATA.localStorageGet('chart_heights.' + this.settings_id, this.height, function(height) {
- // this is the callback that will be called
- // if and when the user resets all localStorage variables
- // to their defaults
-
- resizeChartToHeight(height);
- });
- }
-
- // string - the netdata server URL, without any path
- this.host = self.data('host') || NETDATA.chartDefaults.host;
-
- // make sure the host does not end with /
- // all netdata API requests use absolute paths
- while(this.host.slice(-1) === '/')
- this.host = this.host.substring(0, this.host.length - 1);
-
- // string - the grouping method requested by the user
- this.method = self.data('method') || NETDATA.chartDefaults.method;
-
- // the time-range requested by the user
- this.after = self.data('after') || NETDATA.chartDefaults.after;
- this.before = self.data('before') || NETDATA.chartDefaults.before;
-
- // the pixels per point requested by the user
- this.pixels_per_point = self.data('pixels-per-point') || 1;
- this.points = self.data('points') || null;
-
- // the dimensions requested by the user
- this.dimensions = self.data('dimensions') || null;
-
- // the chart library requested by the user
- this.library_name = self.data('chart-library') || NETDATA.chartDefaults.library;
-
- // object - the chart library used
- this.library = null;
-
- // color management
- this.colors = null;
- this.colors_assigned = {};
- this.colors_available = null;
-
- // the element already created by the user
- this.element_message = null;
-
- // the element with the chart
- this.element_chart = null;
-
- // the element with the legend of the chart (if created by us)
- this.element_legend = null;
- this.element_legend_childs = {
- hidden: null,
- title_date: null,
- title_time: null,
- title_units: null,
- nano: null,
- nano_options: null,
- series: null
- };
-
- this.chart_url = null; // string - the url to download chart info
- this.chart = null; // object - the chart as downloaded from the server
-
- this.title = self.data('title') || null; // the title of the chart
- this.units = self.data('units') || null; // the units of the chart dimensions
- this.append_options = self.data('append-options') || null; // the units of the chart dimensions
-
- this.running = false; // boolean - true when the chart is being refreshed now
- this.validated = false; // boolean - has the chart been validated?
- this.enabled = true; // boolean - is the chart enabled for refresh?
- this.paused = false; // boolean - is the chart paused for any reason?
- this.selected = false; // boolean - is the chart shown a selection?
- this.debug = false; // boolean - console.log() debug info about this chart
-
- this.netdata_first = 0; // milliseconds - the first timestamp in netdata
- this.netdata_last = 0; // milliseconds - the last timestamp in netdata
- this.requested_after = null; // milliseconds - the timestamp of the request after param
- this.requested_before = null; // milliseconds - the timestamp of the request before param
- this.requested_padding = null;
- this.view_after = 0;
- this.view_before = 0;
-
- this.auto = {
- name: 'auto',
- autorefresh: true,
- force_update_at: 0, // the timestamp to force the update at
- force_before_ms: null,
- force_after_ms: null
- };
- this.pan = {
- name: 'pan',
- autorefresh: false,
- force_update_at: 0, // the timestamp to force the update at
- force_before_ms: null,
- force_after_ms: null
- };
- this.zoom = {
- name: 'zoom',
- autorefresh: false,
- force_update_at: 0, // the timestamp to force the update at
- force_before_ms: null,
- force_after_ms: null
- };
-
- // this is a pointer to one of the sub-classes below
- // auto, pan, zoom
- this.current = this.auto;
-
- // check the requested library is available
- // we don't initialize it here - it will be initialized when
- // this chart will be first used
- if(typeof NETDATA.chartLibraries[that.library_name] === 'undefined') {
- NETDATA.error(402, that.library_name);
- error('chart library "' + that.library_name + '" is not found');
- return;
- }
- else if(NETDATA.chartLibraries[that.library_name].enabled === false) {
- NETDATA.error(403, that.library_name);
- error('chart library "' + that.library_name + '" is not enabled');
- return;
- }
- else
- that.library = NETDATA.chartLibraries[that.library_name];
-
- // milliseconds - the time the last refresh took
- this.refresh_dt_ms = 0;
-
- // if we need to report the rendering speed
- // find the element that needs to be updated
- var refresh_dt_element_name = self.data('dt-element-name') || null; // string - the element to print refresh_dt_ms
-
- if(refresh_dt_element_name !== null)
- this.refresh_dt_element = document.getElementById(refresh_dt_element_name) || null;
- else
- this.refresh_dt_element = null;
-
- this.dimensions_visibility = new dimensionsVisibility(this);
-
- this._updating = false;
-
- // ============================================================================================================
- // PRIVATE FUNCTIONS
-
- var createDOM = function() {
- if(that.enabled === false) return;
-
- if(that.element_message !== null) that.element_message.innerHTML = '';
- if(that.element_legend !== null) that.element_legend.innerHTML = '';
- if(that.element_chart !== null) that.element_chart.innerHTML = '';
-
- that.element.innerHTML = '';
-
- that.element_message = document.createElement('div');
- that.element_message.className = ' netdata-message hidden';
- that.element.appendChild(that.element_message);
-
- that.element_chart = document.createElement('div');
- that.element_chart.id = that.library_name + '-' + that.uuid + '-chart';
- that.element.appendChild(that.element_chart);
-
- if(that.hasLegend() === true) {
- that.element.className = "netdata-container-with-legend";
- that.element_chart.className = 'netdata-chart-with-legend-right netdata-' + that.library_name + '-chart-with-legend-right';
-
- that.element_legend = document.createElement('div');
- that.element_legend.className = 'netdata-chart-legend netdata-' + that.library_name + '-legend';
- that.element.appendChild(that.element_legend);
- }
- else {
- that.element.className = "netdata-container";
- that.element_chart.className = ' netdata-chart netdata-' + that.library_name + '-chart';
-
- that.element_legend = null;
- }
- that.element_legend_childs.series = null;
-
- if(typeof(that.width) === 'string')
- $(that.element).css('width', that.width);
- else if(typeof(that.width) === 'number')
- $(that.element).css('width', that.width + 'px');
-
- if(typeof(that.library.aspect_ratio) === 'undefined') {
- if(typeof(that.height) === 'string')
- $(that.element).css('height', that.height);
- else if(typeof(that.height) === 'number')
- $(that.element).css('height', that.height + 'px');
- }
- else {
- var w = that.element.offsetWidth;
- if(w === null || w === 0) {
- // the div is hidden
- // this will resize the chart when next viewed
- that.tm.last_resized = 0;
- }
- else
- $(that.element).css('height', (that.element.offsetWidth * that.library.aspect_ratio / 100).toString() + 'px');
- }
-
- if(NETDATA.chartDefaults.min_width !== null)
- $(that.element).css('min-width', NETDATA.chartDefaults.min_width);
-
- that.tm.last_dom_created = new Date().getTime();
-
- showLoading();
- };
-
- /* init() private
- * initialize state variables
- * destroy all (possibly) created state elements
- * create the basic DOM for a chart
- */
- var init = function() {
- if(that.enabled === false) return;
-
- that.paused = false;
- that.selected = false;
-
- that.chart_created = false; // boolean - is the library.create() been called?
- that.updates_counter = 0; // numeric - the number of refreshes made so far
- that.updates_since_last_unhide = 0; // numeric - the number of refreshes made since the last time the chart was unhidden
- that.updates_since_last_creation = 0; // numeric - the number of refreshes made since the last time the chart was created
-
- that.tm = {
- last_initialized: 0, // milliseconds - the timestamp it was last initialized
- last_dom_created: 0, // milliseconds - the timestamp its DOM was last created
- last_mode_switch: 0, // milliseconds - the timestamp it switched modes
-
- last_info_downloaded: 0, // milliseconds - the timestamp we downloaded the chart
- last_updated: 0, // the timestamp the chart last updated with data
- pan_and_zoom_seq: 0, // the sequence number of the global synchronization
- // between chart.
- // Used with NETDATA.globalPanAndZoom.seq
- last_visible_check: 0, // the time we last checked if it is visible
- last_resized: 0, // the time the chart was resized
- last_hidden: 0, // the time the chart was hidden
- last_unhidden: 0, // the time the chart was unhidden
- last_autorefreshed: 0 // the time the chart was last refreshed
- };
-
- that.data = null; // the last data as downloaded from the netdata server
- that.data_url = 'invalid://'; // string - the last url used to update the chart
- that.data_points = 0; // number - the number of points returned from netdata
- that.data_after = 0; // milliseconds - the first timestamp of the data
- that.data_before = 0; // milliseconds - the last timestamp of the data
- that.data_update_every = 0; // milliseconds - the frequency to update the data
-
- that.tm.last_initialized = new Date().getTime();
- createDOM();
-
- that.setMode('auto');
- };
-
- var maxMessageFontSize = function() {
- // normally we want a font size, as tall as the element
- var h = that.element_message.clientHeight;
-
- // but give it some air, 20% let's say, or 5 pixels min
- var lost = Math.max(h * 0.2, 5);
- h -= lost;
-
- // center the text, vertically
- var paddingTop = (lost - 5) / 2;
-
- // but check the width too
- // it should fit 10 characters in it
- var w = that.element_message.clientWidth / 10;
- if(h > w) {
- paddingTop += (h - w) / 2;
- h = w;
- }
-
- // and don't make it too huge
- // 5% of the screen size is good
- if(h > screen.height / 20) {
- paddingTop += (h - (screen.height / 20)) / 2;
- h = screen.height / 20;
- }
-
- // set it
- that.element_message.style.fontSize = h.toString() + 'px';
- that.element_message.style.paddingTop = paddingTop.toString() + 'px';
- };
-
- var showMessage = function(msg) {
- that.element_message.className = 'netdata-message';
- that.element_message.innerHTML = msg;
- that.element_message.style.fontSize = 'x-small';
- that.element_message.style.paddingTop = '0px';
- that.___messageHidden___ = undefined;
- };
-
- var showMessageIcon = function(icon) {
- that.element_message.innerHTML = icon;
- that.element_message.className = 'netdata-message icon';
- maxMessageFontSize();
- that.___messageHidden___ = undefined;
- };
-
- var hideMessage = function() {
- if(typeof that.___messageHidden___ === 'undefined') {
- that.___messageHidden___ = true;
- that.element_message.className = 'netdata-message hidden';
- }
- };
-
- var showRendering = function() {
- var icon;
- if(that.chart !== null) {
- if(that.chart.chart_type === 'line')
- icon = '<i class="fa fa-line-chart"></i>';
- else
- icon = '<i class="fa fa-area-chart"></i>';
- }
- else
- icon = '<i class="fa fa-area-chart"></i>';
-
- showMessageIcon(icon + ' netdata');
- };
-
- var showLoading = function() {
- if(that.chart_created === false) {
- showMessageIcon('<i class="fa fa-refresh"></i> netdata');
- return true;
- }
- return false;
- };
-
- var isHidden = function() {
- if(typeof that.___chartIsHidden___ !== 'undefined')
- return true;
-
- return false;
- };
-
- // hide the chart, when it is not visible - called from isVisible()
- var hideChart = function() {
- // hide it, if it is not already hidden
- if(isHidden() === true) return;
-
- if(that.chart_created === true) {
- if(NETDATA.options.current.destroy_on_hide === true) {
- // we should destroy it
- init();
- }
- else {
- showRendering();
- that.element_chart.style.display = 'none';
- if(that.element_legend !== null) that.element_legend.style.display = 'none';
- that.tm.last_hidden = new Date().getTime();
-
- // de-allocate data
- // This works, but I not sure there are no corner cases somewhere
- // so it is commented - if the user has memory issues he can
- // set Destroy on Hide for all charts
- // that.data = null;
- }
- }
-
- that.___chartIsHidden___ = true;
- };
-
- // unhide the chart, when it is visible - called from isVisible()
- var unhideChart = function() {
- if(isHidden() === false) return;
-
- that.___chartIsHidden___ = undefined;
- that.updates_since_last_unhide = 0;
-
- if(that.chart_created === false) {
- // we need to re-initialize it, to show our background
- // logo in bootstrap tabs, until the chart loads
- init();
- }
- else {
- that.tm.last_unhidden = new Date().getTime();
- that.element_chart.style.display = '';
- if(that.element_legend !== null) that.element_legend.style.display = '';
- resizeChart();
- hideMessage();
- }
- };
-
- var canBeRendered = function() {
- if(isHidden() === true || that.isVisible(true) === false)
- return false;
-
- return true;
- };
-
- // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
- var callChartLibraryUpdateSafely = function(data) {
- var status;
-
- if(canBeRendered() === false)
- return false;
-
- if(NETDATA.options.debug.chart_errors === true)
- status = that.library.update(that, data);
- else {
- try {
- status = that.library.update(that, data);
- }
- catch(err) {
- status = false;
- }
- }
-
- if(status === false) {
- error('chart failed to be updated as ' + that.library_name);
- return false;
- }
-
- return true;
- };
-
- // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
- var callChartLibraryCreateSafely = function(data) {
- var status;
-
- if(canBeRendered() === false)
- return false;
-
- if(NETDATA.options.debug.chart_errors === true)
- status = that.library.create(that, data);
- else {
- try {
- status = that.library.create(that, data);
- }
- catch(err) {
- status = false;
- }
- }
-
- if(status === false) {
- error('chart failed to be created as ' + that.library_name);
- return false;
- }
-
- that.chart_created = true;
- that.updates_since_last_creation = 0;
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // Chart Resize
-
- // resizeChart() - private
- // to be called just before the chart library to make sure that
- // a properly sized dom is available
- var resizeChart = function() {
- if(that.isVisible() === true && that.tm.last_resized < NETDATA.options.last_resized) {
- if(that.chart_created === false) return;
-
- if(that.needsRecreation()) {
- init();
- }
- else if(typeof that.library.resize === 'function') {
- that.library.resize(that);
-
- if(that.element_legend_childs.nano !== null && that.element_legend_childs.nano_options !== null)
- $(that.element_legend_childs.nano).nanoScroller();
-
- maxMessageFontSize();
- }
-
- that.tm.last_resized = new Date().getTime();
- }
- };
-
- // this is the actual chart resize algorithm
- // it will:
- // - resize the entire container
- // - update the internal states
- // - resize the chart as the div changes height
- // - update the scrollbar of the legend
- var resizeChartToHeight = function(h) {
- // console.log(h);
- that.element.style.height = h;
-
- if(that.settings_id !== null)
- NETDATA.localStorageSet('chart_heights.' + that.settings_id, h);
-
- var now = new Date().getTime();
- NETDATA.options.last_page_scroll = now;
- NETDATA.options.auto_refresher_stop_until = now + NETDATA.options.current.stop_updates_while_resizing;
-
- // force a resize
- that.tm.last_resized = 0;
- resizeChart();
- };
-
- this.resizeHandler = function(e) {
- e.preventDefault();
-
- if(typeof this.event_resize === 'undefined'
- || this.event_resize.chart_original_w === 'undefined'
- || this.event_resize.chart_original_h === 'undefined')
- this.event_resize = {
- chart_original_w: this.element.clientWidth,
- chart_original_h: this.element.clientHeight,
- last: 0
- };
-
- if(e.type === 'touchstart') {
- this.event_resize.mouse_start_x = e.touches.item(0).pageX;
- this.event_resize.mouse_start_y = e.touches.item(0).pageY;
- }
- else {
- this.event_resize.mouse_start_x = e.clientX;
- this.event_resize.mouse_start_y = e.clientY;
- }
-
- this.event_resize.chart_start_w = this.element.clientWidth;
- this.event_resize.chart_start_h = this.element.clientHeight;
- this.event_resize.chart_last_w = this.element.clientWidth;
- this.event_resize.chart_last_h = this.element.clientHeight;
-
- var now = new Date().getTime();
- if(now - this.event_resize.last <= NETDATA.options.current.double_click_speed) {
- // double click / double tap event
-
- // the optimal height of the chart
- // showing the entire legend
- var optimal = this.event_resize.chart_last_h
- + this.element_legend_childs.content.scrollHeight
- - this.element_legend_childs.content.clientHeight;
-
- // if we are not optimal, be optimal
- if(this.event_resize.chart_last_h != optimal)
- resizeChartToHeight(optimal.toString() + 'px');
-
- // else if we do not have the original height
- // reset to the original height
- else if(this.event_resize.chart_last_h != this.event_resize.chart_original_h)
- resizeChartToHeight(this.event_resize.chart_original_h.toString() + 'px');
- }
- else {
- this.event_resize.last = now;
-
- // process movement event
- document.onmousemove =
- document.ontouchmove =
- this.element_legend_childs.resize_handler.onmousemove =
- this.element_legend_childs.resize_handler.ontouchmove =
- function(e) {
- var y = null;
-
- switch(e.type) {
- case 'mousemove': y = e.clientY; break;
- case 'touchmove': y = e.touches.item(e.touches - 1).pageY; break;
- }
-
- if(y !== null) {
- var newH = that.event_resize.chart_start_h + y - that.event_resize.mouse_start_y;
-
- if(newH >= 70 && newH !== that.event_resize.chart_last_h) {
- resizeChartToHeight(newH.toString() + 'px');
- that.event_resize.chart_last_h = newH;
- }
- }
- };
-
- // process end event
- document.onmouseup =
- document.ontouchend =
- this.element_legend_childs.resize_handler.onmouseup =
- this.element_legend_childs.resize_handler.ontouchend =
- function(e) {
- // remove all the hooks
- document.onmouseup =
- document.onmousemove =
- document.ontouchmove =
- document.ontouchend =
- that.element_legend_childs.resize_handler.onmousemove =
- that.element_legend_childs.resize_handler.ontouchmove =
- that.element_legend_childs.resize_handler.onmouseout =
- that.element_legend_childs.resize_handler.onmouseup =
- that.element_legend_childs.resize_handler.ontouchend =
- null;
-
- // allow auto-refreshes
- NETDATA.options.auto_refresher_stop_until = 0;
- };
- }
- };
-
-
- var noDataToShow = function() {
- showMessageIcon('<i class="fa fa-warning"></i> empty');
- that.legendUpdateDOM();
- that.tm.last_autorefreshed = new Date().getTime();
- // that.data_update_every = 30 * 1000;
- //that.element_chart.style.display = 'none';
- //if(that.element_legend !== null) that.element_legend.style.display = 'none';
- //that.___chartIsHidden___ = true;
- };
-
- // ============================================================================================================
- // PUBLIC FUNCTIONS
-
- this.error = function(msg) {
- error(msg);
- };
-
- this.setMode = function(m) {
- if(this.current !== null && this.current.name === m) return;
-
- if(m === 'auto')
- this.current = this.auto;
- else if(m === 'pan')
- this.current = this.pan;
- else if(m === 'zoom')
- this.current = this.zoom;
- else
- this.current = this.auto;
-
- this.current.force_update_at = 0;
- this.current.force_before_ms = null;
- this.current.force_after_ms = null;
-
- this.tm.last_mode_switch = new Date().getTime();
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // global selection sync
-
- // prevent to global selection sync for some time
- this.globalSelectionSyncDelay = function(ms) {
- if(NETDATA.options.current.sync_selection === false)
- return;
-
- if(typeof ms === 'number')
- NETDATA.globalSelectionSync.dont_sync_before = new Date().getTime() + ms;
- else
- NETDATA.globalSelectionSync.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
- };
-
- // can we globally apply selection sync?
- this.globalSelectionSyncAbility = function() {
- if(NETDATA.options.current.sync_selection === false)
- return false;
-
- if(NETDATA.globalSelectionSync.dont_sync_before > new Date().getTime())
- return false;
-
- return true;
- };
-
- this.globalSelectionSyncIsMaster = function() {
- if(NETDATA.globalSelectionSync.state === this)
- return true;
- else
- return false;
- };
-
- // this chart is the master of the global selection sync
- this.globalSelectionSyncBeMaster = function() {
- // am I the master?
- if(this.globalSelectionSyncIsMaster()) {
- if(this.debug === true)
- this.log('sync: I am the master already.');
-
- return;
- }
-
- if(NETDATA.globalSelectionSync.state) {
- if(this.debug === true)
- this.log('sync: I am not the sync master. Resetting global sync.');
-
- this.globalSelectionSyncStop();
- }
-
- // become the master
- if(this.debug === true)
- this.log('sync: becoming sync master.');
-
- this.selected = true;
- NETDATA.globalSelectionSync.state = this;
-
- // find the all slaves
- var targets = NETDATA.options.targets;
- var len = targets.length;
- while(len--) {
- st = targets[len];
-
- if(st === this) {
- if(this.debug === true)
- st.log('sync: not adding me to sync');
- }
- else if(st.globalSelectionSyncIsEligible()) {
- if(this.debug === true)
- st.log('sync: adding to sync as slave');
-
- st.globalSelectionSyncBeSlave();
- }
- }
-
- // this.globalSelectionSyncDelay(100);
- };
-
- // can the chart participate to the global selection sync as a slave?
- this.globalSelectionSyncIsEligible = function() {
- if(this.enabled === true
- && this.library !== null
- && typeof this.library.setSelection === 'function'
- && this.isVisible() === true
- && this.chart_created === true)
- return true;
-
- return false;
- };
-
- // this chart becomes a slave of the global selection sync
- this.globalSelectionSyncBeSlave = function() {
- if(NETDATA.globalSelectionSync.state !== this)
- NETDATA.globalSelectionSync.slaves.push(this);
- };
-
- // sync all the visible charts to the given time
- // this is to be called from the chart libraries
- this.globalSelectionSync = function(t) {
- if(this.globalSelectionSyncAbility() === false) {
- if(this.debug === true)
- this.log('sync: cannot sync (yet?).');
-
- return;
- }
-
- if(this.globalSelectionSyncIsMaster() === false) {
- if(this.debug === true)
- this.log('sync: trying to be sync master.');
-
- this.globalSelectionSyncBeMaster();
-
- if(this.globalSelectionSyncAbility() === false) {
- if(this.debug === true)
- this.log('sync: cannot sync (yet?).');
-
- return;
- }
- }
-
- NETDATA.globalSelectionSync.last_t = t;
- $.each(NETDATA.globalSelectionSync.slaves, function(i, st) {
- st.setSelection(t);
- });
- };
-
- // stop syncing all charts to the given time
- this.globalSelectionSyncStop = function() {
- if(NETDATA.globalSelectionSync.slaves.length) {
- if(this.debug === true)
- this.log('sync: cleaning up...');
-
- $.each(NETDATA.globalSelectionSync.slaves, function(i, st) {
- if(st === that) {
- if(that.debug === true)
- st.log('sync: not adding me to sync stop');
- }
- else {
- if(that.debug === true)
- st.log('sync: removed slave from sync');
-
- st.clearSelection();
- }
- });
-
- NETDATA.globalSelectionSync.last_t = 0;
- NETDATA.globalSelectionSync.slaves = [];
- NETDATA.globalSelectionSync.state = null;
- }
-
- this.clearSelection();
- };
-
- this.setSelection = function(t) {
- if(typeof this.library.setSelection === 'function') {
- if(this.library.setSelection(this, t) === true)
- this.selected = true;
- else
- this.selected = false;
- }
- else this.selected = true;
-
- if(this.selected === true && this.debug === true)
- this.log('selection set to ' + t.toString());
-
- return this.selected;
- };
-
- this.clearSelection = function() {
- if(this.selected === true) {
- if(typeof this.library.clearSelection === 'function') {
- if(this.library.clearSelection(this) === true)
- this.selected = false;
- else
- this.selected = true;
- }
- else this.selected = false;
-
- if(this.selected === false && this.debug === true)
- this.log('selection cleared');
-
- this.legendReset();
- }
-
- return this.selected;
- };
-
- // find if a timestamp (ms) is shown in the current chart
- this.timeIsVisible = function(t) {
- if(t >= this.data_after && t <= this.data_before)
- return true;
- return false;
- };
-
- this.calculateRowForTime = function(t) {
- if(this.timeIsVisible(t) === false) return -1;
- return Math.floor((t - this.data_after) / this.data_update_every);
- };
-
- // ----------------------------------------------------------------------------------------------------------------
-
- // console logging
- this.log = function(msg) {
- console.log(this.id + ' (' + this.library_name + ' ' + this.uuid + '): ' + msg);
- };
-
- this.pauseChart = function() {
- if(this.paused === false) {
- if(this.debug === true)
- this.log('pauseChart()');
-
- this.paused = true;
- }
- };
-
- this.unpauseChart = function() {
- if(this.paused === true) {
- if(this.debug === true)
- this.log('unpauseChart()');
-
- this.paused = false;
- }
- };
-
- this.resetChart = function(dont_clear_master, dont_update) {
- if(this.debug === true)
- this.log('resetChart(' + dont_clear_master + ', ' + dont_update + ') called');
-
- if(typeof dont_clear_master === 'undefined')
- dont_clear_master = false;
-
- if(typeof dont_update === 'undefined')
- dont_update = false;
-
- if(dont_clear_master !== true && NETDATA.globalPanAndZoom.isMaster(this) === true) {
- if(this.debug === true)
- this.log('resetChart() diverting to clearMaster().');
- // this will call us back with master === true
- NETDATA.globalPanAndZoom.clearMaster();
- return;
- }
-
- this.clearSelection();
-
- this.tm.pan_and_zoom_seq = 0;
-
- this.setMode('auto');
- this.current.force_update_at = 0;
- this.current.force_before_ms = null;
- this.current.force_after_ms = null;
- this.tm.last_autorefreshed = 0;
- this.paused = false;
- this.selected = false;
- this.enabled = true;
- // this.debug = false;
-
- // do not update the chart here
- // or the chart will flip-flop when it is the master
- // of a selection sync and another chart becomes
- // the new master
-
- if(dont_update !== true && this.isVisible() === true) {
- this.updateChart();
- }
- };
-
- this.updateChartPanOrZoom = function(after, before) {
- var logme = 'updateChartPanOrZoom(' + after + ', ' + before + '): ';
- var ret = true;
-
- if(this.debug === true)
- this.log(logme);
-
- if(before < after) {
- if(this.debug === true)
- this.log(logme + 'flipped parameters, rejecting it.');
-
- return false;
- }
-
- if(typeof this.fixed_min_duration === 'undefined')
- this.fixed_min_duration = Math.round((this.chartWidth() / 30) * this.chart.update_every * 1000);
-
- var min_duration = this.fixed_min_duration;
- var current_duration = Math.round(this.view_before - this.view_after);
-
- // round the numbers
- after = Math.round(after);
- before = Math.round(before);
-
- // align them to update_every
- // stretching them further away
- after -= after % this.data_update_every;
- before += this.data_update_every - (before % this.data_update_every);
-
- // the final wanted duration
- var wanted_duration = before - after;
-
- // to allow panning, accept just a point below our minimum
- if((current_duration - this.data_update_every) < min_duration)
- min_duration = current_duration - this.data_update_every;
-
- // we do it, but we adjust to minimum size and return false
- // when the wanted size is below the current and the minimum
- // and we zoom
- if(wanted_duration < current_duration && wanted_duration < min_duration) {
- if(this.debug === true)
- this.log(logme + 'too small: min_duration: ' + (min_duration / 1000).toString() + ', wanted: ' + (wanted_duration / 1000).toString());
-
- min_duration = this.fixed_min_duration;
-
- var dt = (min_duration - wanted_duration) / 2;
- before += dt;
- after -= dt;
- wanted_duration = before - after;
- ret = false;
- }
-
- var tolerance = this.data_update_every * 2;
- var movement = Math.abs(before - this.view_before);
-
- if(Math.abs(current_duration - wanted_duration) <= tolerance && movement <= tolerance && ret === true) {
- if(this.debug === true)
- this.log(logme + 'REJECTING UPDATE: current/min duration: ' + (current_duration / 1000).toString() + '/' + (this.fixed_min_duration / 1000).toString() + ', wanted duration: ' + (wanted_duration / 1000).toString() + ', duration diff: ' + (Math.round(Math.abs(current_duration - wanted_duration) / 1000)).toString() + ', movement: ' + (movement / 1000).toString() + ', tolerance: ' + (tolerance / 1000).toString() + ', returning: ' + false);
- return false;
- }
-
- if(this.current.name === 'auto') {
- this.log(logme + 'caller called me with mode: ' + this.current.name);
- this.setMode('pan');
- }
-
- if(this.debug === true)
- this.log(logme + 'ACCEPTING UPDATE: current/min duration: ' + (current_duration / 1000).toString() + '/' + (this.fixed_min_duration / 1000).toString() + ', wanted duration: ' + (wanted_duration / 1000).toString() + ', duration diff: ' + (Math.round(Math.abs(current_duration - wanted_duration) / 1000)).toString() + ', movement: ' + (movement / 1000).toString() + ', tolerance: ' + (tolerance / 1000).toString() + ', returning: ' + ret);
-
- this.current.force_update_at = new Date().getTime() + NETDATA.options.current.pan_and_zoom_delay;
- this.current.force_after_ms = after;
- this.current.force_before_ms = before;
- NETDATA.globalPanAndZoom.setMaster(this, after, before);
- return ret;
- };
-
- this.legendFormatValue = function(value) {
- if(value === null || value === 'undefined') return '-';
- if(typeof value !== 'number') return value;
-
- var abs = Math.abs(value);
- if(abs >= 1000) return (Math.round(value)).toLocaleString();
- if(abs >= 100 ) return (Math.round(value * 10) / 10).toLocaleString();
- if(abs >= 1 ) return (Math.round(value * 100) / 100).toLocaleString();
- if(abs >= 0.1 ) return (Math.round(value * 1000) / 1000).toLocaleString();
- return (Math.round(value * 10000) / 10000).toLocaleString();
- };
-
- this.legendSetLabelValue = function(label, value) {
- var series = this.element_legend_childs.series[label];
- if(typeof series === 'undefined') return;
- if(series.value === null && series.user === null) return;
-
- // if the value has not changed, skip DOM update
- //if(series.last === value) return;
-
- var s, r;
- if(typeof value === 'number') {
- var v = Math.abs(value);
- s = r = this.legendFormatValue(value);
-
- if(typeof series.last === 'number') {
- if(v > series.last) s += '<i class="fa fa-angle-up" style="width: 8px; text-align: center; overflow: hidden; vertical-align: middle;"></i>';
- else if(v < series.last) s += '<i class="fa fa-angle-down" style="width: 8px; text-align: center; overflow: hidden; vertical-align: middle;"></i>';
- else s += '<i class="fa fa-angle-left" style="width: 8px; text-align: center; overflow: hidden; vertical-align: middle;"></i>';
- }
- else s += '<i class="fa fa-angle-right" style="width: 8px; text-align: center; overflow: hidden; vertical-align: middle;"></i>';
- series.last = v;
- }
- else {
- s = r = value;
- series.last = value;
- }
-
- if(series.value !== null) series.value.innerHTML = s;
- if(series.user !== null) series.user.innerHTML = r;
- };
-
- this.legendSetDate = function(ms) {
- if(typeof ms !== 'number') {
- this.legendShowUndefined();
- return;
- }
-
- var d = new Date(ms);
-
- if(this.element_legend_childs.title_date)
- this.element_legend_childs.title_date.innerHTML = d.toLocaleDateString();
-
- if(this.element_legend_childs.title_time)
- this.element_legend_childs.title_time.innerHTML = d.toLocaleTimeString();
-
- if(this.element_legend_childs.title_units)
- this.element_legend_childs.title_units.innerHTML = this.units;
- };
-
- this.legendShowUndefined = function() {
- if(this.element_legend_childs.title_date)
- this.element_legend_childs.title_date.innerHTML = '&nbsp;';
-
- if(this.element_legend_childs.title_time)
- this.element_legend_childs.title_time.innerHTML = this.chart.name;
-
- if(this.element_legend_childs.title_units)
- this.element_legend_childs.title_units.innerHTML = '&nbsp;';
-
- if(this.data && this.element_legend_childs.series !== null) {
- var labels = this.data.dimension_names;
- var i = labels.length;
- while(i--) {
- var label = labels[i];
-
- if(typeof label === 'undefined') continue;
- if(typeof this.element_legend_childs.series[label] === 'undefined') continue;
- this.legendSetLabelValue(label, null);
- }
- }
- };
-
- this.legendShowLatestValues = function() {
- if(this.chart === null) return;
- if(this.selected) return;
-
- if(this.data === null || this.element_legend_childs.series === null) {
- this.legendShowUndefined();
- return;
- }
-
- var show_undefined = true;
- if(Math.abs(this.netdata_last - this.view_before) <= this.data_update_every)
- show_undefined = false;
-
- if(show_undefined) {
- this.legendShowUndefined();
- return;
- }
-
- this.legendSetDate(this.view_before);
-
- var labels = this.data.dimension_names;
- var i = labels.length;
- while(i--) {
- var label = labels[i];
-
- if(typeof label === 'undefined') continue;
- if(typeof this.element_legend_childs.series[label] === 'undefined') continue;
-
- if(show_undefined)
- this.legendSetLabelValue(label, null);
- else
- this.legendSetLabelValue(label, this.data.view_latest_values[i]);
- }
- };
-
- this.legendReset = function() {
- this.legendShowLatestValues();
- };
-
- // this should be called just ONCE per dimension per chart
- this._chartDimensionColor = function(label) {
- if(this.colors === null) this.chartColors();
-
- if(typeof this.colors_assigned[label] === 'undefined') {
- if(this.colors_available.length === 0) {
- for(var i = 0, len = NETDATA.themes.current.colors.length; i < len ; i++)
- this.colors_available.push(NETDATA.themes.current.colors[i]);
- }
-
- this.colors_assigned[label] = this.colors_available.shift();
-
- if(this.debug === true)
- this.log('label "' + label + '" got color "' + this.colors_assigned[label]);
- }
- else {
- if(this.debug === true)
- this.log('label "' + label + '" already has color "' + this.colors_assigned[label] + '"');
- }
-
- this.colors.push(this.colors_assigned[label]);
- return this.colors_assigned[label];
- };
-
- this.chartColors = function() {
- if(this.colors !== null) return this.colors;
-
- this.colors = new Array();
- this.colors_available = new Array();
- var i, len;
-
- var c = $(this.element).data('colors');
- // this.log('read colors: ' + c);
- if(typeof c !== 'undefined' && c !== null && c.length > 0) {
- if(typeof c !== 'string') {
- this.log('invalid color given: ' + c + ' (give a space separated list of colors)');
- }
- else {
- c = c.split(' ');
- var added = 0;
-
- while(added < 20) {
- for(i = 0, len = c.length; i < len ; i++) {
- added++;
- this.colors_available.push(c[i]);
- // this.log('adding color: ' + c[i]);
- }
- }
- }
- }
-
- // push all the standard colors too
- for(i = 0, len = NETDATA.themes.current.colors.length; i < len ; i++)
- this.colors_available.push(NETDATA.themes.current.colors[i]);
-
- return this.colors;
- };
-
- this.legendUpdateDOM = function() {
- var needed = false;
-
- // check that the legend DOM is up to date for the downloaded dimensions
- if(typeof this.element_legend_childs.series !== 'object' || this.element_legend_childs.series === null) {
- // this.log('the legend does not have any series - requesting legend update');
- needed = true;
- }
- else if(this.data === null) {
- // this.log('the chart does not have any data - requesting legend update');
- needed = true;
- }
- else if(typeof this.element_legend_childs.series.labels_key === 'undefined') {
- needed = true;
- }
- else {
- var labels = this.data.dimension_names.toString();
- if(labels !== this.element_legend_childs.series.labels_key) {
- needed = true;
-
- if(this.debug === true)
- this.log('NEW LABELS: "' + labels + '" NOT EQUAL OLD LABELS: "' + this.element_legend_childs.series.labels_key + '"');
- }
- }
-
- if(needed === false) {
- // make sure colors available
- this.chartColors();
-
- // do we have to update the current values?
- // we do this, only when the visible chart is current
- if(Math.abs(this.netdata_last - this.view_before) <= this.data_update_every) {
- if(this.debug === true)
- this.log('chart is in latest position... updating values on legend...');
-
- //var labels = this.data.dimension_names;
- //var i = labels.length;
- //while(i--)
- // this.legendSetLabelValue(labels[i], this.data.latest_values[i]);
- }
- return;
- }
- if(this.colors === null) {
- // this is the first time we update the chart
- // let's assign colors to all dimensions
- if(this.library.track_colors() === true)
- for(var dim in this.chart.dimensions)
- this._chartDimensionColor(this.chart.dimensions[dim].name);
- }
- // we will re-generate the colors for the chart
- // based on the selected dimensions
- this.colors = null;
-
- if(this.debug === true)
- this.log('updating Legend DOM');
-
- // mark all dimensions as invalid
- this.dimensions_visibility.invalidateAll();
-
- var genLabel = function(state, parent, name, count) {
- var color = state._chartDimensionColor(name);
-
- var user_element = null;
- var user_id = self.data('show-value-of-' + name + '-at') || null;
- if(user_id !== null) {
- user_element = document.getElementById(user_id) || null;
- if(user_element === null)
- state.log('Cannot find element with id: ' + user_id);
- }
-
- state.element_legend_childs.series[name] = {
- name: document.createElement('span'),
- value: document.createElement('span'),
- user: user_element,
- last: null
- };
-
- var label = state.element_legend_childs.series[name];
-
- // create the dimension visibility tracking for this label
- state.dimensions_visibility.dimensionAdd(name, label.name, label.value, color);
-
- var rgb = NETDATA.colorHex2Rgb(color);
- label.name.innerHTML = '<table class="netdata-legend-name-table-'
- + state.chart.chart_type
- + '" style="background-color: '
- + 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + NETDATA.options.current['color_fill_opacity_' + state.chart.chart_type] + ')'
- + '"><tr class="netdata-legend-name-tr"><td class="netdata-legend-name-td"></td></tr></table>'
-
- var text = document.createTextNode(' ' + name);
- label.name.appendChild(text);
-
- if(count > 0)
- parent.appendChild(document.createElement('br'));
-
- parent.appendChild(label.name);
- parent.appendChild(label.value);
- };
-
- var content = document.createElement('div');
-
- if(this.hasLegend()) {
- this.element_legend_childs = {
- content: content,
- resize_handler: document.createElement('div'),
- toolbox: document.createElement('div'),
- toolbox_left: document.createElement('div'),
- toolbox_right: document.createElement('div'),
- toolbox_reset: document.createElement('div'),
- toolbox_zoomin: document.createElement('div'),
- toolbox_zoomout: document.createElement('div'),
- toolbox_volume: document.createElement('div'),
- title_date: document.createElement('span'),
- title_time: document.createElement('span'),
- title_units: document.createElement('span'),
- nano: document.createElement('div'),
- nano_options: {
- paneClass: 'netdata-legend-series-pane',
- sliderClass: 'netdata-legend-series-slider',
- contentClass: 'netdata-legend-series-content',
- enabledClass: '__enabled',
- flashedClass: '__flashed',
- activeClass: '__active',
- tabIndex: -1,
- alwaysVisible: true,
- sliderMinHeight: 10
- },
- series: {}
- };
-
- this.element_legend.innerHTML = '';
-
- if(this.library.toolboxPanAndZoom !== null) {
-
- function get_pan_and_zoom_step(event) {
- if (event.ctrlKey)
- return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_control;
-
- else if (event.shiftKey)
- return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_shift;
-
- else if (event.altKey)
- return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_alt;
-
- else
- return NETDATA.options.current.pan_and_zoom_factor;
- }
-
- this.element_legend_childs.toolbox.className += ' netdata-legend-toolbox';
- this.element.appendChild(this.element_legend_childs.toolbox);
-
- this.element_legend_childs.toolbox_left.className += ' netdata-legend-toolbox-button';
- this.element_legend_childs.toolbox_left.innerHTML = '<i class="fa fa-backward"></i>';
- this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_left);
- this.element_legend_childs.toolbox_left.onclick = function(e) {
- e.preventDefault();
-
- var step = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
- var before = that.view_before - step;
- var after = that.view_after - step;
- if(after >= that.netdata_first)
- that.library.toolboxPanAndZoom(that, after, before);
- };
- if(NETDATA.options.current.show_help === true)
- $(this.element_legend_childs.toolbox_left).popover({
- container: "body",
- animation: false,
- html: true,
- trigger: 'hover',
- placement: 'bottom',
- delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
- title: 'Pan Left',
- content: 'Pan the chart to the left. You can also <b>drag it</b> with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
- });
-
-
- this.element_legend_childs.toolbox_reset.className += ' netdata-legend-toolbox-button';
- this.element_legend_childs.toolbox_reset.innerHTML = '<i class="fa fa-play"></i>';
- this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_reset);
- this.element_legend_childs.toolbox_reset.onclick = function(e) {
- e.preventDefault();
- NETDATA.resetAllCharts(that);
- };
- if(NETDATA.options.current.show_help === true)
- $(this.element_legend_childs.toolbox_reset).popover({
- container: "body",
- animation: false,
- html: true,
- trigger: 'hover',
- placement: 'bottom',
- delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
- title: 'Chart Reset',
- content: 'Reset all the charts to their default auto-refreshing state. You can also <b>double click</b> the chart contents with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
- });
-
- this.element_legend_childs.toolbox_right.className += ' netdata-legend-toolbox-button';
- this.element_legend_childs.toolbox_right.innerHTML = '<i class="fa fa-forward"></i>';
- this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_right);
- this.element_legend_childs.toolbox_right.onclick = function(e) {
- e.preventDefault();
- var step = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
- var before = that.view_before + step;
- var after = that.view_after + step;
- if(before <= that.netdata_last)
- that.library.toolboxPanAndZoom(that, after, before);
- };
- if(NETDATA.options.current.show_help === true)
- $(this.element_legend_childs.toolbox_right).popover({
- container: "body",
- animation: false,
- html: true,
- trigger: 'hover',
- placement: 'bottom',
- delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
- title: 'Pan Right',
- content: 'Pan the chart to the right. You can also <b>drag it</b> with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
- });
-
-
- this.element_legend_childs.toolbox_zoomin.className += ' netdata-legend-toolbox-button';
- this.element_legend_childs.toolbox_zoomin.innerHTML = '<i class="fa fa-plus"></i>';
- this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomin);
- this.element_legend_childs.toolbox_zoomin.onclick = function(e) {
- e.preventDefault();
- var dt = ((that.view_before - that.view_after) * (get_pan_and_zoom_step(e) * 0.8) / 2);
- var before = that.view_before - dt;
- var after = that.view_after + dt;
- that.library.toolboxPanAndZoom(that, after, before);
- };
- if(NETDATA.options.current.show_help === true)
- $(this.element_legend_childs.toolbox_zoomin).popover({
- container: "body",
- animation: false,
- html: true,
- trigger: 'hover',
- placement: 'bottom',
- delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
- title: 'Chart Zoom In',
- content: 'Zoom in the chart. You can also press SHIFT and select an area of the chart to zoom in. On Chrome and Opera, you can press the SHIFT or the ALT keys and then use the mouse wheel to zoom in or out.<br/><small>Help, can be disabled from the settings.</small>'
- });
-
- this.element_legend_childs.toolbox_zoomout.className += ' netdata-legend-toolbox-button';
- this.element_legend_childs.toolbox_zoomout.innerHTML = '<i class="fa fa-minus"></i>';
- this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomout);
- this.element_legend_childs.toolbox_zoomout.onclick = function(e) {
- e.preventDefault();
- var dt = (((that.view_before - that.view_after) / (1.0 - (get_pan_and_zoom_step(e) * 0.8)) - (that.view_before - that.view_after)) / 2);
- var before = that.view_before + dt;
- var after = that.view_after - dt;
-
- that.library.toolboxPanAndZoom(that, after, before);
- };
- if(NETDATA.options.current.show_help === true)
- $(this.element_legend_childs.toolbox_zoomout).popover({
- container: "body",
- animation: false,
- html: true,
- trigger: 'hover',
- placement: 'bottom',
- delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
- title: 'Chart Zoom Out',
- content: 'Zoom out the chart. On Chrome and Opera, you can also press the SHIFT or the ALT keys and then use the mouse wheel to zoom in or out.<br/><small>Help, can be disabled from the settings.</small>'
- });
-
- //this.element_legend_childs.toolbox_volume.className += ' netdata-legend-toolbox-button';
- //this.element_legend_childs.toolbox_volume.innerHTML = '<i class="fa fa-sort-amount-desc"></i>';
- //this.element_legend_childs.toolbox_volume.title = 'Visible Volume';
- //this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_volume);
- //this.element_legend_childs.toolbox_volume.onclick = function(e) {
- //e.preventDefault();
- //alert('clicked toolbox_volume on ' + that.id);
- //}
- }
- else {
- this.element_legend_childs.toolbox = null;
- this.element_legend_childs.toolbox_left = null;
- this.element_legend_childs.toolbox_reset = null;
- this.element_legend_childs.toolbox_right = null;
- this.element_legend_childs.toolbox_zoomin = null;
- this.element_legend_childs.toolbox_zoomout = null;
- this.element_legend_childs.toolbox_volume = null;
- }
-
- this.element_legend_childs.resize_handler.className += " netdata-legend-resize-handler";
- this.element_legend_childs.resize_handler.innerHTML = '<i class="fa fa-chevron-up"></i><i class="fa fa-chevron-down"></i>';
- this.element.appendChild(this.element_legend_childs.resize_handler);
- if(NETDATA.options.current.show_help === true)
- $(this.element_legend_childs.resize_handler).popover({
- container: "body",
- animation: false,
- html: true,
- trigger: 'hover',
- placement: 'bottom',
- delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
- title: 'Chart Resize',
- content: 'Drag this point with your mouse or your finger (on touch devices), to resize the chart vertically. You can also <b>double click it</b> or <b>double tap it</b> to reset between 2 states: the default and the one that fits all the values.<br/><small>Help, can be disabled from the settings.</small>'
- });
-
- // mousedown event
- this.element_legend_childs.resize_handler.onmousedown =
- function(e) {
- that.resizeHandler(e);
- };
-
- // touchstart event
- this.element_legend_childs.resize_handler.addEventListener('touchstart', function(e) {
- that.resizeHandler(e);
- }, false);
-
- this.element_legend_childs.title_date.className += " netdata-legend-title-date";
- this.element_legend.appendChild(this.element_legend_childs.title_date);
-
- this.element_legend.appendChild(document.createElement('br'));
-
- this.element_legend_childs.title_time.className += " netdata-legend-title-time";
- this.element_legend.appendChild(this.element_legend_childs.title_time);
-
- this.element_legend.appendChild(document.createElement('br'));
-
- this.element_legend_childs.title_units.className += " netdata-legend-title-units";
- this.element_legend.appendChild(this.element_legend_childs.title_units);
-
- this.element_legend.appendChild(document.createElement('br'));
-
- this.element_legend_childs.nano.className = 'netdata-legend-series';
- this.element_legend.appendChild(this.element_legend_childs.nano);
-
- content.className = 'netdata-legend-series-content';
- this.element_legend_childs.nano.appendChild(content);
-
- if(NETDATA.options.current.show_help === true)
- $(content).popover({
- container: "body",
- animation: false,
- html: true,
- trigger: 'hover',
- placement: 'bottom',
- title: 'Chart Legend',
- delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
- content: 'You can click or tap on the values or the labels to select dimentions. By pressing SHIFT or CONTROL, you can enable or disable multiple dimensions.<br/><small>Help, can be disabled from the settings.</small>'
- });
- }
- else {
- this.element_legend_childs = {
- content: content,
- resize_handler: null,
- toolbox: null,
- toolbox_left: null,
- toolbox_right: null,
- toolbox_reset: null,
- toolbox_zoomin: null,
- toolbox_zoomout: null,
- toolbox_volume: null,
- title_date: null,
- title_time: null,
- title_units: null,
- nano: null,
- nano_options: null,
- series: {}
- };
- }
-
- if(this.data) {
- this.element_legend_childs.series.labels_key = this.data.dimension_names.toString();
- if(this.debug === true)
- this.log('labels from data: "' + this.element_legend_childs.series.labels_key + '"');
-
- for(var i = 0, len = this.data.dimension_names.length; i < len ;i++) {
- genLabel(this, content, this.data.dimension_names[i], i);
- }
- }
- else {
- var tmp = new Array();
- for(var dim in this.chart.dimensions) {
- tmp.push(this.chart.dimensions[dim].name);
- genLabel(this, content, this.chart.dimensions[dim].name, i);
- }
- this.element_legend_childs.series.labels_key = tmp.toString();
- if(this.debug === true)
- this.log('labels from chart: "' + this.element_legend_childs.series.labels_key + '"');
- }
-
- // create a hidden div to be used for hidding
- // the original legend of the chart library
- var el = document.createElement('div');
- if(this.element_legend !== null)
- this.element_legend.appendChild(el);
- el.style.display = 'none';
-
- this.element_legend_childs.hidden = document.createElement('div');
- el.appendChild(this.element_legend_childs.hidden);
-
- if(this.element_legend_childs.nano !== null && this.element_legend_childs.nano_options !== null)
- $(this.element_legend_childs.nano).nanoScroller(this.element_legend_childs.nano_options);
-
- this.legendShowLatestValues();
- };
-
- this.hasLegend = function() {
- if(typeof this.___hasLegendCache___ !== 'undefined')
- return this.___hasLegendCache___;
-
- var leg = false;
- if(this.library && this.library.legend(this) === 'right-side') {
- var legend = $(this.element).data('legend') || 'yes';
- if(legend === 'yes') leg = true;
- }
-
- this.___hasLegendCache___ = leg;
- return leg;
- };
-
- this.legendWidth = function() {
- return (this.hasLegend())?140:0;
- };
-
- this.legendHeight = function() {
- return $(this.element).height();
- };
-
- this.chartWidth = function() {
- return $(this.element).width() - this.legendWidth();
- };
-
- this.chartHeight = function() {
- return $(this.element).height();
- };
-
- this.chartPixelsPerPoint = function() {
- // force an options provided detail
- var px = this.pixels_per_point;
-
- if(this.library && px < this.library.pixels_per_point(this))
- px = this.library.pixels_per_point(this);
-
- if(px < NETDATA.options.current.pixels_per_point)
- px = NETDATA.options.current.pixels_per_point;
-
- return px;
- };
-
- this.needsRecreation = function() {
- return (
- this.chart_created === true
- && this.library
- && this.library.autoresize() === false
- && this.tm.last_resized < NETDATA.options.last_resized
- );
- };
-
- this.chartURL = function() {
- var after, before, points_multiplier = 1;
- if(NETDATA.globalPanAndZoom.isActive() && NETDATA.globalPanAndZoom.isMaster(this) === false) {
- this.tm.pan_and_zoom_seq = NETDATA.globalPanAndZoom.seq;
-
- after = Math.round(NETDATA.globalPanAndZoom.force_after_ms / 1000);
- before = Math.round(NETDATA.globalPanAndZoom.force_before_ms / 1000);
- this.view_after = after * 1000;
- this.view_before = before * 1000;
-
- this.requested_padding = null;
- points_multiplier = 1;
- }
- else if(this.current.force_before_ms !== null && this.current.force_after_ms !== null) {
- this.tm.pan_and_zoom_seq = 0;
-
- before = Math.round(this.current.force_before_ms / 1000);
- after = Math.round(this.current.force_after_ms / 1000);
- this.view_after = after * 1000;
- this.view_before = before * 1000;
-
- if(NETDATA.options.current.pan_and_zoom_data_padding === true) {
- this.requested_padding = Math.round((before - after) / 2);
- after -= this.requested_padding;
- before += this.requested_padding;
- this.requested_padding *= 1000;
- points_multiplier = 2;
- }
-
- this.current.force_before_ms = null;
- this.current.force_after_ms = null;
- }
- else {
- this.tm.pan_and_zoom_seq = 0;
-
- before = this.before;
- after = this.after;
- this.view_after = after * 1000;
- this.view_before = before * 1000;
-
- this.requested_padding = null;
- points_multiplier = 1;
- }
-
- this.requested_after = after * 1000;
- this.requested_before = before * 1000;
-
- this.data_points = this.points || Math.round(this.chartWidth() / this.chartPixelsPerPoint());
-
- // build the data URL
- this.data_url = this.host + this.chart.data_url;
- this.data_url += "&format=" + this.library.format();
- this.data_url += "&points=" + (this.data_points * points_multiplier).toString();
- this.data_url += "&group=" + this.method;
- this.data_url += "&options=" + this.library.options(this);
- this.data_url += '|jsonwrap';
-
- if(NETDATA.options.current.eliminate_zero_dimensions === true)
- this.data_url += '|nonzero';
-
- if(this.append_options !== null)
- this.data_url += '|' + this.append_options.toString();
-
- if(after)
- this.data_url += "&after=" + after.toString();
-
- if(before)
- this.data_url += "&before=" + before.toString();
-
- if(this.dimensions)
- this.data_url += "&dimensions=" + this.dimensions;
-
- if(NETDATA.options.debug.chart_data_url === true || this.debug === true)
- this.log('chartURL(): ' + this.data_url + ' WxH:' + this.chartWidth() + 'x' + this.chartHeight() + ' points: ' + this.data_points + ' library: ' + this.library_name);
- };
-
- this.redrawChart = function() {
- if(this.data !== null)
- this.updateChartWithData(this.data);
- };
-
- this.updateChartWithData = function(data) {
- if(this.debug === true)
- this.log('updateChartWithData() called.');
-
- // this may force the chart to be re-created
- resizeChart();
-
- this.data = data;
- this.updates_counter++;
- this.updates_since_last_unhide++;
- this.updates_since_last_creation++;
-
- var started = new Date().getTime();
-
- // if the result is JSON, find the latest update-every
- this.data_update_every = data.view_update_every * 1000;
- this.data_after = data.after * 1000;
- this.data_before = data.before * 1000;
- this.netdata_first = data.first_entry * 1000;
- this.netdata_last = data.last_entry * 1000;
- this.data_points = data.points;
- data.state = this;
-
- if(NETDATA.options.current.pan_and_zoom_data_padding === true && this.requested_padding !== null) {
- if(this.view_after < this.data_after) {
- // console.log('adusting view_after from ' + this.view_after + ' to ' + this.data_after);
- this.view_after = this.data_after;
- }
-
- if(this.view_before > this.data_before) {
- // console.log('adusting view_before from ' + this.view_before + ' to ' + this.data_before);
- this.view_before = this.data_before;
- }
- }
- else {
- this.view_after = this.data_after;
- this.view_before = this.data_before;
- }
-
- if(this.debug === true) {
- this.log('UPDATE No ' + this.updates_counter + ' COMPLETED');
-
- if(this.current.force_after_ms)
- this.log('STATUS: forced : ' + (this.current.force_after_ms / 1000).toString() + ' - ' + (this.current.force_before_ms / 1000).toString());
- else
- this.log('STATUS: forced : unset');
-
- this.log('STATUS: requested : ' + (this.requested_after / 1000).toString() + ' - ' + (this.requested_before / 1000).toString());
- this.log('STATUS: downloaded: ' + (this.data_after / 1000).toString() + ' - ' + (this.data_before / 1000).toString());
- this.log('STATUS: rendered : ' + (this.view_after / 1000).toString() + ' - ' + (this.view_before / 1000).toString());
- this.log('STATUS: points : ' + (this.data_points).toString());
- }
-
- if(this.data_points === 0) {
- noDataToShow();
- return;
- }
-
- if(this.updates_since_last_creation >= this.library.max_updates_to_recreate()) {
- if(this.debug === true)
- this.log('max updates of ' + this.updates_since_last_creation.toString() + ' reached. Forcing re-generation.');
-
- this.chart_created = false;
- }
-
- // check and update the legend
- this.legendUpdateDOM();
-
- if(this.chart_created === true
- && typeof this.library.update === 'function') {
-
- if(this.debug === true)
- this.log('updating chart...');
-
- if(callChartLibraryUpdateSafely(data) === false)
- return;
- }
- else {
- if(this.debug === true)
- this.log('creating chart...');
-
- if(callChartLibraryCreateSafely(data) === false)
- return;
- }
- hideMessage();
- this.legendShowLatestValues();
- if(this.selected === true)
- NETDATA.globalSelectionSync.stop();
-
- // update the performance counters
- var now = new Date().getTime();
- this.tm.last_updated = now;
-
- // don't update last_autorefreshed if this chart is
- // forced to be updated with global PanAndZoom
- if(NETDATA.globalPanAndZoom.isActive())
- this.tm.last_autorefreshed = 0;
- else {
- if(NETDATA.options.current.parallel_refresher === true && NETDATA.options.current.concurrent_refreshes === true)
- this.tm.last_autorefreshed = now - (now % this.data_update_every);
- else
- this.tm.last_autorefreshed = now;
- }
-
- this.refresh_dt_ms = now - started;
- NETDATA.options.auto_refresher_fast_weight += this.refresh_dt_ms;
-
- if(this.refresh_dt_element !== null)
- this.refresh_dt_element.innerHTML = this.refresh_dt_ms.toString();
- };
-
- this.updateChart = function(callback) {
- if(this.debug === true)
- this.log('updateChart() called.');
-
- if(this._updating === true) {
- if(this.debug === true)
- this.log('I am already updating...');
-
- if(typeof callback === 'function') callback();
- return false;
- }
-
- // due to late initialization of charts and libraries
- // we need to check this too
- if(this.enabled === false) {
- if(this.debug === true)
- this.log('I am not enabled');
-
- if(typeof callback === 'function') callback();
- return false;
- }
-
- if(canBeRendered() === false) {
- if(typeof callback === 'function') callback();
- return false;
- }
-
- if(this.chart === null) {
- this.getChart(function() { that.updateChart(callback); });
- return false;
- }
-
- if(this.library.initialized === false) {
- if(this.library.enabled === true) {
- this.library.initialize(function() { that.updateChart(callback); });
- return false;
- }
- else {
- error('chart library "' + this.library_name + '" is not available.');
- if(typeof callback === 'function') callback();
- return false;
- }
- }
-
- this.clearSelection();
- this.chartURL();
-
- if(this.debug === true)
- this.log('updating from ' + this.data_url);
-
- NETDATA.statistics.refreshes_total++;
- NETDATA.statistics.refreshes_active++;
-
- if(NETDATA.statistics.refreshes_active > NETDATA.statistics.refreshes_active_max)
- NETDATA.statistics.refreshes_active_max = NETDATA.statistics.refreshes_active;
-
- this._updating = true;
-
- this.xhr = $.ajax( {
- url: this.data_url,
- cache: false,
- async: true
- })
- .success(function(data) {
- if(that.debug === true)
- that.log('data received. updating chart.');
-
- that.updateChartWithData(data);
- })
- .fail(function() {
- error('data download failed for url: ' + that.data_url);
- })
- .always(function() {
- NETDATA.statistics.refreshes_active--;
- that._updating = false;
- if(typeof callback === 'function') callback();
- });
-
- return true;
- };
-
- this.isVisible = function(nocache) {
- if(typeof nocache === 'undefined')
- nocache = false;
-
- // this.log('last_visible_check: ' + this.tm.last_visible_check + ', last_page_scroll: ' + NETDATA.options.last_page_scroll);
-
- // caching - we do not evaluate the charts visibility
- // if the page has not been scrolled since the last check
- if(nocache === false && this.tm.last_visible_check > NETDATA.options.last_page_scroll)
- return this.___isVisible___;
-
- this.tm.last_visible_check = new Date().getTime();
-
- var wh = window.innerHeight;
- var x = this.element.getBoundingClientRect();
- var ret = 0;
- var tolerance = 0;
-
- if(x.width === 0 || x.height === 0) {
- hideChart();
- this.___isVisible___ = false;
- return this.___isVisible___;
- }
-
- if(x.top < 0 && -x.top > x.height) {
- // the chart is entirely above
- ret = -x.top - x.height;
- }
- else if(x.top > wh) {
- // the chart is entirely below
- ret = x.top - wh;
- }
-
- if(ret > tolerance) {
- // the chart is too far
-
- hideChart();
- this.___isVisible___ = false;
- return this.___isVisible___;
- }
- else {
- // the chart is inside or very close
-
- unhideChart();
- this.___isVisible___ = true;
- return this.___isVisible___;
- }
- };
-
- this.isAutoRefreshable = function() {
- return (this.current.autorefresh);
- };
-
- this.canBeAutoRefreshed = function() {
- var now = new Date().getTime();
-
- if(this.running === true) {
- if(this.debug === true)
- this.log('I am already running');
-
- return false;
- }
-
- if(this.enabled === false) {
- if(this.debug === true)
- this.log('I am not enabled');
-
- return false;
- }
-
- if(this.library === null || this.library.enabled === false) {
- error('charting library "' + this.library_name + '" is not available');
- if(this.debug === true)
- this.log('My chart library ' + this.library_name + ' is not available');
-
- return false;
- }
-
- if(this.isVisible() === false) {
- if(NETDATA.options.debug.visibility === true || this.debug === true)
- this.log('I am not visible');
-
- return false;
- }
-
- if(this.current.force_update_at !== 0 && this.current.force_update_at < now) {
- if(this.debug === true)
- this.log('timed force update detected - allowing this update');
-
- this.current.force_update_at = 0;
- return true;
- }
-
- if(this.isAutoRefreshable() === true) {
- // allow the first update, even if the page is not visible
- if(this.updates_counter && this.updates_since_last_unhide && NETDATA.options.page_is_visible === false) {
- if(NETDATA.options.debug.focus === true || this.debug === true)
- this.log('canBeAutoRefreshed(): page does not have focus');
-
- return false;
- }
-
- if(this.needsRecreation() === true) {
- if(this.debug === true)
- this.log('canBeAutoRefreshed(): needs re-creation.');
-
- return true;
- }
-
- // options valid only for autoRefresh()
- if(NETDATA.options.auto_refresher_stop_until === 0 || NETDATA.options.auto_refresher_stop_until < now) {
- if(NETDATA.globalPanAndZoom.isActive()) {
- if(NETDATA.globalPanAndZoom.shouldBeAutoRefreshed(this)) {
- if(this.debug === true)
- this.log('canBeAutoRefreshed(): global panning: I need an update.');
-
- return true;
- }
- else {
- if(this.debug === true)
- this.log('canBeAutoRefreshed(): global panning: I am already up to date.');
-
- return false;
- }
- }
-
- if(this.selected === true) {
- if(this.debug === true)
- this.log('canBeAutoRefreshed(): I have a selection in place.');
-
- return false;
- }
-
- if(this.paused === true) {
- if(this.debug === true)
- this.log('canBeAutoRefreshed(): I am paused.');
-
- return false;
- }
-
- if(now - this.tm.last_autorefreshed >= this.data_update_every) {
- if(this.debug === true)
- this.log('canBeAutoRefreshed(): It is time to update me.');
-
- return true;
- }
- }
- }
-
- return false;
- };
-
- this.autoRefresh = function(callback) {
- if(this.canBeAutoRefreshed() === true && this.running === false) {
- var state = this;
-
- state.running = true;
- state.updateChart(function() {
- state.running = false;
-
- if(typeof callback !== 'undefined')
- callback();
- });
- }
- else {
- if(typeof callback !== 'undefined')
- callback();
- }
- };
-
- this._defaultsFromDownloadedChart = function(chart) {
- this.chart = chart;
- this.chart_url = chart.url;
- this.data_update_every = chart.update_every * 1000;
- this.data_points = Math.round(this.chartWidth() / this.chartPixelsPerPoint());
- this.tm.last_info_downloaded = new Date().getTime();
-
- if(this.title === null)
- this.title = chart.title;
-
- if(this.units === null)
- this.units = chart.units;
- };
-
- // fetch the chart description from the netdata server
- this.getChart = function(callback) {
- this.chart = NETDATA.chartRegistry.get(this.host, this.id);
- if(this.chart) {
- this._defaultsFromDownloadedChart(this.chart);
- if(typeof callback === 'function') callback();
- }
- else {
- this.chart_url = "/api/v1/chart?chart=" + this.id;
-
- if(this.debug === true)
- this.log('downloading ' + this.chart_url);
-
- $.ajax( {
- url: this.host + this.chart_url,
- cache: false,
- async: true
- })
- .done(function(chart) {
- chart.url = that.chart_url;
- that._defaultsFromDownloadedChart(chart);
- NETDATA.chartRegistry.add(that.host, that.id, chart);
- })
- .fail(function() {
- NETDATA.error(404, that.chart_url);
- error('chart not found on url "' + that.chart_url + '"');
- })
- .always(function() {
- if(typeof callback === 'function') callback();
- });
- }
- };
-
- // ============================================================================================================
- // INITIALIZATION
-
- init();
- };
-
- NETDATA.resetAllCharts = function(state) {
- // first clear the global selection sync
- // to make sure no chart is in selected state
- state.globalSelectionSyncStop();
-
- // there are 2 possibilities here
- // a. state is the global Pan and Zoom master
- // b. state is not the global Pan and Zoom master
- var master = true;
- if(NETDATA.globalPanAndZoom.isMaster(state) === false)
- master = false;
-
- // clear the global Pan and Zoom
- // this will also refresh the master
- // and unblock any charts currently mirroring the master
- NETDATA.globalPanAndZoom.clearMaster();
-
- // if we were not the master, reset our status too
- // this is required because most probably the mouse
- // is over this chart, blocking it from auto-refreshing
- if(master === false && (state.paused === true || state.selected === true))
- state.resetChart();
- };
-
- // get or create a chart state, given a DOM element
- NETDATA.chartState = function(element) {
- var state = $(element).data('netdata-state-object') || null;
- if(state === null) {
- state = new chartState(element);
- $(element).data('netdata-state-object', state);
- }
- return state;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // Library functions
-
- // Load a script without jquery
- // This is used to load jquery - after it is loaded, we use jquery
- NETDATA._loadjQuery = function(callback) {
- if(typeof jQuery === 'undefined') {
- if(NETDATA.options.debug.main_loop === true)
- console.log('loading ' + NETDATA.jQuery);
-
- var script = document.createElement('script');
- script.type = 'text/javascript';
- script.async = true;
- script.src = NETDATA.jQuery;
-
- // script.onabort = onError;
- script.onerror = function(err, t) { NETDATA.error(101, NETDATA.jQuery); };
- if(typeof callback === "function")
- script.onload = callback;
-
- var s = document.getElementsByTagName('script')[0];
- s.parentNode.insertBefore(script, s);
- }
- else if(typeof callback === "function")
- callback();
- };
-
- NETDATA._loadCSS = function(filename) {
- // don't use jQuery here
- // styles are loaded before jQuery
- // to eliminate showing an unstyled page to the user
-
- var fileref = document.createElement("link");
- fileref.setAttribute("rel", "stylesheet");
- fileref.setAttribute("type", "text/css");
- fileref.setAttribute("href", filename);
-
- if (typeof fileref !== 'undefined')
- document.getElementsByTagName("head")[0].appendChild(fileref);
- };
-
- NETDATA.colorHex2Rgb = function(hex) {
- // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
- var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
- hex = hex.replace(shorthandRegex, function(m, r, g, b) {
- return r + r + g + g + b + b;
- });
-
- var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
- return result ? {
- r: parseInt(result[1], 16),
- g: parseInt(result[2], 16),
- b: parseInt(result[3], 16)
- } : null;
- };
-
- NETDATA.colorLuminance = function(hex, lum) {
- // validate hex string
- hex = String(hex).replace(/[^0-9a-f]/gi, '');
- if (hex.length < 6)
- hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2];
-
- lum = lum || 0;
-
- // convert to decimal and change luminosity
- var rgb = "#", c, i;
- for (i = 0; i < 3; i++) {
- c = parseInt(hex.substr(i*2,2), 16);
- c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16);
- rgb += ("00"+c).substr(c.length);
- }
-
- return rgb;
- };
-
- NETDATA.guid = function() {
- function s4() {
- return Math.floor((1 + Math.random()) * 0x10000)
- .toString(16)
- .substring(1);
- }
-
- return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
- };
-
- NETDATA.zeropad = function(x) {
- if(x > -10 && x < 10) return '0' + x.toString();
- else return x.toString();
- };
-
- // user function to signal us the DOM has been
- // updated.
- NETDATA.updatedDom = function() {
- NETDATA.options.updated_dom = true;
- };
-
- NETDATA.ready = function(callback) {
- NETDATA.options.pauseCallback = callback;
- };
-
- NETDATA.pause = function(callback) {
- if(NETDATA.options.pause === true)
- callback();
- else
- NETDATA.options.pauseCallback = callback;
- };
-
- NETDATA.unpause = function() {
- NETDATA.options.pauseCallback = null;
- NETDATA.options.updated_dom = true;
- NETDATA.options.pause = false;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
-
- // this is purely sequencial charts refresher
- // it is meant to be autonomous
- NETDATA.chartRefresherNoParallel = function(index) {
- if(NETDATA.options.debug.mail_loop === true)
- console.log('NETDATA.chartRefresherNoParallel(' + index + ')');
-
- if(NETDATA.options.updated_dom === true) {
- // the dom has been updated
- // get the dom parts again
- NETDATA.parseDom(NETDATA.chartRefresher);
- return;
- }
- if(index >= NETDATA.options.targets.length) {
- if(NETDATA.options.debug.main_loop === true)
- console.log('waiting to restart main loop...');
-
- NETDATA.options.auto_refresher_fast_weight = 0;
-
- setTimeout(function() {
- NETDATA.chartRefresher();
- }, NETDATA.options.current.idle_between_loops);
- }
- else {
- var state = NETDATA.options.targets[index];
-
- if(NETDATA.options.auto_refresher_fast_weight < NETDATA.options.current.fast_render_timeframe) {
- if(NETDATA.options.debug.main_loop === true)
- console.log('fast rendering...');
-
- state.autoRefresh(function() {
- NETDATA.chartRefresherNoParallel(++index);
- });
- }
- else {
- if(NETDATA.options.debug.main_loop === true) console.log('waiting for next refresh...');
- NETDATA.options.auto_refresher_fast_weight = 0;
-
- setTimeout(function() {
- state.autoRefresh(function() {
- NETDATA.chartRefresherNoParallel(++index);
- });
- }, NETDATA.options.current.idle_between_charts);
- }
- }
- };
-
- // this is part of the parallel refresher
- // its cause is to refresh sequencially all the charts
- // that depend on chart library initialization
- // it will call the parallel refresher back
- // as soon as it sees a chart that its chart library
- // is initialized
- NETDATA.chartRefresher_uninitialized = function() {
- if(NETDATA.options.updated_dom === true) {
- // the dom has been updated
- // get the dom parts again
- NETDATA.parseDom(NETDATA.chartRefresher);
- return;
- }
-
- if(NETDATA.options.sequencial.length === 0)
- NETDATA.chartRefresher();
- else {
- var state = NETDATA.options.sequencial.pop();
- if(state.library.initialized === true)
- NETDATA.chartRefresher();
- else
- state.autoRefresh(NETDATA.chartRefresher_uninitialized);
- }
- };
-
- NETDATA.chartRefresherWaitTime = function() {
- return NETDATA.options.current.idle_parallel_loops;
- };
-
- // the default refresher
- // it will create 2 sets of charts:
- // - the ones that can be refreshed in parallel
- // - the ones that depend on something else
- // the first set will be executed in parallel
- // the second will be given to NETDATA.chartRefresher_uninitialized()
- NETDATA.chartRefresher = function() {
- if(NETDATA.options.pause === true) {
- // console.log('auto-refresher is paused');
- setTimeout(NETDATA.chartRefresher,
- NETDATA.chartRefresherWaitTime());
- return;
- }
-
- if(typeof NETDATA.options.pauseCallback === 'function') {
- // console.log('auto-refresher is calling pauseCallback');
- NETDATA.options.pause = true;
- NETDATA.options.pauseCallback();
- NETDATA.chartRefresher();
- return;
- }
-
- if(NETDATA.options.current.parallel_refresher === false) {
- NETDATA.chartRefresherNoParallel(0);
- return;
- }
-
- if(NETDATA.options.updated_dom === true) {
- // the dom has been updated
- // get the dom parts again
- NETDATA.parseDom(NETDATA.chartRefresher);
- return;
- }
-
- var parallel = new Array();
- var targets = NETDATA.options.targets;
- var len = targets.length;
- var state;
- while(len--) {
- state = targets[len];
- if(state.isVisible() === false || state.running === true)
- continue;
-
- if(state.library.initialized === false) {
- if(state.library.enabled === true) {
- state.library.initialize(NETDATA.chartRefresher);
- return;
- }
- else {
- state.error('chart library "' + state.library_name + '" is not enabled.');
- }
- }
-
- parallel.unshift(state);
- }
-
- if(parallel.length > 0) {
- // this will execute the jobs in parallel
- $(parallel).each(function() {
- this.autoRefresh();
- })
- }
-
- // run the next refresh iteration
- setTimeout(NETDATA.chartRefresher,
- NETDATA.chartRefresherWaitTime());
- };
-
- NETDATA.parseDom = function(callback) {
- NETDATA.options.last_page_scroll = new Date().getTime();
- NETDATA.options.updated_dom = false;
-
- var targets = $('div[data-netdata]'); //.filter(':visible');
-
- if(NETDATA.options.debug.main_loop === true)
- console.log('DOM updated - there are ' + targets.length + ' charts on page.');
-
- NETDATA.options.targets = new Array();
- var len = targets.length;
- while(len--) {
- // the initialization will take care of sizing
- // and the "loading..." message
- NETDATA.options.targets.push(NETDATA.chartState(targets[len]));
- }
-
- if(typeof callback === 'function') callback();
- };
-
- // this is the main function - where everything starts
- NETDATA.start = function() {
- // this should be called only once
-
- NETDATA.options.page_is_visible = true;
-
- $(window).blur(function() {
- if(NETDATA.options.current.stop_updates_when_focus_is_lost === true) {
- NETDATA.options.page_is_visible = false;
- if(NETDATA.options.debug.focus === true)
- console.log('Lost Focus!');
- }
- });
-
- $(window).focus(function() {
- if(NETDATA.options.current.stop_updates_when_focus_is_lost === true) {
- NETDATA.options.page_is_visible = true;
- if(NETDATA.options.debug.focus === true)
- console.log('Focus restored!');
- }
- });
-
- if(typeof document.hasFocus === 'function' && !document.hasFocus()) {
- if(NETDATA.options.current.stop_updates_when_focus_is_lost === true) {
- NETDATA.options.page_is_visible = false;
- if(NETDATA.options.debug.focus === true)
- console.log('Document has no focus!');
- }
- }
-
- // bootstrap tab switching
- $('a[data-toggle="tab"]').on('shown.bs.tab', NETDATA.onscroll);
-
- // bootstrap modal switching
- $('.modal').on('hidden.bs.modal', NETDATA.onscroll);
- $('.modal').on('shown.bs.modal', NETDATA.onscroll);
-
- // bootstrap collapse switching
- $('.collapse').on('hidden.bs.collapse', NETDATA.onscroll);
- $('.collapse').on('shown.bs.collapse', NETDATA.onscroll);
-
- NETDATA.parseDom(NETDATA.chartRefresher);
-
- // Registry initialization
- setTimeout(NETDATA.registry.init, 3000);
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // peity
-
- NETDATA.peityInitialize = function(callback) {
- if(typeof netdataNoPeitys === 'undefined' || !netdataNoPeitys) {
- $.ajax({
- url: NETDATA.peity_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('peity', NETDATA.peity_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.peity.enabled = false;
- NETDATA.error(100, NETDATA.peity_js);
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- });
- }
- else {
- NETDATA.chartLibraries.peity.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.peityChartUpdate = function(state, data) {
- state.peity_instance.innerHTML = data.result;
-
- if(state.peity_options.stroke !== state.chartColors()[0]) {
- state.peity_options.stroke = state.chartColors()[0];
- if(state.chart.chart_type === 'line')
- state.peity_options.fill = NETDATA.themes.current.background;
- else
- state.peity_options.fill = NETDATA.colorLuminance(state.chartColors()[0], NETDATA.chartDefaults.fill_luminance);
- }
-
- $(state.peity_instance).peity('line', state.peity_options);
- return true;
- };
-
- NETDATA.peityChartCreate = function(state, data) {
- state.peity_instance = document.createElement('div');
- state.element_chart.appendChild(state.peity_instance);
-
- var self = $(state.element);
- state.peity_options = {
- stroke: NETDATA.themes.current.foreground,
- strokeWidth: self.data('peity-strokewidth') || 1,
- width: state.chartWidth(),
- height: state.chartHeight(),
- fill: NETDATA.themes.current.foreground
- };
-
- NETDATA.peityChartUpdate(state, data);
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // sparkline
-
- NETDATA.sparklineInitialize = function(callback) {
- if(typeof netdataNoSparklines === 'undefined' || !netdataNoSparklines) {
- $.ajax({
- url: NETDATA.sparkline_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('sparkline', NETDATA.sparkline_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.sparkline.enabled = false;
- NETDATA.error(100, NETDATA.sparkline_js);
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- });
- }
- else {
- NETDATA.chartLibraries.sparkline.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.sparklineChartUpdate = function(state, data) {
- state.sparkline_options.width = state.chartWidth();
- state.sparkline_options.height = state.chartHeight();
-
- $(state.element_chart).sparkline(data.result, state.sparkline_options);
- return true;
- };
-
- NETDATA.sparklineChartCreate = function(state, data) {
- var self = $(state.element);
- var type = self.data('sparkline-type') || 'line';
- var lineColor = self.data('sparkline-linecolor') || state.chartColors()[0];
- var fillColor = self.data('sparkline-fillcolor') || (state.chart.chart_type === 'line')?NETDATA.themes.current.background:NETDATA.colorLuminance(lineColor, NETDATA.chartDefaults.fill_luminance);
- var chartRangeMin = self.data('sparkline-chartrangemin') || undefined;
- var chartRangeMax = self.data('sparkline-chartrangemax') || undefined;
- var composite = self.data('sparkline-composite') || undefined;
- var enableTagOptions = self.data('sparkline-enabletagoptions') || undefined;
- var tagOptionPrefix = self.data('sparkline-tagoptionprefix') || undefined;
- var tagValuesAttribute = self.data('sparkline-tagvaluesattribute') || undefined;
- var disableHiddenCheck = self.data('sparkline-disablehiddencheck') || undefined;
- var defaultPixelsPerValue = self.data('sparkline-defaultpixelspervalue') || undefined;
- var spotColor = self.data('sparkline-spotcolor') || undefined;
- var minSpotColor = self.data('sparkline-minspotcolor') || undefined;
- var maxSpotColor = self.data('sparkline-maxspotcolor') || undefined;
- var spotRadius = self.data('sparkline-spotradius') || undefined;
- var valueSpots = self.data('sparkline-valuespots') || undefined;
- var highlightSpotColor = self.data('sparkline-highlightspotcolor') || undefined;
- var highlightLineColor = self.data('sparkline-highlightlinecolor') || undefined;
- var lineWidth = self.data('sparkline-linewidth') || undefined;
- var normalRangeMin = self.data('sparkline-normalrangemin') || undefined;
- var normalRangeMax = self.data('sparkline-normalrangemax') || undefined;
- var drawNormalOnTop = self.data('sparkline-drawnormalontop') || undefined;
- var xvalues = self.data('sparkline-xvalues') || undefined;
- var chartRangeClip = self.data('sparkline-chartrangeclip') || undefined;
- var chartRangeMinX = self.data('sparkline-chartrangeminx') || undefined;
- var chartRangeMaxX = self.data('sparkline-chartrangemaxx') || undefined;
- var disableInteraction = self.data('sparkline-disableinteraction') || false;
- var disableTooltips = self.data('sparkline-disabletooltips') || false;
- var disableHighlight = self.data('sparkline-disablehighlight') || false;
- var highlightLighten = self.data('sparkline-highlightlighten') || 1.4;
- var highlightColor = self.data('sparkline-highlightcolor') || undefined;
- var tooltipContainer = self.data('sparkline-tooltipcontainer') || undefined;
- var tooltipClassname = self.data('sparkline-tooltipclassname') || undefined;
- var tooltipFormat = self.data('sparkline-tooltipformat') || undefined;
- var tooltipPrefix = self.data('sparkline-tooltipprefix') || undefined;
- var tooltipSuffix = self.data('sparkline-tooltipsuffix') || ' ' + state.units;
- var tooltipSkipNull = self.data('sparkline-tooltipskipnull') || true;
- var tooltipValueLookups = self.data('sparkline-tooltipvaluelookups') || undefined;
- var tooltipFormatFieldlist = self.data('sparkline-tooltipformatfieldlist') || undefined;
- var tooltipFormatFieldlistKey = self.data('sparkline-tooltipformatfieldlistkey') || undefined;
- var numberFormatter = self.data('sparkline-numberformatter') || function(n){ return n.toFixed(2); };
- var numberDigitGroupSep = self.data('sparkline-numberdigitgroupsep') || undefined;
- var numberDecimalMark = self.data('sparkline-numberdecimalmark') || undefined;
- var numberDigitGroupCount = self.data('sparkline-numberdigitgroupcount') || undefined;
- var animatedZooms = self.data('sparkline-animatedzooms') || false;
-
- state.sparkline_options = {
- type: type,
- lineColor: lineColor,
- fillColor: fillColor,
- chartRangeMin: chartRangeMin,
- chartRangeMax: chartRangeMax,
- composite: composite,
- enableTagOptions: enableTagOptions,
- tagOptionPrefix: tagOptionPrefix,
- tagValuesAttribute: tagValuesAttribute,
- disableHiddenCheck: disableHiddenCheck,
- defaultPixelsPerValue: defaultPixelsPerValue,
- spotColor: spotColor,
- minSpotColor: minSpotColor,
- maxSpotColor: maxSpotColor,
- spotRadius: spotRadius,
- valueSpots: valueSpots,
- highlightSpotColor: highlightSpotColor,
- highlightLineColor: highlightLineColor,
- lineWidth: lineWidth,
- normalRangeMin: normalRangeMin,
- normalRangeMax: normalRangeMax,
- drawNormalOnTop: drawNormalOnTop,
- xvalues: xvalues,
- chartRangeClip: chartRangeClip,
- chartRangeMinX: chartRangeMinX,
- chartRangeMaxX: chartRangeMaxX,
- disableInteraction: disableInteraction,
- disableTooltips: disableTooltips,
- disableHighlight: disableHighlight,
- highlightLighten: highlightLighten,
- highlightColor: highlightColor,
- tooltipContainer: tooltipContainer,
- tooltipClassname: tooltipClassname,
- tooltipChartTitle: state.title,
- tooltipFormat: tooltipFormat,
- tooltipPrefix: tooltipPrefix,
- tooltipSuffix: tooltipSuffix,
- tooltipSkipNull: tooltipSkipNull,
- tooltipValueLookups: tooltipValueLookups,
- tooltipFormatFieldlist: tooltipFormatFieldlist,
- tooltipFormatFieldlistKey: tooltipFormatFieldlistKey,
- numberFormatter: numberFormatter,
- numberDigitGroupSep: numberDigitGroupSep,
- numberDecimalMark: numberDecimalMark,
- numberDigitGroupCount: numberDigitGroupCount,
- animatedZooms: animatedZooms,
- width: state.chartWidth(),
- height: state.chartHeight()
- };
-
- $(state.element_chart).sparkline(data.result, state.sparkline_options);
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // dygraph
-
- NETDATA.dygraph = {
- smooth: false
- };
-
- NETDATA.dygraphToolboxPanAndZoom = function(state, after, before) {
- if(after < state.netdata_first)
- after = state.netdata_first;
-
- if(before > state.netdata_last)
- before = state.netdata_last;
-
- state.setMode('zoom');
- state.globalSelectionSyncStop();
- state.globalSelectionSyncDelay();
- state.dygraph_user_action = true;
- state.dygraph_force_zoom = true;
- state.updateChartPanOrZoom(after, before);
- NETDATA.globalPanAndZoom.setMaster(state, after, before);
- };
-
- NETDATA.dygraphSetSelection = function(state, t) {
- if(typeof state.dygraph_instance !== 'undefined') {
- var r = state.calculateRowForTime(t);
- if(r !== -1)
- state.dygraph_instance.setSelection(r);
- else {
- state.dygraph_instance.clearSelection();
- state.legendShowUndefined();
- }
- }
-
- return true;
- };
-
- NETDATA.dygraphClearSelection = function(state, t) {
- if(typeof state.dygraph_instance !== 'undefined') {
- state.dygraph_instance.clearSelection();
- }
- return true;
- };
-
- NETDATA.dygraphSmoothInitialize = function(callback) {
- $.ajax({
- url: NETDATA.dygraph_smooth_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.dygraph.smooth = true;
- smoothPlotter.smoothing = 0.3;
- })
- .fail(function() {
- NETDATA.dygraph.smooth = false;
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- });
- };
-
- NETDATA.dygraphInitialize = function(callback) {
- if(typeof netdataNoDygraphs === 'undefined' || !netdataNoDygraphs) {
- $.ajax({
- url: NETDATA.dygraph_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('dygraph', NETDATA.dygraph_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.dygraph.enabled = false;
- NETDATA.error(100, NETDATA.dygraph_js);
- })
- .always(function() {
- if(NETDATA.chartLibraries.dygraph.enabled === true && NETDATA.options.current.smooth_plot === true)
- NETDATA.dygraphSmoothInitialize(callback);
- else if(typeof callback === "function")
- callback();
- });
- }
- else {
- NETDATA.chartLibraries.dygraph.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.dygraphChartUpdate = function(state, data) {
- var dygraph = state.dygraph_instance;
-
- if(typeof dygraph === 'undefined')
- return NETDATA.dygraphChartCreate(state, data);
-
- // when the chart is not visible, and hidden
- // if there is a window resize, dygraph detects
- // its element size as 0x0.
- // this will make it re-appear properly
-
- if(state.tm.last_unhidden > state.dygraph_last_rendered)
- dygraph.resize();
-
- var options = {
- file: data.result.data,
- colors: state.chartColors(),
- labels: data.result.labels,
- labelsDivWidth: state.chartWidth() - 70,
- visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names)
- };
-
- if(state.dygraph_force_zoom === true) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('dygraphChartUpdate() forced zoom update');
-
- options.dateWindow = (state.requested_padding !== null)?[ state.view_after, state.view_before ]:null;
- options.valueRange = null;
- options.isZoomedIgnoreProgrammaticZoom = true;
- state.dygraph_force_zoom = false;
- }
- else if(state.current.name !== 'auto') {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('dygraphChartUpdate() loose update');
- }
- else {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('dygraphChartUpdate() strict update');
-
- options.dateWindow = (state.requested_padding !== null)?[ state.view_after, state.view_before ]:null;
- options.valueRange = null;
- options.isZoomedIgnoreProgrammaticZoom = true;
- }
-
- if(state.dygraph_smooth_eligible === true) {
- if((NETDATA.options.current.smooth_plot === true && state.dygraph_options.plotter !== smoothPlotter)
- || (NETDATA.options.current.smooth_plot === false && state.dygraph_options.plotter === smoothPlotter)) {
- NETDATA.dygraphChartCreate(state, data);
- return;
- }
- }
-
- dygraph.updateOptions(options);
-
- state.dygraph_last_rendered = new Date().getTime();
- return true;
- };
-
- NETDATA.dygraphChartCreate = function(state, data) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('dygraphChartCreate()');
-
- var self = $(state.element);
-
- var chart_type = state.chart.chart_type;
- if(chart_type === 'stacked' && data.dimensions === 1) chart_type = 'area';
- chart_type = self.data('dygraph-type') || chart_type;
-
- var smooth = (chart_type === 'line' && !NETDATA.chartLibraries.dygraph.isSparkline(state))?true:false;
- smooth = self.data('dygraph-smooth') || smooth;
-
- if(NETDATA.dygraph.smooth === false)
- smooth = false;
-
- var strokeWidth = (chart_type === 'stacked')?0.1:((smooth)?1.5:0.7)
- var highlightCircleSize = (NETDATA.chartLibraries.dygraph.isSparkline(state))?3:4;
-
- state.dygraph_options = {
- colors: self.data('dygraph-colors') || state.chartColors(),
-
- // leave a few pixels empty on the right of the chart
- rightGap: self.data('dygraph-rightgap') || 5,
- showRangeSelector: self.data('dygraph-showrangeselector') || false,
- showRoller: self.data('dygraph-showroller') || false,
-
- title: self.data('dygraph-title') || state.title,
- titleHeight: self.data('dygraph-titleheight') || 19,
-
- legend: self.data('dygraph-legend') || 'always', // 'onmouseover',
- labels: data.result.labels,
- labelsDiv: self.data('dygraph-labelsdiv') || state.element_legend_childs.hidden,
- labelsDivStyles: self.data('dygraph-labelsdivstyles') || { 'fontSize':'1px' },
- labelsDivWidth: self.data('dygraph-labelsdivwidth') || state.chartWidth() - 70,
- labelsSeparateLines: self.data('dygraph-labelsseparatelines') || true,
- labelsShowZeroValues: self.data('dygraph-labelsshowzerovalues') || true,
- labelsKMB: false,
- labelsKMG2: false,
- showLabelsOnHighlight: self.data('dygraph-showlabelsonhighlight') || true,
- hideOverlayOnMouseOut: self.data('dygraph-hideoverlayonmouseout') || true,
-
- ylabel: state.units,
- yLabelWidth: self.data('dygraph-ylabelwidth') || 12,
-
- // the function to plot the chart
- plotter: null,
-
- // The width of the lines connecting data points. This can be used to increase the contrast or some graphs.
- strokeWidth: self.data('dygraph-strokewidth') || strokeWidth,
- strokePattern: self.data('dygraph-strokepattern') || undefined,
-
- // The size of the dot to draw on each point in pixels (see drawPoints). A dot is always drawn when a point is "isolated",
- // i.e. there is a missing point on either side of it. This also controls the size of those dots.
- drawPoints: self.data('dygraph-drawpoints') || false,
-
- // Draw points at the edges of gaps in the data. This improves visibility of small data segments or other data irregularities.
- drawGapEdgePoints: self.data('dygraph-drawgapedgepoints') || true,
-
- connectSeparatedPoints: self.data('dygraph-connectseparatedpoints') || false,
- pointSize: self.data('dygraph-pointsize') || 1,
-
- // enabling this makes the chart with little square lines
- stepPlot: self.data('dygraph-stepplot') || false,
-
- // Draw a border around graph lines to make crossing lines more easily distinguishable. Useful for graphs with many lines.
- strokeBorderColor: self.data('dygraph-strokebordercolor') || NETDATA.themes.current.background,
- strokeBorderWidth: self.data('dygraph-strokeborderwidth') || (chart_type === 'stacked')?0.0:0.0,
-
- fillGraph: self.data('dygraph-fillgraph') || (chart_type === 'area' || chart_type === 'stacked')?true:false,
- fillAlpha: self.data('dygraph-fillalpha') || (chart_type === 'stacked')?NETDATA.options.current.color_fill_opacity_stacked:NETDATA.options.current.color_fill_opacity_area,
- stackedGraph: self.data('dygraph-stackedgraph') || (chart_type === 'stacked')?true:false,
- stackedGraphNaNFill: self.data('dygraph-stackedgraphnanfill') || 'none',
-
- drawAxis: self.data('dygraph-drawaxis') || true,
- axisLabelFontSize: self.data('dygraph-axislabelfontsize') || 10,
- axisLineColor: self.data('dygraph-axislinecolor') || NETDATA.themes.current.axis,
- axisLineWidth: self.data('dygraph-axislinewidth') || 0.3,
-
- drawGrid: self.data('dygraph-drawgrid') || true,
- drawXGrid: self.data('dygraph-drawxgrid') || undefined,
- drawYGrid: self.data('dygraph-drawygrid') || undefined,
- gridLinePattern: self.data('dygraph-gridlinepattern') || null,
- gridLineWidth: self.data('dygraph-gridlinewidth') || 0.3,
- gridLineColor: self.data('dygraph-gridlinecolor') || NETDATA.themes.current.grid,
-
- maxNumberWidth: self.data('dygraph-maxnumberwidth') || 8,
- sigFigs: self.data('dygraph-sigfigs') || null,
- digitsAfterDecimal: self.data('dygraph-digitsafterdecimal') || 2,
- valueFormatter: self.data('dygraph-valueformatter') || function(x){ return x.toFixed(2); },
-
- highlightCircleSize: self.data('dygraph-highlightcirclesize') || highlightCircleSize,
- highlightSeriesOpts: self.data('dygraph-highlightseriesopts') || null, // TOO SLOW: { strokeWidth: 1.5 },
- highlightSeriesBackgroundAlpha: self.data('dygraph-highlightseriesbackgroundalpha') || null, // TOO SLOW: (chart_type === 'stacked')?0.7:0.5,
-
- pointClickCallback: self.data('dygraph-pointclickcallback') || undefined,
- visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names),
- axes: {
- x: {
- pixelsPerLabel: 50,
- ticker: Dygraph.dateTicker,
- axisLabelFormatter: function (d, gran) {
- return NETDATA.zeropad(d.getHours()) + ":" + NETDATA.zeropad(d.getMinutes()) + ":" + NETDATA.zeropad(d.getSeconds());
- },
- valueFormatter: function (ms) {
- var d = new Date(ms);
- return d.toLocaleDateString() + ' ' + d.toLocaleTimeString();
- // return NETDATA.zeropad(d.getHours()) + ":" + NETDATA.zeropad(d.getMinutes()) + ":" + NETDATA.zeropad(d.getSeconds());
- }
- },
- y: {
- pixelsPerLabel: 15,
- valueFormatter: function (x) {
- // we format legends with the state object
- // no need to do anything here
- // return (Math.round(x*100) / 100).toLocaleString();
- // return state.legendFormatValue(x);
- return x;
- }
- }
- },
- legendFormatter: function(data) {
- var elements = state.element_legend_childs;
-
- // if the hidden div is not there
- // we are not managing the legend
- if(elements.hidden === null) return;
-
- if (typeof data.x !== 'undefined') {
- state.legendSetDate(data.x);
- var i = data.series.length;
- while(i--) {
- var series = data.series[i];
- if(!series.isVisible) continue;
- state.legendSetLabelValue(series.label, series.y);
- }
- }
-
- return '';
- },
- drawCallback: function(dygraph, is_initial) {
- if(state.current.name !== 'auto' && state.dygraph_user_action === true) {
- state.dygraph_user_action = false;
-
- var x_range = dygraph.xAxisRange();
- var after = Math.round(x_range[0]);
- var before = Math.round(x_range[1]);
-
- if(NETDATA.options.debug.dygraph === true)
- state.log('dygraphDrawCallback(dygraph, ' + is_initial + '): ' + (after / 1000).toString() + ' - ' + (before / 1000).toString());
-
- if(before <= state.netdata_last && after >= state.netdata_first)
- state.updateChartPanOrZoom(after, before);
- }
- },
- zoomCallback: function(minDate, maxDate, yRanges) {
- if(NETDATA.options.debug.dygraph === true)
- state.log('dygraphZoomCallback()');
-
- state.globalSelectionSyncStop();
- state.globalSelectionSyncDelay();
- state.setMode('zoom');
-
- // refresh it to the greatest possible zoom level
- state.dygraph_user_action = true;
- state.dygraph_force_zoom = true;
- state.updateChartPanOrZoom(minDate, maxDate);
- },
- highlightCallback: function(event, x, points, row, seriesName) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('dygraphHighlightCallback()');
-
- state.pauseChart();
-
- // there is a bug in dygraph when the chart is zoomed enough
- // the time it thinks is selected is wrong
- // here we calculate the time t based on the row number selected
- // which is ok
- var t = state.data_after + row * state.data_update_every;
- // console.log('row = ' + row + ', x = ' + x + ', t = ' + t + ' ' + ((t === x)?'SAME':(Math.abs(x-t)<=state.data_update_every)?'SIMILAR':'DIFFERENT') + ', rows in db: ' + state.data_points + ' visible(x) = ' + state.timeIsVisible(x) + ' visible(t) = ' + state.timeIsVisible(t) + ' r(x) = ' + state.calculateRowForTime(x) + ' r(t) = ' + state.calculateRowForTime(t) + ' range: ' + state.data_after + ' - ' + state.data_before + ' real: ' + state.data.after + ' - ' + state.data.before + ' every: ' + state.data_update_every);
-
- state.globalSelectionSync(x);
-
- // fix legend zIndex using the internal structures of dygraph legend module
- // this works, but it is a hack!
- // state.dygraph_instance.plugins_[0].plugin.legend_div_.style.zIndex = 10000;
- },
- unhighlightCallback: function(event) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('dygraphUnhighlightCallback()');
-
- state.unpauseChart();
- state.globalSelectionSyncStop();
- },
- interactionModel : {
- mousedown: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.mousedown()');
-
- state.dygraph_user_action = true;
- state.globalSelectionSyncStop();
-
- if(NETDATA.options.debug.dygraph === true)
- state.log('dygraphMouseDown()');
-
- // Right-click should not initiate a zoom.
- if(event.button && event.button === 2) return;
-
- context.initializeMouseDown(event, dygraph, context);
-
- if(event.button && event.button === 1) {
- if (event.altKey || event.shiftKey) {
- state.setMode('pan');
- state.globalSelectionSyncDelay();
- Dygraph.startPan(event, dygraph, context);
- }
- else {
- state.setMode('zoom');
- state.globalSelectionSyncDelay();
- Dygraph.startZoom(event, dygraph, context);
- }
- }
- else {
- if (event.altKey || event.shiftKey) {
- state.setMode('zoom');
- state.globalSelectionSyncDelay();
- Dygraph.startZoom(event, dygraph, context);
- }
- else {
- state.setMode('pan');
- state.globalSelectionSyncDelay();
- Dygraph.startPan(event, dygraph, context);
- }
- }
- },
- mousemove: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.mousemove()');
-
- if(context.isPanning) {
- state.dygraph_user_action = true;
- state.globalSelectionSyncStop();
- state.globalSelectionSyncDelay();
- state.setMode('pan');
- Dygraph.movePan(event, dygraph, context);
- }
- else if(context.isZooming) {
- state.dygraph_user_action = true;
- state.globalSelectionSyncStop();
- state.globalSelectionSyncDelay();
- state.setMode('zoom');
- Dygraph.moveZoom(event, dygraph, context);
- }
- },
- mouseup: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.mouseup()');
-
- if (context.isPanning) {
- state.dygraph_user_action = true;
- state.globalSelectionSyncDelay();
- Dygraph.endPan(event, dygraph, context);
- }
- else if (context.isZooming) {
- state.dygraph_user_action = true;
- state.globalSelectionSyncDelay();
- Dygraph.endZoom(event, dygraph, context);
- }
- },
- click: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.click()');
-
- event.preventDefault();
- },
- dblclick: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.dblclick()');
- NETDATA.resetAllCharts(state);
- },
- mousewheel: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.mousewheel()');
-
- // Take the offset of a mouse event on the dygraph canvas and
- // convert it to a pair of percentages from the bottom left.
- // (Not top left, bottom is where the lower value is.)
- function offsetToPercentage(g, offsetX, offsetY) {
- // This is calculating the pixel offset of the leftmost date.
- var xOffset = g.toDomCoords(g.xAxisRange()[0], null)[0];
- var yar0 = g.yAxisRange(0);
-
- // This is calculating the pixel of the higest value. (Top pixel)
- var yOffset = g.toDomCoords(null, yar0[1])[1];
-
- // x y w and h are relative to the corner of the drawing area,
- // so that the upper corner of the drawing area is (0, 0).
- var x = offsetX - xOffset;
- var y = offsetY - yOffset;
-
- // This is computing the rightmost pixel, effectively defining the
- // width.
- var w = g.toDomCoords(g.xAxisRange()[1], null)[0] - xOffset;
-
- // This is computing the lowest pixel, effectively defining the height.
- var h = g.toDomCoords(null, yar0[0])[1] - yOffset;
-
- // Percentage from the left.
- var xPct = w === 0 ? 0 : (x / w);
- // Percentage from the top.
- var yPct = h === 0 ? 0 : (y / h);
-
- // The (1-) part below changes it from "% distance down from the top"
- // to "% distance up from the bottom".
- return [xPct, (1-yPct)];
- }
-
- // Adjusts [x, y] toward each other by zoomInPercentage%
- // Split it so the left/bottom axis gets xBias/yBias of that change and
- // tight/top gets (1-xBias)/(1-yBias) of that change.
- //
- // If a bias is missing it splits it down the middle.
- function zoomRange(g, zoomInPercentage, xBias, yBias) {
- xBias = xBias || 0.5;
- yBias = yBias || 0.5;
-
- function adjustAxis(axis, zoomInPercentage, bias) {
- var delta = axis[1] - axis[0];
- var increment = delta * zoomInPercentage;
- var foo = [increment * bias, increment * (1-bias)];
-
- return [ axis[0] + foo[0], axis[1] - foo[1] ];
- }
-
- var yAxes = g.yAxisRanges();
- var newYAxes = [];
- for (var i = 0; i < yAxes.length; i++) {
- newYAxes[i] = adjustAxis(yAxes[i], zoomInPercentage, yBias);
- }
-
- return adjustAxis(g.xAxisRange(), zoomInPercentage, xBias);
- }
-
- if(event.altKey || event.shiftKey) {
- state.dygraph_user_action = true;
-
- state.globalSelectionSyncStop();
- state.globalSelectionSyncDelay();
-
- // http://dygraphs.com/gallery/interaction-api.js
- var normal = (event.detail) ? event.detail * -1 : event.wheelDelta / 40;
- var percentage = normal / 50;
-
- if (!(event.offsetX && event.offsetY)){
- event.offsetX = event.layerX - event.target.offsetLeft;
- event.offsetY = event.layerY - event.target.offsetTop;
- }
-
- var percentages = offsetToPercentage(dygraph, event.offsetX, event.offsetY);
- var xPct = percentages[0];
- var yPct = percentages[1];
-
- var new_x_range = zoomRange(dygraph, percentage, xPct, yPct);
-
- var after = new_x_range[0];
- var before = new_x_range[1];
-
- var first = state.netdata_first + state.data_update_every;
- var last = state.netdata_last + state.data_update_every;
-
- if(before > last) {
- after -= (before - last);
- before = last;
- }
- if(after < first) {
- after = first;
- }
-
- state.setMode('zoom');
- if(state.updateChartPanOrZoom(after, before) === true)
- dygraph.updateOptions({ dateWindow: [ after, before ] });
-
- event.preventDefault();
- }
- },
- touchstart: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.touchstart()');
-
- state.dygraph_user_action = true;
- state.setMode('zoom');
- state.pauseChart();
-
- Dygraph.defaultInteractionModel.touchstart(event, dygraph, context);
-
- // we overwrite the touch directions at the end, to overwrite
- // the internal default of dygraphs
- context.touchDirections = { x: true, y: false };
-
- state.dygraph_last_touch_start = new Date().getTime();
- state.dygraph_last_touch_move = 0;
-
- if(typeof event.touches[0].pageX === 'number')
- state.dygraph_last_touch_page_x = event.touches[0].pageX;
- else
- state.dygraph_last_touch_page_x = 0;
- },
- touchmove: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.touchmove()');
-
- state.dygraph_user_action = true;
- Dygraph.defaultInteractionModel.touchmove(event, dygraph, context);
-
- state.dygraph_last_touch_move = new Date().getTime();
- },
- touchend: function(event, dygraph, context) {
- if(NETDATA.options.debug.dygraph === true || state.debug === true)
- state.log('interactionModel.touchend()');
-
- state.dygraph_user_action = true;
- Dygraph.defaultInteractionModel.touchend(event, dygraph, context);
-
- // if it didn't move, it is a selection
- if(state.dygraph_last_touch_move === 0 && state.dygraph_last_touch_page_x !== 0) {
- // internal api of dygraphs
- var pct = (state.dygraph_last_touch_page_x - (dygraph.plotter_.area.x + state.element.getBoundingClientRect().left)) / dygraph.plotter_.area.w;
- var t = Math.round(state.data_after + (state.data_before - state.data_after) * pct);
- if(NETDATA.dygraphSetSelection(state, t) === true)
- state.globalSelectionSync(t);
- }
-
- // if it was double tap within double click time, reset the charts
- var now = new Date().getTime();
- if(typeof state.dygraph_last_touch_end !== 'undefined') {
- if(state.dygraph_last_touch_move === 0) {
- var dt = now - state.dygraph_last_touch_end;
- if(dt <= NETDATA.options.current.double_click_speed)
- NETDATA.resetAllCharts(state);
- }
- }
-
- // remember the timestamp of the last touch end
- state.dygraph_last_touch_end = now;
- }
- }
- };
-
- if(NETDATA.chartLibraries.dygraph.isSparkline(state)) {
- state.dygraph_options.drawGrid = false;
- state.dygraph_options.drawAxis = false;
- state.dygraph_options.title = undefined;
- state.dygraph_options.units = undefined;
- state.dygraph_options.ylabel = undefined;
- state.dygraph_options.yLabelWidth = 0;
- state.dygraph_options.labelsDivWidth = 120;
- state.dygraph_options.labelsDivStyles.width = '120px';
- state.dygraph_options.labelsSeparateLines = true;
- state.dygraph_options.rightGap = 0;
- }
-
- if(smooth === true) {
- state.dygraph_smooth_eligible = true;
-
- if(NETDATA.options.current.smooth_plot === true)
- state.dygraph_options.plotter = smoothPlotter;
- }
- else state.dygraph_smooth_eligible = false;
-
- state.dygraph_instance = new Dygraph(state.element_chart,
- data.result.data, state.dygraph_options);
-
- state.dygraph_force_zoom = false;
- state.dygraph_user_action = false;
- state.dygraph_last_rendered = new Date().getTime();
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // morris
-
- NETDATA.morrisInitialize = function(callback) {
- if(typeof netdataNoMorris === 'undefined' || !netdataNoMorris) {
-
- // morris requires raphael
- if(!NETDATA.chartLibraries.raphael.initialized) {
- if(NETDATA.chartLibraries.raphael.enabled) {
- NETDATA.raphaelInitialize(function() {
- NETDATA.morrisInitialize(callback);
- });
- }
- else {
- NETDATA.chartLibraries.morris.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- }
- else {
- NETDATA._loadCSS(NETDATA.morris_css);
-
- $.ajax({
- url: NETDATA.morris_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('morris', NETDATA.morris_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.morris.enabled = false;
- NETDATA.error(100, NETDATA.morris_js);
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- });
- }
- }
- else {
- NETDATA.chartLibraries.morris.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.morrisChartUpdate = function(state, data) {
- state.morris_instance.setData(data.result.data);
- return true;
- };
-
- NETDATA.morrisChartCreate = function(state, data) {
-
- state.morris_options = {
- element: state.element_chart.id,
- data: data.result.data,
- xkey: 'time',
- ykeys: data.dimension_names,
- labels: data.dimension_names,
- lineWidth: 2,
- pointSize: 3,
- smooth: true,
- hideHover: 'auto',
- parseTime: true,
- continuousLine: false,
- behaveLikeLine: false
- };
-
- if(state.chart.chart_type === 'line')
- state.morris_instance = new Morris.Line(state.morris_options);
-
- else if(state.chart.chart_type === 'area') {
- state.morris_options.behaveLikeLine = true;
- state.morris_instance = new Morris.Area(state.morris_options);
- }
- else // stacked
- state.morris_instance = new Morris.Area(state.morris_options);
-
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // raphael
-
- NETDATA.raphaelInitialize = function(callback) {
- if(typeof netdataStopRaphael === 'undefined' || !netdataStopRaphael) {
- $.ajax({
- url: NETDATA.raphael_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('raphael', NETDATA.raphael_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.raphael.enabled = false;
- NETDATA.error(100, NETDATA.raphael_js);
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- });
- }
- else {
- NETDATA.chartLibraries.raphael.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.raphaelChartUpdate = function(state, data) {
- $(state.element_chart).raphael(data.result, {
- width: state.chartWidth(),
- height: state.chartHeight()
- });
-
- return false;
- };
-
- NETDATA.raphaelChartCreate = function(state, data) {
- $(state.element_chart).raphael(data.result, {
- width: state.chartWidth(),
- height: state.chartHeight()
- });
-
- return false;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // C3
-
- NETDATA.c3Initialize = function(callback) {
- if(typeof netdataNoC3 === 'undefined' || !netdataNoC3) {
-
- // C3 requires D3
- if(!NETDATA.chartLibraries.d3.initialized) {
- if(NETDATA.chartLibraries.d3.enabled) {
- NETDATA.d3Initialize(function() {
- NETDATA.c3Initialize(callback);
- });
- }
- else {
- NETDATA.chartLibraries.c3.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- }
- else {
- NETDATA._loadCSS(NETDATA.c3_css);
-
- $.ajax({
- url: NETDATA.c3_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('c3', NETDATA.c3_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.c3.enabled = false;
- NETDATA.error(100, NETDATA.c3_js);
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- });
- }
- }
- else {
- NETDATA.chartLibraries.c3.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.c3ChartUpdate = function(state, data) {
- state.c3_instance.destroy();
- return NETDATA.c3ChartCreate(state, data);
-
- //state.c3_instance.load({
- // rows: data.result,
- // unload: true
- //});
-
- //return true;
- };
-
- NETDATA.c3ChartCreate = function(state, data) {
-
- state.element_chart.id = 'c3-' + state.uuid;
- // console.log('id = ' + state.element_chart.id);
-
- state.c3_instance = c3.generate({
- bindto: '#' + state.element_chart.id,
- size: {
- width: state.chartWidth(),
- height: state.chartHeight()
- },
- color: {
- pattern: state.chartColors()
- },
- data: {
- x: 'time',
- rows: data.result,
- type: (state.chart.chart_type === 'line')?'spline':'area-spline'
- },
- axis: {
- x: {
- type: 'timeseries',
- tick: {
- format: function(x) {
- return NETDATA.zeropad(x.getHours()) + ":" + NETDATA.zeropad(x.getMinutes()) + ":" + NETDATA.zeropad(x.getSeconds());
- }
- }
- }
- },
- grid: {
- x: {
- show: true
- },
- y: {
- show: true
- }
- },
- point: {
- show: false
- },
- line: {
- connectNull: false
- },
- transition: {
- duration: 0
- },
- interaction: {
- enabled: true
- }
- });
-
- // console.log(state.c3_instance);
-
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // D3
-
- NETDATA.d3Initialize = function(callback) {
- if(typeof netdataStopD3 === 'undefined' || !netdataStopD3) {
- $.ajax({
- url: NETDATA.d3_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('d3', NETDATA.d3_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.d3.enabled = false;
- NETDATA.error(100, NETDATA.d3_js);
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- });
- }
- else {
- NETDATA.chartLibraries.d3.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.d3ChartUpdate = function(state, data) {
- return false;
- };
-
- NETDATA.d3ChartCreate = function(state, data) {
- return false;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // google charts
-
- NETDATA.googleInitialize = function(callback) {
- if(typeof netdataNoGoogleCharts === 'undefined' || !netdataNoGoogleCharts) {
- $.ajax({
- url: NETDATA.google_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('google', NETDATA.google_js);
- google.load('visualization', '1.1', {
- 'packages': ['corechart', 'controls'],
- 'callback': callback
- });
- })
- .fail(function() {
- NETDATA.chartLibraries.google.enabled = false;
- NETDATA.error(100, NETDATA.google_js);
- if(typeof callback === "function")
- callback();
- });
- }
- else {
- NETDATA.chartLibraries.google.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.googleChartUpdate = function(state, data) {
- var datatable = new google.visualization.DataTable(data.result);
- state.google_instance.draw(datatable, state.google_options);
- return true;
- };
-
- NETDATA.googleChartCreate = function(state, data) {
- var datatable = new google.visualization.DataTable(data.result);
-
- state.google_options = {
- colors: state.chartColors(),
-
- // do not set width, height - the chart resizes itself
- //width: state.chartWidth(),
- //height: state.chartHeight(),
- lineWidth: 1,
- title: state.title,
- fontSize: 11,
- hAxis: {
- // title: "Time of Day",
- // format:'HH:mm:ss',
- viewWindowMode: 'maximized',
- slantedText: false,
- format:'HH:mm:ss',
- textStyle: {
- fontSize: 9
- },
- gridlines: {
- color: '#EEE'
- }
- },
- vAxis: {
- title: state.units,
- viewWindowMode: 'pretty',
- minValue: -0.1,
- maxValue: 0.1,
- direction: 1,
- textStyle: {
- fontSize: 9
- },
- gridlines: {
- color: '#EEE'
- }
- },
- chartArea: {
- width: '65%',
- height: '80%'
- },
- focusTarget: 'category',
- annotation: {
- '1': {
- style: 'line'
- }
- },
- pointsVisible: 0,
- titlePosition: 'out',
- titleTextStyle: {
- fontSize: 11
- },
- tooltip: {
- isHtml: false,
- ignoreBounds: true,
- textStyle: {
- fontSize: 9
- }
- },
- curveType: 'function',
- areaOpacity: 0.3,
- isStacked: false
- };
-
- switch(state.chart.chart_type) {
- case "area":
- state.google_options.vAxis.viewWindowMode = 'maximized';
- state.google_options.areaOpacity = NETDATA.options.current.color_fill_opacity_area;
- state.google_instance = new google.visualization.AreaChart(state.element_chart);
- break;
-
- case "stacked":
- state.google_options.isStacked = true;
- state.google_options.areaOpacity = NETDATA.options.current.color_fill_opacity_stacked;
- state.google_options.vAxis.viewWindowMode = 'maximized';
- state.google_options.vAxis.minValue = null;
- state.google_options.vAxis.maxValue = null;
- state.google_instance = new google.visualization.AreaChart(state.element_chart);
- break;
-
- default:
- case "line":
- state.google_options.lineWidth = 2;
- state.google_instance = new google.visualization.LineChart(state.element_chart);
- break;
- }
-
- state.google_instance.draw(datatable, state.google_options);
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
-
- NETDATA.percentFromValueMax = function(value, max) {
- if(value === null) value = 0;
- if(max < value) max = value;
-
- var pcent = 0;
- if(max !== 0) {
- pcent = Math.round(value * 100 / max);
- if(pcent === 0 && value > 0) pcent = 1;
- }
-
- return pcent;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // easy-pie-chart
-
- NETDATA.easypiechartInitialize = function(callback) {
- if(typeof netdataNoEasyPieChart === 'undefined' || !netdataNoEasyPieChart) {
- $.ajax({
- url: NETDATA.easypiechart_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('easypiechart', NETDATA.easypiechart_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.easypiechart.enabled = false;
- NETDATA.error(100, NETDATA.easypiechart_js);
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- })
- }
- else {
- NETDATA.chartLibraries.easypiechart.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.easypiechartClearSelection = function(state) {
- if(typeof state.easyPieChartEvent !== 'undefined') {
- if(state.easyPieChartEvent.timer !== null)
- clearTimeout(state.easyPieChartEvent.timer);
-
- state.easyPieChartEvent.timer = null;
- }
-
- if(state.isAutoRefreshable() === true && state.data !== null) {
- NETDATA.easypiechartChartUpdate(state, state.data);
- }
- else {
- state.easyPieChartLabel.innerHTML = state.legendFormatValue(null);
- state.easyPieChart_instance.update(0);
- }
- state.easyPieChart_instance.enableAnimation();
-
- return true;
- };
-
- NETDATA.easypiechartSetSelection = function(state, t) {
- if(state.timeIsVisible(t) !== true)
- return NETDATA.easypiechartClearSelection(state);
-
- var slot = state.calculateRowForTime(t);
- if(slot < 0 || slot >= state.data.result.length)
- return NETDATA.easypiechartClearSelection(state);
-
- if(typeof state.easyPieChartEvent === 'undefined') {
- state.easyPieChartEvent = {
- timer: null,
- value: 0,
- pcent: 0
- };
- }
-
- var value = state.data.result[state.data.result.length - 1 - slot];
- var max = (state.easyPieChartMax === null)?state.data.max:state.easyPieChartMax;
- var pcent = NETDATA.percentFromValueMax(value, max);
-
- state.easyPieChartEvent.value = value;
- state.easyPieChartEvent.pcent = pcent;
- state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
-
- if(state.easyPieChartEvent.timer === null) {
- state.easyPieChart_instance.disableAnimation();
-
- state.easyPieChartEvent.timer = setTimeout(function() {
- state.easyPieChartEvent.timer = null;
- state.easyPieChart_instance.update(state.easyPieChartEvent.pcent);
- }, NETDATA.options.current.charts_selection_animation_delay);
- }
-
- return true;
- };
-
- NETDATA.easypiechartChartUpdate = function(state, data) {
- var value, max, pcent;
-
- if(NETDATA.globalPanAndZoom.isActive() === true || state.isAutoRefreshable() === false) {
- value = null;
- max = 0;
- pcent = 0;
- }
- else {
- value = data.result[0];
- max = (state.easyPieChartMax === null)?data.max:state.easyPieChartMax;
- pcent = NETDATA.percentFromValueMax(value, max);
- }
-
- state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
- state.easyPieChart_instance.update(pcent);
- return true;
- };
-
- NETDATA.easypiechartChartCreate = function(state, data) {
- var self = $(state.element);
- var chart = $(state.element_chart);
-
- var value = data.result[0];
- var max = self.data('easypiechart-max-value') || null;
- var adjust = self.data('easypiechart-adjust') || null;
-
- if(max === null) {
- max = data.max;
- state.easyPieChartMax = null;
- }
- else
- state.easyPieChartMax = max;
-
- var pcent = NETDATA.percentFromValueMax(value, max);
-
- chart.data('data-percent', pcent);
-
- var size;
- switch(adjust) {
- case 'width': size = state.chartHeight(); break;
- case 'min': size = Math.min(state.chartWidth(), state.chartHeight()); break;
- case 'max': size = Math.max(state.chartWidth(), state.chartHeight()); break;
- case 'height':
- default: size = state.chartWidth(); break;
- }
- state.element.style.width = size + 'px';
- state.element.style.height = size + 'px';
-
- var stroke = Math.floor(size / 22);
- if(stroke < 3) stroke = 2;
-
- var valuefontsize = Math.floor((size * 2 / 3) / 5);
- var valuetop = Math.round((size - valuefontsize - (size / 40)) / 2);
- state.easyPieChartLabel = document.createElement('span');
- state.easyPieChartLabel.className = 'easyPieChartLabel';
- state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
- state.easyPieChartLabel.style.fontSize = valuefontsize + 'px';
- state.easyPieChartLabel.style.top = valuetop.toString() + 'px';
- state.element_chart.appendChild(state.easyPieChartLabel);
-
- var titlefontsize = Math.round(valuefontsize * 1.6 / 3);
- var titletop = Math.round(valuetop - (titlefontsize * 2) - (size / 40));
- state.easyPieChartTitle = document.createElement('span');
- state.easyPieChartTitle.className = 'easyPieChartTitle';
- state.easyPieChartTitle.innerHTML = state.title;
- state.easyPieChartTitle.style.fontSize = titlefontsize + 'px';
- state.easyPieChartTitle.style.lineHeight = titlefontsize + 'px';
- state.easyPieChartTitle.style.top = titletop.toString() + 'px';
- state.element_chart.appendChild(state.easyPieChartTitle);
-
- var unitfontsize = Math.round(titlefontsize * 0.9);
- var unittop = Math.round(valuetop + (valuefontsize + unitfontsize) + (size / 40));
- state.easyPieChartUnits = document.createElement('span');
- state.easyPieChartUnits.className = 'easyPieChartUnits';
- state.easyPieChartUnits.innerHTML = state.units;
- state.easyPieChartUnits.style.fontSize = unitfontsize + 'px';
- state.easyPieChartUnits.style.top = unittop.toString() + 'px';
- state.element_chart.appendChild(state.easyPieChartUnits);
-
- chart.easyPieChart({
- barColor: self.data('easypiechart-barcolor') || state.chartColors()[0], //'#ef1e25',
- trackColor: self.data('easypiechart-trackcolor') || NETDATA.themes.current.easypiechart_track,
- scaleColor: self.data('easypiechart-scalecolor') || NETDATA.themes.current.easypiechart_scale,
- scaleLength: self.data('easypiechart-scalelength') || 5,
- lineCap: self.data('easypiechart-linecap') || 'round',
- lineWidth: self.data('easypiechart-linewidth') || stroke,
- trackWidth: self.data('easypiechart-trackwidth') || undefined,
- size: self.data('easypiechart-size') || size,
- rotate: self.data('easypiechart-rotate') || 0,
- animate: self.data('easypiechart-rotate') || {duration: 500, enabled: true},
- easing: self.data('easypiechart-easing') || undefined
- });
-
- // when we just re-create the chart
- // do not animate the first update
- var animate = true;
- if(typeof state.easyPieChart_instance !== 'undefined')
- animate = false;
-
- state.easyPieChart_instance = chart.data('easyPieChart');
- if(animate === false) state.easyPieChart_instance.disableAnimation();
- state.easyPieChart_instance.update(pcent);
- if(animate === false) state.easyPieChart_instance.enableAnimation();
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // gauge.js
-
- NETDATA.gaugeInitialize = function(callback) {
- if(typeof netdataNoGauge === 'undefined' || !netdataNoGauge) {
- $.ajax({
- url: NETDATA.gauge_js,
- cache: true,
- dataType: "script"
- })
- .done(function() {
- NETDATA.registerChartLibrary('gauge', NETDATA.gauge_js);
- })
- .fail(function() {
- NETDATA.chartLibraries.gauge.enabled = false;
- NETDATA.error(100, NETDATA.gauge_js);
- })
- .always(function() {
- if(typeof callback === "function")
- callback();
- })
- }
- else {
- NETDATA.chartLibraries.gauge.enabled = false;
- if(typeof callback === "function")
- callback();
- }
- };
-
- NETDATA.gaugeAnimation = function(state, status) {
- var speed = 32;
-
- if(typeof status === 'boolean' && status === false)
- speed = 1000000000;
- else if(typeof status === 'number')
- speed = status;
-
- state.gauge_instance.animationSpeed = speed;
- state.___gaugeOld__.speed = speed;
- };
-
- NETDATA.gaugeSet = function(state, value, min, max) {
- if(typeof value !== 'number') value = 0;
- if(typeof min !== 'number') min = 0;
- if(typeof max !== 'number') max = 0;
- if(value > max) max = value;
- if(value < min) min = value;
- if(min > max) {
- var t = min;
- min = max;
- max = t;
- }
- else if(min == max)
- max = min + 1;
-
- // gauge.js has an issue if the needle
- // is smaller than min or larger than max
- // when we set the new values
- // the needle will go crazy
-
- // to prevent it, we always feed it
- // with a percentage, so that the needle
- // is always between min and max
- var pcent = (value - min) * 100 / (max - min);
-
- // these should never happen
- if(pcent < 0) pcent = 0;
- if(pcent > 100) pcent = 100;
-
- state.gauge_instance.set(pcent);
-
- state.___gaugeOld__.value = value;
- state.___gaugeOld__.min = min;
- state.___gaugeOld__.max = max;
- };
-
- NETDATA.gaugeSetLabels = function(state, value, min, max) {
- if(state.___gaugeOld__.valueLabel !== value) {
- state.___gaugeOld__.valueLabel = value;
- state.gaugeChartLabel.innerHTML = state.legendFormatValue(value);
- }
- if(state.___gaugeOld__.minLabel !== min) {
- state.___gaugeOld__.minLabel = min;
- state.gaugeChartMin.innerHTML = state.legendFormatValue(min);
- }
- if(state.___gaugeOld__.maxLabel !== max) {
- state.___gaugeOld__.maxLabel = max;
- state.gaugeChartMax.innerHTML = state.legendFormatValue(max);
- }
- };
-
- NETDATA.gaugeClearSelection = function(state) {
- if(typeof state.gaugeEvent !== 'undefined') {
- if(state.gaugeEvent.timer !== null)
- clearTimeout(state.gaugeEvent.timer);
-
- state.gaugeEvent.timer = null;
- }
-
- if(state.isAutoRefreshable() === true && state.data !== null) {
- NETDATA.gaugeChartUpdate(state, state.data);
- }
- else {
- NETDATA.gaugeAnimation(state, false);
- NETDATA.gaugeSet(state, null, null, null);
- NETDATA.gaugeSetLabels(state, null, null, null);
- }
-
- NETDATA.gaugeAnimation(state, true);
- return true;
- };
-
- NETDATA.gaugeSetSelection = function(state, t) {
- if(state.timeIsVisible(t) !== true)
- return NETDATA.gaugeClearSelection(state);
-
- var slot = state.calculateRowForTime(t);
- if(slot < 0 || slot >= state.data.result.length)
- return NETDATA.gaugeClearSelection(state);
-
- if(typeof state.gaugeEvent === 'undefined') {
- state.gaugeEvent = {
- timer: null,
- value: 0,
- min: 0,
- max: 0
- };
- }
-
- var value = state.data.result[state.data.result.length - 1 - slot];
- var max = (state.gaugeMax === null)?state.data.max:state.gaugeMax;
- var min = 0;
-
- state.gaugeEvent.value = value;
- state.gaugeEvent.max = max;
- state.gaugeEvent.min = min;
- NETDATA.gaugeSetLabels(state, value, min, max);
-
- if(state.gaugeEvent.timer === null) {
- NETDATA.gaugeAnimation(state, false);
-
- state.gaugeEvent.timer = setTimeout(function() {
- state.gaugeEvent.timer = null;
- NETDATA.gaugeSet(state, state.gaugeEvent.value, state.gaugeEvent.min, state.gaugeEvent.max);
- }, NETDATA.options.current.charts_selection_animation_delay);
- }
-
- return true;
- };
-
- NETDATA.gaugeChartUpdate = function(state, data) {
- var value, min, max;
-
- if(NETDATA.globalPanAndZoom.isActive() === true || state.isAutoRefreshable() === false) {
- value = 0;
- min = 0;
- max = 1;
- NETDATA.gaugeSetLabels(state, null, null, null);
- }
- else {
- value = data.result[0];
- min = 0;
- max = (state.gaugeMax === null)?data.max:state.gaugeMax;
- if(value > max) max = value;
- NETDATA.gaugeSetLabels(state, value, min, max);
- }
-
- NETDATA.gaugeSet(state, value, min, max);
- return true;
- };
-
- NETDATA.gaugeChartCreate = function(state, data) {
- var self = $(state.element);
- // var chart = $(state.element_chart);
-
- var value = data.result[0];
- var max = self.data('gauge-max-value') || null;
- var adjust = self.data('gauge-adjust') || null;
- var pointerColor = self.data('gauge-pointer-color') || NETDATA.themes.current.gauge_pointer;
- var strokeColor = self.data('gauge-stroke-color') || NETDATA.themes.current.gauge_stroke;
- var startColor = self.data('gauge-start-color') || state.chartColors()[0];
- var stopColor = self.data('gauge-stop-color') || void 0;
- var generateGradient = self.data('gauge-generate-gradient') || false;
-
- if(max === null) {
- max = data.max;
- state.gaugeMax = null;
- }
- else
- state.gaugeMax = max;
-
- var width = state.chartWidth(), height = state.chartHeight(); //, ratio = 1.5;
- //switch(adjust) {
- // case 'width': width = height * ratio; break;
- // case 'height':
- // default: height = width / ratio; break;
- //}
- //state.element.style.width = width.toString() + 'px';
- //state.element.style.height = height.toString() + 'px';
-
- var lum_d = 0.05;
-
- var options = {
- lines: 12, // The number of lines to draw
- angle: 0.15, // The length of each line
- lineWidth: 0.44, // 0.44 The line thickness
- pointer: {
- length: 0.8, // 0.9 The radius of the inner circle
- strokeWidth: 0.035, // The rotation offset
- color: pointerColor // Fill color
- },
- colorStart: startColor, // Colors
- colorStop: stopColor, // just experiment with them
- strokeColor: strokeColor, // to see which ones work best for you
- limitMax: true,
- generateGradient: (generateGradient === true)?true:false,
- gradientType: 0
- };
-
- if (generateGradient.constructor === Array) {
- // example options:
- // data-gauge-generate-gradient="[0, 50, 100]"
- // data-gauge-gradient-percent-color-0="#FFFFFF"
- // data-gauge-gradient-percent-color-50="#999900"
- // data-gauge-gradient-percent-color-100="#000000"
-
- options.percentColors = new Array();
- var len = generateGradient.length;
- while(len--) {
- var pcent = generateGradient[len];
- var color = self.data('gauge-gradient-percent-color-' + pcent.toString()) || false;
- if(color !== false) {
- var a = new Array();
- a[0] = pcent / 100;
- a[1] = color;
- options.percentColors.unshift(a);
- }
- }
- if(options.percentColors.length === 0)
- delete options.percentColors;
- }
- else if(generateGradient === false && NETDATA.themes.current.gauge_gradient === true) {
- options.percentColors = [
- [0.0, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 0))],
- [0.1, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 1))],
- [0.2, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 2))],
- [0.3, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 3))],
- [0.4, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 4))],
- [0.5, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 5))],
- [0.6, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 6))],
- [0.7, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 7))],
- [0.8, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 8))],
- [0.9, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 9))],
- [1.0, NETDATA.colorLuminance(startColor, 0.0)]];
- }
-
- state.gauge_canvas = document.createElement('canvas');
- state.gauge_canvas.id = 'gauge-' + state.uuid + '-canvas';
- state.gauge_canvas.className = 'gaugeChart';
- state.gauge_canvas.width = width;
- state.gauge_canvas.height = height;
- state.element_chart.appendChild(state.gauge_canvas);
-
- var valuefontsize = Math.floor(height / 6);
- var valuetop = Math.round((height - valuefontsize - (height / 6)) / 2);
- state.gaugeChartLabel = document.createElement('span');
- state.gaugeChartLabel.className = 'gaugeChartLabel';
- state.gaugeChartLabel.style.fontSize = valuefontsize + 'px';
- state.gaugeChartLabel.style.top = valuetop.toString() + 'px';
- state.element_chart.appendChild(state.gaugeChartLabel);
-
- var titlefontsize = Math.round(valuefontsize / 2);
- var titletop = 0;
- state.gaugeChartTitle = document.createElement('span');
- state.gaugeChartTitle.className = 'gaugeChartTitle';
- state.gaugeChartTitle.innerHTML = state.title;
- state.gaugeChartTitle.style.fontSize = titlefontsize + 'px';
- state.gaugeChartTitle.style.lineHeight = titlefontsize + 'px';
- state.gaugeChartTitle.style.top = titletop.toString() + 'px';
- state.element_chart.appendChild(state.gaugeChartTitle);
-
- var unitfontsize = Math.round(titlefontsize * 0.9);
- state.gaugeChartUnits = document.createElement('span');
- state.gaugeChartUnits.className = 'gaugeChartUnits';
- state.gaugeChartUnits.innerHTML = state.units;
- state.gaugeChartUnits.style.fontSize = unitfontsize + 'px';
- state.element_chart.appendChild(state.gaugeChartUnits);
-
- state.gaugeChartMin = document.createElement('span');
- state.gaugeChartMin.className = 'gaugeChartMin';
- state.gaugeChartMin.style.fontSize = Math.round(valuefontsize * 0.75).toString() + 'px';
- state.element_chart.appendChild(state.gaugeChartMin);
-
- state.gaugeChartMax = document.createElement('span');
- state.gaugeChartMax.className = 'gaugeChartMax';
- state.gaugeChartMax.style.fontSize = Math.round(valuefontsize * 0.75).toString() + 'px';
- state.element_chart.appendChild(state.gaugeChartMax);
-
- // when we just re-create the chart
- // do not animate the first update
- var animate = true;
- if(typeof state.gauge_instance !== 'undefined')
- animate = false;
-
- state.gauge_instance = new Gauge(state.gauge_canvas).setOptions(options); // create sexy gauge!
-
- state.___gaugeOld__ = {
- value: value,
- min: 0,
- max: max,
- valueLabel: null,
- minLabel: null,
- maxLabel: null
- };
-
- // we will always feed a percentage
- state.gauge_instance.minValue = 0;
- state.gauge_instance.maxValue = 100;
-
- NETDATA.gaugeAnimation(state, animate);
- NETDATA.gaugeSet(state, value, 0, max);
- NETDATA.gaugeSetLabels(state, value, 0, max);
- NETDATA.gaugeAnimation(state, true);
- return true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // Charts Libraries Registration
-
- NETDATA.chartLibraries = {
- "dygraph": {
- initialize: NETDATA.dygraphInitialize,
- create: NETDATA.dygraphChartCreate,
- update: NETDATA.dygraphChartUpdate,
- resize: function(state) {
- if(typeof state.dygraph_instance.resize === 'function')
- state.dygraph_instance.resize();
- },
- setSelection: NETDATA.dygraphSetSelection,
- clearSelection: NETDATA.dygraphClearSelection,
- toolboxPanAndZoom: NETDATA.dygraphToolboxPanAndZoom,
- initialized: false,
- enabled: true,
- format: function(state) { return 'json'; },
- options: function(state) { return 'ms|flip'; },
- legend: function(state) {
- if(this.isSparkline(state) === false)
- return 'right-side';
- else
- return null;
- },
- autoresize: function(state) { return true; },
- max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return true; },
- pixels_per_point: function(state) {
- if(this.isSparkline(state) === false)
- return 3;
- else
- return 2;
- },
-
- isSparkline: function(state) {
- if(typeof state.dygraph_sparkline === 'undefined') {
- var t = $(state.element).data('dygraph-theme');
- if(t === 'sparkline')
- state.dygraph_sparkline = true;
- else
- state.dygraph_sparkline = false;
- }
- return state.dygraph_sparkline;
- }
- },
- "sparkline": {
- initialize: NETDATA.sparklineInitialize,
- create: NETDATA.sparklineChartCreate,
- update: NETDATA.sparklineChartUpdate,
- resize: null,
- setSelection: undefined, // function(state, t) { return true; },
- clearSelection: undefined, // function(state) { return true; },
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'array'; },
- options: function(state) { return 'flip|abs'; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return false; },
- pixels_per_point: function(state) { return 3; }
- },
- "peity": {
- initialize: NETDATA.peityInitialize,
- create: NETDATA.peityChartCreate,
- update: NETDATA.peityChartUpdate,
- resize: null,
- setSelection: undefined, // function(state, t) { return true; },
- clearSelection: undefined, // function(state) { return true; },
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'ssvcomma'; },
- options: function(state) { return 'null2zero|flip|abs'; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return false; },
- pixels_per_point: function(state) { return 3; }
- },
- "morris": {
- initialize: NETDATA.morrisInitialize,
- create: NETDATA.morrisChartCreate,
- update: NETDATA.morrisChartUpdate,
- resize: null,
- setSelection: undefined, // function(state, t) { return true; },
- clearSelection: undefined, // function(state) { return true; },
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'json'; },
- options: function(state) { return 'objectrows|ms'; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 50; },
- track_colors: function(state) { return false; },
- pixels_per_point: function(state) { return 15; }
- },
- "google": {
- initialize: NETDATA.googleInitialize,
- create: NETDATA.googleChartCreate,
- update: NETDATA.googleChartUpdate,
- resize: null,
- setSelection: undefined, //function(state, t) { return true; },
- clearSelection: undefined, //function(state) { return true; },
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'datatable'; },
- options: function(state) { return ''; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 300; },
- track_colors: function(state) { return false; },
- pixels_per_point: function(state) { return 4; }
- },
- "raphael": {
- initialize: NETDATA.raphaelInitialize,
- create: NETDATA.raphaelChartCreate,
- update: NETDATA.raphaelChartUpdate,
- resize: null,
- setSelection: undefined, // function(state, t) { return true; },
- clearSelection: undefined, // function(state) { return true; },
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'json'; },
- options: function(state) { return ''; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return false; },
- pixels_per_point: function(state) { return 3; }
- },
- "c3": {
- initialize: NETDATA.c3Initialize,
- create: NETDATA.c3ChartCreate,
- update: NETDATA.c3ChartUpdate,
- resize: null,
- setSelection: undefined, // function(state, t) { return true; },
- clearSelection: undefined, // function(state) { return true; },
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'csvjsonarray'; },
- options: function(state) { return 'milliseconds'; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return false; },
- pixels_per_point: function(state) { return 15; }
- },
- "d3": {
- initialize: NETDATA.d3Initialize,
- create: NETDATA.d3ChartCreate,
- update: NETDATA.d3ChartUpdate,
- resize: null,
- setSelection: undefined, // function(state, t) { return true; },
- clearSelection: undefined, // function(state) { return true; },
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'json'; },
- options: function(state) { return ''; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return false; },
- pixels_per_point: function(state) { return 3; }
- },
- "easypiechart": {
- initialize: NETDATA.easypiechartInitialize,
- create: NETDATA.easypiechartChartCreate,
- update: NETDATA.easypiechartChartUpdate,
- resize: null,
- setSelection: NETDATA.easypiechartSetSelection,
- clearSelection: NETDATA.easypiechartClearSelection,
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'array'; },
- options: function(state) { return 'absolute'; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return true; },
- pixels_per_point: function(state) { return 3; },
- aspect_ratio: 100
- },
- "gauge": {
- initialize: NETDATA.gaugeInitialize,
- create: NETDATA.gaugeChartCreate,
- update: NETDATA.gaugeChartUpdate,
- resize: null,
- setSelection: NETDATA.gaugeSetSelection,
- clearSelection: NETDATA.gaugeClearSelection,
- toolboxPanAndZoom: null,
- initialized: false,
- enabled: true,
- format: function(state) { return 'array'; },
- options: function(state) { return 'absolute'; },
- legend: function(state) { return null; },
- autoresize: function(state) { return false; },
- max_updates_to_recreate: function(state) { return 5000; },
- track_colors: function(state) { return true; },
- pixels_per_point: function(state) { return 3; },
- aspect_ratio: 70
- }
- };
-
- NETDATA.registerChartLibrary = function(library, url) {
- if(NETDATA.options.debug.libraries === true)
- console.log("registering chart library: " + library);
-
- NETDATA.chartLibraries[library].url = url;
- NETDATA.chartLibraries[library].initialized = true;
- NETDATA.chartLibraries[library].enabled = true;
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // Load required JS libraries and CSS
-
- NETDATA.requiredJs = [
- {
- url: NETDATA.serverDefault + 'lib/bootstrap.min.js',
- isAlreadyLoaded: function() {
- // check if bootstrap is loaded
- if(typeof $().emulateTransitionEnd == 'function')
- return true;
- else {
- if(typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap)
- return true;
- else
- return false;
- }
- }
- },
- {
- url: NETDATA.serverDefault + 'lib/jquery.nanoscroller.min.js',
- isAlreadyLoaded: function() { return false; }
- },
- {
- url: NETDATA.serverDefault + 'lib/bootstrap-toggle.min.js',
- isAlreadyLoaded: function() { return false; }
- }
- ];
-
- NETDATA.requiredCSS = [
- {
- url: NETDATA.themes.current.bootstrap_css,
- isAlreadyLoaded: function() {
- if(typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap)
- return true;
- else
- return false;
- }
- },
- {
- url: NETDATA.serverDefault + 'css/font-awesome.min.css',
- isAlreadyLoaded: function() { return false; }
- },
- {
- url: NETDATA.themes.current.dashboard_css,
- isAlreadyLoaded: function() { return false; }
- },
- {
- url: NETDATA.serverDefault + 'css/bootstrap-toggle.min.css',
- isAlreadyLoaded: function() { return false; }
- }
- ];
-
- NETDATA.loadRequiredJs = function(index, callback) {
- if(index >= NETDATA.requiredJs.length) {
- if(typeof callback === 'function')
- callback();
- return;
- }
-
- if(NETDATA.requiredJs[index].isAlreadyLoaded()) {
- NETDATA.loadRequiredJs(++index, callback);
- return;
- }
-
- if(NETDATA.options.debug.main_loop === true)
- console.log('loading ' + NETDATA.requiredJs[index].url);
-
- $.ajax({
- url: NETDATA.requiredJs[index].url,
- cache: true,
- dataType: "script"
- })
- .success(function() {
- if(NETDATA.options.debug.main_loop === true)
- console.log('loaded ' + NETDATA.requiredJs[index].url);
-
- NETDATA.loadRequiredJs(++index, callback);
- })
- .fail(function() {
- alert('Cannot load required JS library: ' + NETDATA.requiredJs[index].url);
- })
- };
-
- NETDATA.loadRequiredCSS = function(index) {
- if(index >= NETDATA.requiredCSS.length)
- return;
-
- if(NETDATA.requiredCSS[index].isAlreadyLoaded()) {
- NETDATA.loadRequiredCSS(++index);
- return;
- }
-
- if(NETDATA.options.debug.main_loop === true)
- console.log('loading ' + NETDATA.requiredCSS[index].url);
-
- NETDATA._loadCSS(NETDATA.requiredCSS[index].url);
- NETDATA.loadRequiredCSS(++index);
- };
-
-
- // ----------------------------------------------------------------------------------------------------------------
- // Registry of netdata hosts
-
- NETDATA.registry = {
- server: null, // the netdata registry server
- person_guid: null, // the unique ID of this browser / user
- machine_guid: null, // the unique ID the netdata server that served dashboard.js
- hostname: null, // the hostname of the netdata server that served dashboard.js
- urls: null, // the user's other URLs
- urls_array: null, // the user's other URLs in an array
-
- parsePersonUrls: function(person_urls) {
- // console.log(person_urls);
-
- if(person_urls) {
- NETDATA.registry.urls = {};
- NETDATA.registry.urls_array = new Array();
-
- var now = new Date().getTime();
- var apu = person_urls;
- var i = apu.length;
- while(i--) {
- if(typeof NETDATA.registry.urls[apu[i][0]] === 'undefined') {
- // console.log('adding: ' + apu[i][4] + ', ' + ((now - apu[i][2]) / 1000).toString());
-
- var obj = {
- guid: apu[i][0],
- url: apu[i][1],
- last_t: apu[i][2],
- accesses: apu[i][3],
- name: apu[i][4],
- alternate_urls: new Array()
- };
-
- NETDATA.registry.urls[apu[i][0]] = obj;
- NETDATA.registry.urls_array.push(obj);
- }
- else {
- // console.log('appending: ' + apu[i][4] + ', ' + ((now - apu[i][2]) / 1000).toString());
-
- var pu = NETDATA.registry.urls[apu[i][0]];
- if(pu.last_t < apu[i][2]) {
- pu.url = apu[i][1];
- pu.last_t = apu[i][2];
- pu.name = apu[i][4];
- }
- pu.accesses += apu[i][3];
- pu.alternate_urls.push(apu[i][1]);
- }
- }
- }
-
- if(typeof netdataRegistryCallback === 'function')
- netdataRegistryCallback(NETDATA.registry.urls_array);
- },
-
- init: function() {
- if(typeof netdataNoRegistry !== 'undefined' && netdataNoRegistry)
- return;
-
- NETDATA.registry.hello(NETDATA.serverDefault, function(data) {
- if(data) {
- NETDATA.registry.server = data.registry;
- NETDATA.registry.machine_guid = data.machine_guid;
- NETDATA.registry.hostname = data.hostname;
-
- NETDATA.registry.access(10, function (person_urls) {
- NETDATA.registry.parsePersonUrls(person_urls);
-
- });
- }
- });
- },
-
- hello: function(host, callback) {
- // send HELLO to a netdata server:
- // 1. verifies the server is reachable
- // 2. responds with the registry URL, the machine GUID of this netdata server and its hostname
- $.ajax({
- url: host + '/api/v1/registry?action=hello',
- async: true,
- cache: false,
- xhrFields: { withCredentials: true } // required for the cookie
- })
- .done(function(data) {
- if(typeof data.status !== 'string' || data.status !== 'ok') {
- NETDATA.error(408, host + ' response: ' + JSON.stringify(data));
- data = null;
- }
-
- if(typeof callback === 'function')
- callback(data);
- })
- .fail(function() {
- NETDATA.error(407, host);
-
- if(typeof callback === 'function')
- callback(null);
- });
- },
-
- access: function(max_redirects, callback) {
- // send ACCESS to a netdata registry:
- // 1. it lets it know we are accessing a netdata server (its machine GUID and its URL)
- // 2. it responds with a list of netdata servers we know
- // the registry identifies us using a cookie it sets the first time we access it
- // the registry may respond with a redirect URL to send us to another registry
- $.ajax({
- url: NETDATA.registry.server + '/api/v1/registry?action=access&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault), // + '&visible_url=' + encodeURIComponent(document.location),
- async: true,
- cache: false,
- xhrFields: { withCredentials: true } // required for the cookie
- })
- .done(function(data) {
- var redirect = null;
- if(typeof data.registry === 'string')
- redirect = data.registry;
-
- if(typeof data.status !== 'string' || data.status !== 'ok') {
- NETDATA.error(409, NETDATA.registry.server + ' responded with: ' + JSON.stringify(data));
- data = null;
- }
-
- if(data === null && redirect !== null && max_redirects > 0) {
- NETDATA.registry.server = redirect;
- NETDATA.registry.access(max_redirects - 1, callback);
- }
- else {
- if(typeof data.person_guid === 'string')
- NETDATA.registry.person_guid = data.person_guid;
-
- if(typeof callback === 'function')
- callback(data.urls);
- }
- })
- .fail(function() {
- NETDATA.error(410, NETDATA.registry.server);
-
- if(typeof callback === 'function')
- callback(null);
- });
- },
-
- delete: function(delete_url, callback) {
- // send DELETE to a netdata registry:
- $.ajax({
- url: NETDATA.registry.server + '/api/v1/registry?action=delete&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault) + '&delete_url=' + encodeURIComponent(delete_url),
- async: true,
- cache: false,
- xhrFields: { withCredentials: true } // required for the cookie
- })
- .done(function(data) {
- if(typeof data.status !== 'string' || data.status !== 'ok') {
- NETDATA.error(411, NETDATA.registry.server + ' responded with: ' + JSON.stringify(data));
- data = null;
- }
-
- if(typeof callback === 'function')
- callback(data);
- })
- .fail(function() {
- NETDATA.error(412, NETDATA.registry.server);
-
- if(typeof callback === 'function')
- callback(null);
- });
- },
-
- switch: function(new_person_guid, callback) {
- // impersonate
- $.ajax({
- url: NETDATA.registry.server + '/api/v1/registry?action=switch&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault) + '&to=' + new_person_guid,
- async: true,
- cache: false,
- xhrFields: { withCredentials: true } // required for the cookie
- })
- .done(function(data) {
- if(typeof data.status !== 'string' || data.status !== 'ok') {
- NETDATA.error(413, NETDATA.registry.server + ' responded with: ' + JSON.stringify(data));
- data = null;
- }
-
- if(typeof callback === 'function')
- callback(data);
- })
- .fail(function() {
- NETDATA.error(414, NETDATA.registry.server);
-
- if(typeof callback === 'function')
- callback(null);
- });
- }
- };
-
- // ----------------------------------------------------------------------------------------------------------------
- // Boot it!
-
- NETDATA.errorReset();
- NETDATA.loadRequiredCSS(0);
-
- NETDATA._loadjQuery(function() {
- NETDATA.loadRequiredJs(0, function() {
- if(typeof $().emulateTransitionEnd !== 'function') {
- // bootstrap is not available
- NETDATA.options.current.show_help = false;
- }
-
- if(typeof netdataDontStart === 'undefined' || !netdataDontStart) {
- if(NETDATA.options.debug.main_loop === true)
- console.log('starting chart refresh thread');
-
- NETDATA.start();
- }
- });
- });
-
- // window.NETDATA = NETDATA;
+ sync_selection_delay: 1500, // ms - when you pan or zoom a chart, wait this amount
+ // of time before setting up synchronized selections
+ // on hover.
+
+ sync_selection: true, // enable or disable selection sync
+
+ pan_and_zoom_delay: 50, // when panning or zooming, how ofter to update the chart
+
+ sync_pan_and_zoom: true, // enable or disable pan and zoom sync
+
+ pan_and_zoom_data_padding: true, // fetch more data for the master chart when panning or zooming
+
+ update_only_visible: true, // enable or disable visibility management
+
+ parallel_refresher: true, // enable parallel refresh of charts
+
+ concurrent_refreshes: true, // when parallel_refresher is enabled, sync also the charts
+
+ destroy_on_hide: false, // destroy charts when they are not visible
+
+ show_help: netdataShowHelp, // when enabled the charts will show some help
+ show_help_delay_show_ms: 500,
+ show_help_delay_hide_ms: 0,
+
+ eliminate_zero_dimensions: true, // do not show dimensions with just zeros
+
+ stop_updates_when_focus_is_lost: true, // boolean - shall we stop auto-refreshes when document does not have user focus
+ stop_updates_while_resizing: 1000, // ms - time to stop auto-refreshes while resizing the charts
+
+ double_click_speed: 500, // ms - time between clicks / taps to detect double click/tap
+
+ smooth_plot: true, // enable smooth plot, where possible
+
+ charts_selection_animation_delay: 50, // delay to animate charts when syncing selection
+
+ color_fill_opacity_line: 1.0,
+ color_fill_opacity_area: 0.2,
+ color_fill_opacity_stacked: 0.8,
+
+ pan_and_zoom_factor: 0.25, // the increment when panning and zooming with the toolbox
+ pan_and_zoom_factor_multiplier_control: 2.0,
+ pan_and_zoom_factor_multiplier_shift: 3.0,
+ pan_and_zoom_factor_multiplier_alt: 4.0,
+
+ abort_ajax_on_scroll: false,
+
+ setOptionCallback: function() { ; }
+ },
+
+ debug: {
+ show_boxes: false,
+ main_loop: false,
+ focus: false,
+ visibility: false,
+ chart_data_url: false,
+ chart_errors: false, // FIXME
+ chart_timing: false,
+ chart_calls: false,
+ libraries: false,
+ dygraph: false
+ }
+ };
+
+ NETDATA.statistics = {
+ refreshes_total: 0,
+ refreshes_active: 0,
+ refreshes_active_max: 0
+ };
+
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // local storage options
+
+ NETDATA.localStorage = {
+ default: {},
+ current: {},
+ callback: {} // only used for resetting back to defaults
+ };
+
+ NETDATA.localStorageGet = function(key, def, callback) {
+ var ret = def;
+
+ if(typeof NETDATA.localStorage.default[key.toString()] === 'undefined') {
+ NETDATA.localStorage.default[key.toString()] = def;
+ NETDATA.localStorage.callback[key.toString()] = callback;
+ }
+
+ if(typeof Storage !== "undefined" && typeof localStorage === 'object') {
+ try {
+ // console.log('localStorage: loading "' + key.toString() + '"');
+ ret = localStorage.getItem(key.toString());
+ // console.log('netdata loaded: ' + key.toString() + ' = ' + ret.toString());
+ if(ret === null || ret === 'undefined') {
+ // console.log('localStorage: cannot load it, saving "' + key.toString() + '" with value "' + JSON.stringify(def) + '"');
+ localStorage.setItem(key.toString(), JSON.stringify(def));
+ ret = def;
+ }
+ else {
+ // console.log('localStorage: got "' + key.toString() + '" with value "' + ret + '"');
+ ret = JSON.parse(ret);
+ // console.log('localStorage: loaded "' + key.toString() + '" as value ' + ret + ' of type ' + typeof(ret));
+ }
+ }
+ catch(error) {
+ console.log('localStorage: failed to read "' + key.toString() + '", using default: "' + def.toString() + '"');
+ ret = def;
+ }
+ }
+
+ if(typeof ret === 'undefined' || ret === 'undefined') {
+ console.log('localStorage: LOADED UNDEFINED "' + key.toString() + '" as value ' + ret + ' of type ' + typeof(ret));
+ ret = def;
+ }
+
+ NETDATA.localStorage.current[key.toString()] = ret;
+ return ret;
+ };
+
+ NETDATA.localStorageSet = function(key, value, callback) {
+ if(typeof value === 'undefined' || value === 'undefined') {
+ console.log('localStorage: ATTEMPT TO SET UNDEFINED "' + key.toString() + '" as value ' + value + ' of type ' + typeof(value));
+ }
+
+ if(typeof NETDATA.localStorage.default[key.toString()] === 'undefined') {
+ NETDATA.localStorage.default[key.toString()] = value;
+ NETDATA.localStorage.current[key.toString()] = value;
+ NETDATA.localStorage.callback[key.toString()] = callback;
+ }
+
+ if(typeof Storage !== "undefined" && typeof localStorage === 'object') {
+ // console.log('localStorage: saving "' + key.toString() + '" with value "' + JSON.stringify(value) + '"');
+ try {
+ localStorage.setItem(key.toString(), JSON.stringify(value));
+ }
+ catch(e) {
+ console.log('localStorage: failed to save "' + key.toString() + '" with value: "' + value.toString() + '"');
+ }
+ }
+
+ NETDATA.localStorage.current[key.toString()] = value;
+ return value;
+ };
+
+ NETDATA.localStorageGetRecursive = function(obj, prefix, callback) {
+ for(var i in obj) {
+ if(typeof obj[i] === 'object') {
+ //console.log('object ' + prefix + '.' + i.toString());
+ NETDATA.localStorageGetRecursive(obj[i], prefix + '.' + i.toString(), callback);
+ continue;
+ }
+
+ obj[i] = NETDATA.localStorageGet(prefix + '.' + i.toString(), obj[i], callback);
+ }
+ };
+
+ NETDATA.setOption = function(key, value) {
+ if(key.toString() === 'setOptionCallback') {
+ if(typeof NETDATA.options.current.setOptionCallback === 'function') {
+ NETDATA.options.current[key.toString()] = value;
+ NETDATA.options.current.setOptionCallback();
+ }
+ }
+ else if(NETDATA.options.current[key.toString()] !== value) {
+ var name = 'options.' + key.toString();
+
+ if(typeof NETDATA.localStorage.default[name.toString()] === 'undefined')
+ console.log('localStorage: setOption() on unsaved option: "' + name.toString() + '", value: ' + value);
+
+ //console.log(NETDATA.localStorage);
+ //console.log('setOption: setting "' + key.toString() + '" to "' + value + '" of type ' + typeof(value) + ' original type ' + typeof(NETDATA.options.current[key.toString()]));
+ //console.log(NETDATA.options);
+ NETDATA.options.current[key.toString()] = NETDATA.localStorageSet(name.toString(), value, null);
+
+ if(typeof NETDATA.options.current.setOptionCallback === 'function')
+ NETDATA.options.current.setOptionCallback();
+ }
+
+ return true;
+ };
+
+ NETDATA.getOption = function(key) {
+ return NETDATA.options.current[key.toString()];
+ };
+
+ // read settings from local storage
+ NETDATA.localStorageGetRecursive(NETDATA.options.current, 'options', null);
+
+ // always start with this option enabled.
+ NETDATA.setOption('stop_updates_when_focus_is_lost', true);
+
+ NETDATA.resetOptions = function() {
+ for(var i in NETDATA.localStorage.default) {
+ var a = i.split('.');
+
+ if(a[0] === 'options') {
+ if(a[1] === 'setOptionCallback') continue;
+ if(typeof NETDATA.localStorage.default[i] === 'undefined') continue;
+ if(NETDATA.options.current[i] === NETDATA.localStorage.default[i]) continue;
+
+ NETDATA.setOption(a[1], NETDATA.localStorage.default[i]);
+ }
+ else if(a[0] === 'chart_heights') {
+ if(typeof NETDATA.localStorage.callback[i] === 'function' && typeof NETDATA.localStorage.default[i] !== 'undefined') {
+ NETDATA.localStorage.callback[i](NETDATA.localStorage.default[i]);
+ }
+ }
+ }
+ }
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('welcome to NETDATA');
+
+ NETDATA.onresize = function() {
+ NETDATA.options.last_resized = new Date().getTime();
+ NETDATA.onscroll();
+ };
+
+ NETDATA.onscroll = function() {
+ // console.log('onscroll');
+
+ NETDATA.options.last_page_scroll = new Date().getTime();
+ NETDATA.options.auto_refresher_stop_until = 0;
+
+ if(NETDATA.options.targets === null) return;
+
+ // when the user scrolls he sees that we have
+ // hidden all the not-visible charts
+ // using this little function we try to switch
+ // the charts back to visible quickly
+ var targets = NETDATA.options.targets;
+ var len = targets.length;
+ if(NETDATA.options.abort_ajax_on_scroll === true) {
+ while (len--) {
+ if (targets[len]._updating === true) {
+ if (typeof targets[len].xhr !== 'undefined') {
+ targets[len].xhr.abort();
+ targets[len].running = false;
+ targets[len]._updating = false;
+ }
+ targets[len].isVisible();
+ }
+ }
+ }
+ else {
+ while (len--)
+ targets[len].isVisible();
+ }
+ };
+
+ window.onresize = NETDATA.onresize;
+ window.onscroll = NETDATA.onscroll;
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Error Handling
+
+ NETDATA.errorCodes = {
+ 100: { message: "Cannot load chart library", alert: true },
+ 101: { message: "Cannot load jQuery", alert: true },
+ 402: { message: "Chart library not found", alert: false },
+ 403: { message: "Chart library not enabled/is failed", alert: false },
+ 404: { message: "Chart not found", alert: false },
+ 405: { message: "Cannot download charts index from server", alert: true },
+ 406: { message: "Invalid charts index downloaded from server", alert: true },
+ 407: { message: "Cannot HELLO netdata server", alert: false },
+ 408: { message: "Netdata servers sent invalid response to HELLO", alert: false },
+ 409: { message: "Cannot ACCESS netdata registry", alert: false },
+ 410: { message: "Netdata registry ACCESS failed", alert: false },
+ 411: { message: "Netdata registry server send invalid response to DELETE ", alert: false },
+ 412: { message: "Netdata registry DELETE failed", alert: false },
+ 413: { message: "Netdata registry server send invalid response to SWITCH ", alert: false },
+ 414: { message: "Netdata registry SWITCH failed", alert: false },
+ 415: { message: "Netdata alarms download failed", alert: false },
+ 416: { message: "Netdata alarms log download failed", alert: false }
+ };
+ NETDATA.errorLast = {
+ code: 0,
+ message: "",
+ datetime: 0
+ };
+
+ NETDATA.error = function(code, msg) {
+ NETDATA.errorLast.code = code;
+ NETDATA.errorLast.message = msg;
+ NETDATA.errorLast.datetime = new Date().getTime();
+
+ console.log("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
+
+ var ret = true;
+ if(typeof netdataErrorCallback === 'function') {
+ ret = netdataErrorCallback('system', code, msg);
+ }
+
+ if(ret && NETDATA.errorCodes[code].alert)
+ alert("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg);
+ };
+
+ NETDATA.errorReset = function() {
+ NETDATA.errorLast.code = 0;
+ NETDATA.errorLast.message = "You are doing fine!";
+ NETDATA.errorLast.datetime = 0;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Chart Registry
+
+ // When multiple charts need the same chart, we avoid downloading it
+ // multiple times (and having it in browser memory multiple time)
+ // by using this registry.
+
+ // Every time we download a chart definition, we save it here with .add()
+ // Then we try to get it back with .get(). If that fails, we download it.
+
+ NETDATA.chartRegistry = {
+ charts: {},
+
+ fixid: function(id) {
+ return id.replace(/:/g, "_").replace(/\//g, "_");
+ },
+
+ add: function(host, id, data) {
+ host = this.fixid(host);
+ id = this.fixid(id);
+
+ if(typeof this.charts[host] === 'undefined')
+ this.charts[host] = {};
+
+ //console.log('added ' + host + '/' + id);
+ this.charts[host][id] = data;
+ },
+
+ get: function(host, id) {
+ host = this.fixid(host);
+ id = this.fixid(id);
+
+ if(typeof this.charts[host] === 'undefined')
+ return null;
+
+ if(typeof this.charts[host][id] === 'undefined')
+ return null;
+
+ //console.log('cached ' + host + '/' + id);
+ return this.charts[host][id];
+ },
+
+ downloadAll: function(host, callback) {
+ while(host.slice(-1) === '/')
+ host = host.substring(0, host.length - 1);
+
+ var self = this;
+
+ $.ajax({
+ url: host + '/api/v1/charts',
+ async: true,
+ cache: false,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(data) {
+ if(data !== null) {
+ var h = NETDATA.chartRegistry.fixid(host);
+ self.charts[h] = data.charts;
+ }
+ else NETDATA.error(406, host + '/api/v1/charts');
+
+ if(typeof callback === 'function')
+ callback(data);
+ })
+ .fail(function() {
+ NETDATA.error(405, host + '/api/v1/charts');
+
+ if(typeof callback === 'function')
+ callback(null);
+ });
+ }
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Global Pan and Zoom on charts
+
+ // Using this structure are synchronize all the charts, so that
+ // when you pan or zoom one, all others are automatically refreshed
+ // to the same timespan.
+
+ NETDATA.globalPanAndZoom = {
+ seq: 0, // timestamp ms
+ // every time a chart is panned or zoomed
+ // we set the timestamp here
+ // then we use it as a sequence number
+ // to find if other charts are syncronized
+ // to this timerange
+
+ master: null, // the master chart (state), to which all others
+ // are synchronized
+
+ force_before_ms: null, // the timespan to sync all other charts
+ force_after_ms: null,
+
+ callback: null,
+
+ // set a new master
+ setMaster: function(state, after, before) {
+ if(NETDATA.options.current.sync_pan_and_zoom === false)
+ return;
+
+ if(this.master !== null && this.master !== state)
+ this.master.resetChart(true, true);
+
+ var now = new Date().getTime();
+ this.master = state;
+ this.seq = now;
+ this.force_after_ms = after;
+ this.force_before_ms = before;
+ NETDATA.options.auto_refresher_stop_until = now + NETDATA.options.current.global_pan_sync_time;
+
+ if(typeof this.callback === 'function')
+ this.callback(true, after, before);
+ },
+
+ // clear the master
+ clearMaster: function() {
+ if(this.master !== null) {
+ var st = this.master;
+ this.master = null;
+ st.resetChart();
+ }
+
+ this.master = null;
+ this.seq = 0;
+ this.force_after_ms = null;
+ this.force_before_ms = null;
+ NETDATA.options.auto_refresher_stop_until = 0;
+
+ if(typeof this.callback === 'function')
+ this.callback(false, 0, 0);
+ },
+
+ // is the given state the master of the global
+ // pan and zoom sync?
+ isMaster: function(state) {
+ if(this.master === state) return true;
+ return false;
+ },
+
+ // are we currently have a global pan and zoom sync?
+ isActive: function() {
+ if(this.master !== null && this.force_before_ms !== null && this.force_after_ms !== null && this.seq !== 0) return true;
+ return false;
+ },
+
+ // check if a chart, other than the master
+ // needs to be refreshed, due to the global pan and zoom
+ shouldBeAutoRefreshed: function(state) {
+ if(this.master === null || this.seq === 0)
+ return false;
+
+ //if(state.needsRecreation())
+ // return true;
+
+ if(state.tm.pan_and_zoom_seq === this.seq)
+ return false;
+
+ return true;
+ }
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // dimensions selection
+
+ // FIXME
+ // move color assignment to dimensions, here
+
+ dimensionStatus = function(parent, label, name_div, value_div, color) {
+ this.enabled = false;
+ this.parent = parent;
+ this.label = label;
+ this.name_div = null;
+ this.value_div = null;
+ this.color = NETDATA.themes.current.foreground;
+
+ if(parent.selected_count > parent.unselected_count)
+ this.selected = true;
+ else
+ this.selected = false;
+
+ this.setOptions(name_div, value_div, color);
+ };
+
+ dimensionStatus.prototype.invalidate = function() {
+ this.name_div = null;
+ this.value_div = null;
+ this.enabled = false;
+ };
+
+ dimensionStatus.prototype.setOptions = function(name_div, value_div, color) {
+ this.color = color;
+
+ if(this.name_div != name_div) {
+ this.name_div = name_div;
+ this.name_div.title = this.label;
+ this.name_div.style.color = this.color;
+ if(this.selected === false)
+ this.name_div.className = 'netdata-legend-name not-selected';
+ else
+ this.name_div.className = 'netdata-legend-name selected';
+ }
+
+ if(this.value_div != value_div) {
+ this.value_div = value_div;
+ this.value_div.title = this.label;
+ this.value_div.style.color = this.color;
+ if(this.selected === false)
+ this.value_div.className = 'netdata-legend-value not-selected';
+ else
+ this.value_div.className = 'netdata-legend-value selected';
+ }
+
+ this.enabled = true;
+ this.setHandler();
+ };
+
+ dimensionStatus.prototype.setHandler = function() {
+ if(this.enabled === false) return;
+
+ var ds = this;
+
+ // this.name_div.onmousedown = this.value_div.onmousedown = function(e) {
+ this.name_div.onclick = this.value_div.onclick = function(e) {
+ e.preventDefault();
+ if(ds.isSelected()) {
+ // this is selected
+ if(e.shiftKey === true || e.ctrlKey === true) {
+ // control or shift key is pressed -> unselect this (except is none will remain selected, in which case select all)
+ ds.unselect();
+
+ if(ds.parent.countSelected() === 0)
+ ds.parent.selectAll();
+ }
+ else {
+ // no key is pressed -> select only this (except if it is the only selected already, in which case select all)
+ if(ds.parent.countSelected() === 1) {
+ ds.parent.selectAll();
+ }
+ else {
+ ds.parent.selectNone();
+ ds.select();
+ }
+ }
+ }
+ else {
+ // this is not selected
+ if(e.shiftKey === true || e.ctrlKey === true) {
+ // control or shift key is pressed -> select this too
+ ds.select();
+ }
+ else {
+ // no key is pressed -> select only this
+ ds.parent.selectNone();
+ ds.select();
+ }
+ }
+
+ ds.parent.state.redrawChart();
+ }
+ };
+
+ dimensionStatus.prototype.select = function() {
+ if(this.enabled === false) return;
+
+ this.name_div.className = 'netdata-legend-name selected';
+ this.value_div.className = 'netdata-legend-value selected';
+ this.selected = true;
+ };
+
+ dimensionStatus.prototype.unselect = function() {
+ if(this.enabled === false) return;
+
+ this.name_div.className = 'netdata-legend-name not-selected';
+ this.value_div.className = 'netdata-legend-value hidden';
+ this.selected = false;
+ };
+
+ dimensionStatus.prototype.isSelected = function() {
+ return(this.enabled === true && this.selected === true);
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ dimensionsVisibility = function(state) {
+ this.state = state;
+ this.len = 0;
+ this.dimensions = {};
+ this.selected_count = 0;
+ this.unselected_count = 0;
+ };
+
+ dimensionsVisibility.prototype.dimensionAdd = function(label, name_div, value_div, color) {
+ if(typeof this.dimensions[label] === 'undefined') {
+ this.len++;
+ this.dimensions[label] = new dimensionStatus(this, label, name_div, value_div, color);
+ }
+ else
+ this.dimensions[label].setOptions(name_div, value_div, color);
+
+ return this.dimensions[label];
+ };
+
+ dimensionsVisibility.prototype.dimensionGet = function(label) {
+ return this.dimensions[label];
+ };
+
+ dimensionsVisibility.prototype.invalidateAll = function() {
+ for(var d in this.dimensions)
+ this.dimensions[d].invalidate();
+ };
+
+ dimensionsVisibility.prototype.selectAll = function() {
+ for(var d in this.dimensions)
+ this.dimensions[d].select();
+ };
+
+ dimensionsVisibility.prototype.countSelected = function() {
+ var i = 0;
+ for(var d in this.dimensions)
+ if(this.dimensions[d].isSelected()) i++;
+
+ return i;
+ };
+
+ dimensionsVisibility.prototype.selectNone = function() {
+ for(var d in this.dimensions)
+ this.dimensions[d].unselect();
+ };
+
+ dimensionsVisibility.prototype.selected2BooleanArray = function(array) {
+ var ret = new Array();
+ this.selected_count = 0;
+ this.unselected_count = 0;
+
+ for(var i = 0, len = array.length; i < len ; i++) {
+ var ds = this.dimensions[array[i]];
+ if(typeof ds === 'undefined') {
+ // console.log(array[i] + ' is not found');
+ ret.push(false);
+ continue;
+ }
+
+ if(ds.isSelected()) {
+ ret.push(true);
+ this.selected_count++;
+ }
+ else {
+ ret.push(false);
+ this.unselected_count++;
+ }
+ }
+
+ if(this.selected_count === 0 && this.unselected_count !== 0) {
+ this.selectAll();
+ return this.selected2BooleanArray(array);
+ }
+
+ return ret;
+ };
+
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // global selection sync
+
+ NETDATA.globalSelectionSync = {
+ state: null,
+ dont_sync_before: 0,
+ last_t: 0,
+ slaves: [],
+
+ stop: function() {
+ if(this.state !== null)
+ this.state.globalSelectionSyncStop();
+ },
+
+ delay: function() {
+ if(this.state !== null) {
+ this.state.globalSelectionSyncDelay();
+ }
+ }
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Our state object, where all per-chart values are stored
+
+ chartState = function(element) {
+ var self = $(element);
+ this.element = element;
+
+ // IMPORTANT:
+ // all private functions should use 'that', instead of 'this'
+ var that = this;
+
+ /* error() - private
+ * show an error instead of the chart
+ */
+ var error = function(msg) {
+ var ret = true;
+
+ if(typeof netdataErrorCallback === 'function') {
+ ret = netdataErrorCallback('chart', that.id, msg);
+ }
+
+ if(ret) {
+ that.element.innerHTML = that.id + ': ' + msg;
+ that.enabled = false;
+ that.current = that.pan;
+ }
+ };
+
+ // GUID - a unique identifier for the chart
+ this.uuid = NETDATA.guid();
+
+ // string - the name of chart
+ this.id = self.data('netdata');
+
+ // string - the key for localStorage settings
+ this.settings_id = self.data('id') || null;
+
+ // the user given dimensions of the element
+ this.width = self.data('width') || NETDATA.chartDefaults.width;
+ this.height = self.data('height') || NETDATA.chartDefaults.height;
+
+ if(this.settings_id !== null) {
+ this.height = NETDATA.localStorageGet('chart_heights.' + this.settings_id, this.height, function(height) {
+ // this is the callback that will be called
+ // if and when the user resets all localStorage variables
+ // to their defaults
+
+ resizeChartToHeight(height);
+ });
+ }
+
+ // string - the netdata server URL, without any path
+ this.host = self.data('host') || NETDATA.chartDefaults.host;
+
+ // make sure the host does not end with /
+ // all netdata API requests use absolute paths
+ while(this.host.slice(-1) === '/')
+ this.host = this.host.substring(0, this.host.length - 1);
+
+ // string - the grouping method requested by the user
+ this.method = self.data('method') || NETDATA.chartDefaults.method;
+
+ // the time-range requested by the user
+ this.after = self.data('after') || NETDATA.chartDefaults.after;
+ this.before = self.data('before') || NETDATA.chartDefaults.before;
+
+ // the pixels per point requested by the user
+ this.pixels_per_point = self.data('pixels-per-point') || 1;
+ this.points = self.data('points') || null;
+
+ // the dimensions requested by the user
+ this.dimensions = self.data('dimensions') || null;
+
+ // the chart library requested by the user
+ this.library_name = self.data('chart-library') || NETDATA.chartDefaults.library;
+
+ // object - the chart library used
+ this.library = null;
+
+ // color management
+ this.colors = null;
+ this.colors_assigned = {};
+ this.colors_available = null;
+
+ // the element already created by the user
+ this.element_message = null;
+
+ // the element with the chart
+ this.element_chart = null;
+
+ // the element with the legend of the chart (if created by us)
+ this.element_legend = null;
+ this.element_legend_childs = {
+ hidden: null,
+ title_date: null,
+ title_time: null,
+ title_units: null,
+ nano: null,
+ nano_options: null,
+ series: null
+ };
+
+ this.chart_url = null; // string - the url to download chart info
+ this.chart = null; // object - the chart as downloaded from the server
+
+ this.title = self.data('title') || null; // the title of the chart
+ this.units = self.data('units') || null; // the units of the chart dimensions
+ this.append_options = self.data('append-options') || null; // the units of the chart dimensions
+
+ this.running = false; // boolean - true when the chart is being refreshed now
+ this.validated = false; // boolean - has the chart been validated?
+ this.enabled = true; // boolean - is the chart enabled for refresh?
+ this.paused = false; // boolean - is the chart paused for any reason?
+ this.selected = false; // boolean - is the chart shown a selection?
+ this.debug = false; // boolean - console.log() debug info about this chart
+
+ this.netdata_first = 0; // milliseconds - the first timestamp in netdata
+ this.netdata_last = 0; // milliseconds - the last timestamp in netdata
+ this.requested_after = null; // milliseconds - the timestamp of the request after param
+ this.requested_before = null; // milliseconds - the timestamp of the request before param
+ this.requested_padding = null;
+ this.view_after = 0;
+ this.view_before = 0;
+
+ this.auto = {
+ name: 'auto',
+ autorefresh: true,
+ force_update_at: 0, // the timestamp to force the update at
+ force_before_ms: null,
+ force_after_ms: null
+ };
+ this.pan = {
+ name: 'pan',
+ autorefresh: false,
+ force_update_at: 0, // the timestamp to force the update at
+ force_before_ms: null,
+ force_after_ms: null
+ };
+ this.zoom = {
+ name: 'zoom',
+ autorefresh: false,
+ force_update_at: 0, // the timestamp to force the update at
+ force_before_ms: null,
+ force_after_ms: null
+ };
+
+ // this is a pointer to one of the sub-classes below
+ // auto, pan, zoom
+ this.current = this.auto;
+
+ // check the requested library is available
+ // we don't initialize it here - it will be initialized when
+ // this chart will be first used
+ if(typeof NETDATA.chartLibraries[that.library_name] === 'undefined') {
+ NETDATA.error(402, that.library_name);
+ error('chart library "' + that.library_name + '" is not found');
+ return;
+ }
+ else if(NETDATA.chartLibraries[that.library_name].enabled === false) {
+ NETDATA.error(403, that.library_name);
+ error('chart library "' + that.library_name + '" is not enabled');
+ return;
+ }
+ else
+ that.library = NETDATA.chartLibraries[that.library_name];
+
+ // milliseconds - the time the last refresh took
+ this.refresh_dt_ms = 0;
+
+ // if we need to report the rendering speed
+ // find the element that needs to be updated
+ var refresh_dt_element_name = self.data('dt-element-name') || null; // string - the element to print refresh_dt_ms
+
+ if(refresh_dt_element_name !== null)
+ this.refresh_dt_element = document.getElementById(refresh_dt_element_name) || null;
+ else
+ this.refresh_dt_element = null;
+
+ this.dimensions_visibility = new dimensionsVisibility(this);
+
+ this._updating = false;
+
+ // ============================================================================================================
+ // PRIVATE FUNCTIONS
+
+ var createDOM = function() {
+ if(that.enabled === false) return;
+
+ if(that.element_message !== null) that.element_message.innerHTML = '';
+ if(that.element_legend !== null) that.element_legend.innerHTML = '';
+ if(that.element_chart !== null) that.element_chart.innerHTML = '';
+
+ that.element.innerHTML = '';
+
+ that.element_message = document.createElement('div');
+ that.element_message.className = ' netdata-message hidden';
+ that.element.appendChild(that.element_message);
+
+ that.element_chart = document.createElement('div');
+ that.element_chart.id = that.library_name + '-' + that.uuid + '-chart';
+ that.element.appendChild(that.element_chart);
+
+ if(that.hasLegend() === true) {
+ that.element.className = "netdata-container-with-legend";
+ that.element_chart.className = 'netdata-chart-with-legend-right netdata-' + that.library_name + '-chart-with-legend-right';
+
+ that.element_legend = document.createElement('div');
+ that.element_legend.className = 'netdata-chart-legend netdata-' + that.library_name + '-legend';
+ that.element.appendChild(that.element_legend);
+ }
+ else {
+ that.element.className = "netdata-container";
+ that.element_chart.className = ' netdata-chart netdata-' + that.library_name + '-chart';
+
+ that.element_legend = null;
+ }
+ that.element_legend_childs.series = null;
+
+ if(typeof(that.width) === 'string')
+ $(that.element).css('width', that.width);
+ else if(typeof(that.width) === 'number')
+ $(that.element).css('width', that.width + 'px');
+
+ if(typeof(that.library.aspect_ratio) === 'undefined') {
+ if(typeof(that.height) === 'string')
+ $(that.element).css('height', that.height);
+ else if(typeof(that.height) === 'number')
+ $(that.element).css('height', that.height + 'px');
+ }
+ else {
+ var w = that.element.offsetWidth;
+ if(w === null || w === 0) {
+ // the div is hidden
+ // this will resize the chart when next viewed
+ that.tm.last_resized = 0;
+ }
+ else
+ $(that.element).css('height', (that.element.offsetWidth * that.library.aspect_ratio / 100).toString() + 'px');
+ }
+
+ if(NETDATA.chartDefaults.min_width !== null)
+ $(that.element).css('min-width', NETDATA.chartDefaults.min_width);
+
+ that.tm.last_dom_created = new Date().getTime();
+
+ showLoading();
+ };
+
+ /* init() private
+ * initialize state variables
+ * destroy all (possibly) created state elements
+ * create the basic DOM for a chart
+ */
+ var init = function() {
+ if(that.enabled === false) return;
+
+ that.paused = false;
+ that.selected = false;
+
+ that.chart_created = false; // boolean - is the library.create() been called?
+ that.updates_counter = 0; // numeric - the number of refreshes made so far
+ that.updates_since_last_unhide = 0; // numeric - the number of refreshes made since the last time the chart was unhidden
+ that.updates_since_last_creation = 0; // numeric - the number of refreshes made since the last time the chart was created
+
+ that.tm = {
+ last_initialized: 0, // milliseconds - the timestamp it was last initialized
+ last_dom_created: 0, // milliseconds - the timestamp its DOM was last created
+ last_mode_switch: 0, // milliseconds - the timestamp it switched modes
+
+ last_info_downloaded: 0, // milliseconds - the timestamp we downloaded the chart
+ last_updated: 0, // the timestamp the chart last updated with data
+ pan_and_zoom_seq: 0, // the sequence number of the global synchronization
+ // between chart.
+ // Used with NETDATA.globalPanAndZoom.seq
+ last_visible_check: 0, // the time we last checked if it is visible
+ last_resized: 0, // the time the chart was resized
+ last_hidden: 0, // the time the chart was hidden
+ last_unhidden: 0, // the time the chart was unhidden
+ last_autorefreshed: 0 // the time the chart was last refreshed
+ };
+
+ that.data = null; // the last data as downloaded from the netdata server
+ that.data_url = 'invalid://'; // string - the last url used to update the chart
+ that.data_points = 0; // number - the number of points returned from netdata
+ that.data_after = 0; // milliseconds - the first timestamp of the data
+ that.data_before = 0; // milliseconds - the last timestamp of the data
+ that.data_update_every = 0; // milliseconds - the frequency to update the data
+
+ that.tm.last_initialized = new Date().getTime();
+ createDOM();
+
+ that.setMode('auto');
+ };
+
+ var maxMessageFontSize = function() {
+ // normally we want a font size, as tall as the element
+ var h = that.element_message.clientHeight;
+
+ // but give it some air, 20% let's say, or 5 pixels min
+ var lost = Math.max(h * 0.2, 5);
+ h -= lost;
+
+ // center the text, vertically
+ var paddingTop = (lost - 5) / 2;
+
+ // but check the width too
+ // it should fit 10 characters in it
+ var w = that.element_message.clientWidth / 10;
+ if(h > w) {
+ paddingTop += (h - w) / 2;
+ h = w;
+ }
+
+ // and don't make it too huge
+ // 5% of the screen size is good
+ if(h > screen.height / 20) {
+ paddingTop += (h - (screen.height / 20)) / 2;
+ h = screen.height / 20;
+ }
+
+ // set it
+ that.element_message.style.fontSize = h.toString() + 'px';
+ that.element_message.style.paddingTop = paddingTop.toString() + 'px';
+ };
+
+ var showMessage = function(msg) {
+ that.element_message.className = 'netdata-message';
+ that.element_message.innerHTML = msg;
+ that.element_message.style.fontSize = 'x-small';
+ that.element_message.style.paddingTop = '0px';
+ that.___messageHidden___ = undefined;
+ };
+
+ var showMessageIcon = function(icon) {
+ that.element_message.innerHTML = icon;
+ that.element_message.className = 'netdata-message icon';
+ maxMessageFontSize();
+ that.___messageHidden___ = undefined;
+ };
+
+ var hideMessage = function() {
+ if(typeof that.___messageHidden___ === 'undefined') {
+ that.___messageHidden___ = true;
+ that.element_message.className = 'netdata-message hidden';
+ }
+ };
+
+ var showRendering = function() {
+ var icon;
+ if(that.chart !== null) {
+ if(that.chart.chart_type === 'line')
+ icon = '<i class="fa fa-line-chart"></i>';
+ else
+ icon = '<i class="fa fa-area-chart"></i>';
+ }
+ else
+ icon = '<i class="fa fa-area-chart"></i>';
+
+ showMessageIcon(icon + ' netdata');
+ };
+
+ var showLoading = function() {
+ if(that.chart_created === false) {
+ showMessageIcon('<i class="fa fa-refresh"></i> netdata');
+ return true;
+ }
+ return false;
+ };
+
+ var isHidden = function() {
+ if(typeof that.___chartIsHidden___ !== 'undefined')
+ return true;
+
+ return false;
+ };
+
+ // hide the chart, when it is not visible - called from isVisible()
+ var hideChart = function() {
+ // hide it, if it is not already hidden
+ if(isHidden() === true) return;
+
+ if(that.chart_created === true) {
+ if(NETDATA.options.current.destroy_on_hide === true) {
+ // we should destroy it
+ init();
+ }
+ else {
+ showRendering();
+ that.element_chart.style.display = 'none';
+ if(that.element_legend !== null) that.element_legend.style.display = 'none';
+ that.tm.last_hidden = new Date().getTime();
+
+ // de-allocate data
+ // This works, but I not sure there are no corner cases somewhere
+ // so it is commented - if the user has memory issues he can
+ // set Destroy on Hide for all charts
+ // that.data = null;
+ }
+ }
+
+ that.___chartIsHidden___ = true;
+ };
+
+ // unhide the chart, when it is visible - called from isVisible()
+ var unhideChart = function() {
+ if(isHidden() === false) return;
+
+ that.___chartIsHidden___ = undefined;
+ that.updates_since_last_unhide = 0;
+
+ if(that.chart_created === false) {
+ // we need to re-initialize it, to show our background
+ // logo in bootstrap tabs, until the chart loads
+ init();
+ }
+ else {
+ that.tm.last_unhidden = new Date().getTime();
+ that.element_chart.style.display = '';
+ if(that.element_legend !== null) that.element_legend.style.display = '';
+ resizeChart();
+ hideMessage();
+ }
+ };
+
+ var canBeRendered = function() {
+ if(isHidden() === true || that.isVisible(true) === false)
+ return false;
+
+ return true;
+ };
+
+ // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
+ var callChartLibraryUpdateSafely = function(data) {
+ var status;
+
+ if(canBeRendered() === false)
+ return false;
+
+ if(NETDATA.options.debug.chart_errors === true)
+ status = that.library.update(that, data);
+ else {
+ try {
+ status = that.library.update(that, data);
+ }
+ catch(err) {
+ status = false;
+ }
+ }
+
+ if(status === false) {
+ error('chart failed to be updated as ' + that.library_name);
+ return false;
+ }
+
+ return true;
+ };
+
+ // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers
+ var callChartLibraryCreateSafely = function(data) {
+ var status;
+
+ if(canBeRendered() === false)
+ return false;
+
+ if(NETDATA.options.debug.chart_errors === true)
+ status = that.library.create(that, data);
+ else {
+ try {
+ status = that.library.create(that, data);
+ }
+ catch(err) {
+ status = false;
+ }
+ }
+
+ if(status === false) {
+ error('chart failed to be created as ' + that.library_name);
+ return false;
+ }
+
+ that.chart_created = true;
+ that.updates_since_last_creation = 0;
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Chart Resize
+
+ // resizeChart() - private
+ // to be called just before the chart library to make sure that
+ // a properly sized dom is available
+ var resizeChart = function() {
+ if(that.isVisible() === true && that.tm.last_resized < NETDATA.options.last_resized) {
+ if(that.chart_created === false) return;
+
+ if(that.needsRecreation()) {
+ init();
+ }
+ else if(typeof that.library.resize === 'function') {
+ that.library.resize(that);
+
+ if(that.element_legend_childs.nano !== null && that.element_legend_childs.nano_options !== null)
+ $(that.element_legend_childs.nano).nanoScroller();
+
+ maxMessageFontSize();
+ }
+
+ that.tm.last_resized = new Date().getTime();
+ }
+ };
+
+ // this is the actual chart resize algorithm
+ // it will:
+ // - resize the entire container
+ // - update the internal states
+ // - resize the chart as the div changes height
+ // - update the scrollbar of the legend
+ var resizeChartToHeight = function(h) {
+ // console.log(h);
+ that.element.style.height = h;
+
+ if(that.settings_id !== null)
+ NETDATA.localStorageSet('chart_heights.' + that.settings_id, h);
+
+ var now = new Date().getTime();
+ NETDATA.options.last_page_scroll = now;
+ NETDATA.options.auto_refresher_stop_until = now + NETDATA.options.current.stop_updates_while_resizing;
+
+ // force a resize
+ that.tm.last_resized = 0;
+ resizeChart();
+ };
+
+ this.resizeHandler = function(e) {
+ e.preventDefault();
+
+ if(typeof this.event_resize === 'undefined'
+ || this.event_resize.chart_original_w === 'undefined'
+ || this.event_resize.chart_original_h === 'undefined')
+ this.event_resize = {
+ chart_original_w: this.element.clientWidth,
+ chart_original_h: this.element.clientHeight,
+ last: 0
+ };
+
+ if(e.type === 'touchstart') {
+ this.event_resize.mouse_start_x = e.touches.item(0).pageX;
+ this.event_resize.mouse_start_y = e.touches.item(0).pageY;
+ }
+ else {
+ this.event_resize.mouse_start_x = e.clientX;
+ this.event_resize.mouse_start_y = e.clientY;
+ }
+
+ this.event_resize.chart_start_w = this.element.clientWidth;
+ this.event_resize.chart_start_h = this.element.clientHeight;
+ this.event_resize.chart_last_w = this.element.clientWidth;
+ this.event_resize.chart_last_h = this.element.clientHeight;
+
+ var now = new Date().getTime();
+ if(now - this.event_resize.last <= NETDATA.options.current.double_click_speed) {
+ // double click / double tap event
+
+ // the optimal height of the chart
+ // showing the entire legend
+ var optimal = this.event_resize.chart_last_h
+ + this.element_legend_childs.content.scrollHeight
+ - this.element_legend_childs.content.clientHeight;
+
+ // if we are not optimal, be optimal
+ if(this.event_resize.chart_last_h != optimal)
+ resizeChartToHeight(optimal.toString() + 'px');
+
+ // else if we do not have the original height
+ // reset to the original height
+ else if(this.event_resize.chart_last_h != this.event_resize.chart_original_h)
+ resizeChartToHeight(this.event_resize.chart_original_h.toString() + 'px');
+ }
+ else {
+ this.event_resize.last = now;
+
+ // process movement event
+ document.onmousemove =
+ document.ontouchmove =
+ this.element_legend_childs.resize_handler.onmousemove =
+ this.element_legend_childs.resize_handler.ontouchmove =
+ function(e) {
+ var y = null;
+
+ switch(e.type) {
+ case 'mousemove': y = e.clientY; break;
+ case 'touchmove': y = e.touches.item(e.touches - 1).pageY; break;
+ }
+
+ if(y !== null) {
+ var newH = that.event_resize.chart_start_h + y - that.event_resize.mouse_start_y;
+
+ if(newH >= 70 && newH !== that.event_resize.chart_last_h) {
+ resizeChartToHeight(newH.toString() + 'px');
+ that.event_resize.chart_last_h = newH;
+ }
+ }
+ };
+
+ // process end event
+ document.onmouseup =
+ document.ontouchend =
+ this.element_legend_childs.resize_handler.onmouseup =
+ this.element_legend_childs.resize_handler.ontouchend =
+ function(e) {
+ // remove all the hooks
+ document.onmouseup =
+ document.onmousemove =
+ document.ontouchmove =
+ document.ontouchend =
+ that.element_legend_childs.resize_handler.onmousemove =
+ that.element_legend_childs.resize_handler.ontouchmove =
+ that.element_legend_childs.resize_handler.onmouseout =
+ that.element_legend_childs.resize_handler.onmouseup =
+ that.element_legend_childs.resize_handler.ontouchend =
+ null;
+
+ // allow auto-refreshes
+ NETDATA.options.auto_refresher_stop_until = 0;
+ };
+ }
+ };
+
+
+ var noDataToShow = function() {
+ showMessageIcon('<i class="fa fa-warning"></i> empty');
+ that.legendUpdateDOM();
+ that.tm.last_autorefreshed = new Date().getTime();
+ // that.data_update_every = 30 * 1000;
+ //that.element_chart.style.display = 'none';
+ //if(that.element_legend !== null) that.element_legend.style.display = 'none';
+ //that.___chartIsHidden___ = true;
+ };
+
+ // ============================================================================================================
+ // PUBLIC FUNCTIONS
+
+ this.error = function(msg) {
+ error(msg);
+ };
+
+ this.setMode = function(m) {
+ if(this.current !== null && this.current.name === m) return;
+
+ if(m === 'auto')
+ this.current = this.auto;
+ else if(m === 'pan')
+ this.current = this.pan;
+ else if(m === 'zoom')
+ this.current = this.zoom;
+ else
+ this.current = this.auto;
+
+ this.current.force_update_at = 0;
+ this.current.force_before_ms = null;
+ this.current.force_after_ms = null;
+
+ this.tm.last_mode_switch = new Date().getTime();
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // global selection sync
+
+ // prevent to global selection sync for some time
+ this.globalSelectionSyncDelay = function(ms) {
+ if(NETDATA.options.current.sync_selection === false)
+ return;
+
+ if(typeof ms === 'number')
+ NETDATA.globalSelectionSync.dont_sync_before = new Date().getTime() + ms;
+ else
+ NETDATA.globalSelectionSync.dont_sync_before = new Date().getTime() + NETDATA.options.current.sync_selection_delay;
+ };
+
+ // can we globally apply selection sync?
+ this.globalSelectionSyncAbility = function() {
+ if(NETDATA.options.current.sync_selection === false)
+ return false;
+
+ if(NETDATA.globalSelectionSync.dont_sync_before > new Date().getTime())
+ return false;
+
+ return true;
+ };
+
+ this.globalSelectionSyncIsMaster = function() {
+ if(NETDATA.globalSelectionSync.state === this)
+ return true;
+ else
+ return false;
+ };
+
+ // this chart is the master of the global selection sync
+ this.globalSelectionSyncBeMaster = function() {
+ // am I the master?
+ if(this.globalSelectionSyncIsMaster()) {
+ if(this.debug === true)
+ this.log('sync: I am the master already.');
+
+ return;
+ }
+
+ if(NETDATA.globalSelectionSync.state) {
+ if(this.debug === true)
+ this.log('sync: I am not the sync master. Resetting global sync.');
+
+ this.globalSelectionSyncStop();
+ }
+
+ // become the master
+ if(this.debug === true)
+ this.log('sync: becoming sync master.');
+
+ this.selected = true;
+ NETDATA.globalSelectionSync.state = this;
+
+ // find the all slaves
+ var targets = NETDATA.options.targets;
+ var len = targets.length;
+ while(len--) {
+ st = targets[len];
+
+ if(st === this) {
+ if(this.debug === true)
+ st.log('sync: not adding me to sync');
+ }
+ else if(st.globalSelectionSyncIsEligible()) {
+ if(this.debug === true)
+ st.log('sync: adding to sync as slave');
+
+ st.globalSelectionSyncBeSlave();
+ }
+ }
+
+ // this.globalSelectionSyncDelay(100);
+ };
+
+ // can the chart participate to the global selection sync as a slave?
+ this.globalSelectionSyncIsEligible = function() {
+ if(this.enabled === true
+ && this.library !== null
+ && typeof this.library.setSelection === 'function'
+ && this.isVisible() === true
+ && this.chart_created === true)
+ return true;
+
+ return false;
+ };
+
+ // this chart becomes a slave of the global selection sync
+ this.globalSelectionSyncBeSlave = function() {
+ if(NETDATA.globalSelectionSync.state !== this)
+ NETDATA.globalSelectionSync.slaves.push(this);
+ };
+
+ // sync all the visible charts to the given time
+ // this is to be called from the chart libraries
+ this.globalSelectionSync = function(t) {
+ if(this.globalSelectionSyncAbility() === false) {
+ if(this.debug === true)
+ this.log('sync: cannot sync (yet?).');
+
+ return;
+ }
+
+ if(this.globalSelectionSyncIsMaster() === false) {
+ if(this.debug === true)
+ this.log('sync: trying to be sync master.');
+
+ this.globalSelectionSyncBeMaster();
+
+ if(this.globalSelectionSyncAbility() === false) {
+ if(this.debug === true)
+ this.log('sync: cannot sync (yet?).');
+
+ return;
+ }
+ }
+
+ NETDATA.globalSelectionSync.last_t = t;
+ $.each(NETDATA.globalSelectionSync.slaves, function(i, st) {
+ st.setSelection(t);
+ });
+ };
+
+ // stop syncing all charts to the given time
+ this.globalSelectionSyncStop = function() {
+ if(NETDATA.globalSelectionSync.slaves.length) {
+ if(this.debug === true)
+ this.log('sync: cleaning up...');
+
+ $.each(NETDATA.globalSelectionSync.slaves, function(i, st) {
+ if(st === that) {
+ if(that.debug === true)
+ st.log('sync: not adding me to sync stop');
+ }
+ else {
+ if(that.debug === true)
+ st.log('sync: removed slave from sync');
+
+ st.clearSelection();
+ }
+ });
+
+ NETDATA.globalSelectionSync.last_t = 0;
+ NETDATA.globalSelectionSync.slaves = [];
+ NETDATA.globalSelectionSync.state = null;
+ }
+
+ this.clearSelection();
+ };
+
+ this.setSelection = function(t) {
+ if(typeof this.library.setSelection === 'function') {
+ if(this.library.setSelection(this, t) === true)
+ this.selected = true;
+ else
+ this.selected = false;
+ }
+ else this.selected = true;
+
+ if(this.selected === true && this.debug === true)
+ this.log('selection set to ' + t.toString());
+
+ return this.selected;
+ };
+
+ this.clearSelection = function() {
+ if(this.selected === true) {
+ if(typeof this.library.clearSelection === 'function') {
+ if(this.library.clearSelection(this) === true)
+ this.selected = false;
+ else
+ this.selected = true;
+ }
+ else this.selected = false;
+
+ if(this.selected === false && this.debug === true)
+ this.log('selection cleared');
+
+ this.legendReset();
+ }
+
+ return this.selected;
+ };
+
+ // find if a timestamp (ms) is shown in the current chart
+ this.timeIsVisible = function(t) {
+ if(t >= this.data_after && t <= this.data_before)
+ return true;
+ return false;
+ };
+
+ this.calculateRowForTime = function(t) {
+ if(this.timeIsVisible(t) === false) return -1;
+ return Math.floor((t - this.data_after) / this.data_update_every);
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ // console logging
+ this.log = function(msg) {
+ console.log(this.id + ' (' + this.library_name + ' ' + this.uuid + '): ' + msg);
+ };
+
+ this.pauseChart = function() {
+ if(this.paused === false) {
+ if(this.debug === true)
+ this.log('pauseChart()');
+
+ this.paused = true;
+ }
+ };
+
+ this.unpauseChart = function() {
+ if(this.paused === true) {
+ if(this.debug === true)
+ this.log('unpauseChart()');
+
+ this.paused = false;
+ }
+ };
+
+ this.resetChart = function(dont_clear_master, dont_update) {
+ if(this.debug === true)
+ this.log('resetChart(' + dont_clear_master + ', ' + dont_update + ') called');
+
+ if(typeof dont_clear_master === 'undefined')
+ dont_clear_master = false;
+
+ if(typeof dont_update === 'undefined')
+ dont_update = false;
+
+ if(dont_clear_master !== true && NETDATA.globalPanAndZoom.isMaster(this) === true) {
+ if(this.debug === true)
+ this.log('resetChart() diverting to clearMaster().');
+ // this will call us back with master === true
+ NETDATA.globalPanAndZoom.clearMaster();
+ return;
+ }
+
+ this.clearSelection();
+
+ this.tm.pan_and_zoom_seq = 0;
+
+ this.setMode('auto');
+ this.current.force_update_at = 0;
+ this.current.force_before_ms = null;
+ this.current.force_after_ms = null;
+ this.tm.last_autorefreshed = 0;
+ this.paused = false;
+ this.selected = false;
+ this.enabled = true;
+ // this.debug = false;
+
+ // do not update the chart here
+ // or the chart will flip-flop when it is the master
+ // of a selection sync and another chart becomes
+ // the new master
+
+ if(dont_update !== true && this.isVisible() === true) {
+ this.updateChart();
+ }
+ };
+
+ this.updateChartPanOrZoom = function(after, before) {
+ var logme = 'updateChartPanOrZoom(' + after + ', ' + before + '): ';
+ var ret = true;
+
+ if(this.debug === true)
+ this.log(logme);
+
+ if(before < after) {
+ if(this.debug === true)
+ this.log(logme + 'flipped parameters, rejecting it.');
+
+ return false;
+ }
+
+ if(typeof this.fixed_min_duration === 'undefined')
+ this.fixed_min_duration = Math.round((this.chartWidth() / 30) * this.chart.update_every * 1000);
+
+ var min_duration = this.fixed_min_duration;
+ var current_duration = Math.round(this.view_before - this.view_after);
+
+ // round the numbers
+ after = Math.round(after);
+ before = Math.round(before);
+
+ // align them to update_every
+ // stretching them further away
+ after -= after % this.data_update_every;
+ before += this.data_update_every - (before % this.data_update_every);
+
+ // the final wanted duration
+ var wanted_duration = before - after;
+
+ // to allow panning, accept just a point below our minimum
+ if((current_duration - this.data_update_every) < min_duration)
+ min_duration = current_duration - this.data_update_every;
+
+ // we do it, but we adjust to minimum size and return false
+ // when the wanted size is below the current and the minimum
+ // and we zoom
+ if(wanted_duration < current_duration && wanted_duration < min_duration) {
+ if(this.debug === true)
+ this.log(logme + 'too small: min_duration: ' + (min_duration / 1000).toString() + ', wanted: ' + (wanted_duration / 1000).toString());
+
+ min_duration = this.fixed_min_duration;
+
+ var dt = (min_duration - wanted_duration) / 2;
+ before += dt;
+ after -= dt;
+ wanted_duration = before - after;
+ ret = false;
+ }
+
+ var tolerance = this.data_update_every * 2;
+ var movement = Math.abs(before - this.view_before);
+
+ if(Math.abs(current_duration - wanted_duration) <= tolerance && movement <= tolerance && ret === true) {
+ if(this.debug === true)
+ this.log(logme + 'REJECTING UPDATE: current/min duration: ' + (current_duration / 1000).toString() + '/' + (this.fixed_min_duration / 1000).toString() + ', wanted duration: ' + (wanted_duration / 1000).toString() + ', duration diff: ' + (Math.round(Math.abs(current_duration - wanted_duration) / 1000)).toString() + ', movement: ' + (movement / 1000).toString() + ', tolerance: ' + (tolerance / 1000).toString() + ', returning: ' + false);
+ return false;
+ }
+
+ if(this.current.name === 'auto') {
+ this.log(logme + 'caller called me with mode: ' + this.current.name);
+ this.setMode('pan');
+ }
+
+ if(this.debug === true)
+ this.log(logme + 'ACCEPTING UPDATE: current/min duration: ' + (current_duration / 1000).toString() + '/' + (this.fixed_min_duration / 1000).toString() + ', wanted duration: ' + (wanted_duration / 1000).toString() + ', duration diff: ' + (Math.round(Math.abs(current_duration - wanted_duration) / 1000)).toString() + ', movement: ' + (movement / 1000).toString() + ', tolerance: ' + (tolerance / 1000).toString() + ', returning: ' + ret);
+
+ this.current.force_update_at = new Date().getTime() + NETDATA.options.current.pan_and_zoom_delay;
+ this.current.force_after_ms = after;
+ this.current.force_before_ms = before;
+ NETDATA.globalPanAndZoom.setMaster(this, after, before);
+ return ret;
+ };
+
+ this.legendFormatValue = function(value) {
+ if(value === null || value === 'undefined') return '-';
+ if(typeof value !== 'number') return value;
+
+ var abs = Math.abs(value);
+ if(abs >= 1000) return (Math.round(value)).toLocaleString();
+ if(abs >= 100 ) return (Math.round(value * 10) / 10).toLocaleString();
+ if(abs >= 1 ) return (Math.round(value * 100) / 100).toLocaleString();
+ if(abs >= 0.1 ) return (Math.round(value * 1000) / 1000).toLocaleString();
+ return (Math.round(value * 10000) / 10000).toLocaleString();
+ };
+
+ this.legendSetLabelValue = function(label, value) {
+ var series = this.element_legend_childs.series[label];
+ if(typeof series === 'undefined') return;
+ if(series.value === null && series.user === null) return;
+
+ // if the value has not changed, skip DOM update
+ //if(series.last === value) return;
+
+ var s, r;
+ if(typeof value === 'number') {
+ var v = Math.abs(value);
+ s = r = this.legendFormatValue(value);
+
+ if(typeof series.last === 'number') {
+ if(v > series.last) s += '<i class="fa fa-angle-up" style="width: 8px; text-align: center; overflow: hidden; vertical-align: middle;"></i>';
+ else if(v < series.last) s += '<i class="fa fa-angle-down" style="width: 8px; text-align: center; overflow: hidden; vertical-align: middle;"></i>';
+ else s += '<i class="fa fa-angle-left" style="width: 8px; text-align: center; overflow: hidden; vertical-align: middle;"></i>';
+ }
+ else s += '<i class="fa fa-angle-right" style="width: 8px; text-align: center; overflow: hidden; vertical-align: middle;"></i>';
+ series.last = v;
+ }
+ else {
+ s = r = value;
+ series.last = value;
+ }
+
+ if(series.value !== null) series.value.innerHTML = s;
+ if(series.user !== null) series.user.innerHTML = r;
+ };
+
+ this.legendSetDate = function(ms) {
+ if(typeof ms !== 'number') {
+ this.legendShowUndefined();
+ return;
+ }
+
+ var d = new Date(ms);
+
+ if(this.element_legend_childs.title_date)
+ this.element_legend_childs.title_date.innerHTML = d.toLocaleDateString();
+
+ if(this.element_legend_childs.title_time)
+ this.element_legend_childs.title_time.innerHTML = d.toLocaleTimeString();
+
+ if(this.element_legend_childs.title_units)
+ this.element_legend_childs.title_units.innerHTML = this.units;
+ };
+
+ this.legendShowUndefined = function() {
+ if(this.element_legend_childs.title_date)
+ this.element_legend_childs.title_date.innerHTML = '&nbsp;';
+
+ if(this.element_legend_childs.title_time)
+ this.element_legend_childs.title_time.innerHTML = this.chart.name;
+
+ if(this.element_legend_childs.title_units)
+ this.element_legend_childs.title_units.innerHTML = '&nbsp;';
+
+ if(this.data && this.element_legend_childs.series !== null) {
+ var labels = this.data.dimension_names;
+ var i = labels.length;
+ while(i--) {
+ var label = labels[i];
+
+ if(typeof label === 'undefined') continue;
+ if(typeof this.element_legend_childs.series[label] === 'undefined') continue;
+ this.legendSetLabelValue(label, null);
+ }
+ }
+ };
+
+ this.legendShowLatestValues = function() {
+ if(this.chart === null) return;
+ if(this.selected) return;
+
+ if(this.data === null || this.element_legend_childs.series === null) {
+ this.legendShowUndefined();
+ return;
+ }
+
+ var show_undefined = true;
+ if(Math.abs(this.netdata_last - this.view_before) <= this.data_update_every)
+ show_undefined = false;
+
+ if(show_undefined) {
+ this.legendShowUndefined();
+ return;
+ }
+
+ this.legendSetDate(this.view_before);
+
+ var labels = this.data.dimension_names;
+ var i = labels.length;
+ while(i--) {
+ var label = labels[i];
+
+ if(typeof label === 'undefined') continue;
+ if(typeof this.element_legend_childs.series[label] === 'undefined') continue;
+
+ if(show_undefined)
+ this.legendSetLabelValue(label, null);
+ else
+ this.legendSetLabelValue(label, this.data.view_latest_values[i]);
+ }
+ };
+
+ this.legendReset = function() {
+ this.legendShowLatestValues();
+ };
+
+ // this should be called just ONCE per dimension per chart
+ this._chartDimensionColor = function(label) {
+ if(this.colors === null) this.chartColors();
+
+ if(typeof this.colors_assigned[label] === 'undefined') {
+ if(this.colors_available.length === 0) {
+ for(var i = 0, len = NETDATA.themes.current.colors.length; i < len ; i++)
+ this.colors_available.push(NETDATA.themes.current.colors[i]);
+ }
+
+ this.colors_assigned[label] = this.colors_available.shift();
+
+ if(this.debug === true)
+ this.log('label "' + label + '" got color "' + this.colors_assigned[label]);
+ }
+ else {
+ if(this.debug === true)
+ this.log('label "' + label + '" already has color "' + this.colors_assigned[label] + '"');
+ }
+
+ this.colors.push(this.colors_assigned[label]);
+ return this.colors_assigned[label];
+ };
+
+ this.chartColors = function() {
+ if(this.colors !== null) return this.colors;
+
+ this.colors = new Array();
+ this.colors_available = new Array();
+ var i, len;
+
+ var c = $(this.element).data('colors');
+ // this.log('read colors: ' + c);
+ if(typeof c !== 'undefined' && c !== null && c.length > 0) {
+ if(typeof c !== 'string') {
+ this.log('invalid color given: ' + c + ' (give a space separated list of colors)');
+ }
+ else {
+ c = c.split(' ');
+ var added = 0;
+
+ while(added < 20) {
+ for(i = 0, len = c.length; i < len ; i++) {
+ added++;
+ this.colors_available.push(c[i]);
+ // this.log('adding color: ' + c[i]);
+ }
+ }
+ }
+ }
+
+ // push all the standard colors too
+ for(i = 0, len = NETDATA.themes.current.colors.length; i < len ; i++)
+ this.colors_available.push(NETDATA.themes.current.colors[i]);
+
+ return this.colors;
+ };
+
+ this.legendUpdateDOM = function() {
+ var needed = false;
+
+ // check that the legend DOM is up to date for the downloaded dimensions
+ if(typeof this.element_legend_childs.series !== 'object' || this.element_legend_childs.series === null) {
+ // this.log('the legend does not have any series - requesting legend update');
+ needed = true;
+ }
+ else if(this.data === null) {
+ // this.log('the chart does not have any data - requesting legend update');
+ needed = true;
+ }
+ else if(typeof this.element_legend_childs.series.labels_key === 'undefined') {
+ needed = true;
+ }
+ else {
+ var labels = this.data.dimension_names.toString();
+ if(labels !== this.element_legend_childs.series.labels_key) {
+ needed = true;
+
+ if(this.debug === true)
+ this.log('NEW LABELS: "' + labels + '" NOT EQUAL OLD LABELS: "' + this.element_legend_childs.series.labels_key + '"');
+ }
+ }
+
+ if(needed === false) {
+ // make sure colors available
+ this.chartColors();
+
+ // do we have to update the current values?
+ // we do this, only when the visible chart is current
+ if(Math.abs(this.netdata_last - this.view_before) <= this.data_update_every) {
+ if(this.debug === true)
+ this.log('chart is in latest position... updating values on legend...');
+
+ //var labels = this.data.dimension_names;
+ //var i = labels.length;
+ //while(i--)
+ // this.legendSetLabelValue(labels[i], this.data.latest_values[i]);
+ }
+ return;
+ }
+ if(this.colors === null) {
+ // this is the first time we update the chart
+ // let's assign colors to all dimensions
+ if(this.library.track_colors() === true)
+ for(var dim in this.chart.dimensions)
+ this._chartDimensionColor(this.chart.dimensions[dim].name);
+ }
+ // we will re-generate the colors for the chart
+ // based on the selected dimensions
+ this.colors = null;
+
+ if(this.debug === true)
+ this.log('updating Legend DOM');
+
+ // mark all dimensions as invalid
+ this.dimensions_visibility.invalidateAll();
+
+ var genLabel = function(state, parent, dim, name, count) {
+ var color = state._chartDimensionColor(name);
+
+ var user_element = null;
+ var user_id = self.data('show-value-of-' + dim + '-at') || null;
+ if(user_id !== null) {
+ user_element = document.getElementById(user_id) || null;
+ if(user_element === null)
+ state.log('Cannot find element with id: ' + user_id);
+ }
+
+ state.element_legend_childs.series[name] = {
+ name: document.createElement('span'),
+ value: document.createElement('span'),
+ user: user_element,
+ last: null
+ };
+
+ var label = state.element_legend_childs.series[name];
+
+ // create the dimension visibility tracking for this label
+ state.dimensions_visibility.dimensionAdd(name, label.name, label.value, color);
+
+ var rgb = NETDATA.colorHex2Rgb(color);
+ label.name.innerHTML = '<table class="netdata-legend-name-table-'
+ + state.chart.chart_type
+ + '" style="background-color: '
+ + 'rgba(' + rgb.r + ',' + rgb.g + ',' + rgb.b + ',' + NETDATA.options.current['color_fill_opacity_' + state.chart.chart_type] + ')'
+ + '"><tr class="netdata-legend-name-tr"><td class="netdata-legend-name-td"></td></tr></table>'
+
+ var text = document.createTextNode(' ' + name);
+ label.name.appendChild(text);
+
+ if(count > 0)
+ parent.appendChild(document.createElement('br'));
+
+ parent.appendChild(label.name);
+ parent.appendChild(label.value);
+ };
+
+ var content = document.createElement('div');
+
+ if(this.hasLegend()) {
+ this.element_legend_childs = {
+ content: content,
+ resize_handler: document.createElement('div'),
+ toolbox: document.createElement('div'),
+ toolbox_left: document.createElement('div'),
+ toolbox_right: document.createElement('div'),
+ toolbox_reset: document.createElement('div'),
+ toolbox_zoomin: document.createElement('div'),
+ toolbox_zoomout: document.createElement('div'),
+ toolbox_volume: document.createElement('div'),
+ title_date: document.createElement('span'),
+ title_time: document.createElement('span'),
+ title_units: document.createElement('span'),
+ nano: document.createElement('div'),
+ nano_options: {
+ paneClass: 'netdata-legend-series-pane',
+ sliderClass: 'netdata-legend-series-slider',
+ contentClass: 'netdata-legend-series-content',
+ enabledClass: '__enabled',
+ flashedClass: '__flashed',
+ activeClass: '__active',
+ tabIndex: -1,
+ alwaysVisible: true,
+ sliderMinHeight: 10
+ },
+ series: {}
+ };
+
+ this.element_legend.innerHTML = '';
+
+ if(this.library.toolboxPanAndZoom !== null) {
+
+ function get_pan_and_zoom_step(event) {
+ if (event.ctrlKey)
+ return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_control;
+
+ else if (event.shiftKey)
+ return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_shift;
+
+ else if (event.altKey)
+ return NETDATA.options.current.pan_and_zoom_factor * NETDATA.options.current.pan_and_zoom_factor_multiplier_alt;
+
+ else
+ return NETDATA.options.current.pan_and_zoom_factor;
+ }
+
+ this.element_legend_childs.toolbox.className += ' netdata-legend-toolbox';
+ this.element.appendChild(this.element_legend_childs.toolbox);
+
+ this.element_legend_childs.toolbox_left.className += ' netdata-legend-toolbox-button';
+ this.element_legend_childs.toolbox_left.innerHTML = '<i class="fa fa-backward"></i>';
+ this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_left);
+ this.element_legend_childs.toolbox_left.onclick = function(e) {
+ e.preventDefault();
+
+ var step = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
+ var before = that.view_before - step;
+ var after = that.view_after - step;
+ if(after >= that.netdata_first)
+ that.library.toolboxPanAndZoom(that, after, before);
+ };
+ if(NETDATA.options.current.show_help === true)
+ $(this.element_legend_childs.toolbox_left).popover({
+ container: "body",
+ animation: false,
+ html: true,
+ trigger: 'hover',
+ placement: 'bottom',
+ delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
+ title: 'Pan Left',
+ content: 'Pan the chart to the left. You can also <b>drag it</b> with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
+ });
+
+
+ this.element_legend_childs.toolbox_reset.className += ' netdata-legend-toolbox-button';
+ this.element_legend_childs.toolbox_reset.innerHTML = '<i class="fa fa-play"></i>';
+ this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_reset);
+ this.element_legend_childs.toolbox_reset.onclick = function(e) {
+ e.preventDefault();
+ NETDATA.resetAllCharts(that);
+ };
+ if(NETDATA.options.current.show_help === true)
+ $(this.element_legend_childs.toolbox_reset).popover({
+ container: "body",
+ animation: false,
+ html: true,
+ trigger: 'hover',
+ placement: 'bottom',
+ delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
+ title: 'Chart Reset',
+ content: 'Reset all the charts to their default auto-refreshing state. You can also <b>double click</b> the chart contents with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
+ });
+
+ this.element_legend_childs.toolbox_right.className += ' netdata-legend-toolbox-button';
+ this.element_legend_childs.toolbox_right.innerHTML = '<i class="fa fa-forward"></i>';
+ this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_right);
+ this.element_legend_childs.toolbox_right.onclick = function(e) {
+ e.preventDefault();
+ var step = (that.view_before - that.view_after) * get_pan_and_zoom_step(e);
+ var before = that.view_before + step;
+ var after = that.view_after + step;
+ if(before <= that.netdata_last)
+ that.library.toolboxPanAndZoom(that, after, before);
+ };
+ if(NETDATA.options.current.show_help === true)
+ $(this.element_legend_childs.toolbox_right).popover({
+ container: "body",
+ animation: false,
+ html: true,
+ trigger: 'hover',
+ placement: 'bottom',
+ delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
+ title: 'Pan Right',
+ content: 'Pan the chart to the right. You can also <b>drag it</b> with your mouse or your finger (on touch devices).<br/><small>Help, can be disabled from the settings.</small>'
+ });
+
+
+ this.element_legend_childs.toolbox_zoomin.className += ' netdata-legend-toolbox-button';
+ this.element_legend_childs.toolbox_zoomin.innerHTML = '<i class="fa fa-plus"></i>';
+ this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomin);
+ this.element_legend_childs.toolbox_zoomin.onclick = function(e) {
+ e.preventDefault();
+ var dt = ((that.view_before - that.view_after) * (get_pan_and_zoom_step(e) * 0.8) / 2);
+ var before = that.view_before - dt;
+ var after = that.view_after + dt;
+ that.library.toolboxPanAndZoom(that, after, before);
+ };
+ if(NETDATA.options.current.show_help === true)
+ $(this.element_legend_childs.toolbox_zoomin).popover({
+ container: "body",
+ animation: false,
+ html: true,
+ trigger: 'hover',
+ placement: 'bottom',
+ delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
+ title: 'Chart Zoom In',
+ content: 'Zoom in the chart. You can also press SHIFT and select an area of the chart to zoom in. On Chrome and Opera, you can press the SHIFT or the ALT keys and then use the mouse wheel to zoom in or out.<br/><small>Help, can be disabled from the settings.</small>'
+ });
+
+ this.element_legend_childs.toolbox_zoomout.className += ' netdata-legend-toolbox-button';
+ this.element_legend_childs.toolbox_zoomout.innerHTML = '<i class="fa fa-minus"></i>';
+ this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomout);
+ this.element_legend_childs.toolbox_zoomout.onclick = function(e) {
+ e.preventDefault();
+ var dt = (((that.view_before - that.view_after) / (1.0 - (get_pan_and_zoom_step(e) * 0.8)) - (that.view_before - that.view_after)) / 2);
+ var before = that.view_before + dt;
+ var after = that.view_after - dt;
+
+ that.library.toolboxPanAndZoom(that, after, before);
+ };
+ if(NETDATA.options.current.show_help === true)
+ $(this.element_legend_childs.toolbox_zoomout).popover({
+ container: "body",
+ animation: false,
+ html: true,
+ trigger: 'hover',
+ placement: 'bottom',
+ delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
+ title: 'Chart Zoom Out',
+ content: 'Zoom out the chart. On Chrome and Opera, you can also press the SHIFT or the ALT keys and then use the mouse wheel to zoom in or out.<br/><small>Help, can be disabled from the settings.</small>'
+ });
+
+ //this.element_legend_childs.toolbox_volume.className += ' netdata-legend-toolbox-button';
+ //this.element_legend_childs.toolbox_volume.innerHTML = '<i class="fa fa-sort-amount-desc"></i>';
+ //this.element_legend_childs.toolbox_volume.title = 'Visible Volume';
+ //this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_volume);
+ //this.element_legend_childs.toolbox_volume.onclick = function(e) {
+ //e.preventDefault();
+ //alert('clicked toolbox_volume on ' + that.id);
+ //}
+ }
+ else {
+ this.element_legend_childs.toolbox = null;
+ this.element_legend_childs.toolbox_left = null;
+ this.element_legend_childs.toolbox_reset = null;
+ this.element_legend_childs.toolbox_right = null;
+ this.element_legend_childs.toolbox_zoomin = null;
+ this.element_legend_childs.toolbox_zoomout = null;
+ this.element_legend_childs.toolbox_volume = null;
+ }
+
+ this.element_legend_childs.resize_handler.className += " netdata-legend-resize-handler";
+ this.element_legend_childs.resize_handler.innerHTML = '<i class="fa fa-chevron-up"></i><i class="fa fa-chevron-down"></i>';
+ this.element.appendChild(this.element_legend_childs.resize_handler);
+ if(NETDATA.options.current.show_help === true)
+ $(this.element_legend_childs.resize_handler).popover({
+ container: "body",
+ animation: false,
+ html: true,
+ trigger: 'hover',
+ placement: 'bottom',
+ delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
+ title: 'Chart Resize',
+ content: 'Drag this point with your mouse or your finger (on touch devices), to resize the chart vertically. You can also <b>double click it</b> or <b>double tap it</b> to reset between 2 states: the default and the one that fits all the values.<br/><small>Help, can be disabled from the settings.</small>'
+ });
+
+ // mousedown event
+ this.element_legend_childs.resize_handler.onmousedown =
+ function(e) {
+ that.resizeHandler(e);
+ };
+
+ // touchstart event
+ this.element_legend_childs.resize_handler.addEventListener('touchstart', function(e) {
+ that.resizeHandler(e);
+ }, false);
+
+ this.element_legend_childs.title_date.className += " netdata-legend-title-date";
+ this.element_legend.appendChild(this.element_legend_childs.title_date);
+
+ this.element_legend.appendChild(document.createElement('br'));
+
+ this.element_legend_childs.title_time.className += " netdata-legend-title-time";
+ this.element_legend.appendChild(this.element_legend_childs.title_time);
+
+ this.element_legend.appendChild(document.createElement('br'));
+
+ this.element_legend_childs.title_units.className += " netdata-legend-title-units";
+ this.element_legend.appendChild(this.element_legend_childs.title_units);
+
+ this.element_legend.appendChild(document.createElement('br'));
+
+ this.element_legend_childs.nano.className = 'netdata-legend-series';
+ this.element_legend.appendChild(this.element_legend_childs.nano);
+
+ content.className = 'netdata-legend-series-content';
+ this.element_legend_childs.nano.appendChild(content);
+
+ if(NETDATA.options.current.show_help === true)
+ $(content).popover({
+ container: "body",
+ animation: false,
+ html: true,
+ trigger: 'hover',
+ placement: 'bottom',
+ title: 'Chart Legend',
+ delay: { show: NETDATA.options.current.show_help_delay_show_ms, hide: NETDATA.options.current.show_help_delay_hide_ms },
+ content: 'You can click or tap on the values or the labels to select dimentions. By pressing SHIFT or CONTROL, you can enable or disable multiple dimensions.<br/><small>Help, can be disabled from the settings.</small>'
+ });
+ }
+ else {
+ this.element_legend_childs = {
+ content: content,
+ resize_handler: null,
+ toolbox: null,
+ toolbox_left: null,
+ toolbox_right: null,
+ toolbox_reset: null,
+ toolbox_zoomin: null,
+ toolbox_zoomout: null,
+ toolbox_volume: null,
+ title_date: null,
+ title_time: null,
+ title_units: null,
+ nano: null,
+ nano_options: null,
+ series: {}
+ };
+ }
+
+ if(this.data) {
+ this.element_legend_childs.series.labels_key = this.data.dimension_names.toString();
+ if(this.debug === true)
+ this.log('labels from data: "' + this.element_legend_childs.series.labels_key + '"');
+
+ for(var i = 0, len = this.data.dimension_names.length; i < len ;i++) {
+ genLabel(this, content, this.data.dimension_ids[i], this.data.dimension_names[i], i);
+ }
+ }
+ else {
+ var tmp = new Array();
+ for(var dim in this.chart.dimensions) {
+ tmp.push(this.chart.dimensions[dim].name);
+ genLabel(this, content, dim, this.chart.dimensions[dim].name, i);
+ }
+ this.element_legend_childs.series.labels_key = tmp.toString();
+ if(this.debug === true)
+ this.log('labels from chart: "' + this.element_legend_childs.series.labels_key + '"');
+ }
+
+ // create a hidden div to be used for hidding
+ // the original legend of the chart library
+ var el = document.createElement('div');
+ if(this.element_legend !== null)
+ this.element_legend.appendChild(el);
+ el.style.display = 'none';
+
+ this.element_legend_childs.hidden = document.createElement('div');
+ el.appendChild(this.element_legend_childs.hidden);
+
+ if(this.element_legend_childs.nano !== null && this.element_legend_childs.nano_options !== null)
+ $(this.element_legend_childs.nano).nanoScroller(this.element_legend_childs.nano_options);
+
+ this.legendShowLatestValues();
+ };
+
+ this.hasLegend = function() {
+ if(typeof this.___hasLegendCache___ !== 'undefined')
+ return this.___hasLegendCache___;
+
+ var leg = false;
+ if(this.library && this.library.legend(this) === 'right-side') {
+ var legend = $(this.element).data('legend') || 'yes';
+ if(legend === 'yes') leg = true;
+ }
+
+ this.___hasLegendCache___ = leg;
+ return leg;
+ };
+
+ this.legendWidth = function() {
+ return (this.hasLegend())?140:0;
+ };
+
+ this.legendHeight = function() {
+ return $(this.element).height();
+ };
+
+ this.chartWidth = function() {
+ return $(this.element).width() - this.legendWidth();
+ };
+
+ this.chartHeight = function() {
+ return $(this.element).height();
+ };
+
+ this.chartPixelsPerPoint = function() {
+ // force an options provided detail
+ var px = this.pixels_per_point;
+
+ if(this.library && px < this.library.pixels_per_point(this))
+ px = this.library.pixels_per_point(this);
+
+ if(px < NETDATA.options.current.pixels_per_point)
+ px = NETDATA.options.current.pixels_per_point;
+
+ return px;
+ };
+
+ this.needsRecreation = function() {
+ return (
+ this.chart_created === true
+ && this.library
+ && this.library.autoresize() === false
+ && this.tm.last_resized < NETDATA.options.last_resized
+ );
+ };
+
+ this.chartURL = function() {
+ var after, before, points_multiplier = 1;
+ if(NETDATA.globalPanAndZoom.isActive() && NETDATA.globalPanAndZoom.isMaster(this) === false) {
+ this.tm.pan_and_zoom_seq = NETDATA.globalPanAndZoom.seq;
+
+ after = Math.round(NETDATA.globalPanAndZoom.force_after_ms / 1000);
+ before = Math.round(NETDATA.globalPanAndZoom.force_before_ms / 1000);
+ this.view_after = after * 1000;
+ this.view_before = before * 1000;
+
+ this.requested_padding = null;
+ points_multiplier = 1;
+ }
+ else if(this.current.force_before_ms !== null && this.current.force_after_ms !== null) {
+ this.tm.pan_and_zoom_seq = 0;
+
+ before = Math.round(this.current.force_before_ms / 1000);
+ after = Math.round(this.current.force_after_ms / 1000);
+ this.view_after = after * 1000;
+ this.view_before = before * 1000;
+
+ if(NETDATA.options.current.pan_and_zoom_data_padding === true) {
+ this.requested_padding = Math.round((before - after) / 2);
+ after -= this.requested_padding;
+ before += this.requested_padding;
+ this.requested_padding *= 1000;
+ points_multiplier = 2;
+ }
+
+ this.current.force_before_ms = null;
+ this.current.force_after_ms = null;
+ }
+ else {
+ this.tm.pan_and_zoom_seq = 0;
+
+ before = this.before;
+ after = this.after;
+ this.view_after = after * 1000;
+ this.view_before = before * 1000;
+
+ this.requested_padding = null;
+ points_multiplier = 1;
+ }
+
+ this.requested_after = after * 1000;
+ this.requested_before = before * 1000;
+
+ this.data_points = this.points || Math.round(this.chartWidth() / this.chartPixelsPerPoint());
+
+ // build the data URL
+ this.data_url = this.host + this.chart.data_url;
+ this.data_url += "&format=" + this.library.format();
+ this.data_url += "&points=" + (this.data_points * points_multiplier).toString();
+ this.data_url += "&group=" + this.method;
+ this.data_url += "&options=" + this.library.options(this);
+ this.data_url += '|jsonwrap';
+
+ if(NETDATA.options.current.eliminate_zero_dimensions === true)
+ this.data_url += '|nonzero';
+
+ if(this.append_options !== null)
+ this.data_url += '|' + this.append_options.toString();
+
+ if(after)
+ this.data_url += "&after=" + after.toString();
+
+ if(before)
+ this.data_url += "&before=" + before.toString();
+
+ if(this.dimensions)
+ this.data_url += "&dimensions=" + this.dimensions;
+
+ if(NETDATA.options.debug.chart_data_url === true || this.debug === true)
+ this.log('chartURL(): ' + this.data_url + ' WxH:' + this.chartWidth() + 'x' + this.chartHeight() + ' points: ' + this.data_points + ' library: ' + this.library_name);
+ };
+
+ this.redrawChart = function() {
+ if(this.data !== null)
+ this.updateChartWithData(this.data);
+ };
+
+ this.updateChartWithData = function(data) {
+ if(this.debug === true)
+ this.log('updateChartWithData() called.');
+
+ // this may force the chart to be re-created
+ resizeChart();
+
+ this.data = data;
+ this.updates_counter++;
+ this.updates_since_last_unhide++;
+ this.updates_since_last_creation++;
+
+ var started = new Date().getTime();
+
+ // if the result is JSON, find the latest update-every
+ this.data_update_every = data.view_update_every * 1000;
+ this.data_after = data.after * 1000;
+ this.data_before = data.before * 1000;
+ this.netdata_first = data.first_entry * 1000;
+ this.netdata_last = data.last_entry * 1000;
+ this.data_points = data.points;
+ data.state = this;
+
+ if(NETDATA.options.current.pan_and_zoom_data_padding === true && this.requested_padding !== null) {
+ if(this.view_after < this.data_after) {
+ // console.log('adusting view_after from ' + this.view_after + ' to ' + this.data_after);
+ this.view_after = this.data_after;
+ }
+
+ if(this.view_before > this.data_before) {
+ // console.log('adusting view_before from ' + this.view_before + ' to ' + this.data_before);
+ this.view_before = this.data_before;
+ }
+ }
+ else {
+ this.view_after = this.data_after;
+ this.view_before = this.data_before;
+ }
+
+ if(this.debug === true) {
+ this.log('UPDATE No ' + this.updates_counter + ' COMPLETED');
+
+ if(this.current.force_after_ms)
+ this.log('STATUS: forced : ' + (this.current.force_after_ms / 1000).toString() + ' - ' + (this.current.force_before_ms / 1000).toString());
+ else
+ this.log('STATUS: forced : unset');
+
+ this.log('STATUS: requested : ' + (this.requested_after / 1000).toString() + ' - ' + (this.requested_before / 1000).toString());
+ this.log('STATUS: downloaded: ' + (this.data_after / 1000).toString() + ' - ' + (this.data_before / 1000).toString());
+ this.log('STATUS: rendered : ' + (this.view_after / 1000).toString() + ' - ' + (this.view_before / 1000).toString());
+ this.log('STATUS: points : ' + (this.data_points).toString());
+ }
+
+ if(this.data_points === 0) {
+ noDataToShow();
+ return;
+ }
+
+ if(this.updates_since_last_creation >= this.library.max_updates_to_recreate()) {
+ if(this.debug === true)
+ this.log('max updates of ' + this.updates_since_last_creation.toString() + ' reached. Forcing re-generation.');
+
+ this.chart_created = false;
+ }
+
+ // check and update the legend
+ this.legendUpdateDOM();
+
+ if(this.chart_created === true
+ && typeof this.library.update === 'function') {
+
+ if(this.debug === true)
+ this.log('updating chart...');
+
+ if(callChartLibraryUpdateSafely(data) === false)
+ return;
+ }
+ else {
+ if(this.debug === true)
+ this.log('creating chart...');
+
+ if(callChartLibraryCreateSafely(data) === false)
+ return;
+ }
+ hideMessage();
+ this.legendShowLatestValues();
+ if(this.selected === true)
+ NETDATA.globalSelectionSync.stop();
+
+ // update the performance counters
+ var now = new Date().getTime();
+ this.tm.last_updated = now;
+
+ // don't update last_autorefreshed if this chart is
+ // forced to be updated with global PanAndZoom
+ if(NETDATA.globalPanAndZoom.isActive())
+ this.tm.last_autorefreshed = 0;
+ else {
+ if(NETDATA.options.current.parallel_refresher === true && NETDATA.options.current.concurrent_refreshes === true)
+ this.tm.last_autorefreshed = now - (now % this.data_update_every);
+ else
+ this.tm.last_autorefreshed = now;
+ }
+
+ this.refresh_dt_ms = now - started;
+ NETDATA.options.auto_refresher_fast_weight += this.refresh_dt_ms;
+
+ if(this.refresh_dt_element !== null)
+ this.refresh_dt_element.innerHTML = this.refresh_dt_ms.toString();
+ };
+
+ this.updateChart = function(callback) {
+ if(this.debug === true)
+ this.log('updateChart() called.');
+
+ if(this._updating === true) {
+ if(this.debug === true)
+ this.log('I am already updating...');
+
+ if(typeof callback === 'function') callback();
+ return false;
+ }
+
+ // due to late initialization of charts and libraries
+ // we need to check this too
+ if(this.enabled === false) {
+ if(this.debug === true)
+ this.log('I am not enabled');
+
+ if(typeof callback === 'function') callback();
+ return false;
+ }
+
+ if(canBeRendered() === false) {
+ if(typeof callback === 'function') callback();
+ return false;
+ }
+
+ if(this.chart === null) {
+ this.getChart(function() { that.updateChart(callback); });
+ return false;
+ }
+
+ if(this.library.initialized === false) {
+ if(this.library.enabled === true) {
+ this.library.initialize(function() { that.updateChart(callback); });
+ return false;
+ }
+ else {
+ error('chart library "' + this.library_name + '" is not available.');
+ if(typeof callback === 'function') callback();
+ return false;
+ }
+ }
+
+ this.clearSelection();
+ this.chartURL();
+
+ if(this.debug === true)
+ this.log('updating from ' + this.data_url);
+
+ NETDATA.statistics.refreshes_total++;
+ NETDATA.statistics.refreshes_active++;
+
+ if(NETDATA.statistics.refreshes_active > NETDATA.statistics.refreshes_active_max)
+ NETDATA.statistics.refreshes_active_max = NETDATA.statistics.refreshes_active;
+
+ this._updating = true;
+
+ this.xhr = $.ajax( {
+ url: this.data_url,
+ cache: false,
+ async: true,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(data) {
+ that.xhr = undefined;
+
+ if(that.debug === true)
+ that.log('data received. updating chart.');
+
+ that.updateChartWithData(data);
+ })
+ .fail(function(msg) {
+ that.xhr = undefined;
+
+ if(msg.statusText !== 'abort')
+ error('data download failed for url: ' + that.data_url);
+ })
+ .always(function() {
+ that.xhr = undefined;
+
+ NETDATA.statistics.refreshes_active--;
+ that._updating = false;
+ if(typeof callback === 'function') callback();
+ });
+
+ return true;
+ };
+
+ this.isVisible = function(nocache) {
+ if(typeof nocache === 'undefined')
+ nocache = false;
+
+ // this.log('last_visible_check: ' + this.tm.last_visible_check + ', last_page_scroll: ' + NETDATA.options.last_page_scroll);
+
+ // caching - we do not evaluate the charts visibility
+ // if the page has not been scrolled since the last check
+ if(nocache === false && this.tm.last_visible_check > NETDATA.options.last_page_scroll)
+ return this.___isVisible___;
+
+ this.tm.last_visible_check = new Date().getTime();
+
+ var wh = window.innerHeight;
+ var x = this.element.getBoundingClientRect();
+ var ret = 0;
+ var tolerance = 0;
+
+ if(x.width === 0 || x.height === 0) {
+ hideChart();
+ this.___isVisible___ = false;
+ return this.___isVisible___;
+ }
+
+ if(x.top < 0 && -x.top > x.height) {
+ // the chart is entirely above
+ ret = -x.top - x.height;
+ }
+ else if(x.top > wh) {
+ // the chart is entirely below
+ ret = x.top - wh;
+ }
+
+ if(ret > tolerance) {
+ // the chart is too far
+
+ hideChart();
+ this.___isVisible___ = false;
+ return this.___isVisible___;
+ }
+ else {
+ // the chart is inside or very close
+
+ unhideChart();
+ this.___isVisible___ = true;
+ return this.___isVisible___;
+ }
+ };
+
+ this.isAutoRefreshable = function() {
+ return (this.current.autorefresh);
+ };
+
+ this.canBeAutoRefreshed = function() {
+ var now = new Date().getTime();
+
+ if(this.running === true) {
+ if(this.debug === true)
+ this.log('I am already running');
+
+ return false;
+ }
+
+ if(this.enabled === false) {
+ if(this.debug === true)
+ this.log('I am not enabled');
+
+ return false;
+ }
+
+ if(this.library === null || this.library.enabled === false) {
+ error('charting library "' + this.library_name + '" is not available');
+ if(this.debug === true)
+ this.log('My chart library ' + this.library_name + ' is not available');
+
+ return false;
+ }
+
+ if(this.isVisible() === false) {
+ if(NETDATA.options.debug.visibility === true || this.debug === true)
+ this.log('I am not visible');
+
+ return false;
+ }
+
+ if(this.current.force_update_at !== 0 && this.current.force_update_at < now) {
+ if(this.debug === true)
+ this.log('timed force update detected - allowing this update');
+
+ this.current.force_update_at = 0;
+ return true;
+ }
+
+ if(this.isAutoRefreshable() === true) {
+ // allow the first update, even if the page is not visible
+ if(this.updates_counter && this.updates_since_last_unhide && NETDATA.options.page_is_visible === false) {
+ if(NETDATA.options.debug.focus === true || this.debug === true)
+ this.log('canBeAutoRefreshed(): page does not have focus');
+
+ return false;
+ }
+
+ if(this.needsRecreation() === true) {
+ if(this.debug === true)
+ this.log('canBeAutoRefreshed(): needs re-creation.');
+
+ return true;
+ }
+
+ // options valid only for autoRefresh()
+ if(NETDATA.options.auto_refresher_stop_until === 0 || NETDATA.options.auto_refresher_stop_until < now) {
+ if(NETDATA.globalPanAndZoom.isActive()) {
+ if(NETDATA.globalPanAndZoom.shouldBeAutoRefreshed(this)) {
+ if(this.debug === true)
+ this.log('canBeAutoRefreshed(): global panning: I need an update.');
+
+ return true;
+ }
+ else {
+ if(this.debug === true)
+ this.log('canBeAutoRefreshed(): global panning: I am already up to date.');
+
+ return false;
+ }
+ }
+
+ if(this.selected === true) {
+ if(this.debug === true)
+ this.log('canBeAutoRefreshed(): I have a selection in place.');
+
+ return false;
+ }
+
+ if(this.paused === true) {
+ if(this.debug === true)
+ this.log('canBeAutoRefreshed(): I am paused.');
+
+ return false;
+ }
+
+ if(now - this.tm.last_autorefreshed >= this.data_update_every) {
+ if(this.debug === true)
+ this.log('canBeAutoRefreshed(): It is time to update me.');
+
+ return true;
+ }
+ }
+ }
+
+ return false;
+ };
+
+ this.autoRefresh = function(callback) {
+ if(this.canBeAutoRefreshed() === true && this.running === false) {
+ var state = this;
+
+ state.running = true;
+ state.updateChart(function() {
+ state.running = false;
+
+ if(typeof callback !== 'undefined')
+ callback();
+ });
+ }
+ else {
+ if(typeof callback !== 'undefined')
+ callback();
+ }
+ };
+
+ this._defaultsFromDownloadedChart = function(chart) {
+ this.chart = chart;
+ this.chart_url = chart.url;
+ this.data_update_every = chart.update_every * 1000;
+ this.data_points = Math.round(this.chartWidth() / this.chartPixelsPerPoint());
+ this.tm.last_info_downloaded = new Date().getTime();
+
+ if(this.title === null)
+ this.title = chart.title;
+
+ if(this.units === null)
+ this.units = chart.units;
+ };
+
+ // fetch the chart description from the netdata server
+ this.getChart = function(callback) {
+ this.chart = NETDATA.chartRegistry.get(this.host, this.id);
+ if(this.chart) {
+ this._defaultsFromDownloadedChart(this.chart);
+ if(typeof callback === 'function') callback();
+ }
+ else {
+ this.chart_url = "/api/v1/chart?chart=" + this.id;
+
+ if(this.debug === true)
+ this.log('downloading ' + this.chart_url);
+
+ $.ajax( {
+ url: this.host + this.chart_url,
+ cache: false,
+ async: true,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(chart) {
+ chart.url = that.chart_url;
+ that._defaultsFromDownloadedChart(chart);
+ NETDATA.chartRegistry.add(that.host, that.id, chart);
+ })
+ .fail(function() {
+ NETDATA.error(404, that.chart_url);
+ error('chart not found on url "' + that.chart_url + '"');
+ })
+ .always(function() {
+ if(typeof callback === 'function') callback();
+ });
+ }
+ };
+
+ // ============================================================================================================
+ // INITIALIZATION
+
+ init();
+ };
+
+ NETDATA.resetAllCharts = function(state) {
+ // first clear the global selection sync
+ // to make sure no chart is in selected state
+ state.globalSelectionSyncStop();
+
+ // there are 2 possibilities here
+ // a. state is the global Pan and Zoom master
+ // b. state is not the global Pan and Zoom master
+ var master = true;
+ if(NETDATA.globalPanAndZoom.isMaster(state) === false)
+ master = false;
+
+ // clear the global Pan and Zoom
+ // this will also refresh the master
+ // and unblock any charts currently mirroring the master
+ NETDATA.globalPanAndZoom.clearMaster();
+
+ // if we were not the master, reset our status too
+ // this is required because most probably the mouse
+ // is over this chart, blocking it from auto-refreshing
+ if(master === false && (state.paused === true || state.selected === true))
+ state.resetChart();
+ };
+
+ // get or create a chart state, given a DOM element
+ NETDATA.chartState = function(element) {
+ var state = $(element).data('netdata-state-object') || null;
+ if(state === null) {
+ state = new chartState(element);
+ $(element).data('netdata-state-object', state);
+ }
+ return state;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Library functions
+
+ // Load a script without jquery
+ // This is used to load jquery - after it is loaded, we use jquery
+ NETDATA._loadjQuery = function(callback) {
+ if(typeof jQuery === 'undefined') {
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('loading ' + NETDATA.jQuery);
+
+ var script = document.createElement('script');
+ script.type = 'text/javascript';
+ script.async = true;
+ script.src = NETDATA.jQuery;
+
+ // script.onabort = onError;
+ script.onerror = function(err, t) { NETDATA.error(101, NETDATA.jQuery); };
+ if(typeof callback === "function")
+ script.onload = callback;
+
+ var s = document.getElementsByTagName('script')[0];
+ s.parentNode.insertBefore(script, s);
+ }
+ else if(typeof callback === "function")
+ callback();
+ };
+
+ NETDATA._loadCSS = function(filename) {
+ // don't use jQuery here
+ // styles are loaded before jQuery
+ // to eliminate showing an unstyled page to the user
+
+ var fileref = document.createElement("link");
+ fileref.setAttribute("rel", "stylesheet");
+ fileref.setAttribute("type", "text/css");
+ fileref.setAttribute("href", filename);
+
+ if (typeof fileref !== 'undefined')
+ document.getElementsByTagName("head")[0].appendChild(fileref);
+ };
+
+ NETDATA.colorHex2Rgb = function(hex) {
+ // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF")
+ var shorthandRegex = /^#?([a-f\d])([a-f\d])([a-f\d])$/i;
+ hex = hex.replace(shorthandRegex, function(m, r, g, b) {
+ return r + r + g + g + b + b;
+ });
+
+ var result = /^#?([a-f\d]{2})([a-f\d]{2})([a-f\d]{2})$/i.exec(hex);
+ return result ? {
+ r: parseInt(result[1], 16),
+ g: parseInt(result[2], 16),
+ b: parseInt(result[3], 16)
+ } : null;
+ };
+
+ NETDATA.colorLuminance = function(hex, lum) {
+ // validate hex string
+ hex = String(hex).replace(/[^0-9a-f]/gi, '');
+ if (hex.length < 6)
+ hex = hex[0]+hex[0]+hex[1]+hex[1]+hex[2]+hex[2];
+
+ lum = lum || 0;
+
+ // convert to decimal and change luminosity
+ var rgb = "#", c, i;
+ for (i = 0; i < 3; i++) {
+ c = parseInt(hex.substr(i*2,2), 16);
+ c = Math.round(Math.min(Math.max(0, c + (c * lum)), 255)).toString(16);
+ rgb += ("00"+c).substr(c.length);
+ }
+
+ return rgb;
+ };
+
+ NETDATA.guid = function() {
+ function s4() {
+ return Math.floor((1 + Math.random()) * 0x10000)
+ .toString(16)
+ .substring(1);
+ }
+
+ return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4();
+ };
+
+ NETDATA.zeropad = function(x) {
+ if(x > -10 && x < 10) return '0' + x.toString();
+ else return x.toString();
+ };
+
+ // user function to signal us the DOM has been
+ // updated.
+ NETDATA.updatedDom = function() {
+ NETDATA.options.updated_dom = true;
+ };
+
+ NETDATA.ready = function(callback) {
+ NETDATA.options.pauseCallback = callback;
+ };
+
+ NETDATA.pause = function(callback) {
+ if(NETDATA.options.pause === true)
+ callback();
+ else
+ NETDATA.options.pauseCallback = callback;
+ };
+
+ NETDATA.unpause = function() {
+ NETDATA.options.pauseCallback = null;
+ NETDATA.options.updated_dom = true;
+ NETDATA.options.pause = false;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ // this is purely sequencial charts refresher
+ // it is meant to be autonomous
+ NETDATA.chartRefresherNoParallel = function(index) {
+ if(NETDATA.options.debug.mail_loop === true)
+ console.log('NETDATA.chartRefresherNoParallel(' + index + ')');
+
+ if(NETDATA.options.updated_dom === true) {
+ // the dom has been updated
+ // get the dom parts again
+ NETDATA.parseDom(NETDATA.chartRefresher);
+ return;
+ }
+ if(index >= NETDATA.options.targets.length) {
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('waiting to restart main loop...');
+
+ NETDATA.options.auto_refresher_fast_weight = 0;
+
+ setTimeout(function() {
+ NETDATA.chartRefresher();
+ }, NETDATA.options.current.idle_between_loops);
+ }
+ else {
+ var state = NETDATA.options.targets[index];
+
+ if(NETDATA.options.auto_refresher_fast_weight < NETDATA.options.current.fast_render_timeframe) {
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('fast rendering...');
+
+ state.autoRefresh(function() {
+ NETDATA.chartRefresherNoParallel(++index);
+ });
+ }
+ else {
+ if(NETDATA.options.debug.main_loop === true) console.log('waiting for next refresh...');
+ NETDATA.options.auto_refresher_fast_weight = 0;
+
+ setTimeout(function() {
+ state.autoRefresh(function() {
+ NETDATA.chartRefresherNoParallel(++index);
+ });
+ }, NETDATA.options.current.idle_between_charts);
+ }
+ }
+ };
+
+ // this is part of the parallel refresher
+ // its cause is to refresh sequencially all the charts
+ // that depend on chart library initialization
+ // it will call the parallel refresher back
+ // as soon as it sees a chart that its chart library
+ // is initialized
+ NETDATA.chartRefresher_uninitialized = function() {
+ if(NETDATA.options.updated_dom === true) {
+ // the dom has been updated
+ // get the dom parts again
+ NETDATA.parseDom(NETDATA.chartRefresher);
+ return;
+ }
+
+ if(NETDATA.options.sequencial.length === 0)
+ NETDATA.chartRefresher();
+ else {
+ var state = NETDATA.options.sequencial.pop();
+ if(state.library.initialized === true)
+ NETDATA.chartRefresher();
+ else
+ state.autoRefresh(NETDATA.chartRefresher_uninitialized);
+ }
+ };
+
+ NETDATA.chartRefresherWaitTime = function() {
+ return NETDATA.options.current.idle_parallel_loops;
+ };
+
+ // the default refresher
+ // it will create 2 sets of charts:
+ // - the ones that can be refreshed in parallel
+ // - the ones that depend on something else
+ // the first set will be executed in parallel
+ // the second will be given to NETDATA.chartRefresher_uninitialized()
+ NETDATA.chartRefresher = function() {
+ // console.log('auto-refresher...');
+
+ if(NETDATA.options.pause === true) {
+ // console.log('auto-refresher is paused');
+ setTimeout(NETDATA.chartRefresher,
+ NETDATA.chartRefresherWaitTime());
+ return;
+ }
+
+ if(typeof NETDATA.options.pauseCallback === 'function') {
+ // console.log('auto-refresher is calling pauseCallback');
+ NETDATA.options.pause = true;
+ NETDATA.options.pauseCallback();
+ NETDATA.chartRefresher();
+ return;
+ }
+
+ if(NETDATA.options.current.parallel_refresher === false) {
+ // console.log('auto-refresher is calling chartRefresherNoParallel(0)');
+ NETDATA.chartRefresherNoParallel(0);
+ return;
+ }
+
+ if(NETDATA.options.updated_dom === true) {
+ // the dom has been updated
+ // get the dom parts again
+ // console.log('auto-refresher is calling parseDom()');
+ NETDATA.parseDom(NETDATA.chartRefresher);
+ return;
+ }
+
+ var parallel = new Array();
+ var targets = NETDATA.options.targets;
+ var len = targets.length;
+ var state;
+ while(len--) {
+ state = targets[len];
+ if(state.isVisible() === false || state.running === true)
+ continue;
+
+ if(state.library.initialized === false) {
+ if(state.library.enabled === true) {
+ state.library.initialize(NETDATA.chartRefresher);
+ return;
+ }
+ else {
+ state.error('chart library "' + state.library_name + '" is not enabled.');
+ }
+ }
+
+ parallel.unshift(state);
+ }
+
+ if(parallel.length > 0) {
+ // console.log('auto-refresher executing in parallel for ' + parallel.length.toString() + ' charts');
+ // this will execute the jobs in parallel
+ $(parallel).each(function() {
+ this.autoRefresh();
+ })
+ }
+ //else {
+ // console.log('auto-refresher nothing to do');
+ //}
+
+ // run the next refresh iteration
+ setTimeout(NETDATA.chartRefresher,
+ NETDATA.chartRefresherWaitTime());
+ };
+
+ NETDATA.parseDom = function(callback) {
+ NETDATA.options.last_page_scroll = new Date().getTime();
+ NETDATA.options.updated_dom = false;
+
+ var targets = $('div[data-netdata]'); //.filter(':visible');
+
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('DOM updated - there are ' + targets.length + ' charts on page.');
+
+ NETDATA.options.targets = new Array();
+ var len = targets.length;
+ while(len--) {
+ // the initialization will take care of sizing
+ // and the "loading..." message
+ NETDATA.options.targets.push(NETDATA.chartState(targets[len]));
+ }
+
+ if(typeof callback === 'function') callback();
+ };
+
+ // this is the main function - where everything starts
+ NETDATA.start = function() {
+ // this should be called only once
+
+ NETDATA.options.page_is_visible = true;
+
+ $(window).blur(function() {
+ if(NETDATA.options.current.stop_updates_when_focus_is_lost === true) {
+ NETDATA.options.page_is_visible = false;
+ if(NETDATA.options.debug.focus === true)
+ console.log('Lost Focus!');
+ }
+ });
+
+ $(window).focus(function() {
+ if(NETDATA.options.current.stop_updates_when_focus_is_lost === true) {
+ NETDATA.options.page_is_visible = true;
+ if(NETDATA.options.debug.focus === true)
+ console.log('Focus restored!');
+ }
+ });
+
+ if(typeof document.hasFocus === 'function' && !document.hasFocus()) {
+ if(NETDATA.options.current.stop_updates_when_focus_is_lost === true) {
+ NETDATA.options.page_is_visible = false;
+ if(NETDATA.options.debug.focus === true)
+ console.log('Document has no focus!');
+ }
+ }
+
+ // bootstrap tab switching
+ $('a[data-toggle="tab"]').on('shown.bs.tab', NETDATA.onscroll);
+
+ // bootstrap modal switching
+ $('.modal').on('hidden.bs.modal', NETDATA.onscroll);
+ $('.modal').on('shown.bs.modal', NETDATA.onscroll);
+
+ // bootstrap collapse switching
+ $('.collapse').on('hidden.bs.collapse', NETDATA.onscroll);
+ $('.collapse').on('shown.bs.collapse', NETDATA.onscroll);
+
+ NETDATA.parseDom(NETDATA.chartRefresher);
+
+ // Alarms initialization
+ if(netdataShowAlarms === true)
+ setTimeout(NETDATA.alarms.init, 1000);
+
+ // Registry initialization
+ setTimeout(NETDATA.registry.init, 1500);
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // peity
+
+ NETDATA.peityInitialize = function(callback) {
+ if(typeof netdataNoPeitys === 'undefined' || !netdataNoPeitys) {
+ $.ajax({
+ url: NETDATA.peity_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('peity', NETDATA.peity_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.peity.enabled = false;
+ NETDATA.error(100, NETDATA.peity_js);
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ });
+ }
+ else {
+ NETDATA.chartLibraries.peity.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.peityChartUpdate = function(state, data) {
+ state.peity_instance.innerHTML = data.result;
+
+ if(state.peity_options.stroke !== state.chartColors()[0]) {
+ state.peity_options.stroke = state.chartColors()[0];
+ if(state.chart.chart_type === 'line')
+ state.peity_options.fill = NETDATA.themes.current.background;
+ else
+ state.peity_options.fill = NETDATA.colorLuminance(state.chartColors()[0], NETDATA.chartDefaults.fill_luminance);
+ }
+
+ $(state.peity_instance).peity('line', state.peity_options);
+ return true;
+ };
+
+ NETDATA.peityChartCreate = function(state, data) {
+ state.peity_instance = document.createElement('div');
+ state.element_chart.appendChild(state.peity_instance);
+
+ var self = $(state.element);
+ state.peity_options = {
+ stroke: NETDATA.themes.current.foreground,
+ strokeWidth: self.data('peity-strokewidth') || 1,
+ width: state.chartWidth(),
+ height: state.chartHeight(),
+ fill: NETDATA.themes.current.foreground
+ };
+
+ NETDATA.peityChartUpdate(state, data);
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // sparkline
+
+ NETDATA.sparklineInitialize = function(callback) {
+ if(typeof netdataNoSparklines === 'undefined' || !netdataNoSparklines) {
+ $.ajax({
+ url: NETDATA.sparkline_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('sparkline', NETDATA.sparkline_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.sparkline.enabled = false;
+ NETDATA.error(100, NETDATA.sparkline_js);
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ });
+ }
+ else {
+ NETDATA.chartLibraries.sparkline.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.sparklineChartUpdate = function(state, data) {
+ state.sparkline_options.width = state.chartWidth();
+ state.sparkline_options.height = state.chartHeight();
+
+ $(state.element_chart).sparkline(data.result, state.sparkline_options);
+ return true;
+ };
+
+ NETDATA.sparklineChartCreate = function(state, data) {
+ var self = $(state.element);
+ var type = self.data('sparkline-type') || 'line';
+ var lineColor = self.data('sparkline-linecolor') || state.chartColors()[0];
+ var fillColor = self.data('sparkline-fillcolor') || (state.chart.chart_type === 'line')?NETDATA.themes.current.background:NETDATA.colorLuminance(lineColor, NETDATA.chartDefaults.fill_luminance);
+ var chartRangeMin = self.data('sparkline-chartrangemin') || undefined;
+ var chartRangeMax = self.data('sparkline-chartrangemax') || undefined;
+ var composite = self.data('sparkline-composite') || undefined;
+ var enableTagOptions = self.data('sparkline-enabletagoptions') || undefined;
+ var tagOptionPrefix = self.data('sparkline-tagoptionprefix') || undefined;
+ var tagValuesAttribute = self.data('sparkline-tagvaluesattribute') || undefined;
+ var disableHiddenCheck = self.data('sparkline-disablehiddencheck') || undefined;
+ var defaultPixelsPerValue = self.data('sparkline-defaultpixelspervalue') || undefined;
+ var spotColor = self.data('sparkline-spotcolor') || undefined;
+ var minSpotColor = self.data('sparkline-minspotcolor') || undefined;
+ var maxSpotColor = self.data('sparkline-maxspotcolor') || undefined;
+ var spotRadius = self.data('sparkline-spotradius') || undefined;
+ var valueSpots = self.data('sparkline-valuespots') || undefined;
+ var highlightSpotColor = self.data('sparkline-highlightspotcolor') || undefined;
+ var highlightLineColor = self.data('sparkline-highlightlinecolor') || undefined;
+ var lineWidth = self.data('sparkline-linewidth') || undefined;
+ var normalRangeMin = self.data('sparkline-normalrangemin') || undefined;
+ var normalRangeMax = self.data('sparkline-normalrangemax') || undefined;
+ var drawNormalOnTop = self.data('sparkline-drawnormalontop') || undefined;
+ var xvalues = self.data('sparkline-xvalues') || undefined;
+ var chartRangeClip = self.data('sparkline-chartrangeclip') || undefined;
+ var chartRangeMinX = self.data('sparkline-chartrangeminx') || undefined;
+ var chartRangeMaxX = self.data('sparkline-chartrangemaxx') || undefined;
+ var disableInteraction = self.data('sparkline-disableinteraction') || false;
+ var disableTooltips = self.data('sparkline-disabletooltips') || false;
+ var disableHighlight = self.data('sparkline-disablehighlight') || false;
+ var highlightLighten = self.data('sparkline-highlightlighten') || 1.4;
+ var highlightColor = self.data('sparkline-highlightcolor') || undefined;
+ var tooltipContainer = self.data('sparkline-tooltipcontainer') || undefined;
+ var tooltipClassname = self.data('sparkline-tooltipclassname') || undefined;
+ var tooltipFormat = self.data('sparkline-tooltipformat') || undefined;
+ var tooltipPrefix = self.data('sparkline-tooltipprefix') || undefined;
+ var tooltipSuffix = self.data('sparkline-tooltipsuffix') || ' ' + state.units;
+ var tooltipSkipNull = self.data('sparkline-tooltipskipnull') || true;
+ var tooltipValueLookups = self.data('sparkline-tooltipvaluelookups') || undefined;
+ var tooltipFormatFieldlist = self.data('sparkline-tooltipformatfieldlist') || undefined;
+ var tooltipFormatFieldlistKey = self.data('sparkline-tooltipformatfieldlistkey') || undefined;
+ var numberFormatter = self.data('sparkline-numberformatter') || function(n){ return n.toFixed(2); };
+ var numberDigitGroupSep = self.data('sparkline-numberdigitgroupsep') || undefined;
+ var numberDecimalMark = self.data('sparkline-numberdecimalmark') || undefined;
+ var numberDigitGroupCount = self.data('sparkline-numberdigitgroupcount') || undefined;
+ var animatedZooms = self.data('sparkline-animatedzooms') || false;
+
+ if(spotColor === 'disable') spotColor='';
+ if(minSpotColor === 'disable') minSpotColor='';
+ if(maxSpotColor === 'disable') maxSpotColor='';
+
+ state.sparkline_options = {
+ type: type,
+ lineColor: lineColor,
+ fillColor: fillColor,
+ chartRangeMin: chartRangeMin,
+ chartRangeMax: chartRangeMax,
+ composite: composite,
+ enableTagOptions: enableTagOptions,
+ tagOptionPrefix: tagOptionPrefix,
+ tagValuesAttribute: tagValuesAttribute,
+ disableHiddenCheck: disableHiddenCheck,
+ defaultPixelsPerValue: defaultPixelsPerValue,
+ spotColor: spotColor,
+ minSpotColor: minSpotColor,
+ maxSpotColor: maxSpotColor,
+ spotRadius: spotRadius,
+ valueSpots: valueSpots,
+ highlightSpotColor: highlightSpotColor,
+ highlightLineColor: highlightLineColor,
+ lineWidth: lineWidth,
+ normalRangeMin: normalRangeMin,
+ normalRangeMax: normalRangeMax,
+ drawNormalOnTop: drawNormalOnTop,
+ xvalues: xvalues,
+ chartRangeClip: chartRangeClip,
+ chartRangeMinX: chartRangeMinX,
+ chartRangeMaxX: chartRangeMaxX,
+ disableInteraction: disableInteraction,
+ disableTooltips: disableTooltips,
+ disableHighlight: disableHighlight,
+ highlightLighten: highlightLighten,
+ highlightColor: highlightColor,
+ tooltipContainer: tooltipContainer,
+ tooltipClassname: tooltipClassname,
+ tooltipChartTitle: state.title,
+ tooltipFormat: tooltipFormat,
+ tooltipPrefix: tooltipPrefix,
+ tooltipSuffix: tooltipSuffix,
+ tooltipSkipNull: tooltipSkipNull,
+ tooltipValueLookups: tooltipValueLookups,
+ tooltipFormatFieldlist: tooltipFormatFieldlist,
+ tooltipFormatFieldlistKey: tooltipFormatFieldlistKey,
+ numberFormatter: numberFormatter,
+ numberDigitGroupSep: numberDigitGroupSep,
+ numberDecimalMark: numberDecimalMark,
+ numberDigitGroupCount: numberDigitGroupCount,
+ animatedZooms: animatedZooms,
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ };
+
+ $(state.element_chart).sparkline(data.result, state.sparkline_options);
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // dygraph
+
+ NETDATA.dygraph = {
+ smooth: false
+ };
+
+ NETDATA.dygraphToolboxPanAndZoom = function(state, after, before) {
+ if(after < state.netdata_first)
+ after = state.netdata_first;
+
+ if(before > state.netdata_last)
+ before = state.netdata_last;
+
+ state.setMode('zoom');
+ state.globalSelectionSyncStop();
+ state.globalSelectionSyncDelay();
+ state.dygraph_user_action = true;
+ state.dygraph_force_zoom = true;
+ state.updateChartPanOrZoom(after, before);
+ NETDATA.globalPanAndZoom.setMaster(state, after, before);
+ };
+
+ NETDATA.dygraphSetSelection = function(state, t) {
+ if(typeof state.dygraph_instance !== 'undefined') {
+ var r = state.calculateRowForTime(t);
+ if(r !== -1)
+ state.dygraph_instance.setSelection(r);
+ else {
+ state.dygraph_instance.clearSelection();
+ state.legendShowUndefined();
+ }
+ }
+
+ return true;
+ };
+
+ NETDATA.dygraphClearSelection = function(state, t) {
+ if(typeof state.dygraph_instance !== 'undefined') {
+ state.dygraph_instance.clearSelection();
+ }
+ return true;
+ };
+
+ NETDATA.dygraphSmoothInitialize = function(callback) {
+ $.ajax({
+ url: NETDATA.dygraph_smooth_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.dygraph.smooth = true;
+ smoothPlotter.smoothing = 0.3;
+ })
+ .fail(function() {
+ NETDATA.dygraph.smooth = false;
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ });
+ };
+
+ NETDATA.dygraphInitialize = function(callback) {
+ if(typeof netdataNoDygraphs === 'undefined' || !netdataNoDygraphs) {
+ $.ajax({
+ url: NETDATA.dygraph_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('dygraph', NETDATA.dygraph_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.dygraph.enabled = false;
+ NETDATA.error(100, NETDATA.dygraph_js);
+ })
+ .always(function() {
+ if(NETDATA.chartLibraries.dygraph.enabled === true && NETDATA.options.current.smooth_plot === true)
+ NETDATA.dygraphSmoothInitialize(callback);
+ else if(typeof callback === "function")
+ callback();
+ });
+ }
+ else {
+ NETDATA.chartLibraries.dygraph.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.dygraphChartUpdate = function(state, data) {
+ var dygraph = state.dygraph_instance;
+
+ if(typeof dygraph === 'undefined')
+ return NETDATA.dygraphChartCreate(state, data);
+
+ // when the chart is not visible, and hidden
+ // if there is a window resize, dygraph detects
+ // its element size as 0x0.
+ // this will make it re-appear properly
+
+ if(state.tm.last_unhidden > state.dygraph_last_rendered)
+ dygraph.resize();
+
+ var options = {
+ file: data.result.data,
+ colors: state.chartColors(),
+ labels: data.result.labels,
+ labelsDivWidth: state.chartWidth() - 70,
+ visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names)
+ };
+
+ if(state.dygraph_force_zoom === true) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('dygraphChartUpdate() forced zoom update');
+
+ options.dateWindow = (state.requested_padding !== null)?[ state.view_after, state.view_before ]:null;
+ options.valueRange = state.dygraph_options.valueRange;
+ options.isZoomedIgnoreProgrammaticZoom = true;
+ state.dygraph_force_zoom = false;
+ }
+ else if(state.current.name !== 'auto') {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('dygraphChartUpdate() loose update');
+
+ options.valueRange = state.dygraph_options.valueRange;
+ }
+ else {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('dygraphChartUpdate() strict update');
+
+ options.dateWindow = (state.requested_padding !== null)?[ state.view_after, state.view_before ]:null;
+ options.valueRange = state.dygraph_options.valueRange;
+ options.isZoomedIgnoreProgrammaticZoom = true;
+ }
+
+ if(state.dygraph_smooth_eligible === true) {
+ if((NETDATA.options.current.smooth_plot === true && state.dygraph_options.plotter !== smoothPlotter)
+ || (NETDATA.options.current.smooth_plot === false && state.dygraph_options.plotter === smoothPlotter)) {
+ NETDATA.dygraphChartCreate(state, data);
+ return;
+ }
+ }
+
+ dygraph.updateOptions(options);
+
+ state.dygraph_last_rendered = new Date().getTime();
+ return true;
+ };
+
+ NETDATA.dygraphChartCreate = function(state, data) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('dygraphChartCreate()');
+
+ var self = $(state.element);
+
+ var chart_type = state.chart.chart_type;
+ if(chart_type === 'stacked' && data.dimensions === 1) chart_type = 'area';
+ chart_type = self.data('dygraph-type') || chart_type;
+
+ var smooth = (chart_type === 'line' && !NETDATA.chartLibraries.dygraph.isSparkline(state))?true:false;
+ smooth = self.data('dygraph-smooth') || smooth;
+
+ if(NETDATA.dygraph.smooth === false)
+ smooth = false;
+
+ var strokeWidth = (chart_type === 'stacked')?0.1:((smooth)?1.5:0.7)
+ var highlightCircleSize = (NETDATA.chartLibraries.dygraph.isSparkline(state))?3:4;
+
+ state.dygraph_options = {
+ colors: self.data('dygraph-colors') || state.chartColors(),
+
+ // leave a few pixels empty on the right of the chart
+ rightGap: self.data('dygraph-rightgap') || 5,
+ showRangeSelector: self.data('dygraph-showrangeselector') || false,
+ showRoller: self.data('dygraph-showroller') || false,
+
+ title: self.data('dygraph-title') || state.title,
+ titleHeight: self.data('dygraph-titleheight') || 19,
+
+ legend: self.data('dygraph-legend') || 'always', // 'onmouseover',
+ labels: data.result.labels,
+ labelsDiv: self.data('dygraph-labelsdiv') || state.element_legend_childs.hidden,
+ labelsDivStyles: self.data('dygraph-labelsdivstyles') || { 'fontSize':'1px' },
+ labelsDivWidth: self.data('dygraph-labelsdivwidth') || state.chartWidth() - 70,
+ labelsSeparateLines: self.data('dygraph-labelsseparatelines') || true,
+ labelsShowZeroValues: self.data('dygraph-labelsshowzerovalues') || true,
+ labelsKMB: false,
+ labelsKMG2: false,
+ showLabelsOnHighlight: self.data('dygraph-showlabelsonhighlight') || true,
+ hideOverlayOnMouseOut: self.data('dygraph-hideoverlayonmouseout') || true,
+
+ includeZero: self.data('dygraph-includezero') || false,
+ xRangePad: self.data('dygraph-xrangepad') || 0,
+ yRangePad: self.data('dygraph-yrangepad') || 1,
+
+ valueRange: self.data('dygraph-valuerange') || null,
+
+ ylabel: state.units,
+ yLabelWidth: self.data('dygraph-ylabelwidth') || 12,
+
+ // the function to plot the chart
+ plotter: null,
+
+ // The width of the lines connecting data points. This can be used to increase the contrast or some graphs.
+ strokeWidth: self.data('dygraph-strokewidth') || strokeWidth,
+ strokePattern: self.data('dygraph-strokepattern') || undefined,
+
+ // The size of the dot to draw on each point in pixels (see drawPoints). A dot is always drawn when a point is "isolated",
+ // i.e. there is a missing point on either side of it. This also controls the size of those dots.
+ drawPoints: self.data('dygraph-drawpoints') || false,
+
+ // Draw points at the edges of gaps in the data. This improves visibility of small data segments or other data irregularities.
+ drawGapEdgePoints: self.data('dygraph-drawgapedgepoints') || true,
+
+ connectSeparatedPoints: self.data('dygraph-connectseparatedpoints') || false,
+ pointSize: self.data('dygraph-pointsize') || 1,
+
+ // enabling this makes the chart with little square lines
+ stepPlot: self.data('dygraph-stepplot') || false,
+
+ // Draw a border around graph lines to make crossing lines more easily distinguishable. Useful for graphs with many lines.
+ strokeBorderColor: self.data('dygraph-strokebordercolor') || NETDATA.themes.current.background,
+ strokeBorderWidth: self.data('dygraph-strokeborderwidth') || (chart_type === 'stacked')?0.0:0.0,
+
+ fillGraph: self.data('dygraph-fillgraph') || (chart_type === 'area' || chart_type === 'stacked')?true:false,
+ fillAlpha: self.data('dygraph-fillalpha') || (chart_type === 'stacked')?NETDATA.options.current.color_fill_opacity_stacked:NETDATA.options.current.color_fill_opacity_area,
+ stackedGraph: self.data('dygraph-stackedgraph') || (chart_type === 'stacked')?true:false,
+ stackedGraphNaNFill: self.data('dygraph-stackedgraphnanfill') || 'none',
+
+ drawAxis: self.data('dygraph-drawaxis') || true,
+ axisLabelFontSize: self.data('dygraph-axislabelfontsize') || 10,
+ axisLineColor: self.data('dygraph-axislinecolor') || NETDATA.themes.current.axis,
+ axisLineWidth: self.data('dygraph-axislinewidth') || 0.3,
+
+ drawGrid: self.data('dygraph-drawgrid') || true,
+ drawXGrid: self.data('dygraph-drawxgrid') || undefined,
+ drawYGrid: self.data('dygraph-drawygrid') || undefined,
+ gridLinePattern: self.data('dygraph-gridlinepattern') || null,
+ gridLineWidth: self.data('dygraph-gridlinewidth') || 0.3,
+ gridLineColor: self.data('dygraph-gridlinecolor') || NETDATA.themes.current.grid,
+
+ maxNumberWidth: self.data('dygraph-maxnumberwidth') || 8,
+ sigFigs: self.data('dygraph-sigfigs') || null,
+ digitsAfterDecimal: self.data('dygraph-digitsafterdecimal') || 2,
+ valueFormatter: self.data('dygraph-valueformatter') || function(x){ return x.toFixed(2); },
+
+ highlightCircleSize: self.data('dygraph-highlightcirclesize') || highlightCircleSize,
+ highlightSeriesOpts: self.data('dygraph-highlightseriesopts') || null, // TOO SLOW: { strokeWidth: 1.5 },
+ highlightSeriesBackgroundAlpha: self.data('dygraph-highlightseriesbackgroundalpha') || null, // TOO SLOW: (chart_type === 'stacked')?0.7:0.5,
+
+ pointClickCallback: self.data('dygraph-pointclickcallback') || undefined,
+ visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names),
+ axes: {
+ x: {
+ pixelsPerLabel: 50,
+ ticker: Dygraph.dateTicker,
+ axisLabelFormatter: function (d, gran) {
+ return NETDATA.zeropad(d.getHours()) + ":" + NETDATA.zeropad(d.getMinutes()) + ":" + NETDATA.zeropad(d.getSeconds());
+ },
+ valueFormatter: function (ms) {
+ var d = new Date(ms);
+ return d.toLocaleDateString() + ' ' + d.toLocaleTimeString();
+ // return NETDATA.zeropad(d.getHours()) + ":" + NETDATA.zeropad(d.getMinutes()) + ":" + NETDATA.zeropad(d.getSeconds());
+ }
+ },
+ y: {
+ pixelsPerLabel: 15,
+ valueFormatter: function (x) {
+ // we format legends with the state object
+ // no need to do anything here
+ // return (Math.round(x*100) / 100).toLocaleString();
+ // return state.legendFormatValue(x);
+ return x;
+ }
+ }
+ },
+ legendFormatter: function(data) {
+ var elements = state.element_legend_childs;
+
+ // if the hidden div is not there
+ // we are not managing the legend
+ if(elements.hidden === null) return;
+
+ if (typeof data.x !== 'undefined') {
+ state.legendSetDate(data.x);
+ var i = data.series.length;
+ while(i--) {
+ var series = data.series[i];
+ if(!series.isVisible) continue;
+ state.legendSetLabelValue(series.label, series.y);
+ }
+ }
+
+ return '';
+ },
+ drawCallback: function(dygraph, is_initial) {
+ if(state.current.name !== 'auto' && state.dygraph_user_action === true) {
+ state.dygraph_user_action = false;
+
+ var x_range = dygraph.xAxisRange();
+ var after = Math.round(x_range[0]);
+ var before = Math.round(x_range[1]);
+
+ if(NETDATA.options.debug.dygraph === true)
+ state.log('dygraphDrawCallback(dygraph, ' + is_initial + '): ' + (after / 1000).toString() + ' - ' + (before / 1000).toString());
+
+ if(before <= state.netdata_last && after >= state.netdata_first)
+ state.updateChartPanOrZoom(after, before);
+ }
+ },
+ zoomCallback: function(minDate, maxDate, yRanges) {
+ if(NETDATA.options.debug.dygraph === true)
+ state.log('dygraphZoomCallback()');
+
+ state.globalSelectionSyncStop();
+ state.globalSelectionSyncDelay();
+ state.setMode('zoom');
+
+ // refresh it to the greatest possible zoom level
+ state.dygraph_user_action = true;
+ state.dygraph_force_zoom = true;
+ state.updateChartPanOrZoom(minDate, maxDate);
+ },
+ highlightCallback: function(event, x, points, row, seriesName) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('dygraphHighlightCallback()');
+
+ state.pauseChart();
+
+ // there is a bug in dygraph when the chart is zoomed enough
+ // the time it thinks is selected is wrong
+ // here we calculate the time t based on the row number selected
+ // which is ok
+ var t = state.data_after + row * state.data_update_every;
+ // console.log('row = ' + row + ', x = ' + x + ', t = ' + t + ' ' + ((t === x)?'SAME':(Math.abs(x-t)<=state.data_update_every)?'SIMILAR':'DIFFERENT') + ', rows in db: ' + state.data_points + ' visible(x) = ' + state.timeIsVisible(x) + ' visible(t) = ' + state.timeIsVisible(t) + ' r(x) = ' + state.calculateRowForTime(x) + ' r(t) = ' + state.calculateRowForTime(t) + ' range: ' + state.data_after + ' - ' + state.data_before + ' real: ' + state.data.after + ' - ' + state.data.before + ' every: ' + state.data_update_every);
+
+ state.globalSelectionSync(x);
+
+ // fix legend zIndex using the internal structures of dygraph legend module
+ // this works, but it is a hack!
+ // state.dygraph_instance.plugins_[0].plugin.legend_div_.style.zIndex = 10000;
+ },
+ unhighlightCallback: function(event) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('dygraphUnhighlightCallback()');
+
+ state.unpauseChart();
+ state.globalSelectionSyncStop();
+ },
+ interactionModel : {
+ mousedown: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.mousedown()');
+
+ state.dygraph_user_action = true;
+ state.globalSelectionSyncStop();
+
+ if(NETDATA.options.debug.dygraph === true)
+ state.log('dygraphMouseDown()');
+
+ // Right-click should not initiate a zoom.
+ if(event.button && event.button === 2) return;
+
+ context.initializeMouseDown(event, dygraph, context);
+
+ if(event.button && event.button === 1) {
+ if (event.altKey || event.shiftKey) {
+ state.setMode('pan');
+ state.globalSelectionSyncDelay();
+ Dygraph.startPan(event, dygraph, context);
+ }
+ else {
+ state.setMode('zoom');
+ state.globalSelectionSyncDelay();
+ Dygraph.startZoom(event, dygraph, context);
+ }
+ }
+ else {
+ if (event.altKey || event.shiftKey) {
+ state.setMode('zoom');
+ state.globalSelectionSyncDelay();
+ Dygraph.startZoom(event, dygraph, context);
+ }
+ else {
+ state.setMode('pan');
+ state.globalSelectionSyncDelay();
+ Dygraph.startPan(event, dygraph, context);
+ }
+ }
+ },
+ mousemove: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.mousemove()');
+
+ if(context.isPanning) {
+ state.dygraph_user_action = true;
+ state.globalSelectionSyncStop();
+ state.globalSelectionSyncDelay();
+ state.setMode('pan');
+ Dygraph.movePan(event, dygraph, context);
+ }
+ else if(context.isZooming) {
+ state.dygraph_user_action = true;
+ state.globalSelectionSyncStop();
+ state.globalSelectionSyncDelay();
+ state.setMode('zoom');
+ Dygraph.moveZoom(event, dygraph, context);
+ }
+ },
+ mouseup: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.mouseup()');
+
+ if (context.isPanning) {
+ state.dygraph_user_action = true;
+ state.globalSelectionSyncDelay();
+ Dygraph.endPan(event, dygraph, context);
+ }
+ else if (context.isZooming) {
+ state.dygraph_user_action = true;
+ state.globalSelectionSyncDelay();
+ Dygraph.endZoom(event, dygraph, context);
+ }
+ },
+ click: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.click()');
+
+ event.preventDefault();
+ },
+ dblclick: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.dblclick()');
+ NETDATA.resetAllCharts(state);
+ },
+ mousewheel: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.mousewheel()');
+
+ // Take the offset of a mouse event on the dygraph canvas and
+ // convert it to a pair of percentages from the bottom left.
+ // (Not top left, bottom is where the lower value is.)
+ function offsetToPercentage(g, offsetX, offsetY) {
+ // This is calculating the pixel offset of the leftmost date.
+ var xOffset = g.toDomCoords(g.xAxisRange()[0], null)[0];
+ var yar0 = g.yAxisRange(0);
+
+ // This is calculating the pixel of the higest value. (Top pixel)
+ var yOffset = g.toDomCoords(null, yar0[1])[1];
+
+ // x y w and h are relative to the corner of the drawing area,
+ // so that the upper corner of the drawing area is (0, 0).
+ var x = offsetX - xOffset;
+ var y = offsetY - yOffset;
+
+ // This is computing the rightmost pixel, effectively defining the
+ // width.
+ var w = g.toDomCoords(g.xAxisRange()[1], null)[0] - xOffset;
+
+ // This is computing the lowest pixel, effectively defining the height.
+ var h = g.toDomCoords(null, yar0[0])[1] - yOffset;
+
+ // Percentage from the left.
+ var xPct = w === 0 ? 0 : (x / w);
+ // Percentage from the top.
+ var yPct = h === 0 ? 0 : (y / h);
+
+ // The (1-) part below changes it from "% distance down from the top"
+ // to "% distance up from the bottom".
+ return [xPct, (1-yPct)];
+ }
+
+ // Adjusts [x, y] toward each other by zoomInPercentage%
+ // Split it so the left/bottom axis gets xBias/yBias of that change and
+ // tight/top gets (1-xBias)/(1-yBias) of that change.
+ //
+ // If a bias is missing it splits it down the middle.
+ function zoomRange(g, zoomInPercentage, xBias, yBias) {
+ xBias = xBias || 0.5;
+ yBias = yBias || 0.5;
+
+ function adjustAxis(axis, zoomInPercentage, bias) {
+ var delta = axis[1] - axis[0];
+ var increment = delta * zoomInPercentage;
+ var foo = [increment * bias, increment * (1-bias)];
+
+ return [ axis[0] + foo[0], axis[1] - foo[1] ];
+ }
+
+ var yAxes = g.yAxisRanges();
+ var newYAxes = [];
+ for (var i = 0; i < yAxes.length; i++) {
+ newYAxes[i] = adjustAxis(yAxes[i], zoomInPercentage, yBias);
+ }
+
+ return adjustAxis(g.xAxisRange(), zoomInPercentage, xBias);
+ }
+
+ if(event.altKey || event.shiftKey) {
+ state.dygraph_user_action = true;
+
+ state.globalSelectionSyncStop();
+ state.globalSelectionSyncDelay();
+
+ // http://dygraphs.com/gallery/interaction-api.js
+ var normal = (event.detail) ? event.detail * -1 : event.wheelDelta / 40;
+ var percentage = normal / 50;
+
+ if (!(event.offsetX && event.offsetY)){
+ event.offsetX = event.layerX - event.target.offsetLeft;
+ event.offsetY = event.layerY - event.target.offsetTop;
+ }
+
+ var percentages = offsetToPercentage(dygraph, event.offsetX, event.offsetY);
+ var xPct = percentages[0];
+ var yPct = percentages[1];
+
+ var new_x_range = zoomRange(dygraph, percentage, xPct, yPct);
+
+ var after = new_x_range[0];
+ var before = new_x_range[1];
+
+ var first = state.netdata_first + state.data_update_every;
+ var last = state.netdata_last + state.data_update_every;
+
+ if(before > last) {
+ after -= (before - last);
+ before = last;
+ }
+ if(after < first) {
+ after = first;
+ }
+
+ state.setMode('zoom');
+ if(state.updateChartPanOrZoom(after, before) === true)
+ dygraph.updateOptions({ dateWindow: [ after, before ] });
+
+ event.preventDefault();
+ }
+ },
+ touchstart: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.touchstart()');
+
+ state.dygraph_user_action = true;
+ state.setMode('zoom');
+ state.pauseChart();
+
+ Dygraph.defaultInteractionModel.touchstart(event, dygraph, context);
+
+ // we overwrite the touch directions at the end, to overwrite
+ // the internal default of dygraphs
+ context.touchDirections = { x: true, y: false };
+
+ state.dygraph_last_touch_start = new Date().getTime();
+ state.dygraph_last_touch_move = 0;
+
+ if(typeof event.touches[0].pageX === 'number')
+ state.dygraph_last_touch_page_x = event.touches[0].pageX;
+ else
+ state.dygraph_last_touch_page_x = 0;
+ },
+ touchmove: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.touchmove()');
+
+ state.dygraph_user_action = true;
+ Dygraph.defaultInteractionModel.touchmove(event, dygraph, context);
+
+ state.dygraph_last_touch_move = new Date().getTime();
+ },
+ touchend: function(event, dygraph, context) {
+ if(NETDATA.options.debug.dygraph === true || state.debug === true)
+ state.log('interactionModel.touchend()');
+
+ state.dygraph_user_action = true;
+ Dygraph.defaultInteractionModel.touchend(event, dygraph, context);
+
+ // if it didn't move, it is a selection
+ if(state.dygraph_last_touch_move === 0 && state.dygraph_last_touch_page_x !== 0) {
+ // internal api of dygraphs
+ var pct = (state.dygraph_last_touch_page_x - (dygraph.plotter_.area.x + state.element.getBoundingClientRect().left)) / dygraph.plotter_.area.w;
+ var t = Math.round(state.data_after + (state.data_before - state.data_after) * pct);
+ if(NETDATA.dygraphSetSelection(state, t) === true)
+ state.globalSelectionSync(t);
+ }
+
+ // if it was double tap within double click time, reset the charts
+ var now = new Date().getTime();
+ if(typeof state.dygraph_last_touch_end !== 'undefined') {
+ if(state.dygraph_last_touch_move === 0) {
+ var dt = now - state.dygraph_last_touch_end;
+ if(dt <= NETDATA.options.current.double_click_speed)
+ NETDATA.resetAllCharts(state);
+ }
+ }
+
+ // remember the timestamp of the last touch end
+ state.dygraph_last_touch_end = now;
+ }
+ }
+ };
+
+ if(NETDATA.chartLibraries.dygraph.isSparkline(state)) {
+ state.dygraph_options.drawGrid = false;
+ state.dygraph_options.drawAxis = false;
+ state.dygraph_options.title = undefined;
+ state.dygraph_options.units = undefined;
+ state.dygraph_options.ylabel = undefined;
+ state.dygraph_options.yLabelWidth = 0;
+ state.dygraph_options.labelsDivWidth = 120;
+ state.dygraph_options.labelsDivStyles.width = '120px';
+ state.dygraph_options.labelsSeparateLines = true;
+ state.dygraph_options.rightGap = 0;
+ state.dygraph_options.yRangePad = 1;
+ }
+
+ if(smooth === true) {
+ state.dygraph_smooth_eligible = true;
+
+ if(NETDATA.options.current.smooth_plot === true)
+ state.dygraph_options.plotter = smoothPlotter;
+ }
+ else state.dygraph_smooth_eligible = false;
+
+ state.dygraph_instance = new Dygraph(state.element_chart,
+ data.result.data, state.dygraph_options);
+
+ state.dygraph_force_zoom = false;
+ state.dygraph_user_action = false;
+ state.dygraph_last_rendered = new Date().getTime();
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // morris
+
+ NETDATA.morrisInitialize = function(callback) {
+ if(typeof netdataNoMorris === 'undefined' || !netdataNoMorris) {
+
+ // morris requires raphael
+ if(!NETDATA.chartLibraries.raphael.initialized) {
+ if(NETDATA.chartLibraries.raphael.enabled) {
+ NETDATA.raphaelInitialize(function() {
+ NETDATA.morrisInitialize(callback);
+ });
+ }
+ else {
+ NETDATA.chartLibraries.morris.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ }
+ else {
+ NETDATA._loadCSS(NETDATA.morris_css);
+
+ $.ajax({
+ url: NETDATA.morris_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('morris', NETDATA.morris_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.morris.enabled = false;
+ NETDATA.error(100, NETDATA.morris_js);
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ });
+ }
+ }
+ else {
+ NETDATA.chartLibraries.morris.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.morrisChartUpdate = function(state, data) {
+ state.morris_instance.setData(data.result.data);
+ return true;
+ };
+
+ NETDATA.morrisChartCreate = function(state, data) {
+
+ state.morris_options = {
+ element: state.element_chart.id,
+ data: data.result.data,
+ xkey: 'time',
+ ykeys: data.dimension_names,
+ labels: data.dimension_names,
+ lineWidth: 2,
+ pointSize: 3,
+ smooth: true,
+ hideHover: 'auto',
+ parseTime: true,
+ continuousLine: false,
+ behaveLikeLine: false
+ };
+
+ if(state.chart.chart_type === 'line')
+ state.morris_instance = new Morris.Line(state.morris_options);
+
+ else if(state.chart.chart_type === 'area') {
+ state.morris_options.behaveLikeLine = true;
+ state.morris_instance = new Morris.Area(state.morris_options);
+ }
+ else // stacked
+ state.morris_instance = new Morris.Area(state.morris_options);
+
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // raphael
+
+ NETDATA.raphaelInitialize = function(callback) {
+ if(typeof netdataStopRaphael === 'undefined' || !netdataStopRaphael) {
+ $.ajax({
+ url: NETDATA.raphael_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('raphael', NETDATA.raphael_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.raphael.enabled = false;
+ NETDATA.error(100, NETDATA.raphael_js);
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ });
+ }
+ else {
+ NETDATA.chartLibraries.raphael.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.raphaelChartUpdate = function(state, data) {
+ $(state.element_chart).raphael(data.result, {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ });
+
+ return false;
+ };
+
+ NETDATA.raphaelChartCreate = function(state, data) {
+ $(state.element_chart).raphael(data.result, {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ });
+
+ return false;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // C3
+
+ NETDATA.c3Initialize = function(callback) {
+ if(typeof netdataNoC3 === 'undefined' || !netdataNoC3) {
+
+ // C3 requires D3
+ if(!NETDATA.chartLibraries.d3.initialized) {
+ if(NETDATA.chartLibraries.d3.enabled) {
+ NETDATA.d3Initialize(function() {
+ NETDATA.c3Initialize(callback);
+ });
+ }
+ else {
+ NETDATA.chartLibraries.c3.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ }
+ else {
+ NETDATA._loadCSS(NETDATA.c3_css);
+
+ $.ajax({
+ url: NETDATA.c3_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('c3', NETDATA.c3_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.c3.enabled = false;
+ NETDATA.error(100, NETDATA.c3_js);
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ });
+ }
+ }
+ else {
+ NETDATA.chartLibraries.c3.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.c3ChartUpdate = function(state, data) {
+ state.c3_instance.destroy();
+ return NETDATA.c3ChartCreate(state, data);
+
+ //state.c3_instance.load({
+ // rows: data.result,
+ // unload: true
+ //});
+
+ //return true;
+ };
+
+ NETDATA.c3ChartCreate = function(state, data) {
+
+ state.element_chart.id = 'c3-' + state.uuid;
+ // console.log('id = ' + state.element_chart.id);
+
+ state.c3_instance = c3.generate({
+ bindto: '#' + state.element_chart.id,
+ size: {
+ width: state.chartWidth(),
+ height: state.chartHeight()
+ },
+ color: {
+ pattern: state.chartColors()
+ },
+ data: {
+ x: 'time',
+ rows: data.result,
+ type: (state.chart.chart_type === 'line')?'spline':'area-spline'
+ },
+ axis: {
+ x: {
+ type: 'timeseries',
+ tick: {
+ format: function(x) {
+ return NETDATA.zeropad(x.getHours()) + ":" + NETDATA.zeropad(x.getMinutes()) + ":" + NETDATA.zeropad(x.getSeconds());
+ }
+ }
+ }
+ },
+ grid: {
+ x: {
+ show: true
+ },
+ y: {
+ show: true
+ }
+ },
+ point: {
+ show: false
+ },
+ line: {
+ connectNull: false
+ },
+ transition: {
+ duration: 0
+ },
+ interaction: {
+ enabled: true
+ }
+ });
+
+ // console.log(state.c3_instance);
+
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // D3
+
+ NETDATA.d3Initialize = function(callback) {
+ if(typeof netdataStopD3 === 'undefined' || !netdataStopD3) {
+ $.ajax({
+ url: NETDATA.d3_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('d3', NETDATA.d3_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.d3.enabled = false;
+ NETDATA.error(100, NETDATA.d3_js);
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ });
+ }
+ else {
+ NETDATA.chartLibraries.d3.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.d3ChartUpdate = function(state, data) {
+ return false;
+ };
+
+ NETDATA.d3ChartCreate = function(state, data) {
+ return false;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // google charts
+
+ NETDATA.googleInitialize = function(callback) {
+ if(typeof netdataNoGoogleCharts === 'undefined' || !netdataNoGoogleCharts) {
+ $.ajax({
+ url: NETDATA.google_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('google', NETDATA.google_js);
+ google.load('visualization', '1.1', {
+ 'packages': ['corechart', 'controls'],
+ 'callback': callback
+ });
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.google.enabled = false;
+ NETDATA.error(100, NETDATA.google_js);
+ if(typeof callback === "function")
+ callback();
+ });
+ }
+ else {
+ NETDATA.chartLibraries.google.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.googleChartUpdate = function(state, data) {
+ var datatable = new google.visualization.DataTable(data.result);
+ state.google_instance.draw(datatable, state.google_options);
+ return true;
+ };
+
+ NETDATA.googleChartCreate = function(state, data) {
+ var datatable = new google.visualization.DataTable(data.result);
+
+ state.google_options = {
+ colors: state.chartColors(),
+
+ // do not set width, height - the chart resizes itself
+ //width: state.chartWidth(),
+ //height: state.chartHeight(),
+ lineWidth: 1,
+ title: state.title,
+ fontSize: 11,
+ hAxis: {
+ // title: "Time of Day",
+ // format:'HH:mm:ss',
+ viewWindowMode: 'maximized',
+ slantedText: false,
+ format:'HH:mm:ss',
+ textStyle: {
+ fontSize: 9
+ },
+ gridlines: {
+ color: '#EEE'
+ }
+ },
+ vAxis: {
+ title: state.units,
+ viewWindowMode: 'pretty',
+ minValue: -0.1,
+ maxValue: 0.1,
+ direction: 1,
+ textStyle: {
+ fontSize: 9
+ },
+ gridlines: {
+ color: '#EEE'
+ }
+ },
+ chartArea: {
+ width: '65%',
+ height: '80%'
+ },
+ focusTarget: 'category',
+ annotation: {
+ '1': {
+ style: 'line'
+ }
+ },
+ pointsVisible: 0,
+ titlePosition: 'out',
+ titleTextStyle: {
+ fontSize: 11
+ },
+ tooltip: {
+ isHtml: false,
+ ignoreBounds: true,
+ textStyle: {
+ fontSize: 9
+ }
+ },
+ curveType: 'function',
+ areaOpacity: 0.3,
+ isStacked: false
+ };
+
+ switch(state.chart.chart_type) {
+ case "area":
+ state.google_options.vAxis.viewWindowMode = 'maximized';
+ state.google_options.areaOpacity = NETDATA.options.current.color_fill_opacity_area;
+ state.google_instance = new google.visualization.AreaChart(state.element_chart);
+ break;
+
+ case "stacked":
+ state.google_options.isStacked = true;
+ state.google_options.areaOpacity = NETDATA.options.current.color_fill_opacity_stacked;
+ state.google_options.vAxis.viewWindowMode = 'maximized';
+ state.google_options.vAxis.minValue = null;
+ state.google_options.vAxis.maxValue = null;
+ state.google_instance = new google.visualization.AreaChart(state.element_chart);
+ break;
+
+ default:
+ case "line":
+ state.google_options.lineWidth = 2;
+ state.google_instance = new google.visualization.LineChart(state.element_chart);
+ break;
+ }
+
+ state.google_instance.draw(datatable, state.google_options);
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+
+ NETDATA.percentFromValueMax = function(value, max) {
+ if(value === null) value = 0;
+ if(max < value) max = value;
+
+ var pcent = 0;
+ if(max !== 0) {
+ pcent = Math.round(value * 100 / max);
+ if(pcent === 0 && value > 0) pcent = 1;
+ }
+
+ return pcent;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // easy-pie-chart
+
+ NETDATA.easypiechartInitialize = function(callback) {
+ if(typeof netdataNoEasyPieChart === 'undefined' || !netdataNoEasyPieChart) {
+ $.ajax({
+ url: NETDATA.easypiechart_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('easypiechart', NETDATA.easypiechart_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.easypiechart.enabled = false;
+ NETDATA.error(100, NETDATA.easypiechart_js);
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ })
+ }
+ else {
+ NETDATA.chartLibraries.easypiechart.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.easypiechartClearSelection = function(state) {
+ if(typeof state.easyPieChartEvent !== 'undefined') {
+ if(state.easyPieChartEvent.timer !== null)
+ clearTimeout(state.easyPieChartEvent.timer);
+
+ state.easyPieChartEvent.timer = null;
+ }
+
+ if(state.isAutoRefreshable() === true && state.data !== null) {
+ NETDATA.easypiechartChartUpdate(state, state.data);
+ }
+ else {
+ state.easyPieChartLabel.innerHTML = state.legendFormatValue(null);
+ state.easyPieChart_instance.update(0);
+ }
+ state.easyPieChart_instance.enableAnimation();
+
+ return true;
+ };
+
+ NETDATA.easypiechartSetSelection = function(state, t) {
+ if(state.timeIsVisible(t) !== true)
+ return NETDATA.easypiechartClearSelection(state);
+
+ var slot = state.calculateRowForTime(t);
+ if(slot < 0 || slot >= state.data.result.length)
+ return NETDATA.easypiechartClearSelection(state);
+
+ if(typeof state.easyPieChartEvent === 'undefined') {
+ state.easyPieChartEvent = {
+ timer: null,
+ value: 0,
+ pcent: 0
+ };
+ }
+
+ var value = state.data.result[state.data.result.length - 1 - slot];
+ var max = (state.easyPieChartMax === null)?state.data.max:state.easyPieChartMax;
+ var pcent = NETDATA.percentFromValueMax(value, max);
+
+ state.easyPieChartEvent.value = value;
+ state.easyPieChartEvent.pcent = pcent;
+ state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
+
+ if(state.easyPieChartEvent.timer === null) {
+ state.easyPieChart_instance.disableAnimation();
+
+ state.easyPieChartEvent.timer = setTimeout(function() {
+ state.easyPieChartEvent.timer = null;
+ state.easyPieChart_instance.update(state.easyPieChartEvent.pcent);
+ }, NETDATA.options.current.charts_selection_animation_delay);
+ }
+
+ return true;
+ };
+
+ NETDATA.easypiechartChartUpdate = function(state, data) {
+ var value, max, pcent;
+
+ if(NETDATA.globalPanAndZoom.isActive() === true || state.isAutoRefreshable() === false) {
+ value = null;
+ max = 0;
+ pcent = 0;
+ }
+ else {
+ value = data.result[0];
+ max = (state.easyPieChartMax === null)?data.max:state.easyPieChartMax;
+ pcent = NETDATA.percentFromValueMax(value, max);
+ }
+
+ state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
+ state.easyPieChart_instance.update(pcent);
+ return true;
+ };
+
+ NETDATA.easypiechartChartCreate = function(state, data) {
+ var self = $(state.element);
+ var chart = $(state.element_chart);
+
+ var value = data.result[0];
+ var max = self.data('easypiechart-max-value') || null;
+ var adjust = self.data('easypiechart-adjust') || null;
+
+ if(max === null) {
+ max = data.max;
+ state.easyPieChartMax = null;
+ }
+ else
+ state.easyPieChartMax = max;
+
+ var pcent = NETDATA.percentFromValueMax(value, max);
+
+ chart.data('data-percent', pcent);
+
+ var size;
+ switch(adjust) {
+ case 'width': size = state.chartHeight(); break;
+ case 'min': size = Math.min(state.chartWidth(), state.chartHeight()); break;
+ case 'max': size = Math.max(state.chartWidth(), state.chartHeight()); break;
+ case 'height':
+ default: size = state.chartWidth(); break;
+ }
+ state.element.style.width = size + 'px';
+ state.element.style.height = size + 'px';
+
+ var stroke = Math.floor(size / 22);
+ if(stroke < 3) stroke = 2;
+
+ var valuefontsize = Math.floor((size * 2 / 3) / 5);
+ var valuetop = Math.round((size - valuefontsize - (size / 40)) / 2);
+ state.easyPieChartLabel = document.createElement('span');
+ state.easyPieChartLabel.className = 'easyPieChartLabel';
+ state.easyPieChartLabel.innerHTML = state.legendFormatValue(value);
+ state.easyPieChartLabel.style.fontSize = valuefontsize + 'px';
+ state.easyPieChartLabel.style.top = valuetop.toString() + 'px';
+ state.element_chart.appendChild(state.easyPieChartLabel);
+
+ var titlefontsize = Math.round(valuefontsize * 1.6 / 3);
+ var titletop = Math.round(valuetop - (titlefontsize * 2) - (size / 40));
+ state.easyPieChartTitle = document.createElement('span');
+ state.easyPieChartTitle.className = 'easyPieChartTitle';
+ state.easyPieChartTitle.innerHTML = state.title;
+ state.easyPieChartTitle.style.fontSize = titlefontsize + 'px';
+ state.easyPieChartTitle.style.lineHeight = titlefontsize + 'px';
+ state.easyPieChartTitle.style.top = titletop.toString() + 'px';
+ state.element_chart.appendChild(state.easyPieChartTitle);
+
+ var unitfontsize = Math.round(titlefontsize * 0.9);
+ var unittop = Math.round(valuetop + (valuefontsize + unitfontsize) + (size / 40));
+ state.easyPieChartUnits = document.createElement('span');
+ state.easyPieChartUnits.className = 'easyPieChartUnits';
+ state.easyPieChartUnits.innerHTML = state.units;
+ state.easyPieChartUnits.style.fontSize = unitfontsize + 'px';
+ state.easyPieChartUnits.style.top = unittop.toString() + 'px';
+ state.element_chart.appendChild(state.easyPieChartUnits);
+
+ chart.easyPieChart({
+ barColor: self.data('easypiechart-barcolor') || state.chartColors()[0], //'#ef1e25',
+ trackColor: self.data('easypiechart-trackcolor') || NETDATA.themes.current.easypiechart_track,
+ scaleColor: self.data('easypiechart-scalecolor') || NETDATA.themes.current.easypiechart_scale,
+ scaleLength: self.data('easypiechart-scalelength') || 5,
+ lineCap: self.data('easypiechart-linecap') || 'round',
+ lineWidth: self.data('easypiechart-linewidth') || stroke,
+ trackWidth: self.data('easypiechart-trackwidth') || undefined,
+ size: self.data('easypiechart-size') || size,
+ rotate: self.data('easypiechart-rotate') || 0,
+ animate: self.data('easypiechart-rotate') || {duration: 500, enabled: true},
+ easing: self.data('easypiechart-easing') || undefined
+ });
+
+ // when we just re-create the chart
+ // do not animate the first update
+ var animate = true;
+ if(typeof state.easyPieChart_instance !== 'undefined')
+ animate = false;
+
+ state.easyPieChart_instance = chart.data('easyPieChart');
+ if(animate === false) state.easyPieChart_instance.disableAnimation();
+ state.easyPieChart_instance.update(pcent);
+ if(animate === false) state.easyPieChart_instance.enableAnimation();
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // gauge.js
+
+ NETDATA.gaugeInitialize = function(callback) {
+ if(typeof netdataNoGauge === 'undefined' || !netdataNoGauge) {
+ $.ajax({
+ url: NETDATA.gauge_js,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function() {
+ NETDATA.registerChartLibrary('gauge', NETDATA.gauge_js);
+ })
+ .fail(function() {
+ NETDATA.chartLibraries.gauge.enabled = false;
+ NETDATA.error(100, NETDATA.gauge_js);
+ })
+ .always(function() {
+ if(typeof callback === "function")
+ callback();
+ })
+ }
+ else {
+ NETDATA.chartLibraries.gauge.enabled = false;
+ if(typeof callback === "function")
+ callback();
+ }
+ };
+
+ NETDATA.gaugeAnimation = function(state, status) {
+ var speed = 32;
+
+ if(typeof status === 'boolean' && status === false)
+ speed = 1000000000;
+ else if(typeof status === 'number')
+ speed = status;
+
+ state.gauge_instance.animationSpeed = speed;
+ state.___gaugeOld__.speed = speed;
+ };
+
+ NETDATA.gaugeSet = function(state, value, min, max) {
+ if(typeof value !== 'number') value = 0;
+ if(typeof min !== 'number') min = 0;
+ if(typeof max !== 'number') max = 0;
+ if(value > max) max = value;
+ if(value < min) min = value;
+ if(min > max) {
+ var t = min;
+ min = max;
+ max = t;
+ }
+ else if(min == max)
+ max = min + 1;
+
+ // gauge.js has an issue if the needle
+ // is smaller than min or larger than max
+ // when we set the new values
+ // the needle will go crazy
+
+ // to prevent it, we always feed it
+ // with a percentage, so that the needle
+ // is always between min and max
+ var pcent = (value - min) * 100 / (max - min);
+
+ // these should never happen
+ if(pcent < 0) pcent = 0;
+ if(pcent > 100) pcent = 100;
+
+ state.gauge_instance.set(pcent);
+
+ state.___gaugeOld__.value = value;
+ state.___gaugeOld__.min = min;
+ state.___gaugeOld__.max = max;
+ };
+
+ NETDATA.gaugeSetLabels = function(state, value, min, max) {
+ if(state.___gaugeOld__.valueLabel !== value) {
+ state.___gaugeOld__.valueLabel = value;
+ state.gaugeChartLabel.innerHTML = state.legendFormatValue(value);
+ }
+ if(state.___gaugeOld__.minLabel !== min) {
+ state.___gaugeOld__.minLabel = min;
+ state.gaugeChartMin.innerHTML = state.legendFormatValue(min);
+ }
+ if(state.___gaugeOld__.maxLabel !== max) {
+ state.___gaugeOld__.maxLabel = max;
+ state.gaugeChartMax.innerHTML = state.legendFormatValue(max);
+ }
+ };
+
+ NETDATA.gaugeClearSelection = function(state) {
+ if(typeof state.gaugeEvent !== 'undefined') {
+ if(state.gaugeEvent.timer !== null)
+ clearTimeout(state.gaugeEvent.timer);
+
+ state.gaugeEvent.timer = null;
+ }
+
+ if(state.isAutoRefreshable() === true && state.data !== null) {
+ NETDATA.gaugeChartUpdate(state, state.data);
+ }
+ else {
+ NETDATA.gaugeAnimation(state, false);
+ NETDATA.gaugeSet(state, null, null, null);
+ NETDATA.gaugeSetLabels(state, null, null, null);
+ }
+
+ NETDATA.gaugeAnimation(state, true);
+ return true;
+ };
+
+ NETDATA.gaugeSetSelection = function(state, t) {
+ if(state.timeIsVisible(t) !== true)
+ return NETDATA.gaugeClearSelection(state);
+
+ var slot = state.calculateRowForTime(t);
+ if(slot < 0 || slot >= state.data.result.length)
+ return NETDATA.gaugeClearSelection(state);
+
+ if(typeof state.gaugeEvent === 'undefined') {
+ state.gaugeEvent = {
+ timer: null,
+ value: 0,
+ min: 0,
+ max: 0
+ };
+ }
+
+ var value = state.data.result[state.data.result.length - 1 - slot];
+ var max = (state.gaugeMax === null)?state.data.max:state.gaugeMax;
+ var min = 0;
+
+ state.gaugeEvent.value = value;
+ state.gaugeEvent.max = max;
+ state.gaugeEvent.min = min;
+ NETDATA.gaugeSetLabels(state, value, min, max);
+
+ if(state.gaugeEvent.timer === null) {
+ NETDATA.gaugeAnimation(state, false);
+
+ state.gaugeEvent.timer = setTimeout(function() {
+ state.gaugeEvent.timer = null;
+ NETDATA.gaugeSet(state, state.gaugeEvent.value, state.gaugeEvent.min, state.gaugeEvent.max);
+ }, NETDATA.options.current.charts_selection_animation_delay);
+ }
+
+ return true;
+ };
+
+ NETDATA.gaugeChartUpdate = function(state, data) {
+ var value, min, max;
+
+ if(NETDATA.globalPanAndZoom.isActive() === true || state.isAutoRefreshable() === false) {
+ value = 0;
+ min = 0;
+ max = 1;
+ NETDATA.gaugeSetLabels(state, null, null, null);
+ }
+ else {
+ value = data.result[0];
+ min = 0;
+ max = (state.gaugeMax === null)?data.max:state.gaugeMax;
+ if(value > max) max = value;
+ NETDATA.gaugeSetLabels(state, value, min, max);
+ }
+
+ NETDATA.gaugeSet(state, value, min, max);
+ return true;
+ };
+
+ NETDATA.gaugeChartCreate = function(state, data) {
+ var self = $(state.element);
+ // var chart = $(state.element_chart);
+
+ var value = data.result[0];
+ var max = self.data('gauge-max-value') || null;
+ var adjust = self.data('gauge-adjust') || null;
+ var pointerColor = self.data('gauge-pointer-color') || NETDATA.themes.current.gauge_pointer;
+ var strokeColor = self.data('gauge-stroke-color') || NETDATA.themes.current.gauge_stroke;
+ var startColor = self.data('gauge-start-color') || state.chartColors()[0];
+ var stopColor = self.data('gauge-stop-color') || void 0;
+ var generateGradient = self.data('gauge-generate-gradient') || false;
+
+ if(max === null) {
+ max = data.max;
+ state.gaugeMax = null;
+ }
+ else
+ state.gaugeMax = max;
+
+ var width = state.chartWidth(), height = state.chartHeight(); //, ratio = 1.5;
+ //switch(adjust) {
+ // case 'width': width = height * ratio; break;
+ // case 'height':
+ // default: height = width / ratio; break;
+ //}
+ //state.element.style.width = width.toString() + 'px';
+ //state.element.style.height = height.toString() + 'px';
+
+ var lum_d = 0.05;
+
+ var options = {
+ lines: 12, // The number of lines to draw
+ angle: 0.15, // The length of each line
+ lineWidth: 0.44, // 0.44 The line thickness
+ pointer: {
+ length: 0.8, // 0.9 The radius of the inner circle
+ strokeWidth: 0.035, // The rotation offset
+ color: pointerColor // Fill color
+ },
+ colorStart: startColor, // Colors
+ colorStop: stopColor, // just experiment with them
+ strokeColor: strokeColor, // to see which ones work best for you
+ limitMax: true,
+ generateGradient: (generateGradient === true)?true:false,
+ gradientType: 0
+ };
+
+ if (generateGradient.constructor === Array) {
+ // example options:
+ // data-gauge-generate-gradient="[0, 50, 100]"
+ // data-gauge-gradient-percent-color-0="#FFFFFF"
+ // data-gauge-gradient-percent-color-50="#999900"
+ // data-gauge-gradient-percent-color-100="#000000"
+
+ options.percentColors = new Array();
+ var len = generateGradient.length;
+ while(len--) {
+ var pcent = generateGradient[len];
+ var color = self.data('gauge-gradient-percent-color-' + pcent.toString()) || false;
+ if(color !== false) {
+ var a = new Array();
+ a[0] = pcent / 100;
+ a[1] = color;
+ options.percentColors.unshift(a);
+ }
+ }
+ if(options.percentColors.length === 0)
+ delete options.percentColors;
+ }
+ else if(generateGradient === false && NETDATA.themes.current.gauge_gradient === true) {
+ options.percentColors = [
+ [0.0, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 0))],
+ [0.1, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 1))],
+ [0.2, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 2))],
+ [0.3, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 3))],
+ [0.4, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 4))],
+ [0.5, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 5))],
+ [0.6, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 6))],
+ [0.7, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 7))],
+ [0.8, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 8))],
+ [0.9, NETDATA.colorLuminance(startColor, (lum_d * 10) - (lum_d * 9))],
+ [1.0, NETDATA.colorLuminance(startColor, 0.0)]];
+ }
+
+ state.gauge_canvas = document.createElement('canvas');
+ state.gauge_canvas.id = 'gauge-' + state.uuid + '-canvas';
+ state.gauge_canvas.className = 'gaugeChart';
+ state.gauge_canvas.width = width;
+ state.gauge_canvas.height = height;
+ state.element_chart.appendChild(state.gauge_canvas);
+
+ var valuefontsize = Math.floor(height / 6);
+ var valuetop = Math.round((height - valuefontsize - (height / 6)) / 2);
+ state.gaugeChartLabel = document.createElement('span');
+ state.gaugeChartLabel.className = 'gaugeChartLabel';
+ state.gaugeChartLabel.style.fontSize = valuefontsize + 'px';
+ state.gaugeChartLabel.style.top = valuetop.toString() + 'px';
+ state.element_chart.appendChild(state.gaugeChartLabel);
+
+ var titlefontsize = Math.round(valuefontsize / 2);
+ var titletop = 0;
+ state.gaugeChartTitle = document.createElement('span');
+ state.gaugeChartTitle.className = 'gaugeChartTitle';
+ state.gaugeChartTitle.innerHTML = state.title;
+ state.gaugeChartTitle.style.fontSize = titlefontsize + 'px';
+ state.gaugeChartTitle.style.lineHeight = titlefontsize + 'px';
+ state.gaugeChartTitle.style.top = titletop.toString() + 'px';
+ state.element_chart.appendChild(state.gaugeChartTitle);
+
+ var unitfontsize = Math.round(titlefontsize * 0.9);
+ state.gaugeChartUnits = document.createElement('span');
+ state.gaugeChartUnits.className = 'gaugeChartUnits';
+ state.gaugeChartUnits.innerHTML = state.units;
+ state.gaugeChartUnits.style.fontSize = unitfontsize + 'px';
+ state.element_chart.appendChild(state.gaugeChartUnits);
+
+ state.gaugeChartMin = document.createElement('span');
+ state.gaugeChartMin.className = 'gaugeChartMin';
+ state.gaugeChartMin.style.fontSize = Math.round(valuefontsize * 0.75).toString() + 'px';
+ state.element_chart.appendChild(state.gaugeChartMin);
+
+ state.gaugeChartMax = document.createElement('span');
+ state.gaugeChartMax.className = 'gaugeChartMax';
+ state.gaugeChartMax.style.fontSize = Math.round(valuefontsize * 0.75).toString() + 'px';
+ state.element_chart.appendChild(state.gaugeChartMax);
+
+ // when we just re-create the chart
+ // do not animate the first update
+ var animate = true;
+ if(typeof state.gauge_instance !== 'undefined')
+ animate = false;
+
+ state.gauge_instance = new Gauge(state.gauge_canvas).setOptions(options); // create sexy gauge!
+
+ state.___gaugeOld__ = {
+ value: value,
+ min: 0,
+ max: max,
+ valueLabel: null,
+ minLabel: null,
+ maxLabel: null
+ };
+
+ // we will always feed a percentage
+ state.gauge_instance.minValue = 0;
+ state.gauge_instance.maxValue = 100;
+
+ NETDATA.gaugeAnimation(state, animate);
+ NETDATA.gaugeSet(state, value, 0, max);
+ NETDATA.gaugeSetLabels(state, value, 0, max);
+ NETDATA.gaugeAnimation(state, true);
+ return true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Charts Libraries Registration
+
+ NETDATA.chartLibraries = {
+ "dygraph": {
+ initialize: NETDATA.dygraphInitialize,
+ create: NETDATA.dygraphChartCreate,
+ update: NETDATA.dygraphChartUpdate,
+ resize: function(state) {
+ if(typeof state.dygraph_instance.resize === 'function')
+ state.dygraph_instance.resize();
+ },
+ setSelection: NETDATA.dygraphSetSelection,
+ clearSelection: NETDATA.dygraphClearSelection,
+ toolboxPanAndZoom: NETDATA.dygraphToolboxPanAndZoom,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'json'; },
+ options: function(state) { return 'ms|flip'; },
+ legend: function(state) {
+ if(this.isSparkline(state) === false)
+ return 'right-side';
+ else
+ return null;
+ },
+ autoresize: function(state) { return true; },
+ max_updates_to_recreate: function(state) { return 5000; },
+ track_colors: function(state) { return true; },
+ pixels_per_point: function(state) {
+ if(this.isSparkline(state) === false)
+ return 3;
+ else
+ return 2;
+ },
+
+ isSparkline: function(state) {
+ if(typeof state.dygraph_sparkline === 'undefined') {
+ var t = $(state.element).data('dygraph-theme');
+ if(t === 'sparkline')
+ state.dygraph_sparkline = true;
+ else
+ state.dygraph_sparkline = false;
+ }
+ return state.dygraph_sparkline;
+ }
+ },
+ "sparkline": {
+ initialize: NETDATA.sparklineInitialize,
+ create: NETDATA.sparklineChartCreate,
+ update: NETDATA.sparklineChartUpdate,
+ resize: null,
+ setSelection: undefined, // function(state, t) { return true; },
+ clearSelection: undefined, // function(state) { return true; },
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'array'; },
+ options: function(state) { return 'flip|abs'; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 5000; },
+ track_colors: function(state) { return false; },
+ pixels_per_point: function(state) { return 3; }
+ },
+ "peity": {
+ initialize: NETDATA.peityInitialize,
+ create: NETDATA.peityChartCreate,
+ update: NETDATA.peityChartUpdate,
+ resize: null,
+ setSelection: undefined, // function(state, t) { return true; },
+ clearSelection: undefined, // function(state) { return true; },
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'ssvcomma'; },
+ options: function(state) { return 'null2zero|flip|abs'; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 5000; },
+ track_colors: function(state) { return false; },
+ pixels_per_point: function(state) { return 3; }
+ },
+ "morris": {
+ initialize: NETDATA.morrisInitialize,
+ create: NETDATA.morrisChartCreate,
+ update: NETDATA.morrisChartUpdate,
+ resize: null,
+ setSelection: undefined, // function(state, t) { return true; },
+ clearSelection: undefined, // function(state) { return true; },
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'json'; },
+ options: function(state) { return 'objectrows|ms'; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 50; },
+ track_colors: function(state) { return false; },
+ pixels_per_point: function(state) { return 15; }
+ },
+ "google": {
+ initialize: NETDATA.googleInitialize,
+ create: NETDATA.googleChartCreate,
+ update: NETDATA.googleChartUpdate,
+ resize: null,
+ setSelection: undefined, //function(state, t) { return true; },
+ clearSelection: undefined, //function(state) { return true; },
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'datatable'; },
+ options: function(state) { return ''; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 300; },
+ track_colors: function(state) { return false; },
+ pixels_per_point: function(state) { return 4; }
+ },
+ "raphael": {
+ initialize: NETDATA.raphaelInitialize,
+ create: NETDATA.raphaelChartCreate,
+ update: NETDATA.raphaelChartUpdate,
+ resize: null,
+ setSelection: undefined, // function(state, t) { return true; },
+ clearSelection: undefined, // function(state) { return true; },
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'json'; },
+ options: function(state) { return ''; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 5000; },
+ track_colors: function(state) { return false; },
+ pixels_per_point: function(state) { return 3; }
+ },
+ "c3": {
+ initialize: NETDATA.c3Initialize,
+ create: NETDATA.c3ChartCreate,
+ update: NETDATA.c3ChartUpdate,
+ resize: null,
+ setSelection: undefined, // function(state, t) { return true; },
+ clearSelection: undefined, // function(state) { return true; },
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'csvjsonarray'; },
+ options: function(state) { return 'milliseconds'; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 5000; },
+ track_colors: function(state) { return false; },
+ pixels_per_point: function(state) { return 15; }
+ },
+ "d3": {
+ initialize: NETDATA.d3Initialize,
+ create: NETDATA.d3ChartCreate,
+ update: NETDATA.d3ChartUpdate,
+ resize: null,
+ setSelection: undefined, // function(state, t) { return true; },
+ clearSelection: undefined, // function(state) { return true; },
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'json'; },
+ options: function(state) { return ''; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 5000; },
+ track_colors: function(state) { return false; },
+ pixels_per_point: function(state) { return 3; }
+ },
+ "easypiechart": {
+ initialize: NETDATA.easypiechartInitialize,
+ create: NETDATA.easypiechartChartCreate,
+ update: NETDATA.easypiechartChartUpdate,
+ resize: null,
+ setSelection: NETDATA.easypiechartSetSelection,
+ clearSelection: NETDATA.easypiechartClearSelection,
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'array'; },
+ options: function(state) { return 'absolute'; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 5000; },
+ track_colors: function(state) { return true; },
+ pixels_per_point: function(state) { return 3; },
+ aspect_ratio: 100
+ },
+ "gauge": {
+ initialize: NETDATA.gaugeInitialize,
+ create: NETDATA.gaugeChartCreate,
+ update: NETDATA.gaugeChartUpdate,
+ resize: null,
+ setSelection: NETDATA.gaugeSetSelection,
+ clearSelection: NETDATA.gaugeClearSelection,
+ toolboxPanAndZoom: null,
+ initialized: false,
+ enabled: true,
+ format: function(state) { return 'array'; },
+ options: function(state) { return 'absolute'; },
+ legend: function(state) { return null; },
+ autoresize: function(state) { return false; },
+ max_updates_to_recreate: function(state) { return 5000; },
+ track_colors: function(state) { return true; },
+ pixels_per_point: function(state) { return 3; },
+ aspect_ratio: 70
+ }
+ };
+
+ NETDATA.registerChartLibrary = function(library, url) {
+ if(NETDATA.options.debug.libraries === true)
+ console.log("registering chart library: " + library);
+
+ NETDATA.chartLibraries[library].url = url;
+ NETDATA.chartLibraries[library].initialized = true;
+ NETDATA.chartLibraries[library].enabled = true;
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Load required JS libraries and CSS
+
+ NETDATA.requiredJs = [
+ {
+ url: NETDATA.serverDefault + 'lib/bootstrap.min.js',
+ isAlreadyLoaded: function() {
+ // check if bootstrap is loaded
+ if(typeof $().emulateTransitionEnd == 'function')
+ return true;
+ else {
+ if(typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap)
+ return true;
+ else
+ return false;
+ }
+ }
+ },
+ {
+ url: NETDATA.serverDefault + 'lib/jquery.nanoscroller.min.js',
+ isAlreadyLoaded: function() { return false; }
+ },
+ {
+ url: NETDATA.serverDefault + 'lib/bootstrap-toggle.min.js',
+ isAlreadyLoaded: function() { return false; }
+ }
+ ];
+
+ NETDATA.requiredCSS = [
+ {
+ url: NETDATA.themes.current.bootstrap_css,
+ isAlreadyLoaded: function() {
+ if(typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap)
+ return true;
+ else
+ return false;
+ }
+ },
+ {
+ url: NETDATA.serverDefault + 'css/font-awesome.min.css',
+ isAlreadyLoaded: function() { return false; }
+ },
+ {
+ url: NETDATA.themes.current.dashboard_css,
+ isAlreadyLoaded: function() { return false; }
+ },
+ {
+ url: NETDATA.serverDefault + 'css/bootstrap-toggle.min.css',
+ isAlreadyLoaded: function() { return false; }
+ }
+ ];
+
+ NETDATA.loadRequiredJs = function(index, callback) {
+ if(index >= NETDATA.requiredJs.length) {
+ if(typeof callback === 'function')
+ callback();
+ return;
+ }
+
+ if(NETDATA.requiredJs[index].isAlreadyLoaded()) {
+ NETDATA.loadRequiredJs(++index, callback);
+ return;
+ }
+
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('loading ' + NETDATA.requiredJs[index].url);
+
+ $.ajax({
+ url: NETDATA.requiredJs[index].url,
+ cache: true,
+ dataType: "script",
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .success(function() {
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('loaded ' + NETDATA.requiredJs[index].url);
+
+ NETDATA.loadRequiredJs(++index, callback);
+ })
+ .fail(function() {
+ alert('Cannot load required JS library: ' + NETDATA.requiredJs[index].url);
+ })
+ };
+
+ NETDATA.loadRequiredCSS = function(index) {
+ if(index >= NETDATA.requiredCSS.length)
+ return;
+
+ if(NETDATA.requiredCSS[index].isAlreadyLoaded()) {
+ NETDATA.loadRequiredCSS(++index);
+ return;
+ }
+
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('loading ' + NETDATA.requiredCSS[index].url);
+
+ NETDATA._loadCSS(NETDATA.requiredCSS[index].url);
+ NETDATA.loadRequiredCSS(++index);
+ };
+
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Registry of netdata hosts
+
+ NETDATA.alarms = {
+ current: null,
+ callback: null,
+
+ get: function(what, callback) {
+ $.ajax({
+ url: NETDATA.serverDefault + '/api/v1/alarms?' + what.toString(),
+ async: true,
+ cache: false,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(data) {
+ if(typeof callback === 'function')
+ callback(data);
+ })
+ .fail(function() {
+ NETDATA.error(415, host);
+
+ if(typeof callback === 'function')
+ callback(null);
+ });
+ },
+
+ update_forever: function() {
+ NETDATA.alarms.get('active', function(data) {
+ if(data !== null) {
+ NETDATA.alarms.current = data;
+
+ if (typeof NETDATA.alarms.callback === 'function') {
+ NETDATA.alarms.callback(data);
+ }
+ }
+
+ setTimeout(NETDATA.alarms.update_forever, 10000);
+ });
+ },
+
+ get_log: function(callback) {
+ $.ajax({
+ url: NETDATA.serverDefault + '/api/v1/alarm_log',
+ async: true,
+ cache: false,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(data) {
+ if(typeof callback === 'function')
+ callback(data);
+ })
+ .fail(function() {
+ NETDATA.error(416, host);
+
+ if(typeof callback === 'function')
+ callback(null);
+ });
+ },
+
+ init: function() {
+ NETDATA.alarms.update_forever();
+ }
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Registry of netdata hosts
+
+ NETDATA.registry = {
+ server: null, // the netdata registry server
+ person_guid: null, // the unique ID of this browser / user
+ machine_guid: null, // the unique ID the netdata server that served dashboard.js
+ hostname: null, // the hostname of the netdata server that served dashboard.js
+ machines: null, // the user's other URLs
+ machines_array: null, // the user's other URLs in an array
+ person_urls: null,
+
+ parsePersonUrls: function(person_urls) {
+ // console.log(person_urls);
+ NETDATA.registry.person_urls = person_urls;
+
+ if(person_urls) {
+ NETDATA.registry.machines = {};
+ NETDATA.registry.machines_array = new Array();
+
+ var now = new Date().getTime();
+ var apu = person_urls;
+ var i = apu.length;
+ while(i--) {
+ if(typeof NETDATA.registry.machines[apu[i][0]] === 'undefined') {
+ // console.log('adding: ' + apu[i][4] + ', ' + ((now - apu[i][2]) / 1000).toString());
+
+ var obj = {
+ guid: apu[i][0],
+ url: apu[i][1],
+ last_t: apu[i][2],
+ accesses: apu[i][3],
+ name: apu[i][4],
+ alternate_urls: new Array()
+ };
+ obj.alternate_urls.push(apu[i][1]);
+
+ NETDATA.registry.machines[apu[i][0]] = obj;
+ NETDATA.registry.machines_array.push(obj);
+ }
+ else {
+ // console.log('appending: ' + apu[i][4] + ', ' + ((now - apu[i][2]) / 1000).toString());
+
+ var pu = NETDATA.registry.machines[apu[i][0]];
+ if(pu.last_t < apu[i][2]) {
+ pu.url = apu[i][1];
+ pu.last_t = apu[i][2];
+ pu.name = apu[i][4];
+ }
+ pu.accesses += apu[i][3];
+ pu.alternate_urls.push(apu[i][1]);
+ }
+ }
+ }
+
+ if(typeof netdataRegistryCallback === 'function')
+ netdataRegistryCallback(NETDATA.registry.machines_array);
+ },
+
+ init: function() {
+ if(typeof netdataNoRegistry !== 'undefined' && netdataNoRegistry)
+ return;
+
+ NETDATA.registry.hello(NETDATA.serverDefault, function(data) {
+ if(data) {
+ NETDATA.registry.server = data.registry;
+ NETDATA.registry.machine_guid = data.machine_guid;
+ NETDATA.registry.hostname = data.hostname;
+
+ NETDATA.registry.access(2, function (person_urls) {
+ NETDATA.registry.parsePersonUrls(person_urls);
+
+ });
+ }
+ });
+ },
+
+ hello: function(host, callback) {
+ while(host.slice(-1) === '/')
+ host = host.substring(0, host.length - 1);
+
+ // send HELLO to a netdata server:
+ // 1. verifies the server is reachable
+ // 2. responds with the registry URL, the machine GUID of this netdata server and its hostname
+ $.ajax({
+ url: host + '/api/v1/registry?action=hello',
+ async: true,
+ cache: false,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(data) {
+ if(typeof data.status !== 'string' || data.status !== 'ok') {
+ NETDATA.error(408, host + ' response: ' + JSON.stringify(data));
+ data = null;
+ }
+
+ if(typeof callback === 'function')
+ callback(data);
+ })
+ .fail(function() {
+ NETDATA.error(407, host);
+
+ if(typeof callback === 'function')
+ callback(null);
+ });
+ },
+
+ access: function(max_redirects, callback) {
+ // send ACCESS to a netdata registry:
+ // 1. it lets it know we are accessing a netdata server (its machine GUID and its URL)
+ // 2. it responds with a list of netdata servers we know
+ // the registry identifies us using a cookie it sets the first time we access it
+ // the registry may respond with a redirect URL to send us to another registry
+ $.ajax({
+ url: NETDATA.registry.server + '/api/v1/registry?action=access&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault), // + '&visible_url=' + encodeURIComponent(document.location),
+ async: true,
+ cache: false,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(data) {
+ var redirect = null;
+ if(typeof data.registry === 'string')
+ redirect = data.registry;
+
+ if(typeof data.status !== 'string' || data.status !== 'ok') {
+ NETDATA.error(409, NETDATA.registry.server + ' responded with: ' + JSON.stringify(data));
+ data = null;
+ }
+
+ if(data === null) {
+ if(redirect !== null && max_redirects > 0) {
+ NETDATA.registry.server = redirect;
+ NETDATA.registry.access(max_redirects - 1, callback);
+ }
+ else {
+ if(typeof callback === 'function')
+ callback(null);
+ }
+ }
+ else {
+ if(typeof data.person_guid === 'string')
+ NETDATA.registry.person_guid = data.person_guid;
+
+ if(typeof callback === 'function')
+ callback(data.urls);
+ }
+ })
+ .fail(function() {
+ NETDATA.error(410, NETDATA.registry.server);
+
+ if(typeof callback === 'function')
+ callback(null);
+ });
+ },
+
+ delete: function(delete_url, callback) {
+ // send DELETE to a netdata registry:
+ $.ajax({
+ url: NETDATA.registry.server + '/api/v1/registry?action=delete&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault) + '&delete_url=' + encodeURIComponent(delete_url),
+ async: true,
+ cache: false,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(data) {
+ if(typeof data.status !== 'string' || data.status !== 'ok') {
+ NETDATA.error(411, NETDATA.registry.server + ' responded with: ' + JSON.stringify(data));
+ data = null;
+ }
+
+ if(typeof callback === 'function')
+ callback(data);
+ })
+ .fail(function() {
+ NETDATA.error(412, NETDATA.registry.server);
+
+ if(typeof callback === 'function')
+ callback(null);
+ });
+ },
+
+ switch: function(new_person_guid, callback) {
+ // impersonate
+ $.ajax({
+ url: NETDATA.registry.server + '/api/v1/registry?action=switch&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault) + '&to=' + new_person_guid,
+ async: true,
+ cache: false,
+ xhrFields: { withCredentials: true } // required for the cookie
+ })
+ .done(function(data) {
+ if(typeof data.status !== 'string' || data.status !== 'ok') {
+ NETDATA.error(413, NETDATA.registry.server + ' responded with: ' + JSON.stringify(data));
+ data = null;
+ }
+
+ if(typeof callback === 'function')
+ callback(data);
+ })
+ .fail(function() {
+ NETDATA.error(414, NETDATA.registry.server);
+
+ if(typeof callback === 'function')
+ callback(null);
+ });
+ }
+ };
+
+ // ----------------------------------------------------------------------------------------------------------------
+ // Boot it!
+
+ NETDATA.errorReset();
+ NETDATA.loadRequiredCSS(0);
+
+ NETDATA._loadjQuery(function() {
+ NETDATA.loadRequiredJs(0, function() {
+ if(typeof $().emulateTransitionEnd !== 'function') {
+ // bootstrap is not available
+ NETDATA.options.current.show_help = false;
+ }
+
+ if(typeof netdataDontStart === 'undefined' || !netdataDontStart) {
+ if(NETDATA.options.debug.main_loop === true)
+ console.log('starting chart refresh thread');
+
+ NETDATA.start();
+ }
+ });
+ });
+
+ // window.NETDATA = NETDATA;
// })(window, document);
diff --git a/web/dashboard.slate.css b/web/dashboard.slate.css
index 0536a3ed6..9223958ae 100644
--- a/web/dashboard.slate.css
+++ b/web/dashboard.slate.css
@@ -14,6 +14,19 @@ body {
border-left: 2px solid #765d9c;
}
+.morelink {
+ color: #765d9c;
+ text-decoration: none;
+}
+.morelink:hover {
+ color: #563d7c;
+ text-decoration: none;
+}
+.morelink:focus {
+ color: #765d9c;
+ text-decoration: none;
+}
+
.netdata-chart-alignment {
margin-left: 55px;
}
diff --git a/web/demo.html b/web/demo.html
index 4b91d8394..89bcb68c7 100644
--- a/web/demo.html
+++ b/web/demo.html
@@ -1,42 +1,51 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <title>NetData Dashboard</title>
+ <title>NetData Dashboard</title>
+ <meta name="application-name" content="netdata">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <meta name="author" content="costa@tsaousis.gr">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+ <meta name="author" content="costa@tsaousis.gr">
- <script type="text/javascript" src="dashboard.js?v37"></script>
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image" content="https://my-netdata.io/images/seo-performance-512.png"/>
+ <meta property="og:url" content="http://my-netdata.io/"/>
+ <meta property="og:type" content="website"/>
+ <meta property="og:site_name" content="netdata"/>
+ <meta property="og:title" content="netdata - real-time performance monitoring, done right!"/>
+ <meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
+
+ <script type="text/javascript" src="dashboard.js?v42"></script>
</head>
<body>
<div style="width: 100%; text-align: center;">
- <div data-netdata="netdata.server_cpu"
- data-dimensions="user"
- data-chart-library="gauge"
- data-width="150px"
- data-after="-60"
- data-points="60"
- data-title="Yes! Realtime!"
- data-units="I am alive!"
- data-colors="#FF5555"
- ></div>
- <br/>
- <div data-netdata="netdata.server_cpu"
- data-dimensions="user"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-width="200px"
- data-height="30px"
- data-after="-60"
- data-points="60"
- data-colors="#FF5555"
- ></div>
+ <div data-netdata="netdata.server_cpu"
+ data-dimensions="user"
+ data-chart-library="gauge"
+ data-width="150px"
+ data-after="-60"
+ data-points="60"
+ data-title="Yes! Realtime!"
+ data-units="I am alive!"
+ data-colors="#FF5555"
+ ></div>
+ <br/>
+ <div data-netdata="netdata.server_cpu"
+ data-dimensions="user"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-width="200px"
+ data-height="30px"
+ data-after="-60"
+ data-points="60"
+ data-colors="#FF5555"
+ ></div>
</div>
</body>
</html>
diff --git a/web/demo2.html b/web/demo2.html
index 9530d914e..5f8136ce5 100644
--- a/web/demo2.html
+++ b/web/demo2.html
@@ -1,134 +1,143 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <title>NetData Dashboard</title>
+ <title>NetData Dashboard</title>
+ <meta name="application-name" content="netdata">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <meta name="author" content="costa@tsaousis.gr">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+ <meta name="author" content="costa@tsaousis.gr">
- <script>var netdataTheme = 'slate';</script>
- <script type="text/javascript" src="dashboard.js?v37"></script>
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image" content="https://my-netdata.io/images/seo-performance-512.png"/>
+ <meta property="og:url" content="http://my-netdata.io/"/>
+ <meta property="og:type" content="website"/>
+ <meta property="og:site_name" content="netdata"/>
+ <meta property="og:title" content="netdata - real-time performance monitoring, done right!"/>
+ <meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
+
+ <script>var netdataTheme = 'slate';</script>
+ <script type="text/javascript" src="http://my-netdata.io/dashboard.js?v42"></script>
</head>
<body>
<div class="container" style="width: 90%; padding-top: 10px; text-align: center; color: #AAA">
- <div style="font-size: 7vw;">why netdata?</div>
- <br/>
- <div style="font-size: 2vw; color: white;">These charts visualize the same data...</div>
+ <div style="font-size: 7vw;">why netdata?</div>
+ <br/>
+ <div style="font-size: 2vw; color: white;">These charts visualize the same data...</div>
- <!-- Nav tabs -->
- <ul class="nav nav-tabs" role="tablist">
- <li role="presentation" class="active"><a href="#gauge" aria-controls="gauge" role="tab" data-toggle="tab">Gauge.js</a></li>
- <li role="presentation"><a href="#easypiechart" aria-controls="easypiechart" role="tab" data-toggle="tab">Easy Pie Chart</a></li>
- </ul>
+ <!-- Nav tabs -->
+ <ul class="nav nav-tabs" role="tablist">
+ <li role="presentation" class="active"><a href="#gauge" aria-controls="gauge" role="tab" data-toggle="tab">Gauge.js</a></li>
+ <li role="presentation"><a href="#easypiechart" aria-controls="easypiechart" role="tab" data-toggle="tab">Easy Pie Chart</a></li>
+ </ul>
- <!-- Tab panes -->
- <div class="tab-content">
- <div role="tabpanel" class="tab-pane active" id="gauge">
+ <!-- Tab panes -->
+ <div class="tab-content">
+ <div role="tabpanel" class="tab-pane active" id="gauge">
- <div style="display: inline-block; width: 35.8%">
- <div style="font-size: 1.2vw; color: #666; padding-top: 10px;"><i class="fa fa-comment"></i> I can trace an issue like this</div>
- <br/>
- <div data-netdata="example.random2"
- data-dimensions="random"
- data-chart-library="gauge"
- data-gauge-max-value="32767"
- data-width="100%"
- data-after="-600"
- data-points="600"
- data-title="1/second (netdata&nbsp;default)"
- data-units="important metric"
- data-colors="#5A5"
- ></div>
- </div>
- <div style="display: inline-block; width: 50%">
- <div style="font-size: 1.2vw; color: #666;"><i class="fa fa-comment"></i> Can you trace an issue like these?<br/>&nbsp;<br/></div>
- <div data-netdata="example.random2"
- data-dimensions="random"
- data-chart-library="gauge"
- data-gauge-max-value="32767"
- data-width="45%"
- data-after="-600"
- data-points="40"
- data-title="Updates Every 15&nbsp;Sec"
- data-units="important metric"
- data-colors="#C55"
- ></div>
- <div data-netdata="example.random2"
- data-dimensions="random"
- data-chart-library="gauge"
- data-gauge-max-value="32767"
- data-width="45%"
- data-after="-600"
- data-points="2"
- data-title="Updates Every 5&nbsp;Mins"
- data-units="important metric"
- data-colors="#C55"
- ></div>
- </div>
- </div>
- <div role="tabpanel" class="tab-pane" id="easypiechart">
+ <div style="display: inline-block; width: 35.8%">
+ <div style="font-size: 1.2vw; color: #666; padding-top: 10px;"><i class="fa fa-comment"></i> I can trace an issue like this</div>
+ <br/>
+ <div data-netdata="example.random2"
+ data-dimensions="random"
+ data-chart-library="gauge"
+ data-gauge-max-value="32767"
+ data-width="100%"
+ data-after="-600"
+ data-points="600"
+ data-title="1/second (netdata&nbsp;default)"
+ data-units="important metric"
+ data-colors="#5A5"
+ ></div>
+ </div>
+ <div style="display: inline-block; width: 50%">
+ <div style="font-size: 1.2vw; color: #666;"><i class="fa fa-comment"></i> Can you trace an issue like these?<br/>&nbsp;<br/></div>
+ <div data-netdata="example.random2"
+ data-dimensions="random"
+ data-chart-library="gauge"
+ data-gauge-max-value="32767"
+ data-width="45%"
+ data-after="-600"
+ data-points="60"
+ data-title="Updates Every 10&nbsp;Sec"
+ data-units="important metric"
+ data-colors="#C55"
+ ></div>
+ <div data-netdata="example.random2"
+ data-dimensions="random"
+ data-chart-library="gauge"
+ data-gauge-max-value="32767"
+ data-width="45%"
+ data-after="-600"
+ data-points="2"
+ data-title="Updates Every 5&nbsp;Mins"
+ data-units="important metric"
+ data-colors="#C55"
+ ></div>
+ </div>
+ </div>
+ <div role="tabpanel" class="tab-pane" id="easypiechart">
- <div style="display: inline-block; width: 25%">
- <div style="font-size: 1.2vw; color: #666; padding-top: 10px;"><i class="fa fa-comment"></i> I can trace an issue like this</div>
- <br/>
- <div data-netdata="example.random2"
- data-dimensions="random"
- data-chart-library="easypiechart"
- data-easypiechart-max-value="32767"
- data-width="100%"
- data-after="-600"
- data-points="600"
- data-title="1/second (netdata&nbsp;default)"
- data-units="important metric"
- data-colors="#5A5"
- ></div>
- </div>
- <div style="display: inline-block; width: 40%">
- <div style="font-size: 1.2vw; color: #666;"><i class="fa fa-comment"></i> Can you trace an issue like these?<br/>&nbsp;<br/></div>
- <div data-netdata="example.random2"
- data-dimensions="random"
- data-chart-library="easypiechart"
- data-easypiechart-max-value="32767"
- data-width="45%"
- data-after="-600"
- data-points="40"
- data-title="Updates Every 15&nbsp;Sec&nbsp;(<a href='https://github.com/OpenTSDB/opentsdb.net/blob/gh-pages/docs/source/user_guide/utilities/tcollector.rst#collecting-lots-of-metrics-with-tcollector' target='_blank'>OpenTSDB</a>)"
- data-units="important metric"
- data-colors="#C55"
- ></div>
- <div data-netdata="example.random2"
- data-dimensions="random"
- data-chart-library="easypiechart"
- data-easypiechart-max-value="32767"
- data-width="45%"
- data-after="-600"
- data-points="2"
- data-title="Updates Every 5&nbsp;Mins&nbsp;(your&nbsp;NMS)"
- data-units="important metric"
- data-colors="#C55"
- ></div>
- </div>
- </div>
- </div>
- <div style="font-size: 1.5vw;">Hover on the chart below, to see the selected value on the charts above!</div>
- <div data-netdata="example.random2"
- data-dimensions="random"
- data-dygraph-theme="sparkline"
- data-width="100%"
- data-height="20vh"
- data-after="-600"
- data-points="600"
- data-title="1/second (netdata&nbsp;default)"
- data-units="something"
- data-colors="#888"
- ></div>
+ <div style="display: inline-block; width: 25%">
+ <div style="font-size: 1.2vw; color: #666; padding-top: 10px;"><i class="fa fa-comment"></i> I can trace an issue like this</div>
+ <br/>
+ <div data-netdata="example.random2"
+ data-dimensions="random"
+ data-chart-library="easypiechart"
+ data-easypiechart-max-value="32767"
+ data-width="100%"
+ data-after="-600"
+ data-points="600"
+ data-title="1/second (netdata&nbsp;default)"
+ data-units="important metric"
+ data-colors="#5A5"
+ ></div>
+ </div>
+ <div style="display: inline-block; width: 40%">
+ <div style="font-size: 1.2vw; color: #666;"><i class="fa fa-comment"></i> Can you trace an issue like these?<br/>&nbsp;<br/></div>
+ <div data-netdata="example.random2"
+ data-dimensions="random"
+ data-chart-library="easypiechart"
+ data-easypiechart-max-value="32767"
+ data-width="45%"
+ data-after="-600"
+ data-points="60"
+ data-title="Updates Every 10&nbsp;Sec"
+ data-units="important metric"
+ data-colors="#C55"
+ ></div>
+ <div data-netdata="example.random2"
+ data-dimensions="random"
+ data-chart-library="easypiechart"
+ data-easypiechart-max-value="32767"
+ data-width="45%"
+ data-after="-600"
+ data-points="2"
+ data-title="Updates Every 5&nbsp;Mins"
+ data-units="important metric"
+ data-colors="#C55"
+ ></div>
+ </div>
+ </div>
+ </div>
+ <div style="font-size: 1.5vw;">Hover on the chart below, to see the selected value on the charts above!</div>
+ <div data-netdata="example.random2"
+ data-dimensions="random"
+ data-dygraph-theme="sparkline"
+ data-width="100%"
+ data-height="20vh"
+ data-after="-600"
+ data-points="600"
+ data-title="1/second (netdata&nbsp;default)"
+ data-units="something"
+ data-colors="#888"
+ ></div>
</div>
</body>
</html>
diff --git a/web/demosites.html b/web/demosites.html
index f5047f4b2..d57bb4e71 100644
--- a/web/demosites.html
+++ b/web/demosites.html
@@ -1,721 +1,1045 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <title>NetData - Real-time performance monitoring, done right!</title>
+ <title>NetData - Real-time performance monitoring, done right!</title>
+ <meta name="application-name" content="netdata">
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <script>
- // --- OPTIONS FOR THE DASHBOARD --
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image" content="https://my-netdata.io/images/seo-performance-512.png"/>
+ <meta property="og:url" content="http://my-netdata.io/"/>
+ <meta property="og:type" content="website"/>
+ <meta property="og:site_name" content="netdata"/>
+ <meta property="og:title" content="netdata - real-time performance monitoring, done right!"/>
+ <meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
- // this section has to appear before loading dashboard.js
+ <script>
+ // --- OPTIONS FOR THE DASHBOARD --
- // Select a theme.
- // uncomment on of the two themes:
+ // this section has to appear before loading dashboard.js
- // var netdataTheme = 'default'; // this is white
- var netdataTheme = 'slate'; // this is dark
+ // Select a theme.
+ // uncomment on of the two themes:
+ // var netdataTheme = 'default'; // this is white
+ var netdataTheme = 'slate'; // this is dark
- // Set the default netdata server.
- // on charts without a 'data-host', this one will be used.
- // the default is the server that dashboard.js is downloaded from.
- // var netdataServer = 'http://my.server:19999/';
- </script>
+ // Set the default netdata server.
+ // on charts without a 'data-host', this one will be used.
+ // the default is the server that dashboard.js is downloaded from.
- <!--
- --- LOAD dashboard.js ---
+ // var netdataServer = 'http://my.server:19999/';
+ </script>
- to host this HTML file on your web server,
- you have to load dashboard.js from the netdata server.
+ <!--
+ --- LOAD dashboard.js ---
- So, pick one the two below
- If you pick the first, set the server name/IP.
+ to host this HTML file on your web server,
+ you have to load dashboard.js from the netdata server.
- The second assumes you host this file on /usr/share/netdata/web
- and that you have chown it to be owned by netdata:netdata
- -->
- <!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
- <script type="text/javascript" src="dashboard.js?v37"></script>
+ So, pick one the two below
+ If you pick the first, set the server name/IP.
- <script>
- // --- OPTIONS FOR THE CHARTS --
+ The second assumes you host this file on /usr/share/netdata/web
+ and that you have chown it to be owned by netdata:netdata
+ -->
+ <!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
+ <script type="text/javascript" src="dashboard.js?v42"></script>
- // destroy charts not shown (lowers memory on the browsers)
- // set this to 'yes' to destroy, 'false' to hide the charts
- NETDATA.options.current.destroy_on_hide = false;
-
- // set this to false, to always show all dimensions
- NETDATA.options.current.eliminate_zero_dimensions = true;
-
- // set this to false, to lower the pressure on the browser
- NETDATA.options.current.concurrent_refreshes = true;
+ <script>
+ // --- OPTIONS FOR THE CHARTS --
- // if you need to support slow mobile phones, set this to false
- NETDATA.options.current.parallel_refresher = true;
+ // destroy charts not shown (lowers memory on the browsers)
+ // set this to 'true' to destroy, 'false' to hide the charts
+ NETDATA.options.current.destroy_on_hide = true;
+
+ // set this to false, to always show all dimensions
+ NETDATA.options.current.eliminate_zero_dimensions = true;
+
+ // set this to false, to lower the pressure on the browser
+ NETDATA.options.current.concurrent_refreshes = false;
- // set this to false, to always update the charts, even if focus is lost
- NETDATA.options.current.stop_updates_when_focus_is_lost = true;
- </script>
+ // if you need to support slow mobile phones, set this to false
+ NETDATA.options.current.parallel_refresher = true;
- <style>
+ // set this to false, to always update the charts, even if focus is lost
+ NETDATA.options.current.stop_updates_when_focus_is_lost = true;
+ </script>
+
+ <style>
body {
- font-size: 1vw;
+ font-size: 1vw;
}
.mysparkline {
- position: relative;
- display: inline-block;
- min-height: 50px;
- width: 100%;
- height: 8vmax;
- text-align: left;
+ position: relative;
+ display: inline-block;
+ min-height: 50px;
+ width: 100%;
+ height: 8vmax;
+ text-align: left;
}
.mysparkline-overchart-label {
- position: absolute;
- display: block;
- top: 0;
- left: 10px;
- bottom: 0;
- right: 0;
- font-size: 1vmax;
- z-index: 1;
+ position: absolute;
+ display: block;
+ top: 0;
+ left: 10px;
+ bottom: 0;
+ right: 0;
+ font-size: 1vmax;
+ z-index: 1;
}
.mysparkline-overchart-value {
- position: absolute;
- display: block;
- top: 1.1vmax;
- left: 10px;
- bottom: 0;
- right: 0;
- font-size: 5vmax;
- z-index: 2;
- text-shadow: #333 0px 0px 2px;
+ position: absolute;
+ display: block;
+ top: 1.1vmax;
+ left: 10px;
+ bottom: 0;
+ right: 0;
+ font-size: 5vmax;
+ z-index: 2;
+ text-shadow: #333 0px 0px 2px;
}
.myfullchart {
- position: relative;
- display: inline-block;
- width: 100%;
- height: 14vmax;
- min-height: 150px;
- text-align: left;
+ position: relative;
+ display: inline-block;
+ width: 100%;
+ height: 14vmax;
+ min-height: 150px;
+ text-align: left;
}
.mygauge-combo {
- display: inline-block;
+ display: inline-block;
}
.mygauge {
- position: relative;
- display: block;
- width: 20vw;
- height: 12vw;
+ position: relative;
+ display: block;
+ width: 18vw;
+ height: 11vw;
}
.mygauge-button {
- display: block;
+ display: block;
}
.mytitle {
- padding-top: 6vw;
- padding-bottom: 1vw;
- text-align: center;
- font-size: 2.4vw;
+ padding-top: 6vw;
+ padding-bottom: 1vw;
+ text-align: center;
+ font-size: 2.4vw;
}
.mysubtitle {
- padding-top: 2vw;
- padding-bottom: 1vw;
- text-align: center;
- font-size: 1.8vw;
+ padding-top: 2vw;
+ padding-bottom: 1vw;
+ text-align: center;
+ font-size: 1.8vw;
}
.mycontent {
- text-align: center;
- font-size: 1.5vw;
+ text-align: center;
+ font-size: 1.5vw;
}
@media only screen and (min-width : 992px) {
- .container {
- width: 90%;
- }
+ .container {
+ width: 90%;
+ }
}
@media only screen and (max-width : 992px) {
- .container {
- width: 100%;
- }
+ .container {
+ width: 100%;
+ }
}
- </style>
+ </style>
</head>
<body style="text-align: center;">
<div class="container">
- <div style="text-align: center; font-size: 13vw; height: 14vw;">
- <b>netdata</b>
- </div>
- <div style="text-align: center; font-size: 2vw; height: 2.5vw;">
- real-time performance monitoring
- </div>
- <div style="width:80%; text-align: right; font-size: 2.7vw;">
- <strong>scaled out</strong>!
- </div>
- <div class="mytitle">
- pick a <b>netdata</b> demo server
- </div>
- <div class="mycontent">
- these demo servers show what you will get by installing <b>netdata</b>
- </div>
-
- <div style="width: 100%; text-align: center; padding-top: 2vw;">
- <div style="width: 100%; text-align: center;">
-
- <div class="mygauge-combo">
- <div class="mygauge">
- <div data-netdata="netdata.requests"
- data-host="//london.my-netdata.io"
- data-title="EU - London"
- data-chart-library="gauge"
- data-width="100%"
- data-after="-300"
- data-points="300"
- data-colors="#558855"
- ></div>
- </div>
- <div class="mygauge-button">
- <br/>&nbsp;<br/>
- <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//london.my-netdata.io/default.html'" style="font-size: 1.5vw;">Enter London!</button>
- <div style="font-size: 1vw;">
- Donated by DigitalOcean.com
- </div>
- </div>
- </div>
- <div class="mygauge-combo">
- <div class="mygauge">
- <div data-netdata="netdata.requests"
- data-host="//atlanta.my-netdata.io"
- data-title="US - Atlanta"
- data-chart-library="gauge"
- data-width="100%"
- data-after="-300"
- data-points="300"
- data-colors="#AA5555"
- ></div>
- </div>
- <div class="mygauge-button">
- <br/>&nbsp;<br/>
- <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//atlanta.my-netdata.io/default.html'" style="font-size: 1.5vw;">Enter Atlanta!</button>
- <div style="font-size: 1vw;">
- Donated by CDN77.com
- </div>
- </div>
- </div>
- <div class="mygauge-combo">
- <div class="mygauge">
- <div data-netdata="netdata.requests"
- data-host="//athens.my-netdata.io"
- data-title="EU - Greece"
- data-chart-library="gauge"
- data-width="100%"
- data-after="-300"
- data-points="300"
- data-colors="#5555AA"
- ></div>
- </div>
- <div class="mygauge-button">
- <br/>&nbsp;<br/>
- <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//athens.my-netdata.io/default.html'" style="font-size: 1.5vw;">Come to Greece!</button>
- <div style="font-size: 0.8vw;">
- &nbsp;
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="mytitle">
- this page is a custom <b>netdata</b> dashboard
- </div>
- <div class="mycontent">
- charts are coming from 3 servers, in parallel
- <br/>
- the servers are not aware of this multi-server dashboard,
- <br/>
- each server is not aware of the other 2 servers,
- <br/>
- but on this dashboard <b>they are one</b>!
- </div>
- <div style="padding-top: 1vw; width: 100%; text-align: center; font-size: 1.5vw;">
- <i class="fa fa-comment" aria-hidden="true"></i>
- hover on a chart below, or drag it to show the past - <b>the others will follow</b>!
- <br/>
- double click on a chart to reset them all
- </div>
-
- <div class="mytitle">
- our <code>ngnix</code> performance
- </div>
- <div class="mycontent">
- (we proxy netdata through nginx, on the demo sites)
- </div>
-
- <!-- Nav tabs -->
- <ul class="nav nav-tabs" role="tablist" style="padding-top: 1vw;">
- <li role="presentation" class="active"><a href="#nginx_requests" aria-controls="nginx_requests" role="tab" data-toggle="tab">Requests</a></li>
- <li role="presentation"><a href="#nginx_connections" aria-controls="nginx_connections" role="tab" data-toggle="tab">Connections</a></li>
- </ul>
-
- <!-- Tab panes -->
- <div class="tab-content">
- <div role="tabpanel" class="tab-pane active" id="nginx_requests">
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>EU - London</b> web requests/s
- </div>
- <div class="mysparkline-overchart-value" id="nginx.requests.netdata" >
- </div>
- <div data-netdata="nginx.requests"
- data-dimensions="requests"
- data-host="//london.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#558855"
- data-show-value-of-requests-at="nginx.requests.netdata"
- ></div>
- </div>
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>US - Atlanta</b> web requests/s
- </div>
- <div class="mysparkline-overchart-value" id="nginx.requests.netdata2" >
- </div>
- <div data-netdata="nginx.requests"
- data-dimensions="requests"
- data-host="//atlanta.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#AA5555"
- data-show-value-of-requests-at="nginx.requests.netdata2"
- ></div>
- </div>
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>EU - Greece</b> web requests/s
- </div>
- <div class="mysparkline-overchart-value" id="nginx.requests.netdata3" >
- </div>
- <div data-netdata="nginx.requests"
- data-dimensions="requests"
- data-host="//athens.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#5555AA"
- data-show-value-of-requests-at="nginx.requests.netdata3"
- ></div>
- </div>
- </div>
-
- <div role="tabpanel" class="tab-pane" id="nginx_connections">
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>EU - London</b> active connections
- </div>
- <div class="mysparkline-overchart-value" id="nginx.connections.netdata1" >
- </div>
- <div data-netdata="nginx.connections"
- data-dimensions="active"
- data-host="//london.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#558855"
- data-show-value-of-active-at="nginx.connections.netdata1"
- ></div>
- </div>
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>US - Atlanta</b> active connections
- </div>
- <div class="mysparkline-overchart-value" id="nginx.connections.netdata2" >
- </div>
- <div data-netdata="nginx.connections"
- data-dimensions="active"
- data-host="//atlanta.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#AA5555"
- data-show-value-of-active-at="nginx.connections.netdata2"
- ></div>
- </div>
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>EU - Greece</b> active connections
- </div>
- <div class="mysparkline-overchart-value" id="nginx.connections.netdata3" >
- </div>
- <div data-netdata="nginx.connections"
- data-dimensions="active"
- data-host="//athens.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#5555AA"
- data-show-value-of-active-at="nginx.connections.netdata3"
- ></div>
- </div>
- </div>
- </div>
-
- <div style="width: 100%; text-align: right; font-size: 1vw;">
- <i class="fa fa-comment" aria-hidden="true"></i> these charts are draggable and touchable, double click them to reset them
- </div>
-
-
- <div class="mytitle">
- bandwidth consumption on the demo sites
- </div>
- <div class="mycontent">
- Linux QoS is configured by <a href="https://github.com/firehol/netdata/wiki/You-should-install-QoS-on-all-your-servers">FireQOS</a>
- </div>
-
- <!-- Nav tabs -->
- <ul class="nav nav-tabs" role="tablist" style="padding-top: 1vw;">
- <li role="presentation" class="active"><a href="#outbout" aria-controls="outbout" role="tab" data-toggle="tab">Outbound</a></li>
- <li role="presentation"><a href="#inbound" aria-controls="inbound" role="tab" data-toggle="tab">Inbound</a></li>
- </ul>
-
- <!-- Tab panes -->
- <div class="tab-content">
- <div role="tabpanel" class="tab-pane active" id="outbout">
- <div class="myfullchart">
- <div data-netdata="tc.world_out"
- data-host="//london.my-netdata.io"
- data-chart-library="dygraph"
- data-title="EU - London, traffic we send per service"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
-
- <div class="myfullchart">
- <div data-netdata="tc.world_out"
- data-host="//atlanta.my-netdata.io"
- data-chart-library="dygraph"
- data-title="US - Atlanta, traffic we send per service"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
-
- </div>
-
- <div class="myfullchart">
- <div data-netdata="tc.world_out"
- data-host="//athens.my-netdata.io"
- data-chart-library="dygraph"
- data-title="EU - Greece, traffic we send per service"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
- </div>
- <div role="tabpanel" class="tab-pane" id="inbound">
- <div class="myfullchart">
- <div data-netdata="tc.world_in"
- data-host="//london.my-netdata.io"
- data-chart-library="dygraph"
- data-title="EU - London, traffic we receive per service"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
-
- </div>
-
- <div class="myfullchart">
- <div data-netdata="tc.world_in"
- data-host="//atlanta.my-netdata.io"
- data-chart-library="dygraph"
- data-title="US - Atlanta, traffic we receive per service"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
-
- </div>
-
- <div class="myfullchart">
- <div data-netdata="tc.world_in"
- data-host="//athens.my-netdata.io"
- data-chart-library="dygraph"
- data-title="EU - Greece, traffic we receive per service"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
- </div>
- </div>
- <div style="width: 100%; text-align: right; font-size: 1vw;">
- <i class="fa fa-comment" aria-hidden="true"></i> <i>these legends are interactive and the charts are resizable here ^^^</i>
- </div>
-
- <div class="mytitle">
- DDoS protection performance on the demo sites
- </div>
- <div class="mycontent">
- iptables SYNPROXY configured by <a href="https://github.com/firehol/netdata/wiki/Monitoring-SYNPROXY">FireHOL</a>
- </div>
-
- <div style="padding-top: 4vw; width: 100%; text-align: center; font-size: 1.5vw;">
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>EU - London</b>, TCP SYN packets/s received
- </div>
- <div class="mysparkline-overchart-value" id="netfilter.synproxy_syn_received.netdata1" >
- </div>
- <div data-netdata="netfilter.synproxy_syn_received"
- data-dimensions="received"
- data-host="//london.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#558855"
- data-show-value-of-received-at="netfilter.synproxy_syn_received.netdata1"
- ></div>
- </div>
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>US - Atlanta</b>, TCP SYN packets/s received
- </div>
- <div class="mysparkline-overchart-value" id="netfilter.synproxy_syn_received.netdata2" >
- </div>
- <div data-netdata="netfilter.synproxy_syn_received"
- data-dimensions="received"
- data-host="//atlanta.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#885555"
- data-show-value-of-received-at="netfilter.synproxy_syn_received.netdata2"
- ></div>
- </div>
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>EU - Greece</b>, TCP SYN packets/s received
- </div>
- <div class="mysparkline-overchart-value" id="netfilter.synproxy_syn_received.netdata3" >
- </div>
- <div data-netdata="netfilter.synproxy_syn_received"
- data-dimensions="received"
- data-host="//athens.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#555588"
- data-show-value-of-received-at="netfilter.synproxy_syn_received.netdata3"
- ></div>
- </div>
- </div>
- <div style="width: 100%; text-align: right; font-size: 1vw;">
- <i class="fa fa-comment" aria-hidden="true"></i> <i>did you notice the decimal numbers?
- <br/>netdata interpolates collected values at second boundaries, with nanosecond detail!</i>
- </div>
-
-
- <div class="mytitle">
- CPU Utilization of the demo sites
- </div>
-
- <div style="padding-top: 1vw;">
- <div class="myfullchart">
- <div data-netdata="system.cpu"
- data-host="//london.my-netdata.io"
- data-chart-library="dygraph"
- data-title="EU - London, CPU Usage"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
-
- <div class="myfullchart">
- <div data-netdata="system.cpu"
- data-host="//atlanta.my-netdata.io"
- data-chart-library="dygraph"
- data-title="US - Atlanta, CPU Usage"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
-
- <div class="myfullchart">
- <div data-netdata="system.cpu"
- data-host="//athens.my-netdata.io"
- data-chart-library="dygraph"
- data-title="EU - Greece, CPU Usage"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
- </div>
- <div style="width: 100%; text-align: right; font-size: 1vw;">
- <i class="fa fa-comment" aria-hidden="true"></i> <i>what is using so much CPU?
- <br/>The site <a href="//iplists.firehol.org/">iplists.firehol.org</a> is maintained by FireHOL - the CPU is used for comparing security IP Lists.</i>
- </div>
-
- <div class="mytitle">
- CPU Usage of the netdata user
- </div>
- <div class="mycontent">
- netdata monitors <b>users</b>, <b>user groups</b>, <b>applications (process trees)</b>
- <br/>
- and <b>containers</b> (<code>lxc</code>, <code>docker</code>, etc.)
- </div>
-
- <div style="padding-top: 4vw; width: 100%; text-align: center; font-size: 1.5vw;">
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>EU - London</b>, CPU % of a single core
- </div>
- <div class="mysparkline-overchart-value" id="users.cpu.netdata1" >
- </div>
- <div data-netdata="users.cpu"
- data-dimensions="netdata"
- data-host="//london.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#558855"
- data-show-value-of-netdata-at="users.cpu.netdata1"
- ></div>
- </div>
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>US - Atlanta</b>, CPU % of a single core
- </div>
- <div class="mysparkline-overchart-value" id="users.cpu.netdata2" >
- </div>
- <div data-netdata="users.cpu"
- data-dimensions="netdata"
- data-host="//atlanta.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#885555"
- data-show-value-of-netdata-at="users.cpu.netdata2"
- ></div>
- </div>
-
- <div class="mysparkline">
- <div class="mysparkline-overchart-label">
- <b>EU - Greece</b>, CPU % of a single core
- </div>
- <div class="mysparkline-overchart-value" id="users.cpu.netdata3" >
- </div>
- <div data-netdata="users.cpu"
- data-dimensions="netdata"
- data-host="//athens.my-netdata.io"
- data-chart-library="dygraph"
- data-dygraph-theme="sparkline"
- data-dygraph-type="area"
- data-width="100%"
- data-height="100%"
- data-after="-300"
- data-colors="#555588"
- data-show-value-of-netdata-at="users.cpu.netdata3"
- ></div>
- </div>
- </div>
- <div style="width: 100%; text-align: right; font-size: 1vw;">
- <i class="fa fa-comment" aria-hidden="true"></i> <i>this utilization is about the whole netdata process tree and the percentage is of <b>a single core</b>!
- <br/>including <b>BASH</b> plugins (it monitors <code>mysql</code> on the demo sites), <b>node.js</b> plugins (it monitors <code>bind9</code> on the demo sites), etc.
- <br/>and including the chart refreshes for the dashboards of all viewers.</i>
- </div>
-
- <div style="padding-top: 6vw; width: 100%; text-align: center; font-size: 2vw;">
- want to know more?
- <br/>
- jump to <a href="https://github.com/firehol/netdata/">the netdata page at github</a>
- <br/>
- it needs just 3 mins to be installed on your servers!
- <br/>
- &nbsp;
- </div>
+ <div style="text-align: center; font-size: 13vw; height: 14vw;">
+ <b>netdata</b>
+ </div>
+ <div style="text-align: center; font-size: 2vw; height: 2.5vw;">
+ real-time performance monitoring
+ </div>
+ <div style="width:80%; text-align: right; font-size: 2.7vw;">
+ <strong>scaled out</strong>!
+ </div>
+ <div class="mytitle">
+ pick a <b>netdata</b> demo server
+ </div>
+ <div class="mycontent">
+ these demo servers show what you will get by installing <b>netdata</b>
+ </div>
+
+ <div style="width: 100%; text-align: center; padding-top: 2vw;">
+ <div style="width: 100%; text-align: center;">
+
+ <div class="mygauge-combo">
+ <div class="mygauge">
+ <div data-netdata="netdata.requests"
+ data-host="//london.my-netdata.io"
+ data-title="EU - London"
+ data-chart-library="gauge"
+ data-width="100%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#558855"
+ ></div>
+ </div>
+ <div class="mygauge-button">
+ <br/>&nbsp;<br/>
+ <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//london.my-netdata.io/default.html'" style="font-size: 1.0vw;">Enter London!</button>
+ <div style="font-size: 0.8vw;">
+ Donated by DigitalOcean.com
+ </div>
+ </div>
+ </div>
+ <div class="mygauge-combo">
+ <div class="mygauge">
+ <div data-netdata="netdata.requests"
+ data-host="//atlanta.my-netdata.io"
+ data-title="US - Atlanta"
+ data-chart-library="gauge"
+ data-width="100%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#AA5555"
+ ></div>
+ </div>
+ <div class="mygauge-button">
+ <br/>&nbsp;<br/>
+ <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//atlanta.my-netdata.io/default.html'" style="font-size: 1.0vw;">Enter Atlanta!</button>
+ <div style="font-size: 0.8vw;">
+ Donated by CDN77.com
+ </div>
+ </div>
+ </div>
+ <div class="mygauge-combo">
+ <div class="mygauge">
+ <div data-netdata="netdata.requests"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-title="US - California"
+ data-chart-library="gauge"
+ data-width="100%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#5555AA"
+ ></div>
+ </div>
+ <div class="mygauge-button">
+ <br/>&nbsp;<br/>
+ <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//sanfrancisco.netdata.rocks/default.html'" style="font-size: 1.0vw;">Enter California!</button>
+ <div style="font-size: 0.8vw;">
+ Donated by DigitalOcean.com
+ </div>
+ </div>
+ </div>
+ <div class="mygauge-combo">
+ <div class="mygauge">
+ <div data-netdata="netdata.requests"
+ data-host="//toronto.netdata.rocks"
+ data-title="Canada"
+ data-chart-library="gauge"
+ data-width="100%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#885588"
+ ></div>
+ </div>
+ <div class="mygauge-button">
+ <br/>&nbsp;<br/>
+ <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//toronto.netdata.rocks/default.html'" style="font-size: 1.0vw;">Enter Canada!</button>
+ <div style="font-size: 0.8vw;">
+ Donated by DigitalOcean.com
+ </div>
+ </div>
+ </div>
+ <br/>&nbsp;<br/>
+ <div class="mygauge-combo">
+ <div class="mygauge">
+ <div data-netdata="netdata.requests"
+ data-host="//frankfurt.netdata.rocks"
+ data-title="EU - Germany"
+ data-chart-library="easypiechart"
+ data-width="75%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#AAAA55"
+ ></div>
+ </div>
+ <div class="mygauge-button">
+ <br/>&nbsp;<br/>
+ <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//frankfurt.netdata.rocks/default.html'" style="font-size: 1.0vw;">Enter Germany!</button>
+ <div style="font-size: 0.8vw;">
+ Donated by DigitalOcean.com
+ </div>
+ </div>
+ </div>
+ <div class="mygauge-combo">
+ <div class="mygauge">
+ <div data-netdata="netdata.requests"
+ data-host="//newyork.netdata.rocks"
+ data-title="US - New York"
+ data-chart-library="easypiechart"
+ data-width="75%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#BB5533"
+ ></div>
+ </div>
+ <div class="mygauge-button">
+ <br/>&nbsp;<br/>
+ <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//newyork.netdata.rocks/default.html'" style="font-size: 1.0vw;">Enter New York!</button>
+ <div style="font-size: 0.8vw;">
+ Donated by DigitalOcean.com
+ </div>
+ </div>
+ </div>
+ <div class="mygauge-combo">
+ <div class="mygauge">
+ <div data-netdata="netdata.requests"
+ data-host="//singapore.netdata.rocks"
+ data-title="Signapore"
+ data-chart-library="easypiechart"
+ data-width="75%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#5588BB"
+ ></div>
+ </div>
+ <div class="mygauge-button">
+ <br/>&nbsp;<br/>
+ <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//singapore.netdata.rocks/default.html'" style="font-size: 1.0vw;">Enter Singapore!</button>
+ <div style="font-size: 0.8vw;">
+ Donated by DigitalOcean.com
+ </div>
+ </div>
+ </div>
+ <div class="mygauge-combo">
+ <div class="mygauge">
+ <div data-netdata="netdata.requests"
+ data-host="//bangalore.netdata.rocks"
+ data-title="India"
+ data-chart-library="easypiechart"
+ data-width="75%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#BB55BB"
+ ></div>
+ </div>
+ <div class="mygauge-button">
+ <br/>&nbsp;<br/>
+ <button type="button" class="btn btn-default" data-toggle="button" aria-pressed="false" autocomplete="off" onclick="window.location='//bangalore.netdata.rocks/default.html'" style="font-size: 1.0vw;">Enter India!</button>
+ <div style="font-size: 0.8vw;">
+ Donated by DigitalOcean.com
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="mytitle">
+ this page is a custom <b>netdata</b> dashboard
+ </div>
+ <div class="mycontent">
+ charts are coming from 8 servers, in parallel
+ <br/>
+ the servers are not aware of this multi-server dashboard,
+ <br/>
+ each server is not aware of the other servers,
+ <br/>
+ but on this dashboard <b>they are one</b>!
+ </div>
+ <div style="padding-top: 1vw; width: 100%; text-align: center; font-size: 1.5vw;">
+ <i class="fa fa-comment" aria-hidden="true"></i>
+ hover on a chart below, or drag it to show the past - <b>the others will follow</b>!
+ <br/>
+ double click on a chart to reset them all
+ </div>
+
+ <div class="mytitle">
+ our <code>nginx</code> performance
+ </div>
+ <div class="mycontent">
+ (we proxy netdata through nginx, on the demo sites)
+ </div>
+
+ <!-- Nav tabs -->
+ <ul class="nav nav-tabs" role="tablist" style="padding-top: 1vw;">
+ <li role="presentation" class="active"><a href="#nginx_requests" aria-controls="nginx_requests" role="tab" data-toggle="tab">Requests</a></li>
+ <li role="presentation"><a href="#nginx_connections" aria-controls="nginx_connections" role="tab" data-toggle="tab">Connections</a></li>
+ </ul>
+
+ <!-- Tab panes -->
+ <div class="tab-content">
+ <div role="tabpanel" class="tab-pane active" id="nginx_requests">
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>EU - London</b> web requests/s
+ </div>
+ <div class="mysparkline-overchart-value" id="nginx_local.requests.netdata" >
+ </div>
+ <div data-netdata="nginx_local.requests"
+ data-dimensions="requests"
+ data-host="//london.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#558855"
+ data-show-value-of-requests-at="nginx_local.requests.netdata"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - Atlanta</b> web requests/s
+ </div>
+ <div class="mysparkline-overchart-value" id="nginx_local.requests.netdata2" >
+ </div>
+ <div data-netdata="nginx_local.requests"
+ data-dimensions="requests"
+ data-host="//atlanta.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#AA5555"
+ data-show-value-of-requests-at="nginx_local.requests.netdata2"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - California</b> web requests/s
+ </div>
+ <div class="mysparkline-overchart-value" id="nginx_local.requests.netdata3" >
+ </div>
+ <div data-netdata="nginx_local.requests"
+ data-dimensions="requests"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#5555AA"
+ data-show-value-of-requests-at="nginx_local.requests.netdata3"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>Canada</b> web requests/s
+ </div>
+ <div class="mysparkline-overchart-value" id="nginx_local.requests.netdata4" >
+ </div>
+ <div data-netdata="nginx_local.requests"
+ data-dimensions="requests"
+ data-host="//toronto.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#885588"
+ data-show-value-of-requests-at="nginx_local.requests.netdata4"
+ ></div>
+ </div>
+ </div>
+
+ <div role="tabpanel" class="tab-pane" id="nginx_connections">
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>EU - London</b> active connections
+ </div>
+ <div class="mysparkline-overchart-value" id="nginx_local.connections.netdata1" >
+ </div>
+ <div data-netdata="nginx_local.connections"
+ data-dimensions="active"
+ data-host="//london.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#558855"
+ data-show-value-of-active-at="nginx_local.connections.netdata1"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - Atlanta</b> active connections
+ </div>
+ <div class="mysparkline-overchart-value" id="nginx_local.connections.netdata2" >
+ </div>
+ <div data-netdata="nginx_local.connections"
+ data-dimensions="active"
+ data-host="//atlanta.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#AA5555"
+ data-show-value-of-active-at="nginx_local.connections.netdata2"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - California</b> active connections
+ </div>
+ <div class="mysparkline-overchart-value" id="nginx_local.connections.netdata3" >
+ </div>
+ <div data-netdata="nginx_local.connections"
+ data-dimensions="active"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#5555AA"
+ data-show-value-of-active-at="nginx_local.connections.netdata3"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>Canada</b> active connections
+ </div>
+ <div class="mysparkline-overchart-value" id="nginx_local.connections.netdata4" >
+ </div>
+ <div data-netdata="nginx_local.connections"
+ data-dimensions="active"
+ data-host="//toronto.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#885588"
+ data-show-value-of-active-at="nginx_local.connections.netdata4"
+ ></div>
+ </div>
+ </div>
+ </div>
+
+ <div style="width: 100%; text-align: right; font-size: 1vw;">
+ <i class="fa fa-comment" aria-hidden="true"></i> these charts are draggable and touchable, double click them to reset them
+ </div>
+
+
+ <div class="mytitle">
+ bandwidth consumption on the demo sites
+ </div>
+ <div class="mycontent">
+ Linux QoS is configured by <a href="https://github.com/firehol/netdata/wiki/You-should-install-QoS-on-all-your-servers">FireQOS</a>
+ </div>
+
+ <!-- Nav tabs -->
+ <ul class="nav nav-tabs" role="tablist" style="padding-top: 1vw;">
+ <li role="presentation" class="active"><a href="#outbout" aria-controls="outbout" role="tab" data-toggle="tab">Outbound</a></li>
+ <li role="presentation"><a href="#inbound" aria-controls="inbound" role="tab" data-toggle="tab">Inbound</a></li>
+ </ul>
+
+ <!-- Tab panes -->
+ <div class="tab-content">
+ <div role="tabpanel" class="tab-pane active" id="outbout">
+ <div class="myfullchart">
+ <div data-netdata="tc.world_out"
+ data-host="//london.my-netdata.io"
+ data-chart-library="dygraph"
+ data-title="EU - London, traffic we send per service"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="tc.world_out"
+ data-host="//atlanta.my-netdata.io"
+ data-chart-library="dygraph"
+ data-title="US - Atlanta, traffic we send per service"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="tc.world_out"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-chart-library="dygraph"
+ data-title="US - California, traffic we send per service"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="tc.world_out"
+ data-host="//toronto.netdata.rocks"
+ data-chart-library="dygraph"
+ data-title="Canada, traffic we send per service"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ </div>
+ </div>
+
+ <div role="tabpanel" class="tab-pane" id="inbound">
+ <div class="myfullchart">
+ <div data-netdata="tc.world_in"
+ data-host="//london.my-netdata.io"
+ data-chart-library="dygraph"
+ data-title="EU - London, traffic we receive per service"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="tc.world_in"
+ data-host="//atlanta.my-netdata.io"
+ data-chart-library="dygraph"
+ data-title="US - Atlanta, traffic we receive per service"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="tc.world_in"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-chart-library="dygraph"
+ data-title="US - California, traffic we receive per service"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="tc.world_in"
+ data-host="//toronto.netdata.rocks"
+ data-chart-library="dygraph"
+ data-title="Canada, traffic we receive per service"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ </div>
+ </div>
+ </div>
+ <div style="width: 100%; text-align: right; font-size: 1vw;">
+ <i class="fa fa-comment" aria-hidden="true"></i> <i>these legends are interactive and the charts are resizable here ^^^</i>
+ </div>
+
+ <div class="mytitle">
+ DDoS protection performance on the demo sites
+ </div>
+ <div class="mycontent">
+ iptables SYNPROXY configured by <a href="https://github.com/firehol/netdata/wiki/Monitoring-SYNPROXY">FireHOL</a>
+ </div>
+
+ <div style="padding-top: 4vw; width: 100%; text-align: center; font-size: 1.5vw;">
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>EU - London</b>, TCP SYN packets/s received
+ </div>
+ <div class="mysparkline-overchart-value" id="netfilter.synproxy_syn_received.netdata1" >
+ </div>
+ <div data-netdata="netfilter.synproxy_syn_received"
+ data-dimensions="received"
+ data-host="//london.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#558855"
+ data-show-value-of-received-at="netfilter.synproxy_syn_received.netdata1"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - Atlanta</b>, TCP SYN packets/s received
+ </div>
+ <div class="mysparkline-overchart-value" id="netfilter.synproxy_syn_received.netdata2" >
+ </div>
+ <div data-netdata="netfilter.synproxy_syn_received"
+ data-dimensions="received"
+ data-host="//atlanta.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#885555"
+ data-show-value-of-received-at="netfilter.synproxy_syn_received.netdata2"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - California</b>, TCP SYN packets/s received
+ </div>
+ <div class="mysparkline-overchart-value" id="netfilter.synproxy_syn_received.netdata3" >
+ </div>
+ <div data-netdata="netfilter.synproxy_syn_received"
+ data-dimensions="received"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#555588"
+ data-show-value-of-received-at="netfilter.synproxy_syn_received.netdata3"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>Canada</b>, TCP SYN packets/s received
+ </div>
+ <div class="mysparkline-overchart-value" id="netfilter.synproxy_syn_received.netdata4" >
+ </div>
+ <div data-netdata="netfilter.synproxy_syn_received"
+ data-dimensions="received"
+ data-host="//toronto.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#885588"
+ data-show-value-of-received-at="netfilter.synproxy_syn_received.netdata4"
+ ></div>
+ </div>
+ </div>
+ <div style="width: 100%; text-align: right; font-size: 1vw;">
+ <i class="fa fa-comment" aria-hidden="true"></i> <i>did you notice the decimal numbers?
+ <br/>netdata interpolates collected values at second boundaries, with nanosecond detail!</i>
+ </div>
+
+
+ <div class="mytitle">
+ CPU Utilization of the demo sites
+ </div>
+
+ <div style="padding-top: 1vw;">
+ <div class="myfullchart">
+ <div data-netdata="system.cpu"
+ data-host="//london.my-netdata.io"
+ data-chart-library="dygraph"
+ data-title="EU - London, CPU Usage"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-dygraph-valuerange="[0, 100]"
+ ></div>
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="system.cpu"
+ data-host="//atlanta.my-netdata.io"
+ data-chart-library="dygraph"
+ data-title="US - Atlanta, CPU Usage"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-dygraph-valuerange="[0, 100]"
+ ></div>
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="system.cpu"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-chart-library="dygraph"
+ data-title="US - California, CPU Usage"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-dygraph-valuerange="[0, 100]"
+ ></div>
+ </div>
+
+ <div class="myfullchart">
+ <div data-netdata="system.cpu"
+ data-host="//toronto.netdata.rocks"
+ data-chart-library="dygraph"
+ data-title="Canada, CPU Usage"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-dygraph-valuerange="[0, 100]"
+ ></div>
+ </div>
+ </div>
+ <div style="width: 100%; text-align: right; font-size: 1vw;">
+ <i class="fa fa-comment" aria-hidden="true"></i> <i>what is using so much CPU?
+ <br/>The site <a href="//iplists.firehol.org/">iplists.firehol.org</a> is maintained by FireHOL - the CPU is used for comparing security IP Lists.</i>
+ </div>
+
+ <div class="mytitle">
+ Netdata performance
+ </div>
+ <div class="mycontent">
+ netdata monitors <b>users</b>, <b>user groups</b>, <b>applications (process trees)</b>
+ <br/>
+ <b>containers</b> (<code>lxc</code>, <code>docker</code>, etc.) and SNMP devices.
+ </div>
+
+ <!-- Nav tabs -->
+ <ul class="nav nav-tabs" role="tablist" style="padding-top: 1vw;">
+ <li role="presentation" class="active"><a href="#netdata_cpu" aria-controls="netdata_cpu" role="tab" data-toggle="tab">CPU</a></li>
+ <li role="presentation"><a href="#netdata_avgtime" aria-controls="netdata_avgtime" role="tab" data-toggle="tab">Average Response Time</a></li>
+ </ul>
+
+ <!-- Tab panes -->
+ <div class="tab-content">
+ <div role="tabpanel" class="tab-pane active" id="netdata_cpu">
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>EU - London</b>, CPU % of a single core
+ </div>
+ <div class="mysparkline-overchart-value" id="users.cpu.netdata1" >
+ </div>
+ <div data-netdata="apps.cpu"
+ data-dimensions="netdata"
+ data-host="//london.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#558855"
+ data-show-value-of-netdata-at="users.cpu.netdata1"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - Atlanta</b>, CPU % of a single core
+ </div>
+ <div class="mysparkline-overchart-value" id="users.cpu.netdata2" >
+ </div>
+ <div data-netdata="apps.cpu"
+ data-dimensions="netdata"
+ data-host="//atlanta.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#885555"
+ data-show-value-of-netdata-at="users.cpu.netdata2"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - California</b>, CPU % of a single core
+ </div>
+ <div class="mysparkline-overchart-value" id="users.cpu.netdata3" >
+ </div>
+ <div data-netdata="apps.cpu"
+ data-dimensions="netdata"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#555588"
+ data-show-value-of-netdata-at="users.cpu.netdata3"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>Toronto</b>, CPU % of a single core
+ </div>
+ <div class="mysparkline-overchart-value" id="users.cpu.netdata4" >
+ </div>
+ <div data-netdata="apps.cpu"
+ data-dimensions="netdata"
+ data-host="//toronto.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#885588"
+ data-show-value-of-netdata-at="users.cpu.netdata4"
+ ></div>
+ </div>
+
+ <div style="width: 100%; text-align: right; font-size: 1vw;">
+ <i class="fa fa-comment" aria-hidden="true"></i> <i>this utilization is about the whole netdata process tree and the percentage is of <b>a single core</b>!
+ <br/>including <b>BASH</b> plugins (it monitors <code>mysql</code> on the demo sites), <b>node.js</b> plugins (it monitors <code>bind9</code> on the demo sites), etc.
+ <br/>and including the chart refreshes for the dashboards of all viewers.</i>
+ </div>
+ </div>
+
+ <div role="tabpanel" class="tab-pane" id="netdata_avgtime">
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>EU - London</b>, API average response time in milliseconds
+ </div>
+ <div class="mysparkline-overchart-value" id="netdata.response_time1" >
+ </div>
+ <div data-netdata="netdata.response_time"
+ data-host="//london.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#558855 #356835"
+ data-show-value-of-average-at="netdata.response_time1"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - Atlanta</b>, API average response time in milliseconds
+ </div>
+ <div class="mysparkline-overchart-value" id="netdata.response_time2" >
+ </div>
+ <div data-netdata="netdata.response_time"
+ data-host="//atlanta.my-netdata.io"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#885555 #683535"
+ data-show-value-of-average-at="netdata.response_time2"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>US - California</b>, API average response time in milliseconds
+ </div>
+ <div class="mysparkline-overchart-value" id="netdata.response_time3" >
+ </div>
+ <div data-netdata="netdata.response_time"
+ data-host="//sanfrancisco.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#555588 #353568"
+ data-show-value-of-average-at="netdata.response_time3"
+ ></div>
+ </div>
+
+ <div class="mysparkline">
+ <div class="mysparkline-overchart-label">
+ <b>Canada</b>, API average response time in milliseconds
+ </div>
+ <div class="mysparkline-overchart-value" id="netdata.response_time4" >
+ </div>
+ <div data-netdata="netdata.response_time"
+ data-host="//toronto.netdata.rocks"
+ data-chart-library="dygraph"
+ data-dygraph-theme="sparkline"
+ data-dygraph-type="area"
+ data-width="100%"
+ data-height="100%"
+ data-after="-300"
+ data-colors="#885588 #683568"
+ data-show-value-of-average-at="netdata.response_time4"
+ ></div>
+ </div>
+
+ <div style="width: 100%; text-align: right; font-size: 1vw;">
+ <i class="fa fa-comment" aria-hidden="true"></i> <i>netdata is really <b>fast</b> (the values are milliseconds!)
+ <br/>
+ These values include everything, from the reception of the first byte to the dispatch of the last, including gzip compression.
+ <br/>
+ Values above 2-3ms are usually chart refreshes of charts with several dimensions, charts with very long durations (zoomed out), or file transfers.
+ </i>
+ </div>
+ </div>
+ </div>
+
+ <div style="padding-top: 6vw; width: 100%; text-align: center; font-size: 2vw;">
+ want to know more?
+ <br/>
+ jump to <a href="https://github.com/firehol/netdata/">the netdata page at github</a>
+ <br/>
+ it needs just 3 mins to be installed on your servers!
+ <br/>
+ &nbsp;
+ </div>
</div>
</body>
<script>
- // google analytics when this is used for the home page of the demo sites
- // you don't need this if you customize this dashboard for your needs
- setTimeout(function() {
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
-
- ga('create', 'UA-64295674-3', 'auto');
- ga('send', 'pageview');
- }, 2000);
+ // google analytics when this is used for the home page of the demo sites
+ // you don't need this if you customize this dashboard for your needs
+ setTimeout(function() {
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
+
+ ga('create', 'UA-64295674-3', 'auto');
+ ga('send', 'pageview');
+ }, 2000);
</script>
</html>
diff --git a/web/images/animated.gif b/web/images/animated.gif
new file mode 100644
index 000000000..0e94a20ba
--- /dev/null
+++ b/web/images/animated.gif
Binary files differ
diff --git a/web/images/post.png b/web/images/post.png
new file mode 100644
index 000000000..239af429a
--- /dev/null
+++ b/web/images/post.png
Binary files differ
diff --git a/web/index.html b/web/index.html
index 9cc2b4bbe..3e6c22190 100644
--- a/web/index.html
+++ b/web/index.html
@@ -1,1607 +1,2048 @@
-<!DOCTYPE html>
+<!DOCTYPE html>
<html lang="en">
<head>
- <title>netdata dashboard</title>
-
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
- <meta name="author" content="costa@tsaousis.gr">
-
- <link rel="shortcut icon" href="images/seo-performance-multi-size.ico">
-
- <link rel="apple-touch-icon" href="images/seo-performance-72.png">
- <link rel="apple-touch-icon" sizes="72x72" href="images/seo-performance-72.png">
- <link rel="apple-touch-icon" sizes="114x114" href="images/seo-performance-114.png">
-
- <link rel="icon" type="image/png" sizes="512x512" href="images/seo-performance-512.png">
- <link rel="icon" type="image/png" sizes="256x256" href="images/seo-performance-256.png">
- <link rel="icon" type="image/png" sizes="128x128" href="images/seo-performance-128.png">
- <link rel="icon" type="image/png" sizes="64x64" href="images/seo-performance-64.png">
- <link rel="icon" type="image/png" sizes="48x48" href="images/seo-performance-48.png">
- <link rel="icon" type="image/png" sizes="32x32" href="images/seo-performance-32.png">
- <link rel="icon" type="image/png" sizes="24x24" href="images/seo-performance-24.png">
- <link rel="icon" type="image/png" sizes="16x16" href="images/seo-performance-16.png">
-
- <style>
-
- /* prevent body from hiding under the navbar */
- body {
- padding-top: 50px;
- }
-
- .modal-wide .modal-dialog {
- width: 80%;
- }
-
- /* fix # anchors scrolling under the navbar
- https://github.com/twbs/bootstrap/issues/1768#issuecomment-46519033
- */
- h1 {
- position: relative;
- z-index: -1;
- }
- h2 {
- position: relative;
- z-index: -2;
- }
- h1:before, h2:before {
- display: block;
- content: " ";
- margin-top: -70px;
- height: 70px;
- visibility: hidden;
- }
-
- .p {
- display: block;
- margin-top: 15px;
- }
-
- .option-row,
- .option-control {
- vertical-align: top;
- padding: 10px;
- padding-top: 30px;
- padding-left: 30px;
- }
-
- .option-info {
- padding: 10px;
- }
-
- .chart-message {
- display: block;
- margin-top: 10px;
- }
-
- .container {
- width: 90% !important;
- }
-
- #masthead h1 {
- /*font-size: 30px;*/
- line-height: 1;
- padding-top: 30px;
- }
-
- #masthead .well {
- margin-top:4%;
- }
-
- /* fix the navbar shifting when a modal is open */
- /* https://github.com/twbs/bootstrap/issues/14040#issuecomment-159891033 */
- body.modal-open{
- width: 100% !important;
- padding-right: 0 !important;
-/* overflow-y: scroll !important; */
-/* position: fixed !important;*/
- overflow: visible;
- }
-
- /*
- * Side navigation
- *
- * Scrollspy and affixed enhanced navigation to highlight sections and secondary
- * sections of docs content.
- */
-
- .affix {
- position: static;
- top: 70px !important;
- /*width: 220px;*/
- }
-
- .affix-top {
- /*width: 220px;*/
- }
-
- .dashboard-sidebar {
- max-height: calc(100% - 70px) !important;
- overflow-y: auto;
- /*width: 220px !important;*/
- }
-
- /* By default it's not affixed in mobile views, so undo that */
- .dashboard-sidebar.affix {
- position: static;
- }
-
- @media (min-width: 768px) {
- .dashboard-sidebar {
- padding-left: 20px;
- }
- }
-
- /* First level of nav */
- .dashboard-sidenav {
- margin-top: 20px;
- margin-bottom: 20px;
- }
-
- /* All levels of nav */
- .dashboard-sidebar .nav > li > a {
- display: block;
- padding: 4px 20px;
- font-size: 13px;
- font-weight: 500;
- color: #767676;
- }
- .dashboard-sidebar .nav > li > a:hover,
- .dashboard-sidebar .nav > li > a:focus {
- padding-left: 19px;
- color: #563d7c;
- text-decoration: none;
- background-color: transparent;
- border-left: 1px solid #563d7c;
- }
- .dashboard-sidebar .nav > .active > a,
- .dashboard-sidebar .nav > .active:hover > a,
- .dashboard-sidebar .nav > .active:focus > a {
- padding-left: 18px;
- font-weight: bold;
- color: #563d7c;
- background-color: transparent;
- border-left: 2px solid #563d7c;
- }
-
- /* Nav: second level (shown on .active) */
- .dashboard-sidebar .nav .nav {
- display: none; /* Hide by default, but at >768px, show it */
- padding-bottom: 10px;
- }
- .dashboard-sidebar .nav .nav > li > a {
- padding-top: 1px;
- padding-bottom: 1px;
- padding-left: 30px;
- font-size: 12px;
- font-weight: normal;
- }
- .dashboard-sidebar .nav .nav > li > a:hover,
- .dashboard-sidebar .nav .nav > li > a:focus {
- padding-left: 29px;
- }
- .dashboard-sidebar .nav .nav > .active > a,
- .dashboard-sidebar .nav .nav > .active:hover > a,
- .dashboard-sidebar .nav .nav > .active:focus > a {
- padding-left: 28px;
- font-weight: 500;
- }
-
- .dropdown-menu {
- min-width: 200px;
- }
- .dropdown-menu.columns-2 {
- margin: 0;
- padding: 0;
- width: 400px;
- }
- .dropdown-menu li a {
- padding: 5px 15px;
- font-weight: 300;
- }
- .dropdown-menu.multi-column {
- overflow-x: hidden;
- }
- .multi-column-dropdown {
- list-style: none;
- padding: 0;
- }
- .multi-column-dropdown li a {
- display: block;
- clear: both;
- line-height: 1.428571429;
- white-space: normal;
- }
- .multi-column-dropdown li a:hover {
- text-decoration: none;
- color: #f5f5f5;
- background-color: #262626;
- }
- .scrollable-menu {
- height: auto;
- max-height: 80vh;
- overflow-x: hidden;
- }
-
- /* Back to top (hidden on mobile) */
- .back-to-top,
- .dashboard-theme-toggle {
- display: none;
- padding: 4px 10px;
- margin-top: 10px;
- margin-left: 10px;
- font-size: 12px;
- font-weight: 500;
- color: #999;
- }
- .back-to-top:hover,
- .dashboard-theme-toggle:hover {
- color: #563d7c;
- text-decoration: none;
- }
- .dashboard-theme-toggle {
- margin-top: 0;
- }
-
- @media (min-width: 768px) {
- .back-to-top,
- .dashboard-theme-toggle {
- display: block;
- }
-
- /* Widen the fixed sidebar */
- .dashboard-sidebar.affix,
- .dashboard-sidebar.affix-top,
- .dashboard-sidebar.affix-bottom {
- width: 200px !important;
- }
-
- .dashboard-sidebar.affix {
- position: fixed; /* Undo the static from mobile first approach */
- top: 20px;
- }
-
- .dashboard-sidebar.affix-bottom {
- position: absolute; /* Undo the static from mobile first approach */
- }
-
- .dashboard-sidebar.affix-bottom .dashboard-sidenav,
- .dashboard-sidebar.affix .dashboard-sidenav {
- margin-top: 0;
- margin-bottom: 0;
- }
- }
-
- /* Show and affix the side nav when space allows it */
- @media (min-width: 992px) {
- .dashboard-sidebar .nav > .active > ul {
- display: block;
- }
-
- /* Widen the fixed sidebar */
- .dashboard-sidebar.affix,
- .dashboard-sidebar.affix-top,
- .dashboard-sidebar.affix-bottom {
- width: 200px !important;
- }
- .dashboard-sidebar.affix {
- position: fixed; /* Undo the static from mobile first approach */
- top: 20px;
- }
- .dashboard-sidebar.affix-bottom {
- position: absolute; /* Undo the static from mobile first approach */
- }
- .dashboard-sidebar.affix-bottom .dashboard-sidenav,
- .dashboard-sidebar.affix .dashboard-sidenav {
- margin-top: 0;
- margin-bottom: 0;
- }
- }
-
- @media (min-width: 1200px) {
- /* Widen the fixed sidebar again */
- .dashboard-sidebar.affix-bottom,
- .dashboard-sidebar.affix-top,
- .dashboard-sidebar.affix {
- width: 263px;
- }
- }
- </style>
-
- <!-- you can set your netdata server globally, by ucommenting this -->
- <!-- you can also give a different server per chart, with the attribute: data-host="http://netdata.server:19999" -->
- <!-- <script> netdataServer = "http://box:19999"; </script> -->
-
- <!-- check which theme to use -->
- <script>
- function loadLocalStorage(name) {
- var ret = null;
-
- try {
- if(typeof Storage !== "undefined" && typeof localStorage === 'object')
- ret = localStorage.getItem(name);
- }
- catch(error) {
- ;
- }
-
- if(typeof ret === 'undefined' || ret === null)
- return null;
-
- return ret;
- }
-
- function saveLocalStorage(name, value) {
- try {
- if(typeof Storage !== "undefined" && typeof localStorage === 'object') {
- localStorage.setItem(name, value.toString());
- return true;
- }
- }
- catch(error) {
- ;
- }
-
- return false;
- }
-
- function getTheme(def) {
- var ret = loadLocalStorage('netdataTheme');
- if(typeof ret === 'undefined' || ret === null || ret === 'undefined')
- return def;
- else
- return ret;
- }
-
- var netdataTheme = getTheme('slate');
-
- function setTheme(theme) {
- if(theme === netdataTheme) return false;
-
- return saveLocalStorage('netdataTheme', theme);
- }
-
- var netdataRegistryCallback = function(urls_array) {
- var el = '';
- var a1 = '';
- var found = 0;
-
- if(urls_array) {
- function name_comparator_desc(a, b) {
- if (a.name > b.name) return -1;
- if (a.name < b.name) return 1;
- return 0;
- }
-
- var urls = urls_array.sort(name_comparator_desc);
- var len = urls.length;
- while(len--) {
- var u = urls[len];
-
- var status = "enabled";
- found++;
-
- if(u.guid === NETDATA.registry.machine_guid)
- status = "disabled"
-
- el += '<li id="registry_server_' + u.guid + '" class="' + status + '"><a href="' + u.url + '">' + u.name + '</a></li>';
- a1 += '<li id="registry_action_' + u.guid + '"><a href="#" onclick="deleteRegistryModalHandler(\'' + u.guid + '\',\'' + u.name + '\',\'' + u.url + '\'); return false;"><i class="fa fa-trash-o" aria-hidden="true" style="color: #999;"></i></a></li>';
- }
- }
-
- if(!found) {
- if(urls)
- el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #666;" target="_blank">your netdata server list is empty...</a></li>';
- else
- el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #666;" target="_blank">failed to contact the registry...</a></li>';
-
- a1 += '<li><a href="#">&nbsp;</a></li>';
-
- el += '<li role="separator" class="divider"></li>' +
- '<li><a href="//london.netdata.rocks/default.html">EU - London (DigitalOcean.com)</a></li>' +
- '<li><a href="//atlanta.netdata.rocks/default.html">US - Atlanta (CDN77.com)</a></li>' +
- '<li><a href="//athens.netdata.rocks/default.html">EU - Athens</a></li>';
- a1 += '<li role="separator" class="divider"></li>' +
- '<li><a href="#">&nbsp;</a></li>' +
- '<li><a href="#">&nbsp;</a></li>'+
- '<li><a href="#">&nbsp;</a></li>';
- }
-
- el += '<li role="separator" class="divider"></li>';
- a1 += '<li role="separator" class="divider"></li>';
-
- el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #999;" target="_blank">What is this?</a></li>';
- a1 += '<li><a href="#" style="color: #999;" onclick="switchRegistryModalHandler(); return false;"><i class="fa fa-cog" aria-hidden="true" style="color: #999;"></i></a></li>'
-
- document.getElementById('mynetdata_servers').innerHTML = el;
- document.getElementById('mynetdata_servers2').innerHTML = el;
- document.getElementById('mynetdata_actions1').innerHTML = a1;
- };
-
- </script>
-
- <!-- load the dashboard manager - it will do the rest -->
- <script type="text/javascript" src="dashboard.js?v37"></script>
-</head>
+ <title>netdata dashboard</title>
+ <meta name="application-name" content="netdata">
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+ <meta name="author" content="costa@tsaousis.gr">
+
+ <link rel="shortcut icon" href="images/seo-performance-multi-size.ico">
+
+ <link rel="apple-touch-icon" href="images/seo-performance-72.png">
+ <link rel="apple-touch-icon" sizes="72x72" href="images/seo-performance-72.png">
+ <link rel="apple-touch-icon" sizes="114x114" href="images/seo-performance-114.png">
+
+ <link rel="icon" type="image/png" sizes="512x512" href="images/seo-performance-512.png">
+ <link rel="icon" type="image/png" sizes="256x256" href="images/seo-performance-256.png">
+ <link rel="icon" type="image/png" sizes="128x128" href="images/seo-performance-128.png">
+ <link rel="icon" type="image/png" sizes="64x64" href="images/seo-performance-64.png">
+ <link rel="icon" type="image/png" sizes="48x48" href="images/seo-performance-48.png">
+ <link rel="icon" type="image/png" sizes="32x32" href="images/seo-performance-32.png">
+ <link rel="icon" type="image/png" sizes="24x24" href="images/seo-performance-24.png">
+ <link rel="icon" type="image/png" sizes="16x16" href="images/seo-performance-16.png">
+
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image" content="http://my-netdata.io/images/post.png"/>
+ <meta property="og:url" content="http://my-netdata.io/"/>
+ <meta property="og:type" content="website"/>
+ <meta property="og:site_name" content="netdata"/>
+ <meta property="og:title" content="netdata - real-time performance monitoring, done right!"/>
+ <meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
+
+ <style>
+
+ /* prevent body from hiding under the navbar */
+ body {
+ padding-top: 50px;
+ }
+
+ .loadOverlay {
+ position: absolute;
+ top: 0px;
+ left: 0px;
+ width: 100%;
+ height:100%;
+ z-index: 2000;
+ font-size: 10vh;
+ font-family: sans-serif;
+ padding: 40vh 0 40vh 0;
+ font-weight: bold;
+ text-align: center;
+ }
+
+ .modal-wide .modal-dialog {
+ width: 80%;
+ }
+
+ /* fix # anchors scrolling under the navbar
+ https://github.com/twbs/bootstrap/issues/1768#issuecomment-46519033
+ */
+ h1 {
+ position: relative;
+ z-index: -1;
+ }
+ h2 {
+ position: relative;
+ z-index: -2;
+ }
+ h1:before, h2:before {
+ display: block;
+ content: " ";
+ margin-top: -70px;
+ height: 70px;
+ visibility: hidden;
+ }
+
+ .p {
+ display: block;
+ margin-top: 15px;
+ }
+
+ .option-row,
+ .option-control {
+ vertical-align: top;
+ padding: 10px;
+ padding-top: 30px;
+ padding-left: 30px;
+ }
+
+ .option-info {
+ padding: 10px;
+ }
+
+ .chart-message {
+ display: block;
+ margin-top: 10px;
+ }
+
+ .container {
+ width: 90% !important;
+ }
+
+ #masthead h1 {
+ /*font-size: 30px;*/
+ line-height: 1;
+ padding-top: 30px;
+ }
+
+ #masthead .well {
+ margin-top:4%;
+ }
+
+ /* fix the navbar shifting when a modal is open */
+ /* https://github.com/twbs/bootstrap/issues/14040#issuecomment-159891033 */
+ body.modal-open{
+ width: 100% !important;
+ padding-right: 0 !important;
+/* overflow-y: scroll !important; */
+/* position: fixed !important;*/
+ overflow: visible;
+ }
+
+ /*
+ * Side navigation
+ *
+ * Scrollspy and affixed enhanced navigation to highlight sections and secondary
+ * sections of docs content.
+ */
+
+ .affix {
+ position: static;
+ top: 70px !important;
+ /*width: 220px;*/
+ }
+
+ .affix-top {
+ /*width: 220px;*/
+ }
+ .dashboard-sidebar {
+ max-height: calc(100% - 70px) !important;
+ overflow-y: auto;
+ /*width: 220px !important;*/
+ }
+
+ /* By default it's not affixed in mobile views, so undo that */
+ .dashboard-sidebar.affix {
+ position: static;
+ }
+
+ @media (min-width: 768px) {
+ .dashboard-sidebar {
+ padding-left: 20px;
+ }
+ }
+
+ /* First level of nav */
+ .dashboard-sidenav {
+ margin-top: 20px;
+ margin-bottom: 20px;
+ }
+
+ /* All levels of nav */
+ .dashboard-sidebar .nav > li > a {
+ display: block;
+ padding: 4px 20px;
+ font-size: 13px;
+ font-weight: 500;
+ color: #767676;
+ }
+ .dashboard-sidebar .nav > li > a:hover,
+ .dashboard-sidebar .nav > li > a:focus {
+ padding-left: 19px;
+ color: #563d7c;
+ text-decoration: none;
+ background-color: transparent;
+ border-left: 1px solid #563d7c;
+ }
+ .dashboard-sidebar .nav > .active > a,
+ .dashboard-sidebar .nav > .active:hover > a,
+ .dashboard-sidebar .nav > .active:focus > a {
+ padding-left: 18px;
+ font-weight: bold;
+ color: #563d7c;
+ background-color: transparent;
+ border-left: 2px solid #563d7c;
+ }
+
+ /* Nav: second level (shown on .active) */
+ .dashboard-sidebar .nav .nav {
+ display: none; /* Hide by default, but at >768px, show it */
+ padding-bottom: 10px;
+ }
+ .dashboard-sidebar .nav .nav > li > a {
+ padding-top: 1px;
+ padding-bottom: 1px;
+ padding-left: 30px;
+ font-size: 12px;
+ font-weight: normal;
+ }
+ .dashboard-sidebar .nav .nav > li > a:hover,
+ .dashboard-sidebar .nav .nav > li > a:focus {
+ padding-left: 29px;
+ }
+ .dashboard-sidebar .nav .nav > .active > a,
+ .dashboard-sidebar .nav .nav > .active:hover > a,
+ .dashboard-sidebar .nav .nav > .active:focus > a {
+ padding-left: 28px;
+ font-weight: 500;
+ }
+
+ .dropdown-menu {
+ min-width: 200px;
+ }
+ .dropdown-menu.columns-2 {
+ margin: 0;
+ padding: 0;
+ width: 400px;
+ }
+ .dropdown-menu li a {
+ padding: 5px 15px;
+ font-weight: 300;
+ }
+ .dropdown-menu.multi-column {
+ overflow-x: hidden;
+ }
+ .multi-column-dropdown {
+ list-style: none;
+ padding: 0;
+ }
+ .multi-column-dropdown li a {
+ display: block;
+ clear: both;
+ line-height: 1.428571429;
+ white-space: normal;
+ }
+ .multi-column-dropdown li a:hover {
+ text-decoration: none;
+ color: #f5f5f5;
+ background-color: #262626;
+ }
+ .scrollable-menu {
+ height: auto;
+ max-height: 80vh;
+ overflow-x: hidden;
+ }
+
+ /* Back to top (hidden on mobile) */
+ .back-to-top,
+ .dashboard-theme-toggle {
+ display: none;
+ padding: 4px 10px;
+ margin-top: 10px;
+ margin-left: 10px;
+ font-size: 12px;
+ font-weight: 500;
+ color: #999;
+ }
+ .back-to-top:hover,
+ .dashboard-theme-toggle:hover {
+ color: #563d7c;
+ text-decoration: none;
+ }
+ .dashboard-theme-toggle {
+ margin-top: 0;
+ }
+
+ @media (min-width: 768px) {
+ .back-to-top,
+ .dashboard-theme-toggle {
+ display: block;
+ }
+
+ /* Widen the fixed sidebar */
+ .dashboard-sidebar.affix,
+ .dashboard-sidebar.affix-top,
+ .dashboard-sidebar.affix-bottom {
+ width: 200px !important;
+ }
+
+ .dashboard-sidebar.affix {
+ position: fixed; /* Undo the static from mobile first approach */
+ top: 20px;
+ }
+
+ .dashboard-sidebar.affix-bottom {
+ position: absolute; /* Undo the static from mobile first approach */
+ }
+
+ .dashboard-sidebar.affix-bottom .dashboard-sidenav,
+ .dashboard-sidebar.affix .dashboard-sidenav {
+ margin-top: 0;
+ margin-bottom: 0;
+ }
+ }
+
+ /* Show and affix the side nav when space allows it */
+ @media (min-width: 992px) {
+ .dashboard-sidebar .nav > .active > ul {
+ display: block;
+ }
+
+ /* Widen the fixed sidebar */
+ .dashboard-sidebar.affix,
+ .dashboard-sidebar.affix-top,
+ .dashboard-sidebar.affix-bottom {
+ width: 200px !important;
+ }
+ .dashboard-sidebar.affix {
+ position: fixed; /* Undo the static from mobile first approach */
+ top: 20px;
+ }
+ .dashboard-sidebar.affix-bottom {
+ position: absolute; /* Undo the static from mobile first approach */
+ }
+ .dashboard-sidebar.affix-bottom .dashboard-sidenav,
+ .dashboard-sidebar.affix .dashboard-sidenav {
+ margin-top: 0;
+ margin-bottom: 0;
+ }
+ }
+
+ @media (min-width: 1200px) {
+ /* Widen the fixed sidebar again */
+ .dashboard-sidebar.affix-bottom,
+ .dashboard-sidebar.affix-top,
+ .dashboard-sidebar.affix {
+ width: 263px;
+ }
+ }
+ </style>
+
+ <!-- check which theme to use -->
+ <script type="text/javascript">
+ // --------------------------------------------------------------------
+ // urlOptions
+
+ var urlOptions = {
+ hash: '#',
+ theme: null,
+ help: null,
+ pan_and_zoom: false,
+ after: 0,
+ before: 0,
+ nowelcome: 0,
+ hasProperty: function(property) {
+ // console.log('checking property ' + property + ' of type ' + typeof(this[property]));
+ return typeof this[property] !== 'undefined';
+ }
+ };
+
+ function netdataPanAndZoomCallback(status, after, before) {
+ urlOptions.pan_and_zoom = status;
+ urlOptions.after = after;
+ urlOptions.before = before;
+ netdataHashUpdate();
+ }
+
+ function netdataHashUpdate() {
+ history.replaceState(null, '', netdataHash());
+ }
+
+ function netdataHash() {
+ var hash = urlOptions.hash;
+
+ if(urlOptions.pan_and_zoom === true) {
+ hash += ';after=' + urlOptions.after.toString() +
+ ';before=' + urlOptions.before.toString();
+ }
+
+ if(urlOptions.theme !== null)
+ hash += ';theme=' + urlOptions.theme.toString();
+
+ if(urlOptions.help !== null)
+ hash += ';help=' + urlOptions.help.toString();
+
+ return hash;
+ }
+
+ function netdataHashParse() {
+ var variables = document.location.hash.split(';');
+ var len = variables.length;
+ while(len--) {
+ if(len !== 0) {
+ var p = variables[len].split('=');
+ if(urlOptions.hasProperty(p[0]) && typeof p[1] !== 'undefined')
+ urlOptions[p[0]] = p[1];
+ }
+ else {
+ if(variables[len].length > 0)
+ urlOptions.hash = variables[len];
+ }
+ }
+
+ if(urlOptions.before > 0 && urlOptions.after > 0)
+ urlOptions.pan_and_zoom = true;
+
+ // console.log(urlOptions);
+ }
+
+ netdataHashParse();
+
+ // --------------------------------------------------------------------
+ // check options that should be processed before loading netdata.js
+
+ function loadLocalStorage(name) {
+ var ret = null;
+
+ try {
+ if(typeof Storage !== "undefined" && typeof localStorage === 'object')
+ ret = localStorage.getItem(name);
+ }
+ catch(error) {
+ ;
+ }
+
+ if(typeof ret === 'undefined' || ret === null)
+ return null;
+
+ // console.log('loaded: ' + name.toString() + ' = ' + ret.toString());
+
+ return ret;
+ }
+
+ function saveLocalStorage(name, value) {
+ // console.log('saving: ' + name.toString() + ' = ' + value.toString());
+ try {
+ if(typeof Storage !== "undefined" && typeof localStorage === 'object') {
+ localStorage.setItem(name, value.toString());
+ return true;
+ }
+ }
+ catch(error) {
+ ;
+ }
+
+ return false;
+ }
+
+ function getTheme(def) {
+ var ret = loadLocalStorage('netdataTheme');
+ if(typeof ret === 'undefined' || ret === null || ret === 'undefined')
+ return def;
+ else
+ return ret;
+ }
+
+ function setTheme(theme) {
+ if(theme === netdataTheme) return false;
+ return saveLocalStorage('netdataTheme', theme);
+ }
+
+ var netdataTheme = getTheme('slate');
+ var netdataShowHelp = true;
+
+ if(urlOptions.theme !== null) {
+ setTheme(urlOptions.theme);
+ netdataTheme = urlOptions.theme;
+ }
+ else
+ urlOptions.theme = netdataTheme;
+
+ if(urlOptions.help !== null) {
+ saveLocalStorage('options.show_help', urlOptions.help);
+ netdataShowHelp = urlOptions.help;
+ }
+ else {
+ urlOptions.help = loadLocalStorage('options.show_help');
+ }
+
+ // --------------------------------------------------------------------
+ // registry call back to render my-netdata menu
+
+ var netdataRegistryCallback = function(machines_array) {
+ var el = '';
+ var a1 = '';
+ var found = 0;
+
+ if(machines_array) {
+ function name_comparator_desc(a, b) {
+ if (a.name > b.name) return -1;
+ if (a.name < b.name) return 1;
+ return 0;
+ }
+
+ var machines = machines_array.sort(name_comparator_desc);
+ var len = machines.length;
+ while(len--) {
+ var u = machines[len];
+ found++;
+ el += '<li id="registry_server_' + u.guid + '"><a class="registry_link" href="' + u.url + '" onClick="return gotoServerModalHandler(\'' + u.guid + '\');">' + u.name + '</a></li>';
+ a1 += '<li id="registry_action_' + u.guid + '"><a href="#" onclick="deleteRegistryModalHandler(\'' + u.guid + '\',\'' + u.name + '\',\'' + u.url + '\'); return false;"><i class="fa fa-trash-o" aria-hidden="true" style="color: #999;"></i></a></li>';
+ }
+ }
+
+ if(!found) {
+ if(machines)
+ el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #666;" target="_blank">your netdata server list is empty...</a></li>';
+ else
+ el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #666;" target="_blank">failed to contact the registry...</a></li>';
+
+ a1 += '<li><a href="#" onClick="return false;">&nbsp;</a></li>';
+
+ el += '<li role="separator" class="divider"></li>' +
+ '<li><a href="//london.netdata.rocks/default.html">EU - London (DigitalOcean.com)</a></li>' +
+ '<li><a href="//atlanta.netdata.rocks/default.html">US - Atlanta (CDN77.com)</a></li>' +
+ '<li><a href="//athens.netdata.rocks/default.html">EU - Athens</a></li>';
+ a1 += '<li role="separator" class="divider"></li>' +
+ '<li><a href="#">&nbsp;</a></li>' +
+ '<li><a href="#">&nbsp;</a></li>'+
+ '<li><a href="#">&nbsp;</a></li>';
+ }
+
+ el += '<li role="separator" class="divider"></li>';
+ a1 += '<li role="separator" class="divider"></li>';
+
+ el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #999;" target="_blank">What is this?</a></li>';
+ a1 += '<li><a href="#" style="color: #999;" onclick="switchRegistryModalHandler(); return false;"><i class="fa fa-cog" aria-hidden="true" style="color: #999;"></i></a></li>'
+
+ document.getElementById('mynetdata_servers').innerHTML = el;
+ document.getElementById('mynetdata_servers2').innerHTML = el;
+ document.getElementById('mynetdata_actions1').innerHTML = a1;
+
+ gotoServerInit();
+ };
+
+ </script>
+
+ <!-- load the dashboard manager - it will do the rest -->
+ <script type="text/javascript" src="dashboard.js?v42"></script>
+</head>
<body data-spy="scroll" data-target="#sidebar">
- <nav class="navbar navbar-default navbar-fixed-top" role="banner">
- <div class="container">
- <nav id="mynetdata_nav" class="collapse navbar-collapse navbar-left hidden-sm hidden-xs" role="navigation" style="padding-right: 20px;">
- <ul class="nav navbar-nav">
- <li class="dropdown">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="current_view">my-netdata <strong class="caret"></strong></a>
- <ul class="dropdown-menu scrollable-menu inpagemenu multi-column columns-2" role="menu">
- <div class="row">
- <div class="col-sm-6" style="width: 85%; padding-right: 0;">
- <ul id="mynetdata_servers" class="multi-column-dropdown">
- <li><a href="#" onclck="return false;" style="color: #999;">loading...</a></li>
- </ul>
- </div>
- <div class="col-sm-3 hidden-xs" style="width: 15%; padding-left: 0;">
- <ul id="mynetdata_actions1" class="multi-column-dropdown">
- <li style="color: #999;">&nbsp;</li>
- </ul>
- </div>
- </div>
- </ul>
- </li>
- </ul>
- </nav>
- <div class="navbar-header">
- <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse">
- <span class="sr-only">Toggle navigation</span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- <span class="icon-bar"></span>
- </button>
- <a href="/" class="navbar-brand" id="hostname">netdata</a>
- </div>
- <nav class="collapse navbar-collapse navbar-right" role="navigation">
- <ul class="nav navbar-nav">
- <li class="hidden-sm"><a href="#" class="btn" data-toggle="modal" data-target="#optionsModal"><i class="fa fa-cog"></i> settings</a></li>
- <li class="hidden-sm"><a href="https://github.com/firehol/netdata/wiki" class="btn" target="_blank"><i class="fa fa-github"></i> community</a></li>
- <li class="hidden-sm" id="updateButton"><a href="#" class="btn" data-toggle="modal" data-target="#updateModal"><i class="fa fa-cloud-download"></i> update</a></li>
- <li class="hidden-sm"><a href="#" class="btn" data-toggle="modal" data-target="#helpModal"><i class="fa fa-question-circle"></i> help</a></li>
- <li class="dropdown hidden-md hidden-lg hidden-xs">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="current_view">Menu <strong class="caret"></strong></a>
- <ul class="dropdown-menu scrollable-menu inpagemenu" role="menu">
- <li><a href="#" class="btn" data-toggle="modal" data-target="#optionsModal"><i class="fa fa-cog"></i> settings</a></li>
- <li><a href="https://github.com/firehol/netdata/wiki" class="btn" target="_blank"><i class="fa fa-github"></i> community</a></li>
- <li><a href="#" class="btn" data-toggle="modal" data-target="#helpModal"><i class="fa fa-question-circle"></i> help</a></li>
- </ul>
- </li>
- <li class="dropdown hidden-sm hidden-md hidden-lg">
- <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="current_view">my-netdata <strong class="caret"></strong></a>
- <ul id="mynetdata_servers2" class="dropdown-menu scrollable-menu inpagemenu" role="menu">
- <li><a href="#" onclck="return false;" style="color: #999;">loading...</a></li>
- </ul>
- </li>
- </ul>
- </nav>
- </nav>
- </div>
- </nav>
-
- <div id="masthead" style="display: none;">
- <div class="container">
- <div class="row">
- <div class="col-md-7">
- <h1>Netdata
- <p class="lead">Real-time performance monitoring, in the greatest possible detail</p>
- </h1>
- </div>
- <div class="col-md-5">
- <div class="well well-lg">
- <div class="row">
- <div class="col-md-6">
- <b>Drag</b> charts to pan.
- <b>Shift + wheel</b> on them, to zoom in and out.
- <b>Double-click</b> on them, to reset.
- <b>Hover</b> on them too!
- </div>
- <div class="col-md-6">
- <div data-netdata="system.intr" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-dygraph-type="line" data-dygraph-strokewidth="3" data-dygraph-smooth="true" data-dygraph-highlightcirclesize="6" data-after="-90" data-height="60px" data-colors="#C66"></div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
- </div>
-
- <div class="container">
- <div class="row">
- <div class="col-md-10" role="main">
- <div id="charts_div"></div>
- </div>
- <div class="col-md-2" role="complementary">
- <nav class="dashboard-sidebar hidden-print hidden-xs hidden-sm" id="sidebar" role="menu"></nav>
- </div>
- </div>
- </div>
-
- <div id="footer" class="container" style="display: none;">
- <div class="row">
- <div class="col-md-10" role="main">
- <div class="p">
- <big><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></big><br/>
- <i class="fa fa-copyright"></i> Copyright 2016, Costa Tsaousis.<br/>
- Released under <a href="http://www.gnu.org/licenses/gpl-3.0.en.html" target="_blank">GPL v3 or later</a>.<br/>
- </div>
- <div class="p">
- <small>
- <a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a> re-distributes these software tools:
-
- <i class="fa fa-circle"></i> The excellent <a href="http://dygraphs.com/" target="_blank">Dygraphs.com</a> web chart library,
- <i class="fa fa-copyright"></i> Copyright 2009, Dan Vanderkam, <a href="http://dygraphs.com/legal.html" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="http://omnipotent.net/jquery.sparkline/" target="_blank">jQuery Sparklines</a> web chart library,
- <i class="fa fa-copyright"></i> Copyright 2009-2012, Splunk Inc., <a href="http://opensource.org/licenses/BSD-3-Clause" target="_blank">New BSD License</a>
-
- <i class="fa fa-circle"></i> <a href="http://benpickles.github.io/peity/" target="_blank">Peity</a> web chart library,
- <i class="fa fa-copyright"></i> Copyright 2009-2015, Ben Pickles, <a href="https://github.com/benpickles/peity/blob/master/MIT-LICENCE" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="https://rendro.github.io/easy-pie-chart/" target="_blank">Easy Pie Chart</a> web chart library,
- <i class="fa fa-copyright"></i> Copyright 2013, Robert Fleischmann, <a href="https://github.com/rendro/easy-pie-chart/blob/master/LICENSE" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="http://bernii.github.io/gauge.js/" target="_blank">Gauge.js</a> web chart library,
- <i class="fa fa-copyright"></i> Copyright, Bernard Kobos, <a href="http://bernii.github.io/gauge.js/" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="https://jquery.org/" target="_blank">jQuery</a>,
- <i class="fa fa-copyright"></i> Copyright 2015, jQuery Foundation, <a href="https://jquery.org/license/" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="http://getbootstrap.com/getting-started/" target="_blank">Bootstrap</a>,
- <i class="fa fa-copyright"></i> Copyright 2015, Twitter, <a href="http://getbootstrap.com/getting-started/#license-faqs" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="http://www.bootstraptoggle.com/" target="_blank">Bootstrap Toggle</a>,
- <i class="fa fa-copyright"></i> Copyright (c) 2011-2014 Min Hur, The New York Times Company, <a href="https://github.com/minhur/bootstrap-toggle/blob/master/LICENSE" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="https://jamesflorentino.github.io/nanoScrollerJS/" target="_blank">NanoScroller</a>,
- <i class="fa fa-copyright"></i> Copyright 2012, James Florentino, <a href="https://github.com/jamesflorentino/nanoScrollerJS/blob/master/LICENSE" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="https://github.com/marcj/css-element-queries" target="_blank">CSS Element Queries</a>,
- <i class="fa fa-copyright"></i> Copyright Marc J. Schmidt, <a href="https://github.com/marcj/css-element-queries/blob/master/LICENSE" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="https://fortawesome.github.io/Font-Awesome/" target="_blank">FontAwesome</a>,
- <i class="fa fa-copyright"></i> Created by Dave Gandy, Font: <a href="http://scripts.sil.org/OFL" target="_blank">SIL OFL 1.1 License</a>, CSS: <a href="http://opensource.org/licenses/mit-license.html" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="http://www.iconsdb.com/soylent-red-icons/seo-performance-icon.html" target="_blank">IconsDB.com Icons</a>, Icons provided as CC0 1.0 Universal (CC0 1.0) Public Domain Dedication.
-
- <i class="fa fa-circle"></i> <a href="http://morrisjs.github.io/morris.js/" target="_blank">morris.js</a>,
- <i class="fa fa-copyright"></i> Copyright 2013, Olly Smith, <a href="http://morrisjs.github.io/morris.js/" target="_blank">Simplified BSD License</a>
-
- <i class="fa fa-circle"></i> <a href="http://raphaeljs.com/" target="_blank">Raphaël</a>,
- <i class="fa fa-copyright"></i> Copyright 2008, Dmitry Baranovskiy, <a href="http://raphaeljs.com/license.html" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="http://C3js.org/" target="_blank">C3</a>,
- <i class="fa fa-copyright"></i> Copyright 2013, Masayuki Tanaka, <a href="https://github.com/masayuki0812/c3/blob/master/LICENSE" target="_blank">MIT License</a>
-
- <i class="fa fa-circle"></i> <a href="http://D3js.org/" target="_blank">D3</a>,
- <i class="fa fa-copyright"></i> Copyright 2015, Mike Bostock, <a href="http://opensource.org/licenses/BSD-3-Clause" target="_blank">BSD License</a>
-
- </small>
- </div>
- </div>
- </div>
- </div>
-
- <div class="modal fade" id="welcomeModal" tabindex="-1" role="dialog" aria-labelledby="welcomeModalLabel">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- <h4 class="modal-title" id="welcomeModalLabel">Welcome!</h4>
- </div>
- <div class="modal-body">
- <div class="p">
- <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> is the fastest way to visualize metrics. It is a resource efficient, highly optimized system for collecting and visualizing any type of real-time time series data, from CPU usage, disk activity, SQL queries, API calls, web site visitors, etc.
- </div>
- <div class="p">
- <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> tries to visualize the truth of <b>now</b>, in its <b>greatest detail</b>, so that you can get insights of what is happening now and what just happened, on your systems and applications.
- </div>
- <div class="p">
- To make a chart in <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b>, you just need a <b>number</b>. Just a number you can read somehow. <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> will turn this number to a real time, interactive, web chart. For collecting these numbers, it supports <a href="https://github.com/firehol/netdata/wiki/External-Plugins" target="_blank">external plugins</a>, even <a href="https://github.com/firehol/netdata/wiki/General-Info---charts.d" target="_blank">shell</a> or <a href="https://github.com/firehol/netdata/wiki/General-Info---charts.d" target="_blank">node.js</a> plugins. Any computer program, in any language, that can print a few lines of text on its standard output, can be a netdata data collector.
- </div>
- <div class="p">
- <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> can embed charts everywhere, like this one <div data-netdata="system.cpu" data-dimensions="system" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-show-value-of-system-at="system.cpu.system.modal.1"></div> (my CPU system usage which is <span id="system.cpu.system.modal.1" style="display: inline-block; width: 40px; text-align: right;"></span>%),
- or this one <div data-netdata="ipv4.tcppackets" data-dimensions="received" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-show-value-of-received-at="ipv4.tcppackets.received.modal.1"></div> (my IPv4 received TCP packets, which are <span id="ipv4.tcppackets.received.modal.1" style="display: inline-block; width: 60px; text-align: right;"></span>/second).
- </div>
- <div class="p">
- You can have <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> charts on your site too. Just give it a <code>div</code> and a real time chart, zoomable and draggable will appear (try it even on these tiny ones - <b>drag</b> them to pan horizontally, <b>shift + drag</b> to zoom in, on <b>chrome shift + mouse wheel</b> to zoom in/out, <b>double click</b> on them to reset them - don't be afraid of <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> performance - <a href="https://github.com/firehol/netdata/wiki/Performance" target="_blank">a raspberry pi 2 can sustain 300 charts updates per second</a>!).
- </div>
- <div class="p">
- For more information please refer to the <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata wiki</a></b>.
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
-
- <div class="modal fade" id="helpModal" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- <h4 class="modal-title" id="helpModalLabel">Dashboard Help</h4>
- </div>
- <div class="modal-body">
-
- <h4>Dygraphs (line, area and stacked area charts)</h4>
-
- <!-- Nav tabs -->
- <ul class="nav nav-tabs" role="tablist">
- <li role="presentation" class="active"><a href="#help_mouse" aria-controls="help_mouse" role="tab" data-toggle="tab">Mouse Interface</a></li>
- <li role="presentation"><a href="#help_touch" aria-controls="help_touch" role="tab" data-toggle="tab">Touch Interface</a></li>
- </ul>
-
- <!-- Tab panes -->
- <div class="tab-content">
- <div role="tabpanel" class="tab-pane active" id="help_mouse">
- <div class="p">
- <h4>Mouse Over / Hover</h4>
- Mouse over on a chart to show, at its legend, the values for the timestamp under the mouse (the chart will also highlight the point at the chart).
- <br/>
- All the other visible charts will also show and highlight their values for the same timestamp.
- </div>
- <hr/>
- <div class="p">
- <h4>Drag Chart Contents</h4>
- Drag the contents of a chart to pan it horizontally.
- <br/>
- All the charts will follow soon after you let the chart alone (this little delay is by design: it speeds up your browser and lets you focus on what you are exploring).
- <br/>
- Once a chart is panned, auto refreshing stops for all charts. To enable it again, <b>double click</b> a panned chart.
- </div>
- <hr/>
- <div class="p">
- <h4>Double Click</h4>
- Double Click a chart to reset all the charts to their default auto-refreshing state.
- </div>
- <hr/>
- <div class="p">
- <h4>SHIFT + Drag</h4>
- While pressing the shift key, click on the contents of a chart and move the mouse to select an area, to zoom in. The other charts will follow too. Zooming is performed in two phases:
- <ul>
- <li>The already loaded chart contents are zoomed (low resolution)</li>
- <li>New data are transferred from the netdata server, to refresh the chart with possibly more detail.</li>
- </ul>
- Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
- </div>
- <hr/>
- <div class="p">
- <h4>SHIFT + Mouse Wheel <small>(does not work on firefox and IE/Edge)</small></h4>
- While pressing the shift key and the mouse pointer is over the contents of a chart, scroll the mouse wheel to zoom in or out. This kind of zooming is aligned to center below the mouse pointer. The other charts will follow too.
- <br/>
- Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
- </div>
- <hr/>
- <div class="p">
- <h4>Legend Operations</h4>
- Click on the label or value of a dimension, will select / un-select this dimension.
- <br/>
- You can press any of the SHIFT or CONTROL keys and then click on legend labels or values, to select / un-select multiple dimensions.
- </div>
- </div>
- <div role="tabpanel" class="tab-pane" id="help_touch">
- <div class="p">
- <h4>Single Tap</h4>
- Single Tap on the contents of a chart to show, at its legend, the values for the timestamp tapped (the chart will also highlight the point at the chart).
- <br/>
- All the other visible charts will also show and highlight their values for the same timestamp.
- </div>
- <hr/>
- <div class="p">
- <h4>Drag Chart Contents</h4>
- Touch and Drag the contents of a chart to pan it horizontally.
- <br/>
- All the charts will follow soon after you let the chart alone (this little delay is by design: it speeds up your browser and lets you focus on what you are exploring).
- <br/>
- Once a chart is panned, auto refreshing stops for all charts. To enable it again, <b>double tap</b> a panned chart.
- </div>
- <hr/>
- <div class="p">
- <h4>Double Tap</h4>
- Double tap a chart to reset all the charts to their default auto-refreshing state.
- </div>
- <hr/>
- <div class="p">
- <h4>Zoom <small>(does not work on firefox and IE/Edge)</small></h4>
- With two fingers, zoom in or out.
- <br/>
- Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
- </div>
- <hr/>
- <div class="p">
- <h4>Legend Operations</h4>
- Tap on the label or value of a dimension, will select / un-select this dimension.
- </div>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
-
- <div class="modal fade" id="optionsModal" tabindex="-1" role="dialog" aria-labelledby="optionsModalLabel">
- <div class="modal-dialog modal-lg" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- <h4 class="modal-title" id="optionsModalLabel">netdata dashboard options</h4>
- </div>
- <div class="modal-body">
- <center>
- <small style="color: #BBBBBB;">These are browser settings. Each viewer has its own. They do not affect the operation of your netdata server.
- <br/>
- Settings take effect immediately and are saved permanently to browser local storage (except the refresh on focus / always option).
- <br/>
- To reset all options (including charts sizes) to their defaults, click <a href="#" onclick="resetDashboardOptions(); return false;">here</a>.</small>
- </center>
- <div style="padding: 10px;"></div>
-
- <!-- Nav tabs -->
- <ul class="nav nav-tabs" role="tablist">
- <li role="presentation" class="active"><a href="#settings_performance" aria-controls="settings_performance" role="tab" data-toggle="tab">Performance</a></li>
- <li role="presentation"><a href="#settings_sync" aria-controls="settings_sync" role="tab" data-toggle="tab">Synchronization</a></li>
- <li role="presentation"><a href="#settings_visual" aria-controls="settings_visual" role="tab" data-toggle="tab">Visual</a></li>
- </ul>
-
- <!-- Tab panes -->
- <div class="tab-content">
- <div role="tabpanel" class="tab-pane active" id="settings_performance">
- <form id="optionsForm1" method="get" class="form-horizontal">
- <div class="form-group">
- <table>
- <tr class="option-row">
- <td class="option-control"><input id="stop_updates_when_focus_is_lost" type="checkbox" checked data-toggle="toggle" data-offstyle="danger" data-onstyle="success" data-on="On Focus" data-off="Always" data-width="110px"></td>
- <td class="option-info"><strong>When to refresh the charts?</strong><br/>
- <small>When set to <b>On Focus</b>, the charts will stop being updated if the page / tab does not have the focus of the user. When set to <b>Always</b>, the charts will always be refreshed. Set it to <b>On Focus</b> it to lower the CPU requirements of the browser (and extend the battery of laptops and tablets) when this page does not have your focus. Set to <b>Always</b> to work on another window (i.e. change the settings of something) and have the charts auto-refresh in this window.</small>
- </td>
- </tr>
- <tr class="option-row">
- <td class="option-control">
- <input id="eliminate_zero_dimensions" type="checkbox" checked data-toggle="toggle" data-on="Non Zero" data-off="All" data-width="110px">
- </td>
- <td class="option-info"><strong>Which dimensions to show?</strong><br/>
- <small>When set to <b>Non Zero</b>, dimensions that have all their values (within the current view) set to zero will not be transferred from the netdata server (except if all dimensions of the chart are zero, in which case this setting does nothing - all dimensions are transferred and shown). When set to <b>All</b>, all dimensions will always be shown. Set it to <b>Non Zero</b> to lower the data transferred between netdata and your browser, lower the CPU requirements of your browser (fewer lines to draw) and increase the focus on the legends (fewer entries at the legends).</small>
- </td>
- </tr>
- <tr class="option-row">
- <td class="option-control"><input id="destroy_on_hide" type="checkbox" data-toggle="toggle" data-on="Destroy" data-off="Hide" data-width="110px"></td>
- <td class="option-info"><strong>How to handle hidden charts?</strong><br/>
- <small>When set to <b>Destroy</b>, charts that are not in the current viewport of the browser (are above, or below the visible area of the page), will be destroyed and re-created if and when they become visible again. When set to <b>Hide</b>, the not-visible charts will be just hidden, to simplify the DOM and speed up your browser. Set it to <b>Destroy</b>, to lower the memory requirements of your browser. Set it to <b>Hide</b> for smoother page scrolling.</small>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </div>
- <div role="tabpanel" class="tab-pane" id="settings_sync">
- <form id="optionsForm2" method="get" class="form-horizontal">
- <div class="form-group">
- <table>
- <tr class="option-row">
- <td class="option-control"><input id="parallel_refresher" type="checkbox" checked data-toggle="toggle" data-on="Parallel" data-off="Sequential" data-width="110px"></td>
- <td class="option-info"><strong>Which chart refresh policy to use?</strong><br/>
- <small>When set to <b>parallel</b>, visible charts are refreshed in parallel (all queries are sent to netdata server in parallel) and are rendered asynchronously. When set to <b>sequential</b> charts are refreshed one after another. Set it to parallel if your browser can cope with it (most modern browsers do), set it to sequential if you work on an older/slower computer.</small>
- </td>
- </tr>
- <tr class="option-row" id="concurrent_refreshes_row">
- <td class="option-control"></td>
- <td class="option-info">
- <table>
- <tr class="option-row">
- <td class="option-control">
- <input id="concurrent_refreshes" type="checkbox" checked data-toggle="toggle" data-on="Resync" data-off="Best Effort" data-width="110px">
- </td>
- <td class="option-info">
- <strong>Shall we re-sync chart refreshes?</strong><br/>
- <small>When set to <b>Resync</b>, the dashboard will attempt to re-synchronize all the charts so that they are refreshed concurrently. When set to <b>Best Effort</b>, each chart may be refreshed with a little time difference to the others. Normally, the dashboard starts refreshing them in parallel, but depending on the speed of your computer and the network latencies, charts start having a slight time difference. Setting this to <b>Resync</b> will attempt to re-synchronize the charts on every update. Setting it to <b>Best Effort</b> may lower the pressure on your browser and the network.</small>
- </td>
- </tr>
- </table>
- </td>
- </tr>
- <tr class="option-row">
- <td class="option-control"><input id="sync_selection" type="checkbox" checked data-toggle="toggle" data-on="Sync" data-off="Don't Sync" data-onstyle="success" data-offstyle="danger" data-width="110px"></td>
- <td class="option-info"><strong>Sync hover selection on all charts?</strong><br/>
- <small>When enabled, a selection on one chart will automatically select the same time on all other visible charts and the legends of all visible charts will be updated to show the selected values. When disabled, only the chart getting the user's attention will be selected. Enable it to get better insights of the data. Disable it if you are on a very slow computer that cannot actually do it.</small>
- </td>
- </tr>
- <tr class="option-row">
- <td class="option-control"><input id="sync_pan_and_zoom" type="checkbox" checked data-toggle="toggle" data-on="Sync" data-off="Don't Sync" data-onstyle="success" data-offstyle="danger" data-width="110px"></td>
- <td class="option-info"><strong>Sync pan and zoom on all charts?</strong><br/>
- <small>When enabled, pan and zoom operations on a chart will be replicated to all charts (even the ones that are not currently visible - of course only when they will become visible). When disabled, pan and zoom operations will not be propagated to other charts.</small>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </div>
- <div role="tabpanel" class="tab-pane" id="settings_visual">
- <form id="optionsForm3" method="get" class="form-horizontal">
- <div class="form-group">
- <table>
- <tr class="option-row">
- <td class="option-control"><input id="netdata_theme_control" type="checkbox" checked data-toggle="toggle" data-offstyle="danger" data-onstyle="success" data-on="Dark" data-off="White" data-width="110px"></td>
- <td class="option-info"><strong>Which theme to use?</strong><br/>
- <small>Netdata comes with two themes: <b>Dark</b> (the default) and <b>White</b>.
- <br/>
- <b>Switching this will reload the dashboard</b>.
- </small>
- </td>
- </tr>
- <tr class="option-row">
- <td class="option-control"><input id="show_help" type="checkbox" checked data-toggle="toggle" data-on="Help Me" data-off="No Help" data-width="110px"></td>
- <td class="option-info"><strong>Do you need help?</strong><br/>
- <small>Netdata can show some help in some areas to help you use the dashboard. If all these balloons bother you, disable them using this switch.
- <br/>
- <b>Switching this will reload the dashboard</b>.
- </small>
- </td>
- </tr>
- <tr class="option-row">
- <td class="option-control"><input id="pan_and_zoom_data_padding" type="checkbox" checked data-toggle="toggle" data-on="Pad" data-off="Don't Pad" data-width="110px"></td>
- <td class="option-info"><strong>Enable data padding when panning and zooming?</strong><br/>
- <small>When set to <b>Pad</b> the charts will be padded with more data, both before and after the visible area, thus giving the impression the whole database is loaded. This padding will happen only after the first pan or zoom operation on the chart (initially all charts have only the visible data). When set to <b>Don't Pad</b> only the visible data will be transfered from the netdata server, even after the first pan and zoom operation.</small>
- </td>
- </tr>
- <tr class="option-row">
- <td class="option-control"><input id="smooth_plot" type="checkbox" checked data-toggle="toggle" data-on="Smooth" data-off="Rough" data-width="110px"></td>
- <td class="option-info"><strong>Enable Bézier lines on charts?</strong><br/>
- <small>When set to <b>Smooth</b> the charts libraries that support it, will plot smooth curves instead of simple straight lines to connect the points.
- <br/>
- Keep in mind <a href="http://dygraphs.com" target="_blank">dygraphs</a>, the main charting library in netdata dashboards, can only smooth line charts. It cannot smooth area or stacked charts. When set to <b>Rough</b>, this setting can lower the CPU resources consumed by your browser.</small>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </div>
- </div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
-
-
- <div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- <h4 class="modal-title" id="updateModalLabel">Update Check</h4>
- </div>
- <div class="modal-body">
- Your netdata version: <b><code><span id="netdataVersion">Unknown</span></code></b>
- <br/>
- <div style="padding: 10px;"></div>
- <div id="versionCheckLog">Not checked yet. Please press the Check Now button.</div>
- </div>
- <div class="modal-footer">
- <a href="#" onclick="notifyForUpdate(true);" type="button" class="btn btn-default">Check Now</a>
- <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
- </div>
- </div>
- </div>
- </div>
-
- <div class="modal fade" id="deleteRegistryModal" tabindex="-1" role="dialog" aria-labelledby="deleteRegistryModalLabel">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- <h4 class="modal-title" id="deleteRegistryModalLabel">Delete <span id="deleteRegistryServerName"></span>?</h4>
- </div>
- <div class="modal-body">
- You are about to delete, from your personal list of netdata servers, the following server:
- <p style="text-align: center; padding-top: 10px; padding-bottom: 10px; line-height: 2;">
- <b><span id="deleteRegistryServerName2"></span></b>
- <br/>
- <b><span id="deleteRegistryServerURL"></span></b>
- </p>
- Are you sure you want to do this?
- <br/>
- <div style="padding: 10px;"></div>
- <small>Keep in mind, this server will be added back if and when you visit it again.</small>
- <br/>
- <div id="deleteRegistryResponse" style="display: block; width: 100%; text-align: center; padding-top: 20px;"></div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-success" data-dismiss="modal">keep it</button>
- <a href="#" onclick="notifyForDeleteRegistry(true); return false;" type="button" class="btn btn-danger">delete it</a>
- </div>
- </div>
- </div>
- </div>
-
- <div class="modal fade" id="switchRegistryModal" tabindex="-1" role="dialog" aria-labelledby="switchRegistryModalLabel">
- <div class="modal-dialog" role="document">
- <div class="modal-content">
- <div class="modal-header">
- <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
- <h4 class="modal-title" id="switchRegistryModalLabel">Switch Netdata Registry Identity</h4>
- </div>
- <div class="modal-body">
- You can copy and paste the following ID to all your browsers (e.g. work and home).
- <br/>
- All the browsers with the same ID will identify <b>you</b>, so please don't share this with others.
- <p style="text-align: center; padding-top: 10px; padding-bottom: 10px; line-height: 2;">
- <form action="#">
- <input type="text" class="form-control" id="switchRegistryPersonGUID" placeholder="your personal ID" maxlength="36" autocomplete="off" style="text-align: center; font-size: 1.4em;">
- </form>
- </p>
- Either copy this ID and paste it to another browser, or paste here the ID you have taken from another browser.
- <p style="padding-top: 10px;"><small>
- Keep in mind that:
- <ul>
- <li>when you switch ID, your previous ID will be lost forever - this is irreversible.</li>
- <li>both IDs (your old and the new) must list this netdata at their personal lists.</li>
- <li>both IDs have to be known by the registry: <b><span id="switchRegistryURL"></span></b>.</li>
- <li>to get a new ID, just clear your browser cookies.</li>
- </ul>
- </small></p>
- <div id="switchRegistryResponse" style="display: block; width: 100%; text-align: center; padding-top: 20px;"></div>
- </div>
- <div class="modal-footer">
- <button type="button" class="btn btn-success" data-dismiss="modal">cancel</button>
- <a href="#" onclick="notifyForSwitchRegistry(true); return false;" type="button" class="btn btn-danger">impersonate</a>
- </div>
- </div>
- </div>
- </div>
-
-<script>
+ <div id="loadOverlay" class="loadOverlay" style="background-color: #888; color: #888;">
+ netdata<br/><div style="font-size: 3vh;">Real-time performance monitoring, done right!</div>
+ </div>
+ <script type="text/javascript">
+ // change the loadOverlay colors ASAP to match the theme
+ document.getElementById('loadOverlay').style = (urlOptions.theme === 'slate')?"background-color:#272b30; color: #373b40;":"background-color:#fff; color: #ddd;";
+ </script>
+ <nav class="navbar navbar-default navbar-fixed-top" role="banner">
+ <div class="container">
+ <nav id="mynetdata_nav" class="collapse navbar-collapse navbar-left hidden-sm hidden-xs" role="navigation" style="padding-right: 20px;">
+ <ul class="nav navbar-nav">
+ <li class="dropdown">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="current_view">my-netdata <strong class="caret"></strong></a>
+ <ul class="dropdown-menu scrollable-menu inpagemenu multi-column columns-2" role="menu">
+ <div class="row">
+ <div class="col-sm-6" style="width: 85%; padding-right: 0;">
+ <ul id="mynetdata_servers" class="multi-column-dropdown">
+ <li><a href="#" onclick="return false;" style="color: #999;">loading...</a></li>
+ </ul>
+ </div>
+ <div class="col-sm-3 hidden-xs" style="width: 15%; padding-left: 0;">
+ <ul id="mynetdata_actions1" class="multi-column-dropdown">
+ <li style="color: #999;">&nbsp;</li>
+ </ul>
+ </div>
+ </div>
+ </ul>
+ </li>
+ </ul>
+ </nav>
+ <div class="navbar-header">
+ <button class="navbar-toggle" type="button" data-toggle="collapse" data-target=".navbar-collapse">
+ <span class="sr-only">Toggle navigation</span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ <span class="icon-bar"></span>
+ </button>
+ <a href="/" class="navbar-brand" id="hostname" title="reload the dashboard">netdata</a>
+ </div>
+ <nav class="collapse navbar-collapse navbar-right" role="navigation">
+ <ul class="nav navbar-nav">
+ <li class="hidden-sm"><a href="#" class="btn" data-toggle="modal" data-target="#alarmsModal" title="alarms"><i class="fa fa-bell"></i><span id="alarms_count_badge" class="badge"></span></a></li>
+ <li class="hidden-sm"><a href="#" class="btn" data-toggle="modal" data-target="#optionsModal" title="dashboard settings"><i class="fa fa-cog"></i></a></li>
+ <li class="hidden-sm"><a href="https://github.com/firehol/netdata/wiki" class="btn" target="_blank" title="netdata community"><i class="fa fa-github"></i></a></li>
+ <li class="hidden-sm" id="updateButton"><a href="#" class="btn" data-toggle="modal" data-target="#updateModal" title="check for update"><i class="fa fa-cloud-download"></i><span id="update_badge" class="badge"></span></a></li>
+ <li class="hidden-sm"><a href="#" class="btn" data-toggle="modal" data-target="#helpModal" title="dashboard help"><i class="fa fa-question-circle"></i></a></li>
+ <li class="dropdown hidden-md hidden-lg hidden-xs">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="current_view">Menu <strong class="caret"></strong></a>
+ <ul class="dropdown-menu scrollable-menu inpagemenu" role="menu">
+ <li><a href="#" class="btn" data-toggle="modal" data-target="#alarmsModal"><i class="fa fa-cog"></i> alarms</a></li>
+ <li><a href="#" class="btn" data-toggle="modal" data-target="#optionsModal"><i class="fa fa-cog"></i> settings</a></li>
+ <li><a href="https://github.com/firehol/netdata/wiki" class="btn" target="_blank"><i class="fa fa-github"></i> community</a></li>
+ <li><a href="#" class="btn" data-toggle="modal" data-target="#helpModal"><i class="fa fa-question-circle"></i> help</a></li>
+ </ul>
+ </li>
+ <li class="dropdown hidden-sm hidden-md hidden-lg">
+ <a href="#" class="dropdown-toggle" data-toggle="dropdown" id="current_view">my-netdata <strong class="caret"></strong></a>
+ <ul id="mynetdata_servers2" class="dropdown-menu scrollable-menu inpagemenu" role="menu">
+ <li><a href="#" onclick="return false;" style="color: #999;">loading...</a></li>
+ </ul>
+ </li>
+ </ul>
+ </nav>
+ </nav>
+ </div>
+ </nav>
+
+ <div id="masthead" style="display: none;">
+ <div class="container">
+ <div class="row">
+ <div class="col-md-7">
+ <h1>Netdata
+ <p class="lead">Real-time performance monitoring, in the greatest possible detail</p>
+ </h1>
+ </div>
+ <div class="col-md-5">
+ <div class="well well-lg">
+ <div class="row">
+ <div class="col-md-6">
+ <b>Drag</b> charts to pan.
+ <b>Shift + wheel</b> on them, to zoom in and out.
+ <b>Double-click</b> on them, to reset.
+ <b>Hover</b> on them too!
+ </div>
+ <div class="col-md-6">
+ <div data-netdata="system.intr" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-dygraph-type="line" data-dygraph-strokewidth="3" data-dygraph-smooth="true" data-dygraph-highlightcirclesize="6" data-after="-90" data-height="60px" data-colors="#C66"></div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="container">
+ <div class="row">
+ <div class="col-md-10" role="main">
+ <div id="charts_div"></div>
+ </div>
+ <div class="col-md-2" role="complementary">
+ <nav class="dashboard-sidebar hidden-print hidden-xs hidden-sm" id="sidebar" role="menu"></nav>
+ </div>
+ </div>
+ </div>
+
+ <div id="footer" class="container" style="display: none;">
+ <div class="row">
+ <div class="col-md-10" role="main">
+ <div class="p">
+ <big><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></big><br/>
+ <i class="fa fa-copyright"></i> Copyright 2016, Costa Tsaousis.<br/>
+ Released under <a href="http://www.gnu.org/licenses/gpl-3.0.en.html" target="_blank">GPL v3 or later</a>.<br/>
+ </div>
+ <div class="p">
+ <small>
+ <a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a> re-distributes these software tools:
+
+ <i class="fa fa-circle"></i> The excellent <a href="http://dygraphs.com/" target="_blank">Dygraphs.com</a> web chart library,
+ <i class="fa fa-copyright"></i> Copyright 2009, Dan Vanderkam, <a href="http://dygraphs.com/legal.html" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://omnipotent.net/jquery.sparkline/" target="_blank">jQuery Sparklines</a> web chart library,
+ <i class="fa fa-copyright"></i> Copyright 2009-2012, Splunk Inc., <a href="http://opensource.org/licenses/BSD-3-Clause" target="_blank">New BSD License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://benpickles.github.io/peity/" target="_blank">Peity</a> web chart library,
+ <i class="fa fa-copyright"></i> Copyright 2009-2015, Ben Pickles, <a href="https://github.com/benpickles/peity/blob/master/MIT-LICENCE" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="https://rendro.github.io/easy-pie-chart/" target="_blank">Easy Pie Chart</a> web chart library,
+ <i class="fa fa-copyright"></i> Copyright 2013, Robert Fleischmann, <a href="https://github.com/rendro/easy-pie-chart/blob/master/LICENSE" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://bernii.github.io/gauge.js/" target="_blank">Gauge.js</a> web chart library,
+ <i class="fa fa-copyright"></i> Copyright, Bernard Kobos, <a href="http://bernii.github.io/gauge.js/" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="https://jquery.org/" target="_blank">jQuery</a>,
+ <i class="fa fa-copyright"></i> Copyright 2015, jQuery Foundation, <a href="https://jquery.org/license/" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://getbootstrap.com/getting-started/" target="_blank">Bootstrap</a>,
+ <i class="fa fa-copyright"></i> Copyright 2015, Twitter, <a href="http://getbootstrap.com/getting-started/#license-faqs" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://www.bootstraptoggle.com/" target="_blank">Bootstrap Toggle</a>,
+ <i class="fa fa-copyright"></i> Copyright (c) 2011-2014 Min Hur, The New York Times Company, <a href="https://github.com/minhur/bootstrap-toggle/blob/master/LICENSE" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="https://jamesflorentino.github.io/nanoScrollerJS/" target="_blank">NanoScroller</a>,
+ <i class="fa fa-copyright"></i> Copyright 2012, James Florentino, <a href="https://github.com/jamesflorentino/nanoScrollerJS/blob/master/LICENSE" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="https://github.com/marcj/css-element-queries" target="_blank">CSS Element Queries</a>,
+ <i class="fa fa-copyright"></i> Copyright Marc J. Schmidt, <a href="https://github.com/marcj/css-element-queries/blob/master/LICENSE" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="https://fortawesome.github.io/Font-Awesome/" target="_blank">FontAwesome</a>,
+ <i class="fa fa-copyright"></i> Created by Dave Gandy, Font: <a href="http://scripts.sil.org/OFL" target="_blank">SIL OFL 1.1 License</a>, CSS: <a href="http://opensource.org/licenses/mit-license.html" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://www.iconsdb.com/soylent-red-icons/seo-performance-icon.html" target="_blank">IconsDB.com Icons</a>, Icons provided as CC0 1.0 Universal (CC0 1.0) Public Domain Dedication.
+
+ <i class="fa fa-circle"></i> <a href="http://morrisjs.github.io/morris.js/" target="_blank">morris.js</a>,
+ <i class="fa fa-copyright"></i> Copyright 2013, Olly Smith, <a href="http://morrisjs.github.io/morris.js/" target="_blank">Simplified BSD License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://raphaeljs.com/" target="_blank">Raphaël</a>,
+ <i class="fa fa-copyright"></i> Copyright 2008, Dmitry Baranovskiy, <a href="http://raphaeljs.com/license.html" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://C3js.org/" target="_blank">C3</a>,
+ <i class="fa fa-copyright"></i> Copyright 2013, Masayuki Tanaka, <a href="https://github.com/masayuki0812/c3/blob/master/LICENSE" target="_blank">MIT License</a>
+
+ <i class="fa fa-circle"></i> <a href="http://D3js.org/" target="_blank">D3</a>,
+ <i class="fa fa-copyright"></i> Copyright 2015, Mike Bostock, <a href="http://opensource.org/licenses/BSD-3-Clause" target="_blank">BSD License</a>
+
+ </small>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="welcomeModal" tabindex="-1" role="dialog" aria-labelledby="welcomeModalLabel">
+ <div class="modal-dialog modal-lg" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="welcomeModalLabel">Welcome!</h4>
+ </div>
+ <div class="modal-body">
+ <div class="p">
+ <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> is the fastest way to visualize metrics. It is a resource efficient, highly optimized system for collecting and visualizing any type of real-time time series data, from CPU usage, disk activity, SQL queries, API calls, web site visitors, etc.
+ </div>
+ <div class="p">
+ <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> tries to visualize the truth of <b>now</b>, in its <b>greatest detail</b>, so that you can get insights of what is happening now and what just happened, on your systems and applications.
+ </div>
+ <div class="p">
+ To make a chart in <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b>, you just need a <b>number</b>. Just a number you can read somehow. <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> will turn this number to a real time, interactive, web chart. For collecting these numbers, it supports <a href="https://github.com/firehol/netdata/wiki/External-Plugins" target="_blank">external plugins</a>, even <a href="https://github.com/firehol/netdata/wiki/General-Info---charts.d" target="_blank">shell</a> or <a href="https://github.com/firehol/netdata/wiki/General-Info---charts.d" target="_blank">node.js</a> plugins. Any computer program, in any language, that can print a few lines of text on its standard output, can be a netdata data collector.
+ </div>
+ <div class="p">
+ <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> can embed charts everywhere, like this one <div data-netdata="system.cpu" data-dimensions="system" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-show-value-of-system-at="system.cpu.system.modal.1"></div> (my CPU system usage which is <span id="system.cpu.system.modal.1" style="display: inline-block; width: 40px; text-align: right;"></span>%),
+ or this one <div data-netdata="ipv4.tcppackets" data-dimensions="received" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-show-value-of-received-at="ipv4.tcppackets.received.modal.1"></div> (my IPv4 received TCP packets, which are <span id="ipv4.tcppackets.received.modal.1" style="display: inline-block; width: 60px; text-align: right;"></span>/second).
+ </div>
+ <div class="p">
+ You can have <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> charts on your site too. Just give it a <code>div</code> and a real time chart, zoomable and draggable will appear (try it even on these tiny ones - <b>drag</b> them to pan horizontally, <b>shift + drag</b> to zoom in, on <b>chrome shift + mouse wheel</b> to zoom in/out, <b>double click</b> on them to reset them - don't be afraid of <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata</a></b> performance - <a href="https://github.com/firehol/netdata/wiki/Performance" target="_blank">a raspberry pi 2 can sustain 300 charts updates per second</a>!).
+ </div>
+ <div class="p">
+ For more information please refer to the <b><a href="https://github.com/firehol/netdata/wiki" target="_blank">netdata wiki</a></b>.
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="helpModal" tabindex="-1" role="dialog" aria-labelledby="helpModalLabel">
+ <div class="modal-dialog modal-lg" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="helpModalLabel">Dashboard Help</h4>
+ </div>
+ <div class="modal-body">
+
+ <h4>Dygraphs (line, area and stacked area charts)</h4>
+
+ <!-- Nav tabs -->
+ <ul class="nav nav-tabs" role="tablist">
+ <li role="presentation" class="active"><a href="#help_mouse" aria-controls="help_mouse" role="tab" data-toggle="tab">Mouse Interface</a></li>
+ <li role="presentation"><a href="#help_touch" aria-controls="help_touch" role="tab" data-toggle="tab">Touch Interface</a></li>
+ </ul>
+
+ <!-- Tab panes -->
+ <div class="tab-content">
+ <div role="tabpanel" class="tab-pane active" id="help_mouse">
+ <div class="p">
+ <h4>Mouse Over / Hover</h4>
+ Mouse over on a chart to show, at its legend, the values for the timestamp under the mouse (the chart will also highlight the point at the chart).
+ <br/>
+ All the other visible charts will also show and highlight their values for the same timestamp.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>Drag Chart Contents</h4>
+ Drag the contents of a chart to pan it horizontally.
+ <br/>
+ All the charts will follow soon after you let the chart alone (this little delay is by design: it speeds up your browser and lets you focus on what you are exploring).
+ <br/>
+ Once a chart is panned, auto refreshing stops for all charts. To enable it again, <b>double click</b> a panned chart.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>Double Click</h4>
+ Double Click a chart to reset all the charts to their default auto-refreshing state.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>SHIFT + Drag</h4>
+ While pressing the shift key, click on the contents of a chart and move the mouse to select an area, to zoom in. The other charts will follow too. Zooming is performed in two phases:
+ <ul>
+ <li>The already loaded chart contents are zoomed (low resolution)</li>
+ <li>New data are transferred from the netdata server, to refresh the chart with possibly more detail.</li>
+ </ul>
+ Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>SHIFT + Mouse Wheel <small>(does not work on firefox and IE/Edge)</small></h4>
+ While pressing the shift key and the mouse pointer is over the contents of a chart, scroll the mouse wheel to zoom in or out. This kind of zooming is aligned to center below the mouse pointer. The other charts will follow too.
+ <br/>
+ Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>Legend Operations</h4>
+ Click on the label or value of a dimension, will select / un-select this dimension.
+ <br/>
+ You can press any of the SHIFT or CONTROL keys and then click on legend labels or values, to select / un-select multiple dimensions.
+ </div>
+ </div>
+ <div role="tabpanel" class="tab-pane" id="help_touch">
+ <div class="p">
+ <h4>Single Tap</h4>
+ Single Tap on the contents of a chart to show, at its legend, the values for the timestamp tapped (the chart will also highlight the point at the chart).
+ <br/>
+ All the other visible charts will also show and highlight their values for the same timestamp.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>Drag Chart Contents</h4>
+ Touch and Drag the contents of a chart to pan it horizontally.
+ <br/>
+ All the charts will follow soon after you let the chart alone (this little delay is by design: it speeds up your browser and lets you focus on what you are exploring).
+ <br/>
+ Once a chart is panned, auto refreshing stops for all charts. To enable it again, <b>double tap</b> a panned chart.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>Double Tap</h4>
+ Double tap a chart to reset all the charts to their default auto-refreshing state.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>Zoom <small>(does not work on firefox and IE/Edge)</small></h4>
+ With two fingers, zoom in or out.
+ <br/>
+ Once a chart is zoomed, auto refreshing stops for all charts. To enable it again, <b>double click</b> a zoomed chart.
+ </div>
+ <hr/>
+ <div class="p">
+ <h4>Legend Operations</h4>
+ Tap on the label or value of a dimension, will select / un-select this dimension.
+ </div>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="alarmsModal" tabindex="-1" role="dialog" aria-labelledby="alarmsModalLabel">
+ <div class="modal-dialog modal-lg" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="alarmsModalLabel">netdata alarms</h4>
+ </div>
+ <div class="modal-body">
+ <!-- Nav tabs -->
+ <ul class="nav nav-tabs" role="tablist">
+ <li role="presentation" class="active"><a href="#alarms_active" aria-controls="alarms_active" role="tab" data-toggle="tab">Active</a></li>
+ <li role="presentation"><a href="#alarms_all" aria-controls="alarms_all" role="tab" data-toggle="tab">All</a></li>
+ <li role="presentation"><a href="#alarms_log" aria-controls="alarms_log" role="tab" data-toggle="tab">Log</a></li>
+ </ul>
+
+ <!-- Tab panes -->
+ <div class="tab-content">
+ <div role="tabpanel" class="tab-pane active" id="alarms_active">
+ loading...
+ </div>
+ <div role="tabpanel" class="tab-pane" id="alarms_all">
+ loading...
+ </div>
+ <div role="tabpanel" class="tab-pane" id="alarms_log">
+ loading...
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <!-- <a href="#" onclick="alarmsUpdateModal(); return false;" type="button" class="btn btn-default">Update</a> -->
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="optionsModal" tabindex="-1" role="dialog" aria-labelledby="optionsModalLabel">
+ <div class="modal-dialog modal-lg" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="optionsModalLabel">netdata dashboard options</h4>
+ </div>
+ <div class="modal-body">
+ <center>
+ <small style="color: #BBBBBB;">These are browser settings. Each viewer has its own. They do not affect the operation of your netdata server.
+ <br/>
+ Settings take effect immediately and are saved permanently to browser local storage (except the refresh on focus / always option).
+ <br/>
+ To reset all options (including charts sizes) to their defaults, click <a href="#" onclick="resetDashboardOptions(); return false;">here</a>.</small>
+ </center>
+ <div style="padding: 10px;"></div>
+
+ <!-- Nav tabs -->
+ <ul class="nav nav-tabs" role="tablist">
+ <li role="presentation" class="active"><a href="#settings_performance" aria-controls="settings_performance" role="tab" data-toggle="tab">Performance</a></li>
+ <li role="presentation"><a href="#settings_sync" aria-controls="settings_sync" role="tab" data-toggle="tab">Synchronization</a></li>
+ <li role="presentation"><a href="#settings_visual" aria-controls="settings_visual" role="tab" data-toggle="tab">Visual</a></li>
+ </ul>
+
+ <!-- Tab panes -->
+ <div class="tab-content">
+ <div role="tabpanel" class="tab-pane active" id="settings_performance">
+ <form id="optionsForm1" method="get" class="form-horizontal">
+ <div class="form-group">
+ <table>
+ <tr class="option-row">
+ <td class="option-control"><input id="stop_updates_when_focus_is_lost" type="checkbox" checked data-toggle="toggle" data-offstyle="danger" data-onstyle="success" data-on="On Focus" data-off="Always" data-width="110px"></td>
+ <td class="option-info"><strong>When to refresh the charts?</strong><br/>
+ <small>When set to <b>On Focus</b>, the charts will stop being updated if the page / tab does not have the focus of the user. When set to <b>Always</b>, the charts will always be refreshed. Set it to <b>On Focus</b> it to lower the CPU requirements of the browser (and extend the battery of laptops and tablets) when this page does not have your focus. Set to <b>Always</b> to work on another window (i.e. change the settings of something) and have the charts auto-refresh in this window.</small>
+ </td>
+ </tr>
+ <tr class="option-row">
+ <td class="option-control">
+ <input id="eliminate_zero_dimensions" type="checkbox" checked data-toggle="toggle" data-on="Non Zero" data-off="All" data-width="110px">
+ </td>
+ <td class="option-info"><strong>Which dimensions to show?</strong><br/>
+ <small>When set to <b>Non Zero</b>, dimensions that have all their values (within the current view) set to zero will not be transferred from the netdata server (except if all dimensions of the chart are zero, in which case this setting does nothing - all dimensions are transferred and shown). When set to <b>All</b>, all dimensions will always be shown. Set it to <b>Non Zero</b> to lower the data transferred between netdata and your browser, lower the CPU requirements of your browser (fewer lines to draw) and increase the focus on the legends (fewer entries at the legends).</small>
+ </td>
+ </tr>
+ <tr class="option-row">
+ <td class="option-control"><input id="destroy_on_hide" type="checkbox" data-toggle="toggle" data-on="Destroy" data-off="Hide" data-width="110px"></td>
+ <td class="option-info"><strong>How to handle hidden charts?</strong><br/>
+ <small>When set to <b>Destroy</b>, charts that are not in the current viewport of the browser (are above, or below the visible area of the page), will be destroyed and re-created if and when they become visible again. When set to <b>Hide</b>, the not-visible charts will be just hidden, to simplify the DOM and speed up your browser. Set it to <b>Destroy</b>, to lower the memory requirements of your browser. Set it to <b>Hide</b> for smoother page scrolling.</small>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ </div>
+ <div role="tabpanel" class="tab-pane" id="settings_sync">
+ <form id="optionsForm2" method="get" class="form-horizontal">
+ <div class="form-group">
+ <table>
+ <tr class="option-row">
+ <td class="option-control"><input id="parallel_refresher" type="checkbox" checked data-toggle="toggle" data-on="Parallel" data-off="Sequential" data-width="110px"></td>
+ <td class="option-info"><strong>Which chart refresh policy to use?</strong><br/>
+ <small>When set to <b>parallel</b>, visible charts are refreshed in parallel (all queries are sent to netdata server in parallel) and are rendered asynchronously. When set to <b>sequential</b> charts are refreshed one after another. Set it to parallel if your browser can cope with it (most modern browsers do), set it to sequential if you work on an older/slower computer.</small>
+ </td>
+ </tr>
+ <tr class="option-row" id="concurrent_refreshes_row">
+ <td class="option-control"></td>
+ <td class="option-info">
+ <table>
+ <tr class="option-row">
+ <td class="option-control">
+ <input id="concurrent_refreshes" type="checkbox" checked data-toggle="toggle" data-on="Resync" data-off="Best Effort" data-width="110px">
+ </td>
+ <td class="option-info">
+ <strong>Shall we re-sync chart refreshes?</strong><br/>
+ <small>When set to <b>Resync</b>, the dashboard will attempt to re-synchronize all the charts so that they are refreshed concurrently. When set to <b>Best Effort</b>, each chart may be refreshed with a little time difference to the others. Normally, the dashboard starts refreshing them in parallel, but depending on the speed of your computer and the network latencies, charts start having a slight time difference. Setting this to <b>Resync</b> will attempt to re-synchronize the charts on every update. Setting it to <b>Best Effort</b> may lower the pressure on your browser and the network.</small>
+ </td>
+ </tr>
+ </table>
+ </td>
+ </tr>
+ <tr class="option-row">
+ <td class="option-control"><input id="sync_selection" type="checkbox" checked data-toggle="toggle" data-on="Sync" data-off="Don't Sync" data-onstyle="success" data-offstyle="danger" data-width="110px"></td>
+ <td class="option-info"><strong>Sync hover selection on all charts?</strong><br/>
+ <small>When enabled, a selection on one chart will automatically select the same time on all other visible charts and the legends of all visible charts will be updated to show the selected values. When disabled, only the chart getting the user's attention will be selected. Enable it to get better insights of the data. Disable it if you are on a very slow computer that cannot actually do it.</small>
+ </td>
+ </tr>
+ <tr class="option-row">
+ <td class="option-control"><input id="sync_pan_and_zoom" type="checkbox" checked data-toggle="toggle" data-on="Sync" data-off="Don't Sync" data-onstyle="success" data-offstyle="danger" data-width="110px"></td>
+ <td class="option-info"><strong>Sync pan and zoom on all charts?</strong><br/>
+ <small>When enabled, pan and zoom operations on a chart will be replicated to all charts (even the ones that are not currently visible - of course only when they will become visible). When disabled, pan and zoom operations will not be propagated to other charts.</small>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ </div>
+ <div role="tabpanel" class="tab-pane" id="settings_visual">
+ <form id="optionsForm3" method="get" class="form-horizontal">
+ <div class="form-group">
+ <table>
+ <tr class="option-row">
+ <td class="option-control"><input id="netdata_theme_control" type="checkbox" checked data-toggle="toggle" data-offstyle="danger" data-onstyle="success" data-on="Dark" data-off="White" data-width="110px"></td>
+ <td class="option-info"><strong>Which theme to use?</strong><br/>
+ <small>Netdata comes with two themes: <b>Dark</b> (the default) and <b>White</b>.
+ <br/>
+ <b>Switching this will reload the dashboard</b>.
+ </small>
+ </td>
+ </tr>
+ <tr class="option-row">
+ <td class="option-control"><input id="show_help" type="checkbox" checked data-toggle="toggle" data-on="Help Me" data-off="No Help" data-width="110px"></td>
+ <td class="option-info"><strong>Do you need help?</strong><br/>
+ <small>Netdata can show some help in some areas to help you use the dashboard. If all these balloons bother you, disable them using this switch.
+ <br/>
+ <b>Switching this will reload the dashboard</b>.
+ </small>
+ </td>
+ </tr>
+ <tr class="option-row">
+ <td class="option-control"><input id="pan_and_zoom_data_padding" type="checkbox" checked data-toggle="toggle" data-on="Pad" data-off="Don't Pad" data-width="110px"></td>
+ <td class="option-info"><strong>Enable data padding when panning and zooming?</strong><br/>
+ <small>When set to <b>Pad</b> the charts will be padded with more data, both before and after the visible area, thus giving the impression the whole database is loaded. This padding will happen only after the first pan or zoom operation on the chart (initially all charts have only the visible data). When set to <b>Don't Pad</b> only the visible data will be transfered from the netdata server, even after the first pan and zoom operation.</small>
+ </td>
+ </tr>
+ <tr class="option-row">
+ <td class="option-control"><input id="smooth_plot" type="checkbox" checked data-toggle="toggle" data-on="Smooth" data-off="Rough" data-width="110px"></td>
+ <td class="option-info"><strong>Enable Bézier lines on charts?</strong><br/>
+ <small>When set to <b>Smooth</b> the charts libraries that support it, will plot smooth curves instead of simple straight lines to connect the points.
+ <br/>
+ Keep in mind <a href="http://dygraphs.com" target="_blank">dygraphs</a>, the main charting library in netdata dashboards, can only smooth line charts. It cannot smooth area or stacked charts. When set to <b>Rough</b>, this setting can lower the CPU resources consumed by your browser.</small>
+ </td>
+ </tr>
+ </table>
+ </div>
+ </form>
+ </div>
+ </div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+
+ <div class="modal fade" id="updateModal" tabindex="-1" role="dialog" aria-labelledby="updateModalLabel">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="updateModalLabel">Update Check</h4>
+ </div>
+ <div class="modal-body">
+ Your netdata version: <b><code><span id="netdataVersion">Unknown</span></code></b>
+ <br/>
+ <div style="padding: 10px;"></div>
+ <div id="versionCheckLog">Not checked yet. Please press the Check Now button.</div>
+ </div>
+ <div class="modal-footer">
+ <a href="#" onclick="notifyForUpdate(true); return false;" type="button" class="btn btn-default">Check Now</a>
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="deleteRegistryModal" tabindex="-1" role="dialog" aria-labelledby="deleteRegistryModalLabel">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="deleteRegistryModalLabel">Delete <span id="deleteRegistryServerName"></span>?</h4>
+ </div>
+ <div class="modal-body">
+ You are about to delete, from your personal list of netdata servers, the following server:
+ <p style="text-align: center; padding-top: 10px; padding-bottom: 10px; line-height: 2;">
+ <b><span id="deleteRegistryServerName2"></span></b>
+ <br/>
+ <b><span id="deleteRegistryServerURL"></span></b>
+ </p>
+ Are you sure you want to do this?
+ <br/>
+ <div style="padding: 10px;"></div>
+ <small>Keep in mind, this server will be added back if and when you visit it again.</small>
+ <br/>
+ <div id="deleteRegistryResponse" style="display: block; width: 100%; text-align: center; padding-top: 20px;"></div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-success" data-dismiss="modal">keep it</button>
+ <a href="#" onclick="notifyForDeleteRegistry(true); return false;" type="button" class="btn btn-danger">delete it</a>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="switchRegistryModal" tabindex="-1" role="dialog" aria-labelledby="switchRegistryModalLabel">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="switchRegistryModalLabel">Switch Netdata Registry Identity</h4>
+ </div>
+ <div class="modal-body">
+ You can copy and paste the following ID to all your browsers (e.g. work and home).
+ <br/>
+ All the browsers with the same ID will identify <b>you</b>, so please don't share this with others.
+ <p style="text-align: center; padding-top: 10px; padding-bottom: 10px; line-height: 2;">
+ <form action="#">
+ <input type="text" class="form-control" id="switchRegistryPersonGUID" placeholder="your personal ID" maxlength="36" autocomplete="off" style="text-align: center; font-size: 1.4em;">
+ </form>
+ </p>
+ Either copy this ID and paste it to another browser, or paste here the ID you have taken from another browser.
+ <p style="padding-top: 10px;"><small>
+ Keep in mind that:
+ <ul>
+ <li>when you switch ID, your previous ID will be lost forever - this is irreversible.</li>
+ <li>both IDs (your old and the new) must list this netdata at their personal lists.</li>
+ <li>both IDs have to be known by the registry: <b><span id="switchRegistryURL"></span></b>.</li>
+ <li>to get a new ID, just clear your browser cookies.</li>
+ </ul>
+ </small></p>
+ <div id="switchRegistryResponse" style="display: block; width: 100%; text-align: center; padding-top: 20px;"></div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-success" data-dismiss="modal">cancel</button>
+ <a href="#" onclick="notifyForSwitchRegistry(true); return false;" type="button" class="btn btn-danger">impersonate</a>
+ </div>
+ </div>
+ </div>
+ </div>
+
+ <div class="modal fade" id="gotoServerModal" tabindex="-1" role="dialog" aria-labelledby="gotoServerModalLabel">
+ <div class="modal-dialog" role="document">
+ <div class="modal-content">
+ <div class="modal-header">
+ <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
+ <h4 class="modal-title" id="gotoServerModalLabel"><span id="gotoServerName"></span></h4>
+ </div>
+ <div class="modal-body">
+ Checking known URLs for this server...
+ <div style="padding-top: 20px;">
+ <table id="gotoServerList">
+ </table>
+ </div>
+ <p style="padding-top: 10px;"><small>
+ Checks may fail if you are viewing an HTTPS page and the server to be checked is HTTP only.
+ </small></p>
+ <div id="gotoServerResponse" style="display: block; width: 100%; text-align: center; padding-top: 20px;"></div>
+ </div>
+ <div class="modal-footer">
+ <button type="button" class="btn btn-default" data-dismiss="modal">Close</button>
+ </div>
+ </div>
+ </div>
+ </div>
+
+<script type="text/javascript">
var this_is_demo = null;
function isdemo() {
- if(this_is_demo !== null) return this_is_demo;
- this_is_demo = false;
-
- try {
- if(typeof document.location.hostname === 'string') {
- if(document.location.hostname.endsWith('.my-netdata.io') ||
- document.location.hostname.endsWith('.mynetdata.io') ||
- document.location.hostname.endsWith('.netdata.rocks') ||
- document.location.hostname.endsWith('.firehol.org') ||
- document.location.hostname.endsWith('.netdata.online'))
- this_is_demo = true;
- }
- }
- catch(error) {
- ;
- }
-
- return this_is_demo;
+ if(this_is_demo !== null) return this_is_demo;
+ this_is_demo = false;
+
+ try {
+ if(typeof document.location.hostname === 'string') {
+ if(document.location.hostname.endsWith('.my-netdata.io') ||
+ document.location.hostname.endsWith('.mynetdata.io') ||
+ document.location.hostname.endsWith('.netdata.rocks') ||
+ document.location.hostname.endsWith('.firehol.org') ||
+ document.location.hostname.endsWith('.netdata.online'))
+ this_is_demo = true;
+ }
+ }
+ catch(error) {
+ ;
+ }
+
+ return this_is_demo;
}
if(isdemo()) {
- document.getElementById('masthead').style.display = 'block';
+ document.getElementById('masthead').style.display = 'block';
+}
+
+function netdataURL(url) {
+ if(typeof url === 'undefined')
+ url = document.location.toString();
+
+ if(url.indexOf('#') !== -1)
+ url = url.substring(0, url.indexOf('#'));
+
+ var hash = netdataHash();
+
+ // console.log('netdataURL: ' + url + hash);
+
+ return url + hash;
+}
+
+function netdataReload(url) {
+ var t = netdataURL(url);
+ // console.log('netdataReload: ' + t);
+ document.location = t;
+
+ // since we play with hash
+ // this is needed to reload the page
+ location.reload();
+}
+
+var gotoServerValidateRemaining = 0;
+var gotoServerMiddleClick = false;
+var gotoServerStop = false;
+function gotoServerValidateUrl(id, guid, url) {
+ var penaldy = 0;
+ if(document.location.toString().startsWith('http://') && url.toString().startsWith('https://'))
+ // we penalize https only if the current url is http
+ // to allow the user walk through all its servers.
+ penaldy = 500;
+
+ var finalURL = netdataURL(url);
+
+ setTimeout(function() {
+ document.getElementById('gotoServerList').innerHTML += '<tr><td style="padding-left: 20px;"><a href="' + finalURL + '" target="_blank">' + url + '</a></td><td style="padding-left: 30px;"><code id="' + guid + '-' + id + '-status">checking...</code></td></tr>';
+
+ NETDATA.registry.hello(url, function(data) {
+ if (data) {
+ // console.log('OK ' + id + ' URL: ' + url);
+ document.getElementById(guid + '-' + id + '-status').innerHTML = "OK";
+
+ if(!gotoServerStop) {
+ gotoServerStop = true;
+
+ if(gotoServerMiddleClick) {
+ window.open(finalURL, '_blank');
+ gotoServerMiddleClick = false;
+ document.getElementById('gotoServerResponse').innerHTML = '<b>Opening new window to ' + NETDATA.registry.machines[guid].name + '<br/><a href="' + finalURL + '">' + url + '</a></b><br/>(check your pop-up blocker if it fails)';
+ }
+ else
+ document.location = finalURL;
+ }
+ }
+ else {
+ document.getElementById(guid + '-' + id + '-status').innerHTML = "failed!";
+ gotoServerValidateRemaining--;
+ if(gotoServerValidateRemaining <= 0) {
+ gotoServerMiddleClick = false;
+ document.getElementById('gotoServerResponse').innerHTML = '<b>Sorry! I cannot find any operational URL for this server</b>';
+ }
+ }
+ });
+ }, (id * 50) + penaldy);
+}
+
+function gotoServerModalHandler(guid) {
+ // console.log('goto server: ' + guid);
+
+ gotoServerStop = false;
+ var len = NETDATA.registry.machines[guid].alternate_urls.length;
+
+ document.getElementById('gotoServerResponse').innerHTML = '';
+ document.getElementById('gotoServerList').innerHTML = '';
+ document.getElementById('gotoServerName').innerHTML = NETDATA.registry.machines[guid].name;
+ $('#gotoServerModal').modal('show');
+
+ gotoServerValidateRemaining = len;
+ while(len--)
+ gotoServerValidateUrl(len, guid, NETDATA.registry.machines[guid].alternate_urls[len]);
+
+ return false;
+}
+
+function gotoServerInit() {
+ $(".registry_link").on('click', function(e) {
+ if(e.which === 2) {
+ e.preventDefault();
+ gotoServerMiddleClick = true;
+ }
+ else {
+ gotoServerMiddleClick = false;
+ }
+
+ return true;
+ });
}
function switchRegistryModalHandler() {
- document.getElementById('switchRegistryPersonGUID').value = NETDATA.registry.person_guid;
- document.getElementById('switchRegistryURL').innerHTML = NETDATA.registry.server;
- document.getElementById('switchRegistryResponse').innerHTML = '';
- $('#switchRegistryModal').modal('show');
+ document.getElementById('switchRegistryPersonGUID').value = NETDATA.registry.person_guid;
+ document.getElementById('switchRegistryURL').innerHTML = NETDATA.registry.server;
+ document.getElementById('switchRegistryResponse').innerHTML = '';
+ $('#switchRegistryModal').modal('show');
}
function notifyForSwitchRegistry() {
- var n = document.getElementById('switchRegistryPersonGUID').value;
-
- if(n !== '' && n.length === 36) {
- NETDATA.registry.switch(n, function(result) {
- if(result !== null) {
- $('#switchRegistryModal').modal('hide');
- NETDATA.registry.init();
- }
- else {
- document.getElementById('switchRegistryResponse').innerHTML = "<b>Sorry! The registry rejected your request.</b>";
- }
- });
- }
- else
- document.getElementById('switchRegistryResponse').innerHTML = "<b>The ID you have entered is not a GUID.</b>";
+ var n = document.getElementById('switchRegistryPersonGUID').value;
+
+ if(n !== '' && n.length === 36) {
+ NETDATA.registry.switch(n, function(result) {
+ if(result !== null) {
+ $('#switchRegistryModal').modal('hide');
+ NETDATA.registry.init();
+ }
+ else {
+ document.getElementById('switchRegistryResponse').innerHTML = "<b>Sorry! The registry rejected your request.</b>";
+ }
+ });
+ }
+ else
+ document.getElementById('switchRegistryResponse').innerHTML = "<b>The ID you have entered is not a GUID.</b>";
}
var deleteRegistryUrl = null;
function deleteRegistryModalHandler(guid, name, url) {
- deleteRegistryUrl = url;
- document.getElementById('deleteRegistryServerName').innerHTML = name;
- document.getElementById('deleteRegistryServerName2').innerHTML = name;
- document.getElementById('deleteRegistryServerURL').innerHTML = url;
- document.getElementById('deleteRegistryResponse').innerHTML = '';
- $('#deleteRegistryModal').modal('show');
+ deleteRegistryUrl = url;
+ document.getElementById('deleteRegistryServerName').innerHTML = name;
+ document.getElementById('deleteRegistryServerName2').innerHTML = name;
+ document.getElementById('deleteRegistryServerURL').innerHTML = url;
+ document.getElementById('deleteRegistryResponse').innerHTML = '';
+ $('#deleteRegistryModal').modal('show');
}
function notifyForDeleteRegistry() {
- if(deleteRegistryUrl) {
- NETDATA.registry.delete(deleteRegistryUrl, function(result) {
- if(result !== null) {
- deleteRegistryUrl = null;
- $('#deleteRegistryModal').modal('hide');
- NETDATA.registry.init();
- }
- else {
- document.getElementById('deleteRegistryResponse').innerHTML = "<b>Sorry! this command was rejected by the registry server.</b>";
- }
- });
- }
+ if(deleteRegistryUrl) {
+ NETDATA.registry.delete(deleteRegistryUrl, function(result) {
+ if(result !== null) {
+ deleteRegistryUrl = null;
+ $('#deleteRegistryModal').modal('hide');
+ NETDATA.registry.init();
+ }
+ else {
+ document.getElementById('deleteRegistryResponse').innerHTML = "<b>Sorry! this command was rejected by the registry server.</b>";
+ }
+ });
+ }
}
var options = {
- sparklines_registry: {},
- submenu_names: {},
- data: null,
- hostname: 'netdata_server', // will be overwritten by the netdata server
- categories: new Array(),
- categories_idx: {},
- families: new Array(),
- families_idx: {},
-
- chartsPerRow: 0,
- chartsMinWidth: 1450,
- chartsHeight: 180,
- sparklinesHeight: 60
+ sparklines_registry: {},
+ menus: {},
+ submenu_names: {},
+ data: null,
+ hostname: 'netdata_server', // will be overwritten by the netdata server
+ categories: new Array(),
+ categories_idx: {},
+ families: new Array(),
+ families_idx: {},
+
+ chartsPerRow: 0,
+ chartsMinWidth: 1450,
+ chartsHeight: 180,
+ sparklinesHeight: 60,
};
// generate a sparkline
// used in the documentation
function sparkline(chart, dimension, units) {
- var key = chart + '.' + dimension;
+ var key = chart + '.' + dimension;
- if(typeof units === 'undefined')
- units = '';
+ if(typeof units === 'undefined')
+ units = '';
- if(typeof options.sparklines_registry[key] === 'undefined')
- options.sparklines_registry[key] = { count: 1 };
- else
- options.sparklines_registry[key].count++;
+ if(typeof options.sparklines_registry[key] === 'undefined')
+ options.sparklines_registry[key] = { count: 1 };
+ else
+ options.sparklines_registry[key].count++;
- key = key + '.' + options.sparklines_registry[key].count;
+ key = key + '.' + options.sparklines_registry[key].count;
- var h = '<div data-netdata="' + chart + '" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-dimensions="' + dimension + '" data-show-value-of-' + dimension + '-at="' + key + '"></div> (<span id="' + key + '" style="display: inline-block; min-width: 50px; text-align: right;">X</span>' + units + ')';
+ var h = '<div data-netdata="' + chart + '" data-after="-120" data-width="25%" data-height="15px" data-chart-library="dygraph" data-dygraph-theme="sparkline" data-dimensions="' + dimension + '" data-show-value-of-' + dimension + '-at="' + key + '"></div> (<span id="' + key + '" style="display: inline-block; min-width: 50px; text-align: right;">X</span>' + units + ')';
- return h;
+ return h;
}
function chartsPerRow(total) {
- if(options.chartsPerRow === 0) {
- width = Math.floor(total / options.chartsMinWidth);
- if(width === 0) width = 1;
- return width;
- }
- else return options.chartsPerRow;
+ if(options.chartsPerRow === 0) {
+ width = Math.floor(total / options.chartsMinWidth);
+ if(width === 0) width = 1;
+ return width;
+ }
+ else return options.chartsPerRow;
}
function prioritySort(a, b) {
- if(a.priority < b.priority) return -1;
- if(a.priority > b.priority) return 1;
- if(a.name < b.name) return -1;
- return 1;
+ if(a.priority < b.priority) return -1;
+ if(a.priority > b.priority) return 1;
+ if(a.name < b.name) return -1;
+ return 1;
}
function sortObjectByPriority(object) {
- var idx = {};
- var sorted = new Array();
-
- for(var i in object) {
- if(typeof idx[i] === 'undefined') {
- idx[i] = object[i];
- sorted.push(i);
- }
- }
-
- sorted.sort(function(a, b) {
- if(idx[a].priority < idx[b].priority) return -1;
- if(idx[a].priority > idx[b].priority) return 1;
- if(a < b) return -1;
- return 1;
- });
-
- return sorted;
+ var idx = {};
+ var sorted = new Array();
+
+ for(var i in object) {
+ if(typeof idx[i] === 'undefined') {
+ idx[i] = object[i];
+ sorted.push(i);
+ }
+ }
+
+ sorted.sort(function(a, b) {
+ if(idx[a].priority < idx[b].priority) return -1;
+ if(idx[a].priority > idx[b].priority) return 1;
+ if(a < b) return -1;
+ return 1;
+ });
+
+ return sorted;
+}
+
+
+// ----------------------------------------------------------------------------
+// scroll to a section, without changing the browser history
+
+function scrollToId(hash) {
+ if(hash && hash != '') {
+ var offset = $('#' + hash).offset();
+ if(typeof offset !== 'undefined')
+ $('html, body').animate({ scrollTop: offset.top }, 0);
+ }
+
+ // we must return false to prevent the default action
+ return false;
}
// ----------------------------------------------------------------------------
function gaugeChart(title, width, dimensions, colors) {
- if(typeof colors === 'undefined')
- colors = '';
-
- if(typeof dimensions === 'undefined')
- dimensions = '';
-
- return '<div data-netdata="CHART_UNIQUE_ID"'
- + ' data-dimensions="' + dimensions + '"'
- + ' data-chart-library="gauge"'
- + ' data-gauge-adjust="width"'
- + ' data-title="' + title + '"'
- + ' data-width="' + width + '"'
- + ' data-before="0"'
- + ' data-after="-CHART_DURATION"'
- + ' data-points="CHART_DURATION"'
- + ' data-colors="' + colors + '"'
- + ' role="application"></div>';
+ if(typeof colors === 'undefined')
+ colors = '';
+
+ if(typeof dimensions === 'undefined')
+ dimensions = '';
+
+ return '<div data-netdata="CHART_UNIQUE_ID"'
+ + ' data-dimensions="' + dimensions + '"'
+ + ' data-chart-library="gauge"'
+ + ' data-gauge-adjust="width"'
+ + ' data-title="' + title + '"'
+ + ' data-width="' + width + '"'
+ + ' data-before="0"'
+ + ' data-after="-CHART_DURATION"'
+ + ' data-points="CHART_DURATION"'
+ + ' data-colors="' + colors + '"'
+ + ' role="application"></div>';
}
// ----------------------------------------------------------------------------
var menuData = {
- 'system': {
- title: 'System Overview',
- info: 'Overview of the key system metrics.'
- },
-
- 'ap': {
- title: 'Access Points',
- info: undefined
- },
-
- 'tc': {
- title: 'Quality of Service',
- info: 'Netdata collects and visualizes tc class utilization using its <a href="https://github.com/firehol/netdata/blob/master/plugins.d/tc-qos-helper.sh" target="_blank">tc-helper plugin</a>. If you also use <a href="http://firehol.org/#fireqos" target="_blank">FireQOS</a> for setting up QoS, netdata automatically collects interface and class names. If your QoS configuration includes overheads calculation, the values shown here will include these overheads (the total bandwidth for the same interface as reported in the Network Interfaces section, will be lower than the total bandwidth reported here). Also, data collection may have a slight time difference compared to the interface (QoS data collection is implemented with a BASH script, so a shift in data collection of a few milliseconds should be justified).'
- },
-
- 'net': {
- title: 'Network Interfaces',
- info: 'Per network interface statistics collected from <code>/proc/net/dev</code>.'
- },
-
- 'ipv4': {
- title: 'IPv4 Networking',
- info: undefined
- },
-
- 'ipv6': {
- title: 'IPv6 Networking',
- info: undefined
- },
-
- 'ipvs': {
- title: 'IP Virtual Server',
- info: undefined
- },
-
- 'netfilter': {
- title: 'Firewall (netfilter)',
- info: undefined
- },
-
- 'cpu': {
- title: 'CPUs',
- info: undefined
- },
-
- 'mem': {
- title: 'Memory',
- info: undefined
- },
-
- 'disk': {
- title: 'Disks',
- info: undefined
- },
-
- 'sensors': {
- title: 'Sensors',
- info: undefined
- },
-
- 'nfsd': {
- title: 'File Server (nfsd)',
- info: undefined
- },
-
- 'apps': {
- title: 'Applications',
- info: 'Per application statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics for applications of interest, defined in <code>/etc/netdata/apps_groups.conf</code> (the default is <a href="https://github.com/firehol/netdata/blob/master/conf.d/apps_groups.conf" target="_blank">here</a>). The plugin internally builds a process tree (much like <code>ps fax</code> does), and groups processes together (evaluating both child and parent processes) so that the result is always a chart with a predefined set of dimensions (of course, only application groups found running are reported).<br/><b>IMPORTANT</b>: The values shown here are not 100% accurate. They only include values for the processes running. If an application is spawning children continuously, which are terminated in just a few milliseconds (like shell scripts do), the values reported will be inaccurate. Linux does report the values for the exited children of a process. However, these values are reported to the parent process <b>only when the child exits</b>. If these values, of the exited child processes, were also aggregated in the charts below, the charts would have been full of spikes, presenting unrealistic utilization for each process group. So, we decided to ignore these values and present only the utilization of <b>the currently running processes</b>.',
- height: 1.5
- },
-
- 'users': {
- title: 'Users',
- info: 'Per user statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics per user.<br/><b>IMPORTANT</b>: The values shown here are not 100% accurate. They only include values for the processes running. If an application is spawning children continuously, which are terminated in just a few milliseconds (like shell scripts do), the values reported will be inaccurate. Linux does report the values for the exited children of a process. However, these values are reported to the parent process <b>only when the child exits</b>. If these values, of the exited child processes, were also aggregated in the charts below, the charts would have been full of spikes, presenting unrealistic utilization for each process group. So, we decided to ignore these values and present only the utilization of <b>the currently running processes</b>.',
- height: 1.5
- },
-
- 'groups': {
- title: 'User Groups',
- info: 'Per user group statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics per user group.<br/><b>IMPORTANT</b>: The values shown here are not 100% accurate. They only include values for the processes running. If an application is spawning children continuously, which are terminated in just a few milliseconds (like shell scripts do), the values reported will be inaccurate. Linux does report the values for the exited children of a process. However, these values are reported to the parent process <b>only when the child exits</b>. If these values, of the exited child processes, were also aggregated in the charts below, the charts would have been full of spikes, presenting unrealistic utilization for each process group. So, we decided to ignore these values and present only the utilization of <b>the currently running processes</b>.',
- height: 1.5
- },
-
- 'netdata': {
- title: 'Netdata Monitoring',
- info: undefined
- },
-
- 'example': {
- title: 'Example Charts',
- info: undefined
- },
-
- 'cgroup': {
- title: 'Container',
- info: undefined
- },
-
- 'mysql': {
- title: 'MySQL',
- info: undefined
- },
-
- 'named': {
- title: 'named',
- info: undefined
- },
+ 'system': {
+ title: 'System Overview',
+ info: 'Overview of the key system metrics.'
+ },
+
+ 'ap': {
+ title: 'Access Points',
+ info: undefined
+ },
+
+ 'tc': {
+ title: 'Quality of Service',
+ info: 'Netdata collects and visualizes tc class utilization using its <a href="https://github.com/firehol/netdata/blob/master/plugins.d/tc-qos-helper.sh" target="_blank">tc-helper plugin</a>. If you also use <a href="http://firehol.org/#fireqos" target="_blank">FireQOS</a> for setting up QoS, netdata automatically collects interface and class names. If your QoS configuration includes overheads calculation, the values shown here will include these overheads (the total bandwidth for the same interface as reported in the Network Interfaces section, will be lower than the total bandwidth reported here). Also, data collection may have a slight time difference compared to the interface (QoS data collection is implemented with a BASH script, so a shift in data collection of a few milliseconds should be justified).'
+ },
+
+ 'net': {
+ title: 'Network Interfaces',
+ info: 'Per network interface statistics collected from <code>/proc/net/dev</code>.'
+ },
+
+ 'ipv4': {
+ title: 'IPv4 Networking',
+ info: undefined
+ },
+
+ 'ipv6': {
+ title: 'IPv6 Networking',
+ info: undefined
+ },
+
+ 'ipvs': {
+ title: 'IP Virtual Server',
+ info: undefined
+ },
+
+ 'netfilter': {
+ title: 'Firewall (netfilter)',
+ info: undefined
+ },
+
+ 'cpu': {
+ title: 'CPUs',
+ info: undefined
+ },
+
+ 'mem': {
+ title: 'Memory',
+ info: undefined
+ },
+
+ 'disk': {
+ title: 'Disks',
+ info: 'Charts with performance information for all the system disks. Special care has been given to present disk performance metrics in a way compatible with <code>iostat -x</code>. netdata by default prevents rendering performance charts for individual partitions and unmounted virtual disks. Disabled charts can still be enabled by altering the relative settings in the netdata configuration file.'
+ },
+
+ 'sensors': {
+ title: 'Sensors',
+ info: undefined
+ },
+
+ 'nfsd': {
+ title: 'File Server (nfsd)',
+ info: undefined
+ },
+
+ 'apps': {
+ title: 'Applications',
+ info: 'Per application statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics for applications of interest, defined in <code>/etc/netdata/apps_groups.conf</code> (the default is <a href="https://github.com/firehol/netdata/blob/master/conf.d/apps_groups.conf" target="_blank">here</a>). The plugin internally builds a process tree (much like <code>ps fax</code> does), and groups processes together (evaluating both child and parent processes) so that the result is always a chart with a predefined set of dimensions (of course, only application groups found running are reported). The reported values are compatible with <code>top</code>, although the netdata plugin counts also the resources of exited children (unlike <code>top</code> which shows only the resources of the currently running processes). So for processes like shell scripts, the reported values include the resources used by the commands these scripts run within each timeframe.',
+ height: 1.5
+ },
+
+ 'users': {
+ title: 'Users',
+ info: 'Per user statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics per user. The reported values are compatible with <code>top</code>, although the netdata plugin counts also the resources of exited children (unlike <code>top</code> which shows only the resources of the currently running processes). So for processes like shell scripts, the reported values include the resources used by the commands these scripts run within each timeframe.',
+ height: 1.5
+ },
+
+ 'groups': {
+ title: 'User Groups',
+ info: 'Per user group statistics are collected using netdata\'s <code>apps.plugin</code>. This plugin walks through the entire <code>/proc</code> filesystem and aggregates statistics per user group. The reported values are compatible with <code>top</code>, although the netdata plugin counts also the resources of exited children (unlike <code>top</code> which shows only the resources of the currently running processes). So for processes like shell scripts, the reported values include the resources used by the commands these scripts run within each timeframe.',
+ height: 1.5
+ },
+
+ 'netdata': {
+ title: 'Netdata Monitoring',
+ info: undefined
+ },
+
+ 'example': {
+ title: 'Example Charts',
+ info: undefined
+ },
+
+ 'cgroup': {
+ title: 'Container',
+ info: undefined
+ },
+
+ 'cgqemu': {
+ title: 'VM',
+ info: undefined
+ },
+
+ 'memcached': {
+ title: 'memcached',
+ info: undefined
+ },
+
+ 'mysql': {
+ title: 'MySQL',
+ info: undefined
+ },
+
+ 'redis': {
+ title: 'Redis',
+ info: undefined
+ },
+
+ 'ipfs': {
+ title: 'IPFS',
+ info: undefined
+ },
+
+ 'phpfpm': {
+ title: 'PHP-FPM',
+ info: undefined,
+ },
+
+ 'nginx': {
+ title: 'nginx',
+ info: undefined,
+ },
+
+ 'apache': {
+ title: 'Apache',
+ info: undefined,
+ },
+
+ 'named': {
+ title: 'named',
+ info: undefined
+ }
};
var submenuData = {
- 'mem.ksm': {
- title: 'Memory Deduper',
- info: 'Kernel Same-page Merging (KSM) performance monitoring, read from several files in <code>/sys/kernel/mm/ksm/</code>. KSM is a memory-saving de-duplication feature in the Linux kernel (since version 2.6.32). The KSM daemon ksmd periodically scans those areas of user memory which have been registered with it, looking for pages of identical content which can be replaced by a single write-protected page (which is automatically copied if a process later wants to update its content). KSM was originally developed for use with KVM (where it was known as Kernel Shared Memory), to fit more virtual machines into physical memory, by sharing the data common between them. But it can be useful to any application which generates many instances of the same data.'
- },
-
- 'netfilter.conntrack': {
- title: 'Connection Tracker',
- info: 'Netfilter Connection Tracker performance monitoring, read from <code>/proc/net/stat/nf_conntrack</code>. The connection tracker keeps track of all connections of the machine, inbound and outbound. It works by keeping a database with all open connections, tracking network and address translation and connection expectations.'
- },
-
- 'netfilter.nfacct': {
- title: 'Bandwidth Accounting',
- info: 'The following information is read using the <code>nfacct.plugin</code>.'
- },
-
- 'netfilter.synproxy': {
- title: 'DDoS Protection',
- info: 'DDoS Protection performance monitoring read from <code>/proc/net/stat/synproxy</code>. <a href="https://github.com/firehol/firehol/wiki/Working-with-SYNPROXY" target="_blank">SYNPROXY</a> is a TCP SYN packets proxy. It is used to protect any TCP server (like a web server) from SYN floods and similar DDoS attacks. It is a netfilter module, in the Linux kernel (since version 3.12). It is optimized to handle millions of packets per second utilizing all CPUs available without any concurrency locking between the connections. It can be used for any kind of TCP traffic (even encrypted), since it does not interfere with the content itself.'
- }
+ 'mem.ksm': {
+ title: 'Memory Deduper',
+ info: 'Kernel Same-page Merging (KSM) performance monitoring, read from several files in <code>/sys/kernel/mm/ksm/</code>. KSM is a memory-saving de-duplication feature in the Linux kernel (since version 2.6.32). The KSM daemon ksmd periodically scans those areas of user memory which have been registered with it, looking for pages of identical content which can be replaced by a single write-protected page (which is automatically copied if a process later wants to update its content). KSM was originally developed for use with KVM (where it was known as Kernel Shared Memory), to fit more virtual machines into physical memory, by sharing the data common between them. But it can be useful to any application which generates many instances of the same data.'
+ },
+
+ 'netfilter.conntrack': {
+ title: 'Connection Tracker',
+ info: 'Netfilter Connection Tracker performance monitoring, read from <code>/proc/net/stat/nf_conntrack</code>. The connection tracker keeps track of all connections of the machine, inbound and outbound. It works by keeping a database with all open connections, tracking network and address translation and connection expectations.'
+ },
+
+ 'netfilter.nfacct': {
+ title: 'Bandwidth Accounting',
+ info: 'The following information is read using the <code>nfacct.plugin</code>.'
+ },
+
+ 'netfilter.synproxy': {
+ title: 'DDoS Protection',
+ info: 'DDoS Protection performance monitoring read from <code>/proc/net/stat/synproxy</code>. <a href="https://github.com/firehol/firehol/wiki/Working-with-SYNPROXY" target="_blank">SYNPROXY</a> is a TCP SYN packets proxy. It is used to protect any TCP server (like a web server) from SYN floods and similar DDoS attacks. It is a netfilter module, in the Linux kernel (since version 3.12). It is optimized to handle millions of packets per second utilizing all CPUs available without any concurrency locking between the connections. It can be used for any kind of TCP traffic (even encrypted), since it does not interfere with the content itself.'
+ }
};
+//
+// chartData works on the context of a chart
+// Its purpose is to set:
+//
+// info: the text above the charts
+// heads: the representation of the chart at the top the subsection (second level menu)
+// mainheads: the representation of the chart at the top of the section (first level menu)
+// colors: the dimension colors of the chart (the default colors are appended)
+// height: the ratio of the chart height relative to the default
+//
var chartData = {
- 'system.cpu': {
- info: 'Total CPU utilization (all cores). 100% here means there is no CPU idle time at all. You can get per core usage at the <a href="#cpu">CPUs</a> section and per application usage at the <a href="#apps">Applications Monitoring</a> section.<br/>Keep an eye on <b>iowait</b> ' + sparkline('system.cpu', 'iowait', '%') + '. If it is constantly high, your disks are a bottleneck and they slow your system down.<br/>Another important metric worth monitoring, is <b>softirq</b> ' + sparkline('system.cpu', 'softirq', '%') + '. A constantly high percentage of softirq may indicate network drivers issues.'
- },
-
- 'system.load': {
- info: 'Current system load read from <code>/proc/loadavg</code>.',
- height: 0.7
- },
-
- 'system.io': {
- info: 'Total Disk I/O, for all disks, read from <code>/proc/vmstat</code>. You can get detailed information about each disk at the <a href="#disk">Disks</a> section and per application Disk usage at the <a href="#apps">Applications Monitoring</a> section.'
- },
-
- 'system.swapio': {
- info: 'Total Swap I/O, read from <code>/proc/vmstat</code>. (netdata measures both <code>in</code> and <code>out</code>. If either of them is not shown in the chart, it is because it is zero - you can change the page settings to always render all the available dimensions on all charts).'
- },
-
- 'system.pgfaults': {
- info: 'Total page faults, read from <code>/proc/vmstat</code>. <b>Major page faults</b> indicates that the system is using its swap. You can find which applications use the swap at the <a href="#apps">Applications Monitoring</a> section.'
- },
-
- 'system.entropy': {
- colors: '#CC22AA',
- info: '<a href="https://en.wikipedia.org/wiki/Entropy_(computing)" target="_blank">Entropy</a>, read from <code>/proc/sys/kernel/random/entropy_avail</code>, is like a pool of random numbers that are mainly used in cryptography. It is advised that the pool remains always <a href="https://blog.cloudflare.com/ensuring-randomness-with-linuxs-random-number-generator/" target="_blank">above 200</a>. If the pool of entropy gets empty, you risk your security to be predictable and you should install a user-space random numbers generating daemon, like <a href="http://www.issihosts.com/haveged/" target="_blank">haveged</a>, to keep the pool in healthy levels.'
- },
-
- 'system.forks': {
- colors: '#5555DD',
- info: 'The number of new processes created per second, read from <code>/proc/stat</code>.'
- },
-
- 'system.intr': {
- colors: '#DD5555',
- info: 'Total number of CPU interrupts, read from <code>/proc/stat</code>. Check <code>system.interrupts</code> that gives more detail about each interrupt and also the <a href="#cpu">CPUs</a> section where interrupts are analyzed per CPU core.'
- },
-
- 'system.interrupts': {
- info: 'CPU interrupts in detail, read from <code>/proc/interrupts</code>. At the <a href="#cpu">CPUs</a> section, interrupts are analyzed per CPU core.'
- },
-
- 'system.softirqs': {
- info: 'CPU softirqs in detail, read from <code>/proc/softirqs</code>. At the <a href="#cpu">CPUs</a> section, softirqs are analyzed per CPU core.'
- },
-
- 'system.processes': {
- info: 'System processes, read from <code>/proc/stat</code>. <b>Blocked</b> are processes that are willing to execute but they cannot, e.g. because they wait for disk activity.'
- },
-
- 'system.active_processes': {
- info: 'All system active processes, read from <code>/proc/loadavg</code>.'
- },
-
- 'system.ctxt': {
- info: '<a href="https://en.wikipedia.org/wiki/Context_switch" target="_blank">Context Switches</a>, read from <code>/proc/stat</code>, is the switching of the CPU from one process, task or thread to another. If there are many processes or threads willing to execute and very few CPU cores available to handle them, the system is making more context switching to balance the CPU resources among them. The whole process is computationally intensive. The more the context switches, the slower the system gets.'
- },
-
- 'system.idlejitter': {
- colors: '#5555AA',
- info: 'Idle jitter is calculated by netdata. A thread is spawned that requests to sleep for a few microseconds. When the system wakes it up, it measures how many microseconds have passed. The difference between the requested and the actual duration of the sleep, is the <b>idle jitter</b>. This number is useful in real-time environments, where CPU jitter can affect the quality of the service (like VoIP media gateways).'
- },
-
- 'system.ipv4': {
- info: 'Total IPv4 Traffic, read from <code>/proc/net/netstat</code>.'
- },
-
- 'system.ipv6': {
- info: 'Total IPv6 Traffic, read from <code>/proc/net/snmp6</code>.'
- },
-
- 'system.ram': {
- info: 'System memory, read from <code>/proc/meminfo</code>.'
- },
-
- 'system.swap': {
- info: 'System swap memory, read from <code>/proc/meminfo</code>.'
- },
-
- 'mem.ksm_savings': {
- heads: [
- gaugeChart('Saved', '12%', 'savings', '#0099CC')
- ]
- },
-
- 'mem.ksm_ratios': {
- heads: [
- function(id) {
- return '<div data-netdata="' + id + '"'
- + ' data-gauge-max-value="100"'
- + ' data-chart-library="gauge"'
- + ' data-title="Savings"'
- + ' data-units="percentage %"'
- + ' data-gauge-adjust="width"'
- + ' data-width="12%"'
- + ' data-before="0"'
- + ' data-after="-CHART_DURATION"'
- + ' data-points="CHART_DURATION"'
- + ' role="application"></div>';
- }
- ]
- },
-
- 'mem.committed': {
- colors: NETDATA.colors[3]
- },
-
- 'apps.cpu': {
- height: 2.0
- },
-
- 'apps.preads': {
- height: 2.0
- },
-
- 'apps.pwrites': {
- height: 2.0
- },
-
- 'users.cpu': {
- height: 2.0
- },
-
- 'users.preads': {
- height: 2.0
- },
-
- 'users.pwrites': {
- height: 2.0
- },
-
- 'groups.cpu': {
- height: 2.0
- },
-
- 'groups.preads': {
- height: 2.0
- },
-
- 'groups.pwrites': {
- height: 2.0
- },
-
- 'tc.qos': {
- heads: [
- function(id) {
- if(id.match(/.*-ifb$/))
- return gaugeChart('Inbound', '12%', '', '#5555AA');
- else
- return gaugeChart('Outbound', '12%', '', '#AA9900');
- }
- ]
- },
-
- 'net.net': {
- heads: [
- gaugeChart('Received', '12%', 'received'),
- gaugeChart('Sent', '12%', 'sent')
- ]
- },
-
- 'disk.util': {
- colors: '#FF5588',
- heads: [
- gaugeChart('Utilization', '12%', '', '#FF5588')
- ]
- },
-
- 'disk.backlog': {
- colors: '#0099CC'
- },
-
- 'disk.io': {
- heads: [
- gaugeChart('Read', '12%', 'reads'),
- gaugeChart('Write', '12%', 'writes')
- ]
- },
-
- 'netfilter.sockets': {
- colors: '#88AA00',
- heads: [
- gaugeChart('Active Connections', '12%', '', '#88AA00')
- ]
- },
-
- 'netfilter.new': {
- heads: [
- gaugeChart('New Connections', '12%', 'new', '#5555AA')
- ]
- },
-
- 'disk.iotime': {
- height: 0.5
- },
- 'disk.mops': {
- height: 0.5
- },
- 'disk.svctm': {
- height: 0.5
- },
- 'disk.avgsz': {
- height: 0.5
- },
- 'disk.await': {
- height: 0.5
- },
-
- 'apache.connections': {
- colors: NETDATA.colors[4],
- mainheads: [
- gaugeChart('Connections', '12%', '', NETDATA.colors[4])
- ]
- },
-
- 'apache.requests': {
- colors: NETDATA.colors[0],
- mainheads: [
- gaugeChart('Connections', '12%', '', NETDATA.colors[0])
- ]
- },
-
- 'apache.net': {
- colors: NETDATA.colors[3],
- mainheads: [
- gaugeChart('Bandwidth', '12%', '', NETDATA.colors[3])
- ]
- },
-
- 'apache.workers': {
- mainheads: [
- function(id) {
- return '<div data-netdata="' + id + '"'
- + ' data-dimensions="busy"'
- + ' data-append-options="percentage"'
- + ' data-gauge-max-value="100"'
- + ' data-chart-library="gauge"'
- + ' data-title="Workers Utilization"'
- + ' data-units="percentage %"'
- + ' data-gauge-adjust="width"'
- + ' data-width="12%"'
- + ' data-before="0"'
- + ' data-after="-CHART_DURATION"'
- + ' data-points="CHART_DURATION"'
- + ' role="application"></div>';
- }
- ]
- },
-
- 'apache.bytesperreq': {
- colors: NETDATA.colors[3],
- height: 0.5
- },
-
- 'apache.reqpersec': {
- colors: NETDATA.colors[4],
- height: 0.5
- },
-
- 'apache.bytespersec': {
- colors: NETDATA.colors[6],
- height: 0.5
- },
-
- 'nginx.connections': {
- colors: NETDATA.colors[4],
- mainheads: [
- gaugeChart('Connections', '12%', '', NETDATA.colors[4])
- ]
- },
-
- 'nginx.requests': {
- colors: NETDATA.colors[0],
- mainheads: [
- gaugeChart('Requests', '12%', '', NETDATA.colors[0])
- ]
- }
+ 'system.cpu': {
+ info: 'Total CPU utilization (all cores). 100% here means there is no CPU idle time at all. You can get per core usage at the <a href="#cpu">CPUs</a> section and per application usage at the <a href="#apps">Applications Monitoring</a> section.<br/>Keep an eye on <b>iowait</b> ' + sparkline('system.cpu', 'iowait', '%') + '. If it is constantly high, your disks are a bottleneck and they slow your system down.<br/>Another important metric worth monitoring, is <b>softirq</b> ' + sparkline('system.cpu', 'softirq', '%') + '. A constantly high percentage of softirq may indicate network drivers issues.'
+ },
+
+ 'system.load': {
+ info: 'Current system load, i.e. the number of processes using CPU or waiting for system resources (usually CPU and disk). The 3 metrics refer to 1, 5 and 15 minute averages. Linux calculates this once every 5 seconds. Netdata reads them from <code>/proc/loadavg</code>. For more information check <a href="https://en.wikipedia.org/wiki/Load_(computing)" target="_blank">this wikipedia article</a>',
+ height: 0.7
+ },
+
+ 'system.io': {
+ info: 'Total Disk I/O, for all disks, read from <code>/proc/vmstat</code>. You can get detailed information about each disk at the <a href="#disk">Disks</a> section and per application Disk usage at the <a href="#apps">Applications Monitoring</a> section.'
+ },
+
+ 'system.swapio': {
+ info: 'Total Swap I/O, read from <code>/proc/vmstat</code>. (netdata measures both <code>in</code> and <code>out</code>. If either of them is not shown in the chart, it is because it is zero - you can change the page settings to always render all the available dimensions on all charts).'
+ },
+
+ 'system.pgfaults': {
+ info: 'Total page faults, read from <code>/proc/vmstat</code>. <b>Major page faults</b> indicates that the system is using its swap. You can find which applications use the swap at the <a href="#apps">Applications Monitoring</a> section.'
+ },
+
+ 'system.entropy': {
+ colors: '#CC22AA',
+ info: '<a href="https://en.wikipedia.org/wiki/Entropy_(computing)" target="_blank">Entropy</a>, read from <code>/proc/sys/kernel/random/entropy_avail</code>, is like a pool of random numbers that are mainly used in cryptography. It is advised that the pool remains always <a href="https://blog.cloudflare.com/ensuring-randomness-with-linuxs-random-number-generator/" target="_blank">above 200</a>. If the pool of entropy gets empty, you risk your security to be predictable and you should install a user-space random numbers generating daemon, like <a href="http://www.issihosts.com/haveged/" target="_blank">haveged</a>, to keep the pool in healthy levels.'
+ },
+
+ 'system.forks': {
+ colors: '#5555DD',
+ info: 'The number of new processes created per second, read from <code>/proc/stat</code>.'
+ },
+
+ 'system.intr': {
+ colors: '#DD5555',
+ info: 'Total number of CPU interrupts, read from <code>/proc/stat</code>. Check <code>system.interrupts</code> that gives more detail about each interrupt and also the <a href="#cpu">CPUs</a> section where interrupts are analyzed per CPU core.'
+ },
+
+ 'system.interrupts': {
+ info: 'CPU interrupts in detail, read from <code>/proc/interrupts</code>. At the <a href="#cpu">CPUs</a> section, interrupts are analyzed per CPU core.'
+ },
+
+ 'system.softirqs': {
+ info: 'CPU softirqs in detail, read from <code>/proc/softirqs</code>. At the <a href="#cpu">CPUs</a> section, softirqs are analyzed per CPU core.'
+ },
+
+ 'system.processes': {
+ info: 'System processes, read from <code>/proc/stat</code>. <b>Blocked</b> are processes that are willing to execute but they cannot, e.g. because they wait for disk activity.'
+ },
+
+ 'system.active_processes': {
+ info: 'All system active processes, read from <code>/proc/loadavg</code>.'
+ },
+
+ 'system.ctxt': {
+ info: '<a href="https://en.wikipedia.org/wiki/Context_switch" target="_blank">Context Switches</a>, read from <code>/proc/stat</code>, is the switching of the CPU from one process, task or thread to another. If there are many processes or threads willing to execute and very few CPU cores available to handle them, the system is making more context switching to balance the CPU resources among them. The whole process is computationally intensive. The more the context switches, the slower the system gets.'
+ },
+
+ 'system.idlejitter': {
+ colors: '#5555AA',
+ info: 'Idle jitter is calculated by netdata. A thread is spawned that requests to sleep for a few microseconds. When the system wakes it up, it measures how many microseconds have passed. The difference between the requested and the actual duration of the sleep, is the <b>idle jitter</b>. This number is useful in real-time environments, where CPU jitter can affect the quality of the service (like VoIP media gateways).'
+ },
+
+ 'system.ipv4': {
+ info: 'Total IPv4 Traffic, read from <code>/proc/net/netstat</code>.'
+ },
+
+ 'system.ipv6': {
+ info: 'Total IPv6 Traffic, read from <code>/proc/net/snmp6</code>.'
+ },
+
+ 'system.ram': {
+ info: 'System memory, read from <code>/proc/meminfo</code>.'
+ },
+
+ 'system.swap': {
+ info: 'System swap memory, read from <code>/proc/meminfo</code>.'
+ },
+
+ // ------------------------------------------------------------------------
+ // MEMORY
+
+ 'mem.ksm_savings': {
+ heads: [
+ gaugeChart('Saved', '12%', 'savings', '#0099CC')
+ ]
+ },
+
+ 'mem.ksm_ratios': {
+ heads: [
+ function(id) {
+ return '<div data-netdata="' + id + '"'
+ + ' data-gauge-max-value="100"'
+ + ' data-chart-library="gauge"'
+ + ' data-title="Savings"'
+ + ' data-units="percentage %"'
+ + ' data-gauge-adjust="width"'
+ + ' data-width="12%"'
+ + ' data-before="0"'
+ + ' data-after="-CHART_DURATION"'
+ + ' data-points="CHART_DURATION"'
+ + ' role="application"></div>';
+ }
+ ]
+ },
+
+ 'mem.committed': {
+ colors: NETDATA.colors[3]
+ },
+
+ // ------------------------------------------------------------------------
+ // APPS
+
+ 'apps.cpu': {
+ height: 2.0
+ },
+
+ 'apps.preads': {
+ height: 2.0
+ },
+
+ 'apps.pwrites': {
+ height: 2.0
+ },
+
+ // ------------------------------------------------------------------------
+ // USERS
+
+ 'users.cpu': {
+ height: 2.0
+ },
+
+ 'users.preads': {
+ height: 2.0
+ },
+
+ 'users.pwrites': {
+ height: 2.0
+ },
+
+ // ------------------------------------------------------------------------
+ // GROUPS
+
+ 'groups.cpu': {
+ height: 2.0
+ },
+
+ 'groups.preads': {
+ height: 2.0
+ },
+
+ 'groups.pwrites': {
+ height: 2.0
+ },
+
+ // ------------------------------------------------------------------------
+ // NETWORK QoS
+
+ 'tc.qos': {
+ heads: [
+ function(id) {
+ if(id.match(/.*-ifb$/))
+ return gaugeChart('Inbound', '12%', '', '#5555AA');
+ else
+ return gaugeChart('Outbound', '12%', '', '#AA9900');
+ }
+ ]
+ },
+
+ // ------------------------------------------------------------------------
+ // NETWORK INTERFACES
+
+ 'net.net': {
+ heads: [
+ gaugeChart('Received', '12%', 'received'),
+ gaugeChart('Sent', '12%', 'sent')
+ ]
+ },
+
+ // ------------------------------------------------------------------------
+ // NETFILTER
+
+ 'netfilter.sockets': {
+ colors: '#88AA00',
+ heads: [
+ gaugeChart('Active Connections', '12%', '', '#88AA00')
+ ]
+ },
+
+ 'netfilter.new': {
+ heads: [
+ gaugeChart('New Connections', '12%', 'new', '#5555AA')
+ ]
+ },
+
+ // ------------------------------------------------------------------------
+ // DISKS
+
+ 'disk.util': {
+ colors: '#FF5588',
+ heads: [
+ gaugeChart('Utilization', '12%', '', '#FF5588')
+ ],
+ info: 'Disk Utilization measures the amount of time the disk was busy with something. This is not related to its performance. 100% means that the Linux kernel always had an outstanding operation on the disk. Keep in mind that depending on the underlying technology of the disk, 100% here may or may not be an indication of congestion.'
+ },
+
+ 'disk.backlog': {
+ colors: '#0099CC',
+ info: 'Backlog is an indication of the duration of pending disk operations. On every I/O event the Linux kernel is multiplying the time spent doing I/O since the last update of this field with the number of pending operations. While not accurate, this metric can provide an indication of the expected completion time of the operations in progress.'
+ },
+
+ 'disk.io': {
+ heads: [
+ gaugeChart('Read', '12%', 'reads'),
+ gaugeChart('Write', '12%', 'writes')
+ ],
+ info: 'Amount of data transferred to and from disk.'
+ },
+
+ 'disk.ops': {
+ info: 'Completed disk I/O operations. Keep in mind the number of operations requested might be higher, since the Linux kernel is able to merge adjacent to each other (see merged operations chart).'
+ },
+
+ 'disk.qops': {
+ info: 'I/O operations currently in progress. This metric is a snapshot - it is not an average over the last interval.'
+ },
+
+ 'disk.iotime': {
+ height: 0.5,
+ info: 'The sum of the duration of all completed I/O operations. This number can exceed the interval if the disk is able to execute I/O operations in parallel.'
+ },
+ 'disk.mops': {
+ height: 0.5,
+ info: 'The number of merged disk operations. The Linux kernel is able to merge adjacent I/O operations, for example two 4KB reads can become one 8KB read before given to disk.'
+ },
+ 'disk.svctm': {
+ height: 0.5,
+ info: 'The average service time for completed I/O operations. This metric is calculated using the total busy time of the disk and the number of completed operations. If the disk is able to execute multiple parallel operations the reporting average service time will be misleading.'
+ },
+ 'disk.avgsz': {
+ height: 0.5,
+ info: 'The average I/O operation size.'
+ },
+ 'disk.await': {
+ height: 0.5,
+ info: 'The average time for I/O requests issued to the device to be served. This includes the time spent by the requests in queue and the time spent servicing them.'
+ },
+
+ 'disk.space': {
+ info: 'Disk space utilization. reserved for root is automatically reserved by the system to prevent the root user from getting out of space.'
+ },
+ 'disk.inodes': {
+ info: 'inodes (or index nodes) are filesystem objects (e.g. files and directories). On many types of file system implementations, the maximum number of inodes is fixed at filesystem creation, limiting the maximum number of files the filesystem can hold. It is possible for a device to run out of inodes. When this happens, new files cannot be created on the device, even though there may be free space available.'
+ },
+
+ 'mysql.net': {
+ info: 'The amount of data sent to mysql clients (<strong>out</strong>) and received from mysql clients (<strong>in</strong>).'
+ },
+
+ // ------------------------------------------------------------------------
+ // MYSQL
+
+ 'mysql.queries': {
+ info: 'The number of statements executed by the server.<ul>' +
+ '<li><strong>queries</strong> counts the statements executed within stored SQL programs.</li>' +
+ '<li><strong>questions</strong> counts the statements sent to the mysql server by mysql clients.</li>' +
+ '<li><strong>slow queries</strong> counts the number of statements that took more than <a href="http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_long_query_time" target="_blank">long_query_time</a> seconds to be executed.' +
+ ' For more information about slow queries check the mysql <a href="http://dev.mysql.com/doc/refman/5.7/en/slow-query-log.html" target="_blank">slow query log</a>.</li>' +
+ '</ul>'
+ },
+
+ 'mysql.handlers': {
+ info: 'Usage of the internal handlers of mysql. This chart provides very good insights of what the mysql server is actually doing.' +
+ ' (if the chart is not showing all these dimensions it is because they are zero - set <strong>Which dimensions to show?</strong> to <strong>All</strong> from the dashboard settings, to render even the zero values)<ul>' +
+ '<li><strong>commit</strong>, the number of internal <a href="http://dev.mysql.com/doc/refman/5.7/en/commit.html" target="_blank">COMMIT</a> statements.</li>' +
+ '<li><strong>delete</strong>, the number of times that rows have been deleted from tables.</li>' +
+ '<li><strong>prepare</strong>, a counter for the prepare phase of two-phase commit operations.</li>' +
+ '<li><strong>read first</strong>, the number of times the first entry in an index was read. A high value suggests that the server is doing a lot of full index scans; e.g. <strong>SELECT col1 FROM foo</strong>, with col1 indexed.</li>' +
+ '<li><strong>read key</strong>, the number of requests to read a row based on a key. If this value is high, it is a good indication that your tables are properly indexed for your queries.</li>' +
+ '<li><strong>read next</strong>, the number of requests to read the next row in key order. This value is incremented if you are querying an index column with a range constraint or if you are doing an index scan.</li>' +
+ '<li><strong>read prev</strong>, the number of requests to read the previous row in key order. This read method is mainly used to optimize <strong>ORDER BY ... DESC</strong>.</li>' +
+ '<li><strong>read rnd</strong>, the number of requests to read a row based on a fixed position. A high value indicates you are doing a lot of queries that require sorting of the result. You probably have a lot of queries that require MySQL to scan entire tables or you have joins that do not use keys properly.</li>' +
+ '<li><strong>read rnd next</strong>, the number of requests to read the next row in the data file. This value is high if you are doing a lot of table scans. Generally this suggests that your tables are not properly indexed or that your queries are not written to take advantage of the indexes you have.</li>' +
+ '<li><strong>rollback</strong>, the number of requests for a storage engine to perform a rollback operation.</li>' +
+ '<li><strong>savepoint</strong>, the number of requests for a storage engine to place a savepoint.</li>' +
+ '<li><strong>savepoint rollback</strong>, the number of requests for a storage engine to roll back to a savepoint.</li>' +
+ '<li><strong>update</strong>, the number of requests to update a row in a table.</li>' +
+ '<li><strong>write</strong>, the number of requests to insert a row in a table.</li>' +
+ '</ul>'
+ },
+
+ 'mysql.table_locks': {
+ info: 'MySQL table locks counters: <ul>' +
+ '<li><strong>immediate</strong>, the number of times that a request for a table lock could be granted immediately.</li>' +
+ '<li><strong>waited</strong>, the number of times that a request for a table lock could not be granted immediately and a wait was needed. If this is high and you have performance problems, you should first optimize your queries, and then either split your table or tables or use replication.</li>' +
+ '</ul>'
+ },
+
+ // ------------------------------------------------------------------------
+ // APACHE
+
+ 'apache.connections': {
+ colors: NETDATA.colors[4],
+ mainheads: [
+ gaugeChart('Connections', '12%', '', NETDATA.colors[4])
+ ]
+ },
+
+ 'apache.requests': {
+ colors: NETDATA.colors[0],
+ mainheads: [
+ gaugeChart('Requests', '12%', '', NETDATA.colors[0])
+ ]
+ },
+
+ 'apache.net': {
+ colors: NETDATA.colors[3],
+ mainheads: [
+ gaugeChart('Bandwidth', '12%', '', NETDATA.colors[3])
+ ]
+ },
+
+ 'apache.workers': {
+ mainheads: [
+ function(id) {
+ return '<div data-netdata="' + id + '"'
+ + ' data-dimensions="busy"'
+ + ' data-append-options="percentage"'
+ + ' data-gauge-max-value="100"'
+ + ' data-chart-library="gauge"'
+ + ' data-title="Workers Utilization"'
+ + ' data-units="percentage %"'
+ + ' data-gauge-adjust="width"'
+ + ' data-width="12%"'
+ + ' data-before="0"'
+ + ' data-after="-CHART_DURATION"'
+ + ' data-points="CHART_DURATION"'
+ + ' role="application"></div>';
+ }
+ ]
+ },
+
+ 'apache.bytesperreq': {
+ colors: NETDATA.colors[3],
+ height: 0.5
+ },
+
+ 'apache.reqpersec': {
+ colors: NETDATA.colors[4],
+ height: 0.5
+ },
+
+ 'apache.bytespersec': {
+ colors: NETDATA.colors[6],
+ height: 0.5
+ },
+
+
+ // ------------------------------------------------------------------------
+ // NGINX
+
+ 'nginx.connections': {
+ colors: NETDATA.colors[4],
+ mainheads: [
+ gaugeChart('Connections', '12%', '', NETDATA.colors[4])
+ ]
+ },
+
+ 'nginx.requests': {
+ colors: NETDATA.colors[0],
+ mainheads: [
+ gaugeChart('Requests', '12%', '', NETDATA.colors[0])
+ ]
+ },
+
+ // ------------------------------------------------------------------------
+ // NETDATA
+
+ 'netdata.response_time': {
+ info: 'The netdata API response time measures the time netdata needed to serve requests. This time includes everything, from the reception of the first byte of a request, to the dispatch of the last byte of its reply, therefore it includes all network latencies involved (i.e. a client over a slow network will influence these metrics).'
+ }
};
function anyAttribute(obj, attr, key, def) {
- if(typeof obj[key] !== 'undefined') {
- if(typeof obj[key][attr] !== 'undefined')
- return obj[key][attr];
- }
- return def;
+ if(typeof obj[key] !== 'undefined') {
+ if(typeof obj[key][attr] !== 'undefined')
+ return obj[key][attr];
+ }
+ return def;
}
function menuTitle(chart) {
- if(typeof chart.menu_pattern !== 'undefined') {
- return anyAttribute(menuData, 'title', chart.menu_pattern, chart.menu_pattern).toString()
- + ': ' + chart.type.slice(-(chart.type.length - chart.menu_pattern.length - 1)).toString();
- }
+ if(typeof chart.menu_pattern !== 'undefined') {
+ return anyAttribute(menuData, 'title', chart.menu_pattern, chart.menu_pattern).toString()
+ + ': ' + chart.type.slice(-(chart.type.length - chart.menu_pattern.length - 1)).toString();
+ }
- return anyAttribute(menuData, 'title', chart.menu, chart.menu);
+ return anyAttribute(menuData, 'title', chart.menu, chart.menu);
}
function menuInfo(menu) {
- return anyAttribute(menuData, 'info', menu, null);
+ return anyAttribute(menuData, 'info', menu, null);
}
function menuHeight(menu, relative) {
- return anyAttribute(menuData, 'height', menu, 1.0) * relative;
+ return anyAttribute(menuData, 'height', menu, 1.0) * relative;
}
function submenuTitle(menu, submenu) {
- var key = menu + '.' + submenu;
- return anyAttribute(submenuData, 'title', key, submenu);
+ var key = menu + '.' + submenu;
+ return anyAttribute(submenuData, 'title', key, submenu);
}
function submenuInfo(menu, submenu) {
- var key = menu + '.' + submenu;
- return anyAttribute(submenuData, 'info', key, null);
+ var key = menu + '.' + submenu;
+ return anyAttribute(submenuData, 'info', key, null);
}
function submenuHeight(menu, submenu, relative) {
- var key = menu + '.' + submenu;
- return anyAttribute(submenuData, 'height', key, 1.0) * relative;
+ var key = menu + '.' + submenu;
+ return anyAttribute(submenuData, 'height', key, 1.0) * relative;
}
function chartInfo(id) {
- if(typeof chartData[id] !== 'undefined' && typeof chartData[id].info !== 'undefined')
- return '<div class="chart-message netdata-chart-alignment" role="document">' + chartData[id].info + '</div>';
- else
- return '';
+ if(typeof chartData[id] !== 'undefined' && typeof chartData[id].info !== 'undefined')
+ return '<div class="chart-message netdata-chart-alignment" role="document">' + chartData[id].info + '</div>';
+ else
+ return '';
}
function chartHeight(id, def) {
- if(typeof chartData[id] !== 'undefined' && typeof chartData[id].height !== 'undefined')
- return def * chartData[id].height;
- else
- return def;
+ if(typeof chartData[id] !== 'undefined' && typeof chartData[id].height !== 'undefined')
+ return def * chartData[id].height;
+ else
+ return def;
}
@@ -1610,657 +2051,915 @@ function chartHeight(id, def) {
// enrich the data structure returned by netdata
// to reflect our menu system and content
function enrichChartData(chart) {
- var tmp = chart.type.split('_')[0];
-
- switch(tmp) {
- case 'ap':
- case 'net':
- case 'disk':
- chart.menu = tmp;
- break;
-
- case 'mysql':
- case 'named':
- case 'cgroup':
- chart.menu = chart.type;
- chart.menu_pattern = tmp;
- break;
-
- case 'tc':
- chart.menu = tmp;
-
- // find a name for this device from fireqos info
- // we strip '_(in|out)' or '(in|out)_'
- if(typeof options.submenu_names[chart.family] === 'undefined' || options.submenu_names[chart.family] === chart.family) {
- var n = chart.name.split('.')[1];
- if(n.endsWith('_in'))
- options.submenu_names[chart.family] = n.slice(0, n.lastIndexOf('_in'));
- else if(n.endsWith('_out'))
- options.submenu_names[chart.family] = n.slice(0, n.lastIndexOf('_out'));
- else if(n.startsWith('in_'))
- options.submenu_names[chart.family] = n.slice(3, n.length);
- else if(n.startsWith('out_'))
- options.submenu_names[chart.family] = n.slice(4, n.length);
- }
-
- // increase the priority of IFB devices
- // to have inbound appear before outbound
- if(chart.id.match(/.*-ifb$/))
- chart.priority--;
-
- break;
-
- default:
- chart.menu = chart.type;
- break;
- }
-
- chart.submenu = chart.family;
+ var tmp = chart.type.split('_')[0];
+
+ switch(tmp) {
+ case 'ap':
+ case 'net':
+ case 'disk':
+ chart.menu = tmp;
+ break;
+
+ case 'cgroup':
+ chart.menu = chart.type;
+ if(chart.id.match(/.*[\._\/-:]qemu[\._\/-:]*/) || chart.id.match(/.*[\._\/-:]kvm[\._\/-:]*/))
+ chart.menu_pattern = 'cgqemu';
+ else
+ chart.menu_pattern = 'cgroup';
+ break;
+
+ case 'apache':
+ case 'exim':
+ case 'memcached':
+ case 'mysql':
+ case 'named':
+ case 'nginx':
+ case 'phpfpm':
+ case 'postfix':
+ case 'redis':
+ case 'ipfs':
+ case 'squid':
+ case 'snmp':
+ case 'tomcat':
+ chart.menu = chart.type;
+ chart.menu_pattern = tmp;
+ break;
+
+ case 'tc':
+ chart.menu = tmp;
+
+ // find a name for this device from fireqos info
+ // we strip '_(in|out)' or '(in|out)_'
+ if(typeof options.submenu_names[chart.family] === 'undefined' || options.submenu_names[chart.family] === chart.family) {
+ var n = chart.name.split('.')[1];
+ if(n.endsWith('_in'))
+ options.submenu_names[chart.family] = n.slice(0, n.lastIndexOf('_in'));
+ else if(n.endsWith('_out'))
+ options.submenu_names[chart.family] = n.slice(0, n.lastIndexOf('_out'));
+ else if(n.startsWith('in_'))
+ options.submenu_names[chart.family] = n.slice(3, n.length);
+ else if(n.startsWith('out_'))
+ options.submenu_names[chart.family] = n.slice(4, n.length);
+ }
+
+ // increase the priority of IFB devices
+ // to have inbound appear before outbound
+ if(chart.id.match(/.*-ifb$/))
+ chart.priority--;
+
+ break;
+
+ default:
+ chart.menu = chart.type;
+ break;
+ }
+
+ chart.submenu = chart.family;
}
// ----------------------------------------------------------------------------
function name2id(s) {
- return s
- .replace(/ /g, '_')
- .replace(/\(/g, '_')
- .replace(/\)/g, '_')
- .replace(/\./g, '_')
- .replace(/\//g, '_');
+ return s
+ .replace(/ /g, '_')
+ .replace(/\(/g, '_')
+ .replace(/\)/g, '_')
+ .replace(/\./g, '_')
+ .replace(/\//g, '_');
}
function headMain(charts, duration) {
- var head = '';
-
- if(typeof charts['system.swap'] !== 'undefined')
- head += '<div style="margin-right: 10px;" data-netdata="system.swap"'
- + ' data-dimensions="free"'
- + ' data-append-options="percentage"'
- + ' data-chart-library="easypiechart"'
- + ' data-title="Free Swap"'
- + ' data-units="%"'
- + ' data-easypiechart-max-value="100"'
- + ' data-width="8%"'
- + ' data-before="0"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' data-colors="#DD4400"'
- + ' role="application"></div>';
-
- if(typeof charts['system.io'] !== 'undefined') {
- head += '<div style="margin-right: 10px;" data-netdata="system.io"'
- + ' data-dimensions="in"'
- + ' data-chart-library="easypiechart"'
- + ' data-title="Disk Read"'
- + ' data-units="KB / s"'
- + ' data-width="10%"'
- + ' data-before="0"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' role="application"></div>';
-
- head += '<div style="margin-right: 10px;" data-netdata="system.io"'
- + ' data-dimensions="out"'
- + ' data-chart-library="easypiechart"'
- + ' data-title="Disk Write"'
- + ' data-units="KB / s"'
- + ' data-width="10%"'
- + ' data-before="0"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' role="application"></div>';
- }
-
- if(typeof charts['system.cpu'] !== 'undefined')
- head += '<div data-netdata="system.cpu"'
- + ' data-chart-library="gauge"'
- + ' data-title="CPU"'
- + ' data-units="%"'
- + ' data-gauge-max-value="100"'
- + ' data-width="18%"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[12] + '"'
- + ' role="application"></div>';
-
- if(typeof charts['system.ipv4'] !== 'undefined') {
- head += '<div style="margin-right: 10px;" data-netdata="system.ipv4"'
- + ' data-dimensions="received"'
- + ' data-chart-library="easypiechart"'
- + ' data-title="IPv4 Inbound"'
- + ' data-units="kbps"'
- + ' data-width="10%"'
- + ' data-before="0"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' role="application"></div>';
-
- head += '<div style="margin-right: 10px;" data-netdata="system.ipv4"'
- + ' data-dimensions="sent"'
- + ' data-chart-library="easypiechart"'
- + ' data-title="IPv4 Outbound"'
- + ' data-units="kbps"'
- + ' data-width="10%"'
- + ' data-before="0"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' role="application"></div>';
- }
- else if(typeof charts['system.ipv6'] !== 'undefined') {
- head += '<div style="margin-right: 10px;" data-netdata="system.ipv6"'
- + ' data-dimensions="received"'
- + ' data-chart-library="easypiechart"'
- + ' data-title="IPv6 Inbound"'
- + ' data-units="kbps"'
- + ' data-width="10%"'
- + ' data-before="0"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' role="application"></div>';
-
- head += '<div style="margin-right: 10px;" data-netdata="system.ipv6"'
- + ' data-dimensions="sent"'
- + ' data-chart-library="easypiechart"'
- + ' data-title="IPv6 Outbound"'
- + ' data-units="kbps"'
- + ' data-width="10%"'
- + ' data-before="0"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' role="application"></div>';
- }
-
- if(typeof charts['system.ram'] !== 'undefined')
- head += '<div style="margin-right: 10px;" data-netdata="system.ram"'
- + ' data-dimensions="cached|free"'
- + ' data-append-options="percentage"'
- + ' data-chart-library="easypiechart"'
- + ' data-title="Available RAM"'
- + ' data-units="%"'
- + ' data-easypiechart-max-value="100"'
- + ' data-width="8%"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-points="' + duration.toString() + '"'
- + ' data-colors="' + NETDATA.colors[7] + '"'
- + ' role="application"></div>';
-
- return head;
+ var head = '';
+
+ if(typeof charts['system.swap'] !== 'undefined')
+ head += '<div style="margin-right: 10px;" data-netdata="system.swap"'
+ + ' data-dimensions="free"'
+ + ' data-append-options="percentage"'
+ + ' data-chart-library="easypiechart"'
+ + ' data-title="Free Swap"'
+ + ' data-units="%"'
+ + ' data-easypiechart-max-value="100"'
+ + ' data-width="8%"'
+ + ' data-before="0"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' data-colors="#DD4400"'
+ + ' role="application"></div>';
+
+ if(typeof charts['system.io'] !== 'undefined') {
+ head += '<div style="margin-right: 10px;" data-netdata="system.io"'
+ + ' data-dimensions="in"'
+ + ' data-chart-library="easypiechart"'
+ + ' data-title="Disk Read"'
+ + ' data-width="10%"'
+ + ' data-before="0"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' role="application"></div>';
+
+ head += '<div style="margin-right: 10px;" data-netdata="system.io"'
+ + ' data-dimensions="out"'
+ + ' data-chart-library="easypiechart"'
+ + ' data-title="Disk Write"'
+ + ' data-width="10%"'
+ + ' data-before="0"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' role="application"></div>';
+ }
+
+ if(typeof charts['system.cpu'] !== 'undefined')
+ head += '<div data-netdata="system.cpu"'
+ + ' data-chart-library="gauge"'
+ + ' data-title="CPU"'
+ + ' data-units="%"'
+ + ' data-gauge-max-value="100"'
+ + ' data-width="18%"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' data-colors="' + NETDATA.colors[12] + '"'
+ + ' role="application"></div>';
+
+ if(typeof charts['system.ipv4'] !== 'undefined') {
+ head += '<div style="margin-right: 10px;" data-netdata="system.ipv4"'
+ + ' data-dimensions="received"'
+ + ' data-chart-library="easypiechart"'
+ + ' data-title="IPv4 Inbound"'
+ + ' data-width="10%"'
+ + ' data-before="0"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' role="application"></div>';
+
+ head += '<div style="margin-right: 10px;" data-netdata="system.ipv4"'
+ + ' data-dimensions="sent"'
+ + ' data-chart-library="easypiechart"'
+ + ' data-title="IPv4 Outbound"'
+ + ' data-width="10%"'
+ + ' data-before="0"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' role="application"></div>';
+ }
+ else if(typeof charts['system.ipv6'] !== 'undefined') {
+ head += '<div style="margin-right: 10px;" data-netdata="system.ipv6"'
+ + ' data-dimensions="received"'
+ + ' data-chart-library="easypiechart"'
+ + ' data-title="IPv6 Inbound"'
+ + ' data-units="kbps"'
+ + ' data-width="10%"'
+ + ' data-before="0"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' role="application"></div>';
+
+ head += '<div style="margin-right: 10px;" data-netdata="system.ipv6"'
+ + ' data-dimensions="sent"'
+ + ' data-chart-library="easypiechart"'
+ + ' data-title="IPv6 Outbound"'
+ + ' data-units="kbps"'
+ + ' data-width="10%"'
+ + ' data-before="0"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' role="application"></div>';
+ }
+
+ if(typeof charts['system.ram'] !== 'undefined')
+ head += '<div style="margin-right: 10px;" data-netdata="system.ram"'
+ + ' data-dimensions="cached|free"'
+ + ' data-append-options="percentage"'
+ + ' data-chart-library="easypiechart"'
+ + ' data-title="Available RAM"'
+ + ' data-units="%"'
+ + ' data-easypiechart-max-value="100"'
+ + ' data-width="8%"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-points="' + duration.toString() + '"'
+ + ' data-colors="' + NETDATA.colors[7] + '"'
+ + ' role="application"></div>';
+
+ return head;
}
function generateHeadCharts(type, chart, duration) {
- var head = '';
- var hcharts = anyAttribute(chartData, type, chart.context, []);
- if(hcharts.length > 0) {
- var hi = 0, hlen = hcharts.length;
- while(hi < hlen) {
- if(typeof hcharts[hi] === 'function')
- head += hcharts[hi](chart.id).replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
- else
- head += hcharts[hi].replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
- hi++;
- }
- }
- return head;
+ var head = '';
+ var hcharts = anyAttribute(chartData, type, chart.context, []);
+ if(hcharts.length > 0) {
+ var hi = 0, hlen = hcharts.length;
+ while(hi < hlen) {
+ if(typeof hcharts[hi] === 'function')
+ head += hcharts[hi](chart.id).replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
+ else
+ head += hcharts[hi].replace('CHART_DURATION', duration.toString()).replace('CHART_UNIQUE_ID', chart.id);
+ hi++;
+ }
+ }
+ return head;
}
function renderPage(menus, data) {
- var div = document.getElementById('charts_div');
- var pcent_width = Math.floor(100 / chartsPerRow($(div).width()));
-
- // find the proper duration for per-second updates
- var duration = Math.round(($(div).width() * pcent_width / 100 * data.update_every / 3) / 60) * 60;
- var html = '';
- var sidebar = '<ul class="nav dashboard-sidenav" data-spy="affix" id="sidebar_ul">';
- var mainhead = headMain(data.charts, duration);
-
- // sort the menus
- var main = sortObjectByPriority(menus);
- var i = 0, len = main.length;
- while(i < len) {
- var menu = main[i++];
-
- // generate an entry at the main menu
-
- var menuid = name2id(menu);
- sidebar += '<li class=""><a href="#' + menuid + '">' + menus[menu].title + '</a><ul class="nav">';
- html += '<div role="section"><div role="sectionhead"><h1 id="' + menuid + '" role="heading">' + menus[menu].title + '</h1></div><div id="menu_' + menuid + '" role="document">';
-
- if(menus[menu].info !== null)
- html += menus[menu].info;
-
- // console.log(' >> ' + menu + ' (' + menus[menu].priority + '): ' + menus[menu].title);
-
- var shtml = '';
- var mhead = '<div class="netdata-chart-row">' + mainhead;
- mainhead = '';
-
- // sort the submenus of this menu
- var sub = sortObjectByPriority(menus[menu].submenus);
- var si = 0, slen = sub.length;
- while(si < slen) {
- var submenu = sub[si++];
-
- // generate an entry at the submenu
- var submenuid = name2id(menu + '_' + submenu);
- sidebar += '<li class><a href="#' + submenuid + '">' + menus[menu].submenus[submenu].title + '</a></li>';
- shtml += '<div class="netdata-group-container" id="submenu_' + submenuid + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + submenuid + '" class="netdata-chart-alignment" role="heading">' + menus[menu].submenus[submenu].title + '</h2>';
-
- if(menus[menu].submenus[submenu].info !== null)
- shtml += '<div class="chart-message netdata-chart-alignment" role="document">' + menus[menu].submenus[submenu].info + '</div>';
-
- var head = '<div class="netdata-chart-row">';
- var chtml = '';
-
- // console.log(' \------- ' + submenu + ' (' + menus[menu].submenus[submenu].priority + '): ' + menus[menu].submenus[submenu].title);
-
- // sort the charts in this submenu of this menu
- menus[menu].submenus[submenu].charts.sort(prioritySort);
- var ci = 0, clen = menus[menu].submenus[submenu].charts.length;
- while(ci < clen) {
- var chart = menus[menu].submenus[submenu].charts[ci++];
-
- // generate the submenu heading charts
- mhead += generateHeadCharts('mainheads', chart, duration);
- head += generateHeadCharts('heads', chart, duration);
-
- // generate the chart
- chtml += chartInfo(chart.context) + '<div data-netdata="' + chart.id + '"'
- + ' data-width="' + pcent_width.toString() + '%"'
- + ' data-height="' + chartHeight(chart.context, options.chartsHeight).toString() + 'px"'
- + ' data-before="0"'
- + ' data-after="-' + duration.toString() + '"'
- + ' data-id="' + name2id(options.hostname + '/' + chart.id) + '"'
- + ' data-colors="' + anyAttribute(chartData, 'colors', chart.context, '') + '"'
- + ' role="application"></div>';
-
- // console.log(' \------- ' + chart.id + ' (' + chart.priority + '): ' + chart.context + ' height: ' + menus[menu].submenus[submenu].height);
- }
-
- head += '</div>';
- shtml += head + chtml + '</div>';
- }
-
- mhead += '</div>';
- sidebar += '</ul></li>';
- html += mhead + shtml + '</div></div><hr role="separator"/>';
- }
-
- sidebar += '</ul>';
- div.innerHTML = html;
- document.getElementById('sidebar').innerHTML = sidebar;
- finalizePage();
+ var div = document.getElementById('charts_div');
+ var pcent_width = Math.floor(100 / chartsPerRow($(div).width()));
+
+ // find the proper duration for per-second updates
+ var duration = Math.round(($(div).width() * pcent_width / 100 * data.update_every / 3) / 60) * 60;
+ var html = '';
+ var sidebar = '<ul class="nav dashboard-sidenav" data-spy="affix" id="sidebar_ul">';
+ var mainhead = headMain(data.charts, duration);
+
+ // sort the menus
+ var main = sortObjectByPriority(menus);
+ var i = 0, len = main.length;
+ while(i < len) {
+ var menu = main[i++];
+
+ // generate an entry at the main menu
+
+ var menuid = name2id(menu);
+ sidebar += '<li class=""><a href="#' + menuid + '" onClick="return scrollToId(\'' + menuid + '\');">' + menus[menu].title + '</a><ul class="nav">';
+ html += '<div role="section"><div role="sectionhead"><h1 id="' + menuid + '" role="heading">' + menus[menu].title + '</h1></div><div id="menu_' + menuid + '" role="document">';
+
+ if(menus[menu].info !== null)
+ html += menus[menu].info;
+
+ // console.log(' >> ' + menu + ' (' + menus[menu].priority + '): ' + menus[menu].title);
+
+ var shtml = '';
+ var mhead = '<div class="netdata-chart-row">' + mainhead;
+ mainhead = '';
+
+ // sort the submenus of this menu
+ var sub = sortObjectByPriority(menus[menu].submenus);
+ var si = 0, slen = sub.length;
+ while(si < slen) {
+ var submenu = sub[si++];
+
+ // generate an entry at the submenu
+ var submenuid = name2id(menu + '_' + submenu);
+ sidebar += '<li class><a href="#' + submenuid + '" onClick="return scrollToId(\'' + submenuid + '\');">' + menus[menu].submenus[submenu].title + '</a></li>';
+ shtml += '<div class="netdata-group-container" id="submenu_' + submenuid + '" style="display: inline-block; width: ' + pcent_width.toString() + '%"><h2 id="' + submenuid + '" class="netdata-chart-alignment" role="heading">' + menus[menu].submenus[submenu].title + '</h2>';
+
+ if(menus[menu].submenus[submenu].info !== null)
+ shtml += '<div class="chart-message netdata-chart-alignment" role="document">' + menus[menu].submenus[submenu].info + '</div>';
+
+ var head = '<div class="netdata-chart-row">';
+ var chtml = '';
+
+ // console.log(' \------- ' + submenu + ' (' + menus[menu].submenus[submenu].priority + '): ' + menus[menu].submenus[submenu].title);
+
+ // sort the charts in this submenu of this menu
+ menus[menu].submenus[submenu].charts.sort(prioritySort);
+ var ci = 0, clen = menus[menu].submenus[submenu].charts.length;
+ while(ci < clen) {
+ var chart = menus[menu].submenus[submenu].charts[ci++];
+
+ // generate the submenu heading charts
+ mhead += generateHeadCharts('mainheads', chart, duration);
+ head += generateHeadCharts('heads', chart, duration);
+
+ // generate the chart
+ chtml += chartInfo(chart.context) + '<div data-netdata="' + chart.id + '"'
+ + ' data-width="' + pcent_width.toString() + '%"'
+ + ' data-height="' + chartHeight(chart.context, options.chartsHeight).toString() + 'px"'
+ + ' data-before="0"'
+ + ' data-after="-' + duration.toString() + '"'
+ + ' data-id="' + name2id(options.hostname + '/' + chart.id) + '"'
+ + ' data-colors="' + anyAttribute(chartData, 'colors', chart.context, '') + '"'
+ + ' role="application"></div>';
+
+ // console.log(' \------- ' + chart.id + ' (' + chart.priority + '): ' + chart.context + ' height: ' + menus[menu].submenus[submenu].height);
+ }
+
+ head += '</div>';
+ shtml += head + chtml + '</div>';
+ }
+
+ mhead += '</div>';
+ sidebar += '</ul></li>';
+ html += mhead + shtml + '</div></div><hr role="separator"/>';
+ }
+
+ sidebar += '</ul>';
+ div.innerHTML = html;
+ document.getElementById('sidebar').innerHTML = sidebar;
+ finalizePage();
}
function renderChartsAndMenu(data) {
- var menus = {};
- var charts = data.charts;
-
- for(var c in charts) {
- enrichChartData(charts[c]);
-
- // create the menu
- if(typeof menus[charts[c].menu] === 'undefined') {
- menus[charts[c].menu] = {
- priority: charts[c].priority,
- submenus: {},
- title: menuTitle(charts[c]),
- info: menuInfo(charts[c].menu),
- height: menuHeight(charts[c].menu, options.chartsHeight)
- };
- }
-
- if(charts[c].priority < menus[charts[c].menu].priority)
- menus[charts[c].menu].priority = charts[c].priority;
-
- // create the submenu
- if(typeof menus[charts[c].menu].submenus[charts[c].submenu] === 'undefined') {
- menus[charts[c].menu].submenus[charts[c].submenu] = {
- priority: charts[c].priority,
- charts: new Array(),
- title: null,
- info: submenuInfo(charts[c].menu, charts[c].submenu),
- height: submenuHeight(charts[c].menu, charts[c].submenu, menus[charts[c].menu].height)
- };
- }
-
- if(charts[c].priority < menus[charts[c].menu].submenus[charts[c].submenu].priority)
- menus[charts[c].menu].submenus[charts[c].submenu].priority = charts[c].priority;
-
- // index the chart in the menu/submenu
- menus[charts[c].menu].submenus[charts[c].submenu].charts.push(charts[c]);
- }
-
- // propagate the descriptive subname given to QoS
- // to all the other submenus with the same name
- for(var m in menus) {
- for(var s in menus[m].submenus) {
- // set the family using a name
- if(typeof options.submenu_names[s] !== 'undefined') {
- menus[m].submenus[s].title = s + ' (' + options.submenu_names[s] + ')';
- }
- else {
- menus[m].submenus[s].title = submenuTitle(m, s);
- }
- }
- }
-
- renderPage(menus, data);
+ var menus = options.menus;
+ var charts = data.charts;
+
+ for(var c in charts) {
+ enrichChartData(charts[c]);
+
+ // create the menu
+ if(typeof menus[charts[c].menu] === 'undefined') {
+ menus[charts[c].menu] = {
+ priority: charts[c].priority,
+ submenus: {},
+ title: menuTitle(charts[c]),
+ info: menuInfo(charts[c].menu),
+ height: menuHeight(charts[c].menu, options.chartsHeight)
+ };
+ }
+
+ if(charts[c].priority < menus[charts[c].menu].priority)
+ menus[charts[c].menu].priority = charts[c].priority;
+
+ // create the submenu
+ if(typeof menus[charts[c].menu].submenus[charts[c].submenu] === 'undefined') {
+ menus[charts[c].menu].submenus[charts[c].submenu] = {
+ priority: charts[c].priority,
+ charts: new Array(),
+ title: null,
+ info: submenuInfo(charts[c].menu, charts[c].submenu),
+ height: submenuHeight(charts[c].menu, charts[c].submenu, menus[charts[c].menu].height)
+ };
+ }
+
+ if(charts[c].priority < menus[charts[c].menu].submenus[charts[c].submenu].priority)
+ menus[charts[c].menu].submenus[charts[c].submenu].priority = charts[c].priority;
+
+ // index the chart in the menu/submenu
+ menus[charts[c].menu].submenus[charts[c].submenu].charts.push(charts[c]);
+ }
+
+ // propagate the descriptive subname given to QoS
+ // to all the other submenus with the same name
+ for(var m in menus) {
+ for(var s in menus[m].submenus) {
+ // set the family using a name
+ if(typeof options.submenu_names[s] !== 'undefined') {
+ menus[m].submenus[s].title = s + ' (' + options.submenu_names[s] + ')';
+ }
+ else {
+ menus[m].submenus[s].title = submenuTitle(m, s);
+ }
+ }
+ }
+
+ renderPage(menus, data);
+}
+
+function alarmsUpdateModal() {
+ var active = '<h3>Raised Alarms</h3><table class="table">';
+ var all = '<h3>All Running Alarms</h3><table class="table">';
+ var log = '<h3>Alarm Log</h3><table class="table"><tr><th>When</th><th>Chart</th><th>Alarm</th><th>Status</th></tr>';
+ var footer = '<hr/>These are <a href="https://github.com/firehol/netdata/wiki/Generating-Badges" target="_blank">netdata badges</a>. You can copy and paste their URLs to embed them in any web page. Their color indicates the state of the alarm: <b>red</b> is critical, <b>orange</b> is warning, <b>bright green</b> is ok, <b>light grey</b> is undefined (i.e. no data or no status), <b>black</b> is not initialized.';
+
+ NETDATA.alarms.get('all', function(data) {
+ if(data === null) {
+ document.getElementById('alarms_active').innerHTML =
+ document.getElementById('alarms_all').innerHTML =
+ document.getElementById('alarms_log').innerHTML =
+ 'failed to load alarm data!';
+ return;
+ }
+
+ var now = new Date().getTime();
+ var x;
+ var count_active = 0;
+ var count_all = 0;
+ var families = {};
+ for(x in data.alarms) {
+ var alarm = data.alarms[x];
+ var chart = options.data.charts[alarm.chart];
+ var family = alarm.family;
+
+ if(typeof chart !== 'undefined' && typeof chart.menu !== 'undefined' && typeof chart.submenu !== 'undefined')
+ family = chart.menu + ' - ' + chart.submenu;
+
+ if(typeof families[family] === 'undefined')
+ families[family] = new Array();
+
+ families[family].push(alarm);
+ }
+
+ for(x in families) {
+ var active_family_added = false;
+ var all_family_added = false;
+
+ var arr = families[x];
+ var c = arr.length;
+ while(c--) {
+ var alarm = arr[c];
+ if(alarm.status === 'WARNING' || alarm.status === 'CRITICAL') {
+ if(!active_family_added) {
+ active_family_added = true;
+ active += '<tr><th class="text-center"><h4>' + x + '</h4></th><th></th></tr>';
+ }
+ active += '<tr><td class="text-center" style="vertical-align:middle"><embed><img src="' + NETDATA.serverDefault + '/api/v1/badge.svg?chart=' + alarm.chart + '&alarm=' + alarm.name + '&refresh=auto&_=' + now.toString()+ '"></img></embed></td><td><b>' + alarm.info + '</b><table>' + ((typeof alarm.warn !== 'undefined')?('<tr><td>&nbsp;warning&nbsp;when&nbsp;</td><td><code>' + alarm.warn + '</code></td></tr>'):'') + ((typeof alarm.crit !== 'undefined')?('<tr><td style="text-align:right">&nbsp;critical&nbsp;when&nbsp;</td><td><code>' + alarm.crit + '</code></td></tr>'):'') + '<tr><td style="text-align:right"><small>&nbsp;source&nbsp;</small></td><td><small>' + alarm.source + '</small></td></tr></table></td></tr>';
+ count_active++;
+ }
+
+ if(!all_family_added) {
+ all_family_added = true;
+ all += '<tr><th class="text-center"><h4>' + x + '</h4></th><th></th></tr>';
+ }
+ all += '<tr><td class="text-center" style="vertical-align:middle"><embed><img src="' + NETDATA.serverDefault + '/api/v1/badge.svg?chart=' + alarm.chart + '&alarm=' + alarm.name + '&refresh=auto&_=' + now.toString()+ '"></img></embed></td><td><b>' + alarm.info + '</b><table>' + ((typeof alarm.warn !== 'undefined')?('<tr><td>&nbsp;warning&nbsp;when&nbsp;</td><td><code>' + alarm.warn + '</code></td></tr>'):'') + ((typeof alarm.crit !== 'undefined')?('<tr><td style="text-align:right">&nbsp;critical&nbsp;when&nbsp;</td><td><code>' + alarm.crit + '</code></td></tr>'):'') + '<tr><td style="text-align:right"><small>&nbsp;source&nbsp;</small></td><td><small>' + alarm.source + '</small></td></tr></table></td></tr>';
+ count_all++;
+ }
+ }
+ active += "</table>";
+ all += "</table>";
+
+ if(!count_active)
+ active += "<h4>Everything is normal. No raised alarms.</h4>";
+ else
+ active += footer;
+
+ if(!count_all)
+ all += "<h4>No alarms are running in this system.</h4>";
+ else
+ all += footer;
+
+ document.getElementById('alarms_active').innerHTML = active;
+ document.getElementById('alarms_all').innerHTML = all;
+
+ NETDATA.alarms.get_log(function(data) {
+ if(data === null) {
+ document.getElementById('alarms_log').innerHTML =
+ 'failed to load alarm data!';
+ return;
+ }
+
+ var i = 0;
+ var len = data.length;
+ if(len > 50) len = 50;
+ while(i < len) {
+ var time = new Date(data[i].when * 1000);
+ log += '<tr><td>' + time.toLocaleDateString() + ' ' + time.toLocaleTimeString() + '</td><td>' + data[i].chart + '</td><td>' + data[i].name + '</td><td>' + data[i].status + '</td></tr>';
+ i++;
+ }
+ log += "</table>";
+
+ if(i == 0)
+ log += "<h4>No alarms have been logged in this system.</h4>";
+
+ document.getElementById('alarms_log').innerHTML = log;
+ })
+ });
+}
+
+function alarmsCallback(data) {
+ var count = 0;
+ for(x in data.alarms)
+ count++;
+
+ if(count > 0)
+ document.getElementById('alarms_count_badge').innerHTML = count.toString();
+ else
+ document.getElementById('alarms_count_badge').innerHTML = '';
}
function downloadAllCharts(netdata_url) {
- if(typeof netdata_url === 'undefined' || netdata_url === null)
- netdata_url = NETDATA.serverDefault;
+ if(typeof netdata_url === 'undefined' || netdata_url === null)
+ netdata_url = NETDATA.serverDefault;
+
+ NETDATA.pause(function() {
+ $("#loadOverlay").css("display","none");
+ $("#loadOverlay").css("display","none");
- NETDATA.pause(function() {
+ NETDATA.alarms.callback = alarmsCallback;
- // download all the charts the server knows
- NETDATA.chartRegistry.downloadAll(netdata_url, function(data) {
+ // download all the charts the server knows
+ NETDATA.chartRegistry.downloadAll(netdata_url, function(data) {
- options.data = data;
- options.hostname = data.hostname;
- document.getElementById('hostname').innerHTML = options.hostname;
- document.getElementById('hostname').href = NETDATA.serverDefault;
- document.title = options.hostname + ' dashboard';
+ options.data = data;
+ options.hostname = data.hostname;
+ document.getElementById('hostname').innerHTML = options.hostname;
+ document.getElementById('hostname').href = NETDATA.serverDefault;
+ document.title = options.hostname + ' netdata dashboard';
- renderChartsAndMenu(data);
+ renderChartsAndMenu(data);
- // prepare our DOM
-// prepareScreen(data);
+ // prepare our DOM
+// prepareScreen(data);
- // due to affix issues, prepareScreen() will unpause
- // netdata as needed
- });
- });
+ // due to affix issues, prepareScreen() will unpause
+ // netdata as needed
+ });
+ });
}
// ----------------------------------------------------------------------------
function versionLog(msg) {
- document.getElementById('versionCheckLog').innerHTML = msg;
+ document.getElementById('versionCheckLog').innerHTML = msg;
}
function getNetdataVersion(callback) {
- versionLog('Downloading installed version info from netdata...');
-
- $.ajax({
- url: 'version.txt',
- async: true,
- cache: false
- })
- .done(function(data) {
- data = data.replace(/(\r\n|\n|\r| |\t)/gm,"");
- if(data.length !== 40) {
- versionLog('Received version string is invalid.');
- callback(null);
- }
- else {
- versionLog('Installed version of netdata is ' + data);
- document.getElementById('netdataVersion').innerHTML = data;
- callback(data);
- }
- })
- .fail(function() {
- versionLog('Failed to download installed version info from netdata!');
- callback(null);
- });
+ versionLog('Downloading installed version info from netdata...');
+
+ $.ajax({
+ url: 'version.txt',
+ async: true,
+ cache: false
+ })
+ .done(function(data) {
+ data = data.replace(/(\r\n|\n|\r| |\t)/gm,"");
+ if(data.length !== 40) {
+ versionLog('Received version string is invalid.');
+ callback(null);
+ }
+ else {
+ versionLog('Installed version of netdata is ' + data);
+ document.getElementById('netdataVersion').innerHTML = data;
+ callback(data);
+ }
+ })
+ .fail(function() {
+ versionLog('Failed to download installed version info from netdata!');
+ callback(null);
+ });
}
function getGithubLatestCommit(callback) {
- versionLog('Downloading latest version info from github...');
-
- $.ajax({
- url: 'https://api.github.com/repos/firehol/netdata/commits',
- async: true,
- cache: false
- })
- .done(function(data) {
- versionLog('Latest version info from github is ' + data[0].sha);
- callback(data[0].sha);
- })
- .fail(function() {
- versionLog('Failed to download installed version info from github!');
- callback(null);
- });
+ versionLog('Downloading latest version info from github...');
+
+ $.ajax({
+ url: 'https://api.github.com/repos/firehol/netdata/commits',
+ async: true,
+ cache: false
+ })
+ .done(function(data) {
+ versionLog('Latest version info from github is ' + data[0].sha);
+ callback(data[0].sha);
+ })
+ .fail(function() {
+ versionLog('Failed to download installed version info from github!');
+ callback(null);
+ });
}
function checkForUpdate(callback) {
- getNetdataVersion(function(sha1) {
- if(sha1 === null) callback(null, null);
+ getNetdataVersion(function(sha1) {
+ if(sha1 === null) callback(null, null);
- getGithubLatestCommit(function(sha2) {
- callback(sha1, sha2);
- });
- });
+ getGithubLatestCommit(function(sha2) {
+ callback(sha1, sha2);
+ });
+ });
- return null;
+ return null;
}
-var updateBlinkCounter = 0;
function notifyForUpdate(force) {
- versionLog('<p>checking for updates...</p>');
-
- var now = new Date().getTime();
-
- if(typeof force === 'undefined' || force !== true) {
- var last = loadLocalStorage('last_update_check');
-
- if(typeof last === 'string')
- last = parseInt(last);
- else
- last = 0;
-
- if(now - last < 3600000 * 8) {
- // no need to check it - too soon
- return;
- }
- }
-
- checkForUpdate(function(sha1, sha2) {
- var save = false;
-
- if(sha1 === null) {
- save = false;
- versionLog('<p><big>Failed to get your netdata version!</big></p><p>You can always get the latest version of netdata from <a href="https://github.com/firehol/netdata" target="_blank">its github page</a>.</p>');
- }
- else if(sha2 === null) {
- save = false;
- versionLog('<p><big>Failed to get the latest version from github.</big></p><p>You can always get the latest version of netdata from <a href="https://github.com/firehol/netdata" target="_blank">its github page</a>.</p>');
- }
- else if(sha1 === sha2) {
- save = true;
- versionLog('<p><big>You already have the latest version of netdata!</big></p><p>No update yet?<br/>Probably, we need some motivation to keep going on!</p><p>If you haven\'t already, <a href="https://github.com/firehol/netdata" target="_blank">give netdata a <b>Star</b> at its github page</a>.</p>');
- }
- else {
- save = true;
- var compare = 'https://github.com/firehol/netdata/compare/' + sha1.toString() + '...' + sha2.toString();
-
- versionLog('<p><big><strong>New version of netdata available!</strong></big></p><p>Latest version: ' + sha2.toString() + '</p><p><a href="' + compare + '" target="_blank">Click here for the changes log</a> since your installed version, and<br/><a href="https://github.com/firehol/netdata/wiki/Updating-Netdata" target="_blank">click here for directions on updating</a> your netdata installation.</p><p>We suggest to review the changes log for new features you may be interested, or important bug fixes you may need.<br/>Keeping your netdata updated, is generally a good idea.</p>');
-
- function updateButtonBlink() {
- updateBlinkCounter--;
- if(updateBlinkCounter > 0)
- $('#updateButton').fadeOut(500).fadeIn(500, updateButtonBlink);
- }
-
- if(updateBlinkCounter === 0) {
- updateBlinkCounter = 300;
- updateButtonBlink();
- }
- }
-
- if(save)
- saveLocalStorage('last_update_check', now.toString());
- });
-}
+ versionLog('<p>checking for updates...</p>');
-// ----------------------------------------------------------------------------
+ var now = new Date().getTime();
-function getUrlParameter(sParam) {
- var sPageURL = decodeURIComponent(window.location.search.substring(1)),
- sURLVariables = sPageURL.split('&'),
- sParameterName,
- i;
+ if(typeof force === 'undefined' || force !== true) {
+ var last = loadLocalStorage('last_update_check');
- for (i = 0; i < sURLVariables.length; i++) {
- sParameterName = sURLVariables[i].split('=');
+ if(typeof last === 'string')
+ last = parseInt(last);
+ else
+ last = 0;
- if (sParameterName[0] === sParam) {
- return sParameterName[1] === undefined ? true : sParameterName[1];
+ if(now - last < 3600000 * 8) {
+ // no need to check it - too soon
+ return;
}
}
+
+ checkForUpdate(function(sha1, sha2) {
+ var save = false;
+
+ if(sha1 === null) {
+ save = false;
+ versionLog('<p><big>Failed to get your netdata version!</big></p><p>You can always get the latest version of netdata from <a href="https://github.com/firehol/netdata" target="_blank">its github page</a>.</p>');
+ }
+ else if(sha2 === null) {
+ save = false;
+ versionLog('<p><big>Failed to get the latest version from github.</big></p><p>You can always get the latest version of netdata from <a href="https://github.com/firehol/netdata" target="_blank">its github page</a>.</p>');
+ }
+ else if(sha1 === sha2) {
+ save = true;
+ versionLog('<p><big>You already have the latest version of netdata!</big></p><p>No update yet?<br/>Probably, we need some motivation to keep going on!</p><p>If you haven\'t already, <a href="https://github.com/firehol/netdata" target="_blank">give netdata a <b>Star</b> at its github page</a>.</p>');
+ }
+ else {
+ save = true;
+ var compare = 'https://github.com/firehol/netdata/compare/' + sha1.toString() + '...' + sha2.toString();
+
+ versionLog('<p><big><strong>New version of netdata available!</strong></big></p><p>Latest version: ' + sha2.toString() + '</p><p><a href="' + compare + '" target="_blank">Click here for the changes log</a> since your installed version, and<br/><a href="https://github.com/firehol/netdata/wiki/Updating-Netdata" target="_blank">click here for directions on updating</a> your netdata installation.</p><p>We suggest to review the changes log for new features you may be interested, or important bug fixes you may need.<br/>Keeping your netdata updated, is generally a good idea.</p>');
+
+ document.getElementById('update_badge').innerHTML = '!';
+ }
+
+ if(save)
+ saveLocalStorage('last_update_check', now.toString());
+ });
}
+// ----------------------------------------------------------------------------
+
function finalizePage() {
- // resize all charts - without starting the background thread
- // this has to be done while NETDATA is paused
- // if we ommit this, the affix menu will be wrong, since all
- // the Dom elements are initially zero-sized
- NETDATA.parseDom();
-
- var before = 0, after = 0, nowelcome = 0;
- after = getUrlParameter('force_after_ms');
- before = getUrlParameter('force_before_ms');
- nowelcome = (getUrlParameter('nowelcome') === true)?true:false;
-
- if(before > 0 && after > 0) {
- nowelcome = true;
- NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], after, before);
- }
-
- // let it run (update the charts)
- NETDATA.unpause();
-
- // check if we have to jump to a specific section
- var hash = location.hash.replace('#','');
- if(hash != '') {
- // Clear the hash in the URL
- // location.hash = ''; // delete front "//" if you want to change the address bar
- var offset = $(location.hash).offset();
- if(typeof offset !== 'undefined')
- $('html, body').animate({ scrollTop: offset.top }, 0);
- }
-
- /* activate bootstrap sidebar (affix) */
- $('#sidebar').affix({
- offset: {
- top: (isdemo())?150:0,
- bottom: 0
- }
- });
-
- /* fix scrolling of very long affix lists
- http://stackoverflow.com/questions/21691585/bootstrap-3-1-0-affix-too-long
- */
- $('#sidebar').on('affixed.bs.affix', function() {
- $(this).removeAttr('style');
- });
-
- /* activate bootstrap scrollspy (needed for sidebar) */
- $(document.body).scrollspy({
- target: '#sidebar',
- offset: $(window).height() / 3 // controls the diff of the <hX> element to the top, to select it
- });
-
- document.getElementById('footer').style.display = 'block';
-
-
- var update_options_modal = function() {
- // console.log('update_options_modal');
-
- var sync_option = function(option) {
- var self = $('#' + option);
-
- if(self.prop('checked') !== NETDATA.getOption(option)) {
- // console.log('switching ' + option.toString());
- self.bootstrapToggle(NETDATA.getOption(option)?'on':'off');
- }
- }
-
- var theme_sync_option = function(option) {
- var self = $('#' + option);
-
- self.bootstrapToggle(netdataTheme === 'slate'?'on':'off');
- }
-
- sync_option('eliminate_zero_dimensions');
- sync_option('destroy_on_hide');
- sync_option('parallel_refresher');
- sync_option('concurrent_refreshes');
- sync_option('sync_selection');
- sync_option('sync_pan_and_zoom');
- sync_option('stop_updates_when_focus_is_lost');
- sync_option('smooth_plot');
- sync_option('pan_and_zoom_data_padding');
- sync_option('show_help');
- theme_sync_option('netdata_theme_control');
-
- if(NETDATA.getOption('parallel_refresher') === false) {
- $('#concurrent_refreshes_row').hide();
- }
- else {
- $('#concurrent_refreshes_row').show();
- }
- };
- NETDATA.setOption('setOptionCallback', update_options_modal);
-
- // handle options changes
- $('#eliminate_zero_dimensions').change(function() { NETDATA.setOption('eliminate_zero_dimensions', $(this).prop('checked')); });
- $('#destroy_on_hide').change(function() { NETDATA.setOption('destroy_on_hide', $(this).prop('checked')); });
- $('#parallel_refresher').change(function() { NETDATA.setOption('parallel_refresher', $(this).prop('checked')); });
- $('#concurrent_refreshes').change(function() { NETDATA.setOption('concurrent_refreshes', $(this).prop('checked')); });
- $('#sync_selection').change(function() { NETDATA.setOption('sync_selection', $(this).prop('checked')); });
- $('#sync_pan_and_zoom').change(function() { NETDATA.setOption('sync_pan_and_zoom', $(this).prop('checked')); });
- $('#stop_updates_when_focus_is_lost').change(function() { NETDATA.setOption('stop_updates_when_focus_is_lost', $(this).prop('checked')); });
- $('#smooth_plot').change(function() { NETDATA.setOption('smooth_plot', $(this).prop('checked')); });
- $('#pan_and_zoom_data_padding').change(function() { NETDATA.setOption('pan_and_zoom_data_padding', $(this).prop('checked')); });
- $('#show_help').change(function() { NETDATA.setOption('show_help', $(this).prop('checked')); location.reload(); });
-
- // this has to be the last
- // it reloads the page
- $('#netdata_theme_control').change(function() {
- if(setTheme($(this).prop('checked')?'slate':'white'))
- location.reload();
- });
-
- $('#updateModal').on('shown.bs.modal', function() {
- notifyForUpdate(true);
- });
-
- $('#deleteRegistryModal').on('hidden.bs.modal', function() {
- deleteRegistryGuid = null;
- });
-
- if(isdemo()) {
- if(!nowelcome) {
- setTimeout(function() {
- $('#welcomeModal').modal();
- }, 1000);
- }
-
- // google analytics when this is used for the home page of the demo sites
- // this does not run on user's installations
- setTimeout(function() {
- (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
- (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
- m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
- })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
-
- ga('create', 'UA-64295674-3', 'auto');
- ga('send', 'pageview');
- }, 2000);
- }
- else notifyForUpdate();
+ // resize all charts - without starting the background thread
+ // this has to be done while NETDATA is paused
+ // if we ommit this, the affix menu will be wrong, since all
+ // the Dom elements are initially zero-sized
+ NETDATA.parseDom();
+
+ if(urlOptions.pan_and_zoom === true) {
+ urlOptions.nowelcome = true;
+ NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], urlOptions.after, urlOptions.before);
+ }
+
+ // ------------------------------------------------------------------------
+ // https://github.com/viralpatel/jquery.shorten/blob/master/src/jquery.shorten.js
+ $.fn.shorten = function(settings) {
+ "use strict";
+
+ var config = {
+ showChars: 750,
+ minHideChars: 10,
+ ellipsesText: "...",
+ moreText: '<i class="fa fa-expand" aria-hidden="true"></i> show more information',
+ lessText: '<i class="fa fa-compress" aria-hidden="true"></i> show less information',
+ onLess: function() { NETDATA.onscroll(); },
+ onMore: function() { NETDATA.onscroll(); },
+ errMsg: null,
+ force: false
+ };
+
+ if (settings) {
+ $.extend(config, settings);
+ }
+
+ if ($(this).data('jquery.shorten') && !config.force) {
+ return false;
+ }
+ $(this).data('jquery.shorten', true);
+
+ $(document).off("click", '.morelink');
+
+ $(document).on({
+ click: function() {
+
+ var $this = $(this);
+ if ($this.hasClass('less')) {
+ $this.removeClass('less');
+ $this.html(config.moreText);
+ $this.parent().prev().animate({'height':'0'+'%'}, 0, function () { $this.parent().prev().prev().show(); }).hide(0, function() {
+ config.onLess();
+ });
+
+ } else {
+ $this.addClass('less');
+ $this.html(config.lessText);
+ $this.parent().prev().animate({'height':'100'+'%'}, 0, function () { $this.parent().prev().prev().hide(); }).show(0, function() {
+ config.onMore();
+ });
+ }
+ return false;
+ }
+ }, '.morelink');
+
+ return this.each(function() {
+ var $this = $(this);
+
+ var content = $this.html();
+ var contentlen = $this.text().length;
+ if (contentlen > config.showChars + config.minHideChars) {
+ var c = content.substr(0, config.showChars);
+ if (c.indexOf('<') >= 0) // If there's HTML don't want to cut it
+ {
+ var inTag = false; // I'm in a tag?
+ var bag = ''; // Put the characters to be shown here
+ var countChars = 0; // Current bag size
+ var openTags = []; // Stack for opened tags, so I can close them later
+ var tagName = null;
+
+ for (var i = 0, r = 0; r <= config.showChars; i++) {
+ if (content[i] == '<' && !inTag) {
+ inTag = true;
+
+ // This could be "tag" or "/tag"
+ tagName = content.substring(i + 1, content.indexOf('>', i));
+
+ // If its a closing tag
+ if (tagName[0] == '/') {
+
+
+ if (tagName != '/' + openTags[0]) {
+ config.errMsg = 'ERROR en HTML: the top of the stack should be the tag that closes';
+ } else {
+ openTags.shift(); // Pops the last tag from the open tag stack (the tag is closed in the retult HTML!)
+ }
+
+ } else {
+ // There are some nasty tags that don't have a close tag like <br/>
+ if (tagName.toLowerCase() != 'br') {
+ openTags.unshift(tagName); // Add to start the name of the tag that opens
+ }
+ }
+ }
+ if (inTag && content[i] == '>') {
+ inTag = false;
+ }
+
+ if (inTag) { bag += content.charAt(i); } // Add tag name chars to the result
+ else {
+ r++;
+ if (countChars <= config.showChars) {
+ bag += content.charAt(i); // Fix to ie 7 not allowing you to reference string characters using the []
+ countChars++;
+ } else // Now I have the characters needed
+ {
+ if (openTags.length > 0) // I have unclosed tags
+ {
+ //console.log('They were open tags');
+ //console.log(openTags);
+ for (j = 0; j < openTags.length; j++) {
+ //console.log('Cierro tag ' + openTags[j]);
+ bag += '</' + openTags[j] + '>'; // Close all tags that were opened
+
+ // You could shift the tag from the stack to check if you end with an empty stack, that means you have closed all open tags
+ }
+ break;
+ }
+ }
+ }
+ }
+ c = $('<div/>').html(bag + '<span class="ellip">' + config.ellipsesText + '</span>').html();
+ }else{
+ c+=config.ellipsesText;
+ }
+
+ var html = '<div class="shortcontent">' + c +
+ '</div><div class="allcontent">' + content +
+ '</div><span><a href="javascript://nop/" class="morelink">' + config.moreText + '</a></span>';
+
+ $this.html(html);
+ $this.find(".allcontent").hide(); // Hide all text
+ $('.shortcontent p:last', $this).css('margin-bottom', 0); //Remove bottom margin on last paragraph as it's likely shortened
+ }
+ });
+
+ };
+ $(".chart-message").shorten();
+ // ------------------------------------------------------------------------
+
+ // callback for us to track PanAndZoom operations
+ NETDATA.globalPanAndZoom.callback = netdataPanAndZoomCallback;
+
+ // let it run (update the charts)
+ NETDATA.unpause();
+
+ // check if we have to jump to a specific section
+ scrollToId(urlOptions.hash.replace('#',''));
+
+ /* activate bootstrap sidebar (affix) */
+ $('#sidebar').affix({
+ offset: {
+ top: (isdemo())?150:0,
+ bottom: 0
+ }
+ });
+
+ /* fix scrolling of very long affix lists
+ http://stackoverflow.com/questions/21691585/bootstrap-3-1-0-affix-too-long
+ */
+ $('#sidebar').on('affixed.bs.affix', function() {
+ $(this).removeAttr('style');
+ });
+
+ /* activate bootstrap scrollspy (needed for sidebar) */
+ $(document.body).scrollspy({
+ target: '#sidebar',
+ offset: $(window).height() / 3 // controls the diff of the <hX> element to the top, to select it
+ });
+
+ // change the URL based on the current position of the screen
+ $('#sidebar').on('activate.bs.scrollspy', function (e) {
+ var el = $(e.target);
+ if(el.find('ul').size() == 0) {
+ var hash = el.find('a').attr('href');
+ if(typeof hash === 'string' && hash.substring(0, 1) == '#') {
+ urlOptions.hash = hash;
+ // console.log(urlOptions.hash);
+ netdataHashUpdate();
+ }
+ }
+ });
+
+ document.getElementById('footer').style.display = 'block';
+
+ var update_options_modal = function() {
+ // console.log('update_options_modal');
+
+ var sync_option = function(option) {
+ var self = $('#' + option);
+
+ if(self.prop('checked') !== NETDATA.getOption(option)) {
+ // console.log('switching ' + option.toString());
+ self.bootstrapToggle(NETDATA.getOption(option)?'on':'off');
+ }
+ }
+
+ var theme_sync_option = function(option) {
+ var self = $('#' + option);
+
+ self.bootstrapToggle(netdataTheme === 'slate'?'on':'off');
+ }
+
+ sync_option('eliminate_zero_dimensions');
+ sync_option('destroy_on_hide');
+ sync_option('parallel_refresher');
+ sync_option('concurrent_refreshes');
+ sync_option('sync_selection');
+ sync_option('sync_pan_and_zoom');
+ sync_option('stop_updates_when_focus_is_lost');
+ sync_option('smooth_plot');
+ sync_option('pan_and_zoom_data_padding');
+ sync_option('show_help');
+ theme_sync_option('netdata_theme_control');
+
+ if(NETDATA.getOption('parallel_refresher') === false) {
+ $('#concurrent_refreshes_row').hide();
+ }
+ else {
+ $('#concurrent_refreshes_row').show();
+ }
+ };
+ NETDATA.setOption('setOptionCallback', update_options_modal);
+
+ // handle options changes
+ $('#eliminate_zero_dimensions').change(function() { NETDATA.setOption('eliminate_zero_dimensions', $(this).prop('checked')); });
+ $('#destroy_on_hide').change(function() { NETDATA.setOption('destroy_on_hide', $(this).prop('checked')); });
+ $('#parallel_refresher').change(function() { NETDATA.setOption('parallel_refresher', $(this).prop('checked')); });
+ $('#concurrent_refreshes').change(function() { NETDATA.setOption('concurrent_refreshes', $(this).prop('checked')); });
+ $('#sync_selection').change(function() { NETDATA.setOption('sync_selection', $(this).prop('checked')); });
+ $('#sync_pan_and_zoom').change(function() { NETDATA.setOption('sync_pan_and_zoom', $(this).prop('checked')); });
+ $('#stop_updates_when_focus_is_lost').change(function() { NETDATA.setOption('stop_updates_when_focus_is_lost', $(this).prop('checked')); });
+ $('#smooth_plot').change(function() { NETDATA.setOption('smooth_plot', $(this).prop('checked')); });
+ $('#pan_and_zoom_data_padding').change(function() { NETDATA.setOption('pan_and_zoom_data_padding', $(this).prop('checked')); });
+ $('#show_help').change(function() {
+ urlOptions.help = $(this).prop('checked');
+ NETDATA.setOption('show_help', urlOptions.help);
+ netdataReload();
+ });
+
+ // this has to be the last
+ // it reloads the page
+ $('#netdata_theme_control').change(function() {
+ urlOptions.theme = $(this).prop('checked')?'slate':'white';
+ if(setTheme(urlOptions.theme))
+ netdataReload();
+ });
+
+ $('#updateModal').on('shown.bs.modal', function() {
+ notifyForUpdate(true);
+ });
+
+ $('#alarmsModal').on('shown.bs.modal', function() {
+ alarmsUpdateModal();
+ });
+
+ $('#alarmsModal').on('hidden.bs.modal', function() {
+ document.getElementById('alarms_active').innerHTML =
+ document.getElementById('alarms_all').innerHTML =
+ document.getElementById('alarms_log').innerHTML =
+ 'loading...';
+ });
+
+ $('#deleteRegistryModal').on('hidden.bs.modal', function() {
+ deleteRegistryGuid = null;
+ });
+
+ if(isdemo()) {
+ if(!urlOptions.nowelcome) {
+ setTimeout(function() {
+ $('#welcomeModal').modal();
+ }, 1000);
+ }
+
+ // google analytics when this is used for the home page of the demo sites
+ // this does not run on user's installations
+ setTimeout(function() {
+ (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
+ (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
+ m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
+ })(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
+
+ ga('create', 'UA-64295674-3', 'auto');
+ ga('send', 'pageview');
+ }, 2000);
+ }
+ else notifyForUpdate();
}
function resetDashboardOptions() {
- var help = NETDATA.options.current.show_help;
+ var help = NETDATA.options.current.show_help;
- NETDATA.resetOptions();
- if(setTheme('slate'))
- location.reload();
+ NETDATA.resetOptions();
+ if(setTheme('slate'))
+ netdataReload();
- if(help !== NETDATA.options.current.show_help)
- location.reload();
+ if(help !== NETDATA.options.current.show_help)
+ netdataReload();
}
downloadAllCharts();
diff --git a/web/netdata-swagger.json b/web/netdata-swagger.json
index ba674d505..a514d7929 100644
--- a/web/netdata-swagger.json
+++ b/web/netdata-swagger.json
@@ -3,7 +3,7 @@
"info": {
"title": "NetData API",
"description": "Real time data collection and graphs...",
- "version": "1.0.0"
+ "version": "1.2.1_master"
},
"host": "netdata.firehol.org",
"schemes": [
@@ -226,6 +226,171 @@
}
}
}
+ },
+ "/badge.svg": {
+ "get": {
+ "summary": "Generate a SVG image for a chart (or dimension)",
+ "description": "Successful responses are SVG images\n",
+ "parameters": [
+ {
+ "name": "chart",
+ "in": "query",
+ "description": "The id of the chart as returned by the /charts call.",
+ "required": true,
+ "type": "string",
+ "format": "as returned by /charts",
+ "allowEmptyValue": false,
+ "default": "system.cpu"
+ },
+ {
+ "name": "dimension",
+ "in": "query",
+ "description": "zero, one or more dimension ids, as returned by the /chart call.",
+ "required": false,
+ "type": "array",
+ "items": {
+ "type": "string",
+ "collectionFormat": "pipes",
+ "format": "as returned by /charts"
+ },
+ "allowEmptyValue": false
+ },
+ {
+ "name": "after",
+ "in": "query",
+ "description": "This parameter can either be an absolute timestamp specifying the starting point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.",
+ "required": true,
+ "type": "number",
+ "format": "integer",
+ "allowEmptyValue": false,
+ "default": -600
+ },
+ {
+ "name": "before",
+ "in": "query",
+ "description": "This parameter can either be an absolute timestamp specifying the ending point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.",
+ "required": false,
+ "type": "number",
+ "format": "integer",
+ "default": 0
+ },
+ {
+ "name": "points",
+ "in": "query",
+ "description": "The number of points to be returned. If not given, or it is <= 0, or it is bigger than the points stored in the round robin database for this chart for the given duration, all the available collected values for the given duration are returned.",
+ "required": true,
+ "type": "number",
+ "format": "integer",
+ "allowEmptyValue": false,
+ "default": 20
+ },
+ {
+ "name": "group",
+ "in": "query",
+ "description": "The grouping method. If multiple collected values are to be grouped in order to return fewer points, this parameters defines the method of grouping. Two methods are supported, \"max\" and \"average\". \"max\" is actually calculated on the absolute value collected (so it works for both positive and negative dimesions to return the most extreme value in either direction).",
+ "required": true,
+ "type": "string",
+ "enum": [
+ "max",
+ "average"
+ ],
+ "default": "average",
+ "allowEmptyValue": false
+ },
+ {
+ "name": "options",
+ "in": "query",
+ "description": "Options that affect data generation.",
+ "required": false,
+ "type": "array",
+ "items": {
+ "type": "string",
+ "enum": [
+ "nonzero",
+ "flip",
+ "abs",
+ "absolute",
+ "absolute-sum",
+ "null2zero",
+ "percentage"
+ ],
+ "collectionFormat": "pipes"
+ },
+ "default": [
+ "absolute"
+ ],
+ "allowEmptyValue": true
+ },
+ {
+ "name": "label",
+ "in": "query",
+ "description": "a text to be used as the label",
+ "required": false,
+ "type": "string",
+ "format": "any text",
+ "allowEmptyValue": true
+ },
+ {
+ "name": "units",
+ "in": "query",
+ "description": "a text to be used as the units",
+ "required": false,
+ "type": "string",
+ "format": "any text",
+ "allowEmptyValue": true
+ },
+ {
+ "name": "label_color",
+ "in": "query",
+ "description": "a color to be used for the background of the label",
+ "required": false,
+ "type": "string",
+ "format": "any text",
+ "allowEmptyValue": true
+ },
+ {
+ "name": "value_color",
+ "in": "query",
+ "description": "a color to be used for the background of the label. You can set multiple using a pipe with a condition each, like this: color<value|color>value|color:null The following operators are supported: >, <, >=, <=, =, :null (to check if no value exists).",
+ "required": false,
+ "type": "string",
+ "format": "any text",
+ "allowEmptyValue": true
+ },
+ {
+ "name": "multiply",
+ "in": "query",
+ "description": "multiply the value with this number for rendering it at the image (integer value required)",
+ "required": false,
+ "type": "number",
+ "format": "integer",
+ "allowEmptyValue": true
+ },
+ {
+ "name": "divide",
+ "in": "query",
+ "description": "divide the value with this number for rendering it at the image (integer value required)",
+ "required": false,
+ "type": "number",
+ "format": "integer",
+ "allowEmptyValue": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "The call was successful. The response should be an SVG image."
+ },
+ "400": {
+ "description": "Bad request - the body will include a message stating what is wrong."
+ },
+ "404": {
+ "description": "No chart with the given id is found."
+ },
+ "500": {
+ "description": "Internal server error. This usually means the server is out of memory."
+ }
+ }
+ }
}
},
"definitions": {
@@ -316,8 +481,8 @@
"description": "The update frequency of this chart, in seconds. One value every this amount of time is kept in the round robin database."
},
"dimensions": {
- "description": "An object containing all the chart dimensions available for the chart. This is used as an indexed array. The key of the object the id of the dimension.",
"type": "object",
+ "description": "An object containing all the chart dimensions available for the chart. This is used as an indexed array. The key of the object the id of the dimension.",
"properties": {
"key": {
"$ref": "#/definitions/dimension"
diff --git a/web/netdata-swagger.yaml b/web/netdata-swagger.yaml
index 7dfef0aa8..c1049b12d 100644
--- a/web/netdata-swagger.yaml
+++ b/web/netdata-swagger.yaml
@@ -2,7 +2,7 @@ swagger: '2.0'
info:
title: NetData API
description: 'Real time data collection and graphs...'
- version: 1.0.0
+ version: 1.2.1_master
host: netdata.firehol.org
schemes:
- http
@@ -66,7 +66,7 @@ paths:
allowEmptyValue: false
- name: after
in: query
- description: 'This parameter can either be an absolute timestamp specifying the starting point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.'
+ description: 'This parameter can either be an absolute timestamp specifying the starting point of the data to be returned, or a relative number of seconds (relative to parameter: before). Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.'
required: true
type: number
format: integer
@@ -89,10 +89,10 @@ paths:
default: 20
- name: group
in: query
- description: 'The grouping method. If multiple collected values are to be grouped in order to return fewer points, this parameters defines the method of grouping. Two methods are supported, "max" and "average". "max" is actually calculated on the absolute value collected (so it works for both positive and negative dimesions to return the most extreme value in either direction).'
+ description: 'The grouping method. If multiple collected values are to be grouped in order to return fewer points, this parameters defines the method of grouping. methods supported "min", "max", "average", "sum", "incremental-sum". "max" is actually calculated on the absolute value collected (so it works for both positive and negative dimesions to return the most extreme value in either direction).'
required: true
type: string
- enum: [ 'max', 'average' ]
+ enum: [ 'min', 'max', 'average', 'sum', 'incremental-sum' ]
default: 'average'
allowEmptyValue: false
- name: format
@@ -110,7 +110,7 @@ paths:
type: array
items:
type: string
- enum: [ 'nonzero', 'flip', 'jsonwrap', 'min2max', 'seconds', 'milliseconds', 'abs', 'absolute', 'absolute-sum', 'null2zero', 'objectrows', 'google_json', 'percentage' ]
+ enum: [ 'nonzero', 'flip', 'jsonwrap', 'min2max', 'seconds', 'milliseconds', 'abs', 'absolute', 'absolute-sum', 'null2zero', 'objectrows', 'google_json', 'percentage', 'unaligned' ]
collectionFormat: pipes
default: [seconds, jsonwrap]
allowEmptyValue: false
@@ -143,6 +143,122 @@ paths:
description: 'No chart with the given id is found.'
'500':
description: 'Internal server error. This usually means the server is out of memory.'
+ /badge.svg:
+ get:
+ summary: 'Generate a SVG image for a chart (or dimension)'
+ description: |
+ Successful responses are SVG images
+ parameters:
+ - name: chart
+ in: query
+ description: 'The id of the chart as returned by the /charts call.'
+ required: true
+ type: string
+ format: 'as returned by /charts'
+ allowEmptyValue: false
+ default: system.cpu
+ - name: alarm
+ in: query
+ description: 'the name of an alarm linked to the chart'
+ required: false
+ type: string
+ format: 'any text'
+ allowEmptyValue: true
+ - name: dimension
+ in: query
+ description: 'zero, one or more dimension ids, as returned by the /chart call.'
+ required: false
+ type: array
+ items:
+ type: string
+ collectionFormat: pipes
+ format: 'as returned by /charts'
+ allowEmptyValue: false
+ - name: after
+ in: query
+ description: 'This parameter can either be an absolute timestamp specifying the starting point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.'
+ required: true
+ type: number
+ format: integer
+ allowEmptyValue: false
+ default: -600
+ - name: before
+ in: query
+ description: 'This parameter can either be an absolute timestamp specifying the ending point of the data to be returned, or a relative number of seconds, to the last collected timestamp. Netdata will assume it is a relative number if it is smaller than the duration of the round robin database for this chart. So, if the round robin database is 3600 seconds, any value from -3600 to 3600 will trigger relative arithmetics. Netdata will adapt this parameter to the boundaries of the round robin database.'
+ required: false
+ type: number
+ format: integer
+ default: 0
+ - name: group
+ in: query
+ description: 'The grouping method. If multiple collected values are to be grouped in order to return fewer points, this parameters defines the method of grouping. methods are supported "min", "max", "average", "sum", "incremental-sum". "max" is actually calculated on the absolute value collected (so it works for both positive and negative dimesions to return the most extreme value in either direction).'
+ required: true
+ type: string
+ enum: [ 'min', 'max', 'average', 'sum', 'incremental-sum' ]
+ default: 'average'
+ allowEmptyValue: false
+ - name: options
+ in: query
+ description: 'Options that affect data generation.'
+ required: false
+ type: array
+ items:
+ type: string
+ enum: [ 'abs', 'absolute', 'absolute-sum', 'null2zero', 'percentage', 'unaligned' ]
+ collectionFormat: pipes
+ default: ['absolute']
+ allowEmptyValue: true
+ - name: label
+ in: query
+ description: 'a text to be used as the label'
+ required: false
+ type: string
+ format: 'any text'
+ allowEmptyValue: true
+ - name: units
+ in: query
+ description: 'a text to be used as the units'
+ required: false
+ type: string
+ format: 'any text'
+ allowEmptyValue: true
+ - name: label_color
+ in: query
+ description: 'a color to be used for the background of the label'
+ required: false
+ type: string
+ format: 'any text'
+ allowEmptyValue: true
+ - name: value_color
+ in: query
+ description: 'a color to be used for the background of the label. You can set multiple using a pipe with a condition each, like this: color<value|color>value|color:null The following operators are supported: >, <, >=, <=, =, :null (to check if no value exists).'
+ required: false
+ type: string
+ format: 'any text'
+ allowEmptyValue: true
+ - name: multiply
+ in: query
+ description: 'multiply the value with this number for rendering it at the image (integer value required)'
+ required: false
+ type: number
+ format: integer
+ allowEmptyValue: true
+ - name: divide
+ in: query
+ description: 'divide the value with this number for rendering it at the image (integer value required)'
+ required: false
+ type: number
+ format: integer
+ allowEmptyValue: true
+ responses:
+ '200':
+ description: 'The call was successful. The response should be an SVG image.'
+ '400':
+ description: 'Bad request - the body will include a message stating what is wrong.'
+ '404':
+ description: 'No chart with the given id is found.'
+ '500':
+ description: 'Internal server error. This usually means the server is out of memory.'
definitions:
chart_summary:
type: object
diff --git a/web/registry.html b/web/registry.html
new file mode 100644
index 000000000..74c676228
--- /dev/null
+++ b/web/registry.html
@@ -0,0 +1,203 @@
+<!DOCTYPE html>
+<html lang="en">
+<head>
+ <title>NetData Registry Dashboard</title>
+ <meta name="application-name" content="netdata">
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image" content="https://my-netdata.io/images/seo-performance-512.png"/>
+ <meta property="og:url" content="http://my-netdata.io/"/>
+ <meta property="og:type" content="website"/>
+ <meta property="og:site_name" content="netdata"/>
+ <meta property="og:title" content="netdata - real-time performance monitoring, done right!"/>
+ <meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
+
+ <script>
+ // this section has to appear before loading dashboard.js
+
+ // Select a theme.
+ // uncomment on of the two themes:
+
+ // var netdataTheme = 'default'; // this is white
+ var netdataTheme = 'slate'; // this is dark
+
+
+ // Set the default netdata server.
+ // on charts without a 'data-host', this one will be used.
+ // the default is the server that dashboard.js is downloaded from.
+
+ // var netdataServer = 'http://my.server:19999/';
+
+ function registryGotoServer(guid) {
+ console.log('goto server: ' + guid);
+ }
+
+ function registryAddServer(u) {
+ return '<div id="registry_server_' + u.guid + '" class="registry-server-container" onClick="registryGotoServer(\'' + u.guid + '\'); return false;">'
+ + '<div class="registry-server-name">' + u.name + '</div>'
+ + '<div data-netdata="system.cpu"'
+ + ' data-host="' + u.url + '"'
+ + ' data-chart-library="sparkline"'
+ + ' data-sparkline-chartrangemin="0"'
+ + ' data-sparkline-chartrangemax="100"'
+ + ' data-sparkline-chartrangeclip="true"'
+ + ' data-sparkline-disabletooltips="true"'
+ + ' data-sparkline-disableinteraction="true"'
+ + ' data-sparkline-disablehighlight="true"'
+ + ' data-sparkline-linecolor="#444"'
+ + ' data-sparkline-spotcolor="disable"'
+ + ' data-sparkline-minspotcolor="disable"'
+ + ' data-sparkline-maxspotcolor="disable"'
+ + ' data-width="100%"'
+ + ' data-height="20px"'
+ + ' data-after="-200"'
+ + '></div>'
+ + '</div>';
+ }
+
+ var netdataRegistryCallback = function(machines_array) {
+ var el = '';
+ var a1 = '';
+ var found = 0;
+
+ if(machines_array) {
+ function name_comparator_desc(a, b) {
+ if (a.name > b.name) return -1;
+ if (a.name < b.name) return 1;
+ return 0;
+ }
+
+ var machines = machines_array.sort(name_comparator_desc);
+ var len = machines.length;
+ while(len--) {
+ var u = machines[len];
+
+ var status = "enabled";
+ found++;
+
+ if(u.guid === NETDATA.registry.machine_guid)
+ status = "disabled"
+
+ el += registryAddServer(u);
+ a1 += '<li id="registry_action_' + u.guid + '"><a href="#" onclick="deleteRegistryModalHandler(\'' + u.guid + '\',\'' + u.name + '\',\'' + u.url + '\'); return false;"><i class="fa fa-trash-o" aria-hidden="true" style="color: #999;"></i></a></li>';
+ }
+ }
+
+ if(!found) {
+ if(machines)
+ el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #666;" target="_blank">your netdata server list is empty...</a></li>';
+ else
+ el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #666;" target="_blank">failed to contact the registry...</a></li>';
+
+ a1 += '<li><a href="#">&nbsp;</a></li>';
+
+ el += '<li role="separator" class="divider"></li>' +
+ '<li><a href="//london.netdata.rocks/default.html">EU - London (DigitalOcean.com)</a></li>' +
+ '<li><a href="//atlanta.netdata.rocks/default.html">US - Atlanta (CDN77.com)</a></li>' +
+ '<li><a href="//athens.netdata.rocks/default.html">EU - Athens</a></li>';
+ a1 += '<li role="separator" class="divider"></li>' +
+ '<li><a href="#">&nbsp;</a></li>' +
+ '<li><a href="#">&nbsp;</a></li>'+
+ '<li><a href="#">&nbsp;</a></li>';
+ }
+
+ el += '<li role="separator" class="divider"></li>';
+ a1 += '<li role="separator" class="divider"></li>';
+
+ el += '<li><a href="https://github.com/firehol/netdata/wiki/mynetdata-menu-item" style="color: #999;" target="_blank">What is this?</a></li>';
+ a1 += '<li><a href="#" style="color: #999;" onclick="switchRegistryModalHandler(); return false;"><i class="fa fa-cog" aria-hidden="true" style="color: #999;"></i></a></li>'
+
+ document.getElementById('mynetdata_servers').innerHTML = el;
+ //document.getElementById('mynetdata_servers2').innerHTML = el;
+ //document.getElementById('mynetdata_actions1').innerHTML = a1;
+ NETDATA.updatedDom();
+ };
+ </script>
+
+ <!--
+ Load dashboard.js
+
+ to host this HTML file on your web server,
+ you have to load dashboard.js from the netdata server.
+
+ So, pick one the two below
+ If you pick the first, set the server name/IP.
+
+ The second assumes you host this file on /usr/share/netdata/web
+ and that you have chown it to be owned by netdata:netdata
+ -->
+ <!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
+ <script type="text/javascript" src="dashboard.js?v42"></script>
+
+ <script>
+ // Set options for TV operation
+ // This has to be done, after dashboard.js is loaded
+
+ // destroy charts not shown (lowers memory on the browser)
+ NETDATA.options.current.destroy_on_hide = true;
+
+ // set this to false, to always show all dimensions
+ NETDATA.options.current.eliminate_zero_dimensions = true;
+
+ // lower the pressure on this browser
+ NETDATA.options.current.concurrent_refreshes = true;
+
+ // if the tv browser is too slow (a pi?)
+ // set this to false
+ NETDATA.options.current.parallel_refresher = true;
+
+ // always update the charts, even if focus is lost
+ // NETDATA.options.current.stop_updates_when_focus_is_lost = false;
+ </script>
+
+ <style>
+ .registry-container {
+ margin-left: 50px;
+ max-width: 400px;
+ min-width: 200px;
+ border: 1px solid #555;
+ max-height: 80vh;
+ height: auto;
+ overflow-x: hidden;
+ /* background-color: #3a3f44; */
+ text-align: center;
+ }
+ .registry-server-container {
+ width: 100%;
+ height: auto;
+ overflow-x: hidden;
+ font-size: 10px;
+ padding-left: 10px;
+ padding-right: 10px;
+ }
+ .registry-server-container:hover {
+ color: #f5f5f5;
+ background-color: #262626;
+ }
+ .registry-server-name {
+ display: block;
+ text-decoration: none !important;
+ clear: both;
+ font-size: 16px;
+ font-weight: bold;
+ white-space: normal;
+ padding-top: 10px;
+ }
+ </style>
+</head>
+<body>
+&nbsp;
+<div id="mynetdata_servers" class="registry-container" onscroll="NETDATA.onscroll();">
+
+ Loading....
+
+</div> <!-- registry-container -->
+</body>
+</html>
diff --git a/web/tv.html b/web/tv.html
index 58f08eb39..53c47a453 100644
--- a/web/tv.html
+++ b/web/tv.html
@@ -1,244 +1,253 @@
<!DOCTYPE html>
<html lang="en">
<head>
- <title>NetData TV Dashboard</title>
-
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <meta charset="utf-8">
- <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
- <meta name="viewport" content="width=device-width, initial-scale=1">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
-
- <script>
- // this section has to appear before loading dashboard.js
-
- // Select a theme.
- // uncomment on of the two themes:
-
- // var netdataTheme = 'default'; // this is white
- var netdataTheme = 'slate'; // this is dark
-
-
- // Set the default netdata server.
- // on charts without a 'data-host', this one will be used.
- // the default is the server that dashboard.js is downloaded from.
-
- // var netdataServer = 'http://my.server:19999/';
- </script>
-
- <!--
- Load dashboard.js
-
- to host this HTML file on your web server,
- you have to load dashboard.js from the netdata server.
-
- So, pick one the two below
- If you pick the first, set the server name/IP.
-
- The second assumes you host this file on /usr/share/netdata/web
- and that you have chown it to be owned by netdata:netdata
- -->
- <!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
- <script type="text/javascript" src="dashboard.js?v37"></script>
-
- <script>
- // Set options for TV operation
- // This has to be done, after dashboard.js is loaded
-
- // destroy charts not shown (lowers memory on the browser)
- NETDATA.options.current.destroy_on_hide = true;
-
- // set this to false, to always show all dimensions
- NETDATA.options.current.eliminate_zero_dimensions = true;
-
- // lower the pressure on this browser
- NETDATA.options.current.concurrent_refreshes = false;
-
- // if the tv browser is too slow (a pi?)
- // set this to false
- NETDATA.options.current.parallel_refresher = true;
-
- // always update the charts, even if focus is lost
- // NETDATA.options.current.stop_updates_when_focus_is_lost = false;
-
- // Since you may render charts from many servers and any of them may
- // become offline for some time, the charts will break.
- // This will reload the page every RELOAD_EVERY minutes
-
- var RELOAD_EVERY = 5;
- setTimeout(function(){
- location.reload();
- }, RELOAD_EVERY * 60 * 1000);
-
- </script>
+ <title>NetData TV Dashboard</title>
+ <meta name="application-name" content="netdata">
+
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
+ <meta charset="utf-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="apple-mobile-web-app-capable" content="yes">
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent">
+
+ <meta property="og:locale" content="en_US" />
+ <meta property="og:image" content="https://my-netdata.io/images/seo-performance-512.png"/>
+ <meta property="og:url" content="http://my-netdata.io/"/>
+ <meta property="og:type" content="website"/>
+ <meta property="og:site_name" content="netdata"/>
+ <meta property="og:title" content="netdata - real-time performance monitoring, done right!"/>
+ <meta property="og:description" content="Stunning real-time dashboards, blazingly fast and extremely interactive. Zero configuration, zero dependencies, zero maintenance." />
+
+ <script>
+ // this section has to appear before loading dashboard.js
+
+ // Select a theme.
+ // uncomment on of the two themes:
+
+ // var netdataTheme = 'default'; // this is white
+ var netdataTheme = 'slate'; // this is dark
+
+
+ // Set the default netdata server.
+ // on charts without a 'data-host', this one will be used.
+ // the default is the server that dashboard.js is downloaded from.
+
+ // var netdataServer = 'http://my.server:19999/';
+ </script>
+
+ <!--
+ Load dashboard.js
+
+ to host this HTML file on your web server,
+ you have to load dashboard.js from the netdata server.
+
+ So, pick one the two below
+ If you pick the first, set the server name/IP.
+
+ The second assumes you host this file on /usr/share/netdata/web
+ and that you have chown it to be owned by netdata:netdata
+ -->
+ <!-- <script type="text/javascript" src="http://my.server:19999/dashboard.js"></script> -->
+ <script type="text/javascript" src="dashboard.js?v42"></script>
+
+ <script>
+ // Set options for TV operation
+ // This has to be done, after dashboard.js is loaded
+
+ // destroy charts not shown (lowers memory on the browser)
+ NETDATA.options.current.destroy_on_hide = true;
+
+ // set this to false, to always show all dimensions
+ NETDATA.options.current.eliminate_zero_dimensions = true;
+
+ // lower the pressure on this browser
+ NETDATA.options.current.concurrent_refreshes = false;
+
+ // if the tv browser is too slow (a pi?)
+ // set this to false
+ NETDATA.options.current.parallel_refresher = true;
+
+ // always update the charts, even if focus is lost
+ // NETDATA.options.current.stop_updates_when_focus_is_lost = false;
+
+ // Since you may render charts from many servers and any of them may
+ // become offline for some time, the charts will break.
+ // This will reload the page every RELOAD_EVERY minutes
+
+ var RELOAD_EVERY = 5;
+ setTimeout(function(){
+ location.reload();
+ }, RELOAD_EVERY * 60 * 1000);
+
+ </script>
</head>
<body>
<div style="width: 100%; text-align: center; display: inline-block;">
- <div style="width: 100%; height: 24vh; text-align: center; display: inline-block;">
- <div style="width: 100%; height: 15px; text-align: center; display: inline-block;">
- <b>CPU On both servers</b>
- </div>
- <div style="width: 100%; height: calc(100% - 15px); text-align: center; display: inline-block;">
- <br/>
- <div data-netdata="system.cpu"
- data-host="http://netdata.firehol.org"
- data-title="CPU usage of netdata.firehol.org"
- data-chart-library="dygraph"
- data-width="49%"
- data-height="100%"
- data-after="-300"
- ></div>
- <div data-netdata="system.cpu"
- data-title="CPU usage of your netdata server"
- data-chart-library="dygraph"
- data-width="49%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
- </div>
-
-
- <div style="width: 100%; height: 24vh; text-align: center; display: inline-block;">
- <div style="width: 100%; height: 15px; text-align: center; display: inline-block;">
- <b>Disk I/O on both servers</b>
- </div>
- <div style="width: 100%; height: calc(100% - 15px); text-align: center; display: inline-block;">
- <div data-netdata="system.io"
- data-host="http://netdata.firehol.org"
- data-title="I/O on netdata.firehol.org"
- data-chart-library="dygraph"
- data-width="49%"
- data-height="100%"
- data-after="-300"
- ></div>
- <div data-netdata="system.io"
- data-title="I/O on your netdata server"
- data-chart-library="dygraph"
- data-width="49%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
- </div>
-
-
- <div style="width: 100%; height: 24vh; text-align: center; display: inline-block;">
- <div style="width: 100%; height: 15px; text-align: center; display: inline-block;">
- <b>IPv4 traffic on both servers</b>
- </div>
- <div style="width: 100%; height: calc(100% - 15px); text-align: center; display: inline-block;">
- <div data-netdata="system.ipv4"
- data-host="http://netdata.firehol.org"
- data-title="IPv4 traffic on netdata.firehol.org"
- data-chart-library="dygraph"
- data-width="49%"
- data-height="100%"
- data-after="-300"
- ></div>
- <div data-netdata="system.ipv4"
- data-title="IPv4 traffic on your netdata server"
- data-chart-library="dygraph"
- data-width="49%"
- data-height="100%"
- data-after="-300"
- ></div>
- </div>
- </div>
-
- <div style="width: 100%; height: 23vh; text-align: center; display: inline-block;">
- <div style="width: 100%; height: 15px; text-align: center; display: inline-block;">
- <b>Netdata statistics on both servers</b>
- </div>
- <div style="width: 100%; max-height: calc(100% - 15px); text-align: center; display: inline-block;">
- <div style="width: 49%; height:100%; align: center; display: inline-block;">
- netdata.firehol.org
- <br/>
- <div data-netdata="netdata.requests"
- data-host="http://netdata.firehol.org"
- data-title="Chart Refreshes/s"
- data-chart-library="gauge"
- data-width="20%"
- data-height="100%"
- data-after="-300"
- data-points="300"
- ></div>
- <div data-netdata="netdata.clients"
- data-host="http://netdata.firehol.org"
- data-title="Sockets"
- data-chart-library="gauge"
- data-width="20%"
- data-height="100%"
- data-after="-300"
- data-points="300"
- data-colors="#AA5500"
- ></div>
- <div data-netdata="netdata.net"
- data-dimensions="in"
- data-host="http://netdata.firehol.org"
- data-title="Requests Traffic"
- data-chart-library="easypiechart"
- data-width="15%"
- data-height="100%"
- data-after="-300"
- data-points="300"
- ></div>
- <div data-netdata="netdata.net"
- data-dimensions="out"
- data-host="http://netdata.firehol.org"
- data-title="Chart Data Traffic"
- data-chart-library="easypiechart"
- data-width="15%"
- data-height="100%"
- data-after="-300"
- data-points="300"
- ></div>
- </div>
- <div style="width: 49%; height:100%; align: center; display: inline-block;">
- your netdata server
- <br/>
- <div data-netdata="netdata.requests"
- data-title="Chart Refreshes/s"
- data-chart-library="gauge"
- data-width="20%"
- data-height="100%"
- data-after="-300"
- data-points="300"
- ></div>
- <div data-netdata="netdata.clients"
- data-title="Sockets"
- data-chart-library="gauge"
- data-width="20%"
- data-height="100%"
- data-after="-300"
- data-points="300"
- data-colors="#AA5500"
- ></div>
- <div data-netdata="netdata.net"
- data-dimensions="in"
- data-title="Requests Traffic"
- data-chart-library="easypiechart"
- data-width="15%"
- data-height="100%"
- data-after="-300"
- data-points="300"
- ></div>
- <div data-netdata="netdata.net"
- data-dimensions="out"
- data-title="Chart Data Traffic"
- data-chart-library="easypiechart"
- data-width="15%"
- data-height="100%"
- data-after="-300"
- data-points="300"
- ></div>
- </div>
- </div>
- </div>
+ <div style="width: 100%; height: 24vh; text-align: center; display: inline-block;">
+ <div style="width: 100%; height: 15px; text-align: center; display: inline-block;">
+ <b>CPU On both servers</b>
+ </div>
+ <div style="width: 100%; height: calc(100% - 15px); text-align: center; display: inline-block;">
+ <br/>
+ <div data-netdata="system.cpu"
+ data-host="http://netdata.firehol.org"
+ data-title="CPU usage of netdata.firehol.org"
+ data-chart-library="dygraph"
+ data-width="49%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ <div data-netdata="system.cpu"
+ data-title="CPU usage of your netdata server"
+ data-chart-library="dygraph"
+ data-width="49%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ </div>
+ </div>
+
+
+ <div style="width: 100%; height: 24vh; text-align: center; display: inline-block;">
+ <div style="width: 100%; height: 15px; text-align: center; display: inline-block;">
+ <b>Disk I/O on both servers</b>
+ </div>
+ <div style="width: 100%; height: calc(100% - 15px); text-align: center; display: inline-block;">
+ <div data-netdata="system.io"
+ data-host="http://netdata.firehol.org"
+ data-title="I/O on netdata.firehol.org"
+ data-chart-library="dygraph"
+ data-width="49%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ <div data-netdata="system.io"
+ data-title="I/O on your netdata server"
+ data-chart-library="dygraph"
+ data-width="49%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ </div>
+ </div>
+
+
+ <div style="width: 100%; height: 24vh; text-align: center; display: inline-block;">
+ <div style="width: 100%; height: 15px; text-align: center; display: inline-block;">
+ <b>IPv4 traffic on both servers</b>
+ </div>
+ <div style="width: 100%; height: calc(100% - 15px); text-align: center; display: inline-block;">
+ <div data-netdata="system.ipv4"
+ data-host="http://netdata.firehol.org"
+ data-title="IPv4 traffic on netdata.firehol.org"
+ data-chart-library="dygraph"
+ data-width="49%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ <div data-netdata="system.ipv4"
+ data-title="IPv4 traffic on your netdata server"
+ data-chart-library="dygraph"
+ data-width="49%"
+ data-height="100%"
+ data-after="-300"
+ ></div>
+ </div>
+ </div>
+
+ <div style="width: 100%; height: 23vh; text-align: center; display: inline-block;">
+ <div style="width: 100%; height: 15px; text-align: center; display: inline-block;">
+ <b>Netdata statistics on both servers</b>
+ </div>
+ <div style="width: 100%; max-height: calc(100% - 15px); text-align: center; display: inline-block;">
+ <div style="width: 49%; height:100%; align: center; display: inline-block;">
+ netdata.firehol.org
+ <br/>
+ <div data-netdata="netdata.requests"
+ data-host="http://netdata.firehol.org"
+ data-title="Chart Refreshes/s"
+ data-chart-library="gauge"
+ data-width="20%"
+ data-height="100%"
+ data-after="-300"
+ data-points="300"
+ ></div>
+ <div data-netdata="netdata.clients"
+ data-host="http://netdata.firehol.org"
+ data-title="Sockets"
+ data-chart-library="gauge"
+ data-width="20%"
+ data-height="100%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#AA5500"
+ ></div>
+ <div data-netdata="netdata.net"
+ data-dimensions="in"
+ data-host="http://netdata.firehol.org"
+ data-title="Requests Traffic"
+ data-chart-library="easypiechart"
+ data-width="15%"
+ data-height="100%"
+ data-after="-300"
+ data-points="300"
+ ></div>
+ <div data-netdata="netdata.net"
+ data-dimensions="out"
+ data-host="http://netdata.firehol.org"
+ data-title="Chart Data Traffic"
+ data-chart-library="easypiechart"
+ data-width="15%"
+ data-height="100%"
+ data-after="-300"
+ data-points="300"
+ ></div>
+ </div>
+ <div style="width: 49%; height:100%; align: center; display: inline-block;">
+ your netdata server
+ <br/>
+ <div data-netdata="netdata.requests"
+ data-title="Chart Refreshes/s"
+ data-chart-library="gauge"
+ data-width="20%"
+ data-height="100%"
+ data-after="-300"
+ data-points="300"
+ ></div>
+ <div data-netdata="netdata.clients"
+ data-title="Sockets"
+ data-chart-library="gauge"
+ data-width="20%"
+ data-height="100%"
+ data-after="-300"
+ data-points="300"
+ data-colors="#AA5500"
+ ></div>
+ <div data-netdata="netdata.net"
+ data-dimensions="in"
+ data-title="Requests Traffic"
+ data-chart-library="easypiechart"
+ data-width="15%"
+ data-height="100%"
+ data-after="-300"
+ data-points="300"
+ ></div>
+ <div data-netdata="netdata.net"
+ data-dimensions="out"
+ data-title="Chart Data Traffic"
+ data-chart-library="easypiechart"
+ data-width="15%"
+ data-height="100%"
+ data-after="-300"
+ data-points="300"
+ ></div>
+ </div>
+ </div>
+ </div>
</div>
</body>
</html>
diff --git a/web/version.txt b/web/version.txt
index afce0e539..b44550c7a 100644
--- a/web/version.txt
+++ b/web/version.txt
@@ -1 +1 @@
-bb4aa949f5ac825253d8adc6070661299abc1c3b
+b4591e87bd5bf5164eb55c90474bbb9f38f2dad4