From be1c7e50e1e8809ea56f2c9d472eccd8ffd73a97 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 04:57:58 +0200 Subject: Adding upstream version 1.44.3. Signed-off-by: Daniel Baumann --- web/gui/.dashboard-notice.md | 7 + web/gui/.dashboard-v2-notice.md | 8 + web/gui/.well-known/dnt/cookies | 14 + web/gui/Makefile.am | 111 + web/gui/README.md | 165 + web/gui/browserconfig.xml | 2 + web/gui/bundle_dashboard_v1.py | 131 + web/gui/bundle_dashboard_v2.py | 138 + web/gui/confluence/README.md | 1023 ++ web/gui/css/c3-0.4.18.min.css | 2 + web/gui/css/morris-0.5.1.css | 3 + web/gui/custom/README.md | 594 ++ web/gui/dashboard_info.js | 8264 +++++++++++++++ web/gui/dashboard_info_custom_example.js | 62 + web/gui/ilove.html | 302 + web/gui/index.html | 224 + web/gui/main.css | 764 ++ web/gui/main.js | 5161 +++++++++ web/gui/old/index.html | 1321 +++ web/gui/registry-access.html | 73 + web/gui/registry-alert-redirect.html | 150 + web/gui/registry-hello.html | 94 + web/gui/src/dashboard.js/alarms.js | 422 + web/gui/src/dashboard.js/boot.js | 142 + web/gui/src/dashboard.js/chart-registry.js | 94 + web/gui/src/dashboard.js/charting.js | 492 + web/gui/src/dashboard.js/charting/_c3.js | 114 + web/gui/src/dashboard.js/charting/_morris.js | 81 + web/gui/src/dashboard.js/charting/_raphael.js | 48 + web/gui/src/dashboard.js/charting/d3.js | 43 + web/gui/src/dashboard.js/charting/d3pie.js | 341 + web/gui/src/dashboard.js/charting/dygraph.js | 1065 ++ .../src/dashboard.js/charting/easy-pie-chart.js | 281 + web/gui/src/dashboard.js/charting/gauge.js | 406 + web/gui/src/dashboard.js/charting/google-charts.js | 132 + web/gui/src/dashboard.js/charting/peity.js | 62 + web/gui/src/dashboard.js/charting/sparkline.js | 155 + web/gui/src/dashboard.js/charting/textonly.js | 18 + web/gui/src/dashboard.js/colors.js | 34 + web/gui/src/dashboard.js/common.js | 249 + web/gui/src/dashboard.js/compatibility.js | 31 + web/gui/src/dashboard.js/dependencies.js | 21 + web/gui/src/dashboard.js/epilogue.js.inc | 1 + web/gui/src/dashboard.js/error-handling.js | 52 + web/gui/src/dashboard.js/localstorage.js | 173 + web/gui/src/dashboard.js/main.js | 4279 ++++++++ web/gui/src/dashboard.js/options.js | 225 + web/gui/src/dashboard.js/prologue.js.inc | 84 + web/gui/src/dashboard.js/registry.js | 311 + web/gui/src/dashboard.js/server-detection.js | 29 + web/gui/src/dashboard.js/themes.js | 92 + web/gui/src/dashboard.js/timeout.js | 100 + web/gui/src/dashboard.js/units-conversion.js | 528 + web/gui/src/dashboard.js/utils.js | 432 + web/gui/src/dashboard.js/xss.js | 84 + web/gui/static/img/netdata-logomark.svg | 3 + web/gui/static/splash.css | 171 + web/gui/switch.html | 12 + web/gui/v0 | 1 + web/gui/v1/Makefile.am | 212 + web/gui/v1/README.md | 1 + web/gui/v1/asset-manifest.json | 47 + web/gui/v1/console.html | 72 + web/gui/v1/css/bootstrap-3.3.7.css | 6760 ++++++++++++ web/gui/v1/css/bootstrap-slate-flat-3.3.7.css | 7101 +++++++++++++ web/gui/v1/css/bootstrap-slider-10.0.0.min.css | 22 + web/gui/v1/css/bootstrap-theme-3.3.7.min.css | 7 + web/gui/v1/css/bootstrap-toggle-2.2.2.min.css | 29 + web/gui/v1/css/dashboard.css | 785 ++ web/gui/v1/css/dashboard.slate.css | 803 ++ web/gui/v1/dash-example.html | 1020 ++ web/gui/v1/dashboard-react.js | 675 ++ web/gui/v1/dashboard.css | 785 ++ web/gui/v1/dashboard.html | 699 ++ web/gui/v1/dashboard.js | 10333 +++++++++++++++++++ web/gui/v1/dashboard.slate.css | 803 ++ web/gui/v1/demo.html | 51 + web/gui/v1/demo2.html | 143 + web/gui/v1/demosites.html | 1469 +++ web/gui/v1/demosites2.html | 1112 ++ web/gui/v1/favicon.ico | Bin 0 -> 1150 bytes web/gui/v1/fonts/glyphicons-halflings-regular.eot | Bin 0 -> 20127 bytes web/gui/v1/fonts/glyphicons-halflings-regular.svg | 289 + web/gui/v1/fonts/glyphicons-halflings-regular.ttf | Bin 0 -> 45404 bytes web/gui/v1/fonts/glyphicons-halflings-regular.woff | Bin 0 -> 23424 bytes .../v1/fonts/glyphicons-halflings-regular.woff2 | Bin 0 -> 18028 bytes web/gui/v1/goto-host-from-alarm.html | 250 + web/gui/v1/images/alert-128-orange.png | Bin 0 -> 3477 bytes web/gui/v1/images/alert-128-red.png | Bin 0 -> 3743 bytes web/gui/v1/images/alert-multi-size-orange.ico | Bin 0 -> 112374 bytes web/gui/v1/images/alert-multi-size-red.ico | Bin 0 -> 112458 bytes web/gui/v1/images/alerts.jpg | Bin 0 -> 388104 bytes web/gui/v1/images/alerts.png | Bin 0 -> 59943 bytes web/gui/v1/images/android-icon-144x144.png | Bin 0 -> 2721 bytes web/gui/v1/images/android-icon-192x192.png | Bin 0 -> 3923 bytes web/gui/v1/images/android-icon-36x36.png | Bin 0 -> 539 bytes web/gui/v1/images/android-icon-48x48.png | Bin 0 -> 762 bytes web/gui/v1/images/android-icon-72x72.png | Bin 0 -> 1153 bytes web/gui/v1/images/android-icon-96x96.png | Bin 0 -> 1747 bytes web/gui/v1/images/animated.gif | Bin 0 -> 389597 bytes web/gui/v1/images/apple-icon-114x114.png | Bin 0 -> 3651 bytes web/gui/v1/images/apple-icon-120x120.png | Bin 0 -> 2315 bytes web/gui/v1/images/apple-icon-144x144.png | Bin 0 -> 4001 bytes web/gui/v1/images/apple-icon-152x152.png | Bin 0 -> 5026 bytes web/gui/v1/images/apple-icon-180x180.png | Bin 0 -> 3645 bytes web/gui/v1/images/apple-icon-57x57.png | Bin 0 -> 1250 bytes web/gui/v1/images/apple-icon-60x60.png | Bin 0 -> 1052 bytes web/gui/v1/images/apple-icon-72x72.png | Bin 0 -> 1427 bytes web/gui/v1/images/apple-icon-76x76.png | Bin 0 -> 1711 bytes web/gui/v1/images/apple-icon-precomposed.png | Bin 0 -> 3926 bytes web/gui/v1/images/apple-icon.png | Bin 0 -> 3926 bytes web/gui/v1/images/banner-icon-144x144.png | Bin 0 -> 2724 bytes web/gui/v1/images/check-mark-2-128-green.png | Bin 0 -> 3771 bytes .../v1/images/check-mark-2-multi-size-green.ico | Bin 0 -> 111893 bytes web/gui/v1/images/dashboards.png | Bin 0 -> 175464 bytes web/gui/v1/images/favicon-128.png | Bin 0 -> 2436 bytes web/gui/v1/images/favicon-16x16.png | Bin 0 -> 285 bytes web/gui/v1/images/favicon-196x196.png | Bin 0 -> 10025 bytes web/gui/v1/images/favicon-32x32.png | Bin 0 -> 454 bytes web/gui/v1/images/favicon-96x96.png | Bin 0 -> 1925 bytes web/gui/v1/images/favicon.ico | Bin 0 -> 1150 bytes web/gui/v1/images/home.png | Bin 0 -> 98888 bytes web/gui/v1/images/ms-icon-144x144.png | Bin 0 -> 4001 bytes web/gui/v1/images/ms-icon-150x150.png | Bin 0 -> 2867 bytes web/gui/v1/images/ms-icon-310x150.png | Bin 0 -> 3632 bytes web/gui/v1/images/ms-icon-310x310.png | Bin 0 -> 7215 bytes web/gui/v1/images/ms-icon-36x36.png | Bin 0 -> 536 bytes web/gui/v1/images/ms-icon-70x70.png | Bin 0 -> 2436 bytes web/gui/v1/images/netdata-logomark.svg | 8 + web/gui/v1/images/netdata.svg | 18 + web/gui/v1/images/nodeView.png | Bin 0 -> 645133 bytes web/gui/v1/images/nodes.jpg | Bin 0 -> 452421 bytes web/gui/v1/images/overview.png | Bin 0 -> 101515 bytes web/gui/v1/images/packaging-beta-tag.svg | 42 + web/gui/v1/images/post.png | Bin 0 -> 9043 bytes web/gui/v1/images/pricing.png | Bin 0 -> 148860 bytes web/gui/v1/images/seo-performance-128.png | Bin 0 -> 1828 bytes web/gui/v1/index-node-view.html | 30 + web/gui/v1/index.html | 35 + web/gui/v1/infographic.html | 171 + web/gui/v1/lib/bootstrap-3.3.7.min.js | 8 + web/gui/v1/lib/bootstrap-slider-10.0.0.min.js | 6 + web/gui/v1/lib/bootstrap-table-1.11.0.min.js | 9 + .../v1/lib/bootstrap-table-export-1.11.0.min.js | 8 + web/gui/v1/lib/bootstrap-toggle-2.2.2.min.js | 10 + web/gui/v1/lib/clipboard-polyfill-be05dad.js | 9 + web/gui/v1/lib/d3-4.12.2.min.js | 3 + web/gui/v1/lib/d3pie-0.2.1-netdata-3.js | 2124 ++++ web/gui/v1/lib/dygraph-c91c859.min.js | 7 + web/gui/v1/lib/dygraph-smooth-plotter-c91c859.js | 141 + web/gui/v1/lib/fontawesome-all-5.0.1.min.js | 6 + web/gui/v1/lib/gauge-1.3.2.min.js | 2 + web/gui/v1/lib/jquery-3.6.0.min.js | 2 + web/gui/v1/lib/jquery.easypiechart-97b5824.min.js | 10 + web/gui/v1/lib/jquery.peity-3.2.0.min.js | 14 + web/gui/v1/lib/jquery.sparkline-2.1.2.min.js | 6 + web/gui/v1/lib/lz-string-1.4.4.min.js | 2 + web/gui/v1/lib/pako-1.0.6.min.js | 2 + web/gui/v1/lib/perfect-scrollbar-0.6.15.min.js | 3 + web/gui/v1/lib/tableExport-1.6.0.min.js | 55 + web/gui/v1/manifest.json | 41 + ...he-manifest.e2d3811ef5e4b7e75e1f56d6ee92ef2c.js | 190 + web/gui/v1/refresh-badges.js | 98 + web/gui/v1/robots.txt | 7 + web/gui/v1/service-worker.js | 39 + web/gui/v1/sitemap.xml | 9 + web/gui/v1/static/css/2.c454aab8.chunk.css | 15 + web/gui/v1/static/css/2.c454aab8.chunk.css.map | 1 + web/gui/v1/static/css/4.a36e3b73.chunk.css | 42 + web/gui/v1/static/css/4.a36e3b73.chunk.css.map | 1 + web/gui/v1/static/css/main.53ba10f1.chunk.css | 2 + web/gui/v1/static/css/main.53ba10f1.chunk.css.map | 1 + web/gui/v1/static/js/10.a5cd7d0e.chunk.js | 2 + web/gui/v1/static/js/10.a5cd7d0e.chunk.js.map | 1 + web/gui/v1/static/js/2.62d105c5.chunk.js | 3 + web/gui/v1/static/js/2.62d105c5.chunk.js.LICENSE | 278 + web/gui/v1/static/js/2.62d105c5.chunk.js.map | 1 + web/gui/v1/static/js/3.f137faca.chunk.js | 2 + web/gui/v1/static/js/3.f137faca.chunk.js.map | 1 + web/gui/v1/static/js/4.2dbcd906.chunk.js | 2 + web/gui/v1/static/js/4.2dbcd906.chunk.js.map | 1 + web/gui/v1/static/js/5.2f783a54.chunk.js | 3 + web/gui/v1/static/js/5.2f783a54.chunk.js.LICENSE | 3 + web/gui/v1/static/js/5.2f783a54.chunk.js.map | 1 + web/gui/v1/static/js/6.e1951239.chunk.js | 2 + web/gui/v1/static/js/6.e1951239.chunk.js.map | 1 + web/gui/v1/static/js/7.c2417fb0.chunk.js | 2 + web/gui/v1/static/js/7.c2417fb0.chunk.js.map | 1 + web/gui/v1/static/js/8.b4161ea2.chunk.js | 2 + web/gui/v1/static/js/8.b4161ea2.chunk.js.map | 1 + web/gui/v1/static/js/9.a4363968.chunk.js | 2 + web/gui/v1/static/js/9.a4363968.chunk.js.map | 1 + web/gui/v1/static/js/main.e248095a.chunk.js | 3 + .../v1/static/js/main.e248095a.chunk.js.LICENSE | 8 + web/gui/v1/static/js/main.e248095a.chunk.js.map | 1 + web/gui/v1/static/js/runtime-main.08abed8f.js | 2 + web/gui/v1/static/js/runtime-main.08abed8f.js.map | 1 + .../media/ibm-plex-sans-latin-100.245539db.woff2 | Bin 0 -> 18212 bytes .../media/ibm-plex-sans-latin-100.9a582f3a.woff | Bin 0 -> 23296 bytes .../ibm-plex-sans-latin-100italic.1ea7c5d2.woff | Bin 0 -> 25732 bytes .../ibm-plex-sans-latin-100italic.3c34cf08.woff2 | Bin 0 -> 20052 bytes .../media/ibm-plex-sans-latin-200.67524c36.woff | Bin 0 -> 24468 bytes .../media/ibm-plex-sans-latin-200.bf72c841.woff2 | Bin 0 -> 19240 bytes .../ibm-plex-sans-latin-200italic.52df2560.woff | Bin 0 -> 26196 bytes .../ibm-plex-sans-latin-200italic.bbc2d552.woff2 | Bin 0 -> 20536 bytes .../media/ibm-plex-sans-latin-300.10bb6a0a.woff | Bin 0 -> 24220 bytes .../media/ibm-plex-sans-latin-300.9e1c48af.woff2 | Bin 0 -> 19124 bytes .../ibm-plex-sans-latin-300italic.c76f2ab5.woff2 | Bin 0 -> 20468 bytes .../ibm-plex-sans-latin-300italic.d3566d5b.woff | Bin 0 -> 25876 bytes .../media/ibm-plex-sans-latin-400.263d6267.woff2 | Bin 0 -> 17784 bytes .../media/ibm-plex-sans-latin-400.a2c56f94.woff | Bin 0 -> 22620 bytes .../ibm-plex-sans-latin-400italic.272f8611.woff | Bin 0 -> 24664 bytes .../ibm-plex-sans-latin-400italic.89a93a1b.woff2 | Bin 0 -> 19364 bytes .../media/ibm-plex-sans-latin-500.0866c244.woff2 | Bin 0 -> 18640 bytes .../media/ibm-plex-sans-latin-500.f6d5c5d5.woff | Bin 0 -> 23792 bytes .../ibm-plex-sans-latin-500italic.ccd41bd1.woff | Bin 0 -> 25852 bytes .../ibm-plex-sans-latin-500italic.ffd12d59.woff2 | Bin 0 -> 20380 bytes .../media/ibm-plex-sans-latin-600.337b1651.woff | Bin 0 -> 24104 bytes .../media/ibm-plex-sans-latin-600.7852d4dc.woff2 | Bin 0 -> 18912 bytes .../ibm-plex-sans-latin-600italic.17e5379f.woff2 | Bin 0 -> 19940 bytes .../ibm-plex-sans-latin-600italic.6f4ba6aa.woff | Bin 0 -> 25428 bytes .../media/ibm-plex-sans-latin-700.b8809d61.woff | Bin 0 -> 22904 bytes .../media/ibm-plex-sans-latin-700.c9983d3d.woff2 | Bin 0 -> 17976 bytes .../ibm-plex-sans-latin-700italic.02954bee.woff2 | Bin 0 -> 19360 bytes .../ibm-plex-sans-latin-700italic.72e9af40.woff | Bin 0 -> 24584 bytes .../v1/static/media/material-icons.0509ab09.woff2 | Bin 0 -> 60840 bytes web/gui/v1/tv-react.html | 287 + web/gui/v1/tv.html | 279 + web/gui/v2/.well-known/assetlinks.json | 12 + web/gui/v2/1178.b54a742702a74832f653.chunk.js | 1 + web/gui/v2/1193.efd539c053944de2599b.chunk.js | 1 + web/gui/v2/1277.884a6e09fbb50c214d8e.chunk.js | 2 + .../1277.884a6e09fbb50c214d8e.chunk.js.LICENSE.txt | 1 + web/gui/v2/1282.8f29fe3a597e5ef695e5.js | 1 + web/gui/v2/1452.c2c843e34d17591ebafe.chunk.js | 1 + web/gui/v2/1729.b8957abec2922839104a.chunk.js | 1 + web/gui/v2/2337.40d93ac60f1ccbb653ae.chunk.js | 1 + web/gui/v2/2357.cd84c87ed27d878a2371.chunk.js | 1 + web/gui/v2/2406.f2927edc2116c8e03b3b.js | 2 + .../v2/2406.f2927edc2116c8e03b3b.js.LICENSE.txt | 64 + web/gui/v2/2533.2b6849df953c0d8de977.js | 2 + .../v2/2533.2b6849df953c0d8de977.js.LICENSE.txt | 1 + web/gui/v2/2713.2f8abb33ec163445f81d.chunk.js | 1 + web/gui/v2/2773.36292453483e1b60ea2b.chunk.js | 1 + web/gui/v2/2785.b5a9958703db6fd26399.chunk.js | 1 + web/gui/v2/281.93a7bf4372306eb81264.chunk.js | 1 + web/gui/v2/285.40bdfb7ccf71eab2df71.chunk.js | 1 + web/gui/v2/2934.787f7366de588d5e4212.chunk.js | 1 + web/gui/v2/3017.7a600c57c76d95b7de22.chunk.js | 1 + web/gui/v2/3169.9aa93f115e8a19171f69.chunk.js | 1 + web/gui/v2/3212.ef9057f6ac28ed55d62a.chunk.js | 1 + web/gui/v2/3241.fe7d3a8eca88df253a60.chunk.js | 1 + web/gui/v2/3253.48f218e54858427e997b.chunk.js | 1 + web/gui/v2/3253.89070793921be1288bb5.css | 2 + web/gui/v2/3283.88c006d10b31f8ed8088.chunk.js | 1 + web/gui/v2/3981.ccb665950325037c0dda.css | 6 + web/gui/v2/3D_PARTY_LICENSES.txt | 6530 ++++++++++++ web/gui/v2/4586.b2ee472b3fc901d6c88b.js | 2 + .../v2/4586.b2ee472b3fc901d6c88b.js.LICENSE.txt | 15 + web/gui/v2/4744.2f7f0a1a4febd58f933a.chunk.js | 1 + web/gui/v2/4814.4aa06ec12491f116137a.chunk.js | 1 + web/gui/v2/4934.3ffbe62edd432c5a801d.chunk.js | 1 + web/gui/v2/498.8ac2616b1f317e54ddd6.chunk.js | 2 + .../498.8ac2616b1f317e54ddd6.chunk.js.LICENSE.txt | 41 + web/gui/v2/5100.70bf09de4a0223d97932.chunk.js | 1 + web/gui/v2/5112.93d13acdc6a1c411810a.chunk.js | 1 + web/gui/v2/5158.76b96a61b88ac13e64fb.js | 2 + .../v2/5158.76b96a61b88ac13e64fb.js.LICENSE.txt | 5 + web/gui/v2/5575.d6c19cc08835f9f741cf.chunk.js | 2 + .../5575.d6c19cc08835f9f741cf.chunk.js.LICENSE.txt | 3 + web/gui/v2/5756.5bcfd00c65bb1f62ded1.chunk.js | 1 + web/gui/v2/5969.a5bd320bfdea9db1c60f.chunk.js | 1 + web/gui/v2/597.787ec8d8543dac902833.chunk.js | 1 + web/gui/v2/6129.bd0a9b3cc7f4c6f95728.chunk.js | 1 + web/gui/v2/6152.d7e1e2bfdb9cb0ae978f.js | 1 + web/gui/v2/6181.007ffc3728cc5a74130a.chunk.js | 1 + web/gui/v2/6187.0b79ef0afe565349e1bc.js | 2 + .../v2/6187.0b79ef0afe565349e1bc.js.LICENSE.txt | 41 + web/gui/v2/6288.3316ccd0d95f1d801d18.chunk.js | 1 + web/gui/v2/6347.886fd82050c23f2e2db2.chunk.js | 1 + web/gui/v2/6502.94c9d91d866d8a75769b.chunk.js | 1 + web/gui/v2/6610.2be4959755f28fc7f452.chunk.js | 1 + web/gui/v2/6723.080a1abe2d9291d1909e.chunk.js | 1 + web/gui/v2/6723.cc9fa5f3bdc0bf3ab2fc.css | 10 + web/gui/v2/6817.d23c368d61fe2ff69315.chunk.js | 1 + web/gui/v2/6848.6bbd4e759ec15bf74d51.chunk.js | 1 + web/gui/v2/6848.89070793921be1288bb5.css | 2 + web/gui/v2/6876.b74cba4369d8345b7f95.chunk.js | 1 + web/gui/v2/6914.bd8de0fb338f16858f0f.chunk.js | 1 + web/gui/v2/7068.5b656c774fade4cea185.chunk.js | 1 + web/gui/v2/7154.b209cde4e1813acc2cd4.chunk.js | 1 + web/gui/v2/7514.ea3b186181ecff7f8ae5.chunk.js | 2 + .../7514.ea3b186181ecff7f8ae5.chunk.js.LICENSE.txt | 20 + web/gui/v2/8099.4838cb5caf85574b5c9d.js | 2 + .../v2/8099.4838cb5caf85574b5c9d.js.LICENSE.txt | 20 + web/gui/v2/8102.3b2b80fe00d67e577367.chunk.js | 1 + web/gui/v2/8276.cb877f5ee79184a9e0fb.chunk.js | 1 + web/gui/v2/8459.576da4e194a7e4007f03.css | 2 + web/gui/v2/8459.add89d7bb0434b110cd3.chunk.js | 2 + .../8459.add89d7bb0434b110cd3.chunk.js.LICENSE.txt | 5 + web/gui/v2/8663.c6d53b400dd7461702e6.chunk.js | 1 + web/gui/v2/88.fbc9567094081f35e29c.chunk.js | 1 + web/gui/v2/8977.321a7a13b267546a6e7c.chunk.js | 1 + web/gui/v2/90.c0f1d633c6e943af5628.chunk.js | 1 + web/gui/v2/9020.618bce1feb9efd7ead50.chunk.js | 1 + web/gui/v2/9201.7f3fc933d8e1520a2f6a.chunk.js | 1 + web/gui/v2/923.00170bf7762cedfa762e.chunk.js | 1 + web/gui/v2/9360.de29630b4dcacbeb5ecd.chunk.js | 1 + web/gui/v2/9510.dec77b81a86e7cd2ff86.chunk.js | 1 + web/gui/v2/9513.68ac17c54e2a98d13112.js | 2 + .../v2/9513.68ac17c54e2a98d13112.js.LICENSE.txt | 1 + web/gui/v2/9594.89070793921be1288bb5.css | 2 + web/gui/v2/9594.b5b73051fd8e1b9901f1.chunk.js | 1 + web/gui/v2/9768.3e539b24a5eb4979ea85.chunk.js | 1 + web/gui/v2/9886.7d6c2ffca80bd567e52d.chunk.js | 1 + web/gui/v2/9893.b40d1bffe447771a2e43.chunk.js | 1 + web/gui/v2/9895.3d7f7d9acb001bf41011.chunk.js | 1 + web/gui/v2/9975.e14f6e47cf3025af8628.chunk.js | 1 + web/gui/v2/LICENSE.md | 42 + web/gui/v2/Makefile.am | 335 + web/gui/v2/README.md | 1 + web/gui/v2/agent.html | 224 + web/gui/v2/allFiles.6.66.1.json | 364 + web/gui/v2/allFiles.6.json | 364 + web/gui/v2/app.cb2e9f9a81cf9533384e.css | 2 + web/gui/v2/app.efc4ebf75cd13cc4f5f4.js | 1 + web/gui/v2/apple-app-site-association | 11 + web/gui/v2/bundlesManifest.6.json | 15 + web/gui/v2/editor.ae2bfa9dd703149cdd28.chunk.js | 1 + web/gui/v2/favicon.ico | Bin 0 -> 101252 bytes web/gui/v2/index.html | 224 + web/gui/v2/local-agent.html | 224 + web/gui/v2/npm.react.dom.443419261632ac7d4e78.js | 2 + ...m.react.dom.443419261632ac7d4e78.js.LICENSE.txt | 9 + web/gui/v2/registry-access.html | 73 + web/gui/v2/registry-alert-redirect.html | 150 + web/gui/v2/registry-hello.html | 94 + web/gui/v2/runtime.e7f678759af562297436.js | 1 + web/gui/v2/static/.well-known/assetlinks.json | 12 + web/gui/v2/static/apple-app-site-association | 11 + web/gui/v2/static/email/img/clea_badge.png | Bin 0 -> 1147 bytes web/gui/v2/static/email/img/clea_siren.png | Bin 0 -> 2427 bytes web/gui/v2/static/email/img/community_icon.png | Bin 0 -> 1271 bytes web/gui/v2/static/email/img/configure_icon.png | Bin 0 -> 1256 bytes web/gui/v2/static/email/img/crit_badge.png | Bin 0 -> 2479 bytes web/gui/v2/static/email/img/crit_siren.png | Bin 0 -> 3432 bytes web/gui/v2/static/email/img/flood_siren.png | Bin 0 -> 2059 bytes web/gui/v2/static/email/img/full_logo.png | Bin 0 -> 1298 bytes web/gui/v2/static/email/img/header.png | Bin 0 -> 5386 bytes web/gui/v2/static/email/img/isotype_600.png | Bin 0 -> 9114 bytes web/gui/v2/static/email/img/label_critical.png | Bin 0 -> 1595 bytes web/gui/v2/static/email/img/label_recovered.png | Bin 0 -> 2027 bytes web/gui/v2/static/email/img/label_warning.png | Bin 0 -> 1752 bytes web/gui/v2/static/email/img/reachability_siren.png | Bin 0 -> 3951 bytes web/gui/v2/static/email/img/warn_badge.png | Bin 0 -> 2204 bytes web/gui/v2/static/email/img/warn_siren.png | Bin 0 -> 3005 bytes web/gui/v2/static/img/list-style-image.svg | 9 + web/gui/v2/static/img/logos/os/alpine.svg | 1 + web/gui/v2/static/img/logos/os/arch.svg | 72 + web/gui/v2/static/img/logos/os/centos.svg | 13 + web/gui/v2/static/img/logos/os/coreos.svg | 1 + web/gui/v2/static/img/logos/os/debian.svg | 1 + web/gui/v2/static/img/logos/os/docker.svg | 3 + web/gui/v2/static/img/logos/os/fedora.svg | 13 + web/gui/v2/static/img/logos/os/freebsd.svg | 1 + web/gui/v2/static/img/logos/os/freenas.svg | 38 + web/gui/v2/static/img/logos/os/gentoo.svg | 419 + web/gui/v2/static/img/logos/os/kubernetes.svg | 84 + web/gui/v2/static/img/logos/os/linux-small.svg | 3 + web/gui/v2/static/img/logos/os/linux.svg | 1 + web/gui/v2/static/img/logos/os/macos.svg | 13 + web/gui/v2/static/img/logos/os/manjaro.svg | 91 + web/gui/v2/static/img/logos/os/openstack.svg | 1 + web/gui/v2/static/img/logos/os/opensuse.svg | 114 + web/gui/v2/static/img/logos/os/openwrt.svg | 8 + web/gui/v2/static/img/logos/os/oracle.svg | 28 + web/gui/v2/static/img/logos/os/pfsense.svg | 7 + web/gui/v2/static/img/logos/os/placeholder.svg | 3 + web/gui/v2/static/img/logos/os/raspberry-pi.svg | 1 + web/gui/v2/static/img/logos/os/redhat.svg | 1 + web/gui/v2/static/img/logos/os/rocky.svg | 3 + web/gui/v2/static/img/logos/os/suse.svg | 1 + web/gui/v2/static/img/logos/os/ubuntu.svg | 1 + .../v2/static/img/logos/services/access-point.svg | 7 + web/gui/v2/static/img/logos/services/activemq.svg | 253 + web/gui/v2/static/img/logos/services/adaptec.svg | 143 + web/gui/v2/static/img/logos/services/alerta.svg | 20 + web/gui/v2/static/img/logos/services/apache.svg | 138 + web/gui/v2/static/img/logos/services/apc.svg | 103 + web/gui/v2/static/img/logos/services/aws-sns.svg | 1 + web/gui/v2/static/img/logos/services/aws.svg | 3 + .../v2/static/img/logos/services/beanstalkd.svg | 112 + web/gui/v2/static/img/logos/services/boinc.svg | 134 + web/gui/v2/static/img/logos/services/btrfs.svg | 93 + web/gui/v2/static/img/logos/services/ceph.svg | 1 + web/gui/v2/static/img/logos/services/chrony.svg | 68 + web/gui/v2/static/img/logos/services/cloud.svg | 13 + web/gui/v2/static/img/logos/services/concul.svg | 8 + web/gui/v2/static/img/logos/services/consul.svg | 1 + web/gui/v2/static/img/logos/services/container.svg | 1 + web/gui/v2/static/img/logos/services/couchdb.svg | 62 + web/gui/v2/static/img/logos/services/cups.svg | 91 + .../static/img/logos/services/data-encryption.svg | 4 + web/gui/v2/static/img/logos/services/ddos.svg | 7 + web/gui/v2/static/img/logos/services/discord.svg | 1 + web/gui/v2/static/img/logos/services/dns.svg | 4 + web/gui/v2/static/img/logos/services/docker.svg | 100 + web/gui/v2/static/img/logos/services/dovecot.svg | 67 + .../v2/static/img/logos/services/elasticsearch.svg | 74 + web/gui/v2/static/img/logos/services/email.svg | 43 + web/gui/v2/static/img/logos/services/exim.svg | 1 + web/gui/v2/static/img/logos/services/fail2ban.svg | 1 + web/gui/v2/static/img/logos/services/flock.svg | 3 + web/gui/v2/static/img/logos/services/fluentd.svg | 91 + web/gui/v2/static/img/logos/services/fping.svg | 82 + .../v2/static/img/logos/services/freeradius.svg | 260 + web/gui/v2/static/img/logos/services/fronius.svg | 1 + .../v2/static/img/logos/services/gnu-freeipmi.svg | 1 + web/gui/v2/static/img/logos/services/golang.svg | 3 + web/gui/v2/static/img/logos/services/grafana.svg | 57 + web/gui/v2/static/img/logos/services/graphite.svg | 1 + web/gui/v2/static/img/logos/services/haproxy.svg | 1 + web/gui/v2/static/img/logos/services/hub.svg | 1 + web/gui/v2/static/img/logos/services/icecast.svg | 114 + web/gui/v2/static/img/logos/services/influxdb.svg | 3 + web/gui/v2/static/img/logos/services/ipfs.svg | 28 + web/gui/v2/static/img/logos/services/irc.svg | 99 + web/gui/v2/static/img/logos/services/isc.svg | 19 + web/gui/v2/static/img/logos/services/kafka.svg | 1 + web/gui/v2/static/img/logos/services/kairosdb.svg | 3 + web/gui/v2/static/img/logos/services/kavenegar.svg | 10 + web/gui/v2/static/img/logos/services/key-file.svg | 1 + .../v2/static/img/logos/services/kubernetes.svg | 84 + web/gui/v2/static/img/logos/services/libreswan.svg | 27 + web/gui/v2/static/img/logos/services/libvirt.svg | 713 ++ .../v2/static/img/logos/services/lighthttpd.svg | 1 + web/gui/v2/static/img/logos/services/linux.svg | 1 + web/gui/v2/static/img/logos/services/litespeed.svg | 91 + .../v2/static/img/logos/services/lm-sensors.svg | 1 + .../v2/static/img/logos/services/load-balancer.svg | 8 + web/gui/v2/static/img/logos/services/log-file.svg | 55 + web/gui/v2/static/img/logos/services/logstash.svg | 1 + web/gui/v2/static/img/logos/services/lxd.svg | 200 + web/gui/v2/static/img/logos/services/mariadb.svg | 49 + web/gui/v2/static/img/logos/services/memcached.svg | 31 + .../v2/static/img/logos/services/messagebird.svg | 1 + web/gui/v2/static/img/logos/services/mongodb.svg | 1 + web/gui/v2/static/img/logos/services/monit.svg | 12 + .../v2/static/img/logos/services/monitoring.svg | 55 + web/gui/v2/static/img/logos/services/mysql.svg | 17 + web/gui/v2/static/img/logos/services/netfilter.svg | 98 + .../static/img/logos/services/network-protocol.svg | 44 + web/gui/v2/static/img/logos/services/network.svg | 14 + web/gui/v2/static/img/logos/services/nfs.svg | 18 + .../v2/static/img/logos/services/nginx-plus.svg | 28 + web/gui/v2/static/img/logos/services/nginx.svg | 20 + .../img/logos/services/notification-bell.svg | 55 + web/gui/v2/static/img/logos/services/nsd.svg | 117 + web/gui/v2/static/img/logos/services/ntpd.svg | 56 + web/gui/v2/static/img/logos/services/nut.svg | 1 + web/gui/v2/static/img/logos/services/nvidia.svg | 1 + web/gui/v2/static/img/logos/services/openldap.svg | 1 + web/gui/v2/static/img/logos/services/opensips.svg | 1 + web/gui/v2/static/img/logos/services/opentsdb.svg | 27 + web/gui/v2/static/img/logos/services/openvpn.svg | 62 + web/gui/v2/static/img/logos/services/openzfs.svg | 72 + web/gui/v2/static/img/logos/services/oracle.svg | 28 + web/gui/v2/static/img/logos/services/pagerduty.svg | 12 + web/gui/v2/static/img/logos/services/php-fpm.svg | 90 + .../v2/static/img/logos/services/placeholder.svg | 8 + web/gui/v2/static/img/logos/services/postfix.svg | 293 + .../v2/static/img/logos/services/postgresql.svg | 22 + web/gui/v2/static/img/logos/services/powerdns.svg | 1 + web/gui/v2/static/img/logos/services/processor.svg | 1 + .../v2/static/img/logos/services/prometheus.svg | 50 + web/gui/v2/static/img/logos/services/prowl.svg | 35 + web/gui/v2/static/img/logos/services/proxysql.svg | 1 + web/gui/v2/static/img/logos/services/puppet.svg | 31 + .../v2/static/img/logos/services/pushbullet.svg | 1 + web/gui/v2/static/img/logos/services/pushover.svg | 7 + web/gui/v2/static/img/logos/services/qos.svg | 7 + web/gui/v2/static/img/logos/services/rabbitmq.svg | 75 + .../v2/static/img/logos/services/raspberry-pi.svg | 1 + web/gui/v2/static/img/logos/services/redis.svg | 1 + web/gui/v2/static/img/logos/services/rethinkdb.svg | 805 ++ .../v2/static/img/logos/services/retroshare.svg | 263 + .../v2/static/img/logos/services/rocketchat.svg | 7 + web/gui/v2/static/img/logos/services/samba.svg | 3 + .../img/logos/services/server-connection.svg | 68 + web/gui/v2/static/img/logos/services/slack.svg | 3 + web/gui/v2/static/img/logos/services/sma.svg | 27 + web/gui/v2/static/img/logos/services/smstools3.svg | 74 + web/gui/v2/static/img/logos/services/solr.svg | 1 + web/gui/v2/static/img/logos/services/spigot.svg | 1 + .../v2/static/img/logos/services/springboot.svg | 1 + web/gui/v2/static/img/logos/services/squid.svg | 398 + web/gui/v2/static/img/logos/services/statsd.svg | 29 + web/gui/v2/static/img/logos/services/stiebel.svg | 49 + web/gui/v2/static/img/logos/services/systemd.svg | 152 + web/gui/v2/static/img/logos/services/telegram.svg | 17 + .../v2/static/img/logos/services/temperature.svg | 4 + web/gui/v2/static/img/logos/services/tomcat.svg | 107 + web/gui/v2/static/img/logos/services/tor.svg | 140 + web/gui/v2/static/img/logos/services/traefik.svg | 90 + web/gui/v2/static/img/logos/services/twilio.svg | 1 + web/gui/v2/static/img/logos/services/unbound.svg | 105 + web/gui/v2/static/img/logos/services/uwsgi.svg | 109 + web/gui/v2/static/img/logos/services/varnish.svg | 1 + web/gui/v2/static/img/logos/services/veritas.svg | 197 + web/gui/v2/static/img/logos/services/xen.svg | 104 + web/gui/v2/static/img/mail/isotype.png | Bin 0 -> 2611 bytes web/gui/v2/static/img/mail/isotype.svg | 3 + web/gui/v2/static/img/mail/logotype.png | Bin 0 -> 1301 bytes web/gui/v2/static/img/mail/logotype.svg | 11 + web/gui/v2/static/img/new-dashboard.svg | 52 + web/gui/v2/static/img/no-filter-results.png | Bin 0 -> 79381 bytes web/gui/v2/static/img/no-nodes-room.svg | 226 + web/gui/v2/static/img/rack.png | Bin 0 -> 9261 bytes .../pages/holding-page-503/holding-page-503.css | 101 + .../pages/holding-page-503/holding-page-503.svg | 534 + .../static/site/pages/holding-page-503/index.html | 39 + .../holding-page-503/multiple-logos-group.svg | 32 + .../pages/holding-page-503/netdata-logo-white.svg | 3 + .../static/site/pages/holding-page-503/reset.svg | 3 + web/gui/v2/static/splash.css | 171 + web/gui/v2/sw.js | 1 + web/gui/v2live.html | 230 + 527 files changed, 86035 insertions(+) create mode 100644 web/gui/.dashboard-notice.md create mode 100644 web/gui/.dashboard-v2-notice.md create mode 100644 web/gui/.well-known/dnt/cookies create mode 100644 web/gui/Makefile.am create mode 100644 web/gui/README.md create mode 100644 web/gui/browserconfig.xml create mode 100755 web/gui/bundle_dashboard_v1.py create mode 100755 web/gui/bundle_dashboard_v2.py create mode 100644 web/gui/confluence/README.md create mode 100644 web/gui/css/c3-0.4.18.min.css create mode 100644 web/gui/css/morris-0.5.1.css create mode 100644 web/gui/custom/README.md create mode 100644 web/gui/dashboard_info.js create mode 100644 web/gui/dashboard_info_custom_example.js create mode 100644 web/gui/ilove.html create mode 100644 web/gui/index.html create mode 100644 web/gui/main.css create mode 100644 web/gui/main.js create mode 100644 web/gui/old/index.html create mode 100644 web/gui/registry-access.html create mode 100644 web/gui/registry-alert-redirect.html create mode 100644 web/gui/registry-hello.html create mode 100644 web/gui/src/dashboard.js/alarms.js create mode 100644 web/gui/src/dashboard.js/boot.js create mode 100644 web/gui/src/dashboard.js/chart-registry.js create mode 100644 web/gui/src/dashboard.js/charting.js create mode 100644 web/gui/src/dashboard.js/charting/_c3.js create mode 100644 web/gui/src/dashboard.js/charting/_morris.js create mode 100644 web/gui/src/dashboard.js/charting/_raphael.js create mode 100644 web/gui/src/dashboard.js/charting/d3.js create mode 100644 web/gui/src/dashboard.js/charting/d3pie.js create mode 100644 web/gui/src/dashboard.js/charting/dygraph.js create mode 100644 web/gui/src/dashboard.js/charting/easy-pie-chart.js create mode 100644 web/gui/src/dashboard.js/charting/gauge.js create mode 100644 web/gui/src/dashboard.js/charting/google-charts.js create mode 100644 web/gui/src/dashboard.js/charting/peity.js create mode 100644 web/gui/src/dashboard.js/charting/sparkline.js create mode 100644 web/gui/src/dashboard.js/charting/textonly.js create mode 100644 web/gui/src/dashboard.js/colors.js create mode 100644 web/gui/src/dashboard.js/common.js create mode 100644 web/gui/src/dashboard.js/compatibility.js create mode 100644 web/gui/src/dashboard.js/dependencies.js create mode 100644 web/gui/src/dashboard.js/epilogue.js.inc create mode 100644 web/gui/src/dashboard.js/error-handling.js create mode 100644 web/gui/src/dashboard.js/localstorage.js create mode 100644 web/gui/src/dashboard.js/main.js create mode 100644 web/gui/src/dashboard.js/options.js create mode 100644 web/gui/src/dashboard.js/prologue.js.inc create mode 100644 web/gui/src/dashboard.js/registry.js create mode 100644 web/gui/src/dashboard.js/server-detection.js create mode 100644 web/gui/src/dashboard.js/themes.js create mode 100644 web/gui/src/dashboard.js/timeout.js create mode 100644 web/gui/src/dashboard.js/units-conversion.js create mode 100644 web/gui/src/dashboard.js/utils.js create mode 100644 web/gui/src/dashboard.js/xss.js create mode 100644 web/gui/static/img/netdata-logomark.svg create mode 100644 web/gui/static/splash.css create mode 100644 web/gui/switch.html create mode 120000 web/gui/v0 create mode 100644 web/gui/v1/Makefile.am create mode 120000 web/gui/v1/README.md create mode 100644 web/gui/v1/asset-manifest.json create mode 100644 web/gui/v1/console.html create mode 100644 web/gui/v1/css/bootstrap-3.3.7.css create mode 100644 web/gui/v1/css/bootstrap-slate-flat-3.3.7.css create mode 100644 web/gui/v1/css/bootstrap-slider-10.0.0.min.css create mode 100644 web/gui/v1/css/bootstrap-theme-3.3.7.min.css create mode 100644 web/gui/v1/css/bootstrap-toggle-2.2.2.min.css create mode 100644 web/gui/v1/css/dashboard.css create mode 100644 web/gui/v1/css/dashboard.slate.css create mode 100644 web/gui/v1/dash-example.html create mode 100644 web/gui/v1/dashboard-react.js create mode 100644 web/gui/v1/dashboard.css create mode 100644 web/gui/v1/dashboard.html create mode 100644 web/gui/v1/dashboard.js create mode 100644 web/gui/v1/dashboard.slate.css create mode 100644 web/gui/v1/demo.html create mode 100644 web/gui/v1/demo2.html create mode 100644 web/gui/v1/demosites.html create mode 100644 web/gui/v1/demosites2.html create mode 100644 web/gui/v1/favicon.ico create mode 100644 web/gui/v1/fonts/glyphicons-halflings-regular.eot create mode 100644 web/gui/v1/fonts/glyphicons-halflings-regular.svg create mode 100644 web/gui/v1/fonts/glyphicons-halflings-regular.ttf create mode 100644 web/gui/v1/fonts/glyphicons-halflings-regular.woff create mode 100644 web/gui/v1/fonts/glyphicons-halflings-regular.woff2 create mode 100644 web/gui/v1/goto-host-from-alarm.html create mode 100644 web/gui/v1/images/alert-128-orange.png create mode 100644 web/gui/v1/images/alert-128-red.png create mode 100644 web/gui/v1/images/alert-multi-size-orange.ico create mode 100644 web/gui/v1/images/alert-multi-size-red.ico create mode 100644 web/gui/v1/images/alerts.jpg create mode 100644 web/gui/v1/images/alerts.png create mode 100644 web/gui/v1/images/android-icon-144x144.png create mode 100644 web/gui/v1/images/android-icon-192x192.png create mode 100644 web/gui/v1/images/android-icon-36x36.png create mode 100644 web/gui/v1/images/android-icon-48x48.png create mode 100644 web/gui/v1/images/android-icon-72x72.png create mode 100644 web/gui/v1/images/android-icon-96x96.png create mode 100644 web/gui/v1/images/animated.gif create mode 100644 web/gui/v1/images/apple-icon-114x114.png create mode 100644 web/gui/v1/images/apple-icon-120x120.png create mode 100644 web/gui/v1/images/apple-icon-144x144.png create mode 100644 web/gui/v1/images/apple-icon-152x152.png create mode 100644 web/gui/v1/images/apple-icon-180x180.png create mode 100644 web/gui/v1/images/apple-icon-57x57.png create mode 100644 web/gui/v1/images/apple-icon-60x60.png create mode 100644 web/gui/v1/images/apple-icon-72x72.png create mode 100644 web/gui/v1/images/apple-icon-76x76.png create mode 100644 web/gui/v1/images/apple-icon-precomposed.png create mode 100644 web/gui/v1/images/apple-icon.png create mode 100644 web/gui/v1/images/banner-icon-144x144.png create mode 100644 web/gui/v1/images/check-mark-2-128-green.png create mode 100644 web/gui/v1/images/check-mark-2-multi-size-green.ico create mode 100644 web/gui/v1/images/dashboards.png create mode 100644 web/gui/v1/images/favicon-128.png create mode 100644 web/gui/v1/images/favicon-16x16.png create mode 100644 web/gui/v1/images/favicon-196x196.png create mode 100644 web/gui/v1/images/favicon-32x32.png create mode 100644 web/gui/v1/images/favicon-96x96.png create mode 100644 web/gui/v1/images/favicon.ico create mode 100644 web/gui/v1/images/home.png create mode 100644 web/gui/v1/images/ms-icon-144x144.png create mode 100644 web/gui/v1/images/ms-icon-150x150.png create mode 100644 web/gui/v1/images/ms-icon-310x150.png create mode 100644 web/gui/v1/images/ms-icon-310x310.png create mode 100644 web/gui/v1/images/ms-icon-36x36.png create mode 100644 web/gui/v1/images/ms-icon-70x70.png create mode 100644 web/gui/v1/images/netdata-logomark.svg create mode 100644 web/gui/v1/images/netdata.svg create mode 100644 web/gui/v1/images/nodeView.png create mode 100644 web/gui/v1/images/nodes.jpg create mode 100644 web/gui/v1/images/overview.png create mode 100644 web/gui/v1/images/packaging-beta-tag.svg create mode 100644 web/gui/v1/images/post.png create mode 100644 web/gui/v1/images/pricing.png create mode 100644 web/gui/v1/images/seo-performance-128.png create mode 100644 web/gui/v1/index-node-view.html create mode 100644 web/gui/v1/index.html create mode 100644 web/gui/v1/infographic.html create mode 100644 web/gui/v1/lib/bootstrap-3.3.7.min.js create mode 100644 web/gui/v1/lib/bootstrap-slider-10.0.0.min.js create mode 100644 web/gui/v1/lib/bootstrap-table-1.11.0.min.js create mode 100644 web/gui/v1/lib/bootstrap-table-export-1.11.0.min.js create mode 100644 web/gui/v1/lib/bootstrap-toggle-2.2.2.min.js create mode 100644 web/gui/v1/lib/clipboard-polyfill-be05dad.js create mode 100644 web/gui/v1/lib/d3-4.12.2.min.js create mode 100644 web/gui/v1/lib/d3pie-0.2.1-netdata-3.js create mode 100644 web/gui/v1/lib/dygraph-c91c859.min.js create mode 100644 web/gui/v1/lib/dygraph-smooth-plotter-c91c859.js create mode 100644 web/gui/v1/lib/fontawesome-all-5.0.1.min.js create mode 100644 web/gui/v1/lib/gauge-1.3.2.min.js create mode 100644 web/gui/v1/lib/jquery-3.6.0.min.js create mode 100644 web/gui/v1/lib/jquery.easypiechart-97b5824.min.js create mode 100644 web/gui/v1/lib/jquery.peity-3.2.0.min.js create mode 100644 web/gui/v1/lib/jquery.sparkline-2.1.2.min.js create mode 100644 web/gui/v1/lib/lz-string-1.4.4.min.js create mode 100644 web/gui/v1/lib/pako-1.0.6.min.js create mode 100644 web/gui/v1/lib/perfect-scrollbar-0.6.15.min.js create mode 100644 web/gui/v1/lib/tableExport-1.6.0.min.js create mode 100644 web/gui/v1/manifest.json create mode 100644 web/gui/v1/precache-manifest.e2d3811ef5e4b7e75e1f56d6ee92ef2c.js create mode 100644 web/gui/v1/refresh-badges.js create mode 100644 web/gui/v1/robots.txt create mode 100644 web/gui/v1/service-worker.js create mode 100644 web/gui/v1/sitemap.xml create mode 100644 web/gui/v1/static/css/2.c454aab8.chunk.css create mode 100644 web/gui/v1/static/css/2.c454aab8.chunk.css.map create mode 100644 web/gui/v1/static/css/4.a36e3b73.chunk.css create mode 100644 web/gui/v1/static/css/4.a36e3b73.chunk.css.map create mode 100644 web/gui/v1/static/css/main.53ba10f1.chunk.css create mode 100644 web/gui/v1/static/css/main.53ba10f1.chunk.css.map create mode 100644 web/gui/v1/static/js/10.a5cd7d0e.chunk.js create mode 100644 web/gui/v1/static/js/10.a5cd7d0e.chunk.js.map create mode 100644 web/gui/v1/static/js/2.62d105c5.chunk.js create mode 100644 web/gui/v1/static/js/2.62d105c5.chunk.js.LICENSE create mode 100644 web/gui/v1/static/js/2.62d105c5.chunk.js.map create mode 100644 web/gui/v1/static/js/3.f137faca.chunk.js create mode 100644 web/gui/v1/static/js/3.f137faca.chunk.js.map create mode 100644 web/gui/v1/static/js/4.2dbcd906.chunk.js create mode 100644 web/gui/v1/static/js/4.2dbcd906.chunk.js.map create mode 100644 web/gui/v1/static/js/5.2f783a54.chunk.js create mode 100644 web/gui/v1/static/js/5.2f783a54.chunk.js.LICENSE create mode 100644 web/gui/v1/static/js/5.2f783a54.chunk.js.map create mode 100644 web/gui/v1/static/js/6.e1951239.chunk.js create mode 100644 web/gui/v1/static/js/6.e1951239.chunk.js.map create mode 100644 web/gui/v1/static/js/7.c2417fb0.chunk.js create mode 100644 web/gui/v1/static/js/7.c2417fb0.chunk.js.map create mode 100644 web/gui/v1/static/js/8.b4161ea2.chunk.js create mode 100644 web/gui/v1/static/js/8.b4161ea2.chunk.js.map create mode 100644 web/gui/v1/static/js/9.a4363968.chunk.js create mode 100644 web/gui/v1/static/js/9.a4363968.chunk.js.map create mode 100644 web/gui/v1/static/js/main.e248095a.chunk.js create mode 100644 web/gui/v1/static/js/main.e248095a.chunk.js.LICENSE create mode 100644 web/gui/v1/static/js/main.e248095a.chunk.js.map create mode 100644 web/gui/v1/static/js/runtime-main.08abed8f.js create mode 100644 web/gui/v1/static/js/runtime-main.08abed8f.js.map create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-100.245539db.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-100.9a582f3a.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-100italic.1ea7c5d2.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-100italic.3c34cf08.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-200.67524c36.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-200.bf72c841.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-200italic.52df2560.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-200italic.bbc2d552.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-300.10bb6a0a.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-300.9e1c48af.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-300italic.c76f2ab5.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-300italic.d3566d5b.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-400.263d6267.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-400.a2c56f94.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-400italic.272f8611.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-400italic.89a93a1b.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-500.0866c244.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-500.f6d5c5d5.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-500italic.ccd41bd1.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-500italic.ffd12d59.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-600.337b1651.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-600.7852d4dc.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-600italic.17e5379f.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-600italic.6f4ba6aa.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-700.b8809d61.woff create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-700.c9983d3d.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-700italic.02954bee.woff2 create mode 100644 web/gui/v1/static/media/ibm-plex-sans-latin-700italic.72e9af40.woff create mode 100644 web/gui/v1/static/media/material-icons.0509ab09.woff2 create mode 100644 web/gui/v1/tv-react.html create mode 100644 web/gui/v1/tv.html create mode 100644 web/gui/v2/.well-known/assetlinks.json create mode 100644 web/gui/v2/1178.b54a742702a74832f653.chunk.js create mode 100644 web/gui/v2/1193.efd539c053944de2599b.chunk.js create mode 100644 web/gui/v2/1277.884a6e09fbb50c214d8e.chunk.js create mode 100644 web/gui/v2/1277.884a6e09fbb50c214d8e.chunk.js.LICENSE.txt create mode 100644 web/gui/v2/1282.8f29fe3a597e5ef695e5.js create mode 100644 web/gui/v2/1452.c2c843e34d17591ebafe.chunk.js create mode 100644 web/gui/v2/1729.b8957abec2922839104a.chunk.js create mode 100644 web/gui/v2/2337.40d93ac60f1ccbb653ae.chunk.js create mode 100644 web/gui/v2/2357.cd84c87ed27d878a2371.chunk.js create mode 100644 web/gui/v2/2406.f2927edc2116c8e03b3b.js create mode 100644 web/gui/v2/2406.f2927edc2116c8e03b3b.js.LICENSE.txt create mode 100644 web/gui/v2/2533.2b6849df953c0d8de977.js create mode 100644 web/gui/v2/2533.2b6849df953c0d8de977.js.LICENSE.txt create mode 100644 web/gui/v2/2713.2f8abb33ec163445f81d.chunk.js create mode 100644 web/gui/v2/2773.36292453483e1b60ea2b.chunk.js create mode 100644 web/gui/v2/2785.b5a9958703db6fd26399.chunk.js create mode 100644 web/gui/v2/281.93a7bf4372306eb81264.chunk.js create mode 100644 web/gui/v2/285.40bdfb7ccf71eab2df71.chunk.js create mode 100644 web/gui/v2/2934.787f7366de588d5e4212.chunk.js create mode 100644 web/gui/v2/3017.7a600c57c76d95b7de22.chunk.js create mode 100644 web/gui/v2/3169.9aa93f115e8a19171f69.chunk.js create mode 100644 web/gui/v2/3212.ef9057f6ac28ed55d62a.chunk.js create mode 100644 web/gui/v2/3241.fe7d3a8eca88df253a60.chunk.js create mode 100644 web/gui/v2/3253.48f218e54858427e997b.chunk.js create mode 100644 web/gui/v2/3253.89070793921be1288bb5.css create mode 100644 web/gui/v2/3283.88c006d10b31f8ed8088.chunk.js create mode 100644 web/gui/v2/3981.ccb665950325037c0dda.css create mode 100644 web/gui/v2/3D_PARTY_LICENSES.txt create mode 100644 web/gui/v2/4586.b2ee472b3fc901d6c88b.js create mode 100644 web/gui/v2/4586.b2ee472b3fc901d6c88b.js.LICENSE.txt create mode 100644 web/gui/v2/4744.2f7f0a1a4febd58f933a.chunk.js create mode 100644 web/gui/v2/4814.4aa06ec12491f116137a.chunk.js create mode 100644 web/gui/v2/4934.3ffbe62edd432c5a801d.chunk.js create mode 100644 web/gui/v2/498.8ac2616b1f317e54ddd6.chunk.js create mode 100644 web/gui/v2/498.8ac2616b1f317e54ddd6.chunk.js.LICENSE.txt create mode 100644 web/gui/v2/5100.70bf09de4a0223d97932.chunk.js create mode 100644 web/gui/v2/5112.93d13acdc6a1c411810a.chunk.js create mode 100644 web/gui/v2/5158.76b96a61b88ac13e64fb.js create mode 100644 web/gui/v2/5158.76b96a61b88ac13e64fb.js.LICENSE.txt create mode 100644 web/gui/v2/5575.d6c19cc08835f9f741cf.chunk.js create mode 100644 web/gui/v2/5575.d6c19cc08835f9f741cf.chunk.js.LICENSE.txt create mode 100644 web/gui/v2/5756.5bcfd00c65bb1f62ded1.chunk.js create mode 100644 web/gui/v2/5969.a5bd320bfdea9db1c60f.chunk.js create mode 100644 web/gui/v2/597.787ec8d8543dac902833.chunk.js create mode 100644 web/gui/v2/6129.bd0a9b3cc7f4c6f95728.chunk.js create mode 100644 web/gui/v2/6152.d7e1e2bfdb9cb0ae978f.js create mode 100644 web/gui/v2/6181.007ffc3728cc5a74130a.chunk.js create mode 100644 web/gui/v2/6187.0b79ef0afe565349e1bc.js create mode 100644 web/gui/v2/6187.0b79ef0afe565349e1bc.js.LICENSE.txt create mode 100644 web/gui/v2/6288.3316ccd0d95f1d801d18.chunk.js create mode 100644 web/gui/v2/6347.886fd82050c23f2e2db2.chunk.js create mode 100644 web/gui/v2/6502.94c9d91d866d8a75769b.chunk.js create mode 100644 web/gui/v2/6610.2be4959755f28fc7f452.chunk.js create mode 100644 web/gui/v2/6723.080a1abe2d9291d1909e.chunk.js create mode 100644 web/gui/v2/6723.cc9fa5f3bdc0bf3ab2fc.css create mode 100644 web/gui/v2/6817.d23c368d61fe2ff69315.chunk.js create mode 100644 web/gui/v2/6848.6bbd4e759ec15bf74d51.chunk.js create mode 100644 web/gui/v2/6848.89070793921be1288bb5.css create mode 100644 web/gui/v2/6876.b74cba4369d8345b7f95.chunk.js create mode 100644 web/gui/v2/6914.bd8de0fb338f16858f0f.chunk.js create mode 100644 web/gui/v2/7068.5b656c774fade4cea185.chunk.js create mode 100644 web/gui/v2/7154.b209cde4e1813acc2cd4.chunk.js create mode 100644 web/gui/v2/7514.ea3b186181ecff7f8ae5.chunk.js create mode 100644 web/gui/v2/7514.ea3b186181ecff7f8ae5.chunk.js.LICENSE.txt create mode 100644 web/gui/v2/8099.4838cb5caf85574b5c9d.js create mode 100644 web/gui/v2/8099.4838cb5caf85574b5c9d.js.LICENSE.txt create mode 100644 web/gui/v2/8102.3b2b80fe00d67e577367.chunk.js create mode 100644 web/gui/v2/8276.cb877f5ee79184a9e0fb.chunk.js create mode 100644 web/gui/v2/8459.576da4e194a7e4007f03.css create mode 100644 web/gui/v2/8459.add89d7bb0434b110cd3.chunk.js create mode 100644 web/gui/v2/8459.add89d7bb0434b110cd3.chunk.js.LICENSE.txt create mode 100644 web/gui/v2/8663.c6d53b400dd7461702e6.chunk.js create mode 100644 web/gui/v2/88.fbc9567094081f35e29c.chunk.js create mode 100644 web/gui/v2/8977.321a7a13b267546a6e7c.chunk.js create mode 100644 web/gui/v2/90.c0f1d633c6e943af5628.chunk.js create mode 100644 web/gui/v2/9020.618bce1feb9efd7ead50.chunk.js create mode 100644 web/gui/v2/9201.7f3fc933d8e1520a2f6a.chunk.js create mode 100644 web/gui/v2/923.00170bf7762cedfa762e.chunk.js create mode 100644 web/gui/v2/9360.de29630b4dcacbeb5ecd.chunk.js create mode 100644 web/gui/v2/9510.dec77b81a86e7cd2ff86.chunk.js create mode 100644 web/gui/v2/9513.68ac17c54e2a98d13112.js create mode 100644 web/gui/v2/9513.68ac17c54e2a98d13112.js.LICENSE.txt create mode 100644 web/gui/v2/9594.89070793921be1288bb5.css create mode 100644 web/gui/v2/9594.b5b73051fd8e1b9901f1.chunk.js create mode 100644 web/gui/v2/9768.3e539b24a5eb4979ea85.chunk.js create mode 100644 web/gui/v2/9886.7d6c2ffca80bd567e52d.chunk.js create mode 100644 web/gui/v2/9893.b40d1bffe447771a2e43.chunk.js create mode 100644 web/gui/v2/9895.3d7f7d9acb001bf41011.chunk.js create mode 100644 web/gui/v2/9975.e14f6e47cf3025af8628.chunk.js create mode 100644 web/gui/v2/LICENSE.md create mode 100644 web/gui/v2/Makefile.am create mode 120000 web/gui/v2/README.md create mode 100644 web/gui/v2/agent.html create mode 100644 web/gui/v2/allFiles.6.66.1.json create mode 100644 web/gui/v2/allFiles.6.json create mode 100644 web/gui/v2/app.cb2e9f9a81cf9533384e.css create mode 100644 web/gui/v2/app.efc4ebf75cd13cc4f5f4.js create mode 100644 web/gui/v2/apple-app-site-association create mode 100644 web/gui/v2/bundlesManifest.6.json create mode 100644 web/gui/v2/editor.ae2bfa9dd703149cdd28.chunk.js create mode 100644 web/gui/v2/favicon.ico create mode 100644 web/gui/v2/index.html create mode 100644 web/gui/v2/local-agent.html create mode 100644 web/gui/v2/npm.react.dom.443419261632ac7d4e78.js create mode 100644 web/gui/v2/npm.react.dom.443419261632ac7d4e78.js.LICENSE.txt create mode 100644 web/gui/v2/registry-access.html create mode 100644 web/gui/v2/registry-alert-redirect.html create mode 100644 web/gui/v2/registry-hello.html create mode 100644 web/gui/v2/runtime.e7f678759af562297436.js create mode 100644 web/gui/v2/static/.well-known/assetlinks.json create mode 100644 web/gui/v2/static/apple-app-site-association create mode 100644 web/gui/v2/static/email/img/clea_badge.png create mode 100644 web/gui/v2/static/email/img/clea_siren.png create mode 100644 web/gui/v2/static/email/img/community_icon.png create mode 100644 web/gui/v2/static/email/img/configure_icon.png create mode 100644 web/gui/v2/static/email/img/crit_badge.png create mode 100644 web/gui/v2/static/email/img/crit_siren.png create mode 100644 web/gui/v2/static/email/img/flood_siren.png create mode 100644 web/gui/v2/static/email/img/full_logo.png create mode 100644 web/gui/v2/static/email/img/header.png create mode 100644 web/gui/v2/static/email/img/isotype_600.png create mode 100644 web/gui/v2/static/email/img/label_critical.png create mode 100644 web/gui/v2/static/email/img/label_recovered.png create mode 100644 web/gui/v2/static/email/img/label_warning.png create mode 100644 web/gui/v2/static/email/img/reachability_siren.png create mode 100644 web/gui/v2/static/email/img/warn_badge.png create mode 100644 web/gui/v2/static/email/img/warn_siren.png create mode 100644 web/gui/v2/static/img/list-style-image.svg create mode 100644 web/gui/v2/static/img/logos/os/alpine.svg create mode 100644 web/gui/v2/static/img/logos/os/arch.svg create mode 100644 web/gui/v2/static/img/logos/os/centos.svg create mode 100644 web/gui/v2/static/img/logos/os/coreos.svg create mode 100644 web/gui/v2/static/img/logos/os/debian.svg create mode 100644 web/gui/v2/static/img/logos/os/docker.svg create mode 100644 web/gui/v2/static/img/logos/os/fedora.svg create mode 100644 web/gui/v2/static/img/logos/os/freebsd.svg create mode 100644 web/gui/v2/static/img/logos/os/freenas.svg create mode 100644 web/gui/v2/static/img/logos/os/gentoo.svg create mode 100644 web/gui/v2/static/img/logos/os/kubernetes.svg create mode 100644 web/gui/v2/static/img/logos/os/linux-small.svg create mode 100644 web/gui/v2/static/img/logos/os/linux.svg create mode 100644 web/gui/v2/static/img/logos/os/macos.svg create mode 100644 web/gui/v2/static/img/logos/os/manjaro.svg create mode 100644 web/gui/v2/static/img/logos/os/openstack.svg create mode 100644 web/gui/v2/static/img/logos/os/opensuse.svg create mode 100644 web/gui/v2/static/img/logos/os/openwrt.svg create mode 100644 web/gui/v2/static/img/logos/os/oracle.svg create mode 100644 web/gui/v2/static/img/logos/os/pfsense.svg create mode 100644 web/gui/v2/static/img/logos/os/placeholder.svg create mode 100644 web/gui/v2/static/img/logos/os/raspberry-pi.svg create mode 100644 web/gui/v2/static/img/logos/os/redhat.svg create mode 100644 web/gui/v2/static/img/logos/os/rocky.svg create mode 100644 web/gui/v2/static/img/logos/os/suse.svg create mode 100644 web/gui/v2/static/img/logos/os/ubuntu.svg create mode 100644 web/gui/v2/static/img/logos/services/access-point.svg create mode 100644 web/gui/v2/static/img/logos/services/activemq.svg create mode 100644 web/gui/v2/static/img/logos/services/adaptec.svg create mode 100644 web/gui/v2/static/img/logos/services/alerta.svg create mode 100644 web/gui/v2/static/img/logos/services/apache.svg create mode 100644 web/gui/v2/static/img/logos/services/apc.svg create mode 100644 web/gui/v2/static/img/logos/services/aws-sns.svg create mode 100644 web/gui/v2/static/img/logos/services/aws.svg create mode 100644 web/gui/v2/static/img/logos/services/beanstalkd.svg create mode 100644 web/gui/v2/static/img/logos/services/boinc.svg create mode 100644 web/gui/v2/static/img/logos/services/btrfs.svg create mode 100644 web/gui/v2/static/img/logos/services/ceph.svg create mode 100644 web/gui/v2/static/img/logos/services/chrony.svg create mode 100644 web/gui/v2/static/img/logos/services/cloud.svg create mode 100644 web/gui/v2/static/img/logos/services/concul.svg create mode 100644 web/gui/v2/static/img/logos/services/consul.svg create mode 100644 web/gui/v2/static/img/logos/services/container.svg create mode 100644 web/gui/v2/static/img/logos/services/couchdb.svg create mode 100644 web/gui/v2/static/img/logos/services/cups.svg create mode 100644 web/gui/v2/static/img/logos/services/data-encryption.svg create mode 100644 web/gui/v2/static/img/logos/services/ddos.svg create mode 100644 web/gui/v2/static/img/logos/services/discord.svg create mode 100644 web/gui/v2/static/img/logos/services/dns.svg create mode 100644 web/gui/v2/static/img/logos/services/docker.svg create mode 100644 web/gui/v2/static/img/logos/services/dovecot.svg create mode 100644 web/gui/v2/static/img/logos/services/elasticsearch.svg create mode 100644 web/gui/v2/static/img/logos/services/email.svg create mode 100644 web/gui/v2/static/img/logos/services/exim.svg create mode 100644 web/gui/v2/static/img/logos/services/fail2ban.svg create mode 100644 web/gui/v2/static/img/logos/services/flock.svg create mode 100644 web/gui/v2/static/img/logos/services/fluentd.svg create mode 100644 web/gui/v2/static/img/logos/services/fping.svg create mode 100644 web/gui/v2/static/img/logos/services/freeradius.svg create mode 100644 web/gui/v2/static/img/logos/services/fronius.svg create mode 100644 web/gui/v2/static/img/logos/services/gnu-freeipmi.svg create mode 100644 web/gui/v2/static/img/logos/services/golang.svg create mode 100644 web/gui/v2/static/img/logos/services/grafana.svg create mode 100644 web/gui/v2/static/img/logos/services/graphite.svg create mode 100644 web/gui/v2/static/img/logos/services/haproxy.svg create mode 100644 web/gui/v2/static/img/logos/services/hub.svg create mode 100644 web/gui/v2/static/img/logos/services/icecast.svg create mode 100644 web/gui/v2/static/img/logos/services/influxdb.svg create mode 100644 web/gui/v2/static/img/logos/services/ipfs.svg create mode 100644 web/gui/v2/static/img/logos/services/irc.svg create mode 100644 web/gui/v2/static/img/logos/services/isc.svg create mode 100644 web/gui/v2/static/img/logos/services/kafka.svg create mode 100644 web/gui/v2/static/img/logos/services/kairosdb.svg create mode 100644 web/gui/v2/static/img/logos/services/kavenegar.svg create mode 100644 web/gui/v2/static/img/logos/services/key-file.svg create mode 100644 web/gui/v2/static/img/logos/services/kubernetes.svg create mode 100644 web/gui/v2/static/img/logos/services/libreswan.svg create mode 100644 web/gui/v2/static/img/logos/services/libvirt.svg create mode 100644 web/gui/v2/static/img/logos/services/lighthttpd.svg create mode 100644 web/gui/v2/static/img/logos/services/linux.svg create mode 100644 web/gui/v2/static/img/logos/services/litespeed.svg create mode 100644 web/gui/v2/static/img/logos/services/lm-sensors.svg create mode 100644 web/gui/v2/static/img/logos/services/load-balancer.svg create mode 100644 web/gui/v2/static/img/logos/services/log-file.svg create mode 100644 web/gui/v2/static/img/logos/services/logstash.svg create mode 100644 web/gui/v2/static/img/logos/services/lxd.svg create mode 100644 web/gui/v2/static/img/logos/services/mariadb.svg create mode 100644 web/gui/v2/static/img/logos/services/memcached.svg create mode 100644 web/gui/v2/static/img/logos/services/messagebird.svg create mode 100644 web/gui/v2/static/img/logos/services/mongodb.svg create mode 100644 web/gui/v2/static/img/logos/services/monit.svg create mode 100644 web/gui/v2/static/img/logos/services/monitoring.svg create mode 100644 web/gui/v2/static/img/logos/services/mysql.svg create mode 100644 web/gui/v2/static/img/logos/services/netfilter.svg create mode 100644 web/gui/v2/static/img/logos/services/network-protocol.svg create mode 100644 web/gui/v2/static/img/logos/services/network.svg create mode 100644 web/gui/v2/static/img/logos/services/nfs.svg create mode 100644 web/gui/v2/static/img/logos/services/nginx-plus.svg create mode 100644 web/gui/v2/static/img/logos/services/nginx.svg create mode 100644 web/gui/v2/static/img/logos/services/notification-bell.svg create mode 100644 web/gui/v2/static/img/logos/services/nsd.svg create mode 100644 web/gui/v2/static/img/logos/services/ntpd.svg create mode 100644 web/gui/v2/static/img/logos/services/nut.svg create mode 100644 web/gui/v2/static/img/logos/services/nvidia.svg create mode 100644 web/gui/v2/static/img/logos/services/openldap.svg create mode 100644 web/gui/v2/static/img/logos/services/opensips.svg create mode 100644 web/gui/v2/static/img/logos/services/opentsdb.svg create mode 100644 web/gui/v2/static/img/logos/services/openvpn.svg create mode 100644 web/gui/v2/static/img/logos/services/openzfs.svg create mode 100644 web/gui/v2/static/img/logos/services/oracle.svg create mode 100644 web/gui/v2/static/img/logos/services/pagerduty.svg create mode 100644 web/gui/v2/static/img/logos/services/php-fpm.svg create mode 100644 web/gui/v2/static/img/logos/services/placeholder.svg create mode 100644 web/gui/v2/static/img/logos/services/postfix.svg create mode 100644 web/gui/v2/static/img/logos/services/postgresql.svg create mode 100644 web/gui/v2/static/img/logos/services/powerdns.svg create mode 100644 web/gui/v2/static/img/logos/services/processor.svg create mode 100644 web/gui/v2/static/img/logos/services/prometheus.svg create mode 100644 web/gui/v2/static/img/logos/services/prowl.svg create mode 100644 web/gui/v2/static/img/logos/services/proxysql.svg create mode 100644 web/gui/v2/static/img/logos/services/puppet.svg create mode 100644 web/gui/v2/static/img/logos/services/pushbullet.svg create mode 100644 web/gui/v2/static/img/logos/services/pushover.svg create mode 100644 web/gui/v2/static/img/logos/services/qos.svg create mode 100644 web/gui/v2/static/img/logos/services/rabbitmq.svg create mode 100644 web/gui/v2/static/img/logos/services/raspberry-pi.svg create mode 100644 web/gui/v2/static/img/logos/services/redis.svg create mode 100644 web/gui/v2/static/img/logos/services/rethinkdb.svg create mode 100644 web/gui/v2/static/img/logos/services/retroshare.svg create mode 100644 web/gui/v2/static/img/logos/services/rocketchat.svg create mode 100644 web/gui/v2/static/img/logos/services/samba.svg create mode 100644 web/gui/v2/static/img/logos/services/server-connection.svg create mode 100644 web/gui/v2/static/img/logos/services/slack.svg create mode 100644 web/gui/v2/static/img/logos/services/sma.svg create mode 100644 web/gui/v2/static/img/logos/services/smstools3.svg create mode 100644 web/gui/v2/static/img/logos/services/solr.svg create mode 100644 web/gui/v2/static/img/logos/services/spigot.svg create mode 100644 web/gui/v2/static/img/logos/services/springboot.svg create mode 100644 web/gui/v2/static/img/logos/services/squid.svg create mode 100644 web/gui/v2/static/img/logos/services/statsd.svg create mode 100644 web/gui/v2/static/img/logos/services/stiebel.svg create mode 100644 web/gui/v2/static/img/logos/services/systemd.svg create mode 100644 web/gui/v2/static/img/logos/services/telegram.svg create mode 100644 web/gui/v2/static/img/logos/services/temperature.svg create mode 100644 web/gui/v2/static/img/logos/services/tomcat.svg create mode 100644 web/gui/v2/static/img/logos/services/tor.svg create mode 100644 web/gui/v2/static/img/logos/services/traefik.svg create mode 100644 web/gui/v2/static/img/logos/services/twilio.svg create mode 100644 web/gui/v2/static/img/logos/services/unbound.svg create mode 100644 web/gui/v2/static/img/logos/services/uwsgi.svg create mode 100644 web/gui/v2/static/img/logos/services/varnish.svg create mode 100644 web/gui/v2/static/img/logos/services/veritas.svg create mode 100644 web/gui/v2/static/img/logos/services/xen.svg create mode 100644 web/gui/v2/static/img/mail/isotype.png create mode 100644 web/gui/v2/static/img/mail/isotype.svg create mode 100644 web/gui/v2/static/img/mail/logotype.png create mode 100644 web/gui/v2/static/img/mail/logotype.svg create mode 100644 web/gui/v2/static/img/new-dashboard.svg create mode 100644 web/gui/v2/static/img/no-filter-results.png create mode 100644 web/gui/v2/static/img/no-nodes-room.svg create mode 100644 web/gui/v2/static/img/rack.png create mode 100644 web/gui/v2/static/site/pages/holding-page-503/holding-page-503.css create mode 100644 web/gui/v2/static/site/pages/holding-page-503/holding-page-503.svg create mode 100644 web/gui/v2/static/site/pages/holding-page-503/index.html create mode 100644 web/gui/v2/static/site/pages/holding-page-503/multiple-logos-group.svg create mode 100644 web/gui/v2/static/site/pages/holding-page-503/netdata-logo-white.svg create mode 100644 web/gui/v2/static/site/pages/holding-page-503/reset.svg create mode 100644 web/gui/v2/static/splash.css create mode 100644 web/gui/v2/sw.js create mode 100644 web/gui/v2live.html (limited to 'web/gui') diff --git a/web/gui/.dashboard-notice.md b/web/gui/.dashboard-notice.md new file mode 100644 index 00000000..ea403bc6 --- /dev/null +++ b/web/gui/.dashboard-notice.md @@ -0,0 +1,7 @@ +# Do not edit any files in this directory! + +If you spot any errors or bugs in these files and wish to fix them, please submit your changes at +https://github.com/netdata/dashboard instead. + +These files are copied from the most recent release of that repository, and any changes you make here will be +overwritten the next time there’s a new release there. diff --git a/web/gui/.dashboard-v2-notice.md b/web/gui/.dashboard-v2-notice.md new file mode 100644 index 00000000..2eb4374c --- /dev/null +++ b/web/gui/.dashboard-v2-notice.md @@ -0,0 +1,8 @@ +# Do not edit any files in this directory! + +If you spot any errors or bugs in these files please open a bug report +at https://github.com/netdata/netdata/issues/new/choose. + +These files are maintained in a seprate private repository and copied +here when they are updated there, so any changes made in this directory +will eventually be overwritten. diff --git a/web/gui/.well-known/dnt/cookies b/web/gui/.well-known/dnt/cookies new file mode 100644 index 00000000..b7c70e58 --- /dev/null +++ b/web/gui/.well-known/dnt/cookies @@ -0,0 +1,14 @@ +{ + "tracking": "T", + "compliance": ["https://github.com/netdata/netdata/wiki/cookies#compliance"], + "qualifiers": "afc", + "controller": ["https://github.com/netdata/netdata/wiki/cookies#controller"], + "same-party": [ + "my-netdata.io", + "mynetdata.io", + "netdata.online", + "netdata.rocks", + "registry.my-netdata.io" + ], + "policy": "https://github.com/netdata/netdata/wiki/cookies#policy", +} diff --git a/web/gui/Makefile.am b/web/gui/Makefile.am new file mode 100644 index 00000000..b04f3318 --- /dev/null +++ b/web/gui/Makefile.am @@ -0,0 +1,111 @@ +# +# Copyright (C) 2015 Alon Bar-Lev +# SPDX-License-Identifier: GPL-3.0-or-later +# +AUTOMAKE_OPTIONS = subdir-objects +MAINTAINERCLEANFILES = $(srcdir)/Makefile.in +CLEANFILES = \ + version.txt \ + $(NULL) + +SUBDIRS = \ + v1 \ + v2 \ + $(NULL) + +DASHBOARD_JS_FILES = \ + $(srcdir)/src/dashboard.js/prologue.js.inc \ + $(srcdir)/src/dashboard.js/utils.js \ + $(srcdir)/src/dashboard.js/server-detection.js \ + $(srcdir)/src/dashboard.js/dependencies.js \ + $(srcdir)/src/dashboard.js/error-handling.js \ + $(srcdir)/src/dashboard.js/compatibility.js \ + $(srcdir)/src/dashboard.js/xss.js \ + $(srcdir)/src/dashboard.js/colors.js \ + $(srcdir)/src/dashboard.js/units-conversion.js \ + $(srcdir)/src/dashboard.js/options.js \ + $(srcdir)/src/dashboard.js/localstorage.js \ + $(srcdir)/src/dashboard.js/timeout.js \ + $(srcdir)/src/dashboard.js/themes.js \ + $(srcdir)/src/dashboard.js/charting/dygraph.js \ + $(srcdir)/src/dashboard.js/charting/sparkline.js \ + $(srcdir)/src/dashboard.js/charting/google-charts.js \ + $(srcdir)/src/dashboard.js/charting/gauge.js \ + $(srcdir)/src/dashboard.js/charting/easy-pie-chart.js \ + $(srcdir)/src/dashboard.js/charting/d3pie.js \ + $(srcdir)/src/dashboard.js/charting/d3.js \ + $(srcdir)/src/dashboard.js/charting/peity.js \ + $(srcdir)/src/dashboard.js/charting/textonly.js \ + $(srcdir)/src/dashboard.js/charting.js \ + $(srcdir)/src/dashboard.js/chart-registry.js \ + $(srcdir)/src/dashboard.js/common.js \ + $(srcdir)/src/dashboard.js/main.js \ + $(srcdir)/src/dashboard.js/alarms.js \ + $(srcdir)/src/dashboard.js/registry.js \ + $(srcdir)/src/dashboard.js/boot.js \ + $(srcdir)/src/dashboard.js/epilogue.js.inc \ + $(NULL) + +dist_noinst_DATA = \ + $(srcdir)/README.md \ + $(DASHBOARD_JS_FILES) \ + $(NULL) + +dist_web_DATA = \ + dashboard.js \ + $(srcdir)/dashboard_info_custom_example.js \ + $(srcdir)/dashboard_info.js \ + $(srcdir)/index.html \ + $(srcdir)/main.css \ + $(srcdir)/main.js \ + $(srcdir)/registry-access.html \ + $(srcdir)/registry-alert-redirect.html \ + $(srcdir)/registry-hello.html \ + $(srcdir)/switch.html \ + $(srcdir)/ilove.html \ + version.txt \ + $(NULL) + +webolddir=$(webdir)/old +dist_webold_DATA = \ + $(srcdir)/old/index.html \ + $(NULL) + +webv0dir=$(webdir)/v0 +dist_webv0_DATA = \ + $(srcdir)/old/index.html \ + $(NULL) + +webstaticdir=$(webdir)/static/img +dist_webstatic_DATA = \ + $(srcdir)/static/img/netdata-logomark.svg \ + $(NULL) + +webcssdir=$(webdir)/css +dist_webcss_DATA = \ + $(srcdir)/css/morris-0.5.1.css \ + $(srcdir)/css/c3-0.4.18.min.css \ + $(NULL) + +dashboard.js: $(DASHBOARD_JS_FILES) + if test -f $@; then rm -f $@; fi + cat $(DASHBOARD_JS_FILES) > $@.tmp && mv $@.tmp $@ + +webwellknowndir=$(webdir)/.well-known +dist_webwellknown_DATA = \ + $(NULL) + +webdntdir=$(webdir)/.well-known/dnt +dist_webdnt_DATA = \ + $(srcdir)/.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; \ + fi > $@.tmp + test -s $@.tmp || echo 0 > $@.tmp + mv $@.tmp $@ + +# regenerate these files, even if they are up to date +.PHONY: version.txt dashboard.js diff --git a/web/gui/README.md b/web/gui/README.md new file mode 100644 index 00000000..2b73ad26 --- /dev/null +++ b/web/gui/README.md @@ -0,0 +1,165 @@ +# Legacy Agent dashboard + +> ⚠️ You're checking the documentation for the legacy Agent dashboard. For the current version please check [Accessing Netdata Dashboards](https://github.com/netdata/netdata/blob/master/docs/category-overview-pages/accessing-netdata-dashboards.md). + + +The local Netdata Agent dashboard is the heart of Netdata's performance troubleshooting toolkit. You've probably seen it +before: + +![The Netdata dashboard in +action](https://user-images.githubusercontent.com/1153921/101513938-fae28380-3939-11eb-9434-8ad86a39be62.gif) + +Learn more about how dashboards work and how they're populated using the `dashboards.js` file in our [web dashboards +overview](https://github.com/netdata/netdata/blob/master/web/README.md). + +By default, Netdata starts a web server for its dashboard at port `19999`. Open up your web browser of choice and +navigate to `http://NODE:19999`, replacing `NODE` with the IP address or hostname of your Agent. If installed on localhost, +you can access it through `http://localhost:19999`. + +Netdata uses an [internal, static-threaded web server](https://github.com/netdata/netdata/blob/master/web/server/README.md) to host the HTML, CSS, and JavaScript +files that make up the local Agent dashboard. You don't have to configure anything to access it, although you can adjust +[your settings](https://github.com/netdata/netdata/blob/master/web/server/README.md#other-netdataconf-web-section-options) in the `netdata.conf` file, or run Netdata +behind an [Nginx proxy](https://github.com/netdata/netdata/blob/master/docs/Running-behind-nginx.md), and so on. + +## Navigating the local dashboard + +Beyond charts, the local dashboard can be broken down into three key areas: + +- [Local Agent dashboard](#local-agent-dashboard) + - [Navigating the local dashboard](#navigating-the-local-dashboard) + - [Sections](#sections) + - [Time \& date picker](#time--date-picker) + - [Metrics menus](#metrics-menus) + - [Cloud menus (Spaces, War Rooms, and Visited nodes)](#cloud-menus-spaces-war-rooms-and-visited-nodes) + - [Customizing the local dashboard](#customizing-the-local-dashboard) + - [Custom dashboards](#custom-dashboards) + +![Annotated screenshot of the local Agent +dashboard](https://user-images.githubusercontent.com/1153921/101509403-f7e59400-3935-11eb-9abd-cbecfa3ee49a.png) + +### Sections + +Netdata is broken up into multiple **sections**, such as **System Overview**, +**CPU**, **Disk**, and more. Inside each section you'll find a number of charts, +broken down into [contexts](https://github.com/netdata/netdata/blob/master/web/README.md#contexts) and +[families](https://github.com/netdata/netdata/blob/master/web/README.md#families). + +An example of the **Memory** section on a Linux desktop system. + +![Screenshot of the Memory section of the Netdata +dashboard](https://user-images.githubusercontent.com/1153921/101508423-e354cc00-3934-11eb-9b33-3ad57a5988b4.png) + +All sections and their associated charts appear on a single page, so all you need to do to view different sections is +scroll up and down. But it's usually quicker to use the [menus](#metrics-menus). + +### Time & date picker + +The local dashboard features a time & date picker to help you visualize specific timeframes of historical metrics. The +picker chooses an appropriate default to always show per-second granularity based on the width of your browser's +viewport. + +![The time & date picker in the local Agent +dashboard](https://user-images.githubusercontent.com/1153921/101507784-2c585080-3934-11eb-9d6e-eff30b8553e4.png) + +Use the Quick Selector to show metrics from the last 5 minutes, 15 minutes, 30 minutes, 2 hours, 6 hours, or 12 hours. + +Beneath the Quick Selector is an input field and dropdown you use in combination to select a specific timeframe of +minutes, hours, days, or months. Enter a number and choose the appropriate unit of time. + +Use the calendar to select multiple days. Click on a date to begin the timeframe selection, then an ending date. + +Click **Apply** to re-render all visualizations with new metrics data, or **Clear** to restore the default timeframe. + +[Increase the metrics retention policy](https://github.com/netdata/netdata/blob/master/docs/store/change-metrics-storage.md) for your node to see more historical +timeframes. + +### Metrics menus + +**Metrics menus** appears on the right-hand side of the local Agent dashboard. Netdata generates a menu for each +section, and menus link to the section they're associated with. + +![A screenshot of metrics menus](https://user-images.githubusercontent.com/1153921/80834638-f08f2880-8ba5-11ea-99ae-f610b2885fd6.png) + +Most metrics menu items will contain several **submenu** entries, which represent any +[families](https://github.com/netdata/netdata/blob/master/web/README.md#families) from that section. Netdata automatically +generates these submenu entries. + +Here's a **Disks** menu with several submenu entries for each disk drive and +partition Netdata recognizes. + +![Screenshot of some metrics +submenus](https://user-images.githubusercontent.com/1153921/80834697-11577e00-8ba6-11ea-979c-92fd19cdb480.png) + +### Cloud menus (Spaces, War Rooms, and Visited nodes) + +The dashboard also features a menu related to Netdata Cloud functionality. You can view your existing Spaces or create +new ones via the left vertical column of boxes. This menu also displays the name of your current Space, shows a list of +any War Rooms you've added you your Space, and lists any notes you recently visited via their Agent dashboards. Click on +a War Room's name to jump to the Netdata Cloud web interface. + +![A screenshot of the Cloud +menus](https://user-images.githubusercontent.com/1153921/80837210-3f8b8c80-8bab-11ea-9c75-128c2d823ef8.png) + +## Customizing the local dashboard + +Netdata stores information about individual charts in the `dashboard_info.js` +file. This file includes section and subsection headings, descriptions, colors, +titles, tooltips, and other information for Netdata to render on the dashboard. + +For example, here is how `dashboard_info.js` defines the **System Overview** +section. + +```javascript +netdataDashboard.menu = { + 'system': { + title: 'System Overview', + icon: '', + info: 'Overview of the key system metrics.' + }, +``` + +If you want to customize this information, you should avoid editing +`dashboard_info.js` directly. These changes are not persistent; Netdata will +overwrite the file when it's updated. Instead, you should create a new file with +your customizations. + +We created an example file at `dashboard_info_custom_example.js`. You can +copy this to a new file with a name of your choice in the `web/` directory. This +directory changes based on your operating system and installation method. If +you're on a Linux system, it should be at `/usr/share/netdata/web/`. + +```shell +cd /usr/share/netdata/web/ +sudo cp dashboard_info_custom_example.js your_dashboard_info_file.js +``` + +Edit the file with your customizations. For example: + +```javascript +customDashboard.menu = { + system: { + title: "Testing, testing, 1 2 3", + icon: '', + info: "This is overwritten info for the system overview section!" + } +}; +``` + +Finally, tell Netdata where you placed your customization file by replacing +`your_dashboard_info_file.js` below. + +```conf +[web] + custom dashboard_info.js = your_dashboard_info_file.js +``` + +Once you restart Netdata, refresh the dashboard to find your custom +configuration: + +![Screenshot of overwritten text from dashboard_info.js +file](https://user-images.githubusercontent.com/1153921/62798924-570e6c80-ba94-11e9-9578-869753bec39c.png) + +## Custom dashboards + +For information on creating custom dashboards from scratch, see the [custom dashboards](https://github.com/netdata/netdata/blob/master/web/gui/custom/README.md) or +[Atlassian Confluence dashboards](https://github.com/netdata/netdata/blob/master/web/gui/confluence/README.md) guides. diff --git a/web/gui/browserconfig.xml b/web/gui/browserconfig.xml new file mode 100644 index 00000000..32f47595 --- /dev/null +++ b/web/gui/browserconfig.xml @@ -0,0 +1,2 @@ + +#ffffff diff --git a/web/gui/bundle_dashboard_v1.py b/web/gui/bundle_dashboard_v1.py new file mode 100755 index 00000000..20dc1839 --- /dev/null +++ b/web/gui/bundle_dashboard_v1.py @@ -0,0 +1,131 @@ +#!/usr/bin/env python3 +# +# Copyright: © 2021 Netdata Inc. +# SPDX-License-Identifier: GPL-3.0-or-later +'''Bundle the v1 dashboard code into the agent repo. + + This is designed to be run as part of a GHA workflow, but will work fine outside of one.''' + +import os +import shutil +import subprocess +import sys + +from pathlib import Path + +os.chdir(Path(__file__).parent.absolute()) + +BASEPATH = Path('v1') + +URLTEMPLATE = 'https://github.com/netdata/dashboard/releases/download/{0}/dashboard.tar.gz' + +MAKEFILETEMPLATE = ''' +# Auto-generated by bundle_dashboard.py +# Copyright: © 2021 Netdata Inc. +# SPDX-License-Identifier: GPL-3.0-or-later +MAINTAINERCLEANFILES = $(srcdir)/Makefile.in + +dist_noinst_DATA = \\ + $(srcdir)/README.md + +dist_web_DATA = \\ + {0} \\ + $(NULL) + +webv1dir=$(webdir)/v1 + +dist_webv1_DATA = \\ + index.html \\ + $(NULL) + +webcssdir=$(webdir)/css +dist_webcss_DATA = \\ + {1} \\ + $(NULL) + +webfontsdir=$(webdir)/fonts +dist_webfonts_DATA = \\ + {2} \\ + $(NULL) + +webimagesdir=$(webdir)/images +dist_webimages_DATA = \\ + {3} \\ + $(NULL) + +weblibdir=$(webdir)/lib +dist_weblib_DATA = \\ + {4} \\ + $(NULL) + +webstaticcssdir=$(webdir)/static/css +dist_webstaticcss_DATA = \\ + {5} \\ + $(NULL) + +webstaticjsdir=$(webdir)/static/js +dist_webstaticjs_DATA = \\ + {6} \\ + $(NULL) + +webstaticmediadir=$(webdir)/static/media +dist_webstaticmedia_DATA = \\ + {7} \\ + $(NULL) +''' + + +def copy_dashboard(tag): + '''Fetch and bundle the dashboard code.''' + print('Preparing target directory') + shutil.rmtree(BASEPATH) + BASEPATH.mkdir() + print('::group::Fetching dashboard release tarball') + subprocess.check_call('curl -L -o dashboard.tar.gz ' + URLTEMPLATE.format(tag), shell=True) + print('::endgroup::') + print('::group::Extracting dashboard release tarball') + subprocess.check_call('tar -xvzf dashboard.tar.gz -C ' + str(BASEPATH) + ' --strip-components=1', shell=True) + print('::endgroup::') + print('Copying README.md') + BASEPATH.joinpath('README.md').symlink_to('../.dashboard-notice.md') + print('Removing dashboard release tarball') + BASEPATH.joinpath('..', 'dashboard.tar.gz').unlink() + + +def genfilelist(path): + '''Generate a list of files for the Makefile.''' + files = [f for f in path.iterdir() if f.is_file() and f.name != 'README.md'] + files = [Path(*f.parts[1:]) for f in files] + files.sort() + return ' \\\n '.join([("$(srcdir)/" + str(f)) for f in files]) + + +def write_makefile(): + '''Write out the makefile for the dashboard code.''' + print('Generating Makefile') + MAKEFILEDATA = MAKEFILETEMPLATE.format( + genfilelist(BASEPATH), + genfilelist(BASEPATH.joinpath('css')), + genfilelist(BASEPATH.joinpath('fonts')), + genfilelist(BASEPATH.joinpath('images')), + genfilelist(BASEPATH.joinpath('lib')), + genfilelist(BASEPATH.joinpath('static', 'css')), + genfilelist(BASEPATH.joinpath('static', 'js')), + genfilelist(BASEPATH.joinpath('static', 'media')), + ) + + BASEPATH.joinpath('Makefile.am').write_text(MAKEFILEDATA) + + +def list_changed_files(): + '''Create a list of changed files, and set it in an environment variable.''' + if 'GITHUB_ENV' in os.environ: + print('Generating file list for commit.') + subprocess.check_call('echo "COMMIT_FILES<> $GITHUB_ENV', shell=True) + subprocess.check_call('git status --porcelain=v1 --no-renames --untracked-files=all | rev | cut -d \' \' -f 1 | rev >> $GITHUB_ENV', shell=True) + subprocess.check_call('echo "EOF" >> $GITHUB_ENV', shell=True) + + +copy_dashboard(sys.argv[1]) +write_makefile() +list_changed_files() diff --git a/web/gui/bundle_dashboard_v2.py b/web/gui/bundle_dashboard_v2.py new file mode 100755 index 00000000..66c74503 --- /dev/null +++ b/web/gui/bundle_dashboard_v2.py @@ -0,0 +1,138 @@ +#!/usr/bin/env python3 +# +# Copyright: © 2023 Netdata Inc. +# SPDX-License-Identifier: GPL-3.0-or-later +'''Bundle the v2 dashboard code into the agent repo. + + This is designed to be run as part of a GHA workflow, but will work fine outside of one.''' + +import os +import shutil +import subprocess + +from pathlib import Path + +os.chdir(Path(__file__).parent.absolute()) + +BASEDIR = 'v2' + +BASEPATH = Path(BASEDIR) + +TMPPATH = Path('tmp') + +URLSRC = 'https://app.netdata.cloud/agent.tar.gz' + +MAKEFILETEMPLATE = ''' +# Auto-generated by bundle_dashboard_v2.py +# Copyright: © 2023 Netdata Inc. +# SPDX-License-Identifier: GPL-3.0-or-later +MAINTAINERCLEANFILES = $(srcdir)/Makefile.in + +dist_noinst_DATA = \\ + $(srcdir)/README.md + +webv2dir=$(webdir)/v2 + +dist_webv2_DATA = \\ + {0} \\ + $(NULL) + +webv2staticdir=$(webv2dir)/static +dist_webv2static_DATA = \\ + {1} \\ + $(NULL) + +webv2staticemailimgdir=$(webv2staticdir)/email/img +dist_webv2staticemailimg_DATA = \\ + {2} \\ + $(NULL) + +webv2staticimgdir=$(webv2staticdir)/img +dist_webv2staticimg_DATA = \\ + {3} \\ + $(NULL) + +webv2staticimglogososdir=$(webv2staticimgdir)/logos/os +dist_webv2staticimglogosos_DATA = \\ + {4} \\ + $(NULL) + +webv2staticimglogosservicesdir=$(webv2staticimgdir)/logos/services +dist_webv2staticimglogosservices_DATA = \\ + {5} \\ + $(NULL) + +webv2staticimgmaildir=$(webv2staticimgdir)/mail +dist_webv2staticimgmail_DATA = \\ + {6} \\ + $(NULL) + +webv2staticsitepagesholding503dir=$(webv2staticdir)/site/pages/holding-page-503 +dist_webv2staticsitepagesholding503_DATA = \\ + {7} \\ + $(NULL) +''' + + +def copy_dashboard(): + '''Fetch and bundle the dashboard code.''' + print('Preparing target directory') + shutil.rmtree(BASEPATH) + TMPPATH.mkdir() + print('::group::Fetching dashboard release tarball') + subprocess.check_call(f'curl -L -o agent.tar { URLSRC }', shell=True) + print('::endgroup::') + print('::group::Extracting dashboard release tarball') + subprocess.check_call(f"tar -xvf agent.tar -C { TMPPATH } --strip-components=1 --exclude='*.br' --exclude='*.gz'", shell=True) + print('::endgroup::') + print('Copying files') + (TMPPATH / 'agent' / BASEDIR).rename(BASEPATH) + (TMPPATH / 'agent' / 'index.html').rename(Path('./index.html')) + (TMPPATH / 'agent' / 'registry-access.html').rename('./registry-access.html') + (TMPPATH / 'agent' / 'registry-alert-redirect.html').rename('./registry-alert-redirect.html') + (TMPPATH / 'agent' / 'registry-hello.html').rename('./registry-hello.html') + shutil.copytree(TMPPATH / 'agent' / 'static', Path('./static'), dirs_exist_ok=True) + shutil.rmtree(TMPPATH) + print('Copying README.md') + BASEPATH.joinpath('README.md').symlink_to('../.dashboard-v2-notice.md') + print('Removing dashboard release tarball') + BASEPATH.joinpath('..', 'agent.tar').unlink() + + +def genfilelist(path): + '''Generate a list of files for the Makefile.''' + files = [f for f in path.iterdir() if f.is_file() and f.name != 'README.md'] + files = [Path(*f.parts[1:]) for f in files] + files.sort() + return ' \\\n '.join([("$(srcdir)/" + str(f)) for f in files]) + + +def write_makefile(): + '''Write out the makefile for the dashboard code.''' + print('Generating Makefile') + MAKEFILEDATA = MAKEFILETEMPLATE.format( + genfilelist(BASEPATH), + genfilelist(BASEPATH.joinpath('static')), + genfilelist(BASEPATH.joinpath('static', 'email', 'img')), + genfilelist(BASEPATH.joinpath('static', 'img')), + genfilelist(BASEPATH.joinpath('static', 'img', 'logos', 'os')), + genfilelist(BASEPATH.joinpath('static', 'img', 'logos', 'services')), + genfilelist(BASEPATH.joinpath('static', 'img', 'mail')), + genfilelist(BASEPATH.joinpath('static', 'site', 'pages', 'holding-page-503')), + ) + + BASEPATH.joinpath('Makefile.am').write_text(MAKEFILEDATA) + + +def list_changed_files(): + '''Create a list of changed files, and set it in an environment variable.''' + if 'GITHUB_ENV' in os.environ: + print('Generating file list for commit.') + subprocess.check_call('echo "COMMIT_FILES<> $GITHUB_ENV', shell=True) + subprocess.check_call('git status --porcelain=v1 --no-renames --untracked-files=all | rev | cut -d \' \' -f 1 | rev >> $GITHUB_ENV', shell=True) + subprocess.check_call('echo "EOF" >> $GITHUB_ENV', shell=True) + + +copy_dashboard() +write_makefile() +list_changed_files() diff --git a/web/gui/confluence/README.md b/web/gui/confluence/README.md new file mode 100644 index 00000000..d76aabf7 --- /dev/null +++ b/web/gui/confluence/README.md @@ -0,0 +1,1023 @@ + + +# Atlassian Confluence dashboards + +With Netdata you can build **live, interactive, monitoring dashboards** directly on Atlassian's **Confluence** pages. + +I see you already asking "why should I do this?" + +Well... think a bit of it.... confluence is the perfect place for something like that: + +1. All the employees of your company already have access to it. + +2. Most probably you have already several spaces on confluence, one for each project or service. Adding live monitoring information there is ideal: everything in one place. Your users will just click on the page and instantly the monitoring page they need will appear with only the information they need to know. + +3. You can create monitoring pages for very specific purposes, hiding all the information that is too detailed for most users, or explaining in detail things that are difficult for them to understand. + +So, what can we expect? What can Netdata do on confluence? + +You will be surprised! **Everything a Netdata dashboard does!**. Example: + +![final-confluence4](https://user-images.githubusercontent.com/2662304/34366214-767fa4b8-eaa1-11e7-83af-0b9b9b72aa73.gif) + +Let me show you how. + +> Let's assume we have 2 web servers we want to monitor. We will create a simple dashboard with key information about them, directly on confluence. + +### Before you begin + +Most likely your confluence is accessible via HTTPS. So, you need to proxy your Netdata servers via an apache or nginx to make them HTTPS too. If your Confluence is HTTPS but your Netdata are not, you will not be able to fetch the Netdata content from the confluence page. The Netdata wiki has many examples for proxying Netdata through another web server. + +> So, make sure Netdata and Confluence can be accessed with the same protocol (**http**, or **https**). + +For our example, I will use these 2 servers: + +| server | url | +|------|---| +| Server 1 | | +| Server 2 | | + +I will use the first server for the static dashboard javascript files. + +--- + +Then, you need to enable the `html` plugin of confluence. We will add some plain html content on that page, and this plugin is required. + +### Create a new page + +Create a new confluence page and paste this into an `html` box: + +```html + + + +``` + +like this (type `{html` for the html box to appear - you need the confluence html plugin enabled): + +![screenshot from 2017-12-25 00-46-20](https://user-images.githubusercontent.com/2662304/34329541-1dd9077c-e90d-11e7-988d-6820be31ff3f.png) + +### Add a few badges + +Then, go to your Netdata and copy an alert badge (the `` version of it): + +![copy-embed-badge](https://user-images.githubusercontent.com/2662304/34329562-dddea37e-e90d-11e7-9830-041a9f6a5984.gif) + +Then add another HTML box on the page, and paste it, like this: + +![screenshot from 2017-12-25 00-55-18](https://user-images.githubusercontent.com/2662304/34329569-4fc3d07c-e90e-11e7-8127-3127a21e1657.png) + +Hit **update** and you will get this: + +![screenshot from 2017-12-25 00-56-58](https://user-images.githubusercontent.com/2662304/34329573-8d4237cc-e90e-11e7-80bf-6c260456c690.png) + +This badge is now auto-refreshing. It will update itself based on the update frequency of the alert. + +> Keep in mind you can add badges with custom Netdata queries too. Netdata automatically creates badges for all the +> alerts, but every chart, every dimension on every chart, can be used for a badge. And Netdata badges are quite +> powerful! Check [Creating Badges](https://github.com/netdata/netdata/blob/master/web/api/badges/README.md) for more information on badges. + +So, let's create a table and add this badge for both our web servers: + +![screenshot from 2017-12-25 01-06-10](https://user-images.githubusercontent.com/2662304/34329609-d3e9ab00-e90f-11e7-99df-884196347538.png) + +Now we get this: + +![screenshot from 2017-12-25 01-07-10](https://user-images.githubusercontent.com/2662304/34329615-f7dea286-e90f-11e7-9b6f-600215494f96.png) + +### Add a Netdata chart + +The simplest form of a chart is this (it adds the chart `web_log_nginx_netdata.response_statuses`, using 100% of the width, 150px height, and the last 10 minutes of data): + +```html +
+``` + +Add this to `html` block on confluence: + +![screenshot from 2017-12-25 01-13-15](https://user-images.githubusercontent.com/2662304/34329635-cf83ab0a-e910-11e7-85a3-b72ccc2d54e4.png) + +And you will get this: + +![screenshot from 2017-12-25 01-14-09](https://user-images.githubusercontent.com/2662304/34329640-efd15574-e910-11e7-9004-94487dcde154.png) + +> This chart is **alive**, fully interactive. You can drag it, pan it, zoom it, etc like you do on Netdata dashboards! + +Of course this too big. We need something smaller to add inside the table. Let's try this: + +```html +
+``` + +The chart name is shown on all Netdata charts, so just copy it from a Netdata dashboard. + +We will fetch the same chart from both servers. To define the server we also added `data-host=` with the URL of each server, like this (we also added `
` for a newline between the badge and the chart): + +![screenshot from 2017-12-25 01-25-05](https://user-images.githubusercontent.com/2662304/34329695-76fd2680-e912-11e7-9969-87f8d5b36145.png) + +Which gives us this: + +![screenshot from 2017-12-25 01-26-04](https://user-images.githubusercontent.com/2662304/34329700-989f0f2e-e912-11e7-8ac9-c78f82cfbdb0.png) + +Note the color difference. This is because Netdata automatically hides dimensions that are just zero (the frankfurt server has only successful requests). To instruct Netdata to disable this feature, we need to add another html fragment at the bottom of the page (make sure this is added after loading `dashboard.js`). So we edit the first block we added, and append a new ` + + + + +``` + +Now they match: + +![screenshot from 2017-12-25 01-30-14](https://user-images.githubusercontent.com/2662304/34329716-2ea83680-e913-11e7-847e-52b3f402aeb0.png) + +#### more options + +If you want to change the colors append `data-colors="#001122 #334455 #667788"`. The colors will be used for the dimensions top to bottom, as shown on a Netdata dashboard. Keep in mind the default Netdata dashboards hide by default all dimensions that are just zero, so enable them at the dashboard settings to see them all. + +You can get a percentage chart, by adding these on these charts: + +```html + data-append-options="percentage" + data-decimal-digits="0" + data-dygraph-valuerange="[0, 100]" + data-dygraph-includezero="true" + data-units="%" +``` + +The first line instructs Netdata to calculate the percentage of each dimension, the second strips any fractional digits, the third instructs the charting library to size the chart from 0 to 100, the next one instructs it to include 0 in the chart and the last changes the units of the chart to `%`. This is how it will look: + +![screenshot from 2017-12-25 01-45-39](https://user-images.githubusercontent.com/2662304/34329774-570ef990-e915-11e7-899f-eee939564aaf.png) + +You can make any number of charts have common min and max on the y-range by adding `common-min="NAME"` and `common-max="NAME"`, where `NAME` is anything you like. Keep in mind for best results all the charts with the same `NAME` should be visible at once, otherwise a not-visible chart will influence the range and until it is updated the range will not adapt. + +### Add gauges + +Let's now add a few gauges. The chart we added has several dimensions: `success`, `error`, `redirect`, `bad` and `other`. + +Let's say we want to add 2 gauges: + +1. `success` and `redirect` together, in blue +2. `error`, `bad` and `other` together, in orange + +We will add the following for each server. We have enclosed them in another a `
` because Confluence will wrap them if the page width is not enough to fit them. With that additional `
` they will always be next to each other. + +```html +
+
+
+``` + +Adding the above will give you this: + +![final-confluence](https://user-images.githubusercontent.com/2662304/34329813-636bb8de-e917-11e7-8cc7-19e197859008.gif) + +### Final source - for the confluence source editor + +If you enable the source editor of Confluence, you can paste the whole example (implementing the first image on this post and demonstrating everything discussed on this page): + +```html +

Monitoring the health of the web servers, by analyzing the response codes they send.

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+
+
LondonFrankfurtSan FranciscoToronto
+ last hour +
+ requests +
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+ last
1 hour
+
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+ last 10
minutes
+
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+
+

+
+

+ +
]]> + +

+
+

+ +
+ last 1
minute
+
+
+

+
+

+ + +
+
]]>
+
+

+
+

+
+
+
+

+
+

+ + +
+
]]>
+
+

+
+

+
+
+
+

+
+

+ + +
+
]]>
+
+

+
+

+
+
+
+

+
+

+ + +
+
]]>
+
+

+
+

+
+
+ now + +
+

+
+

+ + +
+
+
+
]]> + +

+
+

+ +
+
+

+
+

+ + +
+
+
+
]]> + +

+
+

+ +
+
+

+
+

+ + +
+
+
+
]]> + +

+
+

+ +
+
+

+
+

+ + +
+
+
+
]]> + +

+
+

+ +
+

+
+

+

+
+

+ + +// don't load bootstrap - confluence does not need this +var netdataNoBootstrap = true; + +// select the web notifications to show on this dashboard +// var netdataShowAlarms = true; +// var netdataAlarmsRecipients = [ 'sysadmin', 'webmaster' ]; + + + + + +]]> + +

+
+

+
+ +
+
+
+
+ +
+
+
+``` + + diff --git a/web/gui/css/c3-0.4.18.min.css b/web/gui/css/c3-0.4.18.min.css new file mode 100644 index 00000000..a033d720 --- /dev/null +++ b/web/gui/css/c3-0.4.18.min.css @@ -0,0 +1,2 @@ +/* SPDX-License-Identifier: MIT */ +.c3 svg{font:10px sans-serif;-webkit-tap-highlight-color:transparent}.c3 line,.c3 path{fill:none;stroke:#000}.c3 text{-webkit-user-select:none;-moz-user-select:none;user-select:none}.c3-bars path,.c3-event-rect,.c3-legend-item-tile,.c3-xgrid-focus,.c3-ygrid{shape-rendering:crispEdges}.c3-chart-arc path{stroke:#fff}.c3-chart-arc text{fill:#fff;font-size:13px}.c3-grid line{stroke:#aaa}.c3-grid text{fill:#aaa}.c3-xgrid,.c3-ygrid{stroke-dasharray:3 3}.c3-text.c3-empty{fill:grey;font-size:2em}.c3-line{stroke-width:1px}.c3-circle._expanded_{stroke-width:1px;stroke:#fff}.c3-selected-circle{fill:#fff;stroke-width:2px}.c3-bar{stroke-width:0}.c3-bar._expanded_{fill-opacity:1;fill-opacity:.75}.c3-target.c3-focused{opacity:1}.c3-target.c3-focused path.c3-line,.c3-target.c3-focused path.c3-step{stroke-width:2px}.c3-target.c3-defocused{opacity:.3!important}.c3-region{fill:#4682b4;fill-opacity:.1}.c3-brush .extent{fill-opacity:.1}.c3-legend-item{font-size:12px}.c3-legend-item-hidden{opacity:.15}.c3-legend-background{opacity:.75;fill:#fff;stroke:#d3d3d3;stroke-width:1}.c3-title{font:14px sans-serif}.c3-tooltip-container{z-index:10}.c3-tooltip{border-collapse:collapse;border-spacing:0;background-color:#fff;empty-cells:show;-webkit-box-shadow:7px 7px 12px -9px #777;-moz-box-shadow:7px 7px 12px -9px #777;box-shadow:7px 7px 12px -9px #777;opacity:.9}.c3-tooltip tr{border:1px solid #ccc}.c3-tooltip th{background-color:#aaa;font-size:14px;padding:2px 5px;text-align:left;color:#fff}.c3-tooltip td{font-size:13px;padding:3px 6px;background-color:#fff;border-left:1px dotted #999}.c3-tooltip td>span{display:inline-block;width:10px;height:10px;margin-right:6px}.c3-tooltip td.value{text-align:right}.c3-area{stroke-width:0;opacity:.2}.c3-chart-arcs-title{dominant-baseline:middle;font-size:1.3em}.c3-chart-arcs .c3-chart-arcs-background{fill:#e0e0e0;stroke:none}.c3-chart-arcs .c3-chart-arcs-gauge-unit{fill:#000;font-size:16px}.c3-chart-arcs .c3-chart-arcs-gauge-max{fill:#777}.c3-chart-arcs .c3-chart-arcs-gauge-min{fill:#777}.c3-chart-arc .c3-gauge-value{fill:#000}.c3-chart-arc.c3-target g path{opacity:1}.c3-chart-arc.c3-target.c3-focused g path{opacity:1} diff --git a/web/gui/css/morris-0.5.1.css b/web/gui/css/morris-0.5.1.css new file mode 100644 index 00000000..39203d31 --- /dev/null +++ b/web/gui/css/morris-0.5.1.css @@ -0,0 +1,3 @@ +/* SPDX-License-Identifier: BSD-2-Clause */ +.morris-hover{position:absolute;z-index:1000}.morris-hover.morris-default-style{border-radius:10px;padding:6px;color:#666;background:rgba(255,255,255,0.8);border:solid 2px rgba(230,230,230,0.8);font-family:sans-serif;font-size:12px;text-align:center}.morris-hover.morris-default-style .morris-hover-row-label{font-weight:bold;margin:0.25em 0} +.morris-hover.morris-default-style .morris-hover-point{white-space:nowrap;margin:0.1em 0} diff --git a/web/gui/custom/README.md b/web/gui/custom/README.md new file mode 100644 index 00000000..2924a321 --- /dev/null +++ b/web/gui/custom/README.md @@ -0,0 +1,594 @@ +# Custom dashboards + +You can build custom Netdata dashboards just with some basic HTML knowledge. + +Custom dashboards allow you to utilize any or all of the available chart libraries, on the same dashboard. +You can use data from one or more Netdata servers, on the same dashboard and host your dashboard HTML page on +any web server, anywhere. You can also add Netdata charts to existing web pages. + +Check this **[very simple working example of a custom dashboard](http://netdata.firehol.org/demo.html)**. + +You should also look at the [custom dashboard +template](https://my-netdata.io/dashboard.html), which contains samples of all +supported charts. The code is [here](http://netdata.firehol.org/dashboard.html). + +If you plan to put the dashboard on TV, check out +[tv.html](http://netdata.firehol.org/tv.html). Here's is a screenshot of it, +monitoring two servers on the same page: + +image + + + + +## Web directory + +All of the mentioned examples are available on your local Netdata installation +(e.g. `http://myhost:19999/dashboard.html`). The default web root directory with +the HTML and JS code is `/usr/share/netdata/web`. The main dashboard is also in +that directory and called `index.html`.\ +Note: index.html has a different syntax. Don't use it as a template for simple +custom dashboards. + +> Some operating systems will use `/opt/netdata/usr/share/netdata/web` as the web directory. If you're not sure where +> yours is, navigate to `http://NODE:19999/netdata.conf` in your browser, replacing `NODE` with the IP address or hostname +> of your node, and find the `# web files directory = ` setting. The value listed is the web directory for your system. + +## Example empty dashboard + +If you need to create a new dashboard on an empty page, we suggest the following +header: + +```html + + + +  Your dashboard + +   +   +   +   +   +   + +   + + + + + + + + +``` + + +## dashboard.js + +To add Netdata charts to any web page (dedicated to Netdata or not), you need to +include the `/dashboard.js` file of a Netdata server. + +For example, if your Netdata server listens at `http://box:19999/`, you will +need to add the following to the `head` section of your web page: + +```html + +``` + +### What does dashboard.js do? + +`dashboard.js` will automatically load the following: + +1. `dashboard.css`, required for the Netdata charts + +2. `jquery.min.js`, (only if jQuery is not already loaded for this web page) + +3. `bootstrap.min.js` (only if Bootstrap is not already loaded) and + `bootstrap.min.css`. + + You can disable this by adding the following before loading `dashboard.js`: + +```html + +``` + +4. `jquery.nanoscroller.min.js`, required for the scrollbar of the chart + legends. + +5. `bootstrap-toggle.min.js` and `bootstrap-toggle.min.css`, required for the + settings toggle buttons. + +6. `font-awesome.min.css`, for icons. + +When `dashboard.js` loads will scan the page for elements that define charts +(see below) and immediately start refreshing them. Keep in mind more javascript +modules may be loaded (every chart library is a different javascript file, that +is loaded on first use). + +### Prevent dashboard.js from starting chart refreshes + +If your web page is not static and you plan to add charts using JavaScript, you +can tell `dashboard.js` not to start processing charts immediately after loaded, +by adding this fragment before loading it: + +```html + +``` + +The above, will inform the `dashboard.js` to load everything, but not process the web page until you tell it to. +You can tell it to start processing the page, by running this javascript code: + +```js +NETDATA.start(); +``` + +Be careful not to call the `NETDATA.start()` multiple times. Each call to this +function will spawn a new thread that will start refreshing the charts. + +If, after calling `NETDATA.start()` you need to update the page (or even get +your javascript code synchronized with `dashboard.js`), you can call (after you +loaded `dashboard.js`): + +```js +NETDATA.pause(function() { + // ok, it is paused + + // update the DOM as you wish + + // and then call this to let the charts refresh: + NETDATA.unpause(); +}); +``` + +### The default Netdata server + +`dashboard.js` will attempt to auto-detect the URL of the Netdata server it is +loaded from, and set this server as the default Netdata server for all charts. + +If you need to set any other URL as the default Netdata server for all charts +that do not specify a Netdata server, add this before loading `dashboard.js`: + +```html + +``` + + + +## Adding charts + +To add charts, you need to add a `div` for each of them. Each of these `div` +elements accept a few `data-` attributes: + +### The chart unique ID + +The unique ID of a chart is shown at the title of the chart of the default +Netdata dashboard. You can also find all the charts available at your Netdata +server with this URL: `http://your.netdata.server:19999/api/v1/charts` +([example](http://netdata.firehol.org/api/v1/charts)). + +To specify the unique id, use this: + +```html +
+``` + +The above is enough for adding a chart. It most probably have the wrong visual +settings though. Keep reading... + +### The duration of the chart + +You can specify the duration of the chart (how much time of data it will show) +using: + +```html +
+``` + +`AFTER_SECONDS` and `BEFORE_SECONDS` are numbers representing a time-frame in +seconds. + +The can be either: + +- **absolute** unix timestamps (in javascript terms, they are `new + Date().getTime() / 1000`. Using absolute timestamps you can have a chart + showing always the same time-frame. + +- **relative** number of seconds to now. To show the last 10 minutes of data, + `AFTER_SECONDS` must be `-600` (relative to now) and `BEFORE_SECONDS` must + be `0` (meaning: now). If you want the chart to auto-refresh the current + values, you need to specify **relative** values. + +### Chart sizes + +You can set the size of the chart using this: + +```html +
+``` + +`WIDTH` and `HEIGHT` can be anything CSS accepts for width and height (e.g. +percentages, pixels, etc). Keep in mind that for certain chart libraries, +`dashboard.js` may apply an aspect ratio to these. + +If you want `dashboard.js` to permanently remember (browser local storage) the +dimensions of the chart (the user may resize it), you can add: `data-id=" +SETTINGS_ID"`, where `SETTINGS_ID` is anything that will be common for this +chart across user sessions. + +### Netdata server + +Each chart can get data from a different Netdata server. You can specify the Netdata server to use for each chart using: + +```html +
+``` + +If you have ephemeral monitoring setup ([More info here](https://github.com/netdata/netdata/blob/master/streaming/README.md#monitoring-ephemeral-nodes)) and have no +direct access to the nodes dashboards, you can use the following: + +```html +
+``` + +### Chart library + +Netdata supports a number of chart libraries. The default chart library is +`dygraph`, but you can set a different chart library per chart using +`data-chart-library`: + +```html +
+``` + +Each chart library has a number of specific settings. To learn more about them, +you should investigate the documentation of the given chart library, or visit +the appropriate JavaScript file that defines the library's options. These files +are concatenated into the monolithic `dashboard.js` for deployment. + +- [Dygraph](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L2034) +- [d3](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L4095) +- [d3pie](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L3753) +- [Gauge.js](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L3065) +- [Google Charts](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L2936) +- [EasyPieChart](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L3531) +- [Peity](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L4137) +- [Sparkline](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L2779) +- [Text-only](https://github.com/netdata/netdata/blob/5b57fc441c40959514c4e2d0863be2e6a417e352/web/gui/dashboard.js#L4200) + +### Data points + +For the time-frame requested, `dashboard.js` will use the chart dimensions and +the settings of the chart library to find out how many data points it can show. + +For example, most line chart libraries are using 3 pixels per data point. If the +chart shows 10 minutes of data (600 seconds), its update frequency is 1 second, +and the chart width is 1800 pixels, then `dashboard.js` will request from the +Netdata server: 10 minutes of data, represented in 600 points, and the chart +will be refreshed per second. If the user resizes the window so that the chart +becomes 600 pixels wide, then `dashboard.js` will request the same 10 minutes of +data, represented in 200 points and the chart will be refreshed once every 3 +seconds. + +If you need the chart to show a fixed number of points, you can set the `data-points` option. Replace `DATA_POINTS` with the number of points you need: + +```html +
+``` + +You can also overwrite the pixels-per-point per chart using this: + +```html +
+``` + +Where `PIXELS_PER_POINT` is the number of pixels each data point should occupy. + +### Data grouping method + +Netdata supports **average** (the default), **sum** and **max** grouping +methods. The grouping method is used when the Netdata server is requested to +return fewer points for a time-frame, compared to the number of points +available. + +You can give it per chart, using: + +```html +
+``` + +### Changing rates + +Netdata can change the rate of charts on the fly. So a charts that shows values +**per second** can be turned to **per minute** (or any other, e.g. **per 10 +seconds**), with this: + +```html +
+``` + +The above will provide the average rate per minute (60 seconds). Use 60 for +`/minute`, 3600 for `/hour`, 86400 for `/day` (provided you have that many +data). + +- The `data-gtime` setting does not change the units of the chart. You have to + change them yourself with `data-units`. +- This works only for `data-method="average"`. +- Netdata may aggregate multiple points to satisfy the `data-points` setting. + For example, you request `per minute` but the requested number of points to + be returned are not enough to report every single minute. In this case + Netdata will sum the `per second` raw data of the database to find the `per + minute` for every single minute and then **average** them to find the + **average per minute rate of every X minutes**. So, it works as if the data + collection frequency was per minute. + +### Selecting dimensions + +By default, `dashboard.js` will show all the dimensions of the chart. You can +select specific dimensions using this: + +```html +
+``` + +Netdata supports coma (`,`) or pipe (`|`) separated [simple +patterns](https://github.com/netdata/netdata/blob/master/libnetdata/simple_pattern/README.md) for dimensions. By default it +searches for both dimension IDs and dimension NAMEs. You can control the target +of the match with: `data-append-options="match-ids"` or +`data-append-options="match-names"`. Spaces in `data-dimensions=""` are matched +in the dimension names and IDs. + +### Chart title + +You can overwrite the title of the chart using this: + +```html +
+``` + +### Chart units + +You can overwrite the units of measurement of the dimensions of the chart, using +this: + +```html +
+``` + +### Chart colors + +`dashboard.js` has an internal palette of colors for the dimensions of the +charts. You can prepend colors to it (so that your will be used first) using +this: + +```html +
+``` + +### Extracting dimension values + +`dashboard.js` can update the selected values of the chart at elements you +specify. For example, let's assume we have a chart that measures the bandwidth +of eth0, with 2 dimensions `in` and `out`. You can use this: + +```html +
+ +My eth0 interface, is receiving +and transmitting . +``` + +### Hiding the legend of a chart + +On charts that by default have a legend managed by `dashboard.js` you can remove +it, using this: + +```html +
+``` + +### API options + +You can append Netdata **[REST API v1](https://github.com/netdata/netdata/blob/master/web/api/README.md)** data options, using this: + +```html +
+``` + +A few useful options are: + +- `absolute` to show all values are absolute (i.e. turn negative dimensions to + positive) +- `percentage` to express the values as a percentage of the chart total (so, + the values of the dimensions are added, and the sum of them if expressed as + a percentage of the sum of all dimensions) +- `unaligned` to prevent Netdata from aligning the charts (e.g. when + requesting 60 seconds aggregation per point, Netdata returns chart data + aligned to XX:XX:00 to XX:XX:59 - similarly for hours, days, etc - the + `unaligned` option disables this feature) +- `match-ids` or `match-names` is used to control what `data-dimensions=` will + match. + +### Chart library performance + +`dashboard.js` measures the performance of the chart library when it renders the +charts. You can specify an element ID you want this information to be +visualized, using this: + +```html +
+ +refreshed in milliseconds! +``` + +### Syncing charts y-range + +If you give the same `data-common-max="NAME"` to 2+ charts, then all of them +will share the same max value of their y-range. If one spikes, all of them will +be aligned to have the same scale. This is done for the cpu interrupts and and +cpu softnet charts at the dashboard and also for the `gauge` and `easypiecharts` +of the Netdata home page. + +```html +
+ +
+``` + +The same functionality exists for `data-common-min`. + +### Syncing chart units + +Netdata dashboards support auto-scaling of units. So, `MB` can become `KB`, +`GB`, etc dynamically, based on the value to be shown. + +Giving the same `NAME` with `data-common-units= "NAME"`, 2+ charts can be forced +to always have the same units. + +```html +
+ +
+``` + +### Setting desired units + +Charts can be scaled to specific units with `data-desired-units=" UNITS"`. If +the dashboard can convert the units to the desired one, it will do. + +```html +
+``` + +## Chart library settings + +### Dygraph + +You can set the min and max values of the y-axis using +`data-dygraph-valuerange=" [MIN, MAX] "`. + +### EasyPieChart + +#### Value range + +You can set the max value of the chart using the following snippet: + +```html +
+``` + +Be aware that values that exceed the max value will get expanded (e.g. "41" is +still 100%). Similar for the minimum: + +```html +
+``` + +If you specify both minimum and maximum, the rendering behavior changes. Instead +of displaying the `value` based from zero, it is now based on the range that is +provided by the snippet: + +```html +
+``` + +In the first example, a value of `30`, without specifying the minimum, fills the chart bar to '75 %` (100% / 40 * 30). However, in this example the range is now `20` (40 - 20 = 20). The value `30` will fill the chart to ** '50 %`**, since it's in the middle between 20 and 40. + +This scenario is useful if you have metrics that change only within a specific range, e.g. temperatures that are very unlikely to fall out of range. In these cases it is more useful to have the chart render the values between the given min and max, to better highlight the changes within them. + +#### Negative values + +EasyPieCharts can render negative values with the following flag: +```html +
+``` +Negative values are rendered counter-clockwise. + +#### Full example with EasyPieChart + +This is a chart that displays the hotwater temperature in the given range of 40 +to 50. +```html +
+``` + +![hot water +chart](https://user-images.githubusercontent.com/12159026/28666665-a7d68ad2-72c8-11e7-9a96-f6bf9691b471.png) + diff --git a/web/gui/dashboard_info.js b/web/gui/dashboard_info.js new file mode 100644 index 00000000..d579bf71 --- /dev/null +++ b/web/gui/dashboard_info.js @@ -0,0 +1,8264 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +// Codacy declarations +/* global NETDATA */ + +var netdataDashboard = window.netdataDashboard || {}; + +// Informational content for the various sections of the GUI (menus, sections, charts, etc.) + +// ---------------------------------------------------------------------------- +// Menus + +netdataDashboard.menu = { + 'system': { + title: 'System Overview', + icon: '', + info: 'Overview of the key system metrics.' + }, + + 'services': { + title: 'systemd Services', + icon: '', + info: 'Resources utilization of systemd services. '+ + 'Netdata monitors all systemd services via '+ + 'cgroups ' + + '(the resources accounting used by containers).' + }, + + 'ap': { + title: 'Access Points', + icon: '', + info: 'Performance metrics for the access points (i.e. wireless interfaces in AP mode) found on the system.' + }, + + 'tc': { + title: 'Quality of Service', + icon: '', + info: 'Netdata collects and visualizes tc class utilization using its ' + + 'tc-helper plugin. ' + + 'If you also use FireQOS 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). QoS data collection may have a slight time difference compared to the interface ' + + '(QoS data collection uses a BASH script, so a shift in data collection of a few milliseconds ' + + 'should be justified).' + }, + + 'net': { + title: 'Network Interfaces', + icon: '', + info: '

Performance metrics for network interfaces.

'+ + '

Netdata retrieves this data reading the /proc/net/dev file and /sys/class/net/ directory.

' + }, + + 'Infiniband': { + title: 'Infiniband ports', + icon: '', + info: '

Performance and exception statistics for '+ + 'Infiniband ports. '+ + 'The individual port and hardware counter descriptions can be found in the '+ + 'Mellanox knowledge base.' + }, + + 'wireless': { + title: 'Wireless Interfaces', + icon: '', + info: 'Performance metrics for wireless interfaces.' + }, + + 'ip': { + title: 'Networking Stack', + icon: '', + info: function (os) { + if (os === "linux") + return 'Metrics for the networking stack of the system. These metrics are collected from /proc/net/netstat or attaching kprobes to kernel functions, apply to both IPv4 and IPv6 traffic and are related to operation of the kernel networking stack.'; + else + return 'Metrics for the networking stack of the system.'; + } + }, + + 'ipv4': { + title: 'IPv4 Networking', + icon: '', + info: 'Metrics for the IPv4 stack of the system. ' + + 'Internet Protocol version 4 (IPv4) is ' + + 'the fourth version of the Internet Protocol (IP). It is one of the core protocols of standards-based ' + + 'internetworking methods in the Internet. IPv4 is a connectionless protocol for use on packet-switched ' + + 'networks. It operates on a best effort delivery model, in that it does not guarantee delivery, nor does ' + + 'it assure proper sequencing or avoidance of duplicate delivery. These aspects, including data integrity, ' + + 'are addressed by an upper layer transport protocol, such as the Transmission Control Protocol (TCP).' + }, + + 'ipv6': { + title: 'IPv6 Networking', + icon: '', + info: 'Metrics for the IPv6 stack of the system. Internet Protocol version 6 (IPv6) is the most recent version of the Internet Protocol (IP), the communications protocol that provides an identification and location system for computers on networks and routes traffic across the Internet. IPv6 was developed by the Internet Engineering Task Force (IETF) to deal with the long-anticipated problem of IPv4 address exhaustion. IPv6 is intended to replace IPv4.' + }, + + 'sctp': { + title: 'SCTP Networking', + icon: '', + info: '

Stream Control Transmission Protocol (SCTP) '+ + 'is a computer network protocol which operates at the transport layer and serves a role similar to the popular '+ + 'protocols TCP and UDP. SCTP provides some of the features of both UDP and TCP: it is message-oriented like UDP '+ + 'and ensures reliable, in-sequence transport of messages with congestion control like TCP. '+ + 'It differs from those protocols by providing multi-homing and redundant paths to increase resilience and reliability.

'+ + '

Netdata collects SCTP metrics reading the /proc/net/sctp/snmp file.

' + }, + + 'ipvs': { + title: 'IP Virtual Server', + icon: '', + info: '

IPVS (IP Virtual Server) '+ + 'implements transport-layer load balancing inside the Linux kernel, so called Layer-4 switching. '+ + 'IPVS running on a host acts as a load balancer at the front of a cluster of real servers, '+ + 'it can direct requests for TCP/UDP based services to the real servers, '+ + 'and makes services of the real servers to appear as a virtual service on a single IP address.

'+ + '

Netdata collects summary statistics, reading /proc/net/ip_vs_stats. '+ + 'To display the statistics information of services and their servers, run ipvsadm -Ln --stats '+ + 'or ipvsadm -Ln --rate for the rate statistics. '+ + 'For details, see ipvsadm(8).

' + }, + + 'netfilter': { + title: 'Firewall (netfilter)', + icon: '', + info: 'Performance metrics of the netfilter components.' + }, + + 'ipfw': { + title: 'Firewall (ipfw)', + icon: '', + info: 'Counters and memory usage for the ipfw rules.' + }, + + 'cpu': { + title: 'CPUs', + icon: '', + info: 'Detailed information for each CPU of the system. A summary of the system for all CPUs can be found at the System Overview section.' + }, + + 'amdgpu': { + title: 'AMD GPUs', + icon: '', + info: 'Detailed information for each AMD GPU of the system. Temperature, fan speed, voltage and power metrics can be found at the Sensors section.' + }, + + 'mem': { + title: 'Memory', + icon: '', + info: 'Detailed information about the memory management of the system.' + }, + + 'disk': { + title: 'Disks', + icon: '', + 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 iostat -x. netdata by default prevents rendering performance charts for individual partitions and unmounted virtual disks. Disabled charts can still be enabled by configuring the relative settings in the netdata configuration file.' + }, + + 'mount': { + title: 'Mount Points', + icon: '', + info: '' + }, + + 'mdstat': { + title: 'MD arrays', + icon: '', + info: '

RAID devices are virtual devices created from two or more real block devices. '+ + 'Linux Software RAID devices are '+ + 'implemented through the md (Multiple Devices) device driver.

'+ + '

Netdata monitors the current status of MD arrays reading /proc/mdstat and '+ + '/sys/block/%s/md/mismatch_cnt files.

' + }, + + 'sensors': { + title: 'Sensors', + icon: '', + info: 'Readings of the configured system sensors.' + }, + + 'ipmi': { + title: 'IPMI', + icon: '', + info: 'The Intelligent Platform Management Interface (IPMI) is a set of computer interface specifications for an autonomous computer subsystem that provides management and monitoring capabilities independently of the host system\'s CPU, firmware (BIOS or UEFI) and operating system.' + }, + + 'samba': { + title: 'Samba', + icon: '', + info: 'Performance metrics of the Samba file share operations of this system. Samba is a implementation of Windows services, including Windows SMB protocol file shares.' + }, + + 'nfsd': { + title: 'NFS Server', + icon: '', + info: 'Performance metrics of the Network File Server. '+ + 'NFS '+ + 'is a distributed file system protocol, allowing a user on a client computer to access files over a network, '+ + 'much like local storage is accessed. '+ + 'NFS, like many other protocols, builds on the Open Network Computing Remote Procedure Call (ONC RPC) system.' + }, + + 'nfs': { + title: 'NFS Client', + icon: '', + info: 'Performance metrics of the '+ + 'NFS '+ + 'operations of this system, acting as an NFS client.' + }, + + 'zfs': { + title: 'ZFS Cache', + icon: '', + info: 'Performance metrics of the '+ + 'ZFS ARC and L2ARC. '+ + 'The following charts visualize all metrics reported by '+ + 'arcstat.py and '+ + 'arc_summary.py.' + }, + + 'zfspool': { + title: 'ZFS pools', + icon: '', + info: 'State of ZFS pools.' + }, + + 'btrfs': { + title: 'BTRFS filesystem', + icon: '', + info: 'Disk space metrics for the BTRFS filesystem.' + }, + + 'apps': { + title: 'Applications', + icon: '', + info: 'Per application statistics are collected using '+ + 'apps.plugin. '+ + 'This plugin walks through all processes and aggregates statistics for '+ + 'application groups. '+ + 'The plugin also counts the resources of exited children. '+ + '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', + icon: '', + info: 'Per user group statistics are collected using '+ + 'apps.plugin. '+ + 'This plugin walks through all processes and aggregates statistics per user group. '+ + 'The plugin also counts the resources of exited children. '+ + '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', + icon: '', + info: 'Per user statistics are collected using '+ + 'apps.plugin. '+ + 'This plugin walks through all processes and aggregates statistics per user. '+ + 'The plugin also counts the resources of exited children. '+ + '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', + icon: '', + info: 'Performance metrics for the operation of netdata itself and its plugins.' + }, + + 'aclk_test': { + title: 'ACLK Test Generator', + info: 'For internal use to perform integration testing.' + }, + + 'example': { + title: 'Example Charts', + info: 'Example charts, demonstrating the external plugin architecture.' + }, + + 'cgroup': { + title: '', + icon: '', + info: 'Container resource utilization metrics. Netdata reads this information from cgroups (abbreviated from control groups), a Linux kernel feature that limits and accounts resource usage (CPU, memory, disk I/O, network, etc.) of a collection of processes. cgroups together with namespaces (that offer isolation between processes) provide what we usually call: containers.' + }, + + 'cgqemu': { + title: '', + icon: '', + info: 'QEMU virtual machine resource utilization metrics. QEMU (short for Quick Emulator) is a free and open-source hosted hypervisor that performs hardware virtualization.' + }, + + 'docker': { + title: 'Docker', + icon: '', + info: 'Docker containers state and disk usage.' + }, + + 'ping': { + title: 'Ping', + icon: '', + info: 'Measures round-trip time and packet loss by sending ping messages to network hosts.' + }, + + 'gearman': { + title: 'Gearman', + icon: '', + info: 'Gearman is a job server that allows you to do work in parallel, to load balance processing, and to call functions between languages.' + }, + + 'ioping': { + title: 'ioping', + icon: '', + info: 'Disk latency statistics, via ioping. ioping is a program to read/write data probes from/to a disk.' + }, + + 'httpcheck': { + title: 'Http Check', + icon: '', + info: 'Web Service availability and latency monitoring using HTTP checks. This plugin is a specialized version of the port check plugin.' + }, + + 'memcached': { + title: 'memcached', + icon: '', + info: 'Performance metrics for memcached. Memcached is a general-purpose distributed memory caching system. It is often used to speed up dynamic database-driven websites by caching data and objects in RAM to reduce the number of times an external data source (such as a database or API) must be read.' + }, + + 'monit': { + title: 'monit', + icon: '', + info: 'Statuses of checks in monit. Monit is a utility for managing and monitoring processes, programs, files, directories and filesystems on a Unix system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.' + }, + + 'mysql': { + title: 'MySQL', + icon: '', + info: 'Performance metrics for mysql, the open-source relational database management system (RDBMS).' + }, + + 'nvme': { + title: 'NVMe', + icon: '', + info: 'NVMe devices SMART and health metrics. Additional information on metrics can be found in the NVM Express Base Specification.' + }, + + 'postgres': { + title: 'PostgreSQL', + icon: '', + info: 'Performance metrics for PostgreSQL, the open source object-relational database management system (ORDBMS).' + }, + + 'proxysql': { + title: 'ProxySQL', + icon: '', + info: 'Performance metrics for ProxySQL, a high-performance open-source MySQL proxy.' + }, + + 'pgbouncer': { + title: 'PgBouncer', + icon: '', + info: 'Performance metrics for PgBouncer, an open source connection pooler for PostgreSQL.' + }, + + 'redis': { + title: 'Redis', + icon: '', + info: 'Performance metrics for redis. Redis (REmote DIctionary Server) is a software project that implements data structure servers. It is open-source, networked, in-memory, and stores keys with optional durability.' + }, + + 'rethinkdbs': { + title: 'RethinkDB', + icon: '', + info: 'Performance metrics for rethinkdb. RethinkDB is the first open-source scalable database built for realtime applications' + }, + + 'retroshare': { + title: 'RetroShare', + icon: '', + info: 'Performance metrics for RetroShare. RetroShare is open source software for encrypted filesharing, serverless email, instant messaging, online chat, and BBS, based on a friend-to-friend network built on GNU Privacy Guard (GPG).' + }, + + 'riakkv': { + title: 'Riak KV', + icon: '', + info: 'Metrics for Riak KV, the distributed key-value store.' + }, + + 'ipfs': { + title: 'IPFS', + icon: '', + info: 'Performance metrics for the InterPlanetary File System (IPFS), a content-addressable, peer-to-peer hypermedia distribution protocol.' + }, + + 'phpfpm': { + title: 'PHP-FPM', + icon: '', + info: 'Performance metrics for PHP-FPM, an alternative FastCGI implementation for PHP.' + }, + + 'pihole': { + title: 'Pi-hole', + icon: '', + info: 'Metrics for Pi-hole, a black hole for Internet advertisements.' + + ' The metrics returned by Pi-Hole API is all from the last 24 hours.' + }, + + 'portcheck': { + title: 'Port Check', + icon: '', + info: 'Service availability and latency monitoring using port checks.' + }, + + 'postfix': { + title: 'postfix', + icon: '', + info: undefined + }, + + 'dovecot': { + title: 'Dovecot', + icon: '', + info: undefined + }, + + 'hddtemp': { + title: 'HDD Temp', + icon: '', + info: undefined + }, + + 'nginx': { + title: 'nginx', + icon: '', + info: undefined + }, + + 'nginxplus': { + title: 'Nginx Plus', + icon: '', + info: undefined + }, + + 'apache': { + title: 'Apache', + icon: '', + info: undefined + }, + + 'lighttpd': { + title: 'Lighttpd', + icon: '', + info: undefined + }, + + 'web_log': { + title: undefined, + icon: '', + info: 'Information extracted from a server log file. web_log plugin incrementally parses the server log file to provide, in real-time, a break down of key server performance metrics. For web servers, an extended log file format may optionally be used (for nginx and apache) offering timing information and bandwidth for both requests and responses. web_log plugin may also be configured to provide a break down of requests per URL pattern (check /etc/netdata/go.d/web_log.conf).' + }, + + 'squid': { + title: 'squid', + icon: '', + info: undefined + }, + + 'nut': { + title: 'UPS', + icon: '', + info: undefined + }, + + 'apcupsd': { + title: 'UPS', + icon: '', + info: undefined + }, + + 'snmp': { + title: 'SNMP', + icon: '', + info: undefined + }, + + 'go_expvar': { + title: 'Go - expvars', + icon: '', + info: 'Statistics about running Go applications exposed by the expvar package.' + }, + + 'chrony': { + title: 'Chrony', + icon: '', + info: 'The system’s clock performance and peers activity status.' + }, + + 'couchdb': { + icon: '', + info: 'Performance metrics for CouchDB, the open-source, JSON document-based database with an HTTP API and multi-master replication.' + }, + + 'beanstalk': { + title: 'Beanstalkd', + icon: '', + info: 'Provides statistics on the beanstalkd server and any tubes available on that server using data pulled from beanstalkc' + }, + + 'rabbitmq': { + title: 'RabbitMQ', + icon: '', + info: 'Performance data for the RabbitMQ open-source message broker.' + }, + + 'ceph': { + title: 'Ceph', + icon: '', + info: 'Provides statistics on the ceph cluster server, the open-source distributed storage system.' + }, + + 'ntpd': { + title: 'ntpd', + icon: '', + info: 'Provides statistics for the internal variables of the Network Time Protocol daemon ntpd and optional including the configured peers (if enabled in the module configuration). The module presents the performance metrics as shown by ntpq (the standard NTP query program) using NTP mode 6 UDP packets to communicate with the NTP server.' + }, + + 'spigotmc': { + title: 'Spigot MC', + icon: '', + info: 'Provides basic performance statistics for the Spigot Minecraft server.' + }, + + 'unbound': { + title: 'Unbound', + icon: '', + info: undefined + }, + + 'boinc': { + title: 'BOINC', + icon: '', + info: 'Provides task counts for BOINC distributed computing clients.' + }, + + 'w1sensor': { + title: '1-Wire Sensors', + icon: '', + info: 'Data derived from 1-Wire sensors. Currently temperature sensors are automatically detected.' + }, + + 'logind': { + title: 'Logind', + icon: '', + info: 'Keeps track of user logins and sessions by querying the systemd-logind API.' + }, + + 'powersupply': { + title: 'Power Supply', + icon: '', + info: 'Statistics for the various system power supplies. Data collected from Linux power supply class.' + }, + + 'xenstat': { + title: 'Xen Node', + icon: '', + info: 'General statistics for the Xen node. Data collected using xenstat library.' + }, + + 'xendomain': { + title: '', + icon: '', + info: 'Xen domain resource utilization metrics. Netdata reads this information using xenstat library which gives access to the resource usage information (CPU, memory, disk I/O, network) for a virtual machine.' + }, + + 'windows': { + title: 'Windows', + icon: '', + info: undefined + }, + + 'iis': { + title: 'IIS', + icon: '', + info: undefined + }, + + 'mssql': { + title: 'MS SQL Server', + icon: '', + info: undefined + }, + + 'ad': { + title: 'AD Domain Service', + icon: '', + info: undefined + }, + + 'adcs': { + title: 'AD Certification Service', + icon: '', + info: undefined + }, + + 'adfs': { + title: 'AD Federation Service', + icon: '', + info: undefined + }, + + 'netframework': { + title: '.NET Framework', + icon: '', + info: undefined + }, + + 'perf': { + title: 'Perf Counters', + icon: '', + info: 'Performance Monitoring Counters (PMC). Data collected using perf_event_open() system call which utilises Hardware Performance Monitoring Units (PMU).' + }, + + 'vsphere': { + title: 'vSphere', + icon: '', + info: 'Performance statistics for ESXI hosts and virtual machines. Data collected from VMware vCenter Server using govmomi library.' + }, + + 'vcsa': { + title: 'VCSA', + icon: '', + info: 'vCenter Server Appliance health statistics. Data collected from Health API.' + }, + + 'zookeeper': { + title: 'Zookeeper', + icon: '', + info: 'Provides health statistics for Zookeeper server. Data collected through the command port using mntr command.' + }, + + 'hdfs': { + title: 'HDFS', + icon: '', + info: 'Provides Hadoop Distributed File System performance statistics. Module collects metrics over Java Management Extensions through the web interface of an HDFS daemon.' + }, + + 'am2320': { + title: 'AM2320 Sensor', + icon: '', + info: 'Readings from the external AM2320 Sensor.' + }, + + 'scaleio': { + title: 'ScaleIO', + icon: '', + info: 'Performance and health statistics for various ScaleIO components. Data collected via VxFlex OS Gateway REST API.' + }, + + 'squidlog': { + title: 'Squid log', + icon: '', + info: undefined + }, + + 'cockroachdb': { + title: 'CockroachDB', + icon: '', + info: 'Performance and health statistics for various CockroachDB components.' + }, + + 'ebpf': { + title: 'eBPF', + icon: '', + info: 'Monitor system calls, internal functions, bytes read, bytes written and errors using eBPF.' + }, + + 'filesystem': { + title: 'Filesystem', + icon: '', + info: 'Number of filesystem events for Virtual File System, File Access, Directory cache, and file system latency (BTRFS, EXT4, NFS, XFS, and ZFS) when your disk has the file system. Filesystem charts have relationship with SWAP, Disk, Sync, and Mount Points.' + }, + + 'vernemq': { + title: 'VerneMQ', + icon: '', + info: 'Performance data for the VerneMQ open-source MQTT broker.' + }, + + 'pulsar': { + title: 'Pulsar', + icon: '', + info: 'Summary, namespaces and topics performance data for the Apache Pulsar pub-sub messaging system.' + }, + + 'anomalies': { + title: 'Anomalies', + icon: '', + info: 'Anomaly scores relating to key system metrics. A high anomaly probability indicates strange behaviour and may trigger an anomaly prediction from the trained models. Read the anomalies collector docs for more details.' + }, + + 'alarms': { + title: 'Alarms', + icon: '', + info: 'Charts showing alarm status over time. More details here.' + }, + + 'statsd': { + title: 'StatsD', + icon: '', + info:'StatsD is an industry-standard technology stack for monitoring applications and instrumenting any piece of software to deliver custom metrics. Netdata allows the user to organize the metrics in different charts and visualize any application metric easily. Read more on Netdata Learn.' + }, + + 'supervisord': { + title: 'Supervisord', + icon: '', + info: 'Detailed statistics for each group of processes controlled by Supervisor. ' + + 'Netdata collects these metrics using getAllProcessInfo method.' + }, + + 'systemdunits': { + title: 'systemd units', + icon: '', + info: 'systemd provides a dependency system between various entities called "units" of 11 different types. ' + + 'Units encapsulate various objects that are relevant for system boot-up and maintenance. ' + + 'Units may be active (meaning started, bound, plugged in, depending on the unit type), ' + + 'or inactive (meaning stopped, unbound, unplugged), ' + + 'as well as in the process of being activated or deactivated, i.e. between the two states (these states are called activating, deactivating). ' + + 'A special failed state is available as well, which is very similar to inactive and is entered when the service failed in some way (process returned error code on exit, or crashed, an operation timed out, or after too many restarts). ' + + 'For details, see systemd(1).' + }, + + 'changefinder': { + title: 'ChangeFinder', + icon: '', + info: 'Online changepoint detection using machine learning. More details here.' + }, + + 'zscores': { + title: 'Z-Scores', + icon: '', + info: 'Z scores scores relating to key system metrics.' + }, + + 'anomaly_detection': { + title: 'Anomaly Detection', + icon: '', + info: 'Charts relating to anomaly detection, increased anomalous dimensions or a higher than usual anomaly_rate could be signs of some abnormal behaviour. Read our anomaly detection guide for more details.' + }, + + 'fail2ban': { + title: 'Fail2ban', + icon: '', + info: 'Netdata keeps track of the current jail status by reading the Fail2ban log file.' + }, + + 'wireguard': { + title: 'WireGuard', + icon: '', + info: 'VPN network interfaces and peers traffic.' + }, + + 'pandas': { + icon: '' + }, + + 'cassandra': { + title: 'Cassandra', + icon: '', + info: 'Performance metrics for Cassandra, the open source distributed NoSQL database management system' + }, + + 'consul': { + title: 'Consul', + icon: '', + info: 'Consul performance and health metrics. For details, see Key Metrics.' + }, + + 'kmsg Logs': { + title: 'kmsg Logs', + icon: '', + info: 'Metrics extracted from log messages collected from the Kernel log buffer. For details, see the Fluent Bit Kernel Logs plugin.' + }, + + 'Systemd Logs': { + title: 'Systemd Logs', + icon: '', + info: 'Metrics extracted from log messages collected from the Journald daemon. For details, see the Fluent Bit Systemd plugin.' + }, + + 'docker_events_logs': { + title: 'Docker Events Logs', + icon: '', + info: 'Docker server events metrics. For details, see the Fluent Bit Docker Events plugin ' + + 'and the official Docker Events documentation.' + }, + + 'Apache access.log': { + title: 'Apache access.log', + icon: '', + info: 'Performance metrics exctracted from the Apache server access.log. If Go plugins are enabled, see also the web log apache collector.' + }, + + 'Nginx access.log': { + title: 'Nginx access.log', + icon: '', + info: 'Performance metrics exctracted from the Nginx server access.log. If Go plugins are enabled, see also the web log nginx collector.' + }, + + 'Netdata error.log': { + title: 'Netdata error.log', + icon: '', + info: 'Metrics extracted from Netdata\'s error.log.' + }, + + 'Netdata fluentbit.log': { + title: 'Netdata fluentbit.log', + icon: '', + info: 'Metrics extracted from Netdata\'s embedded Fluent Bit logs.' + } +}; + + +// ---------------------------------------------------------------------------- +// submenus + +// information to be shown, just below each submenu + +// information about the submenus +netdataDashboard.submenu = { + 'web_log.squid_bandwidth': { + title: 'bandwidth', + info: 'Bandwidth of responses (sent) by squid. This chart may present unusual spikes, since the bandwidth is accounted at the time the log line is saved by the server, even if the time needed to serve it spans across a longer duration. We suggest to use QoS (e.g. FireQOS) for accurate accounting of the server bandwidth.' + }, + + 'web_log.squid_responses': { + title: 'responses', + info: 'Information related to the responses sent by squid.' + }, + + 'web_log.squid_requests': { + title: 'requests', + info: 'Information related to the requests squid has received.' + }, + + 'web_log.squid_hierarchy': { + title: 'hierarchy', + info: 'Performance metrics for the squid hierarchy used to serve the requests.' + }, + + 'web_log.squid_squid_transport': { + title: 'transport' + }, + + 'web_log.squid_squid_cache': { + title: 'cache', + info: 'Performance metrics for the performance of the squid cache.' + }, + + 'web_log.squid_timings': { + title: 'timings', + info: 'Duration of squid requests. Unrealistic spikes may be reported, since squid logs the total time of the requests, when they complete. Especially for HTTPS, the clients get a tunnel from the proxy and exchange requests directly with the upstream servers, so squid cannot evaluate the individual requests and reports the total time the tunnel was open.' + }, + + 'web_log.squid_clients': { + title: 'clients' + }, + + 'web_log.bandwidth': { + info: 'Bandwidth of requests (received) and responses (sent). received requires an extended log format (without it, the web server log does not have this information). This chart may present unusual spikes, since the bandwidth is accounted at the time the log line is saved by the web server, even if the time needed to serve it spans across a longer duration. We suggest to use QoS (e.g. FireQOS) for accurate accounting of the web server bandwidth.' + }, + + 'web_log.urls': { + info: 'Number of requests for each URL pattern defined in /etc/netdata/go.d/web_log.conf. This chart counts all requests matching the URL patterns defined, independently of the web server response codes (i.e. both successful and unsuccessful).' + }, + + 'web_log.clients': { + info: 'Charts showing the number of unique client IPs, accessing the web server.' + }, + + 'web_log.timings': { + info: 'Web server response timings - the time the web server needed to prepare and respond to requests. This requires an extended log format and its meaning is web server specific. For most web servers this accounts the time from the reception of a complete request, to the dispatch of the last byte of the response. So, it includes the network delays of responses, but it does not include the network delays of requests.' + }, + + 'mem.ksm': { + title: 'deduper (ksm)', + info: 'Kernel Same-page Merging '+ + '(KSM) performance monitoring, read from several files in /sys/kernel/mm/ksm/. '+ + 'KSM is a memory-saving de-duplication feature in the Linux kernel. '+ + '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.' + }, + + 'mem.hugepages': { + info: 'Hugepages is a feature that allows the kernel to utilize the multiple page size capabilities of modern hardware architectures. The kernel creates multiple pages of virtual memory, mapped from both physical RAM and swap. There is a mechanism in the CPU architecture called "Translation Lookaside Buffers" (TLB) to manage the mapping of virtual memory pages to actual physical memory addresses. The TLB is a limited hardware resource, so utilizing a large amount of physical memory with the default page size consumes the TLB and adds processing overhead. By utilizing Huge Pages, the kernel is able to create pages of much larger sizes, each page consuming a single resource in the TLB. Huge Pages are pinned to physical RAM and cannot be swapped/paged out.' + }, + + 'mem.numa': { + info: 'Non-Uniform Memory Access (NUMA) is a hierarchical memory design the memory access time is dependent on locality. Under NUMA, a processor can access its own local memory faster than non-local memory (memory local to another processor or memory shared between processors). The individual metrics are described in the Linux kernel documentation.' + }, + + 'mem.ecc': { + info: '

ECC memory '+ + 'is a type of computer data storage that uses an error correction code (ECC) to detect '+ + 'and correct n-bit data corruption which occurs in memory. '+ + 'Typically, ECC memory maintains a memory system immune to single-bit errors: '+ + 'the data that is read from each word is always the same as the data that had been written to it, '+ + 'even if one of the bits actually stored has been flipped to the wrong state.

'+ + '

Memory errors can be classified into two types: '+ + 'Soft errors, which randomly corrupt bits but do not leave physical damage. '+ + 'Soft errors are transient in nature and are not repeatable, can be because of electrical or '+ + 'magnetic interference. '+ + 'Hard errors, which corrupt bits in a repeatable manner because '+ + 'of a physical/hardware defect or an environmental problem.' + }, + + 'mem.pagetype': { + info: 'Statistics of free memory available from '+ + 'memory buddy allocator. '+ + 'The buddy allocator is the system memory allocator. '+ + 'The whole memory space is split in physical pages, which are grouped by '+ + 'NUMA node, zone, '+ + 'migrate type, and size of the block. '+ + 'By keeping pages grouped based on their ability to move, '+ + 'the kernel can reclaim pages within a page block to satisfy a high-order allocation. '+ + 'When the kernel or an application requests some memory, the buddy allocator provides a page that matches closest the request.' + }, + + 'mem.fragmentation': { + info: 'These charts show whether the kernel will compact memory or direct reclaim to satisfy a high-order allocation. '+ + 'The extfrag/extfrag_index file in debugfs shows what the fragmentation index for each order is in each zone in the system.' + + 'Values tending towards 0 imply allocations would fail due to lack of memory, values towards 1000 imply failures are due to ' + + 'fragmentation and -1 implies that the allocation will succeed as long as watermarks are met.' + }, + + 'system.zswap': { + info : 'Zswap is a backend for frontswap that takes pages that are in the process of being swapped out and attempts to compress and store them in a ' + + 'RAM-based memory pool. This can result in a significant I/O reduction on the swap device and, in the case where decompressing from RAM is faster ' + + 'than reading from the swap device, can also improve workload performance.' + }, + + 'ip.ecn': { + info: 'Explicit Congestion Notification (ECN) '+ + 'is an extension to the IP and to the TCP that allows end-to-end notification of network congestion without dropping packets. '+ + 'ECN is an optional feature that may be used between two ECN-enabled endpoints when '+ + 'the underlying network infrastructure also supports it.' + }, + + 'ip.multicast': { + info: 'IP multicast is a technique for '+ + 'one-to-many communication over an IP network. '+ + 'Multicast uses network infrastructure efficiently by requiring the source to send a packet only once, '+ + 'even if it needs to be delivered to a large number of receivers. '+ + 'The nodes in the network take care of replicating the packet to reach multiple receivers only when necessary.' + }, + 'ip.broadcast': { + info: 'In computer networking, '+ + 'broadcasting refers to transmitting a packet that will be received by every device on the network. '+ + 'In practice, the scope of the broadcast is limited to a broadcast domain.' + }, + + 'netfilter.conntrack': { + title: 'connection tracker', + info: 'Netfilter Connection Tracker performance metrics. 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 nfacct.plugin.' + }, + + 'netfilter.synproxy': { + title: 'DDoS protection', + info: 'DDoS protection performance metrics. SYNPROXY '+ + '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. '+ + 'SYNPROXY intercepts new TCP connections and handles the initial 3-way handshake using syncookies '+ + 'instead of conntrack to establish the connection. '+ + '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.' + }, + + 'ipfw.dynamic_rules': { + title: 'dynamic rules', + info: 'Number of dynamic rules, created by correspondent stateful firewall rules.' + }, + + 'system.softnet_stat': { + title: 'softnet', + info: function (os) { + if (os === 'linux') + return '

Statistics for CPUs SoftIRQs related to network receive work. '+ + 'Break down per CPU core can be found at CPU / softnet statistics. '+ + 'More information about identifying and troubleshooting network driver related issues can be found at '+ + 'Red Hat Enterprise Linux Network Performance Tuning Guide.

'+ + '

Processed - packets processed. '+ + 'Dropped - packets dropped because the network device backlog was full. '+ + 'Squeezed - number of times the network device budget was consumed or the time limit was reached, '+ + 'but more work was available. '+ + 'ReceivedRPS - number of times this CPU has been woken up to process packets via an Inter-processor Interrupt. '+ + 'FlowLimitCount - number of times the flow limit has been reached (flow limiting is an optional '+ + 'Receive Packet Steering feature).

'; + else + return 'Statistics for CPUs SoftIRQs related to network receive work.'; + } + }, + + 'system.clock synchronization': { + info: 'NTP '+ + 'lets you automatically sync your system time with a remote server. '+ + 'This keeps your machine’s time accurate by syncing with servers that are known to have accurate times.' + }, + + 'cpu.softnet_stat': { + title: 'softnet', + info: function (os) { + if (os === 'linux') + return '

Statistics for CPUs SoftIRQs related to network receive work. '+ + 'Total for all CPU cores can be found at System / softnet statistics. '+ + 'More information about identifying and troubleshooting network driver related issues can be found at '+ + 'Red Hat Enterprise Linux Network Performance Tuning Guide.

'+ + '

Processed - packets processed. '+ + 'Dropped - packets dropped because the network device backlog was full. '+ + 'Squeezed - number of times the network device budget was consumed or the time limit was reached, '+ + 'but more work was available. '+ + 'ReceivedRPS - number of times this CPU has been woken up to process packets via an Inter-processor Interrupt. '+ + 'FlowLimitCount - number of times the flow limit has been reached (flow limiting is an optional '+ + 'Receive Packet Steering feature).

'; + else + return 'Statistics for per CPUs core SoftIRQs related to network receive work. Total for all CPU cores can be found at System / softnet statistics.'; + } + }, + + 'go_expvar.memstats': { + title: 'memory statistics', + info: 'Go runtime memory statistics. See runtime.MemStats documentation for more info about each chart and the values.' + }, + + 'couchdb.dbactivity': { + title: 'db activity', + info: 'Overall database reads and writes for the entire server. This includes any external HTTP traffic, as well as internal replication traffic performed in a cluster to ensure node consistency.' + }, + + 'couchdb.httptraffic': { + title: 'http traffic breakdown', + info: 'All HTTP traffic, broken down by type of request (GET, PUT, POST, etc.) and response status code (200, 201, 4xx, etc.)

Any 5xx errors here indicate a likely CouchDB bug; check the logfile for further information.' + }, + + 'couchdb.ops': { + title: 'server operations' + }, + + 'couchdb.perdbstats': { + title: 'per db statistics', + info: 'Statistics per database. This includes 3 size graphs per database: active (the size of live data in the database), external (the uncompressed size of the database contents), and file (the size of the file on disk, exclusive of any views and indexes). It also includes the number of documents and number of deleted documents per database.' + }, + + 'couchdb.erlang': { + title: 'erlang statistics', + info: 'Detailed information about the status of the Erlang VM that hosts CouchDB. These are intended for advanced users only. High values of the peak message queue (>10e6) generally indicate an overload condition.' + }, + + 'ntpd.system': { + title: 'system', + info: 'Statistics of the system variables as shown by the readlist billboard ntpq -c rl. System variables are assigned an association ID of zero and can also be shown in the readvar billboard ntpq -c "rv 0". These variables are used in the Clock Discipline Algorithm, to calculate the lowest and most stable offset.' + }, + + 'ntpd.peers': { + title: 'peers', + info: 'Statistics of the peer variables for each peer configured in /etc/ntp.conf as shown by the readvar billboard ntpq -c "rv <association>", while each peer is assigned a nonzero association ID as shown by ntpq -c "apeers". The module periodically scans for new/changed peers (default: every 60s). ntpd selects the best possible peer from the available peers to synchronize the clock. A minimum of at least 3 peers is required to properly identify the best possible peer.' + }, + + 'mem.page_cache': { + title: 'page cache (eBPF)', + info: 'Number of calls to functions used to manipulate the Linux page cache. This chart has a relationship with File Systems, Sync, and Hard Disk.' + }, + + 'apps.page_cache': { + title: 'page cache (eBPF)', + info: 'Netdata also gives a summary for these charts in Memory submenu.' + }, + + 'filesystem.vfs': { + title: 'vfs (eBPF)', + info: 'Number of calls to Virtual File System functions used to manipulate File Systems.' + }, + + 'apps.vfs': { + title: 'vfs (eBPF)', + info: 'Netdata also gives a summary for these charts in Filesystem submenu.' + }, + + 'filesystem.ext4_latency': { + title: 'ext4 latency (eBPF)', + info: 'Latency is the time it takes for an event to be completed. Based on the eBPF ext4dist from BCC tools. This chart is provided by the eBPF plugin to monitor File systems.' + }, + + 'filesystem.xfs_latency': { + title: 'xfs latency (eBPF)', + info: 'Latency is the time it takes for an event to be completed. Based on the xfsdist from BCC tools. This chart is provided by the eBPF plugin to monitor File systems.' + }, + + 'filesystem.nfs_latency': { + title: 'nfs latency (eBPF)', + info: 'Latency is the time it takes for an event to be completed. Based on the nfsdist from BCC tools. This chart is provided by the eBPF plugin to monitor File systems.' + }, + + 'filesystem.zfs_latency': { + title: 'zfs latency (eBPF)', + info: 'Latency is the time it takes for an event to be completed. Based on the zfsdist from BCC tools. This chart is provided by the eBPF plugin to monitor File systems.' + }, + + 'filesystem.btrfs_latency': { + title: 'btrfs latency (eBPF)', + info: 'Latency is the time it takes for an event to be completed. Based on the btrfsdist from BCC tools. This chart is provided by the eBPF plugin to monitor File systems.' + }, + + 'filesystem.file_access': { + title: 'file access (eBPF)', + }, + + 'apps.file_access': { + title: 'file access (eBPF)', + info: 'Netdata also gives a summary for this chart on Filesystem submenu (more details on eBPF plugin file chart section).' + }, + + 'ip.kernel': { + title: 'kernel functions (eBPF)', + }, + + 'apps.net': { + title: 'network', + info: 'Netdata also gives a summary for eBPF charts in Networking Stack submenu.' + }, + + 'system.ipc semaphores': { + info: 'System V semaphores is an inter-process communication (IPC) mechanism. '+ + 'It allows processes or threads within a process to synchronize their actions. '+ + 'They are often used to monitor and control the availability of system resources such as shared memory segments. ' + + 'For details, see svipc(7). ' + + 'To see the host IPC semaphore information, run ipcs -us. For limits, run ipcs -ls.' + }, + + 'system.ipc shared memory': { + info: 'System V shared memory is an inter-process communication (IPC) mechanism. '+ + 'It allows processes to communicate information by sharing a region of memory. '+ + 'It is the fastest form of inter-process communication available since no kernel involvement occurs when data is passed between the processes (no copying). '+ + 'Typically, processes must synchronize their access to a shared memory object, using, for example, POSIX semaphores. '+ + 'For details, see svipc(7). '+ + 'To see the host IPC shared memory information, run ipcs -um. For limits, run ipcs -lm.' + }, + + 'system.ipc message queues': { + info: 'System V message queues is an inter-process communication (IPC) mechanism. '+ + 'It allow processes to exchange data in the form of messages. '+ + 'For details, see svipc(7). ' + + 'To see the host IPC messages information, run ipcs -uq. For limits, run ipcs -lq.' + }, + + 'system.interrupts': { + info: 'Interrupts are signals '+ + 'sent to the CPU by external devices (normally I/O devices) or programs (running processes). '+ + 'They tell the CPU to stop its current activities and execute the appropriate part of the operating system. '+ + 'Interrupt types are '+ + 'hardware (generated by hardware devices to signal that they need some attention from the OS), '+ + 'software (generated by programs when they want to request a system call to be performed by the operating system), and '+ + 'traps (generated by the CPU itself to indicate that some error or condition occurred for which assistance from the operating system is needed).' + }, + + 'system.softirqs': { + info: 'Software interrupts (or "softirqs") are one of the oldest deferred-execution mechanisms in the kernel. '+ + 'Several tasks among those executed by the kernel are not critical: '+ + 'they can be deferred for a long period of time, if necessary. '+ + 'The deferrable tasks can execute with all interrupts enabled '+ + '(softirqs are patterned after hardware interrupts). '+ + 'Taking them out of the interrupt handler helps keep kernel response time small.' + }, + + 'cpu.softirqs': { + info: 'Total number of software interrupts per CPU. '+ + 'To see the total number for the system check the softirqs section.' + }, + + 'cpu.interrupts': { + info: 'Total number of interrupts per CPU. '+ + 'To see the total number for the system check the interrupts section. '+ + 'The last column in /proc/interrupts provides an interrupt description or the device name that registered the handler for that interrupt.' + }, + + 'cpu.throttling': { + info: ' CPU throttling is commonly used to automatically slow down the computer '+ + 'when possible to use less energy and conserve battery.' + }, + + 'cpu.cpuidle': { + info: 'Idle States (C-states) '+ + 'are used to save power when the processor is idle.' + }, + + 'services.net': { + title: 'network (eBPF)', + }, + + 'services.page_cache': { + title: 'pache cache (eBPF)', + }, + + 'netdata.ebpf': { + title: 'eBPF.plugin', + info: 'eBPF (extended Berkeley Packet Filter) is used to collect metrics from inside Linux kernel giving a zoom inside your Process, '+ + 'Hard Disk, File systems (File Access, and ' + + 'Directory Cache), Memory (Swap I/O, Page Cache), ' + + 'IRQ (Hard IRQ and Soft IRQ ), Shared Memory, ' + + 'Syscalls (Sync, Mount), and Network.' + }, + + 'postgres.connections': { + info: 'A connection is an established line of communication between a client and the PostgreSQL server. Each connection adds to the load on the PostgreSQL server. To guard against running out of memory or overloading the database the max_connections parameter (default = 100) defines the maximum number of concurrent connections to the database server. A separate parameter, superuser_reserved_connections (default = 3), defines the quota for superuser connections (so that superusers can connect even if all other connection slots are blocked).' + }, + + 'system.power_consumption': { + info: 'The current power consumption of the zones defined by the power capping framework.' + } + +}; + +// ---------------------------------------------------------------------------- +// chart + +// information 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 cgroupCPULimitIsSet = 0; +var cgroupMemLimitIsSet = 0; + +const netBytesInfo = 'The amount of traffic transferred by the network interface.' +const netPacketsInfo = 'The number of packets transferred by the network interface. ' + + 'Received multicast counter is ' + + 'commonly calculated at the device level (unlike received) and therefore may include packets which did not reach the host.' +const netErrorsInfo = '

The number of errors encountered by the network interface.

' + + '

Inbound - bad packets received on this interface. ' + + 'It includes dropped packets due to invalid length, CRC, frame alignment, and other errors. ' + + 'Outbound - transmit problems. ' + + 'It includes frames transmission errors due to loss of carrier, FIFO underrun/underflow, heartbeat, ' + + 'late collisions, and other problems.

' +const netFIFOInfo = '

The number of FIFO errors encountered by the network interface.

' + + '

Inbound - packets dropped because they did not fit into buffers provided by the host, ' + + 'e.g. packets larger than MTU or next buffer in the ring was not available for a scatter transfer. ' + + 'Outbound - frame transmission errors due to device FIFO underrun/underflow. ' + + 'This condition occurs when the device begins transmission of a frame ' + + 'but is unable to deliver the entire frame to the transmitter in time for transmission.

' +const netDropsInfo = '

The number of packets that have been dropped at the network interface level.

' + + '

Inbound - packets received but not processed, e.g. due to ' + + 'softnet backlog overflow, bad/unintended VLAN tags, ' + + 'unknown or unregistered protocols, IPv6 frames when the server is not configured for IPv6. ' + + 'Outbound - packets dropped on their way to transmission, e.g. due to lack of resources.

' +const netCompressedInfo = 'The number of correctly transferred compressed packets by the network interface. ' + + 'These counters are only meaningful for interfaces which support packet compression (e.g. CSLIP, PPP).' +const netEventsInfo = '

The number of errors encountered by the network interface.

' + + '

Frames - aggregated counter for dropped packets due to ' + + 'invalid length, FIFO overflow, CRC, and frame alignment errors. ' + + 'Collisions - ' + + 'collisions during packet transmissions. ' + + 'Carrier - aggregated counter for frame transmission errors due to ' + + 'excessive collisions, loss of carrier, device FIFO underrun/underflow, Heartbeat/SQE Test errors, and late collisions.

' +const netDuplexInfo = '

The interface\'s latest or current ' + + 'duplex that the network adapter ' + + 'negotiated with the device it is connected to.

' + + '

Unknown - the duplex mode can not be determined. ' + + 'Half duplex - the communication is one direction at a time. ' + + 'Full duplex - the interface is able to send and receive data simultaneously.

' +const netOperstateInfo = '

The current ' + + 'operational state of the interface.

' + + '

Unknown - the state can not be determined. ' + + 'NotPresent - the interface has missing (typically, hardware) components. ' + + 'Down - the interface is unable to transfer data on L1, e.g. ethernet is not plugged or interface is administratively down. ' + + 'LowerLayerDown - the interface is down due to state of lower-layer interface(s). ' + + 'Testing - the interface is in testing mode, e.g. cable test. It can’t be used for normal traffic until tests complete. ' + + 'Dormant - the interface is L1 up, but waiting for an external event, e.g. for a protocol to establish. ' + + 'Up - the interface is ready to pass packets and can be used.

' +const netCarrierInfo = 'The current physical link state of the interface.' +const netSpeedInfo = 'The interface\'s latest or current speed that the network adapter ' + + 'negotiated with the device it is connected to. ' + + 'This does not give the max supported speed of the NIC.' +const netMTUInfo = 'The interface\'s currently configured ' + + 'Maximum transmission unit (MTU) value. ' + + 'MTU is the size of the largest protocol data unit that can be communicated in a single network layer transaction.' +// eBPF constants +const ebpfChartProvides = ' This chart is provided by the eBPF plugin.' +const ebpfProcessCreate = 'Number of times a function ' + + 'that starts a process is called. Netdata gives a summary for this chart in Process, and when the integration ' + + 'is enabled, Netdata shows process per ' + + 'application.' + ebpfChartProvides +const ebpfThreadCreate = 'Number of times a function ' + + 'that starts a thread is called. Netdata gives a summary for this chart in Process, and when the integration ' + + 'is enabled, Netdata shows process per ' + + 'application.' + ebpfChartProvides +const ebpfTaskExit = 'Number of times a function ' + + 'that responsible for closing tasks is called. Netdata gives a summary for this chart in Process, and when the integration ' + + 'is enabled, Netdata shows process per ' + + 'application.' + ebpfChartProvides +const ebpfTaskClose = 'Number of times a function ' + + 'that responsible for releasing tasks is called. Netdata gives a summary for this chart in Process, and when the integration ' + + 'is enabled, Netdata shows process per ' + + 'application.' + ebpfChartProvides +const ebpfTaskError = 'Number of errors to create a new task. Netdata gives a ' + + 'summary for this chart in Process, and when the integration is enabled, ' + + 'Netdata shows process per application.' + ebpfChartProvides +const ebpfFileOpen = 'Number of calls for internal functions on the Linux kernel responsible to open files. ' + + 'Netdata gives a summary for this chart in file access, and when the integration is ' + + 'enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfFileOpenError = 'Number of failed calls for internal functions on the Linux kernel responsible to open files. ' + + 'Netdata gives a summary for this chart in file access, and when the integration is ' + + 'enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfFileClosed = 'Number of calls for internal functions on the Linux kernel responsible to close files. ' + + 'Netdata gives a summary for this chart in file access, and when the integration is ' + + 'enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfFileCloseError = 'Number of failed calls for internal functions on the Linux kernel responsible to close files. ' + + 'Netdata gives a summary for this chart in file access, and when the integration is ' + + 'enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfDCHit = 'Percentage of file accesses that were present in the directory cache. ' + + 'Netdata gives a summary for this chart in directory cache, and when the integration is enabled, ' + + 'Netdata shows directory cache per application.' + ebpfChartProvides +const ebpfDCReference = 'Number of times a file is accessed inside directory cache. ' + + 'Netdata gives a summary for this chart in directory cache, and when the integration is enabled, ' + + 'Netdata shows directory cache per application.' + ebpfChartProvides +const ebpfDCNotCache = 'Number of times a file is accessed in the file system, because it is not present inside the directory cache. ' + + 'Netdata gives a summary for this chart in directory cache, and when the integration is enabled, ' + + 'Netdata shows directory cache per application.' + ebpfChartProvides +const ebpfDCNotFound = 'Number of times a file was not found on the file system. Netdata gives a summary for this chart in directory cache, ' + + 'and when the integration is enabled, ' + + 'Netdata shows directory cache per application.' + ebpfChartProvides +const ebpfVFSWrite = 'Number of successful calls to VFS writer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSRead = 'Number of successful calls to VFS reader function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSWriteError = 'Number of failed calls to VFS writer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSReadError = 'Number of failed calls to VFS reader function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSWriteBytes = 'Total of bytes successfully written using the VFS writer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSReadBytes = 'Total of bytes successfully read using the VFS reader function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSUnlink = 'Number of calls to VFS unlinker function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSSync = 'Number of calls to VFS syncer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSSyncError = 'Number of failed calls to VFS syncer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSOpen = 'Number of calls to VFS opener function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSOpenError = 'Number of failed calls to VFS opener function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSCreate = 'Number of calls to VFS creator function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfVFSCreateError = 'Number of failed calls to VFS creator function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per application.' + ebpfChartProvides +const ebpfSwapRead = 'Number of failed calls to swap reader function. Netdata gives a summary for this chart in ' + + 'System Overview, and when the integration is enabled, ' + + 'Netdata shows swap per application.' + ebpfChartProvides +const ebpfSwapWrite = 'Number of failed calls to swap writer function. Netdata gives a summary for this chart in ' + + 'System Overview, and when the integration is enabled, ' + + 'Netdata shows swap per application.' + ebpfChartProvides +const ebpfCachestatRatio = 'The ratio shows the percentage of data accessed directly in memory. ' + + 'Netdata gives a summary for this chart in Memory, and when the integration is enabled, ' + + 'Netdata shows page cache hit per application.' + ebpfChartProvides +const ebpfCachestatDirties = 'Number of modified pages in Linux page cache. ' + + 'Netdata gives a summary for this chart in Memory, and when the integration is enabled, ' + + 'Netdata shows page cache hit per application.' + ebpfChartProvides +const ebpfCachestatHits = 'Number of access to data in Linux page cache. ' + + 'Netdata gives a summary for this chart in Memory, and when the integration is enabled, ' + + 'Netdata shows page cache hit per application.' + ebpfChartProvides +const ebpfCachestatMisses = 'Number of access to data was not present in Linux page cache. ' + + 'Netdata gives a summary for this chart in Memory, and when the integration is enabled, ' + + 'Netdata shows page cache misses per application.' + ebpfChartProvides +const ebpfSHMget = 'Number of calls to shmget. Netdata gives a summary for this chart in System Overview, and when the integration is ' + + 'enabled, Netdata shows shared memory metrics per application.' + ebpfChartProvides +const ebpfSHMat = 'Number of calls to shmat. Netdata gives a summary for this chart in System Overview, and when the integration is ' + + 'enabled, Netdata shows shared memory metrics per application.' + ebpfChartProvides +const ebpfSHMctl = 'Number of calls to shmctl. Netdata gives a summary for this chart in System Overview, and when the integration is ' + + 'enabled, Netdata shows shared memory metrics per application.' + ebpfChartProvides +const ebpfSHMdt = 'Number of calls to shmdt. Netdata gives a summary for this chart in System Overview, and when the integration is ' + + 'enabled, Netdata shows shared memory metrics per application.' + ebpfChartProvides +const ebpfIPV4conn = 'Number of calls to IPV4 TCP function responsible for starting connections. ' + + 'Netdata gives a summary for this chart in Network Stack. When the integration is enabled, ' + + 'Netdata shows outbound connections per application.' + ebpfChartProvides +const ebpfIPV6conn = 'Number of calls to IPV6 TCP function responsible for starting connections. ' + + 'Netdata gives a summary for this chart in Network Stack. When the integration is enabled, ' + + 'Netdata shows outbound connections per application.' + ebpfChartProvides +const ebpfBandwidthSent = 'Total bytes sent with TCP or UDP internal functions. ' + + 'Netdata gives a summary for this chart in Network Stack. When the integration is enabled, ' + + 'Netdata shows bandwidth per application.' + ebpfChartProvides +const ebpfBandwidthRecv = 'Total bytes received with TCP or UDP internal functions. ' + + 'Netdata gives a summary for this chart in Network Stack. When the integration is enabled, ' + + 'Netdata shows bandwidth per application.' + ebpfChartProvides +const ebpfTCPSendCall = 'Number of calls to TCP functions responsible to send data. ' + + 'Netdata gives a summary for this chart in Network Stack. ' + + 'When the integration is enabled, Netdata shows TCP calls per application.' + ebpfChartProvides +const ebpfTCPRecvCall = 'Number of calls to TCP functions responsible to receive data. ' + + 'Netdata gives a summary for this chart in Network Stack. ' + + 'When the integration is enabled, ' + + 'Netdata shows TCP calls per application.' + ebpfChartProvides +const ebpfTCPRetransmit = 'Number of times a TCP packet was retransmitted. ' + + 'Netdata gives a summary for this chart in Network Stack. ' + + 'When the integration is enabled, Netdata shows TCP calls per application.' + ebpfChartProvides +const ebpfUDPsend = 'Number of calls to UDP functions responsible to send data. ' + + 'Netdata gives a summary for this chart in Network Stack. ' + + 'When the integration is enabled, Netdata shows UDP calls per application.' + ebpfChartProvides +const ebpfUDPrecv = 'Number of calls to UDP functions responsible to receive data. ' + + 'Netdata gives a summary for this chart in Network Stack. ' + + 'When the integration is enabled, Netdata shows UDP calls per application.' + ebpfChartProvides + +const cgroupCPULimit = 'Total CPU utilization within the configured or system-wide (if not set) limits. When the CPU utilization of a cgroup exceeds the limit for the configured period, the tasks belonging to its hierarchy will be throttled and are not allowed to run again until the next period.' +const cgroupCPU = 'Total CPU utilization within the system-wide CPU resources (all cores). The amount of time spent by tasks of the cgroup in user and kernel modes.' +const cgroupThrottled = 'The percentage of runnable periods when tasks in a cgroup have been throttled. The tasks have not been allowed to run because they have exhausted all of the available time as specified by their CPU quota.' +const cgroupThrottledDuration = 'The total time duration for which tasks in a cgroup have been throttled. When an application has used its allotted CPU quota for a given period, it gets throttled until the next period.' +const cgroupCPUShared = '

The weight of each group living in the same hierarchy, that translates into the amount of CPU it is expected to get. The percentage of CPU assigned to the cgroup is the value of shares divided by the sum of all shares in all cgroups in the same level.

For example, tasks in two cgroups that have cpu.shares set to 100 will receive equal CPU time, but tasks in a cgroup that has cpu.shares set to 200 receive twice the CPU time of tasks in a cgroup where cpu.shares is set to 100.

' +const cgroupCPUPerCore = 'Total CPU utilization per core within the system-wide CPU resources.' +const cgroupCPUSomePressure = 'CPU Pressure Stall Information. Some indicates the share of time in which at least some tasks are stalled on CPU. The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' +const cgroupCPUSomePressureStallTime = 'The amount of time some processes have been waiting for CPU time.' +const cgroupCPUFullPressure = 'CPU Pressure Stall Information. Full indicates the share of time in which all non-idle tasks are stalled on CPU resource simultaneously. The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' +const cgroupCPUFullPressureStallTime = 'The amount of time all non-idle processes have been stalled due to CPU congestion.' + +const cgroupMemUtilization = 'RAM utilization within the configured or system-wide (if not set) limits. When the RAM utilization of a cgroup exceeds the limit, OOM killer will start killing the tasks belonging to the cgroup.' +const cgroupMemUsageLimit = 'RAM usage within the configured or system-wide (if not set) limits. When the RAM usage of a cgroup exceeds the limit, OOM killer will start killing the tasks belonging to the cgroup.' +const cgroupMemUsage = 'The amount of used RAM and swap memory.' +const cgroupMem = 'Memory usage statistics. The individual metrics are described in the memory.stat section for cgroup-v1 and cgroup-v2.' +const cgroupMemFailCnt = 'The number of memory usage hits limits.' +const cgroupWriteback = 'Dirty is the amount of memory waiting to be written to disk. Writeback is how much memory is actively being written to disk.' +const cgroupMemActivity = '

Memory accounting statistics.

In - a page is accounted as either mapped anon page (RSS) or cache page (Page Cache) to the cgroup. Out - a page is unaccounted from the cgroup.

' +const cgroupPgFaults = '

Memory page fault statistics.

Pgfault - all page faults. Swap - major page faults.

' +const cgroupMemorySomePressure = 'Memory Pressure Stall Information. Some indicates the share of time in which at least some tasks are stalled on memory. In this state the CPU is still doing productive work. The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' +const cgroupMemorySomePressureStallTime = 'The amount of time some processes have been waiting due to memory congestion.' +const cgroupMemoryFullPressure = 'Memory Pressure Stall Information. Full indicates the share of time in which all non-idle tasks are stalled on memory resource simultaneously. In this state actual CPU cycles are going to waste, and a workload that spends extended time in this state is considered to be thrashing. This has severe impact on performance. The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' +const cgroupMemoryFullPressureStallTime = 'The amount of time all non-idle processes have been stalled due to memory congestion.' + +const cgroupIO = 'The amount of data transferred to and from specific devices as seen by the CFQ scheduler. It is not updated when the CFQ scheduler is operating on a request queue.' +const cgroupServicedOps = 'The number of I/O operations performed on specific devices as seen by the CFQ scheduler.' +const cgroupQueuedOps = 'The number of requests queued for I/O operations.' +const cgroupMergedOps = 'The number of BIOS requests merged into requests for I/O operations.' +const cgroupThrottleIO = 'The amount of data transferred to and from specific devices as seen by the throttling policy.' +const cgroupThrottleIOServicesOps = 'The number of I/O operations performed on specific devices as seen by the throttling policy.' +const cgroupIOSomePressure = 'I/O Pressure Stall Information. Some indicates the share of time in which at least some tasks are stalled on I/O. In this state the CPU is still doing productive work. The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' +const cgroupIOSomePRessureStallTime = 'The amount of time some processes have been waiting due to I/O congestion.' +const cgroupIOFullPressure = 'I/O Pressure Stall Information. Full line indicates the share of time in which all non-idle tasks are stalled on I/O resource simultaneously. In this state actual CPU cycles are going to waste, and a workload that spends extended time in this state is considered to be thrashing. This has severe impact on performance. The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' +const cgroupIOFullPressureStallTime = 'The amount of time all non-idle processes have been stalled due to I/O congestion.' + +netdataDashboard.context = { + 'system.cpu': { + info: function (os) { + void (os); + return 'Total CPU utilization (all cores). 100% here means there is no CPU idle time at all. You can get per core usage at the CPUs section and per application usage at the Applications Monitoring section.' + + netdataDashboard.sparkline('
Keep an eye on iowait ', 'system.cpu', 'iowait', '%', '. If it is constantly high, your disks are a bottleneck and they slow your system down.') + + netdataDashboard.sparkline( + '
An important metric worth monitoring, is softirq ', + 'system.cpu', + 'softirq', + '%', + '. A constantly high percentage of softirq may indicate network driver issues. '+ + 'The individual metrics can be found in the '+ + 'kernel documentation.'); + }, + valueRange: "[0, 100]" + }, + + '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. The system calculates this once every 5 seconds. For more information check this wikipedia article.', + height: 0.7 + }, + + 'system.cpu_some_pressure': { + info: 'CPU Pressure Stall Information. '+ + 'Some indicates the share of time in which at least some tasks are stalled on CPU. ' + + 'The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' + }, + 'system.cpu_some_pressure_stall_time': { + info: 'The amount of time some processes have been waiting for CPU time.' + }, + 'system.cpu_full_pressure': { + info: 'CPU Pressure Stall Information. ' + + 'Full indicates the share of time in which all non-idle tasks are stalled on CPU resource simultaneously. ' + + 'The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' + }, + 'system.cpu_full_pressure_stall_time': { + info: 'The amount of time all non-idle processes have been stalled due to CPU congestion.' + }, + + 'system.memory_some_pressure': { + info: 'Memory Pressure Stall Information. '+ + 'Some indicates the share of time in which at least some tasks are stalled on memory. ' + + 'In this state the CPU is still doing productive work. '+ + 'The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' + }, + 'system.memory_some_pressure_stall_time': { + info: 'The amount of time some processes have been waiting due to memory congestion.' + }, + 'system.memory_full_pressure': { + info: 'Memory Pressure Stall Information. ' + + 'Full indicates the share of time in which all non-idle tasks are stalled on memory resource simultaneously. ' + + 'In this state actual CPU cycles are going to waste, and a workload that spends extended time in this state is considered to be thrashing. '+ + 'This has severe impact on performance. '+ + 'The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' + }, + 'system.memory_full_pressure_stall_time': { + info: 'The amount of time all non-idle processes have been stalled due to memory congestion.' + }, + + 'system.io_some_pressure': { + info: 'I/O Pressure Stall Information. '+ + 'Some indicates the share of time in which at least some tasks are stalled on I/O. ' + + 'In this state the CPU is still doing productive work. '+ + 'The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' + }, + 'system.io_some_pressure_stall_time': { + info: 'The amount of time some processes have been waiting due to I/O congestion.' + }, + 'system.io_full_pressure': { + info: 'I/O Pressure Stall Information. ' + + 'Full line indicates the share of time in which all non-idle tasks are stalled on I/O resource simultaneously. ' + + 'In this state actual CPU cycles are going to waste, and a workload that spends extended time in this state is considered to be thrashing. '+ + 'This has severe impact on performance. '+ + 'The ratios are tracked as recent trends over 10-, 60-, and 300-second windows.' + }, + 'system.io_full_pressure_stall_time': { + info: 'The amount of time all non-idle processes have been stalled due to I/O congestion.' + }, + + 'system.io': { + info: function (os) { + var s = 'Total Disk I/O, for all physical disks. You can get detailed information about each disk at the Disks section and per application Disk usage at the Applications Monitoring section.'; + + if (os === 'linux') + return s + ' Physical are all the disks that are listed in /sys/block, but do not exist in /sys/devices/virtual/block.'; + else + return s; + } + }, + + 'system.pgpgio': { + info: 'Memory paged from/to disk. This is usually the total disk I/O of the system.' + }, + + 'mem.swapio': { + info: '

System swap I/O.

'+ + 'In - pages the system has swapped in from disk to RAM. '+ + 'Out - pages the system has swapped out from RAM to disk.' + }, + + 'system.pgfaults': { + info: 'Total page faults. Major page faults indicates that the system is using its swap. You can find which applications use the swap at the Applications Monitoring section.' + }, + + 'system.entropy': { + colors: '#CC22AA', + info: 'Entropy, is a pool of random numbers (/dev/random) that is mainly used in cryptography. If the pool of entropy gets empty, processes requiring random numbers may run a lot slower (it depends on the interface each program uses), waiting for the pool to be replenished. Ideally a system with high entropy demands should have a hardware device for that purpose (TPM is one such device). There are also several software-only options you may install, like haveged, although these are generally useful only in servers.' + }, + + 'system.zswap_rejections': { + info: '

Zswap rejected pages per access.

' + + '

CompressPoor - compressed page was too big for the allocator to store. ' + + 'KmemcacheFail - number of entry metadata that could not be allocated. ' + + 'AllocFail - allocator could not get memory. ' + + 'ReclaimFail - memory cannot be reclaimed (pool limit was reached).

' + }, + + 'system.clock_sync_state': { + info:'

The system clock synchronization state as provided by the ntp_adjtime() system call. '+ + 'An unsynchronized clock may be the result of synchronization issues by the NTP daemon or a hardware clock fault. '+ + 'It can take several minutes (usually up to 17) before NTP daemon selects a server to synchronize with. '+ + '

State map: 0 - not synchronized, 1 - synchronized.

' + }, + + 'system.clock_status': { + info:'

The kernel code can operate in various modes and with various features enabled or disabled, as selected by the '+ + 'ntp_adjtime() system call. '+ + 'The system clock status shows the value of the time_status variable in the kernel. '+ + 'The bits of the variable are used to control these functions and record error conditions as they exist.

'+ + '

UNSYNC - set/cleared by the caller to indicate clock unsynchronized (e.g., when no peers are reachable). '+ + 'This flag is usually controlled by an application program, but the operating system may also set it. '+ + 'CLOCKERR - set/cleared by the external hardware clock driver to indicate hardware fault.

'+ + '

Status map: 0 - bit unset, 1 - bit set.

' + }, + + 'system.clock_sync_offset': { + info: 'A typical NTP client regularly polls one or more NTP servers. '+ + 'The client must compute its '+ + 'time offset '+ + 'and round-trip delay. '+ + 'Time offset is the difference in absolute time between the two clocks.' + }, + + 'system.forks': { + colors: '#5555DD', + info: 'The number of new processes created.' + }, + + 'system.intr': { + colors: '#DD5555', + info: 'Total number of CPU interrupts. Check system.interrupts that gives more detail about each interrupt and also the CPUs section where interrupts are analyzed per CPU core.' + }, + + 'system.interrupts': { + info: 'CPU interrupts in detail. At the CPUs section, interrupts are analyzed per CPU core. '+ + 'The last column in /proc/interrupts provides an interrupt description or the device name that registered the handler for that interrupt.' + }, + + 'system.hardirq_latency': { + info: 'Total time spent servicing hardware interrupts. Based on the eBPF hardirqs from BCC tools.' + ebpfChartProvides + '
' + }, + + 'system.softirqs': { + info: '

Total number of software interrupts in the system. '+ + 'At the CPUs section, softirqs are analyzed per CPU core.

'+ + '

HI - high priority tasklets. '+ + 'TIMER - tasklets related to timer interrupts. '+ + 'NET_TX, NET_RX - used for network transmit and receive processing. '+ + 'BLOCK - handles block I/O completion events. '+ + 'IRQ_POLL - used by the IO subsystem to increase performance (a NAPI like approach for block devices). '+ + 'TASKLET - handles regular tasklets. '+ + 'SCHED - used by the scheduler to perform load-balancing and other scheduling tasks. '+ + 'HRTIMER - used for high-resolution timers. '+ + 'RCU - performs read-copy-update (RCU) processing.

' + + }, + + 'system.softirq_latency': { + info: 'Total time spent servicing software interrupts. Based on the eBPF softirqs from BCC tools.' + ebpfChartProvides + '
' + }, + + 'system.processes': { + info: '

System processes.

'+ + '

Running - running or ready to run (runnable). '+ + 'Blocked - currently blocked, waiting for I/O to complete.

' + }, + + 'system.processes_state': { + info: '

The number of processes in different states.

'+ + '

Running - Process using the CPU at a particular moment. '+ + 'Sleeping (uninterruptible) - Process will wake when a waited-upon resource becomes available or after a time-out occurs during that wait. '+ + 'Mostly used by device drivers waiting for disk or network I/O. '+ + 'Sleeping (interruptible) - Process is waiting either for a particular time slot or for a particular event to occur. '+ + 'Zombie - Process that has completed its execution, released the system resources, but its entry is not removed from the process table. '+ + 'Usually occurs in child processes when the parent process still needs to read its child’s exit status. '+ + 'A process that stays a zombie for a long time is generally an error and causes system PID space leak. '+ + 'Stopped - Process is suspended from proceeding further due to STOP or TSTP signals. ' + + 'In this state, a process will not do anything (not even terminate) until it receives a CONT signal.

' + }, + + 'system.active_processes': { + info: 'The total number of processes in the system.' + }, + + 'system.ctxt': { + info: 'Context Switches, 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': { + 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 idle jitter. This number is useful in real-time environments, where CPU jitter can affect the quality of the service (like VoIP media gateways).' + }, + + 'system.net': { + info: function (os) { + var s = 'Total bandwidth of all physical network interfaces. This does not include lo, VPNs, network bridges, IFB devices, bond interfaces, etc. Only the bandwidth of physical network interfaces is aggregated.'; + + if (os === 'linux') + return s + ' Physical are all the network interfaces that are listed in /proc/net/dev, but do not exist in /sys/devices/virtual/net.'; + else + return s; + } + }, + + 'system.ip': { + info: 'Total IP traffic in the system.' + }, + + 'system.ipv4': { + info: 'Total IPv4 Traffic.' + }, + + 'system.ipv6': { + info: 'Total IPv6 Traffic.' + }, + + 'system.ram': { + info: 'System Random Access Memory (i.e. physical memory) usage.' + }, + + 'mem.swap': { + info: 'System swap memory usage. Swap space is used when the amount of physical memory (RAM) is full. When the system needs more memory resources and the RAM is full, inactive pages in memory are moved to the swap space (usually a disk, a disk partition or a file).' + }, + + 'system.swapcalls': { + info: 'Number of calls to functions used to manipulate swap data. Netdata shows swap metrics per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'system.ipc_semaphores': { + info: 'Number of allocated System V IPC semaphores. '+ + 'The system-wide limit on the number of semaphores in all semaphore sets is specified in /proc/sys/kernel/sem file (2nd field).' + }, + + 'system.ipc_semaphore_arrays': { + info: 'Number of used System V IPC semaphore arrays (sets). Semaphores support semaphore sets where each one is a counting semaphore. '+ + 'So when an application requests semaphores, the kernel releases them in sets. '+ + 'The system-wide limit on the maximum number of semaphore sets is specified in /proc/sys/kernel/sem file (4th field).' + }, + + 'system.shared_memory_segments': { + info: 'Number of allocated System V IPC memory segments. '+ + 'The system-wide maximum number of shared memory segments that can be created is specified in /proc/sys/kernel/shmmni file.' + }, + + 'system.shared_memory_bytes': { + info: 'Amount of memory currently used by System V IPC memory segments. '+ + 'The run-time limit on the maximum shared memory segment size that can be created is specified in /proc/sys/kernel/shmmax file.' + }, + + 'system.shared_memory_calls': { + info: 'Number of calls to syscalls responsible to manipulate shared memories. Netdata shows shared memory metrics per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'system.message_queue_messages': { + info: 'Number of messages that are currently present in System V IPC message queues.' + }, + + 'system.message_queue_bytes': { + info: 'Amount of memory currently used by messages in System V IPC message queues.' + }, + + 'system.uptime': { + info: 'The amount of time the system has been running, including time spent in suspend.' + }, + + 'system.process_thread': { + title : 'Task creation', + info: 'Number of times a function that starts a process or thread is called. Netdata shows process metrics per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'system.exit': { + title : 'Exit monitoring', + info: 'Number of times a function responsible to close a process or thread is called. Netdata shows process metrics per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'system.task_error': { + title : 'Task error', + info: 'Number of times a function that starts a process or thread failed. Netdata shows process metrics per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'system.process_status': { + title : 'Task status', + info: 'Difference between the number of calls to functions that close a task and release a task.'+ ebpfChartProvides + }, + + 'system.power_consumption': { + info: 'The current power consumption of the zones defined by the power capping framework.' + }, + + // ------------------------------------------------------------------------ + // CPU charts + + 'cpu.cpu': { + commonMin: true, + commonMax: true, + valueRange: "[0, 100]" + }, + + 'cpu.interrupts': { + commonMin: true, + commonMax: true + }, + + 'cpu.softirqs': { + commonMin: true, + commonMax: true + }, + + 'cpu.softnet_stat': { + commonMin: true, + commonMax: true + }, + + 'cpu.core_throttling': { + info: 'The number of adjustments made to the clock speed of the CPU based on it\'s core temperature.' + }, + + 'cpu.package_throttling': { + info: 'The number of adjustments made to the clock speed of the CPU based on it\'s package (chip) temperature.' + }, + + 'cpufreq.cpufreq': { + info: 'The frequency measures the number of cycles your CPU executes per second.' + }, + + 'cpuidle.cpuidle': { + info: 'The percentage of time spent in C-states.' + }, + + // ------------------------------------------------------------------------ + // MEMORY + + 'mem.ksm': { + info: '

Memory pages merging statistics. '+ + 'A high ratio of Sharing to Shared indicates good sharing, '+ + 'but a high ratio of Unshared to Sharing indicates wasted effort.

'+ + '

Shared - used shared pages. '+ + 'Unshared - memory no longer shared (pages are unique but repeatedly checked for merging). '+ + 'Sharing - memory currently shared (how many more sites are sharing the pages, i.e. how much saved). '+ + 'Volatile - volatile pages (changing too fast to be placed in a tree).

' + }, + + 'mem.ksm_savings': { + heads: [ + netdataDashboard.gaugeChart('Saved', '12%', 'savings', '#0099CC') + ], + info: '

The amount of memory saved by KSM.

'+ + '

Savings - saved memory. '+ + 'Offered - memory marked as mergeable.

' + }, + + 'mem.ksm_ratios': { + heads: [ + function (os, id) { + void (os); + return '
'; + } + ], + info: 'The effectiveness of KSM. '+ + 'This is the percentage of the mergeable pages that are currently merged.' + }, + + 'mem.zram_usage': { + info: 'ZRAM total RAM usage metrics. ZRAM uses some memory to store metadata about stored memory pages, thus introducing an overhead which is proportional to disk size. It excludes same-element-filled-pages since no memory is allocated for them.' + }, + + 'mem.zram_savings': { + info: 'Displays original and compressed memory data sizes.' + }, + + 'mem.zram_ratio': { + heads: [ + netdataDashboard.gaugeChart('Compression Ratio', '12%', 'ratio', '#0099CC') + ], + info: 'Compression ratio, calculated as 100 * original_size / compressed_size. More means better compression and more RAM savings.' + }, + + 'mem.zram_efficiency': { + heads: [ + netdataDashboard.gaugeChart('Efficiency', '12%', 'percent', NETDATA.colors[0]) + ], + commonMin: true, + commonMax: true, + valueRange: "[0, 100]", + info: 'Memory usage efficiency, calculated as 100 * compressed_size / total_mem_used.' + }, + + + 'mem.pgfaults': { + info: '

A page fault is a type of interrupt, '+ + 'called trap, raised by computer hardware when a running program accesses a memory page '+ + 'that is mapped into the virtual address space, but not actually loaded into main memory.

'+ + '

Minor - the page is loaded in memory at the time the fault is generated, '+ + 'but is not marked in the memory management unit as being loaded in memory. '+ + 'Major - generated when the system needs to load the memory page from disk or swap memory.

' + }, + + 'mem.committed': { + colors: NETDATA.colors[3], + info: 'Committed Memory, is the sum of all memory which has been allocated by processes.' + }, + + 'mem.real': { + colors: NETDATA.colors[3], + info: 'Total amount of real (physical) memory used.' + }, + + 'mem.oom_kill': { + info: 'The number of processes killed by '+ + 'Out of Memory Killer. '+ + 'The kernel\'s OOM killer is summoned when the system runs short of free memory and '+ + 'is unable to proceed without killing one or more processes. '+ + 'It tries to pick the process whose demise will free the most memory while '+ + 'causing the least misery for users of the system. '+ + 'This counter also includes processes within containers that have exceeded the memory limit.' + }, + + 'mem.numa': { + info: '

NUMA balancing statistics.

'+ + '

Local - pages successfully allocated on this node, by a process on this node. '+ + 'Foreign - pages initially intended for this node that were allocated to another node instead. '+ + 'Interleave - interleave policy pages successfully allocated to this node. '+ + 'Other - pages allocated on this node, by a process on another node. '+ + 'PteUpdates - base pages that were marked for NUMA hinting faults. '+ + 'HugePteUpdates - transparent huge pages that were marked for NUMA hinting faults. '+ + 'In Combination with pte_updates the total address space that was marked can be calculated. '+ + 'HintFaults - NUMA hinting faults that were trapped. '+ + 'HintFaultsLocal - hinting faults that were to local nodes. '+ + 'In combination with HintFaults, the percentage of local versus remote faults can be calculated. '+ + 'A high percentage of local hinting faults indicates that the workload is closer to being converged. '+ + 'PagesMigrated - pages were migrated because they were misplaced. '+ + 'As migration is a copying operation, it contributes the largest part of the overhead created by NUMA balancing.

' + }, + + 'mem.available': { + info: function (os) { + if (os === "freebsd") + return 'The amount of memory that can be used by user-space processes without causing swapping. Calculated as the sum of free, cached, and inactive memory.'; + else + return 'Available Memory is estimated by the kernel, as the amount of RAM that can be used by userspace processes, without causing swapping.'; + } + }, + + 'mem.writeback': { + info: 'Dirty is the amount of memory waiting to be written to disk. Writeback is how much memory is actively being written to disk.' + }, + + 'mem.kernel': { + info: '

The total amount of memory being used by the kernel.

'+ + '

Slab - used by the kernel to cache data structures for its own use. '+ + 'KernelStack - allocated for each task done by the kernel. '+ + 'PageTables - dedicated to the lowest level of page tables (A page table is used to turn a virtual address into a physical memory address). '+ + 'VmallocUsed - being used as virtual address space. '+ + 'Percpu - allocated to the per-CPU allocator used to back per-CPU allocations (excludes the cost of metadata). '+ + 'When you create a per-CPU variable, each processor on the system gets its own copy of that variable.

' + }, + + 'mem.slab': { + info: '

Slab memory statistics.

'+ + '

Reclaimable - amount of memory which the kernel can reuse. '+ + 'Unreclaimable - can not be reused even when the kernel is lacking memory.

' + }, + + 'mem.hugepages': { + info: 'Dedicated (or Direct) HugePages is memory reserved for applications configured to utilize huge pages. Hugepages are used memory, even if there are free hugepages available.' + }, + + 'mem.transparent_hugepages': { + info: 'Transparent HugePages (THP) is backing virtual memory with huge pages, supporting automatic promotion and demotion of page sizes. It works for all applications for anonymous memory mappings and tmpfs/shmem.' + }, + + 'mem.hwcorrupt': { + info: 'The amount of memory with physical corruption problems, identified by ECC and set aside by the kernel so it does not get used.' + }, + + 'mem.ecc_ce': { + info: 'The number of correctable (single-bit) ECC errors. '+ + 'These errors do not affect the normal operation of the system '+ + 'because they are still being corrected. '+ + 'Periodic correctable errors may indicate that one of the memory modules is slowly failing.' + }, + + 'mem.ecc_ue': { + info: 'The number of uncorrectable (multi-bit) ECC errors. '+ + 'An uncorrectable error is a fatal issue that will typically lead to an OS crash.' + }, + + 'mem.pagetype_global': { + info: 'The amount of memory available in blocks of certain size.' + }, + + 'mem.cachestat_ratio': { + info: 'The ratio shows the percentage of data accessed directly in memory. Netdata shows the ratio per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + }, + + 'mem.cachestat_dirties': { + info: 'Number of modified pages in Linux page cache. Netdata shows the dity page application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'mem.cachestat_hits': { + info: 'Number of access to data in Linux page cache. Netdata shows the hits per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'mem.cachestat_misses': { + info: 'Number of access to data that was not present in Linux page cache. Netdata shows the missed access per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'mem.sync': { + info: 'Number of calls to syscalls that sync filesystem metadata or cached. This chart has a relationship with File systems and Linux Page Cache.' + ebpfChartProvides + }, + + 'mem.file_sync': { + info: 'Number of calls to syscalls responsible to transfer modified Linux page cache to disk. This chart has a relationship with File systems and Linux Page Cache.' + ebpfChartProvides + }, + + 'mem.memory_map': { + info: 'Number of calls to syscall responsible to the in-core copy of a file that was mapped. This chart has a relationship with File systems and Linux Page Cache.' + ebpfChartProvides + }, + + 'mem.file_segment': { + info: 'Number of calls to syscall responsible to sync file segments. This chart has a relationship with File systems and Linux Page Cache.' + ebpfChartProvides + }, + + 'filesystem.dc_hit_ratio': { + info: 'Percentage of file accesses that were present in the directory cache. Netdata shows directory cache metrics per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'filesystem.dc_reference': { + info: 'Counters of file accesses. Reference is when there is a file access and the file is not present in the directory cache. Miss is when there is file access and the file is not found in the filesystem. Slow is when there is a file access and the file is present in the filesystem but not in the directory cache. Netdata shows directory cache metrics per application and cgroup (systemd Services) if apps or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'md.health': { + info: 'Number of failed devices per MD array. '+ + 'Netdata retrieves this data from the [n/m] field of the md status line. '+ + 'It means that ideally the array would have n devices however, currently, m devices are in use. '+ + 'failed disks is n-m.' + }, + 'md.disks': { + info: 'Number of devices in use and in the down state. '+ + 'Netdata retrieves this data from the [n/m] field of the md status line. '+ + 'It means that ideally the array would have n devices however, currently, m devices are in use. '+ + 'inuse is m, down is n-m.' + }, + 'md.status': { + info: 'Completion progress of the ongoing operation.' + }, + 'md.expected_time_until_operation_finish': { + info: 'Estimated time to complete the ongoing operation. '+ + 'The time is only an approximation since the operation speed will vary according to other I/O demands.' + }, + 'md.operation_speed': { + info: 'Speed of the ongoing operation. '+ + 'The system-wide rebuild speed limits are specified in /proc/sys/dev/raid/{speed_limit_min,speed_limit_max} files. '+ + 'These options are good for tweaking rebuilt process and may increase overall system load, cpu and memory usage.' + }, + 'md.mismatch_cnt': { + info: 'When performing check and repair, and possibly when performing resync, md will count the number of errors that are found. '+ + 'A count of mismatches is recorded in the sysfs file md/mismatch_cnt. '+ + 'This value is the number of sectors that were re-written, or (for check) would have been re-written. '+ + 'It may be larger than the number of actual errors by a factor of the number of sectors in a page. '+ + 'Mismatches can not be interpreted very reliably on RAID1 or RAID10, especially when the device is used for swap. '+ + 'On a truly clean RAID5 or RAID6 array, any mismatches should indicate a hardware problem at some level - '+ + 'software issues should never cause such a mismatch. '+ + 'For details, see md(4).' + }, + 'md.flush': { + info: 'Number of flush counts per MD array. Based on the eBPF mdflush from BCC tools.' + }, + + // ------------------------------------------------------------------------ + // IP + + 'ip.inerrors': { + info: '

The number of errors encountered during the reception of IP packets.

' + + '

NoRoutes - packets that were dropped because there was no route to send them. ' + + 'Truncated - packets which is being discarded because the datagram frame didn\'t carry enough data. ' + + 'Checksum - packets that were dropped because they had wrong checksum.

' + }, + + 'ip.mcast': { + info: 'Total multicast traffic in the system.' + }, + + 'ip.mcastpkts': { + info: 'Total transferred multicast packets in the system.' + }, + + 'ip.bcast': { + info: 'Total broadcast traffic in the system.' + }, + + 'ip.bcastpkts': { + info: 'Total transferred broadcast packets in the system.' + }, + + 'ip.ecnpkts': { + info: '

Total number of received IP packets with ECN bits set in the system.

'+ + '

CEP - congestion encountered. '+ + 'NoECTP - non ECN-capable transport. '+ + 'ECTP0 and ECTP1 - ECN capable transport.

' + }, + + 'ip.inbound_conn': { + info: 'Number of calls to functions responsible for receiving connections.' + ebpfChartProvides + }, + + 'ip.tcp_outbound_conn': { + info: 'Number of calls to TCP functions responsible for starting connections. ' + + 'Netdata shows TCP outbound connections metrics per application and cgroup (systemd Services) if ' + + 'apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'ip.tcp_functions': { + info: 'Number of calls to TCP functions responsible for exchanging data. ' + + 'Netdata shows TCP outbound connections metrics per application and cgroup (systemd Services) if ' + + 'apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'ip.total_tcp_bandwidth': { + info: 'Total bytes sent and received with TCP internal functions. ' + + 'Netdata shows TCP bandwidth metrics per application and cgroup (systemd Services) if ' + + 'apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'ip.tcp_error': { + info: 'Number of failed calls to TCP functions responsible for TCP bandwidth. ' + + 'Netdata shows TCP error per application and cgroup (systemd Services) if ' + + 'apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'ip.tcp_retransmit': { + info: 'Number of times a TCP packet was retransmitted. ' + + 'Netdata shows TCP retransmit per application and cgroup (systemd Services) if ' + + 'apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'ip.udp_functions': { + info: 'Number of calls to UDP functions responsible for exchanging data. ' + + 'Netdata shows TCP outbound connections metrics per application and cgroup (systemd Services) if ' + + 'apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'ip.total_udp_bandwidth': { + info: 'Total bytes sent and received with UDP internal functions. ' + + 'Netdata shows UDP bandwidth metrics per application and cgroup (systemd Services) if ' + + 'apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'ip.udp_error': { + info: 'Number of failed calls to UDP functions responsible for UDP bandwidth. ' + + 'Netdata shows UDP error per application and cgroup (systemd Services) if ' + + 'apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + '
' + }, + + 'ip.tcpreorders': { + info: '

TCP prevents out-of-order packets by either sequencing them in the correct order or '+ + 'by requesting the retransmission of out-of-order packets.

'+ + '

Timestamp - detected re-ordering using the timestamp option. '+ + 'SACK - detected re-ordering using Selective Acknowledgment algorithm. '+ + 'FACK - detected re-ordering using Forward Acknowledgment algorithm. '+ + 'Reno - detected re-ordering using Fast Retransmit algorithm.

' + }, + + 'ip.tcpofo': { + info: '

TCP maintains an out-of-order queue to keep the out-of-order packets in the TCP communication.

'+ + '

InQueue - the TCP layer receives an out-of-order packet and has enough memory to queue it. '+ + 'Dropped - the TCP layer receives an out-of-order packet but does not have enough memory, so drops it. '+ + 'Merged - the received out-of-order packet has an overlay with the previous packet. '+ + 'The overlay part will be dropped. All these packets will also be counted into InQueue. '+ + 'Pruned - packets dropped from out-of-order queue because of socket buffer overrun.

' + }, + + 'ip.tcpsyncookies': { + info: '

SYN cookies '+ + 'are used to mitigate SYN flood.

'+ + '

Received - after sending a SYN cookie, it came back to us and passed the check. '+ + 'Sent - an application was not able to accept a connection fast enough, so the kernel could not store '+ + 'an entry in the queue for this connection. Instead of dropping it, it sent a SYN cookie to the client. '+ + 'Failed - the MSS decoded from the SYN cookie is invalid. When this counter is incremented, '+ + 'the received packet won’t be treated as a SYN cookie.

' + }, + + 'ip.tcpmemorypressures': { + info: 'The number of times a socket was put in memory pressure due to a non fatal memory allocation failure '+ + '(the kernel attempts to work around this situation by reducing the send buffers, etc).' + }, + + 'ip.tcpconnaborts': { + info: '

TCP connection aborts.

'+ + '

BadData - happens while the connection is on FIN_WAIT1 and the kernel receives a packet '+ + 'with a sequence number beyond the last one for this connection - '+ + 'the kernel responds with RST (closes the connection). '+ + 'UserClosed - happens when the kernel receives data on an already closed connection and '+ + 'responds with RST. '+ + 'NoMemory - happens when there are too many orphaned sockets (not attached to an fd) and '+ + 'the kernel has to drop a connection - sometimes it will send an RST, sometimes it won\'t. '+ + 'Timeout - happens when a connection times out. '+ + 'Linger - happens when the kernel killed a socket that was already closed by the application and '+ + 'lingered around for long enough. '+ + 'Failed - happens when the kernel attempted to send an RST but failed because there was no memory available.

' + }, + + 'ip.tcp_syn_queue': { + info: '

The SYN queue of the kernel tracks TCP handshakes until connections get fully established. ' + + 'It overflows when too many incoming TCP connection requests hang in the half-open state and the server ' + + 'is not configured to fall back to SYN cookies. Overflows are usually caused by SYN flood DoS attacks.

' + + '

Drops - number of connections dropped because the SYN queue was full and SYN cookies were disabled. ' + + 'Cookies - number of SYN cookies sent because the SYN queue was full.

' + }, + + 'ip.tcp_accept_queue': { + info: '

The accept queue of the kernel holds the fully established TCP connections, waiting to be handled ' + + 'by the listening application.

'+ + 'Overflows - the number of established connections that could not be handled because '+ + 'the receive queue of the listening application was full. '+ + 'Drops - number of incoming connections that could not be handled, including SYN floods, '+ + 'overflows, out of memory, security issues, no route to destination, reception of related ICMP messages, '+ + 'socket is broadcast or multicast.

' + }, + + + // ------------------------------------------------------------------------ + // IPv4 + + 'ipv4.packets': { + info: '

IPv4 packets statistics for this host.

'+ + '

Received - packets received by the IP layer. '+ + 'This counter will be increased even if the packet is dropped later. '+ + 'Sent - packets sent via IP layer, for both single cast and multicast packets. '+ + 'This counter does not include any packets counted in Forwarded. '+ + 'Forwarded - input packets for which this host was not their final IP destination, '+ + 'as a result of which an attempt was made to find a route to forward them to that final destination. '+ + 'In hosts which do not act as IP Gateways, this counter will include only those packets which were '+ + 'Source-Routed '+ + 'and the Source-Route option processing was successful. '+ + 'Delivered - packets delivered to the upper layer protocols, e.g. TCP, UDP, ICMP, and so on.

' + }, + + 'ipv4.fragsout': { + info: '

IPv4 fragmentation '+ + 'statistics for this system.

'+ + '

OK - packets that have been successfully fragmented. '+ + 'Failed - packets that have been discarded because they needed to be fragmented '+ + 'but could not be, e.g. due to Don\'t Fragment (DF) flag was set. '+ + 'Created - fragments that have been generated as a result of fragmentation.

' + }, + + 'ipv4.fragsin': { + info: '

IPv4 reassembly '+ + 'statistics for this system.

'+ + '

OK - packets that have been successfully reassembled. '+ + 'Failed - failures detected by the IP reassembly algorithm. '+ + 'This is not necessarily a count of discarded IP fragments since some algorithms '+ + 'can lose track of the number of fragments by combining them as they are received. '+ + 'All - received IP fragments which needed to be reassembled.

' + }, + + 'ipv4.errors': { + info: '

The number of discarded IPv4 packets.

'+ + '

InDiscards, OutDiscards - inbound and outbound packets which were chosen '+ + 'to be discarded even though no errors had been '+ + 'detected to prevent their being deliverable to a higher-layer protocol. '+ + 'InHdrErrors - input packets that have been discarded due to errors in their IP headers, including '+ + 'bad checksums, version number mismatch, other format errors, time-to-live exceeded, '+ + 'errors discovered in processing their IP options, etc. '+ + 'OutNoRoutes - packets that have been discarded because no route could be found '+ + 'to transmit them to their destination. This includes any packets which a host cannot route '+ + 'because all of its default gateways are down. '+ + 'InAddrErrors - input packets that have been discarded due to invalid IP address or '+ + 'the destination IP address is not a local address and IP forwarding is not enabled. '+ + 'InUnknownProtos - input packets which were discarded because of an unknown or unsupported protocol.

' + }, + + 'ipv4.icmp': { + info: '

The number of transferred IPv4 ICMP messages.

'+ + '

Received, Sent - ICMP messages which the host received and attempted to send. '+ + 'Both these counters include errors.

' + }, + + 'ipv4.icmp_errors': { + info: '

The number of IPv4 ICMP errors.

'+ + '

InErrors - received ICMP messages but determined as having ICMP-specific errors, '+ + 'e.g. bad ICMP checksums, bad length, etc. '+ + 'OutErrors - ICMP messages which this host did not send due to '+ + 'problems discovered within ICMP such as a lack of buffers. '+ + 'This counter does not include errors discovered outside the ICMP layer '+ + 'such as the inability of IP to route the resultant datagram. '+ + 'InCsumErrors - received ICMP messages with bad checksum.

' + }, + + 'ipv4.icmpmsg': { + info: 'The number of transferred '+ + 'IPv4 ICMP control messages.' + }, + + 'ipv4.udppackets': { + info: 'The number of transferred UDP packets.' + }, + + 'ipv4.udperrors': { + info: '

The number of errors encountered during transferring UDP packets.

'+ + 'RcvbufErrors - receive buffer is full. '+ + 'SndbufErrors - send buffer is full, no kernel memory available, or '+ + 'the IP layer reported an error when trying to send the packet and no error queue has been setup. '+ + 'InErrors - that is an aggregated counter for all errors, excluding NoPorts. '+ + 'NoPorts - no application is listening at the destination port. '+ + 'InCsumErrors - a UDP checksum failure is detected. '+ + 'IgnoredMulti - ignored multicast packets.' + }, + + 'ipv4.udplite': { + info: 'The number of transferred UDP-Lite packets.' + }, + + 'ipv4.udplite_errors': { + info: '

The number of errors encountered during transferring UDP-Lite packets.

'+ + 'RcvbufErrors - receive buffer is full. '+ + 'SndbufErrors - send buffer is full, no kernel memory available, or '+ + 'the IP layer reported an error when trying to send the packet and no error queue has been setup. '+ + 'InErrors - that is an aggregated counter for all errors, excluding NoPorts. '+ + 'NoPorts - no application is listening at the destination port. '+ + 'InCsumErrors - a UDP checksum failure is detected. '+ + 'IgnoredMulti - ignored multicast packets.' + }, + + 'ipv4.tcppackets': { + info: '

The number of packets transferred by the TCP layer.

'+ + '

Received - received packets, including those received in error, '+ + 'such as checksum error, invalid TCP header, and so on. '+ + 'Sent - sent packets, excluding the retransmitted packets. '+ + 'But it includes the SYN, ACK, and RST packets.

' + }, + + 'ipv4.tcpsock': { + info: 'The number of TCP connections for which the current state is either ESTABLISHED or CLOSE-WAIT. '+ + 'This is a snapshot of the established connections at the time of measurement '+ + '(i.e. a connection established and a connection disconnected within the same iteration will not affect this metric).' + }, + + 'ipv4.tcpopens': { + info: '

TCP connection statistics.

'+ + '

Active - number of outgoing TCP connections attempted by this host. '+ + 'Passive - number of incoming TCP connections accepted by this host.

' + }, + + 'ipv4.tcperrors': { + info: '

TCP errors.

'+ + '

InErrs - TCP segments received in error '+ + '(including header too small, checksum errors, sequence errors, bad packets - for both IPv4 and IPv6). '+ + 'InCsumErrors - TCP segments received with checksum errors (for both IPv4 and IPv6). '+ + 'RetransSegs - TCP segments retransmitted.

' + }, + + 'ipv4.tcphandshake': { + info: '

TCP handshake statistics.

'+ + '

EstabResets - established connections resets '+ + '(i.e. connections that made a direct transition from ESTABLISHED or CLOSE_WAIT to CLOSED). '+ + 'OutRsts - TCP segments sent, with the RST flag set (for both IPv4 and IPv6). '+ + 'AttemptFails - number of times TCP connections made a direct transition from either '+ + 'SYN_SENT or SYN_RECV to CLOSED, plus the number of times TCP connections made a direct transition '+ + 'from the SYN_RECV to LISTEN. '+ + 'SynRetrans - shows retries for new outbound TCP connections, '+ + 'which can indicate general connectivity issues or backlog on the remote host.

' + }, + + 'ipv4.sockstat_sockets': { + info: 'The total number of used sockets for all '+ + 'address families '+ + 'in this system.' + }, + + 'ipv4.sockstat_tcp_sockets': { + info: '

The number of TCP sockets in the system in certain '+ + 'states.

'+ + '

Alloc - in any TCP state. '+ + 'Orphan - no longer attached to a socket descriptor in any user processes, '+ + 'but for which the kernel is still required to maintain state in order to complete the transport protocol. '+ + 'InUse - in any TCP state, excluding TIME-WAIT and CLOSED. '+ + 'TimeWait - in the TIME-WAIT state.

' + }, + + 'ipv4.sockstat_tcp_mem': { + info: 'The amount of memory used by allocated TCP sockets.' + }, + + 'ipv4.sockstat_udp_sockets': { + info: 'The number of used UDP sockets.' + }, + + 'ipv4.sockstat_udp_mem': { + info: 'The amount of memory used by allocated UDP sockets.' + }, + + 'ipv4.sockstat_udplite_sockets': { + info: 'The number of used UDP-Lite sockets.' + }, + + 'ipv4.sockstat_raw_sockets': { + info: 'The number of used raw sockets.' + }, + + 'ipv4.sockstat_frag_sockets': { + info: 'The number of entries in hash tables that are used for packet reassembly.' + }, + + 'ipv4.sockstat_frag_mem': { + info: 'The amount of memory used for packet reassembly.' + }, + + // ------------------------------------------------------------------------ + // IPv6 + + 'ipv6.packets': { + info: '

IPv6 packet statistics for this host.

'+ + '

Received - packets received by the IP layer. '+ + 'This counter will be increased even if the packet is dropped later. '+ + 'Sent - packets sent via IP layer, for both single cast and multicast packets. '+ + 'This counter does not include any packets counted in Forwarded. '+ + 'Forwarded - input packets for which this host was not their final IP destination, '+ + 'as a result of which an attempt was made to find a route to forward them to that final destination. '+ + 'In hosts which do not act as IP Gateways, this counter will include only those packets which were '+ + 'Source-Routed '+ + 'and the Source-Route option processing was successful. '+ + 'Delivers - packets delivered to the upper layer protocols, e.g. TCP, UDP, ICMP, and so on.

' + }, + + 'ipv6.fragsout': { + info: '

IPv6 fragmentation '+ + 'statistics for this system.

'+ + '

OK - packets that have been successfully fragmented. '+ + 'Failed - packets that have been discarded because they needed to be fragmented '+ + 'but could not be, e.g. due to Don\'t Fragment (DF) flag was set. '+ + 'All - fragments that have been generated as a result of fragmentation.

' + }, + + 'ipv6.fragsin': { + info: '

IPv6 reassembly '+ + 'statistics for this system.

'+ + '

OK - packets that have been successfully reassembled. '+ + 'Failed - failures detected by the IP reassembly algorithm. '+ + 'This is not necessarily a count of discarded IP fragments since some algorithms '+ + 'can lose track of the number of fragments by combining them as they are received. '+ + 'Timeout - reassembly timeouts detected. '+ + 'All - received IP fragments which needed to be reassembled.

' + }, + + 'ipv6.errors': { + info: '

The number of discarded IPv6 packets.

'+ + '

InDiscards, OutDiscards - packets which were chosen to be discarded even though '+ + 'no errors had been detected to prevent their being deliverable to a higher-layer protocol. '+ + 'InHdrErrors - errors in IP headers, including bad checksums, version number mismatch, '+ + 'other format errors, time-to-live exceeded, etc. '+ + 'InAddrErrors - invalid IP address or the destination IP address is not a local address and '+ + 'IP forwarding is not enabled. '+ + 'InUnknownProtos - unknown or unsupported protocol. '+ + 'InTooBigErrors - the size exceeded the link MTU. '+ + 'InTruncatedPkts - packet frame did not carry enough data. '+ + 'InNoRoutes - no route could be found while forwarding. '+ + 'OutNoRoutes - no route could be found for packets generated by this host.

' + }, + + 'ipv6.udppackets': { + info: 'The number of transferred UDP packets.' + }, + + 'ipv6.udperrors': { + info: '

The number of errors encountered during transferring UDP packets.

'+ + 'RcvbufErrors - receive buffer is full. '+ + 'SndbufErrors - send buffer is full, no kernel memory available, or '+ + 'the IP layer reported an error when trying to send the packet and no error queue has been setup. '+ + 'InErrors - that is an aggregated counter for all errors, excluding NoPorts. '+ + 'NoPorts - no application is listening at the destination port. '+ + 'InCsumErrors - a UDP checksum failure is detected. '+ + 'IgnoredMulti - ignored multicast packets.' + }, + + 'ipv6.udplitepackets': { + info: 'The number of transferred UDP-Lite packets.' + }, + + 'ipv6.udpliteerrors': { + info: '

The number of errors encountered during transferring UDP-Lite packets.

'+ + '

RcvbufErrors - receive buffer is full. '+ + 'SndbufErrors - send buffer is full, no kernel memory available, or '+ + 'the IP layer reported an error when trying to send the packet and no error queue has been setup. '+ + 'InErrors - that is an aggregated counter for all errors, excluding NoPorts. '+ + 'NoPorts - no application is listening at the destination port. '+ + 'InCsumErrors - a UDP checksum failure is detected.

' + }, + + 'ipv6.mcast': { + info: 'Total IPv6 multicast traffic.' + }, + + 'ipv6.bcast': { + info: 'Total IPv6 broadcast traffic.' + }, + + 'ipv6.mcastpkts': { + info: 'Total transferred IPv6 multicast packets.' + }, + + 'ipv6.icmp': { + info: '

The number of transferred ICMPv6 messages.

'+ + '

Received, Sent - ICMP messages which the host received and attempted to send. '+ + 'Both these counters include errors.

' + }, + + 'ipv6.icmpredir': { + info: 'The number of transferred ICMPv6 Redirect messages. '+ + 'These messages inform a host to update its routing information (to send packets on an alternative route).' + }, + + 'ipv6.icmpechos': { + info: 'The number of ICMPv6 Echo messages.' + }, + + 'ipv6.icmperrors': { + info: '

The number of ICMPv6 errors and '+ + 'error messages.

'+ + '

InErrors, OutErrors - bad ICMP messages (bad ICMP checksums, bad length, etc.). '+ + 'InCsumErrors - wrong checksum.

' + }, + + 'ipv6.groupmemb': { + info: '

The number of transferred ICMPv6 Group Membership messages.

'+ + '

Multicast routers send Group Membership Query messages to learn which groups have members on each of their '+ + 'attached physical networks. Host computers respond by sending a Group Membership Report for each '+ + 'multicast group joined by the host. A host computer can also send a Group Membership Report when '+ + 'it joins a new multicast group. '+ + 'Group Membership Reduction messages are sent when a host computer leaves a multicast group.

' + }, + + 'ipv6.icmprouter': { + info: '

The number of transferred ICMPv6 '+ + 'Router Discovery messages.

'+ + '

Router Solicitations message is sent from a computer host to any routers on the local area network '+ + 'to request that they advertise their presence on the network. '+ + 'Router Advertisement message is sent by a router on the local area network to announce its IP address '+ + 'as available for routing.

' + }, + + 'ipv6.icmpneighbor': { + info: '

The number of transferred ICMPv6 '+ + 'Neighbour Discovery messages.

'+ + '

Neighbor Solicitations are used by nodes to determine the link layer address '+ + 'of a neighbor, or to verify that a neighbor is still reachable via a cached link layer address. '+ + 'Neighbor Advertisements are used by nodes to respond to a Neighbor Solicitation message.

' + }, + + 'ipv6.icmpmldv2': { + info: 'The number of transferred ICMPv6 '+ + 'Multicast Listener Discovery (MLD) messages.' + }, + + 'ipv6.icmptypes': { + info: 'The number of transferred ICMPv6 messages of '+ + 'certain types.' + }, + + 'ipv6.ect': { + info: '

Total number of received IPv6 packets with ECN bits set in the system.

'+ + '

CEP - congestion encountered. '+ + 'NoECTP - non ECN-capable transport. '+ + 'ECTP0 and ECTP1 - ECN capable transport.

' + }, + + 'ipv6.sockstat6_tcp_sockets': { + info: 'The number of TCP sockets in any '+ + 'state, '+ + 'excluding TIME-WAIT and CLOSED.' + }, + + 'ipv6.sockstat6_udp_sockets': { + info: 'The number of used UDP sockets.' + }, + + 'ipv6.sockstat6_udplite_sockets': { + info: 'The number of used UDP-Lite sockets.' + }, + + 'ipv6.sockstat6_raw_sockets': { + info: 'The number of used raw sockets.' + }, + + 'ipv6.sockstat6_frag_sockets': { + info: 'The number of entries in hash tables that are used for packet reassembly.' + }, + + + // ------------------------------------------------------------------------ + // SCTP + + 'sctp.established': { + info: 'The number of associations for which the current state is either '+ + 'ESTABLISHED, SHUTDOWN-RECEIVED or SHUTDOWN-PENDING.' + }, + + 'sctp.transitions': { + info: '

The number of times that associations have made a direct transition between states.

'+ + '

Active - from COOKIE-ECHOED to ESTABLISHED. The upper layer initiated the association attempt. '+ + 'Passive - from CLOSED to ESTABLISHED. The remote endpoint initiated the association attempt. '+ + 'Aborted - from any state to CLOSED using the primitive ABORT. Ungraceful termination of the association. '+ + 'Shutdown - from SHUTDOWN-SENT or SHUTDOWN-ACK-SENT to CLOSED. Graceful termination of the association.

' + }, + + 'sctp.packets': { + info: '

The number of transferred SCTP packets.

'+ + '

Received - includes duplicate packets. '+ + 'Sent - includes retransmitted DATA chunks.

' + }, + + 'sctp.packet_errors': { + info: '

The number of errors encountered during receiving SCTP packets.

'+ + '

Invalid - packets for which the receiver was unable to identify an appropriate association. '+ + 'Checksum - packets with an invalid checksum.

' + }, + + 'sctp.fragmentation': { + info: '

The number of fragmented and reassembled SCTP messages.

'+ + '

Reassembled - reassembled user messages, after conversion into DATA chunks. '+ + 'Fragmented - user messages that have to be fragmented because of the MTU.

' + }, + + 'sctp.chunks': { + info: 'The number of transferred control, ordered, and unordered DATA chunks. '+ + 'Retransmissions and duplicates are not included.' + }, + + // ------------------------------------------------------------------------ + // Netfilter Connection Tracker + + 'netfilter.conntrack_sockets': { + info: 'The number of entries in the conntrack table.' + }, + + 'netfilter.conntrack_new': { + info: '

Packet tracking statistics. New (since v4.9) and Ignore (since v5.10) are hardcoded to zeros in the latest kernel.

'+ + '

New - conntrack entries added which were not expected before. '+ + 'Ignore - packets seen which are already connected to a conntrack entry. '+ + 'Invalid - packets seen which can not be tracked.

' + }, + + 'netfilter.conntrack_changes': { + info: '

The number of changes in conntrack tables.

'+ + '

Inserted, Deleted - conntrack entries which were inserted or removed. '+ + 'Delete-list - conntrack entries which were put to dying list.

' + }, + + 'netfilter.conntrack_expect': { + info: '

The number of events in the "expect" table. '+ + 'Connection tracking expectations are the mechanism used to "expect" RELATED connections to existing ones. '+ + 'An expectation is a connection that is expected to happen in a period of time.

'+ + '

Created, Deleted - conntrack entries which were inserted or removed. '+ + 'New - conntrack entries added after an expectation for them was already present.

' + }, + + 'netfilter.conntrack_search': { + info: '

Conntrack table lookup statistics.

'+ + '

Searched - conntrack table lookups performed. '+ + 'Restarted - conntrack table lookups which had to be restarted due to hashtable resizes. '+ + 'Found - conntrack table lookups which were successful.

' + }, + + 'netfilter.conntrack_errors': { + info: '

Conntrack errors.

'+ + '

IcmpError - packets which could not be tracked due to error situation. '+ + 'InsertFailed - entries for which list insertion was attempted but failed '+ + '(happens if the same entry is already present). '+ + 'Drop - packets dropped due to conntrack failure. '+ + 'Either new conntrack entry allocation failed, or protocol helper dropped the packet. '+ + 'EarlyDrop - dropped conntrack entries to make room for new ones, if maximum table size was reached.

' + }, + + 'netfilter.synproxy_syn_received': { + info: 'The number of initial TCP SYN packets received from clients.' + }, + + 'netfilter.synproxy_conn_reopened': { + info: 'The number of reopened connections by new TCP SYN packets directly from the TIME-WAIT state.' + }, + + 'netfilter.synproxy_cookies': { + info: '

SYNPROXY cookie statistics.

'+ + '

Valid, Invalid - result of cookie validation in TCP ACK packets received from clients. '+ + 'Retransmits - TCP SYN packets retransmitted to the server. '+ + 'It happens when the client repeats TCP ACK and the connection to the server is not yet established.

' + }, + + // ------------------------------------------------------------------------ + // APPS (Applications, Groups, Users) + + // APPS cpu + 'apps.cpu': { + info: 'Total CPU utilization (all cores). It includes user, system and guest time.' + }, + 'groups.cpu': { + info: 'Total CPU utilization (all cores). It includes user, system and guest time.' + }, + 'users.cpu': { + info: 'Total CPU utilization (all cores). It includes user, system and guest time.' + }, + + 'apps.cpu_user': { + info: 'The amount of time the CPU was busy executing code in '+ + 'user mode (all cores).' + }, + 'groups.cpu_user': { + info: 'The amount of time the CPU was busy executing code in '+ + 'user mode (all cores).' + }, + 'users.cpu_user': { + info: 'The amount of time the CPU was busy executing code in '+ + 'user mode (all cores).' + }, + + 'apps.cpu_system': { + info: 'The amount of time the CPU was busy executing code in '+ + 'kernel mode (all cores).' + }, + 'groups.cpu_system': { + info: 'The amount of time the CPU was busy executing code in '+ + 'kernel mode (all cores).' + }, + 'users.cpu_system': { + info: 'The amount of time the CPU was busy executing code in '+ + 'kernel mode (all cores).' + }, + + 'apps.cpu_guest': { + info: 'The amount of time spent running a virtual CPU for a guest operating system (all cores).' + }, + 'groups.cpu_guest': { + info: 'The amount of time spent running a virtual CPU for a guest operating system (all cores).' + }, + 'users.cpu_guest': { + info: 'The amount of time spent running a virtual CPU for a guest operating system (all cores).' + }, + + // APPS disk + 'apps.preads': { + info: 'The amount of data that has been read from the storage layer. '+ + 'Actual physical disk I/O was required.' + }, + 'groups.preads': { + info: 'The amount of data that has been read from the storage layer. '+ + 'Actual physical disk I/O was required.' + }, + 'users.preads': { + info: 'The amount of data that has been read from the storage layer. '+ + 'Actual physical disk I/O was required.' + }, + + 'apps.pwrites': { + info: 'The amount of data that has been written to the storage layer. '+ + 'Actual physical disk I/O was required.' + }, + 'groups.pwrites': { + info: 'The amount of data that has been written to the storage layer. '+ + 'Actual physical disk I/O was required.' + }, + 'users.pwrites': { + info: 'The amount of data that has been written to the storage layer. '+ + 'Actual physical disk I/O was required.' + }, + + 'apps.lreads': { + info: 'The amount of data that has been read from the storage layer. '+ + 'It includes things such as terminal I/O and is unaffected by whether or '+ + 'not actual physical disk I/O was required '+ + '(the read might have been satisfied from pagecache).' + }, + 'groups.lreads': { + info: 'The amount of data that has been read from the storage layer. '+ + 'It includes things such as terminal I/O and is unaffected by whether or '+ + 'not actual physical disk I/O was required '+ + '(the read might have been satisfied from pagecache).' + }, + 'users.lreads': { + info: 'The amount of data that has been read from the storage layer. '+ + 'It includes things such as terminal I/O and is unaffected by whether or '+ + 'not actual physical disk I/O was required '+ + '(the read might have been satisfied from pagecache).' + }, + + 'apps.lwrites': { + info: 'The amount of data that has been written or shall be written to the storage layer. '+ + 'It includes things such as terminal I/O and is unaffected by whether or '+ + 'not actual physical disk I/O was required.' + }, + 'groups.lwrites': { + info: 'The amount of data that has been written or shall be written to the storage layer. '+ + 'It includes things such as terminal I/O and is unaffected by whether or '+ + 'not actual physical disk I/O was required.' + }, + 'users.lwrites': { + info: 'The amount of data that has been written or shall be written to the storage layer. '+ + 'It includes things such as terminal I/O and is unaffected by whether or '+ + 'not actual physical disk I/O was required.' + }, + + 'apps.files': { + info: 'The number of open files and directories.' + }, + 'groups.files': { + info: 'The number of open files and directories.' + }, + 'users.files': { + info: 'The number of open files and directories.' + }, + + // APPS mem + 'apps.mem': { + info: 'Real memory (RAM) used by applications. This does not include shared memory.' + }, + 'groups.mem': { + info: 'Real memory (RAM) used per user group. This does not include shared memory.' + }, + 'users.mem': { + info: 'Real memory (RAM) used per user. This does not include shared memory.' + }, + + 'apps.vmem': { + info: 'Virtual memory allocated by applications. '+ + 'Check this article for more information.' + }, + 'groups.vmem': { + info: 'Virtual memory allocated per user group since the Netdata restart. Please check this article for more information.' + }, + 'users.vmem': { + info: 'Virtual memory allocated per user since the Netdata restart. Please check this article for more information.' + }, + + 'apps.minor_faults': { + info: 'The number of minor faults '+ + 'which have not required loading a memory page from the disk. '+ + 'Minor page faults occur when a process needs data that is in memory and is assigned to another process. '+ + 'They share memory pages between multiple processes – '+ + 'no additional data needs to be read from disk to memory.' + }, + 'groups.minor_faults': { + info: 'The number of minor faults '+ + 'which have not required loading a memory page from the disk. '+ + 'Minor page faults occur when a process needs data that is in memory and is assigned to another process. '+ + 'They share memory pages between multiple processes – '+ + 'no additional data needs to be read from disk to memory.' + }, + 'users.minor_faults': { + info: 'The number of minor faults '+ + 'which have not required loading a memory page from the disk. '+ + 'Minor page faults occur when a process needs data that is in memory and is assigned to another process. '+ + 'They share memory pages between multiple processes – '+ + 'no additional data needs to be read from disk to memory.' + }, + + // APPS processes + 'apps.threads': { + info: 'The number of threads.' + }, + 'groups.threads': { + info: 'The number of threads.' + }, + 'users.threads': { + info: 'The number of threads.' + }, + + 'apps.processes': { + info: 'The number of processes.' + }, + 'groups.processes': { + info: 'The number of processes.' + }, + 'users.processes': { + info: 'The number of processes.' + }, + + 'apps.uptime': { + info: 'The period of time within which at least one process in the group has been running.' + }, + 'groups.uptime': { + info: 'The period of time within which at least one process in the group has been running.' + }, + 'users.uptime': { + info: 'The period of time within which at least one process in the group has been running.' + }, + + 'apps.uptime_min': { + info: 'The shortest uptime among processes in the group.' + }, + 'groups.uptime_min': { + info: 'The shortest uptime among processes in the group.' + }, + 'users.uptime_min': { + info: 'The shortest uptime among processes in the group.' + }, + + 'apps.uptime_avg': { + info: 'The average uptime of processes in the group.' + }, + 'groups.uptime_avg': { + info: 'The average uptime of processes in the group.' + }, + 'users.uptime_avg': { + info: 'The average uptime of processes in the group.' + }, + + 'apps.uptime_max': { + info: 'The longest uptime among processes in the group.' + }, + 'groups.uptime_max': { + info: 'The longest uptime among processes in the group.' + }, + 'users.uptime_max': { + info: 'The longest uptime among processes in the group.' + }, + + 'apps.pipes': { + info: 'The number of open '+ + 'pipes. '+ + 'A pipe is a unidirectional data channel that can be used for interprocess communication.' + }, + 'groups.pipes': { + info: 'The number of open '+ + 'pipes. '+ + 'A pipe is a unidirectional data channel that can be used for interprocess communication.' + }, + 'users.pipes': { + info: 'The number of open '+ + 'pipes. '+ + 'A pipe is a unidirectional data channel that can be used for interprocess communication.' + }, + + // APPS swap + 'apps.swap': { + info: 'The amount of swapped-out virtual memory by anonymous private pages. '+ + 'This does not include shared swap memory.' + }, + 'groups.swap': { + info: 'The amount of swapped-out virtual memory by anonymous private pages. '+ + 'This does not include shared swap memory.' + }, + 'users.swap': { + info: 'The amount of swapped-out virtual memory by anonymous private pages. '+ + 'This does not include shared swap memory.' + }, + + 'apps.major_faults': { + info: 'The number of major faults '+ + 'which have required loading a memory page from the disk. '+ + 'Major page faults occur because of the absence of the required page from the RAM. '+ + 'They are expected when a process starts or needs to read in additional data and '+ + 'in these cases do not indicate a problem condition. '+ + 'However, a major page fault can also be the result of reading memory pages that have been written out '+ + 'to the swap file, which could indicate a memory shortage.' + }, + 'groups.major_faults': { + info: 'The number of major faults '+ + 'which have required loading a memory page from the disk. '+ + 'Major page faults occur because of the absence of the required page from the RAM. '+ + 'They are expected when a process starts or needs to read in additional data and '+ + 'in these cases do not indicate a problem condition. '+ + 'However, a major page fault can also be the result of reading memory pages that have been written out '+ + 'to the swap file, which could indicate a memory shortage.' + }, + 'users.major_faults': { + info: 'The number of major faults '+ + 'which have required loading a memory page from the disk. '+ + 'Major page faults occur because of the absence of the required page from the RAM. '+ + 'They are expected when a process starts or needs to read in additional data and '+ + 'in these cases do not indicate a problem condition. '+ + 'However, a major page fault can also be the result of reading memory pages that have been written out '+ + 'to the swap file, which could indicate a memory shortage.' + }, + + // APPS net + 'apps.sockets': { + info: 'The number of open sockets. '+ + 'Sockets are a way to enable inter-process communication between programs running on a server, '+ + 'or between programs running on separate servers. This includes both network and UNIX sockets.' + }, + 'groups.sockets': { + info: 'The number of open sockets. '+ + 'Sockets are a way to enable inter-process communication between programs running on a server, '+ + 'or between programs running on separate servers. This includes both network and UNIX sockets.' + }, + 'users.sockets': { + info: 'The number of open sockets. '+ + 'Sockets are a way to enable inter-process communication between programs running on a server, '+ + 'or between programs running on separate servers. This includes both network and UNIX sockets.' + }, + + // Apps eBPF stuff + + 'apps.file_open': { + info: 'Number of calls for internal functions on the Linux kernel responsible to open files. ' + + 'Netdata gives a summary for this chart in file access, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.file_open_error': { + info: 'Number of failed calls for internal functions on the Linux kernel responsible to open files. ' + + 'Netdata gives a summary for this chart in file access, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.file_closed': { + info: 'Number of calls for internal functions on the Linux kernel responsible to close files. ' + + 'Netdata gives a summary for this chart in file access, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.file_close_error': { + info: 'Number of failed calls for internal functions on the Linux kernel responsible to close files. ' + + 'Netdata gives a summary for this chart in file access, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.file_deleted': { + info: 'Number of calls to VFS unlinker function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '' + }, + + 'apps.vfs_write_call': { + info: 'Number of successful calls to VFS writer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_write_error': { + info: 'Number of failed calls to VFS writer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_read_call': { + info: 'Number of successful calls to VFS reader function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_read_error': { + info: 'Number of failed calls to VFS reader function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_write_bytes': { + info: 'Total of bytes successfully written using the VFS writer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_read_bytes': { + info: 'Total of bytes successfully written using the VFS reader function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_fsync': { + info: 'Number of calls to VFS syncer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_fsync_error': { + info: 'Number of failed calls to VFS syncer function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_open': { + info: 'Number of calls to VFS opener function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_open_error': { + info: 'Number of failed calls to VFS opener function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_create': { + info: 'Number of calls to VFS creator function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.vfs_create_error': { + info: 'Number of failed calls to VFS creator function. Netdata gives a summary for this chart in ' + + 'Virtual File System, and when the integration is enabled, ' + + 'Netdata shows virtual file system per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.process_create': { + info: 'Number of times a function that starts a process is called. Netdata gives a summary for this chart in Process, and when the integration is enabled, Netdata shows process per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.thread_create': { + info: 'Number of times a function that starts a thread is called. Netdata gives a summary for this chart in Process, and when the integration is enabled, Netdata shows process per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.task_exit': { + info: 'Number of times a function responsible for closing tasks is called. Netdata gives a summary for this chart in Process, and when the integration is enabled, Netdata shows process per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.task_close': { + info: 'Number of times a function responsible for releasing tasks is called. Netdata gives a summary for this chart in Process, and when the integration is enabled, Netdata shows process per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.task_error': { + info: 'Number of errors to create a new task. Netdata gives a summary for this chart in Process, and when the integration is enabled, Netdata shows process per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.outbound_conn_v4': { + info: 'Number of calls to IPV4 TCP function responsible for starting connections. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows outbound connections per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.outbound_conn_v6': { + info: 'Number of calls to IPV6 TCP function responsible for starting connections. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows outbound connections per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.total_bandwidth_sent': { + info: 'Total bytes sent with TCP or UDP internal functions. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows bandwidth per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.total_bandwidth_recv': { + info: 'Total bytes received with TCP or UDP internal functions. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows bandwidth per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.bandwidth_tcp_send': { + info: 'Number of calls to TCP functions responsible to send data. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows TCP calls per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.bandwidth_tcp_recv': { + info: 'Number of calls to TCP functions responsible to receive data. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows TCP calls per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.bandwidth_tcp_retransmit': { + info: 'Number of times a TCP packet was retransmitted. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows TCP calls per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.bandwidth_udp_send': { + info: 'Number of calls to UDP functions responsible to send data. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows UDP calls per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.bandwidth_udp_recv': { + info: 'Number of calls to UDP functions responsible to receive data. Netdata gives a summary for this chart in Network Stack. When the integration is enabled, Netdata shows UDP calls per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.cachestat_ratio' : { + info: 'The ratio shows the percentage of data accessed directly in memory. Netdata gives a summary for this chart in Memory, and when the integration is enabled, Netdata shows page cache hit per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.cachestat_dirties' : { + info: 'Number of modified pages in Linux page cache. Netdata gives a summary for this chart in Memory, and when the integration is enabled, Netdata shows page cache hit per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.cachestat_hits' : { + info: 'Number of access to data in Linux page cache. Netdata gives a summary for this chart in Memory, and when the integration is enabled, Netdata shows page cache hit per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.cachestat_misses' : { + info: 'Number of access to data was not present in Linux page cache. Netdata gives a summary for this chart in Memory, and when the integration is enabled, Netdata shows page cache misses per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.dc_hit_ratio': { + info: 'Percentage of file accesses that were present in the directory cache. Netdata gives a summary for this chart in directory cache, and when the integration is enabled, Netdata shows directory cache per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.dc_reference': { + info: 'Number of times a file is accessed inside directory cache. Netdata gives a summary for this chart in directory cache, and when the integration is enabled, Netdata shows directory cache per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.dc_not_cache': { + info: 'Number of times a file is accessed in the file system, because it is not present inside the directory cache. Netdata gives a summary for this chart in directory cache, and when the integration is enabled, Netdata shows directory cache per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.dc_not_found': { + info: 'Number of times a file was not found on the file system. Netdata gives a summary for this chart in directory cache, and when the integration is enabled, Netdata shows directory cache per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.swap_read_call': { + info: 'Number of calls to swap reader function. Netdata gives a summary for this chart in System Overview, and when the integration is enabled, Netdata shows swap metrics per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.swap_write_call': { + info: 'Number of calls to swap writer function. Netdata gives a summary for this chart in System Overview, and when the integration is enabled, Netdata shows swap metrics per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.shmget_call': { + info: 'Number of calls to shmget. Netdata gives a summary for this chart in System Overview, and when the integration is enabled, Netdata shows shared memory metrics per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.shmat_call': { + info: 'Number of calls to shmat. Netdata gives a summary for this chart in System Overview, and when the integration is enabled, Netdata shows shared memory metrics per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.shmdt_call': { + info: 'Number of calls to shmdt. Netdata gives a summary for this chart in System Overview, and when the integration is enabled, Netdata shows shared memory metrics per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + 'apps.shmctl_call': { + info: 'Number of calls to shmctl. Netdata gives a summary for this chart in System Overview, and when the integration is enabled, Netdata shows shared memory metrics per cgroup (systemd Services).' + ebpfChartProvides + '
' + }, + + // ------------------------------------------------------------------------ + // NETWORK QoS + + 'tc.qos': { + heads: [ + function (os, id) { + void (os); + + if (id.match(/.*-ifb$/)) + return netdataDashboard.gaugeChart('Inbound', '12%', '', '#5555AA'); + else + return netdataDashboard.gaugeChart('Outbound', '12%', '', '#AA9900'); + } + ] + }, + + // ------------------------------------------------------------------------ + // NETWORK INTERFACES + + 'net.net': { + heads: [ + netdataDashboard.gaugeChart('Received', '12%', 'received'), + netdataDashboard.gaugeChart('Sent', '12%', 'sent'), + ], + info: netBytesInfo + }, + 'net.packets': { + info: netPacketsInfo + }, + 'net.errors': { + info: netErrorsInfo + }, + 'net.fifo': { + info: netFIFOInfo + }, + 'net.drops': { + info: netDropsInfo + }, + 'net.compressed': { + info: netCompressedInfo + }, + 'net.events': { + info: netEventsInfo + }, + 'net.duplex': { + info: netDuplexInfo + }, + 'net.operstate': { + info: netOperstateInfo + }, + 'net.carrier': { + info: netCarrierInfo + }, + 'net.speed': { + info: netSpeedInfo + }, + 'net.mtu': { + info: netMTUInfo + }, + + // ------------------------------------------------------------------------ + // CGROUP NETWORK INTERFACES + + 'cgroup.net_net': { + mainheads: [ + function (os, id) { + void (os); + var iface; + try { + iface = ' ' + id.substring(id.lastIndexOf('.net_') + 5, id.length); + } catch (e) { + iface = ''; + } + return netdataDashboard.gaugeChart('Received' + iface, '12%', 'received'); + + }, + function (os, id) { + void (os); + var iface; + try { + iface = ' ' + id.substring(id.lastIndexOf('.net_') + 5, id.length); + } catch (e) { + iface = ''; + } + return netdataDashboard.gaugeChart('Sent' + iface, '12%', 'sent'); + } + ], + info: netBytesInfo + }, + 'cgroup.net_packets': { + info: netPacketsInfo + }, + 'cgroup.net_errors': { + info: netErrorsInfo + }, + 'cgroup.net_fifo': { + info: netFIFOInfo + }, + 'cgroup.net_drops': { + info: netDropsInfo + }, + 'cgroup.net_compressed': { + info: netCompressedInfo + }, + 'cgroup.net_events': { + info: netEventsInfo + }, + 'cgroup.net_duplex': { + info: netDuplexInfo + }, + 'cgroup.net_operstate': { + info: netOperstateInfo + }, + 'cgroup.net_carrier': { + info: netCarrierInfo + }, + 'cgroup.net_speed': { + info: netSpeedInfo + }, + 'cgroup.net_mtu': { + info: netMTUInfo + }, + + 'k8s.cgroup.net_net': { + mainheads: [ + function (_, id) { + var iface; + try { + iface = ' ' + id.substring(id.lastIndexOf('.net_') + 5, id.length); + } catch (e) { + iface = ''; + } + return netdataDashboard.gaugeChart('Received' + iface, '12%', 'received'); + + }, + function (_, id) { + var iface; + try { + iface = ' ' + id.substring(id.lastIndexOf('.net_') + 5, id.length); + } catch (e) { + iface = ''; + } + return netdataDashboard.gaugeChart('Sent' + iface, '12%', 'sent'); + } + ], + info: netBytesInfo + }, + 'k8s.cgroup.net_packets': { + info: netPacketsInfo + }, + 'k8s.cgroup.net_errors': { + info: netErrorsInfo + }, + 'k8s.cgroup.net_fifo': { + info: netFIFOInfo + }, + 'k8s.cgroup.net_drops': { + info: netDropsInfo + }, + 'k8s.cgroup.net_compressed': { + info: netCompressedInfo + }, + 'k8s.cgroup.net_events': { + info: netEventsInfo + }, + 'k8s.cgroup.net_operstate': { + info: netOperstateInfo + }, + 'k8s.cgroup.net_duplex': { + info: netDuplexInfo + }, + 'k8s.cgroup.net_carrier': { + info: netCarrierInfo + }, + 'k8s.cgroup.net_speed': { + info: netSpeedInfo + }, + 'k8s.cgroup.net_mtu': { + info: netMTUInfo + }, + + // ------------------------------------------------------------------------ + // WIRELESS NETWORK INTERFACES + + 'wireless.link_quality': { + info: 'Overall quality of the link. '+ + 'May be based on the level of contention or interference, the bit or frame error rate, '+ + 'how good the received signal is, some timing synchronisation, or other hardware metric.' + }, + + 'wireless.signal_level': { + info: 'Received signal strength '+ + '(RSSI).' + }, + + 'wireless.noise_level': { + info: 'Background noise level (when no packet is transmitted).' + }, + + 'wireless.discarded_packets': { + info: '

The number of discarded packets.

'+ + '

NWID - received packets with a different NWID or ESSID. '+ + 'Used to detect configuration problems or adjacent network existence (on the same frequency). '+ + 'Crypt - received packets that the hardware was unable to code/encode. '+ + 'This can be used to detect invalid encryption settings. '+ + 'Frag - received packets for which the hardware was not able to properly re-assemble '+ + 'the link layer fragments (most likely one was missing). '+ + 'Retry - packets that the hardware failed to deliver. '+ + 'Most MAC protocols will retry the packet a number of times before giving up. '+ + 'Misc - other packets lost in relation with specific wireless operations.

' + }, + + 'wireless.missed_beacons': { + info: 'The number of periodic '+ + 'beacons '+ + 'from the Cell or the Access Point have been missed. '+ + 'Beacons are sent at regular intervals to maintain the cell coordination, '+ + 'failure to receive them usually indicates that the card is out of range.' + }, + + // ------------------------------------------------------------------------ + // INFINIBAND + + 'ib.bytes': { + info: 'The amount of traffic transferred by the port.' + }, + + 'ib.packets': { + info: 'The number of packets transferred by the port.' + }, + + 'ib.errors': { + info: 'The number of errors encountered by the port.' + }, + + 'ib.hwerrors': { + info: 'The number of hardware errors encountered by the port.' + }, + + 'ib.hwpackets': { + info: 'The number of hardware packets transferred by the port.' + }, + + // ------------------------------------------------------------------------ + // NETFILTER + + 'netfilter.sockets': { + colors: '#88AA00', + heads: [ + netdataDashboard.gaugeChart('Active Connections', '12%', '', '#88AA00') + ] + }, + + 'netfilter.new': { + heads: [ + netdataDashboard.gaugeChart('New Connections', '12%', 'new', '#5555AA') + ] + }, + + // ------------------------------------------------------------------------ + // IPVS + 'ipvs.sockets': { + info: 'Total created connections for all services and their servers. '+ + 'To see the IPVS connection table, run ipvsadm -Lnc.' + }, + 'ipvs.packets': { + info: 'Total transferred packets for all services and their servers.' + }, + 'ipvs.net': { + info: 'Total network traffic for all services and their servers.' + }, + + // ------------------------------------------------------------------------ + // DISKS + + 'disk.util': { + colors: '#FF5588', + heads: [ + netdataDashboard.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 system 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.busy': { + colors: '#FF5588', + info: 'Disk Busy Time measures the amount of time the disk was busy with something.' + }, + + 'disk.backlog': { + colors: '#0099CC', + info: 'Backlog is an indication of the duration of pending disk operations. On every I/O event the system 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: [ + netdataDashboard.gaugeChart('Read', '12%', 'reads'), + netdataDashboard.gaugeChart('Write', '12%', 'writes') + ], + info: 'The amount of data transferred to and from disk.' + }, + + 'disk_ext.io': { + info: 'The amount of discarded data that are no longer in use by a mounted file system.' + }, + + 'disk.ops': { + info: 'Completed disk I/O operations. Keep in mind the number of operations requested might be higher, since the system is able to merge adjacent to each other (see merged operations chart).' + }, + + 'disk_ext.ops': { + info: '

The number (after merges) of completed discard/flush requests.

'+ + '

Discard commands inform disks which blocks of data are no longer considered to be in use and therefore can be erased internally. '+ + 'They are useful for solid-state drivers (SSDs) and thinly-provisioned storage. '+ + 'Discarding/trimming enables the SSD to handle garbage collection more efficiently, '+ + 'which would otherwise slow future write operations to the involved blocks down.

'+ + '

Flush operations transfer all modified in-core data (i.e., modified buffer cache pages) to the disk device '+ + 'so that all changed information can be retrieved even if the system crashes or is rebooted. '+ + 'Flush requests are executed by disks. Flush requests are not tracked for partitions. '+ + 'Before being merged, flush operations are counted as writes.

' + }, + + '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_ext.iotime': { + height: 0.5, + info: 'The sum of the duration of all completed discard/flush operations. This number can exceed the interval if the disk is able to execute discard/flush operations in parallel.' + }, + 'disk.mops': { + height: 0.5, + info: 'The number of merged disk operations. The system is able to merge adjacent I/O operations, for example two 4KB reads can become one 8KB read before given to disk.' + }, + 'disk_ext.mops': { + height: 0.5, + info: 'The number of merged discard disk operations. Discard operations which are adjacent to each other may be merged for efficiency.' + }, + '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.latency_io': { + height: 0.5, + info: 'Disk I/O latency is the time it takes for an I/O request to be completed. Disk chart has a relationship with Filesystem charts. This chart is based on the bio_tracepoints tool of the ebpf_exporter.' + ebpfChartProvides + }, + 'disk.avgsz': { + height: 0.5, + info: 'The average I/O operation size.' + }, + 'disk_ext.avgsz': { + height: 0.5, + info: 'The average discard 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_ext.await': { + height: 0.5, + info: 'The average time for discard/flush 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.' + }, + + 'disk.bcache_hit_ratio': { + info: '

Bcache (block cache) is a cache in the block layer of Linux kernel, '+ + 'which is used for accessing secondary storage devices. '+ + 'It allows one or more fast storage devices, such as flash-based solid-state drives (SSDs), '+ + 'to act as a cache for one or more slower storage devices, such as hard disk drives (HDDs).

'+ + '

Percentage of data requests that were fulfilled right from the block cache. '+ + 'Hits and misses are counted per individual IO as bcache sees them. '+ + 'A partial hit is counted as a miss.

' + }, + 'disk.bcache_rates': { + info: 'Throttling rates. '+ + 'To avoid congestions bcache tracks latency to the cache device, and gradually throttles traffic if the latency exceeds a threshold. ' + + 'If the writeback percentage is nonzero, bcache tries to keep around this percentage of the cache dirty by '+ + 'throttling background writeback and using a PD controller to smoothly adjust the rate.' + }, + 'disk.bcache_size': { + info: 'The amount of dirty data for this backing device in the cache.' + }, + 'disk.bcache_usage': { + info: 'The percentage of cache device which does not contain dirty data, and could potentially be used for writeback.' + }, + 'disk.bcache_cache_read_races': { + info: 'Read races happen when a bucket was reused and invalidated while data was being read from the cache. '+ + 'When this occurs the data is reread from the backing device. '+ + 'IO errors are decayed by the half life. '+ + 'If the decaying count reaches the limit, dirty data is written out and the cache is disabled.' + }, + 'disk.bcache': { + info: 'Hits and misses are counted per individual IO as bcache sees them; a partial hit is counted as a miss. '+ + 'Collisions happen when data was going to be inserted into the cache from a cache miss, '+ + 'but raced with a write and data was already present. '+ + 'Cache miss reads are rounded up to the readahead size, but without overlapping existing cache entries.' + }, + 'disk.bcache_bypass': { + info: 'Hits and misses for IO that is intended to skip the cache.' + }, + 'disk.bcache_cache_alloc': { + info: '

Working set size.

'+ + '

Unused is the percentage of the cache that does not contain any data. '+ + 'Dirty is the data that is modified in the cache but not yet written to the permanent storage. '+ + 'Clean data matches the data stored on the permanent storage. '+ + 'Metadata is bcache\'s metadata overhead.

' + }, + + // ------------------------------------------------------------------------ + // NFS client + + 'nfs.net': { + info: 'The number of received UDP and TCP packets.' + }, + + 'nfs.rpc': { + info: '

Remote Procedure Call (RPC) statistics.

'+ + '

Calls - all RPC calls. '+ + 'Retransmits - retransmitted calls. '+ + 'AuthRefresh - authentication refresh calls (validating credentials with the server).

' + }, + + 'nfs.proc2': { + info: 'NFSv2 RPC calls. The individual metrics are described in '+ + 'RFC1094.' + }, + + 'nfs.proc3': { + info: 'NFSv3 RPC calls. The individual metrics are described in '+ + 'RFC1813.' + }, + + 'nfs.proc4': { + info: 'NFSv4 RPC calls. The individual metrics are described in '+ + 'RFC8881.' + }, + + // ------------------------------------------------------------------------ + // NFS server + + 'nfsd.readcache': { + info: '

Reply cache statistics. '+ + 'The reply cache keeps track of responses to recently performed non-idempotent transactions, and '+ + 'in case of a replay, the cached response is sent instead of attempting to perform the operation again.

'+ + 'Hits - client did not receive a reply and re-transmitted its request. This event is undesirable. '+ + 'Misses - an operation that requires caching (idempotent). '+ + 'Nocache - an operation that does not require caching (non-idempotent).' + }, + + 'nfsd.filehandles': { + info: '

File handle statistics. '+ + 'File handles are small pieces of memory that keep track of what file is opened.

'+ + '

Stale - happen when a file handle references a location that has been recycled. '+ + 'This also occurs when the server loses connection and '+ + 'applications are still using files that are no longer accessible.' + }, + + 'nfsd.io': { + info: 'The amount of data transferred to and from disk.' + }, + + 'nfsd.threads': { + info: 'The number of threads used by the NFS daemon.' + }, + + 'nfsd.readahead': { + info: '

Read-ahead cache statistics. '+ + 'NFS read-ahead predictively requests blocks from a file in advance of I/O requests by the application. '+ + 'It is designed to improve client sequential read throughput.

'+ + '

10%-100% - histogram of depth the block was found. '+ + 'This means how far the cached block is from the original block that was first requested. '+ + 'Misses - not found in the read-ahead cache.

' + }, + + 'nfsd.net': { + info: 'The number of received UDP and TCP packets.' + }, + + 'nfsd.rpc': { + info: '

Remote Procedure Call (RPC) statistics.

'+ + '

Calls - all RPC calls. '+ + 'BadAuth - bad authentication. '+ + 'It does not count if you try to mount from a machine that it\'s not in your exports file. '+ + 'BadFormat - other errors.

' + }, + + 'nfsd.proc2': { + info: 'NFSv2 RPC calls. The individual metrics are described in '+ + 'RFC1094.' + }, + + 'nfsd.proc3': { + info: 'NFSv3 RPC calls. The individual metrics are described in '+ + 'RFC1813.' + }, + + 'nfsd.proc4': { + info: 'NFSv4 RPC calls. The individual metrics are described in '+ + 'RFC8881.' + }, + + 'nfsd.proc4ops': { + info: 'NFSv4 RPC operations. The individual metrics are described in '+ + 'RFC8881.' + }, + + // ------------------------------------------------------------------------ + // ZFS + + 'zfs.arc_size': { + info: '

The size of the ARC.

'+ + '

Arcsz - actual size. '+ + 'Target - target size that the ARC is attempting to maintain (adaptive). '+ + 'Min - minimum size limit. When the ARC is asked to shrink, it will stop shrinking at this value. '+ + 'Max - maximum size limit.

' + }, + + 'zfs.l2_size': { + info: '

The size of the L2ARC.

'+ + '

Actual - size of compressed data. '+ + 'Size - size of uncompressed data.

' + }, + + 'zfs.reads': { + info: '

The number of read requests.

'+ + '

ARC - all prefetch and demand requests. '+ + 'Demand - triggered by an application request. '+ + 'Prefetch - triggered by the prefetch mechanism, not directly from an application request. '+ + 'Metadata - metadata read requests. '+ + 'L2 - L2ARC read requests.

' + }, + + 'zfs.bytes': { + info: 'The amount of data transferred to and from the L2ARC cache devices.' + }, + + 'zfs.hits': { + info: '

Hit rate of the ARC read requests.

'+ + '

Hits - a data block was in the ARC DRAM cache and returned. '+ + 'Misses - a data block was not in the ARC DRAM cache. '+ + 'It will be read from the L2ARC cache devices (if available and the data is cached on them) or the pool disks.

' + }, + + 'zfs.dhits': { + info: '

Hit rate of the ARC data and metadata demand read requests. '+ + 'Demand requests are triggered by an application request.

'+ + '

Hits - a data block was in the ARC DRAM cache and returned. '+ + 'Misses - a data block was not in the ARC DRAM cache. '+ + 'It will be read from the L2ARC cache devices (if available and the data is cached on them) or the pool disks.

' + }, + + 'zfs.phits': { + info: '

Hit rate of the ARC data and metadata prefetch read requests. '+ + 'Prefetch requests are triggered by the prefetch mechanism, not directly from an application request.

'+ + '

Hits - a data block was in the ARC DRAM cache and returned. '+ + 'Misses - a data block was not in the ARC DRAM cache. '+ + 'It will be read from the L2ARC cache devices (if available and the data is cached on them) or the pool disks.

' + }, + + 'zfs.mhits': { + info: '

Hit rate of the ARC metadata read requests.

'+ + '

Hits - a data block was in the ARC DRAM cache and returned. '+ + 'Misses - a data block was not in the ARC DRAM cache. '+ + 'It will be read from the L2ARC cache devices (if available and the data is cached on them) or the pool disks.

' + }, + + 'zfs.l2hits': { + info: '

Hit rate of the L2ARC lookups.

'+ + '

Hits - a data block was in the L2ARC cache and returned. '+ + 'Misses - a data block was not in the L2ARC cache. '+ + 'It will be read from the pool disks.

' + }, + + 'zfs.demand_data_hits': { + info: '

Hit rate of the ARC data demand read requests. '+ + 'Demand requests are triggered by an application request.

'+ + 'Hits - a data block was in the ARC DRAM cache and returned. '+ + 'Misses - a data block was not in the ARC DRAM cache. '+ + 'It will be read from the L2ARC cache devices (if available and the data is cached on them) or the pool disks.

' + }, + + 'zfs.prefetch_data_hits': { + info: '

Hit rate of the ARC data prefetch read requests. '+ + 'Prefetch requests are triggered by the prefetch mechanism, not directly from an application request.

'+ + '

Hits - a data block was in the ARC DRAM cache and returned. '+ + 'Misses - a data block was not in the ARC DRAM cache. '+ + 'It will be read from the L2ARC cache devices (if available and the data is cached on them) or the pool disks.

' + }, + + 'zfs.list_hits': { + info: 'MRU (most recently used) and MFU (most frequently used) cache list hits. '+ + 'MRU and MFU lists contain metadata for requested blocks which are cached. '+ + 'Ghost lists contain metadata of the evicted pages on disk.' + }, + + 'zfs.arc_size_breakdown': { + info: 'The size of MRU (most recently used) and MFU (most frequently used) cache.' + }, + + 'zfs.memory_ops': { + info: '

Memory operation statistics.

'+ + '

Direct - synchronous memory reclaim. Data is evicted from the ARC and free slabs reaped. '+ + 'Throttled - number of times that ZFS had to limit the ARC growth. '+ + 'A constant increasing of the this value can indicate excessive pressure to evict data from the ARC. '+ + 'Indirect - asynchronous memory reclaim. It reaps free slabs from the ARC cache.

' + }, + + 'zfs.important_ops': { + info: '

Eviction and insertion operation statistics.

'+ + '

EvictSkip - skipped data eviction operations. '+ + 'Deleted - old data is evicted (deleted) from the cache. '+ + 'MutexMiss - an attempt to get hash or data block mutex when it is locked during eviction. '+ + 'HashCollisions - occurs when two distinct data block numbers have the same hash value.

' + }, + + 'zfs.actual_hits': { + info: '

MRU and MFU cache hit rate.

'+ + '

Hits - a data block was in the ARC DRAM cache and returned. '+ + 'Misses - a data block was not in the ARC DRAM cache. '+ + 'It will be read from the L2ARC cache devices (if available and the data is cached on them) or the pool disks.

' + }, + + 'zfs.hash_elements': { + info: '

Data Virtual Address (DVA) hash table element statistics.

'+ + '

Current - current number of elements. '+ + 'Max - maximum number of elements seen.

' + }, + + 'zfs.hash_chains': { + info: '

Data Virtual Address (DVA) hash table chain statistics. '+ + 'A chain is formed when two or more distinct data block numbers have the same hash value.

'+ + '

Current - current number of chains. '+ + 'Max - longest length seen for a chain. '+ + 'If the value is high, performance may degrade as the hash locks are held longer while the chains are walked.

' + }, + + // ------------------------------------------------------------------------ + // ZFS pools + 'zfspool.state': { + info: 'ZFS pool state. '+ + 'The overall health of a pool, as reported by zpool status, '+ + 'is determined by the aggregate state of all devices within the pool. ' + + 'For states description, '+ + 'see ZFS documentation.' + }, + + // ------------------------------------------------------------------------ + // MYSQL + + 'mysql.net': { + info: 'The amount of data sent to mysql clients (out) and received from mysql clients (in).' + }, + + 'mysql.queries': { + info: 'The number of statements executed by the server.
    ' + + '
  • queries counts the statements executed within stored SQL programs.
  • ' + + '
  • questions counts the statements sent to the mysql server by mysql clients.
  • ' + + '
  • slow queries counts the number of statements that took more than long_query_time seconds to be executed.' + + ' For more information about slow queries check the mysql slow query log.
  • ' + + '
' + }, + + '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 Which dimensions to show? to All from the dashboard settings, to render even the zero values)
    ' + + '
  • commit, the number of internal COMMIT statements.
  • ' + + '
  • delete, the number of times that rows have been deleted from tables.
  • ' + + '
  • prepare, a counter for the prepare phase of two-phase commit operations.
  • ' + + '
  • read first, 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. SELECT col1 FROM foo, with col1 indexed.
  • ' + + '
  • read key, 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.
  • ' + + '
  • read next, 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.
  • ' + + '
  • read prev, the number of requests to read the previous row in key order. This read method is mainly used to optimize ORDER BY ... DESC.
  • ' + + '
  • read rnd, 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.
  • ' + + '
  • read rnd next, 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.
  • ' + + '
  • rollback, the number of requests for a storage engine to perform a rollback operation.
  • ' + + '
  • savepoint, the number of requests for a storage engine to place a savepoint.
  • ' + + '
  • savepoint rollback, the number of requests for a storage engine to roll back to a savepoint.
  • ' + + '
  • update, the number of requests to update a row in a table.
  • ' + + '
  • write, the number of requests to insert a row in a table.
  • ' + + '
' + }, + + 'mysql.table_locks': { + info: 'MySQL table locks counters:
    ' + + '
  • immediate, the number of times that a request for a table lock could be granted immediately.
  • ' + + '
  • waited, 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.
  • ' + + '
' + }, + + 'mysql.innodb_deadlocks': { + info: 'A deadlock happens when two or more transactions mutually hold and request for locks, creating a cycle of dependencies. For more information about how to minimize and handle deadlocks.' + }, + + 'mysql.galera_cluster_status': { + info: "

Status of this cluster component.

Primary - primary group configuration, quorum present. Non-Primary - non-primary group configuration, quorum lost. Disconnected - not connected to group, retrying.

" + }, + + 'mysql.galera_cluster_state': { + info: "

Membership state of this cluster component.

Undefined - undefined state. Joining - the node is attempting to join the cluster. Donor - the node has blocked itself while it sends a State Snapshot Transfer (SST) to bring a new node up to date with the cluster. Joined - the node has successfully joined the cluster. Synced - the node has established a connection with the cluster and synchronized its local databases with those of the cluster. Error - the node is not part of the cluster and does not replicate transactions. This state is provider-specific, check wsrep_local_state_comment variable for a description.

" + }, + + 'mysql.galera_cluster_weight': { + info: 'The value is counted as a sum of pc.weight of the nodes in the current Primary Component.' + }, + + 'mysql.galera_connected': { + info: '0 means that the node has not yet connected to any of the cluster components. ' + + 'This may be due to misconfiguration.' + }, + + 'mysql.open_transactions': { + info: 'The number of locally running transactions which have been registered inside the wsrep provider. ' + + 'This means transactions which have made operations which have caused write set population to happen. ' + + 'Transactions which are read only are not counted.' + }, + + + // ------------------------------------------------------------------------ + // POSTGRESQL + 'postgres.connections_utilization': { + room: { + mainheads: [ + function (_, id) { + return '
'; + } + ], + }, + info: 'Total connection utilization across all databases. Utilization is measured as a percentage of (max_connections - superuser_reserved_connections). If the utilization is 100% no more new connections will be accepted (superuser connections will still be accepted if superuser quota is available).' + }, + 'postgres.connections_usage': { + info: '

Connections usage across all databases. The maximum number of concurrent connections to the database server is (max_connections - superuser_reserved_connections). As a general rule, if you need more than 200 connections it is advisable to use connection pooling.

Available - new connections allowed. Used - connections currently in use.

' + }, + 'postgres.connections_state_count': { + info: '

Number of connections in each state across all databases.

Active - the backend is executing query. Idle - the backend is waiting for a new client command. IdleInTransaction - the backend is in a transaction, but is not currently executing a query. IdleInTransactionAborted - the backend is in a transaction, and not currently executing a query, but one of the statements in the transaction caused an error. FastPathFunctionCall - the backend is executing a fast-path function. Disabled - is reported if track_activities is disabled in this backend.

' + }, + 'postgres.transactions_duration': { + info: 'Running transactions duration histogram. The bins are specified as consecutive, non-overlapping intervals. The value is the number of observed transactions that fall into each interval.' + }, + 'postgres.queries_duration': { + info: 'Active queries duration histogram. The bins are specified as consecutive, non-overlapping intervals. The value is the number of observed active queries that fall into each interval.' + }, + 'postgres.checkpoints_rate': { + info: '

Number of checkpoints that have been performed. Checkpoints are periodic maintenance operations the database performs to make sure that everything it\'s been caching in memory has been synchronized with the disk. Ideally checkpoints should be time-driven (scheduled) as opposed to load-driven (requested).

Scheduled - checkpoints triggered as per schedule when time elapsed from the previous checkpoint is greater than checkpoint_timeout. Requested - checkpoints triggered due to WAL updates reaching the max_wal_size before the checkpoint_timeout is reached.

' + }, + 'postgres.checkpoints_time': { + info: '

Checkpoint timing information. An important indicator of how well checkpoint I/O is performing is the amount of time taken to sync files to disk.

Write - amount of time spent writing files to disk during checkpoint processing. Sync - amount of time spent synchronizing files to disk during checkpoint processing.

' + }, + 'postgres.buffers_allocated_rate': { + info: 'Allocated and re-allocated buffers. If a backend process requests data it is either found in a block in shared buffer cache or the block has to be allocated (read from disk). The latter is counted as Allocated.' + }, + 'postgres.buffers_io_rate': { + info: '

Amount of data flushed from memory to disk.

Checkpoint - buffers written during checkpoints. Backend - buffers written directly by a backend. It may happen that a dirty page is requested by a backend process. In this case the page is synced to disk before the page is returned to the client. BgWriter - buffers written by the background writer. PostgreSQL may clear pages with a low usage count in advance. The process scans for dirty pages with a low usage count so that they could be cleared if necessary. Buffers written by this process increment the counter.

' + }, + 'postgres.bgwriter_halts_rate': { + info: 'Number of times the background writer stopped a cleaning scan because it had written too many buffers (exceeding the value of bgwriter_lru_maxpages).' + }, + 'postgres.buffers_backend_fsync_rate': { + info: 'Number of times a backend had to execute its own fsync call (normally the background writer handles those even when the backend does its own write). Any values above zero can indicate problems with storage when fsync queue is completely filled.' + }, + 'postgres.wal_io_rate': { + info: 'Write-Ahead Logging (WAL) ensures data integrity by ensuring that changes to data files (where tables and indexes reside) are written only after log records describing the changes have been flushed to permanent storage.' + }, + 'postgres.wal_files_count': { + info: '

Number of WAL logs stored in the directory pg_wal under the data directory.

Written - generated log segments files. Recycled - old log segment files that are no longer needed. Renamed to become future segments in the numbered sequence to avoid the need to create new ones.

' + }, + 'postgres.wal_archiving_files_count': { + info: '

WAL archiving.

Ready - WAL files waiting to be archived. A non-zero value can indicate archive_command is in error, see Continuous Archiving and Point-in-Time Recovery. Done - WAL files successfully archived.' + }, + 'postgres.autovacuum_workers_count': { + info: 'PostgreSQL databases require periodic maintenance known as vacuuming. For many installations, it is sufficient to let vacuuming be performed by the autovacuum daemon. For more information see The Autovacuum Daemon.' + }, + 'postgres.txid_exhaustion_towards_autovacuum_perc': { + info: 'Percentage towards emergency autovacuum for one or more tables. A forced autovacuum will run once this value reaches 100%. For more information see Preventing Transaction ID Wraparound Failures.' + }, + 'postgres.txid_exhaustion_perc': { + info: 'Percentage towards transaction wraparound. A transaction wraparound may occur when this value reaches 100%. For more information see Preventing Transaction ID Wraparound Failures.' + }, + 'postgres.txid_exhaustion_oldest_txid_num': { + info: 'The oldest current transaction ID (XID). If for some reason autovacuum fails to clear old XIDs from a table, the system will begin to emit warning messages when the database\'s oldest XIDs reach eleven million transactions from the wraparound point. For more information see Preventing Transaction ID Wraparound Failures.' + }, + 'postgres.uptime': { + room: { + mainheads: [ + function (os, id) { + void (os); + return '

'; + } + ], + }, + info: 'The time elapsed since the Postgres process was started.' + }, + + 'postgres.replication_app_wal_lag_size': { + info: '

Replication WAL lag size.

SentLag - sent over the network. WriteLag - written to disk. FlushLag - flushed to disk. ReplayLag - replayed into the database.

' + }, + 'postgres.replication_app_wal_lag_time': { + info: '

Replication WAL lag time.

WriteLag - time elapsed between flushing recent WAL locally and receiving notification that the standby server has written it, but not yet flushed it or applied it. FlushLag - time elapsed between flushing recent WAL locally and receiving notification that the standby server has written and flushed it, but not yet applied it. ReplayLag - time elapsed between flushing recent WAL locally and receiving notification that the standby server has written, flushed and applied it.

' + }, + 'postgres.replication_slot_files_count': { + info: '

Replication slot files. For more information see Replication Slots.

WalKeep - WAL files retained by the replication slot. PgReplslotFiles - files present in pg_replslot.

' + }, + + 'postgres.db_transactions_ratio': { + info: 'Percentage of committed/rollback transactions.' + }, + 'postgres.db_transactions_rate': { + info: '

Number of transactions that have been performed

Committed - transactions that have been committed. All changes made by the committed transaction become visible to others and are guaranteed to be durable if a crash occurs. Rollback - transactions that have been rolled back. Rollback aborts the current transaction and causes all the updates made by the transaction to be discarded. Single queries that have failed outside the transactions are also accounted as rollbacks.

' + }, + 'postgres.db_connections_utilization': { + info: 'Connection utilization per database. Utilization is measured as a percentage of CONNECTION LIMIT per database (if set) or max_connections (if CONNECTION LIMIT is not set).' + }, + 'postgres.db_connections_count': { + info: 'Number of current connections per database.' + }, + 'postgres.db_cache_io_ratio': { + room: { + mainheads: [ + function (_, id) { + return '
'; + } + ], + }, + info: 'PostgreSQL uses a shared buffer cache to store frequently accessed data in memory, and avoid slower disk reads. If you are seeing performance issues, consider increasing the shared_buffers size or tuning effective_cache_size.' + }, + 'postgres.db_io_rate': { + info: '

Amount of data read from shared buffer cache or from disk.

Disk - data read from disk. Memory - data read from buffer cache (this only includes hits in the PostgreSQL buffer cache, not the operating system\'s file system cache).

' + }, + 'postgres.db_ops_fetched_rows_ratio': { + room: { + mainheads: [ + function (_, id) { + return '
'; + } + ], + }, + info: 'The percentage of rows that contain data needed to execute the query, out of the total number of rows scanned. A high value indicates that the database is executing queries efficiently, while a low value indicates that the database is performing extra work by scanning a large number of rows that aren\'t required to process the query. Low values may be caused by missing indexes or inefficient queries.' + }, + 'postgres.db_ops_read_rows_rate': { + info: '

Read queries throughput.

Returned - Total number of rows scanned by queries. This value indicates rows returned by the storage layer to be scanned, not rows returned to the client. Fetched - Subset of scanned rows (Returned) that contained data needed to execute the query.

' + }, + 'postgres.db_ops_write_rows_rate': { + info: '

Write queries throughput.

Inserted - number of rows inserted by queries. Deleted - number of rows deleted by queries. Updated - number of rows updated by queries.

' + }, + 'postgres.db_conflicts_rate': { + info: 'Number of queries canceled due to conflict with recovery on standby servers. To minimize query cancels caused by cleanup records consider configuring hot_standby_feedback.' + }, + 'postgres.db_conflicts_reason_rate': { + info: '

Statistics about queries canceled due to various types of conflicts on standby servers.

Tablespace - queries that have been canceled due to dropped tablespaces. Lock - queries that have been canceled due to lock timeouts. Snapshot - queries that have been canceled due to old snapshots. Bufferpin - queries that have been canceled due to pinned buffers. Deadlock - queries that have been canceled due to deadlocks.

' + }, + 'postgres.db_deadlocks_rate': { + info: 'Number of detected deadlocks. When a transaction cannot acquire the requested lock within a certain amount of time (configured by deadlock_timeout), it begins deadlock detection.' + }, + 'postgres.db_locks_held_count': { + info: 'Number of held locks. Some of these lock modes are acquired by PostgreSQL automatically before statement execution, while others are provided to be used by applications. All lock modes acquired in a transaction are held for the duration of the transaction. For lock modes details, see table-level locks.' + }, + 'postgres.db_locks_awaited_count': { + info: 'Number of awaited locks. It indicates that some transaction is currently waiting to acquire a lock, which implies that some other transaction is holding a conflicting lock mode on the same lockable object. For lock modes details, see table-level locks.' + }, + 'postgres.db_temp_files_created_rate': { + info: 'Number of temporary files created by queries. Complex queries may require more memory than is available (specified by work_mem). When this happens, Postgres reverts to using temporary files - they are actually stored on disk, but only exist for the duration of the request. After the request returns, the temporary files are deleted.' + }, + 'postgres.db_temp_files_io_rate': { + info: 'Amount of data written temporarily to disk to execute queries.' + }, + 'postgres.db_size': { + room: { + mainheads: [ + function (os, id) { + void (os); + return '
'; + } + ], + }, + info: 'Actual on-disk usage of the database\'s data directory and any associated tablespaces.' + }, + 'postgres.table_rows_dead_ratio': { + info: 'Percentage of dead rows. An increase in dead rows indicates a problem with VACUUM processes, which can slow down your queries.' + }, + 'postgres.table_rows_count': { + info: '

Number of rows. When you do an UPDATE or DELETE, the row is not actually physically deleted. For a DELETE, the database simply marks the row as unavailable for future transactions, and for UPDATE, under the hood it is a combined INSERT then DELETE, where the previous version of the row is marked unavailable.

Live - rows that currently in use and can be queried. Dead - deleted rows that will later be reused for new rows from INSERT or UPDATE.

' + }, + 'postgres.table_ops_rows_rate': { + info: 'Write queries throughput. If you see a large number of updated and deleted rows, keep an eye on the number of dead rows, as a high percentage of dead rows can slow down your queries.' + }, + 'postgres.table_ops_rows_hot_ratio': { + info: 'Percentage of HOT (Heap Only Tuple) updated rows. HOT updates are much more efficient than ordinary updates: less write operations, less WAL writes, vacuum operation has less work to do, increased read efficiency (help to limit table and index bloat).' + }, + 'postgres.table_ops_rows_hot_rate': { + info: 'Number of HOT (Heap Only Tuple) updated rows.' + }, + 'postgres.table_cache_io_ratio': { + info: 'Table cache inefficiency. Percentage of data read from disk. Lower is better.' + }, + 'postgres.table_io_rate': { + info: '

Amount of data read from shared buffer cache or from disk.

Disk - data read from disk. Memory - data read from buffer cache (this only includes hits in the PostgreSQL buffer cache, not the operating system\'s file system cache).

' + }, + 'postgres.table_index_cache_io_ratio': { + info: 'Table indexes cache inefficiency. Percentage of data read from disk. Lower is better.' + }, + 'postgres.table_index_io_rate': { + info: '

Amount of data read from all indexes from shared buffer cache or from disk.

Disk - data read from disk. Memory - data read from buffer cache (this only includes hits in the PostgreSQL buffer cache, not the operating system\'s file system cache).

' + }, + 'postgres.table_toast_cache_io_ratio': { + info: 'Table TOAST cache inefficiency. Percentage of data read from disk. Lower is better.' + }, + 'postgres.table_toast_io_rate': { + info: '

Amount of data read from TOAST table from shared buffer cache or from disk.

Disk - data read from disk. Memory - data read from buffer cache (this only includes hits in the PostgreSQL buffer cache, not the operating system\'s file system cache).

' + }, + 'postgres.table_toast_index_cache_io_ratio': { + info: 'Table TOAST indexes cache inefficiency. Percentage of data read from disk. Lower is better.' + }, + 'postgres.table_toast_index_io_rate': { + info: '

Amount of data read from this table\'s TOAST table indexes from shared buffer cache or from disk.

Disk - data read from disk. Memory - data read from buffer cache (this only includes hits in the PostgreSQL buffer cache, not the operating system\'s file system cache).

' + }, + 'postgres.table_scans_rate': { + info: '

Number of scans initiated on this table. If you see that your database regularly performs more sequential scans over time, you can improve its performance by creating an index on data that is frequently accessed.

Index - relying on an index to point to the location of specific rows. Sequential - have to scan through each row of a table sequentially. Typically, take longer than index scans.

' + }, + 'postgres.table_scans_rows_rate': { + info: 'Number of live rows fetched by scans.' + }, + 'postgres.table_autovacuum_since_time': { + info: 'Time elapsed since this table was vacuumed by the autovacuum daemon.' + }, + 'postgres.table_vacuum_since_time': { + info: 'Time elapsed since this table was manually vacuumed (not counting VACUUM FULL).' + }, + 'postgres.table_autoanalyze_since_time': { + info: 'Time elapsed this table was analyzed by the autovacuum daemon.' + }, + 'postgres.table_analyze_since_time': { + info: 'Time elapsed since this table was manually analyzed.' + }, + 'postgres.table_null_columns': { + info: 'Number of table columns that contain only NULLs.' + }, + 'postgres.table_total_size': { + info: 'Actual on-disk size of the table.' + }, + 'postgres.table_bloat_size_perc': { + info: 'Estimated percentage of bloat in the table. It is normal for tables that are updated frequently to have a small to moderate amount of bloat.' + }, + 'postgres.table_bloat_size': { + info: 'Disk space that was used by the table and is available for reuse by the database but has not been reclaimed. Bloated tables require more disk storage and additional I/O that can slow down query execution. Running VACUUM regularly on a table that is updated frequently results in fast reuse of space occupied by expired rows, which prevents the table from growing too large.' + }, + 'postgres.index_size': { + info: 'Actual on-disk size of the index.' + }, + 'postgres.index_bloat_size_perc': { + info: 'Estimated percentage of bloat in the index.' + }, + 'postgres.index_bloat_size': { + info: 'Disk space that was used by the index and is available for reuse by the database but has not been reclaimed. Bloat slows down your database and eats up more storage than needed. To recover the space from indexes, recreate them using the REINDEX command.' + }, + 'postgres.index_usage_status': { + info: 'An index is considered unused if no scans have been initiated on that index.' + }, + + + // ------------------------------------------------------------------------ + // PgBouncer + 'pgbouncer.client_connections_utilization': { + info: 'Client connections in use as percentage of max_client_conn (default 100).' + }, + 'pgbouncer.db_client_connections': { + info: '

Client connections in different states.

Active - linked to server connection and can process queries. Waiting - have sent queries but have not yet got a server connection. CancelReq - have not forwarded query cancellations to the server yet.

' + }, + 'pgbouncer.db_server_connections': { + info: '

Server connections in different states.

Active - linked to a client. Idle - unused and immediately usable for client queries. Used - have been idle for more than server_check_delay, so they need server_check_query to run on them before they can be used again. Tested - currently running either server_reset_query or server_check_query. Login - currently in the process of logging in.

' + }, + 'pgbouncer.db_server_connections_utilization': { + info: 'Server connections in use as percentage of max_db_connections (default 0 - unlimited). This considers the PgBouncer database that the client has connected to, not the PostgreSQL database of the outgoing connection.' + }, + 'pgbouncer.db_clients_wait_time': { + info: 'Time spent by clients waiting for a server connection. This shows if the decrease in database performance from the client\'s point of view was due to exhaustion of the corresponding PgBouncer pool.' + }, + 'pgbouncer.db_client_max_wait_time': { + info: 'Waiting time for the first (oldest) client in the queue. If this starts increasing, then the current pool of servers does not handle requests quickly enough.' + }, + 'pgbouncer.db_transactions': { + info: 'SQL transactions pooled (proxied) by pgbouncer.' + }, + 'pgbouncer.db_transactions_time': { + info: 'Time spent by pgbouncer when connected to PostgreSQL in a transaction, either idle in transaction or executing queries.' + }, + 'pgbouncer.db_transaction_avg_time': { + info: 'Average transaction duration.' + }, + 'pgbouncer.db_queries': { + info: 'SQL queries pooled (proxied) by pgbouncer.' + }, + 'pgbouncer.db_queries_time': { + info: 'Time spent by pgbouncer when actively connected to PostgreSQL, executing queries.' + }, + 'pgbouncer.db_query_avg_time': { + info: 'Average query duration.' + }, + 'pgbouncer.db_network_io': { + info: '

Network traffic received and sent by pgbouncer.

Received - received from clients. Sent - sent to servers.

' + }, + + // ------------------------------------------------------------------------ + // CASSANDRA + + 'cassandra.client_requests_rate': { + info: 'Client requests received per second. Consider whether your workload is read-heavy or write-heavy while choosing a compaction strategy.' + }, + 'cassandra.client_requests_latency': { + info: 'Response latency of requests received per second. Latency could be impacted by disk access, network latency or replication configuration.' + }, + 'cassandra.key_cache_hit_ratio': { + info: 'Key cache hit ratio indicates the efficiency of the key cache. If ratio is consistently < 80% consider increasing cache size.' + }, + 'cassandra.key_cache_hit_rate': { + info: 'Key cache hit rate measures the cache hits and misses per second.' + }, + 'cassandra.storage_live_disk_space_used': { + info: 'Amount of live disk space used. This does not include obsolete data waiting to be garbage collected.' + }, + 'cassandra.compaction_completed_tasks_rate': { + info: 'Compaction tasks completed per second.' + }, + 'cassandra.compaction_pending_tasks_count': { + info: 'Total compaction tasks in queue.' + }, + 'cassandra.thread_pool_active_tasks_count': { + info: 'Total tasks currently being processed.' + }, + 'cassandra.thread_pool_pending_tasks_count': { + info: 'Total tasks in queue awaiting a thread for processing.' + }, + 'cassandra.thread_pool_blocked_tasks_rate': { + info: 'Tasks that cannot be queued for processing yet.' + }, + 'cassandra.thread_pool_blocked_tasks_count': { + info: 'Total tasks that cannot yet be queued for processing.' + }, + 'cassandra.jvm_gc_rate': { + info: 'Rate of garbage collections.

ParNew - young-generation. cms (ConcurrentMarkSweep) - old-generation.

' + }, + 'cassandra.jvm_gc_time': { + info: 'Elapsed time of garbage collection.

ParNew - young-generation. cms (ConcurrentMarkSweep) - old-generation.

' + }, + 'cassandra.client_requests_timeouts_rate': { + info: 'Requests which were not acknowledged within the configurable timeout window.' + }, + 'cassandra.client_requests_unavailables_rate': { + info: 'Requests for which the required number of nodes was unavailable.' + }, + 'cassandra.storage_exceptions_rate': { + info: 'Requests for which a storage exception was encountered.' + }, + + // ------------------------------------------------------------------------ + // Consul + 'consul.node_health_check_status': { + info: 'The current status of the node health check. A node health check monitors the health of the entire node. If the node health check fails, Consul marks the node as unhealthy.' + }, + 'consul.service_health_check_status': { + info: 'The current status of the service health check. A service check only affects the health of the service it is associated with. If the service health check fails, the DNS interface stops returning that service.' + }, + 'consul.client_rpc_requests_rate': { + info: 'The number of RPC requests to a Consul server.' + }, + 'consul.client_rpc_requests_exceeded_rate': { + info: 'The number of rate-limited RPC requests to a Consul server. An Increase of this metric either indicates the load is getting high enough to limit the rate or a incorrectly configured Consul agent.' + }, + 'consul.client_rpc_requests_failed_rate': { + info: 'The number of failed RPC requests to a Consul server.' + }, + 'consul.memory_allocated': { + info: 'The amount of memory allocated by the Consul process.' + }, + 'consul.memory_sys': { + info: 'The amount of memory obtained from the OS.' + }, + 'consul.gc_pause_time': { + info: 'The amount of time spent in garbage collection (GC) pauses. GC pause is a "stop-the-world" event, meaning that all runtime threads are blocked until GC completes. If memory usage is high, the Go runtime may GC so frequently that it starts to slow down Consul.' + }, + 'consul.kvs_apply_time': { + info: 'The time it takes to complete an update to the KV store.' + }, + 'consul.kvs_apply_operations_rate': { + info: 'The number of KV store updates.' + }, + 'consul.txn_apply_time': { + info: 'The time spent applying a transaction operation.' + }, + 'consul.txn_apply_operations_rate': { + info: 'The number of applied transaction operations.' + }, + 'consul.raft_commit_time': { + info: 'The time it takes to commit a new entry to the Raft log on the leader.' + }, + 'consul.raft_commits_rate': { + info: 'The number of applied Raft transactions.' + }, + 'consul.autopilot_health_status': { + info: 'The overall health of the local server cluster. The status is healthy if all servers are considered healthy by Autopilot.' + }, + 'consul.autopilot_server_health_status': { + info: 'Whether the server is healthy according to the current Autopilot configuration.' + }, + 'consul.autopilot_server_stable_time': { + info: 'The time this server has been in its current state.' + }, + 'consul.autopilot_server_serf_status': { + info: 'The SerfHealth check status for the server.' + }, + 'consul.autopilot_server_voter_status': { + info: 'Whether the server is a voting member of the Raft cluster.' + }, + 'consul.autopilot_failure_tolerance': { + info: 'The number of voting servers that the cluster can lose while continuing to function.' + }, + 'consul.network_lan_rtt': { + info: 'Estimated network round-trip time between this node and other nodes of the cluster.' + }, + 'consul.raft_leader_last_contact_time': { + info: 'The time since the leader was last able to contact the follower nodes when checking its leader lease.' + }, + 'consul.raft_follower_last_contact_leader_time': { + info: 'The time elapsed since this server last contacted the leader.' + }, + 'consul.raft_leader_elections_rate': { + info: 'The number of leadership elections. Increments whenever a Consul server starts an election.' + }, + 'consul.raft_leadership_transitions_rate': { + info: 'The number of leadership elections. Increments whenever a Consul server becomes a leader.' + }, + 'consul.server_leadership_status': { + info: 'The Consul server leadership status.' + }, + 'consul.raft_thread_main_saturation_perc': { + info: 'An approximate measurement of the proportion of time the main Raft goroutine is busy and unavailable to accept new work.' + }, + 'consul.raft_thread_fsm_saturation_perc': { + info: 'An approximate measurement of the proportion of time the Raft FSM goroutine is busy and unavailable to accept new work.' + }, + 'consul.raft_fsm_last_restore_duration': { + info: 'The time taken to restore the FSM from a snapshot on an agent restart or from the leader calling installSnapshot.' + }, + 'consul.raft_leader_oldest_log_age': { + info: 'The time elapsed since the oldest journal was written to the leader\'s journal storage. This can be important for the health of replication when the write rate is high and the snapshot is large, because followers may not be able to recover from a restart if recovery takes longer than the minimum for the current leader.' + }, + 'consul.raft_rpc_install_snapshot_time': { + info: 'The time it takes to process the installSnapshot RPC call.' + }, + 'consul.raft_boltdb_freelist_bytes': { + info: 'The number of bytes necessary to encode the freelist metadata. When raft_boltdb.NoFreelistSync is set to false these metadata bytes must also be written to disk for each committed log.' + }, + 'consul.raft_boltdb_logs_per_batch_rate': { + info: 'The number of logs written per batch to the database.' + }, + 'consul.raft_boltdb_store_logs_time': { + info: 'The amount of time spent writing logs to the database.' + }, + 'consul.license_expiration_time': { + info: 'The amount of time remaining before Consul Enterprise license expires. When the license expires, some Consul Enterprise features will stop working.' + }, + + // ------------------------------------------------------------------------ + // Windows (Process) + + 'windows.processes_cpu_time': { + info: 'Total CPU utilization. The amount of time spent by the process in user and privileged modes.' + }, + 'windows.processes_handles': { + info: 'Total number of handles the process has open. This number is the sum of the handles currently open by each thread in the process.' + }, + 'windows.processes_io_bytes': { + info: 'Bytes issued to I/O operations in different modes (read, write, other). This property counts all I/O activity generated by the process to include file, network, and device I/Os. Read and write mode includes data operations; other mode includes those that do not involve data, such as control operations.' + }, + 'windows.processes_io_operations': { + info: 'I/O operations issued in different modes (read, write, other). This property counts all I/O activity generated by the process to include file, network, and device I/Os. Read and write mode includes data operations; other mode includes those that do not involve data, such as control operations.' + }, + 'windows.processes_page_faults': { + info: 'Page faults by the threads executing in this process. A page fault occurs when a thread refers to a virtual memory page that is not in its working set in main memory. This can cause the page not to be fetched from disk if it is on the standby list and hence already in main memory, or if it is in use by another process with which the page is shared.' + }, + 'windows.processes_file_bytes': { + info: 'Current number of bytes this process has used in the paging file(s). Paging files are used to store pages of memory used by the process that are not contained in other files. Paging files are shared by all processes, and lack of space in paging files can prevent other processes from allocating memory.' + }, + 'windows.processes_pool_bytes': { + info: 'Pool Bytes is the last observed number of bytes in the paged or nonpaged pool. The nonpaged pool is an area of system memory (physical memory used by the operating system) for objects that cannot be written to disk, but must remain in physical memory as long as they are allocated. The paged pool is an area of system memory (physical memory used by the operating system) for objects that can be written to disk when they are not being used.' + }, + 'windows.processes_threads': { + info: 'Number of threads currently active in this process. An instruction is the basic unit of execution in a processor, and a thread is the object that executes instructions. Every running process has at least one thread.' + }, + + // ------------------------------------------------------------------------ + // Windows (TCP) + + 'windows.tcp_conns_active': { + info: 'Number of times TCP connections have made a direct transition from the CLOSED state to the SYN-SENT state.' + }, + 'windows.tcp_conns_established': { + info: 'Number of TCP connections for which the current state is either ESTABLISHED or CLOSE-WAIT.' + }, + 'windows.tcp_conns_failures': { + info: 'Number of times TCP connections have made a direct transition to the CLOSED state from the SYN-SENT state or the SYN-RCVD state, plus the number of times TCP connections have made a direct transition from the SYN-RCVD state to the LISTEN state.' + }, + 'windows.tcp_conns_passive': { + info: 'Number of times TCP connections have made a direct transition from the LISTEN state to the SYN-RCVD state.' + }, + 'windows.tcp_conns_resets': { + info: 'Number of times TCP connections have made a direct transition from the LISTEN state to the SYN-RCVD state.' + }, + 'windows.tcp_segments_received': { + info: 'Rate at which segments are received, including those received in error. This count includes segments received on currently established connections.' + }, + 'windows.tcp_segments_retransmitted': { + info: 'Rate at which segments are retransmitted, that is, segments transmitted that contain one or more previously transmitted bytes.' + }, + 'windows.tcp_segments_sent': { + info: 'Rate at which segments are sent, including those on current connections, but excluding those containing only retransmitted bytes.' + }, + + // ------------------------------------------------------------------------ + // Windows (IIS) + + 'iis.website_isapi_extension_requests_count': { + info: 'The number of ISAPI extension requests that are processed concurrently by the web service.' + }, + 'iis.website_errors_rate': { + info: '

The number of requests that cannot be satisfied by the server.

DocumentLocked - the requested document was locked. Usually reported as HTTP error 423. DocumentNotFound - the requested document was not found. Usually reported as HTTP error 404.

' + }, + + // ------------------------------------------------------------------------ + // Windows (Service) + + 'windows.service_status': { + info: 'The current status of the service.' + }, + + // ------------------------------------------------------------------------ + // Windows (MSSQL) + + 'mssql.instance_accessmethods_page_splits': { + info : 'Page split happens when the page does not have more space. This chart shows the number of page splits per second that occur as the result of overflowing index pages.' + }, + + 'mssql.instance_cache_hit_ratio': { + info : 'Indicates the percentage of pages found in the buffer cache without having to read from disk. The ratio is the total number of cache hits divided by the total number of cache lookups over the last few thousand page accesses. After a long period of time, the ratio moves very little. Because reading from the cache is much less expensive than reading from disk, you want this ratio to be high.' + }, + + 'mssql.instance_bufman_checkpoint_pages': { + info : 'Indicates the number of pages flushed to disk per second by a checkpoint or other operation that require all dirty pages to be flushed.' + }, + + 'mssql.instance_bufman_page_life_expectancy': { + info : 'Indicates the number of seconds a page will stay in the buffer pool without references.' + }, + + 'mssql.instance_memmgr_external_benefit_of_memory': { + info : 'It is used by the engine to balance memory usage between cache and is useful to support when troubleshooting cases with unexpected cache growth. The value is presented as an integer based on an internal calculation.' + }, + + 'mssql.instance_sql_errors': { + info: 'Errors in Microsoft SQL Server.

Db_offline - Tracks severe errors that cause SQL Server to take the current database offline. Info - Information related to error messages that provide information to users but do not cause errors. Kill_connection - Tracks severe errors that cause SQL Server to kill the current connection. User - User errors.

' + }, + + 'mssql.instance_sqlstats_auto_parameterization_attempts': { + info: 'Auto-parameterization occurs when an instance of SQL Server tries to parameterize a Transact-SQL request by replacing some literals with parameters so that reuse of the resulting cached execution plan across multiple similar-looking requests is possible. Note that auto-parameterizations are also known as simple parameterizations in newer versions of SQL Server. This counter does not include forced parameterizations.' + }, + + 'mssql.instance_sqlstats_batch_requests': { + info: 'This statistic is affected by all constraints (such as I/O, number of users, cache size, complexity of requests, and so on). High batch requests mean good throughput.' + }, + + 'mssql.instance_sqlstats_safe_auto_parameterization_attempts': { + info: 'Note that auto-parameterizations are also known as simple parameterizations in later versions of SQL Server.' + }, + + 'mssql.instance_sqlstats_sql_compilations': { + info: 'Indicates the number of times the compile code path is entered. Includes compiles caused by statement-level recompilations in SQL Server. After SQL Server user activity is stable, this value reaches a steady state.' + }, + + // ------------------------------------------------------------------------ + // Windows (AD) + + 'ad.dra_replication_intersite_compressed_traffic': { + info: 'The compressed size, in bytes, of inbound and outbound compressed replication data (size after compression, from DSAs in other sites).' + }, + + 'ad.dra_replication_intrasite_compressed_traffic': { + info: 'The number of bytes replicated that were not compressed (that is., from DSAs in the same site).' + }, + + 'ad.dra_replication_properties_updated': { + info: 'The number of properties that are updated due to incoming property winning the reconciliation logic that determines the final value to be replicated.' + }, + + 'ad.dra_replication_objects_filtered': { + info: 'The number of objects received from inbound replication partners that contained no updates that needed to be applied.' + }, + + 'ad.dra_replication_pending_syncs': { + info: 'The number of directory synchronizations that are queued for this server but not yet processed.' + }, + + 'ad.dra_replication_sync_requests': { + info: 'The number of directory synchronizations that are queued for this server but not yet processed.' + }, + + // ------------------------------------------------------------------------ + // Windows (NET Framework: Exception) + + 'netframework.clrexception_thrown': { + info: 'The exceptions include both .NET exceptions and unmanaged exceptions that are converted into .NET exceptions.' + }, + + 'netframework.clrexception_filters': { + info: 'An exception filter evaluates regardless of whether an exception is handled.' + }, + + 'netframework.clrexception_finallys': { + info: 'The metric counts only the finally blocks executed for an exception; finally blocks on normal code paths are not counted by this counter.' + }, + + // ------------------------------------------------------------------------ + // Windows (NET Framework: Interop) + + 'netframework.clrinterop_com_callable_wrappers': { + info: 'A COM callable wrappers (CCW) is a proxy for a managed object being referenced from an unmanaged COM client.' + }, + + 'netframework.clrinterop_interop_stubs_created': { + info: 'The Stubs are responsible for marshaling arguments and return values from managed to unmanaged code, and vice versa, during a COM interop call or a platform invoke call.' + }, + + // ------------------------------------------------------------------------ + // Windows (NET Framework: JIT) + + 'netframework.clrjit_methods': { + info: 'The metric does not include pre-JIT-compiled methods.' + }, + + 'netframework.clrjit_time': { + info: 'The metric is updated at the end of every JIT compilation phase. A JIT compilation phase occurs when a method and its dependencies are compiled.' + }, + + 'netframework.clrjit_standard_failures': { + info: 'The failure can occur if the MSIL cannot be verified or if there is an internal error in the JIT compiler.' + }, + + // ------------------------------------------------------------------------ + // Windows (NET Framework: Loading) + + 'netframework.clrloading_loader_heap_size': { + info: 'The memory committed by the class loader across all application domains is the physical space reserved in the disk paging file.' + }, + + 'netframework.clrloading_assemblies_loaded': { + info: 'If the assembly is loaded as domain-neutral from multiple application domains, the metric is incremented only once.' + }, + + // ------------------------------------------------------------------------ + // Windows (NET Framework: Locks and Threads) + + 'netframework.clrlocksandthreads_recognized_threads': { + info: 'Displays the total number of threads that have been recognized by the runtime since the application started. These threads are associated with a corresponding managed thread object. The runtime does not create these threads, but they have run inside the runtime at least once.' + }, + + // ------------------------------------------------------------------------ + // Windows (NET Framework: Memory) + + 'netframework.clrmemory_heap_size': { + info: 'The metric shows maximum bytes that can be allocated, but it does not indicate the current number of bytes allocated.' + }, + + 'netframework.clrmemory_promoted': { + info: 'Memory is promoted when it survives a garbage collection.' + }, + + 'netframework.clrmemory_number_gc_handles': { + info: 'Garbage collection handles are handles to resources external to the common language runtime and the managed environment.' + }, + + 'netframework.clrmemory_induced_gc': { + info: 'The metric is updated when an explicit call to GC.Collect happens.' + }, + + 'netframework.clrmemory_number_sink_blocks_in_use': { + info: 'Synchronization blocks are per-object data structures allocated for storing synchronization information. They hold weak references to managed objects and must be scanned by the garbage collector.' + }, + + 'netframework.clrmemory_committed': { + info: 'Committed memory is the physical memory for which space has been reserved in the disk paging file.' + }, + + 'netframework.clrmemory_reserved': { + info: 'Reserved memory is the virtual memory space reserved for the application when no disk or main memory pages have been used.' + }, + + 'netframework.clrmemory_gc_time': { + info: 'Displays the percentage of time that was spent performing a garbage collection in the last sample.' + }, + + // ------------------------------------------------------------------------ + // APACHE + + 'apache.connections': { + colors: NETDATA.colors[4], + mainheads: [ + netdataDashboard.gaugeChart('Connections', '12%', '', NETDATA.colors[4]) + ] + }, + + 'apache.requests': { + colors: NETDATA.colors[0], + mainheads: [ + netdataDashboard.gaugeChart('Requests', '12%', '', NETDATA.colors[0]) + ] + }, + + 'apache.net': { + colors: NETDATA.colors[3], + mainheads: [ + netdataDashboard.gaugeChart('Bandwidth', '12%', '', NETDATA.colors[3]) + ] + }, + + 'apache.workers': { + mainheads: [ + function (os, id) { + void (os); + return '
'; + } + ] + }, + + '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 + }, + + + // ------------------------------------------------------------------------ + // LIGHTTPD + + 'lighttpd.connections': { + colors: NETDATA.colors[4], + mainheads: [ + netdataDashboard.gaugeChart('Connections', '12%', '', NETDATA.colors[4]) + ] + }, + + 'lighttpd.requests': { + colors: NETDATA.colors[0], + mainheads: [ + netdataDashboard.gaugeChart('Requests', '12%', '', NETDATA.colors[0]) + ] + }, + + 'lighttpd.net': { + colors: NETDATA.colors[3], + mainheads: [ + netdataDashboard.gaugeChart('Bandwidth', '12%', '', NETDATA.colors[3]) + ] + }, + + 'lighttpd.workers': { + mainheads: [ + function (os, id) { + void (os); + return '
'; + } + ] + }, + + 'lighttpd.bytesperreq': { + colors: NETDATA.colors[3], + height: 0.5 + }, + + 'lighttpd.reqpersec': { + colors: NETDATA.colors[4], + height: 0.5 + }, + + 'lighttpd.bytespersec': { + colors: NETDATA.colors[6], + height: 0.5 + }, + + // ------------------------------------------------------------------------ + // NGINX + + 'nginx.connections': { + colors: NETDATA.colors[4], + mainheads: [ + netdataDashboard.gaugeChart('Connections', '12%', '', NETDATA.colors[4]) + ] + }, + + 'nginx.requests': { + colors: NETDATA.colors[0], + mainheads: [ + netdataDashboard.gaugeChart('Requests', '12%', '', NETDATA.colors[0]) + ] + }, + + // ------------------------------------------------------------------------ + // NGINX Plus + 'nginxplus.client_connections_rate': { + info: 'Accepted and dropped (not handled) connections. A connection is considered dropped if the worker process is unable to get a connection for the request by establishing a new connection or reusing an open one.' + }, + 'nginxplus.client_connections_count': { + info: 'The current number of client connections. A connection is considered idle if there are currently no active requests.' + }, + 'nginxplus.ssl_handshakes_rate': { + info: 'Successful and failed SSL handshakes.' + }, + 'nginxplus.ssl_session_reuses_rate': { + info: 'The number of session reuses during SSL handshake.' + }, + 'nginxplus.ssl_handshakes_failures_rate': { + info: '

SSL handshake failures.

NoCommonProtocol - failed because of no common protocol. NoCommonCipher - failed because of no shared cipher. Timeout - failed because of a timeout. PeerRejectedCert - failed because a client rejected the certificate.

' + }, + 'nginxplus.ssl_verification_errors_rate': { + info: '

SSL verification errors.

NoCert - a client did not provide the required certificate. ExpiredCert - an expired or not yet valid certificate was presented by a client. RevokedCert - a revoked certificate was presented by a client. HostnameMismatch - server\'s certificate does not match the hostname. Other - other SSL certificate verification errors.

' + }, + 'nginxplus.http_requests_rate': { + info: 'The number of HTTP requests received from clients.' + }, + 'nginxplus.http_requests_count': { + info: 'The current number of client requests.' + }, + 'nginxplus.uptime': { + info: 'The time elapsed since the NGINX process was started.' + }, + 'nginxplus.http_server_zone_requests_rate': { + info: 'The number of requests to the HTTP Server Zone.' + }, + 'nginxplus.http_server_zone_responses_per_code_class_rate': { + info: 'The number of responses from the HTTP Server Zone. Responses grouped by HTTP status code class.' + }, + 'nginxplus.http_server_zone_traffic_rate': { + info: 'The amount of data transferred to and from the HTTP Server Zone.' + }, + 'nginxplus.http_server_zone_requests_processing_count': { + info: 'The number of client requests that are currently being processed by the HTTP Server Zone.' + }, + 'nginxplus.http_server_zone_requests_discarded_rate': { + info: 'The number of requests to the HTTP Server Zone completed without sending a response.' + }, + 'nginxplus.http_location_zone_requests_rate': { + info: 'The number of requests to the HTTP Location Zone.' + }, + 'nginxplus.http_location_zone_responses_per_code_class_rate': { + info: 'The number of responses from the HTTP Location Zone. Responses grouped by HTTP status code class.' + }, + 'nginxplus.http_location_zone_traffic_rate': { + info: 'The amount of data transferred to and from the HTTP Location Zone.' + }, + 'nginxplus.http_location_zone_requests_discarded_rate': { + info: 'The number of requests to the HTTP Location Zone completed without sending a response.' + }, + 'nginxplus.http_upstream_peers_count': { + info: 'The number of HTTP Upstream servers.' + }, + 'nginxplus.http_upstream_zombies_count': { + info: 'The current number of HTTP Upstream servers removed from the group but still processing active client requests.' + }, + 'nginxplus.http_upstream_keepalive_count': { + info: 'The current number of idle keepalive connections to the HTTP Upstream.' + }, + 'nginxplus.http_upstream_server_requests_rate': { + info: 'The number of client requests forwarded to the HTTP Upstream Server.' + }, + 'nginxplus.http_upstream_server_responses_per_code_class_rate': { + info: 'The number of responses received from the HTTP Upstream Server. Responses grouped by HTTP status code class.' + }, + 'nginxplus.http_upstream_server_response_time': { + info: 'The average time to get a complete response from the HTTP Upstream Server.' + }, + 'nginxplus.http_upstream_server_response_header_time': { + info: 'The average time to get a response header from the HTTP Upstream Server.' + }, + 'nginxplus.http_upstream_server_traffic_rate': { + info: 'The amount of traffic transferred to and from the HTTP Upstream Server.' + }, + 'nginxplus.http_upstream_server_state': { + info: 'The current state of the HTTP Upstream Server. Status active if set to 1.' + }, + 'nginxplus.http_upstream_server_connections_count': { + info: 'The current number of active connections to the HTTP Upstream Server.' + }, + 'nginxplus.http_upstream_server_downtime': { + info: 'The time the HTTP Upstream Server has spent in the unavail, checking, and unhealthy states.' + }, + 'nginxplus.http_cache_state': { + info: 'HTTP cache current state. Cold means that the cache loader process is still loading data from disk into the cache.' + }, + 'nginxplus.http_cache_iops': { + info: '

HTTP cache IOPS.

Served - valid, expired, and revalidated responses read from the cache. Written - miss, expired, and bypassed responses written to the cache. Bypassed - miss, expired, and bypass responses.

' + }, + 'nginxplus.http_cache_io': { + info: '

HTTP cache IO.

Served - valid, expired, and revalidated responses read from the cache. Written - miss, expired, and bypassed responses written to the cache. Bypassed - miss, expired, and bypass responses.

' + }, + 'nginxplus.http_cache_size': { + info: 'The current size of the cache.' + }, + 'nginxplus.stream_server_zone_connections_rate': { + info: 'The number of accepted connections to the Stream Server Zone.' + }, + 'nginxplus.stream_server_zone_sessions_per_code_class_rate': { + info: 'The number of completed sessions for the Stream Server Zone. Sessions grouped by status code class.' + }, + 'nginxplus.stream_server_zone_traffic_rate': { + info: 'The amount of data transferred to and from the Stream Server Zone.' + }, + 'nginxplus.stream_server_zone_connections_processing_count': { + info: 'The number of client connections to the Stream Server Zone that are currently being processed.' + }, + 'nginxplus.stream_server_zone_connections_discarded_rate': { + info: 'The number of connections to the Stream Server Zone completed without creating a session.' + }, + 'nginxplus.stream_upstream_peers_count': { + info: 'The number of Stream Upstream servers.' + }, + 'nginxplus.stream_upstream_zombies_count': { + info: 'The current number of HTTP Upstream servers removed from the group but still processing active client connections.' + }, + 'nginxplus.stream_upstream_server_connections_rate': { + info: 'The number of connections forwarded to the Stream Upstream Server.' + }, + 'nginxplus.stream_upstream_server_traffic_rate': { + info: 'The amount of traffic transferred to and from the Stream Upstream Server.' + }, + 'nginxplus.stream_upstream_server_state': { + info: 'The current state of the Stream Upstream Server. Status active if set to 1.' + }, + 'nginxplus.stream_upstream_server_downtime': { + info: 'The time the Stream Upstream Server has spent in the unavail, checking, and unhealthy states.' + }, + 'nginxplus.stream_upstream_server_connections_count': { + info: 'The current number of connections to the Stream Upstream Server.' + }, + 'nginxplus.resolver_zone_requests_rate': { + info: '

Resolver zone DNS requests.

Name - requests to resolve names to addresses. Srv - requests to resolve SRV records. Addr - requests to resolve addresses to names.

' + }, + 'nginxplus.resolver_zone_responses_rate': { + info: '

Resolver zone DNS responses.

NoError - successful responses. FormErr - format error responses. ServFail - server failure responses. NXDomain - host not found responses. NotImp - unimplemented responses. Refused - operation refused responses. TimedOut - timed out requests. Unknown - requests completed with an unknown error.

' + }, + + // ------------------------------------------------------------------------ + // HTTP check + + 'httpcheck.responsetime': { + info: 'The response time describes the time passed between request and response. ' + + 'Currently, the accuracy of the response time is low and should be used as reference only.' + }, + + 'httpcheck.responselength': { + info: 'The response length counts the number of characters in the response body. For static pages, this should be mostly constant.' + }, + + 'httpcheck.status': { + valueRange: "[0, 1]", + info: 'This chart verifies the response of the webserver. Each status dimension will have a value of 1 if triggered. ' + + 'Dimension success is 1 only if all constraints are satisfied. ' + + 'This chart is most useful for alarms or third-party apps.' + }, + + // ------------------------------------------------------------------------ + // 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).' + }, + + 'netdata.ebpf_threads': { + info: 'Show thread status. Threads running have value 1 an stopped value 0. For more details about the threads, see the official documentation.' + }, + + 'netdata.ebpf_life_time': { + info: 'Time remaining for thread shutdown itself.' + }, + + 'netdata.ebpf_load_methods': { + info: 'Show number of threads loaded using legacy code (independent binary) or CO-RE (Compile Once Run Everywhere).' + }, + + 'netdata.ebpf_kernel_memory': { + info: 'Show amount of memory allocated inside kernel ring for hash tables. This chart shows the same information displayed by command `bpftool map show`.' + }, + + 'netdata.ebpf_hash_tables_count': { + info: 'Show total number of hash tables loaded by eBPF.plugin`.' + }, + + 'netdata.ebpf_aral_stat_size': { + info: 'Show total memory allocated for the specific ARAL.' + }, + + 'netdata.ebpf_aral_stat_alloc': { + info: 'Show total memory of calls to get a specific region of memory inside an ARAL region.' + }, + +// ------------------------------------------------------------------------ + // RETROSHARE + + 'retroshare.bandwidth': { + info: 'RetroShare inbound and outbound traffic.', + mainheads: [ + netdataDashboard.gaugeChart('Received', '12%', 'bandwidth_down_kb'), + netdataDashboard.gaugeChart('Sent', '12%', 'bandwidth_up_kb') + ] + }, + + 'retroshare.peers': { + info: 'Number of (connected) RetroShare friends.', + mainheads: [ + function (os, id) { + void (os); + return '
'; + } + ] + }, + + 'retroshare.dht': { + info: 'Statistics about RetroShare\'s DHT. These values are estimated!' + }, + + // ------------------------------------------------------------------------ + // containers + + 'cgroup.cpu_limit': { + valueRange: "[0, null]", + mainheads: [ + function (_, id) { + cgroupCPULimitIsSet = 1; + return '
'; + } + ], + info: cgroupCPULimit + }, + 'cgroup.cpu': { + mainheads: [ + function (_, id) { + if (cgroupCPULimitIsSet === 0) { + return '
'; + } else + return ''; + } + ], + info: cgroupCPU + }, + 'cgroup.throttled': { + info: cgroupThrottled + }, + 'cgroup.throttled_duration': { + info: cgroupThrottledDuration + }, + 'cgroup.cpu_shares': { + info: cgroupCPUShared + }, + 'cgroup.cpu_per_core': { + info: cgroupCPUPerCore + }, + 'cgroup.cpu_some_pressure': { + info: cgroupCPUSomePressure + }, + 'cgroup.cpu_some_pressure_stall_time': { + info: cgroupCPUSomePressureStallTime + }, + 'cgroup.cpu_full_pressure': { + info: cgroupCPUFullPressure + }, + 'cgroup.cpu_full_pressure_stall_time': { + info: cgroupCPUFullPressureStallTime + }, + + 'k8s.cgroup.cpu_limit': { + valueRange: "[0, null]", + mainheads: [ + function (_, id) { + cgroupCPULimitIsSet = 1; + return '
'; + } + ], + info: cgroupCPULimit + }, + 'k8s.cgroup.cpu': { + mainheads: [ + function (_, id) { + if (cgroupCPULimitIsSet === 0) { + return '
'; + } else + return ''; + } + ], + info: cgroupCPU + }, + 'k8s.cgroup.throttled': { + info: cgroupThrottled + }, + 'k8s.cgroup.throttled_duration': { + info: cgroupThrottledDuration + }, + 'k8s.cgroup.cpu_shares': { + info: cgroupCPUShared + }, + 'k8s.cgroup.cpu_per_core': { + info: cgroupCPUPerCore + }, + 'k8s.cgroup.cpu_some_pressure': { + info: cgroupCPUSomePressure + }, + 'k8s.cgroup.cpu_some_pressure_stall_time': { + info: cgroupCPUSomePressureStallTime + }, + 'k8s.cgroup.cpu_full_pressure': { + info: cgroupCPUFullPressure + }, + 'k8s.cgroup.cpu_full_pressure_stall_time': { + info: cgroupCPUFullPressureStallTime + }, + + 'cgroup.mem_utilization': { + info: cgroupMemUtilization + }, + 'cgroup.mem_usage_limit': { + mainheads: [ + function (_, id) { + cgroupMemLimitIsSet = 1; + return '
'; + } + ], + info: cgroupMemUsageLimit + }, + 'cgroup.mem_usage': { + mainheads: [ + function (_, id) { + if (cgroupMemLimitIsSet === 0) { + return '
'; + } else + return ''; + } + ], + info: cgroupMemUsage + }, + 'cgroup.mem': { + info: cgroupMem + }, + 'cgroup.mem_failcnt': { + info: cgroupMemFailCnt + }, + 'cgroup.writeback': { + info: cgroupWriteback + }, + 'cgroup.mem_activity': { + info: cgroupMemActivity + }, + 'cgroup.pgfaults': { + info: cgroupPgFaults + }, + 'cgroup.memory_some_pressure': { + info: cgroupMemorySomePressure + }, + 'cgroup.memory_some_pressure_stall_time': { + info: cgroupMemorySomePressureStallTime + }, + 'cgroup.memory_full_pressure': { + info: cgroupMemoryFullPressure + }, + 'cgroup.memory_full_pressure_stall_time': { + info: cgroupMemoryFullPressureStallTime + }, + + 'k8s.cgroup.mem_utilization': { + info: cgroupMemUtilization + }, + 'k8s.cgroup.mem_usage_limit': { + mainheads: [ + function (_, id) { + cgroupMemLimitIsSet = 1; + return '
'; + } + ], + info: cgroupMemUsageLimit + }, + 'k8s.cgroup.mem_usage': { + mainheads: [ + function (_, id) { + if (cgroupMemLimitIsSet === 0) { + return '
'; + } else + return ''; + } + ], + info: cgroupMemUsage + }, + 'k8s.cgroup.mem': { + info: cgroupMem + }, + 'k8s.cgroup.mem_failcnt': { + info: cgroupMemFailCnt + }, + 'k8s.cgroup.writeback': { + info: cgroupWriteback + }, + 'k8s.cgroup.mem_activity': { + info: cgroupMemActivity + }, + 'k8s.cgroup.pgfaults': { + info: cgroupPgFaults + }, + 'k8s.cgroup.memory_some_pressure': { + info: cgroupMemorySomePressure + }, + 'k8s.cgroup.memory_some_pressure_stall_time': { + info: cgroupMemorySomePressureStallTime + }, + 'k8s.cgroup.memory_full_pressure': { + info: cgroupMemoryFullPressure + }, + 'k8s.cgroup.memory_full_pressure_stall_time': { + info: cgroupMemoryFullPressureStallTime + }, + + 'cgroup.io': { + info: cgroupIO + }, + 'cgroup.serviced_ops': { + info: cgroupServicedOps + }, + 'cgroup.queued_ops': { + info: cgroupQueuedOps + }, + 'cgroup.merged_ops': { + info: cgroupMergedOps + }, + 'cgroup.throttle_io': { + mainheads: [ + function (_, id) { + return '
'; + }, + function (_, id) { + return '
'; + } + ], + info: cgroupThrottleIO + }, + 'cgroup.throttle_serviced_ops': { + info: cgroupThrottleIOServicesOps + }, + 'cgroup.io_some_pressure': { + info: cgroupIOSomePressure + }, + 'cgroup.io_some_pressure_stall_time': { + info: cgroupIOSomePRessureStallTime + }, + 'cgroup.io_full_pressure': { + info: cgroupIOFullPressure + }, + 'cgroup.io_full_pressure_stall_time': { + info: cgroupIOFullPressureStallTime + }, + + 'k8s.cgroup.io': { + info: cgroupIO + }, + 'k8s.cgroup.serviced_ops': { + info: cgroupServicedOps + }, + 'k8s.cgroup.queued_ops': { + info: cgroupQueuedOps + }, + 'k8s.cgroup.merged_ops': { + info: cgroupMergedOps + }, + 'k8s.cgroup.throttle_io': { + mainheads: [ + function (_, id) { + return '
'; + }, + function (_, id) { + return '
'; + } + ], + info: cgroupThrottleIO + }, + 'k8s.cgroup.throttle_serviced_ops': { + info: cgroupThrottleIOServicesOps + }, + 'k8s.cgroup.io_some_pressure': { + info: cgroupIOSomePressure + }, + 'k8s.cgroup.io_some_pressure_stall_time': { + info: cgroupIOSomePRessureStallTime + }, + 'k8s.cgroup.io_full_pressure': { + info: cgroupIOFullPressure + }, + 'k8s.cgroup.io_full_pressure_stall_time': { + info: cgroupIOFullPressureStallTime + }, + + 'cgroup.swap_read': { + info: ebpfSwapRead + }, + 'cgroup.swap_write': { + info: ebpfSwapWrite + }, + 'cgroup.fd_open': { + info: ebpfFileOpen + }, + 'cgroup.fd_open_error': { + info: ebpfFileOpenError + }, + 'cgroup.fd_close': { + info: ebpfFileClosed + }, + 'cgroup.fd_close_error': { + info: ebpfFileCloseError + }, + 'cgroup.vfs_unlink': { + info: ebpfVFSUnlink + }, + 'cgroup.vfs_write': { + info: ebpfVFSWrite + }, + 'cgroup.vfs_write_error': { + info: ebpfVFSWriteError + }, + 'cgroup.vfs_read': { + info: ebpfVFSRead + }, + 'cgroup.vfs_read_error': { + info: ebpfVFSReadError + }, + 'cgroup.vfs_write_bytes': { + info: ebpfVFSWriteBytes + }, + 'cgroup.vfs_read_bytes': { + info: ebpfVFSReadBytes + }, + 'cgroup.vfs_fsync': { + info: ebpfVFSSync + }, + 'cgroup.vfs_fsync_error': { + info: ebpfVFSSyncError + }, + 'cgroup.vfs_open': { + info: ebpfVFSOpen + }, + 'cgroup.vfs_open_error': { + info: ebpfVFSOpenError + }, + 'cgroup.vfs_create': { + info: ebpfVFSCreate + }, + 'cgroup.vfs_create_error': { + info: ebpfVFSCreateError + }, + 'cgroup.process_create': { + info: ebpfProcessCreate + }, + 'cgroup.thread_create': { + info: ebpfThreadCreate + }, + 'cgroup.task_exit': { + info: ebpfTaskExit + }, + 'cgroup.task_close': { + info: ebpfTaskClose + }, + 'cgroup.task_error': { + info: ebpfTaskError + }, + 'cgroup.dc_ratio': { + info: 'Percentage of file accesses that were present in the directory cache. 100% means that every file that was accessed was present in the directory cache. If files are not present in the directory cache 1) they are not present in the file system, 2) the files were not accessed before. Read more about directory cache. Netdata also gives a summary for these charts in Filesystem submenu.' + }, + 'cgroup.shmget': { + info: ebpfSHMget + }, + 'cgroup.shmat': { + info: ebpfSHMat + }, + 'cgroup.shmdt': { + info: ebpfSHMdt + }, + 'cgroup.shmctl': { + info: ebpfSHMctl + }, + 'cgroup.outbound_conn_v4': { + info: ebpfIPV4conn + }, + 'cgroup.outbound_conn_v6': { + info: ebpfIPV6conn + }, + 'cgroup.net_bytes_send': { + info: ebpfBandwidthSent + }, + 'cgroup.net_bytes_recv': { + info: ebpfBandwidthRecv + }, + 'cgroup.net_tcp_send': { + info: ebpfTCPSendCall + }, + 'cgroup.net_tcp_recv': { + info: ebpfTCPRecvCall + }, + 'cgroup.net_retransmit': { + info: ebpfTCPRetransmit + }, + 'cgroup.net_udp_send': { + info: ebpfUDPsend + }, + 'cgroup.net_udp_recv': { + info: ebpfUDPrecv + }, + 'cgroup.dc_hit_ratio': { + info: ebpfDCHit + }, + 'cgroup.dc_reference': { + info: ebpfDCReference + }, + 'cgroup.dc_not_cache': { + info: ebpfDCNotCache + }, + 'cgroup.dc_not_found': { + info: ebpfDCNotFound + }, + 'cgroup.cachestat_ratio': { + info: ebpfCachestatRatio + }, + 'cgroup.cachestat_dirties': { + info: ebpfCachestatDirties + }, + 'cgroup.cachestat_hits': { + info: ebpfCachestatHits + }, + 'cgroup.cachestat_misses': { + info: ebpfCachestatMisses + }, + + // ------------------------------------------------------------------------ + // containers (systemd) + + 'services.cpu': { + info: 'Total CPU utilization within the system-wide CPU resources (all cores). '+ + 'The amount of time spent by tasks of the cgroup in '+ + 'user and kernel modes.' + }, + + 'services.mem_usage': { + info: 'The amount of used RAM.' + }, + + 'services.mem_rss': { + info: 'The amount of used '+ + 'RSS memory. '+ + 'It includes transparent hugepages.' + }, + + 'services.mem_mapped': { + info: 'The size of '+ + 'memory-mapped files.' + }, + + 'services.mem_cache': { + info: 'The amount of used '+ + 'page cache memory.' + }, + + 'services.mem_writeback': { + info: 'The amount of file/anon cache that is '+ + 'queued for syncing '+ + 'to disk.' + }, + + 'services.mem_pgfault': { + info: 'The number of '+ + 'page faults. '+ + 'It includes both minor and major page faults.' + }, + + 'services.mem_pgmajfault': { + info: 'The number of '+ + 'major '+ + 'page faults.' + }, + + 'services.mem_pgpgin': { + info: 'The amount of memory charged to the cgroup. '+ + 'The charging event happens each time a page is accounted as either '+ + 'mapped anon page(RSS) or cache page(Page Cache) to the cgroup.' + }, + + 'services.mem_pgpgout': { + info: 'The amount of memory uncharged from the cgroup. '+ + 'The uncharging event happens each time a page is unaccounted from the cgroup.' + }, + + 'services.mem_failcnt': { + info: 'The number of memory usage hits limits.' + }, + + 'services.swap_usage': { + info: 'The amount of used '+ + 'swap '+ + 'memory.' + }, + + 'services.io_read': { + info: 'The amount of data transferred from specific devices as seen by the CFQ scheduler. '+ + 'It is not updated when the CFQ scheduler is operating on a request queue.' + }, + + 'services.io_write': { + info: 'The amount of data transferred to specific devices as seen by the CFQ scheduler. '+ + 'It is not updated when the CFQ scheduler is operating on a request queue.' + }, + + 'services.io_ops_read': { + info: 'The number of read operations performed on specific devices as seen by the CFQ scheduler.' + }, + + 'services.io_ops_write': { + info: 'The number write operations performed on specific devices as seen by the CFQ scheduler.' + }, + + 'services.throttle_io_read': { + info: 'The amount of data transferred from specific devices as seen by the throttling policy.' + }, + + 'services.throttle_io_write': { + info: 'The amount of data transferred to specific devices as seen by the throttling policy.' + }, + + 'services.throttle_io_ops_read': { + info: 'The number of read operations performed on specific devices as seen by the throttling policy.' + }, + + 'services.throttle_io_ops_write': { + info: 'The number of write operations performed on specific devices as seen by the throttling policy.' + }, + + 'services.queued_io_ops_read': { + info: 'The number of queued read requests.' + }, + + 'services.queued_io_ops_write': { + info: 'The number of queued write requests.' + }, + + 'services.merged_io_ops_read': { + info: 'The number of read requests merged.' + }, + + 'services.merged_io_ops_write': { + info: 'The number of write requests merged.' + }, + + 'services.swap_read': { + info: ebpfSwapRead + '
' + }, + + 'services.swap_write': { + info: ebpfSwapWrite + '
' + }, + + 'services.fd_open': { + info: ebpfFileOpen + '
' + }, + + 'services.fd_open_error': { + info: ebpfFileOpenError + '
' + }, + + 'services.fd_close': { + info: ebpfFileClosed + '
' + }, + + 'services.fd_close_error': { + info: ebpfFileCloseError + '
' + }, + + 'services.vfs_unlink': { + info: ebpfVFSUnlink + '' + }, + + 'services.vfs_write': { + info: ebpfVFSWrite + '
' + }, + + 'services.vfs_write_error': { + info: ebpfVFSWriteError + '
' + }, + + 'services.vfs_read': { + info: ebpfVFSRead + '
' + }, + + 'services.vfs_read_error': { + info: ebpfVFSReadError + '
' + }, + + 'services.vfs_write_bytes': { + info: ebpfVFSWriteBytes + '
' + }, + + 'services.vfs_read_bytes': { + info: ebpfVFSReadBytes + '
' + }, + + 'services.vfs_fsync': { + info: ebpfVFSSync + '
' + }, + + 'services.vfs_fsync_error': { + info: ebpfVFSSyncError + '
' + }, + + 'services.vfs_open': { + info: ebpfVFSOpen + '
' + }, + + 'services.vfs_open_error': { + info: ebpfVFSOpenError + '
' + }, + + 'services.vfs_create': { + info: ebpfVFSCreate + '
' + }, + + 'services.vfs_create_error': { + info: ebpfVFSCreateError + '
' + }, + + 'services.process_create': { + info: ebpfProcessCreate + '
' + }, + + 'services.thread_create': { + info: ebpfThreadCreate + '
' + }, + + 'services.task_exit': { + info: ebpfTaskExit + '
' + }, + + 'services.task_close': { + info: ebpfTaskClose + '
' + }, + + 'services.task_error': { + info: ebpfTaskError + '
' + }, + + 'services.dc_hit_ratio': { + info: ebpfDCHit + '
' + }, + + 'services.dc_reference': { + info: ebpfDCReference + '
' + }, + + 'services.dc_not_cache': { + info: ebpfDCNotCache + '
' + }, + + 'services.dc_not_found': { + info: ebpfDCNotFound + '
' + }, + + 'services.cachestat_ratio': { + info: ebpfCachestatRatio + '
' + }, + + 'services.cachestat_dirties': { + info: ebpfCachestatDirties + '
' + }, + + 'services.cachestat_hits': { + info: ebpfCachestatHits + '
' + }, + + 'services.cachestat_misses': { + info: ebpfCachestatMisses + '
' + }, + + 'services.shmget': { + info: ebpfSHMget + '
' + }, + + 'services.shmat': { + info: ebpfSHMat + '
' + }, + + 'services.shmdt': { + info: ebpfSHMdt + '
' + }, + + 'services.shmctl': { + info: ebpfSHMctl + '
' + }, + + 'services.outbound_conn_v4': { + info: ebpfIPV4conn + '
' + }, + + 'services.outbound_conn_v6': { + info: ebpfIPV6conn + '
' + }, + + 'services.net_bytes_send': { + info: ebpfBandwidthSent + '
' + }, + + 'services.net_bytes_recv': { + info: ebpfBandwidthRecv + '
' + }, + + 'services.net_tcp_send': { + info: ebpfTCPSendCall + '
' + }, + + 'services.net_tcp_recv': { + info: ebpfTCPRecvCall + '
' + }, + + 'services.net_retransmit': { + info: ebpfTCPRetransmit + '
' + }, + + 'services.net_udp_send': { + info: ebpfUDPsend + '
' + }, + + 'services.net_udp_recv': { + info: ebpfUDPrecv + '
' + }, + + // ------------------------------------------------------------------------ + // beanstalkd + // system charts + 'beanstalk.cpu_usage': { + info: 'Amount of CPU Time for user and system used by beanstalkd.' + }, + + // This is also a per-tube stat + 'beanstalk.jobs_rate': { + info: 'The rate of jobs processed by the beanstalkd served.' + }, + + 'beanstalk.connections_rate': { + info: 'The rate of connections opened to beanstalkd.' + }, + + 'beanstalk.commands_rate': { + info: 'The rate of commands received by beanstalkd.' + }, + + 'beanstalk.current_tubes': { + info: 'Total number of current tubes on the server including the default tube (which always exists).' + }, + + 'beanstalk.current_jobs': { + info: 'Current number of jobs in all tubes grouped by status: urgent, ready, reserved, delayed and buried.' + }, + + 'beanstalk.current_connections': { + info: 'Current number of connections group by connection type: written, producers, workers, waiting.' + }, + + 'beanstalk.binlog': { + info: 'The rate of records written to binlog and migrated as part of compaction.' + }, + + 'beanstalk.uptime': { + info: 'Total time beanstalkd server has been up for.' + }, + + // tube charts + 'beanstalk.jobs': { + info: 'Number of jobs currently in the tube grouped by status: urgent, ready, reserved, delayed and buried.' + }, + + 'beanstalk.connections': { + info: 'The current number of connections to this tube grouped by connection type; using, waiting and watching.' + }, + + 'beanstalk.commands': { + info: 'The rate of delete and pause commands executed by beanstalkd.' + }, + + 'beanstalk.pause': { + info: 'Shows info on how long the tube has been paused for, and how long is left remaining on the pause.' + }, + + // ------------------------------------------------------------------------ + // ceph + + 'ceph.general_usage': { + info: 'The usage and available space in all ceph cluster.' + }, + + 'ceph.general_objects': { + info: 'Total number of objects storage on ceph cluster.' + }, + + 'ceph.general_bytes': { + info: 'Cluster read and write data per second.' + }, + + 'ceph.general_operations': { + info: 'Number of read and write operations per second.' + }, + + 'ceph.general_latency': { + info: 'Total of apply and commit latency in all OSDs. The apply latency is the total time taken to flush an update to disk. The commit latency is the total time taken to commit an operation to the journal.' + }, + + 'ceph.pool_usage': { + info: 'The usage space in each pool.' + }, + + 'ceph.pool_objects': { + info: 'Number of objects presents in each pool.' + }, + + 'ceph.pool_read_bytes': { + info: 'The rate of read data per second in each pool.' + }, + + 'ceph.pool_write_bytes': { + info: 'The rate of write data per second in each pool.' + }, + + 'ceph.pool_read_objects': { + info: 'Number of read objects per second in each pool.' + }, + + 'ceph.pool_write_objects': { + info: 'Number of write objects per second in each pool.' + }, + + 'ceph.osd_usage': { + info: 'The usage space in each OSD.' + }, + + 'ceph.osd_size': { + info: "Each OSD's size" + }, + + 'ceph.apply_latency': { + info: 'Time taken to flush an update in each OSD.' + }, + + 'ceph.commit_latency': { + info: 'Time taken to commit an operation to the journal in each OSD.' + }, + + // ------------------------------------------------------------------------ + // web_log + + 'web_log.response_statuses': { + info: 'Web server responses by type. success includes 1xx, 2xx, 304 and 401, error includes 5xx, redirect includes 3xx except 304, bad includes 4xx except 401, other are all the other responses.', + mainheads: [ + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + } + ] + }, + + 'web_log.response_codes': { + info: 'Web server responses by code family. ' + + 'According to the standards 1xx are informational responses, ' + + '2xx are successful responses, ' + + '3xx are redirects (although they include 304 which is used as "not modified"), ' + + '4xx are bad requests, ' + + '5xx are internal server errors, ' + + 'other are non-standard responses, ' + + 'unmatched counts the lines in the log file that are not matched by the plugin (let us know if you have any unmatched).' + }, + + 'web_log.response_time': { + mainheads: [ + function (os, id) { + void (os); + return '
'; + } + ] + }, + + 'web_log.detailed_response_codes': { + info: 'Number of responses for each response code individually.' + }, + + 'web_log.requests_per_ipproto': { + info: 'Web server requests received per IP protocol version.' + }, + + 'web_log.clients': { + info: 'Unique client IPs accessing the web server, within each data collection iteration. If data collection is per second, this chart shows unique client IPs per second.' + }, + + 'web_log.clients_all': { + info: 'Unique client IPs accessing the web server since the last restart of netdata. This plugin keeps in memory all the unique IPs that have accessed the web server. On very busy web servers (several millions of unique IPs) you may want to disable this chart (check /etc/netdata/go.d/web_log.conf).' + }, + + // ------------------------------------------------------------------------ + // web_log for squid + + 'web_log.squid_response_statuses': { + info: 'Squid responses by type. ' + + 'success includes 1xx, 2xx, 000, 304, ' + + 'error includes 5xx and 6xx, ' + + 'redirect includes 3xx except 304, ' + + 'bad includes 4xx, ' + + 'other are all the other responses.', + mainheads: [ + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + } + ] + }, + + 'web_log.squid_response_codes': { + info: 'Web server responses by code family. ' + + 'According to HTTP standards 1xx are informational responses, ' + + '2xx are successful responses, ' + + '3xx are redirects (although they include 304 which is used as "not modified"), ' + + '4xx are bad requests, ' + + '5xx are internal server errors. ' + + 'Squid also defines 000 mostly for UDP requests, and ' + + '6xx for broken upstream servers sending wrong headers. ' + + 'Finally, other are non-standard responses, and ' + + 'unmatched counts the lines in the log file that are not matched by the plugin (let us know if you have any unmatched).' + }, + + 'web_log.squid_duration': { + mainheads: [ + function (os, id) { + void (os); + return '
'; + } + ] + }, + + 'web_log.squid_detailed_response_codes': { + info: 'Number of responses for each response code individually.' + }, + + 'web_log.squid_clients': { + info: 'Unique client IPs accessing squid, within each data collection iteration. If data collection is per second, this chart shows unique client IPs per second.' + }, + + 'web_log.squid_clients_all': { + info: 'Unique client IPs accessing squid since the last restart of netdata. This plugin keeps in memory all the unique IPs that have accessed the server. On very busy squid servers (several millions of unique IPs) you may want to disable this chart (check /etc/netdata/go.d/web_log.conf).' + }, + + 'web_log.squid_transport_methods': { + info: 'Break down per delivery method: TCP are requests on the HTTP port (usually 3128), ' + + 'UDP are requests on the ICP port (usually 3130), or HTCP port (usually 4128). ' + + 'If ICP logging was disabled using the log_icp_queries option, no ICP replies will be logged. ' + + 'NONE are used to state that squid delivered an unusual response or no response at all. ' + + 'Seen with cachemgr requests and errors, usually when the transaction fails before being classified into one of the above outcomes. ' + + 'Also seen with responses to CONNECT requests.' + }, + + 'web_log.squid_code': { + info: 'These are combined squid result status codes. A break down per component is given in the following charts. ' + + 'Check the squid documentation about them.' + }, + + 'web_log.squid_handling_opts': { + info: 'These tags are optional and describe why the particular handling was performed or where the request came from. ' + + 'CLIENT means that the client request placed limits affecting the response. Usually seen with client issued a no-cache, or analogous cache control command along with the request. Thus, the cache has to validate the object.' + + 'IMS states that the client sent a revalidation (conditional) request. ' + + 'ASYNC, is used when the request was generated internally by Squid. Usually this is background fetches for cache information exchanges, background revalidation from stale-while-revalidate cache controls, or ESI sub-objects being loaded. ' + + 'SWAPFAIL is assigned when the object was believed to be in the cache, but could not be accessed. A new copy was requested from the server. ' + + 'REFRESH when a revalidation (conditional) request was sent to the server. ' + + 'SHARED when this request was combined with an existing transaction by collapsed forwarding. NOTE: the existing request is not marked as SHARED. ' + + 'REPLY when particular handling was requested in the HTTP reply from server or peer. Usually seen on DENIED due to http_reply_access ACLs preventing delivery of servers response object to the client.' + }, + + 'web_log.squid_object_types': { + info: 'These tags are optional and describe what type of object was produced. ' + + 'NEGATIVE is only seen on HIT responses, indicating the response was a cached error response. e.g. 404 not found. ' + + 'STALE means the object was cached and served stale. This is usually caused by stale-while-revalidate or stale-if-error cache controls. ' + + 'OFFLINE when the requested object was retrieved from the cache during offline_mode. The offline mode never validates any object. ' + + 'INVALID when an invalid request was received. An error response was delivered indicating what the problem was. ' + + 'FAIL is only seen on REFRESH to indicate the revalidation request failed. The response object may be the server provided network error or the stale object which was being revalidated depending on stale-if-error cache control. ' + + 'MODIFIED is only seen on REFRESH responses to indicate revalidation produced a new modified object. ' + + 'UNMODIFIED is only seen on REFRESH responses to indicate revalidation produced a 304 (Not Modified) status, which was relayed to the client. ' + + 'REDIRECT when squid generated an HTTP redirect response to this request.' + }, + + 'web_log.squid_cache_events': { + info: 'These tags are optional and describe whether the response was loaded from cache, network, or otherwise. ' + + 'HIT when the response object delivered was the local cache object. ' + + 'MEM when the response object came from memory cache, avoiding disk accesses. Only seen on HIT responses. ' + + 'MISS when the response object delivered was the network response object. ' + + 'DENIED when the request was denied by access controls. ' + + 'NOFETCH an ICP specific type, indicating service is alive, but not to be used for this request (sent during "-Y" startup, or during frequent failures, a cache in hit only mode will return either UDP_HIT or UDP_MISS_NOFETCH. Neighbours will thus only fetch hits). ' + + 'TUNNEL when a binary tunnel was established for this transaction.' + }, + + 'web_log.squid_transport_errors': { + info: 'These tags are optional and describe some error conditions which occurred during response delivery (if any). ' + + 'ABORTED when the response was not completed due to the connection being aborted (usually by the client). ' + + 'TIMEOUT, when the response was not completed due to a connection timeout.' + }, + + // ------------------------------------------------------------------------ + // go web_log + + 'web_log.type_requests': { + info: 'Web server responses by type. success includes 1xx, 2xx, 304 and 401, error includes 5xx, redirect includes 3xx except 304, bad includes 4xx except 401, other are all the other responses.', + mainheads: [ + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + }, + + function (os, id) { + void (os); + return '
'; + } + ] + }, + + 'web_log.request_processing_time': { + mainheads: [ + function (os, id) { + void (os); + return '
'; + } + ] + }, + + // ------------------------------------------------------------------------ + // Port check + + 'portcheck.latency': { + info: 'The latency describes the time spent connecting to a TCP port. No data is sent or received. ' + + 'Currently, the accuracy of the latency is low and should be used as reference only.' + }, + + 'portcheck.status': { + valueRange: "[0, 1]", + info: 'The status chart verifies the availability of the service. ' + + 'Each status dimension will have a value of 1 if triggered. Dimension success is 1 only if connection could be established. ' + + 'This chart is most useful for alarms and third-party apps.' + }, + + // ------------------------------------------------------------------------ + // Chrony + + 'chrony.stratum': { + info: 'The stratum indicates the distance (hops) to the computer with the reference clock. The higher the stratum number, the more the timing accuracy and stability degrades.', + }, + + 'chrony.current_correction': { + info: 'Any error in the system clock is corrected by slightly speeding up or slowing down the system clock until the error has been removed, and then returning to the system clock’s normal speed. A consequence of this is that there will be a period when the system clock (as read by other programs) will be different from chronyd\'s estimate of the current true time (which it reports to NTP clients when it is operating as a server). The reported value is the difference due to this effect.', + }, + + 'chrony.root_delay': { + info: 'The total of the network path delays to the stratum-1 computer from which the computer is ultimately synchronised.' + }, + + 'chrony.root_dispersion': { + info: 'The total dispersion accumulated through all the computers back to the stratum-1 computer from which the computer is ultimately synchronised. Dispersion is due to system clock resolution, statistical measurement variations, etc.' + }, + + 'chrony.last_offset': { + info: 'The estimated local offset on the last clock update. A positive value indicates the local time (as previously estimated true time) was ahead of the time sources.', + }, + + 'chrony.frequency': { + info: 'The frequency is the rate by which the system’s clock would be wrong if chronyd was not correcting it. It is expressed in ppm (parts per million). For example, a value of 1 ppm would mean that when the system’s clock thinks it has advanced 1 second, it has actually advanced by 1.000001 seconds relative to true time.', + }, + + 'chrony.residual_frequency': { + info: 'The residual frequency for the currently selected reference source. This reflects any difference between what the measurements from the reference source indicate the frequency should be and the frequency currently being used. The reason this is not always zero is that a smoothing procedure is applied to the frequency.', + }, + + 'chrony.skew': { + info: 'The estimated error bound on the frequency.', + }, + + 'chrony.ref_measurement_time': { + info: 'The time elapsed since the last measurement from the reference source was processed.', + }, + + 'chrony.leap_status': { + info: '

The current leap status of the source.

Normal - indicates the normal status (no leap second). InsertSecond - indicates that a leap second will be inserted at the end of the month. DeleteSecond - indicates that a leap second will be deleted at the end of the month. Unsynchronised - the server has not synchronized properly with the NTP server.

', + }, + + 'chrony.activity': { + info: '

The number of servers and peers that are online and offline.

Online - the server or peer is currently online (i.e. assumed by chronyd to be reachable). Offline - the server or peer is currently offline (i.e. assumed by chronyd to be unreachable, and no measurements from it will be attempted). BurstOnline - a burst command has been initiated for the server or peer and is being performed. After the burst is complete, the server or peer will be returned to the online state. BurstOffline - a burst command has been initiated for the server or peer and is being performed. After the burst is complete, the server or peer will be returned to the offline state. Unresolved - the name of the server or peer was not resolved to an address yet.

', + }, + + // ------------------------------------------------------------------------ + // Couchdb + + 'couchdb.active_tasks': { + info: 'Active tasks running on this CouchDB cluster. Four types of tasks currently exist: indexer (view building), replication, database compaction and view compaction.' + }, + + 'couchdb.replicator_jobs': { + info: 'Detailed breakdown of any replication jobs in progress on this node. For more information, see the replicator documentation.' + }, + + 'couchdb.open_files': { + info: 'Count of all files held open by CouchDB. If this value seems pegged at 1024 or 4096, your server process is probably hitting the open file handle limit and needs to be increased.' + }, + + 'btrfs.disk': { + info: 'Physical disk usage of BTRFS. The disk space reported here is the raw physical disk space assigned to the BTRFS volume (i.e. before any RAID levels). BTRFS uses a two-stage allocator, first allocating large regions of disk space for one type of block (data, metadata, or system), and then using a regular block allocator inside those regions. unallocated is the physical disk space that is not allocated yet and is available to become data, metadata or system on demand. When unallocated is zero, all available disk space has been allocated to a specific function. Healthy volumes should ideally have at least five percent of their total space unallocated. You can keep your volume healthy by running the btrfs balance command on it regularly (check man btrfs-balance for more info). Note that some of the space listed as unallocated may not actually be usable if the volume uses devices of different sizes.', + colors: [NETDATA.colors[12]] + }, + + 'btrfs.data': { + info: 'Logical disk usage for BTRFS data. Data chunks are used to store the actual file data (file contents). The disk space reported here is the usable allocation (i.e. after any striping or replication). Healthy volumes should ideally have no more than a few GB of free space reported here persistently. Running btrfs balance can help here.' + }, + + 'btrfs.metadata': { + info: 'Logical disk usage for BTRFS metadata. Metadata chunks store most of the filesystem internal structures, as well as information like directory structure and file names. The disk space reported here is the usable allocation (i.e. after any striping or replication). Healthy volumes should ideally have no more than a few GB of free space reported here persistently. Running btrfs balance can help here.' + }, + + 'btrfs.system': { + info: 'Logical disk usage for BTRFS system. System chunks store information about the allocation of other chunks. The disk space reported here is the usable allocation (i.e. after any striping or replication). The values reported here should be relatively small compared to Data and Metadata, and will scale with the volume size and overall space usage.' + }, + + 'btrfs.commits': { + info: 'Tracks filesystem wide commits. Commits mark fully consistent synchronization points for the filesystem, and are triggered automatically when certain events happen or when enough time has elapsed since the last commit.' + }, + + 'btrfs.commits_perc_time': { + info: 'Tracks commits time share. The reported time share metrics are valid only when BTRFS commit interval is longer than Netdata\'s update_every interval.' + }, + + 'btrfs.commit_timings': { + info: 'Tracks timing information for commits. last dimension metrics are valid only when BTRFS commit interval is longer than Netdata\'s update_every interval.' + }, + + 'btrfs.device_errors': { + info: 'Tracks per-device error counts. Five types of errors are tracked: read errors, write errors, flush errors, corruption errors, and generation errors. Read, write, and flush are errors reported by the underlying block device when trying to perform the associated operations on behalf of BTRFS. Corruption errors count checksum mismatches, which usually are a result of either at-rest data corruption or hardware problems. Generation errors count generational mismatches within the internal data structures of the volume, and are also usually indicative of at-rest data corruption or hardware problems. Note that errors reported here may not trigger an associated IO error in userspace, as BTRFS has relatively robust error recovery that allows it to return correct data in most multi-device setups.' + }, + + // ------------------------------------------------------------------------ + // RabbitMQ + + // 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 + + 'rabbitmq.queued_messages': { + info: 'Overall total of ready and unacknowledged queued messages. Messages that are delivered immediately are not counted here.' + }, + + 'rabbitmq.message_rates': { + info: 'Overall messaging rates including acknowledgements, deliveries, redeliveries, and publishes.' + }, + + 'rabbitmq.global_counts': { + info: 'Overall totals for channels, consumers, connections, queues and exchanges.' + }, + + 'rabbitmq.file_descriptors': { + info: 'Total number of used filed descriptors. See Open File Limits for further details.', + colors: NETDATA.colors[3] + }, + + 'rabbitmq.sockets': { + info: 'Total number of used socket descriptors. Each used socket also counts as a used file descriptor. See Open File Limits for further details.', + colors: NETDATA.colors[3] + }, + + 'rabbitmq.processes': { + info: 'Total number of processes running within the Erlang VM. This is not the same as the number of processes running on the host.', + colors: NETDATA.colors[3] + }, + + 'rabbitmq.erlang_run_queue': { + info: 'Number of Erlang processes the Erlang schedulers have queued to run.', + colors: NETDATA.colors[3] + }, + + 'rabbitmq.memory': { + info: 'Total amount of memory used by the RabbitMQ. This is a complex statistic that can be further analyzed in the management UI. See Memory for further details.', + colors: NETDATA.colors[3] + }, + + 'rabbitmq.disk_space': { + info: 'Total amount of disk space consumed by the message store(s). See Disk Space Limits for further details.', + colors: NETDATA.colors[3] + }, + + 'rabbitmq.queue_messages': { + info: 'Total amount of messages and their states in this queue.', + colors: NETDATA.colors[3] + }, + + 'rabbitmq.queue_messages_stats': { + info: 'Overall messaging rates including acknowledgements, deliveries, redeliveries, and publishes.', + colors: NETDATA.colors[3] + }, + + // ------------------------------------------------------------------------ + // ntpd + + 'ntpd.sys_offset': { + info: 'For hosts without any time critical services an offset of < 100 ms should be acceptable even with high network latencies. For hosts with time critical services an offset of about 0.01 ms or less can be achieved by using peers with low delays and configuring optimal poll exponent values.', + colors: NETDATA.colors[4] + }, + + 'ntpd.sys_jitter': { + info: 'The jitter statistics are exponentially-weighted RMS averages. The system jitter is defined in the NTPv4 specification; the clock jitter statistic is computed by the clock discipline module.' + }, + + 'ntpd.sys_frequency': { + info: 'The frequency offset is shown in ppm (parts per million) relative to the frequency of the system. The frequency correction needed for the clock can vary significantly between boots and also due to external influences like temperature or radiation.', + colors: NETDATA.colors[2], + height: 0.6 + }, + + 'ntpd.sys_wander': { + info: 'The wander statistics are exponentially-weighted RMS averages.', + colors: NETDATA.colors[3], + height: 0.6 + }, + + 'ntpd.sys_rootdelay': { + info: 'The rootdelay is the round-trip delay to the primary reference clock, similar to the delay shown by the ping command. A lower delay should result in a lower clock offset.', + colors: NETDATA.colors[1] + }, + + 'ntpd.sys_stratum': { + info: 'The distance in "hops" to the primary reference clock', + colors: NETDATA.colors[5], + height: 0.3 + }, + + 'ntpd.sys_tc': { + info: 'Time constants and poll intervals are expressed as exponents of 2. The default poll exponent of 6 corresponds to a poll interval of 64 s. For typical Internet paths, the optimum poll interval is about 64 s. For fast LANs with modern computers, a poll exponent of 4 (16 s) is appropriate. The poll process sends NTP packets at intervals determined by the clock discipline algorithm.', + height: 0.5 + }, + + 'ntpd.sys_precision': { + colors: NETDATA.colors[6], + height: 0.2 + }, + + 'ntpd.peer_offset': { + info: 'The offset of the peer clock relative to the system clock in milliseconds. Smaller values here weight peers more heavily for selection after the initial synchronization of the local clock. For a system providing time service to other systems, these should be as low as possible.' + }, + + 'ntpd.peer_delay': { + info: 'The round-trip time (RTT) for communication with the peer, similar to the delay shown by the ping command. Not as critical as either the offset or jitter, but still factored into the selection algorithm (because as a general rule, lower delay means more accurate time). In most cases, it should be below 100ms.' + }, + + 'ntpd.peer_dispersion': { + info: 'This is a measure of the estimated error between the peer and the local system. Lower values here are better.' + }, + + 'ntpd.peer_jitter': { + info: 'This is essentially a remote estimate of the peer\'s system_jitter value. Lower values here weight highly in favor of peer selection, and this is a good indicator of overall quality of a given time server (good servers will have values not exceeding single digit milliseconds here, with high quality stratum one servers regularly having sub-millisecond jitter).' + }, + + 'ntpd.peer_xleave': { + info: 'This variable is used in interleaved mode (used only in NTP symmetric and broadcast modes). See NTP Interleaved Modes.' + }, + + 'ntpd.peer_rootdelay': { + info: 'For a stratum 1 server, this is the access latency for the reference clock. For lower stratum servers, it is the sum of the peer_delay and peer_rootdelay for the system they are syncing off of. Similarly to peer_delay, lower values here are technically better, but have limited influence in peer selection.' + }, + + 'ntpd.peer_rootdisp': { + info: 'Is the same as peer_rootdelay, but measures accumulated peer_dispersion instead of accumulated peer_delay.' + }, + + 'ntpd.peer_hmode': { + info: 'The peer_hmode and peer_pmode variables give info about what mode the packets being sent to and received from a given peer are. Mode 1 is symmetric active (both the local system and the remote peer have each other declared as peers in /etc/ntp.conf), Mode 2 is symmetric passive (only one side has the other declared as a peer), Mode 3 is client, Mode 4 is server, and Mode 5 is broadcast (also used for multicast and manycast operation).', + height: 0.2 + }, + + 'ntpd.peer_pmode': { + height: 0.2 + }, + + 'ntpd.peer_hpoll': { + info: 'The peer_hpoll and peer_ppoll variables are log2 representations of the polling interval in seconds.', + height: 0.5 + }, + + 'ntpd.peer_ppoll': { + height: 0.5 + }, + + 'ntpd.peer_precision': { + height: 0.2 + }, + + 'spigotmc.tps': { + info: 'The running 1, 5, and 15 minute average number of server ticks per second. An idealized server will show 20.0 for all values, but in practice this almost never happens. Typical servers should show approximately 19.98-20.0 here. Lower values indicate progressively more server-side lag (and thus that you need better hardware for your server or a lower user limit). For every 0.05 ticks below 20, redstone clocks will lag behind by approximately 0.25%. Values below approximately 19.50 may interfere with complex free-running redstone circuits and will noticeably slow down growth.' + }, + + 'spigotmc.users': { + info: 'The number of currently connected users on the monitored Spigot server.' + }, + + 'boinc.tasks': { + info: 'The total number of tasks and the number of active tasks. Active tasks are those which are either currently being processed, or are partially processed but suspended.' + }, + + 'boinc.states': { + info: 'Counts of tasks in each task state. The normal sequence of states is New, Downloading, Ready to Run, Uploading, Uploaded. Tasks which are marked Ready to Run may be actively running, or may be waiting to be scheduled. Compute Errors are tasks which failed for some reason during execution. Aborted tasks were manually cancelled, and will not be processed. Failed Uploads are otherwise finished tasks which failed to upload to the server, and usually indicate networking issues.' + }, + + 'boinc.sched': { + info: 'Counts of active tasks in each scheduling state. Scheduled tasks are the ones which will run if the system is permitted to process tasks. Preempted tasks are on standby, and will run if a Scheduled task stops running for some reason. Uninitialized tasks should never be present, and indicate tha the scheduler has not tried to schedule them yet.' + }, + + 'boinc.process': { + info: 'Counts of active tasks in each process state. Executing tasks are running right now. Suspended tasks have an associated process, but are not currently running (either because the system isn\'t processing any tasks right now, or because they have been preempted by higher priority tasks). Quit tasks are exiting gracefully. Aborted tasks exceeded some resource limit, and are being shut down. Copy Pending tasks are waiting on a background file transfer to finish. Uninitialized tasks do not have an associated process yet.' + }, + + 'w1sensor.temp': { + info: 'Temperature derived from 1-Wire temperature sensors.' + }, + + 'logind.sessions': { + info: 'Local and remote sessions.' + }, + 'logind.sessions_type': { + info: '

Sessions of each session type.

Graphical - sessions are running under one of X11, Mir, or Wayland. Console - sessions are usually regular text mode local logins, but depending on how the system is configured may have an associated GUI. Other - sessions are those that do not fall into the above categories (such as sessions for cron jobs or systemd timer units).

' + }, + 'logind.sessions_state': { + info: '

Sessions in each session state.

Online - logged in and running in the background. Closing - nominally logged out, but some processes belonging to it are still around. Active - logged in and running in the foreground.

' + }, + 'logind.users_state': { + info: '

Users in each user state.

Offline - users are not logged in. Closing - users are in the process of logging out without lingering. Online - users are logged in, but have no active sessions. Lingering - users are not logged in, but have one or more services still running. Active - users are logged in, and have at least one active session.

' + }, + + // ------------------------------------------------------------------------ + // ProxySQL + + 'proxysql.pool_status': { + info: 'The status of the backend servers. ' + + '1=ONLINE backend server is fully operational, ' + + '2=SHUNNED backend sever is temporarily taken out of use because of either too many connection errors in a time that was too short, or replication lag exceeded the allowed threshold, ' + + '3=OFFLINE_SOFT when a server is put into OFFLINE_SOFT mode, new incoming connections aren\'t accepted anymore, while the existing connections are kept until they became inactive. In other words, connections are kept in use until the current transaction is completed. This allows to gracefully detach a backend, ' + + '4=OFFLINE_HARD when a server is put into OFFLINE_HARD mode, the existing connections are dropped, while new incoming connections aren\'t accepted either. This is equivalent to deleting the server from a hostgroup, or temporarily taking it out of the hostgroup for maintenance work, ' + + '-1 Unknown status.' + }, + + 'proxysql.pool_net': { + info: 'The amount of data sent to/received from the backend ' + + '(This does not include metadata (packets\' headers, OK/ERR packets, fields\' description, etc).' + }, + + 'proxysql.pool_overall_net': { + info: 'The amount of data sent to/received from the all backends ' + + '(This does not include metadata (packets\' headers, OK/ERR packets, fields\' description, etc).' + }, + + 'proxysql.questions': { + info: 'questions total number of queries sent from frontends, ' + + 'slow_queries number of queries that ran for longer than the threshold in milliseconds defined in global variable mysql-long_query_time. ' + }, + + 'proxysql.connections': { + info: 'aborted number of frontend connections aborted due to invalid credential or max_connections reached, ' + + 'connected number of frontend connections currently connected, ' + + 'created number of frontend connections created, ' + + 'non_idle number of frontend connections that are not currently idle. ' + }, + + 'proxysql.pool_latency': { + info: 'The currently ping time in microseconds, as reported from Monitor.' + }, + + 'proxysql.queries': { + info: 'The number of queries routed towards this particular backend server.' + }, + + 'proxysql.pool_used_connections': { + info: 'The number of connections are currently used by ProxySQL for sending queries to the backend server.' + }, + + 'proxysql.pool_free_connections': { + info: 'The number of connections are currently free. They are kept open in order to minimize the time cost of sending a query to the backend server.' + }, + + 'proxysql.pool_ok_connections': { + info: 'The number of connections were established successfully.' + }, + + 'proxysql.pool_error_connections': { + info: 'The number of connections weren\'t established successfully.' + }, + + 'proxysql.commands_count': { + info: 'The total number of commands of that type executed' + }, + + 'proxysql.commands_duration': { + info: 'The total time spent executing commands of that type, in ms' + }, + + // ------------------------------------------------------------------------ + // Power Supplies + + 'powersupply.capacity': { + info: 'The current battery charge.' + }, + + 'powersupply.charge': { + info: '

The battery charge in Amp-hours.

'+ + '

now - actual charge value. '+ + 'full, empty - last remembered value of charge when battery became full/empty. '+ + 'It also could mean "value of charge when battery considered full/empty at given conditions (temperature, age)". '+ + 'I.e. these attributes represents real thresholds, not design values. ' + + 'full_design, empty_design - design charge values, when battery considered full/empty.

' + }, + + 'powersupply.energy': { + info: '

The battery charge in Watt-hours.

'+ + '

now - actual charge value. '+ + 'full, empty - last remembered value of charge when battery became full/empty. '+ + 'It also could mean "value of charge when battery considered full/empty at given conditions (temperature, age)". '+ + 'I.e. these attributes represents real thresholds, not design values. ' + + 'full_design, empty_design - design charge values, when battery considered full/empty.

' + }, + + 'powersupply.voltage': { + info: '

The power supply voltage.

'+ + '

now - current voltage. '+ + 'max, min - voltage values that hardware could only guess (measure and retain) the thresholds '+ + 'of a given power supply. '+ + 'max_design, min_design - design values for maximal and minimal power supply voltages. '+ + 'Maximal/minimal means values of voltages when battery considered "full"/"empty" at normal conditions.

' + }, + + // ------------------------------------------------------------------------ + // VMware vSphere + + // Host specific + 'vsphere.host_mem_usage_percentage': { + info: 'Percentage of used machine memory: consumed / machine-memory-size.' + }, + + 'vsphere.host_mem_usage': { + info: + 'granted is amount of machine memory that is mapped for a host, ' + + 'it equals sum of all granted metrics for all powered-on virtual machines, plus machine memory for vSphere services on the host. ' + + 'consumed is amount of machine memory used on the host, it includes memory used by the Service Console, the VMkernel, vSphere services, plus the total consumed metrics for all running virtual machines. ' + + 'consumed = total host memory - free host memory.' + + 'active is sum of all active metrics for all powered-on virtual machines plus vSphere services (such as COS, vpxa) on the host.' + + 'shared is sum of all shared metrics for all powered-on virtual machines, plus amount for vSphere services on the host. ' + + 'sharedcommon is amount of machine memory that is shared by all powered-on virtual machines and vSphere services on the host. ' + + 'shared - sharedcommon = machine memory (host memory) savings (KB). ' + + 'For details see Measuring and Differentiating Types of Memory Usage and ' + + 'Memory Counters articles.' + }, + + 'vsphere.host_mem_swap_rate': { + info: + 'This statistic refers to VMkernel swapping and not to guest OS swapping. ' + + 'in is sum of swapinRate values for all powered-on virtual machines on the host.' + + 'swapinRate is rate at which VMKernel reads data into machine memory from the swap file. ' + + 'out is sum of swapoutRate values for all powered-on virtual machines on the host.' + + 'swapoutRate is rate at which VMkernel writes to the virtual machine’s swap file from machine memory.' + }, + + // VM specific + 'vsphere.vm_mem_usage_percentage': { + info: 'Percentage of used virtual machine “physical” memory: active / virtual machine configured size.' + }, + + 'vsphere.vm_mem_usage': { + info: + 'granted is amount of guest “physical” memory that is mapped to machine memory, it includes shared memory amount. ' + + 'consumed is amount of guest “physical” memory consumed by the virtual machine for guest memory, ' + + 'consumed = granted - memory saved due to memory sharing. ' + + 'active is amount of memory that is actively used, as estimated by VMkernel based on recently touched memory pages. ' + + 'shared is amount of guest “physical” memory shared with other virtual machines (through the VMkernel’s transparent page-sharing mechanism, a RAM de-duplication technique). ' + + 'For details see Measuring and Differentiating Types of Memory Usage and ' + + 'Memory Counters articles.' + + }, + + 'vsphere.vm_mem_swap_rate': { + info: + 'This statistic refers to VMkernel swapping and not to guest OS swapping. ' + + 'in is rate at which VMKernel reads data into machine memory from the swap file. ' + + 'out is rate at which VMkernel writes to the virtual machine’s swap file from machine memory.' + }, + + 'vsphere.vm_mem_swap': { + info: + 'This statistic refers to VMkernel swapping and not to guest OS swapping. ' + + 'swapped is amount of guest physical memory swapped out to the virtual machine\'s swap file by the VMkernel. ' + + 'Swapped memory stays on disk until the virtual machine needs it.' + }, + + // Common + 'vsphere.cpu_usage_total': { + info: 'Summary CPU usage statistics across all CPUs/cores.' + }, + + 'vsphere.net_bandwidth_total': { + info: 'Summary receive/transmit statistics across all network interfaces.' + }, + + 'vsphere.net_packets_total': { + info: 'Summary receive/transmit statistics across all network interfaces.' + }, + + 'vsphere.net_errors_total': { + info: 'Summary receive/transmit statistics across all network interfaces.' + }, + + 'vsphere.net_drops_total': { + info: 'Summary receive/transmit statistics across all network interfaces.' + }, + + 'vsphere.disk_usage_total': { + info: 'Summary read/write statistics across all disks.' + }, + + 'vsphere.disk_max_latency': { + info: 'latency is highest latency value across all disks.' + }, + + 'vsphere.overall_status': { + info: '0 is unknown, 1 is OK, 2 is might have a problem, 3 is definitely has a problem.' + }, + + // ------------------------------------------------------------------------ + // VCSA + 'vcsa.system_health': { + info: + '-1: unknown; ' + + '0: all components are healthy; ' + + '1: one or more components might become overloaded soon; ' + + '2: one or more components in the appliance might be degraded; ' + + '3: one or more components might be in an unusable status and the appliance might become unresponsive soon; ' + + '4: no health data is available.' + }, + + 'vcsa.components_health': { + info: + '-1: unknown; ' + + '0: healthy; ' + + '1: healthy, but may have some problems; ' + + '2: degraded, and may have serious problems; ' + + '3: unavailable, or will stop functioning soon; ' + + '4: no health data is available.' + }, + + 'vcsa.software_updates_health': { + info: + 'softwarepackages represents information on available software updates available in the remote vSphere Update Manager repository.
' + + '-1: unknown; ' + + '0: no updates available; ' + + '2: non-security updates are available; ' + + '3: security updates are available; ' + + '4: an error retrieving information on software updates.' + }, + + // ------------------------------------------------------------------------ + // Zookeeper + + 'zookeeper.server_state': { + info: + '0: unknown, ' + + '1: leader, ' + + '2: follower, ' + + '3: observer, ' + + '4: standalone.' + }, + + // ------------------------------------------------------------------------ + // Squidlog + + 'squidlog.requests': { + info: 'Total number of requests (log lines read). It includes unmatched.' + }, + + 'squidlog.excluded_requests': { + info: 'unmatched counts the lines in the log file that are not matched by the plugin parser (let us know if you have any unmatched).' + }, + + 'squidlog.type_requests': { + info: 'Requests by response type:
' + + '
    ' + + '
  • success includes 1xx, 2xx, 0, 304, 401.
  • ' + + '
  • error includes 5xx and 6xx.
  • ' + + '
  • redirect includes 3xx except 304.
  • ' + + '
  • bad includes 4xx except 401.
  • ' + + '
' + }, + + 'squidlog.http_status_code_class_responses': { + info: 'The HTTP response status code classes. According to rfc7231:
' + + '
  • 1xx is informational responses.
  • ' + + '
  • 2xx is successful responses.
  • ' + + '
  • 3xx is redirects.
  • ' + + '
  • 4xx is bad requests.
  • ' + + '
  • 5xx is internal server errors.
  • ' + + ' ' + + 'Squid also uses 0 for a result code being unavailable, and 6xx to signal an invalid header, a proxy error.' + }, + + 'squidlog.http_status_code_responses': { + info: 'Number of responses for each http response status code individually.' + }, + + 'squidlog.uniq_clients': { + info: 'Unique clients (requesting instances), within each data collection iteration. If data collection is per second, this chart shows unique clients per second.' + }, + + 'squidlog.bandwidth': { + info: 'The size is the amount of data delivered to the clients. Mind that this does not constitute the net object size, as headers are also counted. ' + + 'Also, failed requests may deliver an error page, the size of which is also logged here.' + }, + + 'squidlog.response_time': { + info: 'The elapsed time considers how many milliseconds the transaction busied the cache. It differs in interpretation between TCP and UDP:' + + '
      ' + + '
    • TCP this is basically the time from having received the request to when Squid finishes sending the last byte of the response.
    • ' + + '
    • UDP this is the time between scheduling a reply and actually sending it.
    • ' + + '
    ' + + 'Please note that the entries are logged after the reply finished being sent, not during the lifetime of the transaction.' + }, + + 'squidlog.cache_result_code_requests': { + info: 'The Squid result code is composed of several tags (separated by underscore characters) which describe the response sent to the client. ' + + 'Check the squid documentation about them.' + }, + + 'squidlog.cache_result_code_transport_tag_requests': { + info: 'These tags are always present and describe delivery method.
    ' + + '
      ' + + '
    • TCP requests on the HTTP port (usually 3128).
    • ' + + '
    • UDP requests on the ICP port (usually 3130) or HTCP port (usually 4128).
    • ' + + '
    • NONE Squid delivered an unusual response or no response at all. Seen with cachemgr requests and errors, usually when the transaction fails before being classified into one of the above outcomes. Also seen with responses to CONNECT requests.
    • ' + + '
    ' + }, + + 'squidlog.cache_result_code_handling_tag_requests': { + info: 'These tags are optional and describe why the particular handling was performed or where the request came from.
    ' + + '
      ' + + '
    • CF at least one request in this transaction was collapsed. See collapsed_forwarding for more details about request collapsing.
    • ' + + '
    • CLIENT usually seen with client issued a "no-cache", or analogous cache control command along with the request. Thus, the cache has to validate the object.
    • ' + + '
    • IMS the client sent a revalidation (conditional) request.
    • ' + + '
    • ASYNC the request was generated internally by Squid. Usually this is background fetches for cache information exchanges, background revalidation from stale-while-revalidate cache controls, or ESI sub-objects being loaded.
    • ' + + '
    • SWAPFAIL the object was believed to be in the cache, but could not be accessed. A new copy was requested from the server.
    • ' + + '
    • REFRESH a revalidation (conditional) request was sent to the server.
    • ' + + '
    • SHARED this request was combined with an existing transaction by collapsed forwarding.
    • ' + + '
    • REPLY the HTTP reply from server or peer. Usually seen on DENIED due to http_reply_access ACLs preventing delivery of servers response object to the client.
    • ' + + '
    ' + }, + + 'squidlog.cache_code_object_tag_requests': { + info: 'These tags are optional and describe what type of object was produced.
    ' + + '
      ' + + '
    • NEGATIVE only seen on HIT responses, indicating the response was a cached error response. e.g. 404 not found.
    • ' + + '
    • STALE the object was cached and served stale. This is usually caused by stale-while-revalidate or stale-if-error cache controls.
    • ' + + '
    • OFFLINE the requested object was retrieved from the cache during offline_mode. The offline mode never validates any object.
    • ' + + '
    • INVALID an invalid request was received. An error response was delivered indicating what the problem was.
    • ' + + '
    • FAILED only seen on REFRESH to indicate the revalidation request failed. The response object may be the server provided network error or the stale object which was being revalidated depending on stale-if-error cache control.
    • ' + + '
    • MODIFIED only seen on REFRESH responses to indicate revalidation produced a new modified object.
    • ' + + '
    • UNMODIFIED only seen on REFRESH responses to indicate revalidation produced a 304 (Not Modified) status. The client gets either a full 200 (OK), a 304 (Not Modified), or (in theory) another response, depending on the client request and other details.
    • ' + + '
    • REDIRECT Squid generated an HTTP redirect response to this request.
    • ' + + '
    ' + }, + + 'squidlog.cache_code_load_source_tag_requests': { + info: 'These tags are optional and describe whether the response was loaded from cache, network, or otherwise.
    ' + + '
      ' + + '
    • HIT the response object delivered was the local cache object.
    • ' + + '
    • MEM the response object came from memory cache, avoiding disk accesses. Only seen on HIT responses.
    • ' + + '
    • MISS the response object delivered was the network response object.
    • ' + + '
    • DENIED the request was denied by access controls.
    • ' + + '
    • NOFETCH an ICP specific type, indicating service is alive, but not to be used for this request.
    • ' + + '
    • TUNNEL a binary tunnel was established for this transaction.
    • ' + + '
    ' + }, + + 'squidlog.cache_code_error_tag_requests': { + info: 'These tags are optional and describe some error conditions which occurred during response delivery.
    ' + + '
      ' + + '
    • ABORTED the response was not completed due to the connection being aborted (usually by the client).
    • ' + + '
    • TIMEOUT the response was not completed due to a connection timeout.
    • ' + + '
    • IGNORED while refreshing a previously cached response A, Squid got a response B that was older than A (as determined by the Date header field). Squid ignored response B (and attempted to use A instead).
    • ' + + '
    ' + }, + + 'squidlog.http_method_requests': { + info: 'The request method to obtain an object. Please refer to section request-methods for available methods and their description.' + }, + + 'squidlog.hier_code_requests': { + info: 'A code that explains how the request was handled, e.g. by forwarding it to a peer, or going straight to the source. ' + + 'Any hierarchy tag may be prefixed with TIMEOUT_, if the timeout occurs waiting for all ICP replies to return from the neighbours. The timeout is either dynamic, if the icp_query_timeout was not set, or the time configured there has run up. ' + + 'Refer to Hierarchy Codes for details on hierarchy codes.' + }, + + 'squidlog.server_address_forwarded_requests': { + info: 'The IP address or hostname where the request (if a miss) was forwarded. For requests sent to origin servers, this is the origin server\'s IP address. ' + + 'For requests sent to a neighbor cache, this is the neighbor\'s hostname. NOTE: older versions of Squid would put the origin server hostname here.' + }, + + 'squidlog.mime_type_requests': { + info: 'The content type of the object as seen in the HTTP reply header. Please note that ICP exchanges usually don\'t have any content type.' + }, + + // ------------------------------------------------------------------------ + // CockroachDB + + 'cockroachdb.process_cpu_time_combined_percentage': { + info: 'Current combined cpu utilization, calculated as (user+system)/num of logical cpus.' + }, + + 'cockroachdb.host_disk_bandwidth': { + info: 'Summary disk bandwidth statistics across all system host disks.' + }, + + 'cockroachdb.host_disk_operations': { + info: 'Summary disk operations statistics across all system host disks.' + }, + + 'cockroachdb.host_disk_iops_in_progress': { + info: 'Summary disk iops in progress statistics across all system host disks.' + }, + + 'cockroachdb.host_network_bandwidth': { + info: 'Summary network bandwidth statistics across all system host network interfaces.' + }, + + 'cockroachdb.host_network_packets': { + info: 'Summary network packets statistics across all system host network interfaces.' + }, + + 'cockroachdb.live_nodes': { + info: 'Will be 0 if this node is not itself live.' + }, + + 'cockroachdb.total_storage_capacity': { + info: 'Entire disk capacity. It includes non-CR data, CR data, and empty space.' + }, + + 'cockroachdb.storage_capacity_usability': { + info: 'usable is sum of empty space and CR data, unusable is space used by non-CR data.' + }, + + 'cockroachdb.storage_usable_capacity': { + info: 'Breakdown of usable space.' + }, + + 'cockroachdb.storage_used_capacity_percentage': { + info: 'total is % of total space used, usable is % of usable space used.' + }, + + 'cockroachdb.sql_bandwidth': { + info: 'The total amount of SQL client network traffic.' + }, + + 'cockroachdb.sql_errors': { + info: 'statement is statements resulting in a planning or runtime error, ' + + 'transaction is SQL transactions abort errors.' + }, + + 'cockroachdb.sql_started_ddl_statements': { + info: 'The amount of started DDL (Data Definition Language) statements. ' + + 'This type means database schema changes. ' + + 'It includes CREATE, ALTER, DROP, RENAME, TRUNCATE and COMMENT statements.' + }, + + 'cockroachdb.sql_executed_ddl_statements': { + info: 'The amount of executed DDL (Data Definition Language) statements. ' + + 'This type means database schema changes. ' + + 'It includes CREATE, ALTER, DROP, RENAME, TRUNCATE and COMMENT statements.' + }, + + 'cockroachdb.sql_started_dml_statements': { + info: 'The amount of started DML (Data Manipulation Language) statements.' + }, + + 'cockroachdb.sql_executed_dml_statements': { + info: 'The amount of executed DML (Data Manipulation Language) statements.' + }, + + 'cockroachdb.sql_started_tcl_statements': { + info: 'The amount of started TCL (Transaction Control Language) statements.' + }, + + 'cockroachdb.sql_executed_tcl_statements': { + info: 'The amount of executed TCL (Transaction Control Language) statements.' + }, + + 'cockroachdb.live_bytes': { + info: 'The amount of live data used by both applications and the CockroachDB system.' + }, + + 'cockroachdb.kv_transactions': { + info: 'KV transactions breakdown:
    ' + + '
      ' + + '
    • committed committed KV transactions (including 1PC).
    • ' + + '
    • fast-path_committed KV transaction on-phase commit attempts.
    • ' + + '
    • aborted aborted KV transactions.
    • ' + + '
    ' + }, + + 'cockroachdb.kv_transaction_restarts': { + info: 'KV transactions restarts breakdown:
    ' + + '
      ' + + '
    • write too old restarts due to a concurrent writer committing first.
    • ' + + '
    • write too old (multiple) restarts due to multiple concurrent writers committing first.
    • ' + + '
    • forwarded timestamp (iso=serializable) restarts due to a forwarded commit timestamp and isolation=SERIALIZABLE".
    • ' + + '
    • possible replay restarts due to possible replays of command batches at the storage layer.
    • ' + + '
    • async consensus failure restarts due to async consensus writes that failed to leave intents.
    • ' + + '
    • read within uncertainty interval restarts due to reading a new value within the uncertainty interval.
    • ' + + '
    • aborted restarts due to an abort by a concurrent transaction (usually due to deadlock).
    • ' + + '
    • push failure restarts due to a transaction push failure.
    • ' + + '
    • unknown restarts due to a unknown reasons.
    • ' + + '
    ' + }, + + 'cockroachdb.ranges': { + info: 'CockroachDB stores all user data (tables, indexes, etc.) and almost all system data in a giant sorted map of key-value pairs. ' + + 'This keyspace is divided into "ranges", contiguous chunks of the keyspace, so that every key can always be found in a single range.' + }, + + 'cockroachdb.ranges_replication_problem': { + info: 'Ranges with not optimal number of replicas:
    ' + + '
      ' + + '
    • unavailable ranges with fewer live replicas than needed for quorum.
    • ' + + '
    • under replicated ranges with fewer live replicas than the replication target.
    • ' + + '
    • over replicated ranges with more live replicas than the replication target.
    • ' + + '
    ' + }, + + 'cockroachdb.replicas': { + info: 'CockroachDB replicates each range (3 times by default) and stores each replica on a different node.' + }, + + 'cockroachdb.replicas_leaders': { + info: 'For each range, one of the replicas is the leader for write requests, not leaseholders is the number of Raft leaders whose range lease is held by another store.' + }, + + 'cockroachdb.replicas_leaseholders': { + info: 'For each range, one of the replicas holds the "range lease". This replica, referred to as the leaseholder, is the one that receives and coordinates all read and write requests for the range.' + }, + + 'cockroachdb.queue_processing_failures': { + info: 'Failed replicas breakdown by queue:
    ' + + '
      ' + + '
    • gc replicas which failed processing in the GC queue.
    • ' + + '
    • replica gc replicas which failed processing in the replica GC queue.
    • ' + + '
    • replication replicas which failed processing in the replicate queue.
    • ' + + '
    • split replicas which failed processing in the split queue.
    • ' + + '
    • consistency replicas which failed processing in the consistency checker queue.
    • ' + + '
    • raft log replicas which failed processing in the Raft log queue.
    • ' + + '
    • raft snapshot replicas which failed processing in the Raft repair queue.
    • ' + + '
    • time series maintenance replicas which failed processing in the time series maintenance queue.
    • ' + + '
    ' + }, + + 'cockroachdb.rebalancing_queries': { + info: 'Number of kv-level requests received per second by the store, averaged over a large time period as used in rebalancing decisions.' + }, + + 'cockroachdb.rebalancing_writes': { + info: 'Number of keys written (i.e. applied by raft) per second to the store, averaged over a large time period as used in rebalancing decisions.' + }, + + 'cockroachdb.slow_requests': { + info: 'Requests that have been stuck for a long time.' + }, + + 'cockroachdb.timeseries_samples': { + info: 'The amount of metric samples written to disk.' + }, + + 'cockroachdb.timeseries_write_errors': { + info: 'The amount of errors encountered while attempting to write metrics to disk.' + }, + + 'cockroachdb.timeseries_write_bytes': { + info: 'Size of metric samples written to disk.' + }, + + // ------------------------------------------------------------------------ + // Perf + + 'perf.instructions_per_cycle': { + info: 'An IPC < 1.0 likely means memory bound, and an IPC > 1.0 likely means instruction bound. For more details about the metric take a look at this blog post.' + }, + + // ------------------------------------------------------------------------ + // Filesystem + + 'filesystem.vfs_deleted_objects': { + title : 'VFS remove', + info: 'Number of calls to VFS unlinker function. This chart may not show all file system events if it uses other functions ' + + 'to store data on disk. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.' + }, + + 'filesystem.vfs_io': { + title : 'VFS IO', + info: 'Number of calls to VFS I/O functions. This chart may not show all file system events if it uses other functions ' + + 'to store data on disk. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.vfs_io_bytes': { + title : 'VFS bytes written', + info: 'Total of bytes read or written with success using the VFS I/O functions. This chart may not show all file system events if it uses other functions ' + + 'to store data on disk. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.vfs_io_error': { + title : 'VFS IO error', + info: 'Number of failed calls to VFS I/O functions. This chart may not show all file system events if it uses other functions ' + + 'to store data on disk. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.vfs_fsync': { + info: 'Number of calls to VFS syncer function. This chart may not show all file system events if it uses other functions ' + + 'to sync data on disk. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.vfs_fsync_error': { + info: 'Number of failed calls to VFS syncer function.. This chart may not show all file system events if it uses other functions ' + + 'to sync data on disk. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.vfs_open': { + info: 'Number of calls to VFS opener function. This chart may not show all file system events if it uses other functions ' + + 'to open files. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.vfs_open_error': { + info: 'Number of failed calls to VFS opener function. This chart may not show all file system events if it uses other functions ' + + 'to open files. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.vfs_create': { + info: 'Number of calls to VFS creator function. This chart may not show all file system events if it uses other functions ' + + 'to create files. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.vfs_create_error': { + info: 'Number of failed calls to VFS creator function. This chart may not show all file system events if it uses other functions ' + + 'to create files. Netdata shows virtual file system metrics per application and cgroup (systemd Services) ' + + 'if apps or ' + + 'cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + + ' to monitor File Systems.
    ' + }, + + 'filesystem.ext4_read_latency': { + info: 'Latency for each read request monitoring ext4 reader function.' + ebpfChartProvides + 'to monitor File systems.' + }, + + 'filesystem.ext4_write_latency': { + info: 'Latency for each write request monitoring ext4 writer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.ext4_open_latency': { + info: 'Latency for each open request monitoring ext4 opener function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.ext4_sync_latency': { + info: 'Latency for each sync request monitoring ext4 syncer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.xfs_read_latency': { + info: 'Latency for each read request monitoring xfs reader function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.xfs_write_latency': { + info: 'Latency for each write request monitoring xfs writer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.xfs_open_latency': { + info: 'Latency for each open request monitoring xfs opener function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.xfs_sync_latency': { + info: 'Latency for each sync request monitoring xfs syncer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.nfs_read_latency': { + info: 'Latency for each read request monitoring nfs reader function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.nfs_write_latency': { + info: 'Latency for each write request monitoring nfs writer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.nfs_open_latency': { + info: 'Latency for each open request monitoring nfs opener function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.nfs_attribute_latency': { + info: 'Latency for each get attribute request monitoring nfs attribute function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.zfs_read_latency': { + info: 'Latency for each read request monitoring zfs reader function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.zfs_write_latency': { + info: 'Latency for each write request monitoring zfs writer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.zfs_open_latency': { + info: 'Latency for each open request monitoring zfs opener function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.zfs_sync_latency': { + info: 'Latency for each sync request monitoring zfs syncer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.btrfs_read_latency': { + info: 'Latency for each read request monitoring btrfs reader function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.btrfs_write_latency': { + info: 'Latency for each write request monitoring btrfs writer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.btrfs_open_latency': { + info: 'Latency for each open request monitoring btrfs opener function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'filesystem.btrfs_sync_latency': { + info: 'Latency for each sync request monitoring btrfs syncer function.' + ebpfChartProvides + ' to monitor File systems.' + }, + + 'mount_points.call': { + info: 'Monitor calls to syscalls that are responsible for attaching (mount(2)) or removing filesystems (umount(2)). This chart has relationship with File systems.' + ebpfChartProvides + }, + + 'mount_points.error': { + info: 'Monitor errors in calls to syscalls that are responsible for attaching (mount(2)) or removing filesystems (umount(2)). This chart has relationship with File systems.' + ebpfChartProvides + }, + + 'filesystem.file_descriptor': { + info: 'Number of calls for internal functions on the Linux kernel responsible to open and closing files. ' + + 'Netdata shows file access per application and cgroup (systemd Services) if apps ' + + 'or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + ' to monitor File systems' + }, + + 'filesystem.file_error': { + info: 'Number of failed calls to the kernel internal function responsible to open and closing files. ' + + 'Netdata shows file error per application and cgroup (systemd Services) if apps ' + + 'or cgroup (systemd Services) plugins are enabled.' + ebpfChartProvides + ' to monitor File systems.' + }, + + // ------------------------------------------------------------------------ + // ACLK Internal Stats + 'netdata.aclk_status': { + valueRange: "[0, 1]", + info: 'This chart shows if ACLK was online during entirety of the sample duration.' + }, + + 'netdata.aclk_query_per_second': { + info: 'This chart shows how many queries were added for ACLK_query thread to process and how many it was actually able to process.' + }, + + 'netdata.aclk_latency_mqtt': { + info: 'Measures latency between MQTT publish of the message and it\'s PUB_ACK being received' + }, + + // ------------------------------------------------------------------------ + // VerneMQ + + 'vernemq.sockets': { + mainheads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'vernemq.queue_processes': { + mainheads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'vernemq.queue_messages': { + mainheads: [ + function (os, id) { + void (os); + return '
    '; + }, + function (os, id) { + void (os); + return '
    '; + }, + ] + }, + 'vernemq.average_scheduler_utilization': { + mainheads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + + // ------------------------------------------------------------------------ + // Apache Pulsar + 'pulsar.messages_rate': { + mainheads: [ + function (os, id) { + void (os); + return '
    '; + }, + function (os, id) { + void (os); + return '
    '; + }, + ] + }, + 'pulsar.subscription_msg_rate_redeliver': { + mainheads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'pulsar.subscription_blocked_on_unacked_messages': { + mainheads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'pulsar.msg_backlog': { + mainheads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + + 'pulsar.namespace_messages_rate': { + heads: [ + function (os, id) { + void (os); + return '
    '; + }, + function (os, id) { + void (os); + return '
    '; + }, + ] + }, + 'pulsar.namespace_subscription_msg_rate_redeliver': { + heads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'pulsar.namespace_subscription_blocked_on_unacked_messages': { + heads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'pulsar.namespace_msg_backlog': { + heads: [ + function (os, id) { + void (os); + return '
    '; + }, + ], + }, + + // ------------------------------------------------------------------------ + // Nvidia-smi + + 'nvidia_smi.fan_speed': { + heads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'nvidia_smi.temperature': { + heads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'nvidia_smi.memory_allocated': { + heads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + 'nvidia_smi.power': { + heads: [ + function (os, id) { + void (os); + return '
    '; + } + ] + }, + + // ------------------------------------------------------------------------ + // Supervisor + + 'supervisord.process_state_code': { + info: 'Process states map: ' + + '0 - stopped, 10 - starting, 20 - running, 30 - backoff,' + + '40 - stopping, 100 - exited, 200 - fatal, 1000 - unknown.' + }, + + // ------------------------------------------------------------------------ + // Systemd units + + 'systemd.service_units_state': { + info: 'Service units start and control daemons and the processes they consist of. ' + + 'For details, see systemd.service(5)' + }, + + 'systemd.socket_unit_state': { + info: 'Socket units encapsulate local IPC or network sockets in the system, useful for socket-based activation. ' + + 'For details about socket units, see systemd.socket(5), ' + + 'for details on socket-based activation and other forms of activation, see daemon(7).' + }, + + 'systemd.target_unit_state': { + info: 'Target units are useful to group units, or provide well-known synchronization points during boot-up, ' + + 'see systemd.target(5).' + }, + + 'systemd.path_unit_state': { + info: 'Path units may be used to activate other services when file system objects change or are modified. ' + + 'See systemd.path(5).' + }, + + 'systemd.device_unit_state': { + info: 'Device units expose kernel devices in systemd and may be used to implement device-based activation. ' + + 'For details, see systemd.device(5).' + }, + + 'systemd.mount_unit_state': { + info: 'Mount units control mount points in the file system. ' + + 'For details, see systemd.mount(5).' + }, + + 'systemd.automount_unit_state': { + info: 'Automount units provide automount capabilities, for on-demand mounting of file systems as well as parallelized boot-up. ' + + 'See systemd.automount(5).' + }, + + 'systemd.swap_unit_state': { + info: 'Swap units are very similar to mount units and encapsulate memory swap partitions or files of the operating system. ' + + 'They are described in systemd.swap(5).' + }, + + 'systemd.timer_unit_state': { + info: 'Timer units are useful for triggering activation of other units based on timers. ' + + 'You may find details in systemd.timer(5).' + }, + + 'systemd.scope_unit_state': { + info: 'Slice units may be used to group units which manage system processes (such as service and scope units) ' + + 'in a hierarchical tree for resource management purposes. ' + + 'See systemd.scope(5).' + }, + + 'systemd.slice_unit_state': { + info: 'Scope units are similar to service units, but manage foreign processes instead of starting them as well. ' + + 'See systemd.slice(5).' + }, + + 'anomaly_detection.dimensions': { + info: 'Total count of dimensions considered anomalous or normal. ' + }, + + 'anomaly_detection.anomaly_rate': { + info: 'Percentage of anomalous dimensions. ' + }, + + 'anomaly_detection.detector_window': { + info: 'The length of the active window used by the detector. ' + }, + + 'anomaly_detection.detector_events': { + info: 'Flags (0 or 1) to show when an anomaly event has been triggered by the detector. ' + }, + + 'anomaly_detection.prediction_stats': { + info: 'Diagnostic metrics relating to prediction time of anomaly detection. ' + }, + + 'anomaly_detection.training_stats': { + info: 'Diagnostic metrics relating to training time of anomaly detection. ' + }, + + // ------------------------------------------------------------------------ + // Supervisor + + 'fail2ban.failed_attempts': { + info: '

    The number of failed attempts.

    '+ + '

    This chart reflects the number of \'Found\' lines. '+ + 'Found means a line in the service’s log file matches the failregex in its filter.

    ' + }, + + 'fail2ban.bans': { + info: '

    The number of bans.

    '+ + '

    This chart reflects the number of \'Ban\' and \'Restore Ban\' lines. '+ + 'Ban action happens when the number of failed attempts (maxretry) occurred in the last configured interval (findtime).

    ' + }, + + 'fail2ban.banned_ips': { + info: '

    The number of banned IP addresses.

    ' + }, + + // ------------------------------------------------------------------------ + // K8s state: Node. + + 'k8s_state.node_allocatable_cpu_requests_utilization': { + info: 'The percentage of allocated CPU resources used by Pod requests. '+ + 'A Pod is scheduled to run on a Node only if the Node has enough CPU resources available to satisfy the Pod CPU request.' + }, + 'k8s_state.node_allocatable_cpu_requests_used': { + info: 'The amount of allocated CPU resources used by Pod requests. ' + + '1000 millicpu is equivalent to '+ + '1 physical or virtual CPU core.' + }, + 'k8s_state.node_allocatable_cpu_limits_utilization': { + info: 'The percentage of allocated CPU resources used by Pod limits. '+ + 'Total limits may be over 100 percent (overcommitted).' + }, + 'k8s_state.node_allocatable_cpu_limits_used': { + info: 'The amount of allocated CPU resources used by Pod limits. ' + + '1000 millicpu is equivalent to '+ + '1 physical or virtual CPU core.' + }, + 'k8s_state.node_allocatable_mem_requests_utilization': { + info: 'The percentage of allocated memory resources used by Pod requests. '+ + 'A Pod is scheduled to run on a Node only if the Node has enough memory resources available to satisfy the Pod memory request.' + }, + 'k8s_state.node_allocatable_mem_requests_used': { + info: 'The amount of allocated memory resources used by Pod requests.' + }, + 'k8s_state.node_allocatable_mem_limits_utilization': { + info: 'The percentage of allocated memory resources used by Pod limits. '+ + 'Total limits may be over 100 percent (overcommitted).' + }, + 'k8s_state.node_allocatable_mem_limits_used': { + info: 'The amount of allocated memory resources used by Pod limits.' + }, + 'k8s_state.node_allocatable_pods_utilization': { + info: 'Pods limit utilization.' + }, + 'k8s_state.node_allocatable_pods_usage': { + info: '

    Pods limit usage.

    '+ + '

    Available - the number of Pods available for scheduling. '+ + 'Allocated - the number of Pods that have been scheduled.

    ' + }, + 'k8s_state.node_condition': { + info: 'Health status. '+ + 'If the status of the Ready condition remains False for longer than the pod-eviction-timeout (the default is 5 minutes), '+ + 'then the node controller triggers API-initiated eviction for all Pods assigned to that node. '+ + 'More info.' + }, + 'k8s_state.node_pods_readiness': { + info: 'The percentage of Pods that are ready to serve requests.' + }, + 'k8s_state.node_pods_readiness_state': { + info: '

    Pods readiness state.

    '+ + '

    Ready - the Pod has passed its readiness probe and ready to serve requests. '+ + 'Unready - the Pod has not passed its readiness probe yet.

    ' + }, + 'k8s_state.node_pods_condition': { + info: '

    Pods state. '+ + 'More info.

    '+ + 'PodReady - the Pod is able to serve requests and should be added to the load balancing pools of all matching Services. '+ + 'PodScheduled - the Pod has been scheduled to a node. '+ + 'PodInitialized - all init containers have completed successfully. '+ + 'ContainersReady - all containers in the Pod are ready.

    ' + }, + 'k8s_state.node_pods_phase': { + info: '

    Pods phase. The phase of a Pod is a high-level summary of where the Pod is in its lifecycle. '+ + 'More info.

    '+ + '

    Running - the Pod has been bound to a node, and all of the containers have been created. '+ + 'At least one container is still running, or is in the process of starting or restarting. ' + + 'Failed - all containers in the Pod have terminated, and at least one container has terminated in failure. '+ + 'That is, the container either exited with non-zero status or was terminated by the system. ' + + 'Succedeed - all containers in the Pod have terminated in success, and will not be restarted. ' + + 'Pending - the Pod has been accepted by the Kubernetes cluster, but one or more of the containers has not been set up and made ready to run.

    ' + }, + 'k8s_state.node_containers': { + info: 'The total number of containers and init containers.' + }, + 'k8s_state.node_containers_state': { + info: '

    The number of containers in different lifecycle states. '+ + 'More info.

    '+ + '

    Running - a container is executing without issues. '+ + 'Waiting - a container is still running the operations it requires in order to complete start up. '+ + 'Terminated - a container began execution and then either ran to completion or failed for some reason.

    ' + }, + 'k8s_state.node_init_containers_state': { + info: '

    The number of init containers in different lifecycle states. '+ + 'More info.

    '+ + '

    Running - a container is executing without issues. '+ + 'Waiting - a container is still running the operations it requires in order to complete start up. '+ + 'Terminated - a container began execution and then either ran to completion or failed for some reason.

    ' + }, + 'k8s_state.node_age': { + info: 'The lifetime of the Node.' + }, + + // K8s state: Pod. + + 'k8s_state.pod_cpu_requests_used': { + info: 'The overall CPU resource requests for a Pod. '+ + 'This is the sum of the CPU requests for all the Containers in the Pod. '+ + 'Provided the system has CPU time free, a container is guaranteed to be allocated as much CPU as it requests. '+ + '1000 millicpu is equivalent to '+ + '1 physical or virtual CPU core.' + }, + 'k8s_state.pod_cpu_limits_used': { + info: 'The overall CPU resource limits for a Pod. '+ + 'This is the sum of the CPU limits for all the Containers in the Pod. '+ + 'If set, containers cannot use more CPU than the configured limit. '+ + '1000 millicpu is equivalent to '+ + '1 physical or virtual CPU core.' + }, + 'k8s_state.pod_mem_requests_used': { + info: 'The overall memory resource requests for a Pod. '+ + 'This is the sum of the memory requests for all the Containers in the Pod.' + }, + 'k8s_state.pod_mem_limits_used': { + info: 'The overall memory resource limits for a Pod. '+ + 'This is the sum of the memory limits for all the Containers in the Pod. '+ + 'If set, containers cannot use more RAM than the configured limit.' + }, + 'k8s_state.pod_condition': { + info: 'The current state of the Pod. ' + + 'More info.

    '+ + '

    PodReady - the Pod is able to serve requests and should be added to the load balancing pools of all matching Services. ' + + 'PodScheduled - the Pod has been scheduled to a node. ' + + 'PodInitialized - all init containers have completed successfully. ' + + 'ContainersReady - all containers in the Pod are ready. ' + }, + 'k8s_state.pod_phase': { + info: 'High-level summary of where the Pod is in its lifecycle. ' + + 'More info.

    '+ + '

    Running - the Pod has been bound to a node, and all of the containers have been created. '+ + 'At least one container is still running, or is in the process of starting or restarting. ' + + 'Failed - all containers in the Pod have terminated, and at least one container has terminated in failure. '+ + 'That is, the container either exited with non-zero status or was terminated by the system. ' + + 'Succedeed - all containers in the Pod have terminated in success, and will not be restarted. ' + + 'Pending - the Pod has been accepted by the Kubernetes cluster, but one or more of the containers has not been set up and made ready to run. '+ + 'This includes time a Pod spends waiting to be scheduled as well as the time spent downloading container images over the network. ' + }, + 'k8s_state.pod_age': { + info: 'The lifetime of the Pod. ' + }, + 'k8s_state.pod_containers': { + info: 'The number of containers and init containers belonging to the Pod.' + }, + 'k8s_state.pod_containers_state': { + info: 'The state of each container inside this Pod. '+ + 'More info. '+ + '

    Running - a container is executing without issues. '+ + 'Waiting - a container is still running the operations it requires in order to complete start up. '+ + 'Terminated - a container began execution and then either ran to completion or failed for some reason.

    ' + }, + 'k8s_state.pod_init_containers_state': { + info: 'The state of each init container inside this Pod. '+ + 'More info. '+ + '

    Running - a container is executing without issues. '+ + 'Waiting - a container is still running the operations it requires in order to complete start up. '+ + 'Terminated - a container began execution and then either ran to completion or failed for some reason.

    ' + }, + + // K8s state: Pod container. + + 'k8s_state.pod_container_readiness_state': { + info: 'Specifies whether the container has passed its readiness probe. '+ + 'Kubelet uses readiness probes to know when a container is ready to start accepting traffic.' + }, + 'k8s_state.pod_container_restarts': { + info: 'The number of times the container has been restarted.' + }, + 'k8s_state.pod_container_state': { + info: 'Current state of the container. '+ + 'More info. '+ + '

    Running - a container is executing without issues. '+ + 'Waiting - a container is still running the operations it requires in order to complete start up. '+ + 'Terminated - a container began execution and then either ran to completion or failed for some reason.

    ' + }, + 'k8s_state.pod_container_waiting_state_reason': { + info: 'Reason the container is not yet running. '+ + 'More info. ' + }, + 'k8s_state.pod_container_terminated_state_reason': { + info: 'Reason from the last termination of the container. '+ + 'More info.' + }, + + // Ping + + 'ping.host_rtt': { + info: 'Round-trip time (RTT) is the time it takes for a data packet to reach its destination and return back to its original source.' + }, + 'ping.host_std_dev_rtt': { + info: 'Round-trip time (RTT) standard deviation. The average value of how far each RTT of a ping differs from the average RTT.' + }, + 'ping.host_packet_loss': { + info: 'Packet loss occurs when one or more transmitted data packets do not reach their destination. Usually caused by data transfer errors, network congestion or firewall blocking. ICMP echo packets are often treated as lower priority by routers and target hosts, so ping test packet loss may not always translate to application packet loss.' + }, + 'ping.host_packets': { + info: 'Number of ICMP messages sent and received. These counters should be equal if there is no packet loss.' + }, + + // NVMe + + 'nvme.device_estimated_endurance_perc': { + info: 'NVM subsystem lifetime used based on the actual usage and the manufacturer\'s prediction of NVM life. A value of 100 indicates that the estimated endurance of the device has been consumed, but may not indicate a device failure. The value can be greater than 100 if you use the storage beyond its planned lifetime.' + }, + 'nvme.device_available_spare_perc': { + info: 'Remaining spare capacity that is available. SSDs provide a set of internal spare capacity, called spare blocks, that can be used to replace blocks that have reached their write operation limit. After all of the spare blocks have been used, the next block that reaches its limit causes the disk to fail.' + }, + 'nvme.device_composite_temperature': { + info: 'The current composite temperature of the controller and namespace(s) associated with that controller. The manner in which this value is computed is implementation specific and may not represent the actual temperature of any physical point in the NVM subsystem.' + }, + 'nvme.device_io_transferred_count': { + info: 'The total amount of data read and written by the host.' + }, + 'nvme.device_power_cycles_count': { + info: 'Power cycles reflect the number of times this host has been rebooted or the device has been woken up after sleep. A high number of power cycles does not affect the device\'s life expectancy.' + }, + 'nvme.device_power_on_time': { + info: 'Power-on time is the length of time the device is supplied with power.' + }, + 'nvme.device_unsafe_shutdowns_count': { + info: 'The number of times a power outage occurred without a shutdown notification being sent. Depending on the NVMe device you are using, an unsafe shutdown can corrupt user data.' + }, + 'nvme.device_critical_warnings_state': { + info: '

    Critical warnings for the status of the controller. Status active if set to 1.

    AvailableSpare - the available spare capacity is below the threshold. TempThreshold - the composite temperature is greater than or equal to an over temperature threshold or less than or equal to an under temperature threshold. NvmSubsystemReliability - the NVM subsystem reliability is degraded due to excessive media or internal errors. ReadOnly - media is placed in read-only mode. VolatileMemBackupFailed - the volatile memory backup device has failed. PersistentMemoryReadOnly - the Persistent Memory Region has become read-only or unreliable.

    ' + }, + 'nvme.device_media_errors_rate': { + info: 'The number of occurrences where the controller detected an unrecovered data integrity error. Errors such as uncorrectable ECC, CRC checksum failure, or LBA tag mismatch are included in this counter.' + }, + 'nvme.device_error_log_entries_rate': { + info: 'The number of entries in the Error Information Log. By itself, an increase in the number of records is not an indicator of any failure condition.' + }, + 'nvme.device_warning_composite_temperature_time': { + info: 'The time the device has been operating above the Warning Composite Temperature Threshold (WCTEMP) and below Critical Composite Temperature Threshold (CCTEMP).' + }, + 'nvme.device_critical_composite_temperature_time': { + info: 'The time the device has been operating above the Critical Composite Temperature Threshold (CCTEMP).' + }, + 'nvme.device_thermal_mgmt_temp1_transitions_rate': { + info: 'The number of times the controller has entered lower active power states or performed vendor-specific thermal management actions, minimizing performance impact, to attempt to lower the Composite Temperature due to the host-managed thermal management feature.' + }, + 'nvme.device_thermal_mgmt_temp2_transitions_rate': { + info: 'The number of times the controller has entered lower active power states or performed vendor-specific thermal management actions, regardless of the impact on performance (e.g., heavy throttling), to attempt to lower the Combined Temperature due to the host-managed thermal management feature.' + }, + 'nvme.device_thermal_mgmt_temp1_time': { + info: 'The amount of time the controller has entered lower active power states or performed vendor-specific thermal management actions, minimizing performance impact, to attempt to lower the Composite Temperature due to the host-managed thermal management feature.' + }, + 'nvme.device_thermal_mgmt_temp2_time': { + info: 'The amount of time the controller has entered lower active power states or performed vendor-specific thermal management actions, regardless of the impact on performance (e.g., heavy throttling), to attempt to lower the Combined Temperature due to the host-managed thermal management feature.' + }, + + // ------------------------------------------------------------------------ + // Logs Management + + 'docker_events_logs.events_type': { + info: 'The Docker object type of the event. See here for more information.' + }, + + // ------------------------------------------------------------------------ + +}; diff --git a/web/gui/dashboard_info_custom_example.js b/web/gui/dashboard_info_custom_example.js new file mode 100644 index 00000000..6a2d5376 --- /dev/null +++ b/web/gui/dashboard_info_custom_example.js @@ -0,0 +1,62 @@ +// SPDX-License-Identifier: GPL-3.0-or-later +/* + * Custom netdata information file + * ------------------------------- + * + * Use this file to add custom information on netdata dashboards: + * + * 1. Copy it to a new filename (so that it will not be overwritten with netdata updates) + * 2. Edit it to fit your needs + * 3. Set the following option to /etc/netdata/netdata.conf : + * + * [web] + * custom dashboard_info.js = your_filename.js + * + * Using this file you can: + * + * 1. Overwrite or add messages to menus, submenus and charts. + * Use dashboard_info.js to find out what you can define. + * + * 2. Inject javascript code into the default netdata dashboard. + * + */ + +// Codacy declarations +/* global customDashboard */ + +// ---------------------------------------------------------------------------- +// MENU +// +// - title the menu title as to be rendered at the charts menu +// - icon html fragment of the icon to display +// - info html fragment for the description above all the menu charts + +customDashboard.menu = { + +}; + + +// ---------------------------------------------------------------------------- +// SUBMENU +// +// - title the submenu title as to be rendered at the charts menu +// - info html fragment for the description above all the submenu charts + +customDashboard.submenu = { + +}; + + +// ---------------------------------------------------------------------------- +// CONTEXT (the template each chart is based on) +// +// - info html fragment for the description above the chart +// - height a ratio to the default as a decimal number: 1.0 = 100% +// - colors a single color or an array of colors to use for the dimensions +// - valuerange the y-range of the chart as an array [min, max] +// - heads an array of gauge charts to render above the submenu section +// - mainheads an array of gauge charts to render at the menu section + +customDashboard.context = { + +}; diff --git a/web/gui/ilove.html b/web/gui/ilove.html new file mode 100644 index 00000000..f82b1cfd --- /dev/null +++ b/web/gui/ilove.html @@ -0,0 +1,302 @@ + + + + + + + I Love SVG + + + + +
    + +
    + +
    + +
    + +
    + + + + + +
    + +
    + Big SVG Image +
    + + + + diff --git a/web/gui/index.html b/web/gui/index.html new file mode 100644 index 00000000..5ffbdb75 --- /dev/null +++ b/web/gui/index.html @@ -0,0 +1,224 @@ +Netdata Agent Console

    Welcome to Netdata

    Loading latest Netdata UI...

    We couldn't load the latest Netdata UI. You can try again
    Or you can load the old single node dashboard or a local copy of Netdata UI
    \ No newline at end of file diff --git a/web/gui/main.css b/web/gui/main.css new file mode 100644 index 00000000..870a1fdd --- /dev/null +++ b/web/gui/main.css @@ -0,0 +1,764 @@ +/* force the vertical window scrollbar */ +html { + overflow-y: hidden; +} + +/* 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; +} + +.navbar-highlight { + display: none; + position: fixed; + margin-top: 5px; + height: 26px; + width: 100%; + text-align: center; + overflow: hidden; + z-index: 30; + pointer-events: none !important; +} + +.navbar-highlight-content { + position: relative; + display: inline-block; + margin: 0 auto; + height: 26px; + min-width: 500px; + background-color: rgba(0, 0, 0, 0.7); + padding-top: 2px; + padding-bottom: 2px; + padding-left: 15px; + padding-right: 15px; + border-radius: 10px; + color: lightgrey; + pointer-events: auto !important; +} + +.navbar-highlight-bar { + cursor: pointer; +} + +.navbar-highlight-button-right { + cursor: pointer; + padding-left: 10px; +} + +.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; +} + +.dashboard-submenu-info { + display: block; + margin-top: 10px; +} + +.dashboard-context-info { + display: block; + margin-top: 10px; +} + +#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; +} + +/* make accordion use the whole header bar for expand/collapse */ +.panel-title a { + display: block; + padding: 10px 15px; + margin: -10px -15px; +} + +/* + * Side navigation + * + * Scrollspy and affixed enhanced navigation to highlight sections and secondary + * sections of docs content. + */ + +.affix { + position: static; + top: 70px !important; + /*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; +} + +/* 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 > .svg-inline--fa { + width: 20px; + text-align: center; +} + +.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: inline-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; +} + +.scrollable-menu-50 { + height: auto; + max-height: 50vh; + 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; +} + +.container { + width: calc(100% - 20px) !important; +} + +.charts-body { + display: inline-block; + width: 100%; +} + +.sidebar-body { + position: absolute; + display: none; + height: 100vh; +} + +.dashboard-section-container { + display: block; + width: 100%; + page-break-before: auto; + page-break-after: auto; + page-break-inside: auto; +} + +.dashboard-print-row { + display: block; + width: 100%; + page-break-before: auto; + page-break-after: auto; + page-break-inside: avoid; +} + +.netdata-chartblock-container { + display: inline-block; +} + +/* https://github.com/seiyria/bootstrap-slider/issues/746 */ +.tooltip { + -webkit-user-select: none; + -moz-user-select: none; + -ms-user-select: none; + user-select: none; +} + +.action-button { + position: relative; + display: inline-block; + color: gray; + cursor: pointer; + margin: 0 auto; + width: 30px; + height: 30px; + font-size: 25px; +} + +.ripple { + position: relative; + /*overflow: hidden;*/ + transform: translate3d(0, 0, 0) +} + +.ripple:after { + content: ""; + display: block; + position: absolute; + width: 100%; + height: 100%; + top: 0; + left: 0; + pointer-events: none; + background-image: radial-gradient(circle, #000 10%, transparent 10.01%); + background-repeat: no-repeat; + background-position: 50%; + transform: scale(18, 18); /* the size of the ripple */ + opacity: 0; + transition: transform .5s, opacity 1s +} + +.ripple:active:after { + transform: scale(0, 0); + opacity: .2; + transition: 0s +} + +/* -------------------------------------------------------------------------- */ + +#alarms_log_table tbody tr { + cursor: pointer; +} + +#my-netdata-dropdown-content { + width: 500px; +} + +#my-netdata-dropdown-content a:hover { + color: #fff; +} + +#my-netdata-dropdown-content .info-item { + height: 32px; + line-height: 32px; + padding-left: 14px; +} + +#my-netdata-dropdown-content .agent-item { + display: flex; + align-items: center; + min-height: 32px; + font-weight: 300; +} + +#my-netdata-dropdown-content .agent-item .__title { + cursor: pointer; +} + +#my-netdata-dropdown-content .agent-item:hover { + background-color: #262626; +} + +#my-netdata-dropdown-content .agent-item a:hover { + text-decoration: none; +} + +#my-netdata-dropdown-content .agent-item > :first-child { + width: 40px; + text-align: center; +} + +#my-netdata-dropdown-content .agent-item > :last-child { + width: 40px; + text-align: center; +} + +#my-netdata-dropdown-content .agent-item :nth-child(2) { + min-width: 420px; + line-height: 32px; +} + +.agent-item--separated { + border-top: 1px solid #333; +} + +.agent-item--alternate a { + color: #999; +} + +#my-netdata-dropdown-content .agent-alternate-urls.collapsed { + display: none; +} + +#my-netdata-dropdown-content hr { + display: block; + margin-top: 5px; + margin-bottom: 0; + border-top: 1px solid #333; + height: 4px; +} + +/* white theme overrides */ + +#my-netdata-dropdown-content.theme-white hr { + border-top: 1px solid #ddd; +} + +#my-netdata-dropdown-content.theme-white .agent-item:hover { + background-color: #e6e6e6; +} + +#my-netdata-dropdown-content.theme-white a { + color: #888; +} + +#my-netdata-dropdown-content.theme-white a:hover { + color: #000; +} + +#sign-in-iframe { + background-color: #fff; + border: none; +} + +#cloud-menu { +} + +#cloud-menu.dropdown-menu > li > a { + text-align: left; +} + +#my-netdata-menu-filter-input { + color: #fff; + border: none; + background-color: #4b4f55; + width: 472px; + margin: 5px 14px; + margin-right: 0; + padding: 2px 5px; + outline: none; +} + +#my-netdata-menu-filter-input::placeholder { + opacity: 0.7; +} + +#my-netdata-dropdown-content.theme-white #my-netdata-menu-filter-input { + background-color: #e7e7e7; + color: #555; +} + +.filter-control { + position: relative; +} + +.filter-control .filter-control__clear { + cursor: pointer; + position: absolute; + top: 7px; + right: 19px; +} + +#myNetdataDropdownParent { + float: left; +} + +#hostname { + font-size: 18px; + overflow: hidden; + text-overflow: ellipsis; + max-width: 220px; + } + + #hostnametext { + white-space: pre; + float: left; + text-overflow: ellipsis; + overflow: hidden; + max-width: 160px; +} + +.sign-in-btn { + background-color: #1E2126; +} + +.sign-in-btn.theme-white { + background-color: #e6e6e6; +} + +.sign-in-btn.theme-white span { + color: #000; +} + +#sign-in-banner { + position: fixed; + bottom: 0; + left: 0; + right: 0; + z-index: 9999; + /* margin: 5px 0; */ + background-color: #1E2126; + height: 44px; + line-height: 44px; + text-align: center; +} + +#sign-in-banner.theme-white { + background-color: #e6e6e6; +} + +#sign-in-banner .__link { + color: #17CE8A; +} + +#sign-in-banner .__link:hover { + text-decoration: underline; +} + +#sign-in-banner .__close { + cursor: pointer; + float: right; +} + +#sign-in-banner .__close .fa-times { + margin-left: 5px; + color: #17CE8A; +} + +.beta { + color:#FFCC00; +} + + +@media (min-width: 1400px) { + #hostname { + max-width: 600px !important; + } + + #hostnametext { + max-width: 540px !important; + } +} + +@media (min-width: 1360px) { + .container { + padding-left: 3% !important; + } + + #hostname { + max-width: 280px !important; + } + + #hostnametext { + max-width: 220px !important; + } + + .charts-body { + width: calc(100% - 263px) !important; + padding-left: 1% !important; + padding-right: 2% !important; + } + + .sidebar-body { + display: inline-block !important; + width: 263px !important; + } + + /* Widen the fixed sidebar again */ + .dashboard-sidebar.affix, + .dashboard-sidebar.affix-top, + .dashboard-sidebar.affix-bottom { + width: 263px !important; + } +} + +@media (min-width: 1200px) { + #hostname { + max-width: 100px; + } + + #hostnametext { + max-width: 40px; + } + .container { + padding-left: 2% !important; + } + + + .charts-body { + width: calc(100% - 233px) !important; + padding-left: 1% !important; + padding-right: 1% !important; + } + + .sidebar-body { + display: inline-block !important; + width: 233px !important; + } + + /* Widen the fixed sidebar again */ + .dashboard-sidebar.affix, + .dashboard-sidebar.affix-top, + .dashboard-sidebar.affix-bottom { + width: 233px !important; + } +} + +@media (min-width: 992px) { + .container { + padding-left: 0% !important; + } + + .charts-body { + width: calc(100% - 213px) !important; + padding-left: 1% !important; + padding-right: 0% !important; + } + + .sidebar-body { + display: inline-block !important; + width: 213px !important; + } + + .dashboard-sidebar .nav > .active > ul { + display: block; + } + + /* Widen the fixed sidebar */ + .dashboard-sidebar.affix, + .dashboard-sidebar.affix-top, + .dashboard-sidebar.affix-bottom { + width: 213px !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: 860px) { + .dashboard-sidebar { + padding-left: 20px; + } + +} + +@media (min-width: 768px) { + .dashboard-sidebar { + padding-left: 20px; + } + + .charts-body { + padding-left: 0%; + padding-right: 0%; + } + + .back-to-top, + .dashboard-theme-toggle { + display: block; + } +} + +@media print { + body { + overflow: visible !important; + -webkit-print-color-adjust: exact; + page-break-inside: auto; + page-break-before: auto; + page-break-after: auto; + } + + .dashboard-section { + page-break-inside: auto; + page-break-before: auto; + page-break-after: auto; + } + + .dashboard-subsection { + page-break-before: avoid; + page-break-after: auto; + page-break-inside: auto; + } + + .charts-body { + padding-left: 0%; + padding-right: 0%; + display: block; + page-break-inside: auto; + page-break-before: auto; + page-break-after: auto; + } + + .back-to-top, + .dashboard-theme-toggle { + display: block; + } +} diff --git a/web/gui/main.js b/web/gui/main.js new file mode 100644 index 00000000..20f455fd --- /dev/null +++ b/web/gui/main.js @@ -0,0 +1,5161 @@ +// Main JavaScript file for the Netdata GUI. + +// Codacy declarations +/* global NETDATA */ + +// netdata snapshot data +var netdataSnapshotData = null; + +// enable alarms checking and notifications +var netdataShowAlarms = true; + +// enable registry updates +var netdataRegistry = true; + +// forward definition only - not used here +var netdataServer = undefined; +var netdataServerStatic = undefined; +var netdataCheckXSS = undefined; + +// control the welcome modal and analytics +var this_is_demo = null; + +function escapeUserInputHTML(s) { + return s.toString() + .replace(/&/g, '&') + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/#/g, '#') + .replace(/'/g, ''') + .replace(/\(/g, '(') + .replace(/\)/g, ')') + .replace(/\//g, '/'); +} + +function verifyURL(s) { + if (typeof (s) === 'string' && (s.startsWith('http://') || s.startsWith('https://'))) { + return s + .replace(/'/g, '%22') + .replace(/"/g, '%27') + .replace(/\)/g, '%28') + .replace(/\(/g, '%29'); + } + + console.log('invalid URL detected:'); + console.log(s); + return 'javascript:alert("invalid url");'; +} + +// -------------------------------------------------------------------- +// urlOptions + +var urlOptions = { + hash: '#', + theme: null, + help: null, + mode: 'live', // 'live', 'print' + update_always: false, + pan_and_zoom: false, + server: null, + after: 0, + before: 0, + highlight: false, + highlight_after: 0, + highlight_before: 0, + nowelcome: false, + show_alarms: false, + chart: null, + family: null, + alarm: null, + alarm_unique_id: 0, + alarm_id: 0, + alarm_event_id: 0, + alarm_when: 0, + + hasProperty: function (property) { + // console.log('checking property ' + property + ' of type ' + typeof(this[property])); + return typeof this[property] !== 'undefined'; + }, + + genHash: function (forReload) { + var hash = urlOptions.hash; + + if (urlOptions.pan_and_zoom === true) { + hash += ';after=' + urlOptions.after.toString() + + ';before=' + urlOptions.before.toString(); + } + + if (urlOptions.highlight === true) { + hash += ';highlight_after=' + urlOptions.highlight_after.toString() + + ';highlight_before=' + urlOptions.highlight_before.toString(); + } + + if (urlOptions.theme !== null) { + hash += ';theme=' + urlOptions.theme.toString(); + } + + if (urlOptions.help !== null) { + hash += ';help=' + urlOptions.help.toString(); + } + + if (urlOptions.update_always === true) { + hash += ';update_always=true'; + } + + if (forReload === true && urlOptions.server !== null) { + hash += ';server=' + urlOptions.server.toString(); + } + + if (urlOptions.mode !== 'live') { + hash += ';mode=' + urlOptions.mode; + } + + return hash; + }, + + parseHash: function () { + 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]] = decodeURIComponent(p[1]); + } + } else { + if (variables[len].length > 0) { + urlOptions.hash = variables[len]; + } + } + } + + var booleans = ['nowelcome', 'show_alarms', 'update_always']; + len = booleans.length; + while (len--) { + if (urlOptions[booleans[len]] === 'true' || urlOptions[booleans[len]] === true || urlOptions[booleans[len]] === '1' || urlOptions[booleans[len]] === 1) { + urlOptions[booleans[len]] = true; + } else { + urlOptions[booleans[len]] = false; + } + } + + var numeric = ['after', 'before', 'highlight_after', 'highlight_before', 'alarm_when']; + len = numeric.length; + while (len--) { + if (typeof urlOptions[numeric[len]] === 'string') { + try { + urlOptions[numeric[len]] = parseInt(urlOptions[numeric[len]]); + } + catch (e) { + console.log('failed to parse URL hash parameter ' + numeric[len]); + urlOptions[numeric[len]] = 0; + } + } + } + + if (urlOptions.alarm_when) { + // if alarm_when exists, create after/before params + // -/+ 2 minutes from the alarm, and reload the page + const alarmTime = new Date(urlOptions.alarm_when * 1000).valueOf(); + const timeMarginMs = 120000; // 2 mins + + const after = alarmTime - timeMarginMs; + const before = alarmTime + timeMarginMs; + const newHash = document.location.hash.replace( + /;alarm_when=[0-9]*/i, + ";after=" + after + ";before=" + before, + ); + history.replaceState(null, '', newHash); + location.reload(); + } + + if (urlOptions.server !== null && urlOptions.server !== '') { + netdataServerStatic = document.location.origin.toString() + document.location.pathname.toString(); + netdataServer = urlOptions.server; + netdataCheckXSS = true; + } else { + urlOptions.server = null; + } + + if (urlOptions.before > 0 && urlOptions.after > 0) { + urlOptions.pan_and_zoom = true; + urlOptions.nowelcome = true; + } else { + urlOptions.pan_and_zoom = false; + } + + if (urlOptions.highlight_before > 0 && urlOptions.highlight_after > 0) { + urlOptions.highlight = true; + } else { + urlOptions.highlight = false; + } + + switch (urlOptions.mode) { + case 'print': + urlOptions.theme = 'white'; + urlOptions.welcome = false; + urlOptions.help = false; + urlOptions.show_alarms = false; + + if (urlOptions.pan_and_zoom === false) { + urlOptions.pan_and_zoom = true; + urlOptions.before = Date.now(); + urlOptions.after = urlOptions.before - 600000; + } + + netdataShowAlarms = false; + netdataRegistry = false; + this_is_demo = false; + break; + + case 'live': + default: + urlOptions.mode = 'live'; + break; + } + + // console.log(urlOptions); + }, + + hashUpdate: function () { + history.replaceState(null, '', urlOptions.genHash(true)); + }, + + netdataPanAndZoomCallback: function (status, after, before) { + //console.log(1); + //console.log(new Error().stack); + + if (netdataSnapshotData === null) { + urlOptions.pan_and_zoom = status; + urlOptions.after = after; + urlOptions.before = before; + urlOptions.hashUpdate(); + } + }, + + netdataHighlightCallback: function (status, after, before) { + //console.log(2); + //console.log(new Error().stack); + + if (status === true && (after === null || before === null || after <= 0 || before <= 0 || after >= before)) { + status = false; + after = 0; + before = 0; + } + + if (netdataSnapshotData === null) { + urlOptions.highlight = status; + } else { + urlOptions.highlight = false; + } + + urlOptions.highlight_after = Math.round(after); + urlOptions.highlight_before = Math.round(before); + urlOptions.hashUpdate(); + + var show_eye = NETDATA.globalChartUnderlay.hasViewport(); + + if (status === true && after > 0 && before > 0 && after < before) { + var d1 = NETDATA.dateTime.localeDateString(after); + var d2 = NETDATA.dateTime.localeDateString(before); + if (d1 === d2) { + d2 = ''; + } + document.getElementById('navbar-highlight-content').innerHTML = + ((show_eye === true) ? '' : '').toString() + + 'highlighted time-frame' + + ' ' + d1 + ' ' + NETDATA.dateTime.localeTimeString(after) + ' to ' + + ' ' + d2 + ' ' + NETDATA.dateTime.localeTimeString(before) + ', ' + + 'duration ' + NETDATA.seconds4human(Math.round((before - after) / 1000)) + '' + + '' + + ''; + + $('.navbar-highlight').show(); + + $('.highlight-tooltip').tooltip({ + html: true, + delay: { show: 500, hide: 0 }, + container: 'body' + }); + } else { + $('.navbar-highlight').hide(); + } + }, + + clearHighlight: function () { + NETDATA.globalChartUnderlay.clear(); + + if (NETDATA.globalPanAndZoom.isActive() === true) { + NETDATA.globalPanAndZoom.clearMaster(); + } + }, + + showHighlight: function () { + NETDATA.globalChartUnderlay.focus(); + } +}; + +urlOptions.parseHash(); + +// -------------------------------------------------------------------- +// check options that should be processed before loading netdata.js + +var localStorageTested = -1; + +function localStorageTest() { + if (localStorageTested !== -1) { + return localStorageTested; + } + + if (typeof Storage !== "undefined" && typeof localStorage === 'object') { + var test = 'test'; + try { + localStorage.setItem(test, test); + localStorage.removeItem(test); + localStorageTested = true; + } + catch (e) { + console.log(e); + localStorageTested = false; + } + } else { + localStorageTested = false; + } + + return localStorageTested; +} + +function loadLocalStorage(name) { + var ret = null; + + try { + if (localStorageTest() === true) { + ret = localStorage.getItem(name); + } else { + console.log('localStorage is not available'); + } + } + catch (error) { + console.log(error); + return null; + } + + 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 (localStorageTest() === true) { + localStorage.setItem(name, value.toString()); + return true; + } + } + catch (error) { + console.log(error); + } + + return false; +} + +function getTheme(def) { + if (urlOptions.mode === 'print') { + return 'white'; + } + + var ret = loadLocalStorage('netdataTheme'); + if (typeof ret === 'undefined' || ret === null || ret === 'undefined') { + return def; + } else { + return ret; + } +} + +function setTheme(theme) { + if (urlOptions.mode === 'print') { + return false; + } + + 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'); +} + +// -------------------------------------------------------------------- +// natural sorting +// http://www.davekoelle.com/files/alphanum.js - LGPL + +function naturalSortChunkify(t) { + var tz = []; + var x = 0, y = -1, n = 0, i, j; + + while (i = (j = t.charAt(x++)).charCodeAt(0)) { + var m = (i >= 48 && i <= 57); + if (m !== n) { + tz[++y] = ""; + n = m; + } + tz[y] += j; + } + + return tz; +} + +function naturalSortCompare(a, b) { + var aa = naturalSortChunkify(a.toLowerCase()); + var bb = naturalSortChunkify(b.toLowerCase()); + + for (var x = 0; aa[x] && bb[x]; x++) { + if (aa[x] !== bb[x]) { + var c = Number(aa[x]), d = Number(bb[x]); + if (c.toString() === aa[x] && d.toString() === bb[x]) { + return c - d; + } else { + return (aa[x] > bb[x]) ? 1 : -1; + } + } + } + + return aa.length - bb.length; +} + +// -------------------------------------------------------------------- +// saving files to client + +function saveTextToClient(data, filename) { + var blob = new Blob([data], { + type: 'application/octet-stream' + }); + + var url = URL.createObjectURL(blob); + var link = document.createElement('a'); + link.setAttribute('href', url); + link.setAttribute('download', filename); + + var el = document.getElementById('hiddenDownloadLinks'); + el.innerHTML = ''; + el.appendChild(link); + + setTimeout(function () { + el.removeChild(link); + URL.revokeObjectURL(url); + }, 60); + + link.click(); +} + +function saveObjectToClient(data, filename) { + saveTextToClient(JSON.stringify(data), filename); +} + +// ----------------------------------------------------------------------------- +// registry call back to render my-netdata menu + +function toggleExpandIcon(svgEl) { + if (svgEl.getAttribute('data-icon') === 'caret-down') { + svgEl.setAttribute('data-icon', 'caret-up'); + } else { + svgEl.setAttribute('data-icon', 'caret-down'); + } +} + +function toggleAgentItem(e, guid) { + e.stopPropagation(); + e.preventDefault(); + + toggleExpandIcon(e.currentTarget.children[0]); + + const el = document.querySelector(`.agent-alternate-urls.agent-${guid}`); + if (el) { + el.classList.toggle('collapsed'); + } +} + +// When you stream metrics from netdata to netdata, the receiving netdata now +// has multiple host databases. It's own, and multiple mirrored. Mirrored databases +// can be accessed with +const OLD_DASHBOARD_SUFFIX = "old" +let isOldSuffix = true +try { + const currentScriptMainJs = document.currentScript; + const mainJsSrc = currentScriptMainJs.getAttribute("src") + isOldSuffix = mainJsSrc.startsWith("../main.js") +} catch { + console.warn("current script not detecting, assuming the dashboard is running with /old suffix") +} + +function transformWithOldSuffix(url) { + return isOldSuffix ? `../${url}` : url +} + +function renderStreamedHosts(options) { + let html = `
    Databases streamed to this agent
    `; + + var base = document.location.origin.toString() + + document.location.pathname.toString() + .replace(isOldSuffix ? `/${OLD_DASHBOARD_SUFFIX}` : "", ""); + if (base.endsWith("/host/" + options.hostname + "/")) { + base = base.substring(0, base.length - ("/host/" + options.hostname + "/").toString().length); + } + + if (base.endsWith("/")) { + base = base.substring(0, base.length - 1); + } + + var master = options.hosts[0].hostname; + // We sort a clone of options.hosts, to keep the master as the first element + // for future calls. + var sorted = options.hosts.slice(0).sort(function (a, b) { + if (a.hostname === master) { + return -1; + } + return naturalSortCompare(a.hostname, b.hostname); + }); + + let displayedDatabases = false; + + for (var s of sorted) { + let url, icon; + const hostname = s.hostname; + + if (myNetdataMenuFilterValue !== "") { + if (!hostname.includes(myNetdataMenuFilterValue)) { + continue; + } + } + + displayedDatabases = true; + + if (hostname === master) { + url = isOldSuffix ? `${base}/${OLD_DASHBOARD_SUFFIX}/` : `${base}/`; + icon = 'home'; + } else { + url = isOldSuffix ? `${base}/host/${hostname}/${OLD_DASHBOARD_SUFFIX}/` : `${base}/host/${hostname}/`; + icon = 'window-restore'; + } + + html += ( + `
    + + + + + ${hostname} + +
    +
    ` + ) + } + + if (!displayedDatabases) { + html += ( + `
    + + no databases match the filter criteria. +
    ` + ) + } + + return html; +} + +function renderMachines(machinesArray) { + let html = `
    My nodes
    `; + + if (machinesArray === null) { + let ret = loadLocalStorage("registryCallback"); + if (ret) { + machinesArray = JSON.parse(ret); + console.log("failed to contact the registry - loaded registry data from browser local storage"); + } + } + + let found = false; + let displayedAgents = false; + + const maskedURL = NETDATA.registry.MASKED_DATA; + + if (machinesArray) { + saveLocalStorage("registryCallback", JSON.stringify(machinesArray)); + + var machines = machinesArray.sort(function (a, b) { + return naturalSortCompare(a.name, b.name); + }); + + for (var machine of machines) { + found = true; + + if (myNetdataMenuFilterValue !== "") { + if (!machine.name.includes(myNetdataMenuFilterValue)) { + continue; + } + } + + displayedAgents = true; + + const alternateUrlItems = ( + `` + ) + + html += ( + ` + ${alternateUrlItems}` + ) + } + + if (found && (!displayedAgents)) { + html += ( + `
    + + zero nodes are matching the filter value. +
    ` + ) + } + } + + if (!found) { + if (machines) { + html += ( + `` + ) + } else { + html += ( + `` + ) + } + + html += `
    `; + html += `
    Demo netdata nodes
    `; + + const demoServers = [ + { url: "//london.netdata.rocks/default.html", title: "UK - London (DigitalOcean.com)" }, + { url: "//newyork.netdata.rocks/default.html", title: "US - New York (DigitalOcean.com)" }, + { url: "//sanfrancisco.netdata.rocks/default.html", title: "US - San Francisco (DigitalOcean.com)" }, + { url: "//atlanta.netdata.rocks/default.html", title: "US - Atlanta (CDN77.com)" }, + { url: "//frankfurt.netdata.rocks/default.html", title: "Germany - Frankfurt (DigitalOcean.com)" }, + { url: "//toronto.netdata.rocks/default.html", title: "Canada - Toronto (DigitalOcean.com)" }, + { url: "//singapore.netdata.rocks/default.html", title: "Japan - Singapore (DigitalOcean.com)" }, + { url: "//bangalore.netdata.rocks/default.html", title: "India - Bangalore (DigitalOcean.com)" }, + + ] + + for (var server of demoServers) { + html += ( + `
    + + ${server.title} +
    +
    + ` + ); + } + } + + return html; +} + +function setMyNetdataMenu(html) { + const el = document.getElementById('my-netdata-dropdown-content') + el.innerHTML = html; +} + +function clearMyNetdataMenu() { + setMyNetdataMenu(`
    + + Loading, please wait... +
    +
    `); +} + +function errorMyNetdataMenu() { + setMyNetdataMenu(`
    + + Cannot load known Netdata agents from Netdata Cloud! Please make sure you have the latest version of Netdata. +
    `); +} + +function restrictMyNetdataMenu() { + setMyNetdataMenu(`
    + Please sign in to netdata.cloud to view your nodes! +
    +
    `); +} + +function openAuthenticatedUrl(url) { + if (isSignedIn()) { + window.open(url); + } else { + window.open(`${NETDATA.registry.cloudBaseURL}/account/sign-in-agent?id=${NETDATA.registry.machine_guid}&name=${encodeURIComponent(NETDATA.registry.hostname)}&origin=${encodeURIComponent(window.location.origin + "/")}&redirect_uri=${encodeURIComponent(window.location.origin + "/" + url)}`); + } +} + +function renderMyNetdataMenu(machinesArray) { + const el = document.getElementById('my-netdata-dropdown-content'); + el.classList.add(`theme-${netdataTheme}`); + + if (machinesArray == registryAgents) { + console.log("Rendering my-netdata menu from registry"); + } else { + console.log("Rendering my-netdata menu from netdata.cloud", machinesArray); + } + + let html = ''; + + if (!isSignedIn()) { + if (!NETDATA.registry.isRegistryEnabled()) { + html += ( + `
    + Please sign in to netdata.cloud to view your nodes! +
    +
    +
    ` + ); + } + } + + if (isSignedIn()) { + html += ( + `
    + + +
    +
    ` + ); + } + + // options.hosts = [ + // { + // hostname: "streamed1", + // }, + // { + // hostname: "streamed2", + // }, + // ] + + if (options.hosts.length > 1) { + html += `
    ${renderStreamedHosts(options)}

    `; + } + + if (isSignedIn() || NETDATA.registry.isRegistryEnabled()) { + html += `
    ${renderMachines(machinesArray)}

    `; + } + + if (!isSignedIn()) { + html += ( + `
    + + Switch Identity +
    +
    +
    + + What is this? +
    +
    ` + ) + } else { + html += ( + `
    + + Nodes beta +
    +
    + +
    + + What is this? +
    +
    ` + ) + } + + el.innerHTML = html; + + gotoServerInit(); +} + +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('.netdata.ai') || + document.location.hostname.endsWith('.netdata.live') || + document.location.hostname.endsWith('.firehol.org') || + document.location.hostname.endsWith('.netdata.online') || + document.location.hostname.endsWith('.netdata.cloud')) { + this_is_demo = true; + } + } + } + catch (error) { + } + return this_is_demo; +} + +function netdataURL(url, forReload) { + if (typeof url === 'undefined') + // url = document.location.toString(); + { + url = ''; + } + + if (url.indexOf('#') !== -1) { + url = url.substring(0, url.indexOf('#')); + } + + var hash = urlOptions.genHash(forReload); + + // console.log('netdataURL: ' + url + hash); + + return url + hash; +} + +function netdataReload(url) { + document.location = verifyURL(netdataURL(url, true)); + + // since we play with hash + // this is needed to reload the page + location.reload(); +} + +function gotoHostedModalHandler(url) { + document.location = verifyURL(url + urlOptions.genHash()); + return false; +} + +var gotoServerValidateRemaining = 0; +var gotoServerMiddleClick = false; +var gotoServerStop = false; + +function gotoServerValidateUrl(id, guid, url) { + var penalty = 0; + var error = 'failed'; + + 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. + { + penalty = 500; + } else if (document.location.toString().startsWith('https://') && url.toString().startsWith('http://')) { + error = 'can\'t check'; + } + + var finalURL = netdataURL(url); + + setTimeout(function () { + document.getElementById('gotoServerList').innerHTML += '' + escapeUserInputHTML(url) + 'checking...'; + + NETDATA.registry.hello(url, function (data) { + if (typeof data !== 'undefined' && data !== null && typeof data.machine_guid === 'string' && data.machine_guid === guid) { + // console.log('OK ' + id + ' URL: ' + url); + document.getElementById(guid + '-' + id + '-status').innerHTML = "OK"; + + if (!gotoServerStop) { + gotoServerStop = true; + + if (gotoServerMiddleClick) { + window.open(verifyURL(finalURL), '_blank'); + gotoServerMiddleClick = false; + document.getElementById('gotoServerResponse').innerHTML = 'Opening new window to ' + NETDATA.registry.machines[guid].name + '
    ' + escapeUserInputHTML(url) + '

    (check your pop-up blocker if it fails)'; + } else { + document.getElementById('gotoServerResponse').innerHTML += 'found it! It is at:
    ' + escapeUserInputHTML(url) + ''; + document.location = verifyURL(finalURL); + $('#gotoServerModal').modal('hide'); + } + } + } else { + if (typeof data !== 'undefined' && data !== null && typeof data.machine_guid === 'string' && data.machine_guid !== guid) { + error = 'wrong machine'; + } + + document.getElementById(guid + '-' + id + '-status').innerHTML = error; + gotoServerValidateRemaining--; + if (gotoServerValidateRemaining <= 0) { + gotoServerMiddleClick = false; + document.getElementById('gotoServerResponse').innerHTML = 'Sorry! I cannot find any operational URL for this server'; + } + } + }); + }, (id * 50) + penalty); +} + +function gotoServerModalHandler(guid) { + // console.log('goto server: ' + guid); + + gotoServerStop = false; + var checked = {}; + var len = NETDATA.registry.machines[guid].alternate_urls.length; + var count = 0; + + document.getElementById('gotoServerResponse').innerHTML = ''; + document.getElementById('gotoServerList').innerHTML = ''; + document.getElementById('gotoServerName').innerHTML = NETDATA.registry.machines[guid].name; + $('#gotoServerModal').modal('show'); + + gotoServerValidateRemaining = len; + while (len--) { + var url = NETDATA.registry.machines[guid].alternate_urls[len]; + checked[url] = true; + gotoServerValidateUrl(count++, guid, url); + } + + if (!isSignedIn()) { + // When the registry is enabled, if the user's known URLs are not working + // we consult the registry to get additional URLs. + setTimeout(function () { + if (gotoServerStop === false) { + document.getElementById('gotoServerResponse').innerHTML = 'Added all the known URLs for this machine.'; + NETDATA.registry.search(guid, function (data) { + // console.log(data); + len = data.urls.length; + while (len--) { + var url = data.urls[len][1]; + // console.log(url); + if (typeof checked[url] === 'undefined') { + gotoServerValidateRemaining++; + checked[url] = true; + gotoServerValidateUrl(count++, guid, url); + } + } + }); + } + }, 2000); + } + + 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'); +} + +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 = "Sorry! The registry rejected your request."; + } + }); + } else { + document.getElementById('switchRegistryResponse').innerHTML = "The ID you have entered is not a GUID."; + } +} + +var deleteRegistryGuid = null; +var deleteRegistryUrl = null; + +function deleteRegistryModalHandler(guid, name, url) { + // void (guid); + + deleteRegistryGuid = guid; + 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() { + const responseEl = document.getElementById('deleteRegistryResponse'); + + if (deleteRegistryUrl) { + if (isSignedIn()) { + deleteCloudAgentURL(deleteRegistryGuid, deleteRegistryUrl) + .then((count) => { + if (!count) { + responseEl.innerHTML = "Sorry, this command was rejected by netdata.cloud!"; + return; + } + NETDATA.registry.delete(deleteRegistryUrl, function (result) { + if (result === null) { + console.log("Received error from registry", result); + } + + deleteRegistryUrl = null; + $('#deleteRegistryModal').modal('hide'); + NETDATA.registry.init(); + }); + }); + } else { + NETDATA.registry.delete(deleteRegistryUrl, function (result) { + if (result !== null) { + deleteRegistryUrl = null; + $('#deleteRegistryModal').modal('hide'); + NETDATA.registry.init(); + } else { + responseEl.innerHTML = "Sorry, this command was rejected by the registry server!"; + } + }); + } + } +} + +var options = { + menus: {}, + submenu_names: {}, + data: null, + hostname: 'netdata_server', // will be overwritten by the netdata server + version: 'unknown', + release_channel: 'unknown', + hosts: [], + + duration: 0, // the default duration of the charts + update_every: 1, + + chartsPerRow: 0, + // chartsMinWidth: 1450, + chartsHeight: 180, +}; + +function chartsPerRow(total) { + void (total); + + if (options.chartsPerRow === 0) { + return 1; + //var 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; + } + return naturalSortCompare(a.name, b.name); +} + +function sortObjectByPriority(object) { + var idx = {}; + var sorted = []; + + for (var i in object) { + if (!object.hasOwnProperty(i)) { + continue; + } + + 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; + } + return naturalSortCompare(a, b); + }); + + return sorted; +} + +// ---------------------------------------------------------------------------- +// scroll to a section, without changing the browser history + +function scrollToId(hash) { + if (hash && hash !== '' && document.getElementById(hash) !== null) { + var offset = $('#' + hash).offset(); + if (typeof offset !== 'undefined') { + //console.log('scrolling to ' + hash + ' at ' + offset.top.toString()); + $('html, body').animate({ scrollTop: offset.top - 30 }, 0); + } + } + + // we must return false to prevent the default action + return false; +} + +// ---------------------------------------------------------------------------- + +// user editable information +var customDashboard = { + menu: {}, + submenu: {}, + context: {} +}; + +// netdata standard information +var netdataDashboard = { + sparklines_registry: {}, + os: 'unknown', + + menu: {}, + submenu: {}, + context: {}, + + // generate a sparkline + // used in the documentation + sparkline: function (prefix, chart, dimension, units, suffix) { + if (options.data === null || typeof options.data.charts === 'undefined') { + return ''; + } + + if (typeof options.data.charts[chart] === 'undefined') { + return ''; + } + + if (typeof options.data.charts[chart].dimensions === 'undefined') { + return ''; + } + + if (typeof options.data.charts[chart].dimensions[dimension] === 'undefined') { + return ''; + } + + var key = chart + '.' + dimension; + + if (typeof units === 'undefined') { + units = ''; + } + + if (typeof this.sparklines_registry[key] === 'undefined') { + this.sparklines_registry[key] = { count: 1 }; + } else { + this.sparklines_registry[key].count++; + } + + key = key + '.' + this.sparklines_registry[key].count; + + return prefix + '
    (X' + units + ')' + suffix; + }, + + gaugeChart: function (title, width, dimensions, colors) { + if (typeof colors === 'undefined') { + colors = ''; + } + + if (typeof dimensions === 'undefined') { + dimensions = ''; + } + + return '
    '; + }, + + anyAttribute: function (obj, attr, key, def) { + if (typeof (obj[key]) !== 'undefined') { + var x = obj[key][attr]; + + if (typeof (x) === 'undefined') { + return def; + } + + if (typeof (x) === 'function') { + return x(netdataDashboard.os); + } + + return x; + } + + return def; + }, + + menuTitle: function (chart) { + if (typeof chart.menu_pattern !== 'undefined') { + return (this.anyAttribute(this.menu, 'title', chart.menu_pattern, chart.menu_pattern).toString() + + ' ' + chart.type.slice(-(chart.type.length - chart.menu_pattern.length - 1)).toString()).replace(/_/g, ' '); + } + + return (this.anyAttribute(this.menu, 'title', chart.menu, chart.menu)).toString().replace(/_/g, ' '); + }, + + menuIcon: function (chart) { + if (typeof chart.menu_pattern !== 'undefined') { + return this.anyAttribute(this.menu, 'icon', chart.menu_pattern, '').toString(); + } + + return this.anyAttribute(this.menu, 'icon', chart.menu, ''); + }, + + menuInfo: function (chart) { + if (typeof chart.menu_pattern !== 'undefined') { + return this.anyAttribute(this.menu, 'info', chart.menu_pattern, null); + } + + return this.anyAttribute(this.menu, 'info', chart.menu, null); + }, + + menuHeight: function (chart) { + if (typeof chart.menu_pattern !== 'undefined') { + return this.anyAttribute(this.menu, 'height', chart.menu_pattern, 1.0); + } + + return this.anyAttribute(this.menu, 'height', chart.menu, 1.0); + }, + + submenuTitle: function (menu, submenu) { + var key = menu + '.' + submenu; + // console.log(key); + var title = this.anyAttribute(this.submenu, 'title', key, submenu).toString().replace(/_/g, ' '); + if (title.length > 28) { + var a = title.substring(0, 13); + var b = title.substring(title.length - 12, title.length); + return a + '...' + b; + } + return title; + }, + + submenuInfo: function (menu, submenu) { + var key = menu + '.' + submenu; + return this.anyAttribute(this.submenu, 'info', key, null); + }, + + submenuHeight: function (menu, submenu, relative) { + var key = menu + '.' + submenu; + return this.anyAttribute(this.submenu, 'height', key, 1.0) * relative; + }, + + contextInfo: function (id) { + var x = this.anyAttribute(this.context, 'info', id, null); + + if (x !== null) { + return '
    ' + x + '
    '; + } else { + return ''; + } + }, + + contextValueRange: function (id) { + if (typeof this.context[id] !== 'undefined' && typeof this.context[id].valueRange !== 'undefined') { + return this.context[id].valueRange; + } else { + return '[null, null]'; + } + }, + + contextHeight: function (id, def) { + if (typeof this.context[id] !== 'undefined' && typeof this.context[id].height !== 'undefined') { + return def * this.context[id].height; + } else { + return def; + } + }, + + contextDecimalDigits: function (id, def) { + if (typeof this.context[id] !== 'undefined' && typeof this.context[id].decimalDigits !== 'undefined') { + return this.context[id].decimalDigits; + } else { + return def; + } + } +}; + +// ---------------------------------------------------------------------------- + +// enrich the data structure returned by netdata +// to reflect our menu system and content +// TODO: this is a shame - we should fix charts naming (issue #807) +function enrichChartData(chart) { + var parts = chart.type.split('_'); + var tmp = parts[0]; + + switch (tmp) { + case 'ap': + case 'net': + case 'disk': + case 'powersupply': + chart.menu = tmp; + break; + + case 'apache': + chart.menu = chart.type; + if (parts.length > 2 && parts[1] === 'cache') { + chart.menu_pattern = tmp + '_' + parts[1]; + } else if (parts.length > 1) { + chart.menu_pattern = tmp; + } + break; + + case 'bind': + chart.menu = chart.type; + if (parts.length > 2 && parts[1] === 'rndc') { + chart.menu_pattern = tmp + '_' + parts[1]; + } else if (parts.length > 1) { + chart.menu_pattern = 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 'go': + chart.menu = chart.type; + if (parts.length > 2 && parts[1] === 'expvar') { + chart.menu_pattern = tmp + '_' + parts[1]; + } else if (parts.length > 1) { + chart.menu_pattern = tmp; + } + break; + + case 'mount': + if (parts.length > 2) { + chart.menu = tmp + '_' + parts[1]; + } else { + chart.menu = tmp; + } + break; + + case 'isc': + chart.menu = chart.type; + if (parts.length > 2 && parts[1] === 'dhcpd') { + chart.menu_pattern = tmp + '_' + parts[1]; + } else if (parts.length > 1) { + chart.menu_pattern = tmp; + } + break; + + case 'ovpn': + chart.menu = chart.type; + if (parts.length > 3 && parts[1] === 'status' && parts[2] === 'log') { + chart.menu_pattern = tmp + '_' + parts[1]; + } else if (parts.length > 1) { + chart.menu_pattern = tmp; + } + break; + + case 'smartd': + case 'web': + chart.menu = chart.type; + if (parts.length > 2 && parts[1] === 'log') { + chart.menu_pattern = tmp + '_' + parts[1]; + } else if (parts.length > 1) { + 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 (chart.context === 'tc.qos' && (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); + } else { + options.submenu_names[chart.family] = n; + } + } + + // 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; + if (parts.length > 1) { + chart.menu_pattern = tmp; + } + break; + } + + chart.submenu = chart.family; +} + +// ---------------------------------------------------------------------------- + +function headMain(os, charts, duration) { + void (os); + + if (urlOptions.mode === 'print') { + return ''; + } + + var head = ''; + + if (typeof charts['system.swap'] !== 'undefined') { + head += '
    '; + } + + if (typeof charts['system.io'] !== 'undefined') { + head += '
    '; + + head += '
    '; + } + else if (typeof charts['system.pgpgio'] !== 'undefined') { + head += '
    '; + + head += '
    '; + } + + if (typeof charts['system.cpu'] !== 'undefined') { + head += '
    '; + } + + if (typeof charts['system.net'] !== 'undefined') { + head += '
    '; + + head += '
    '; + } + else if (typeof charts['system.ip'] !== 'undefined') { + head += '
    '; + + head += '
    '; + } + else if (typeof charts['system.ipv4'] !== 'undefined') { + head += '
    '; + + head += '
    '; + } + else if (typeof charts['system.ipv6'] !== 'undefined') { + head += '
    '; + + head += '
    '; + } + + if (typeof charts['system.ram'] !== 'undefined') { + head += '
    '; + } + + return head; +} + +function generateHeadCharts(type, chart, duration) { + if (urlOptions.mode === 'print') { + return ''; + } + + var head = ''; + var hcharts = netdataDashboard.anyAttribute(netdataDashboard.context, type, chart.context, []); + if (hcharts.length > 0) { + var hi = 0, hlen = hcharts.length; + while (hi < hlen) { + if (typeof hcharts[hi] === 'function') { + head += hcharts[hi](netdataDashboard.os, chart.id).replace(/CHART_DURATION/g, duration.toString()).replace(/CHART_UNIQUE_ID/g, chart.id); + } else { + head += hcharts[hi].replace(/CHART_DURATION/g, duration.toString()).replace(/CHART_UNIQUE_ID/g, 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; + options.duration = duration; + options.update_every = data.update_every; + + var html = ''; + var sidebar = '

    '; + } + + const isMemoryModeDbEngine = data.memory_mode === "dbengine"; + + sidebar += '
  • Add more charts
  • '; + sidebar += '
  • Add more alarms
  • '; + sidebar += '
  • Every ' + + ((data.update_every === 1) ? 'second' : data.update_every.toString() + ' seconds') + ', ' + + 'Netdata collects ' + data.dimensions_count.toLocaleString() + ' metrics on ' + + data.hostname.toString() + ', presents them in ' + + data.charts_count.toLocaleString() + ' charts' + + (isMemoryModeDbEngine ? '' : ',') + // oxford comma + ' and monitors them with ' + + data.alarms_count.toLocaleString() + ' alarms.'; + + if (!isMemoryModeDbEngine) { + sidebar += '
     
    Get more history by ' + + 'configuring Netdata\'s history or using the DB engine.'; + } + + sidebar += '
     
    netdata
    ' + data.version.toString() + '
  • '; + + sidebar += ''; + div.innerHTML = html; + document.getElementById('sidebar').innerHTML = sidebar; + + if (urlOptions.highlight === true) { + NETDATA.globalChartUnderlay.init(null + , urlOptions.highlight_after + , urlOptions.highlight_before + , (urlOptions.after > 0) ? urlOptions.after : null + , (urlOptions.before > 0) ? urlOptions.before : null + ); + } else { + NETDATA.globalChartUnderlay.clear(); + } + + if (urlOptions.mode === 'print') { + printPage(); + } else { + finalizePage(); + } +} + +function renderChartsAndMenu(data) { + options.menus = {}; + options.submenu_names = {}; + + var menus = options.menus; + var charts = data.charts; + var m, menu_key; + + for (var c in charts) { + if (!charts.hasOwnProperty(c)) { + continue; + } + + var chart = charts[c]; + enrichChartData(chart); + m = chart.menu; + + // create the menu + if (typeof menus[m] === 'undefined') { + menus[m] = { + menu_pattern: chart.menu_pattern, + priority: chart.priority, + submenus: {}, + title: netdataDashboard.menuTitle(chart), + icon: netdataDashboard.menuIcon(chart), + info: netdataDashboard.menuInfo(chart), + height: netdataDashboard.menuHeight(chart) * options.chartsHeight + }; + } else { + if (typeof (menus[m].menu_pattern) === 'undefined') { + menus[m].menu_pattern = chart.menu_pattern; + } + + if (chart.priority < menus[m].priority) { + menus[m].priority = chart.priority; + } + } + + menu_key = (typeof (menus[m].menu_pattern) !== 'undefined') ? menus[m].menu_pattern : m; + + // create the submenu + if (typeof menus[m].submenus[chart.submenu] === 'undefined') { + menus[m].submenus[chart.submenu] = { + priority: chart.priority, + charts: [], + title: null, + info: netdataDashboard.submenuInfo(menu_key, chart.submenu), + height: netdataDashboard.submenuHeight(menu_key, chart.submenu, menus[m].height) + }; + } else { + if (chart.priority < menus[m].submenus[chart.submenu].priority) { + menus[m].submenus[chart.submenu].priority = chart.priority; + } + } + + // index the chart in the menu/submenu + menus[m].submenus[chart.submenu].charts.push(chart); + } + + // propagate the descriptive subname given to QoS + // to all the other submenus with the same name + for (var m in menus) { + if (!menus.hasOwnProperty(m)) { + continue; + } + + for (var s in menus[m].submenus) { + if (!menus[m].submenus.hasOwnProperty(s)) { + continue; + } + + // set the family using a name + if (typeof options.submenu_names[s] !== 'undefined') { + menus[m].submenus[s].title = s + ' (' + options.submenu_names[s] + ')'; + } else { + menu_key = (typeof (menus[m].menu_pattern) !== 'undefined') ? menus[m].menu_pattern : m; + menus[m].submenus[s].title = netdataDashboard.submenuTitle(menu_key, s); + } + } + } + + renderPage(menus, data); +} + +// ---------------------------------------------------------------------------- + +function loadJs(url, callback) { + $.ajax({ + url: url.startsWith("http") ? url : transformWithOldSuffix(url), + cache: true, + dataType: "script", + xhrFields: { withCredentials: true } // required for the cookie + }) + .fail(function () { + alert('Cannot load required JS library: ' + url); + }) + .always(function () { + if (typeof callback === 'function') { + callback(); + } + }) +} + +var clipboardLoaded = false; + +function loadClipboard(callback) { + if (clipboardLoaded === false) { + clipboardLoaded = true; + loadJs('lib/clipboard-polyfill-be05dad.js', callback); + } else { + callback(); + } +} + +var bootstrapTableLoaded = false; + +function loadBootstrapTable(callback) { + if (bootstrapTableLoaded === false) { + bootstrapTableLoaded = true; + loadJs('lib/bootstrap-table-1.11.0.min.js', function () { + loadJs('lib/bootstrap-table-export-1.11.0.min.js', function () { + loadJs('lib/tableExport-1.6.0.min.js', callback); + }) + }); + } else { + callback(); + } +} + +var bootstrapSliderLoaded = false; + +function loadBootstrapSlider(callback) { + if (bootstrapSliderLoaded === false) { + bootstrapSliderLoaded = true; + loadJs('lib/bootstrap-slider-10.0.0.min.js', function () { + NETDATA._loadCSS(transformWithOldSuffix("css/bootstrap-slider-10.0.0.min.css")); + callback(); + }); + } else { + callback(); + } +} + +var lzStringLoaded = false; + +function loadLzString(callback) { + if (lzStringLoaded === false) { + lzStringLoaded = true; + loadJs('lib/lz-string-1.4.4.min.js', callback); + } else { + callback(); + } +} + +var pakoLoaded = false; + +function loadPako(callback) { + if (pakoLoaded === false) { + pakoLoaded = true; + loadJs('lib/pako-1.0.6.min.js', callback); + } else { + callback(); + } +} + +// ---------------------------------------------------------------------------- + +function clipboardCopy(text) { + clipboard.writeText(text); +} + +function clipboardCopyBadgeEmbed(url) { + clipboard.writeText(''); +} + +// ---------------------------------------------------------------------------- + +function alarmsUpdateModal() { + var active = '

    Raised Alarms

    '; + var all = '

    All Running Alarms

    '; + var footer = '
    netdata badges refresh automatically. Their color indicates the state of the alarm:  red  is critical,  orange  is warning,  bright green  is ok,  light grey  is undefined (i.e. no data or no status),  black  is not initialized. You can copy and paste their URLs to embed them in any web page.
    netdata can send notifications for these alarms. Check this configuration file for more information.'; + + loadClipboard(function () { + }); + + NETDATA.alarms.get('all', function (data) { + options.alarm_families = []; + + alarmsCallback(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; + } + + function alarmid4human(id) { + if (id === 0) { + return '-'; + } + + return id.toString(); + } + + function timestamp4human(timestamp, space) { + if (timestamp === 0) { + return '-'; + } + + if (typeof space === 'undefined') { + space = ' '; + } + + var t = new Date(timestamp * 1000); + var now = new Date(); + + if (t.toDateString() === now.toDateString()) { + return t.toLocaleTimeString(); + } + + return t.toLocaleDateString() + space + t.toLocaleTimeString(); + } + + function alarm_lookup_explain(alarm, chart) { + var dimensions = ' of all values '; + + if (chart.dimensions.length > 1) { + dimensions = ' of the sum of all dimensions '; + } + + if (typeof alarm.lookup_dimensions !== 'undefined') { + var d = alarm.lookup_dimensions.replace(/|/g, ','); + var x = d.split(','); + if (x.length > 1) { + dimensions = 'of the sum of dimensions ' + alarm.lookup_dimensions + ' '; + } else { + dimensions = 'of all values of dimension ' + alarm.lookup_dimensions + ' '; + } + } + + return '' + alarm.lookup_method + ' ' + + dimensions + ', of chart ' + alarm.chart + '' + + ', starting ' + NETDATA.seconds4human(alarm.lookup_after + alarm.lookup_before, { space: ' ' }) + ' and up to ' + NETDATA.seconds4human(alarm.lookup_before, { space: ' ' }) + '' + + ((alarm.lookup_options) ? (', with options ' + alarm.lookup_options.replace(/ /g, ', ') + '') : '') + + '.'; + } + + function alarm_to_html(alarm, full) { + var chart = options.data.charts[alarm.chart]; + if (typeof (chart) === 'undefined') { + chart = options.data.charts_by_name[alarm.chart]; + if (typeof (chart) === 'undefined') { + // this means the charts loaded are incomplete + // probably netdata was restarted and more alarms + // are now available. + console.log('Cannot find chart ' + alarm.chart + ', you probably need to refresh the page.'); + return ''; + } + } + + var has_alarm = (typeof alarm.warn !== 'undefined' || typeof alarm.crit !== 'undefined'); + var badge_url = NETDATA.alarms.server + '/api/v1/badge.svg?chart=' + alarm.chart + '&alarm=' + alarm.name + '&refresh=auto'; + + var action_buttons = '
     
    role: ' + alarm.recipient + '
     
    ' + + '
    ' + + '
    ' + + '
    '; + + var html = '
    ' + + ''; + + return html; + } + + function alarm_family_show(id) { + var html = '
    ' + alarm.chart + '
     

     
    ' + alarm.info + '' + action_buttons + '
    ' + + ((typeof alarm.warn !== 'undefined') ? ('') : '') + + ((typeof alarm.crit !== 'undefined') ? ('') : ''); + + if (full === true) { + var units = chart.units; + if (units === '%') { + units = '%'; + } + + html += ((typeof alarm.lookup_after !== 'undefined') ? ('') : '') + + ((typeof alarm.calc !== 'undefined') ? ('') : '') + + ((chart.green !== null) ? ('') : '') + + ((chart.red !== null) ? ('') : ''); + } + + if (alarm.warn_repeat_every > 0) { + html += ''; + } + + if (alarm.crit_repeat_every > 0) { + html += ''; + } + + var delay = ''; + if ((alarm.delay_up_duration > 0 || alarm.delay_down_duration > 0) && alarm.delay_multiplier !== 0 && alarm.delay_max_duration > 0) { + if (alarm.delay_up_duration === alarm.delay_down_duration) { + delay += '
    hysteresis ' + NETDATA.seconds4human(alarm.delay_up_duration, { + space: ' ', + negative_suffix: '' + }); + } else { + delay = '
    hysteresis '; + if (alarm.delay_up_duration > 0) { + delay += 'on escalation ' + NETDATA.seconds4human(alarm.delay_up_duration, { + space: ' ', + negative_suffix: '' + }) + ', '; + } + if (alarm.delay_down_duration > 0) { + delay += 'on recovery ' + NETDATA.seconds4human(alarm.delay_down_duration, { + space: ' ', + negative_suffix: '' + }) + ', '; + } + } + if (alarm.delay_multiplier !== 1.0) { + delay += 'multiplied by ' + alarm.delay_multiplier.toString() + ''; + delay += ', up to ' + NETDATA.seconds4human(alarm.delay_max_duration, { + space: ' ', + negative_suffix: '' + }) + ''; + } + delay += '
    '; + } + + html += '
    ' + + ((has_alarm === true) ? ('') : '') + + '' + + '
    warning when' + alarm.warn + '
    critical when' + alarm.crit + '
    db lookup' + alarm_lookup_explain(alarm, chart) + '
    calculation' + alarm.calc + '
    green threshold' + chart.green + ' ' + units + '
    red threshold' + chart.red + ' ' + units + '
    repeat warning' + NETDATA.seconds4human(alarm.warn_repeat_every) + '
    repeat critical' + NETDATA.seconds4human(alarm.crit_repeat_every) + '
    check every' + NETDATA.seconds4human(alarm.update_every, { + space: ' ', + negative_suffix: '' + }) + '
    execute' + alarm.exec + '' + delay + '
    source' + alarm.source + '
    '; + var family = options.alarm_families[id]; + var len = family.arr.length; + while (len--) { + var alarm = family.arr[len]; + html += alarm_to_html(alarm, true); + } + html += '
    '; + + $('#alarm_all_' + id.toString()).html(html); + enableTooltipsAndPopovers(); + } + + // find the proper family of each alarm + var x, family, alarm; + var count_active = 0; + var count_all = 0; + var families = {}; + var families_sort = []; + for (x in data.alarms) { + if (!data.alarms.hasOwnProperty(x)) { + continue; + } + + alarm = data.alarms[x]; + family = alarm.family; + + // find the chart + var chart = options.data.charts[alarm.chart]; + if (typeof chart === 'undefined') { + chart = options.data.charts_by_name[alarm.chart]; + } + + // not found - this should never happen! + if (typeof chart === 'undefined') { + console.log('WARNING: alarm ' + x + ' is linked to chart ' + alarm.chart + ', which is not found in the list of chart got from the server.'); + chart = { priority: 9999999 }; + } + else if (typeof chart.menu !== 'undefined' && typeof chart.submenu !== 'undefined') + // the family based on the chart + { + family = chart.menu + ' - ' + chart.submenu; + } + + if (typeof families[family] === 'undefined') { + families[family] = { + name: family, + arr: [], + priority: chart.priority + }; + + families_sort.push(families[family]); + } + + if (chart.priority < families[family].priority) { + families[family].priority = chart.priority; + } + + families[family].arr.unshift(alarm); + } + + // sort the families, like the dashboard menu does + var families_sorted = families_sort.sort(function (a, b) { + if (a.priority < b.priority) { + return -1; + } + if (a.priority > b.priority) { + return 1; + } + return naturalSortCompare(a.name, b.name); + }); + + var i = 0; + var fc = 0; + var len = families_sorted.length; + while (len--) { + family = families_sorted[i++].name; + var active_family_added = false; + var expanded = 'true'; + var collapsed = ''; + var cin = 'in'; + + if (fc !== 0) { + all += ""; + expanded = 'false'; + collapsed = 'class="collapsed"'; + cin = ''; + } + + all += '
    '; + + options.alarm_families[fc] = families[family]; + + fc++; + + var arr = families[family].arr; + var c = arr.length; + while (c--) { + alarm = arr[c]; + if (alarm.status === 'WARNING' || alarm.status === 'CRITICAL') { + if (!active_family_added) { + active_family_added = true; + active += '

    ' + family + '

    '; + } + count_active++; + active += alarm_to_html(alarm, true); + } + + count_all++; + } + } + active += ""; + if (families_sorted.length > 0) { + all += "
    "; + } + all += ""; + + if (!count_active) { + active += '

    Everything is normal. No raised alarms.
    '; + } else { + active += footer; + } + + if (!count_all) { + all += "

    No alarms are running in this system.

    "; + } else { + all += footer; + } + + document.getElementById('alarms_active').innerHTML = active; + document.getElementById('alarms_all').innerHTML = all; + enableTooltipsAndPopovers(); + + if (families_sorted.length > 0) { + alarm_family_show(0); + } + + // register bootstrap events + var $accordion = $('#alarms_all_accordion'); + $accordion.on('show.bs.collapse', function (d) { + var target = $(d.target); + var id = $(target).data('alarm-id'); + alarm_family_show(id); + }); + $accordion.on('hidden.bs.collapse', function (d) { + var target = $(d.target); + var id = $(target).data('alarm-id'); + $('#alarm_all_' + id.toString()).html(''); + }); + + document.getElementById('alarms_log').innerHTML = '

    Alarm Log

    '; + + loadBootstrapTable(function () { + $('#alarms_log_table').bootstrapTable({ + url: NETDATA.alarms.server + '/api/v1/alarm_log?all', + cache: false, + pagination: true, + pageSize: 10, + showPaginationSwitch: false, + search: true, + searchTimeOut: 300, + searchAlign: 'left', + showColumns: true, + showExport: true, + exportDataType: 'basic', + exportOptions: { + fileName: 'netdata_alarm_log' + }, + onClickRow: function (row, $element,field) { + void (field); + void ($element); + let main_url; + let common_url = "&host=" + encodeURIComponent(row['hostname']) + "&chart=" + encodeURIComponent(row['chart']) + "&family=" + encodeURIComponent(row['family']) + "&alarm=" + encodeURIComponent(row['name']) + "&alarm_unique_id=" + row['unique_id'] + "&alarm_id=" + row['alarm_id'] + "&alarm_event_id=" + row['alarm_event_id'] + "&alarm_when=" + row['when']; + if (NETDATA.registry.isUsingGlobalRegistry() && NETDATA.registry.machine_guid != null) { + main_url = "https://netdata.cloud/alarms/redirect?agentID=" + NETDATA.registry.machine_guid + common_url; + } else { + main_url = NETDATA.registry.server + "/goto-host-from-alarm.html?" + common_url ; + } + window.open(main_url,"_blank"); + }, + rowStyle: function (row, index) { + void (index); + + switch (row.status) { + case 'CRITICAL': + return { classes: 'danger' }; + break; + case 'WARNING': + return { classes: 'warning' }; + break; + case 'UNDEFINED': + return { classes: 'info' }; + break; + case 'CLEAR': + return { classes: 'success' }; + break; + } + return {}; + }, + showFooter: false, + showHeader: true, + showRefresh: true, + showToggle: false, + sortable: true, + silentSort: false, + columns: [ + { + field: 'when', + title: 'Event Date', + valign: 'middle', + titleTooltip: 'The date and time the even took place', + formatter: function (value, row, index) { + void (row); + void (index); + return timestamp4human(value, ' '); + }, + align: 'center', + switchable: false, + sortable: true + }, + { + field: 'hostname', + title: 'Host', + valign: 'middle', + titleTooltip: 'The host that generated this event', + align: 'center', + visible: false, + sortable: true + }, + { + field: 'unique_id', + title: 'Unique ID', + titleTooltip: 'The host unique ID for this event', + formatter: function (value, row, index) { + void (row); + void (index); + return alarmid4human(value); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'alarm_id', + title: 'Alarm ID', + titleTooltip: 'The ID of the alarm that generated this event', + formatter: function (value, row, index) { + void (row); + void (index); + return alarmid4human(value); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'alarm_event_id', + title: 'Alarm Event ID', + titleTooltip: 'The incremental ID of this event for the given alarm', + formatter: function (value, row, index) { + void (row); + void (index); + return alarmid4human(value); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'chart', + title: 'Chart', + titleTooltip: 'The chart the alarm is attached to', + align: 'center', + valign: 'middle', + switchable: false, + sortable: true + }, + { + field: 'family', + title: 'Family', + titleTooltip: 'The family of the chart the alarm is attached to', + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'name', + title: 'Alarm', + titleTooltip: 'The alarm name that generated this event', + formatter: function (value, row, index) { + void (row); + void (index); + return value.toString().replace(/_/g, ' '); + }, + align: 'center', + valign: 'middle', + switchable: false, + sortable: true + }, + { + field: 'value_string', + title: 'Friendly Value', + titleTooltip: 'The value of the alarm, that triggered this event', + align: 'right', + valign: 'middle', + sortable: true + }, + { + field: 'old_value_string', + title: 'Friendly Old Value', + titleTooltip: 'The value of the alarm, just before this event', + align: 'right', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'old_value', + title: 'Old Value', + titleTooltip: 'The value of the alarm, just before this event', + formatter: function (value, row, index) { + void (row); + void (index); + return ((value !== null) ? Math.round(value * 100) / 100 : 'NaN').toString(); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'value', + title: 'Value', + titleTooltip: 'The value of the alarm, that triggered this event', + formatter: function (value, row, index) { + void (row); + void (index); + return ((value !== null) ? Math.round(value * 100) / 100 : 'NaN').toString(); + }, + align: 'right', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'units', + title: 'Units', + titleTooltip: 'The units of the value of the alarm', + align: 'left', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'old_status', + title: 'Old Status', + titleTooltip: 'The status of the alarm, just before this event', + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'status', + title: 'Status', + titleTooltip: 'The status of the alarm, that was set due to this event', + align: 'center', + valign: 'middle', + switchable: false, + sortable: true + }, + { + field: 'duration', + title: 'Last Duration', + titleTooltip: 'The duration the alarm was at its previous state, just before this event', + formatter: function (value, row, index) { + void (row); + void (index); + return NETDATA.seconds4human(value, { negative_suffix: '', space: ' ', now: 'no time' }); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'non_clear_duration', + title: 'Raised Duration', + titleTooltip: 'The duration the alarm was raised, just before this event', + formatter: function (value, row, index) { + void (row); + void (index); + return NETDATA.seconds4human(value, { negative_suffix: '', space: ' ', now: 'no time' }); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'recipient', + title: 'Recipient', + titleTooltip: 'The recipient of this event', + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'processed', + title: 'Processed Status', + titleTooltip: 'True when this event is processed', + formatter: function (value, row, index) { + void (row); + void (index); + + if (value === true) { + return 'DONE'; + } else { + return 'PENDING'; + } + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'updated', + title: 'Updated Status', + titleTooltip: 'True when this event has been updated by another event', + formatter: function (value, row, index) { + void (row); + void (index); + + if (value === true) { + return 'UPDATED'; + } else { + return 'CURRENT'; + } + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'updated_by_id', + title: 'Updated By ID', + titleTooltip: 'The unique ID of the event that obsoleted this one', + formatter: function (value, row, index) { + void (row); + void (index); + return alarmid4human(value); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'updates_id', + title: 'Updates ID', + titleTooltip: 'The unique ID of the event obsoleted because of this event', + formatter: function (value, row, index) { + void (row); + void (index); + return alarmid4human(value); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'exec', + title: 'Script', + titleTooltip: 'The script to handle the event notification', + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'exec_run', + title: 'Script Run At', + titleTooltip: 'The date and time the script has been ran', + formatter: function (value, row, index) { + void (row); + void (index); + return timestamp4human(value, ' '); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'exec_code', + title: 'Script Return Value', + titleTooltip: 'The return code of the script', + formatter: function (value, row, index) { + void (row); + void (index); + + if (value === 0) { + return 'OK (returned 0)'; + } else { + return 'FAILED (with code ' + value.toString() + ')'; + } + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'delay', + title: 'Script Delay', + titleTooltip: 'The hysteresis of the notification', + formatter: function (value, row, index) { + void (row); + void (index); + + return NETDATA.seconds4human(value, { negative_suffix: '', space: ' ', now: 'no time' }); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'delay_up_to_timestamp', + title: 'Script Delay Run At', + titleTooltip: 'The date and time the script should be run, after hysteresis', + formatter: function (value, row, index) { + void (row); + void (index); + return timestamp4human(value, ' '); + }, + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'info', + title: 'Description', + titleTooltip: 'A short description of the alarm', + align: 'center', + valign: 'middle', + visible: false, + sortable: true + }, + { + field: 'source', + title: 'Alarm Source', + titleTooltip: 'The source of configuration of the alarm', + align: 'center', + valign: 'middle', + visible: false, + sortable: true + } + ] + }); + // console.log($('#alarms_log_table').bootstrapTable('getOptions')); + }); + }); +} + +function alarmsCallback(data) { + var count = 0, x; + for (x in data.alarms) { + if (!data.alarms.hasOwnProperty(x)) { + continue; + } + + var alarm = data.alarms[x]; + if (alarm.status === 'WARNING' || alarm.status === 'CRITICAL') { + count++; + } + } + + if (count > 0) { + document.getElementById('alarms_count_badge').innerHTML = count.toString(); + } else { + document.getElementById('alarms_count_badge').innerHTML = ''; + } +} + +function initializeDynamicDashboardWithData(data) { + if (data !== null) { + options.hostname = data.hostname; + options.data = data; + options.version = data.version; + options.release_channel = data.release_channel; + netdataDashboard.os = data.os; + + if (typeof data.hosts !== 'undefined') { + options.hosts = data.hosts; + } + + // update the dashboard hostname + document.getElementById('hostname').innerHTML = '' + options.hostname + ((netdataSnapshotData !== null) ? ' (snap)' : '').toString() + '  '; + document.getElementById('hostname').href = NETDATA.serverDefault; + document.getElementById('netdataVersion').innerHTML = options.version; + + if (netdataSnapshotData !== null) { + $('#alarmsButton').hide(); + $('#updateButton').hide(); + // $('#loadButton').hide(); + $('#saveButton').hide(); + $('#printButton').hide(); + } + + // update the dashboard title + document.title = options.hostname + ' netdata dashboard'; + + // close the splash screen + $("#loadOverlay").css("display", "none"); + + // create a chart_by_name index + data.charts_by_name = {}; + var charts = data.charts; + var x; + for (x in charts) { + if (!charts.hasOwnProperty(x)) { + continue; + } + + var chart = charts[x]; + data.charts_by_name[chart.name] = chart; + } + + // render all charts + renderChartsAndMenu(data); + + // Ensure MyNetdata menu is rendered with latest host info #5370 + renderMyNetdataMenu(isSignedIn() ? cloudAgents : registryAgents); + } +} + +// an object to keep initialization configuration +// needed due to the async nature of the XSS modal +var initializeConfig = { + url: null, + custom_info: true, +}; + +function loadCustomDashboardInfo(url, callback) { + loadJs(url, function () { + $.extend(true, netdataDashboard, customDashboard); + callback(); + }); +} + +function initializeChartsAndCustomInfo() { + NETDATA.alarms.callback = alarmsCallback; + + // download all the charts the server knows + NETDATA.chartRegistry.downloadAll(initializeConfig.url, function (data) { + if (data !== null) { + if (initializeConfig.custom_info === true && typeof data.custom_info !== 'undefined' && data.custom_info !== "" && netdataSnapshotData === null) { + //console.log('loading custom dashboard decorations from server ' + initializeConfig.url); + loadCustomDashboardInfo(NETDATA.serverDefault + data.custom_info, function () { + initializeDynamicDashboardWithData(data); + }); + } else { + //console.log('not loading custom dashboard decorations from server ' + initializeConfig.url); + initializeDynamicDashboardWithData(data); + } + } + }); +} + +function xssModalDisableXss() { + //console.log('disabling xss checks'); + NETDATA.xss.enabled = false; + NETDATA.xss.enabled_for_data = false; + initializeConfig.custom_info = true; + initializeChartsAndCustomInfo(); + return false; +} + +function xssModalKeepXss() { + //console.log('keeping xss checks'); + NETDATA.xss.enabled = true; + NETDATA.xss.enabled_for_data = true; + initializeConfig.custom_info = false; + initializeChartsAndCustomInfo(); + return false; +} + +function initializeDynamicDashboard(netdata_url) { + if (typeof netdata_url === 'undefined' || netdata_url === null) { + netdata_url = NETDATA.serverDefault; + } + + initializeConfig.url = netdata_url; + + // initialize clickable alarms + NETDATA.alarms.chart_div_offset = -50; + NETDATA.alarms.chart_div_id_prefix = 'chart_'; + NETDATA.alarms.chart_div_animation_duration = 0; + + NETDATA.pause(function () { + if (typeof netdataCheckXSS !== 'undefined' && netdataCheckXSS === true) { + //$("#loadOverlay").css("display","none"); + document.getElementById('netdataXssModalServer').innerText = initializeConfig.url; + $('#xssModal').modal('show'); + } else { + initializeChartsAndCustomInfo(); + } + }); +} + +// ---------------------------------------------------------------------------- + +function versionLog(msg) { + document.getElementById('versionCheckLog').innerHTML = msg; +} + +// New way of checking for updates, based only on versions + +function versionsMatch(v1, v2) { + if (v1 == v2) { + return true; + } else { + let s1 = v1.split('.'); + let s2 = v2.split('.'); + // Check major version + let n1 = parseInt(s1[0].substring(1, 2), 10); + let n2 = parseInt(s2[0].substring(1, 2), 10); + if (n1 < n2) return false; + else if (n1 > n2) return true; + + // Check minor version + n1 = parseInt(s1[1], 10); + n2 = parseInt(s2[1], 10); + if (n1 < n2) return false; + else if (n1 > n2) return true; + + // Split patch: format could be e.g. 0-22-nightly + s1 = s1[2].split('-'); + s2 = s2[2].split('-'); + + n1 = parseInt(s1[0], 10); + n2 = parseInt(s2[0], 10); + if (n1 < n2) return false; + else if (n1 > n2) return true; + + n1 = (s1.length > 1) ? parseInt(s1[1], 10) : 0; + n2 = (s2.length > 1) ? parseInt(s2[1], 10) : 0; + if (n1 < n2) return false; + else return true; + } +} + +function getGithubLatestVersion(callback) { + versionLog('Downloading latest version id from github...'); + + $.ajax({ + url: 'https://api.github.com/repos/netdata/netdata/releases/latest', + async: true, + cache: false + }) + .done(function (data) { + data = data.tag_name.replace(/(\r\n|\n|\r| |\t)/gm, ""); + versionLog('Latest stable version from github is ' + data); + callback(data); + }) + .fail(function () { + versionLog('Failed to download the latest stable version id from github!'); + callback(null); + }); +} + +function getGCSLatestVersion(callback) { + versionLog('Downloading latest version id from GCS...'); + $.ajax({ + url: "https://www.googleapis.com/storage/v1/b/netdata-nightlies/o/latest-version.txt", + async: true, + cache: false + }) + .done(function (response) { + $.ajax({ + url: response.mediaLink, + async: true, + cache: false + }) + .done(function (data) { + data = data.replace(/(\r\n|\n|\r| |\t)/gm, ""); + versionLog('Latest nightly version from GCS is ' + data); + callback(data); + }) + .fail(function (xhr, textStatus, errorThrown) { + versionLog('Failed to download the latest nightly version id from GCS!'); + callback(null); + }); + }) + .fail(function (xhr, textStatus, errorThrown) { + versionLog('Failed to download the latest nightly version from GCS!'); + callback(null); + }); +} + + +function checkForUpdateByVersion(force, callback) { + if (options.release_channel === 'stable') { + getGithubLatestVersion(function (sha2) { + callback(options.version, sha2); + }); + } else { + getGCSLatestVersion(function (sha2) { + callback(options.version, sha2); + }); + } + return null; +} + +function notifyForUpdate(force) { + versionLog('

    checking for updates...

    '); + + var now = Date.now(); + + 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; + } + } + + checkForUpdateByVersion(force, function (sha1, sha2) { + var save = false; + + if (sha1 === null) { + save = false; + versionLog('

    Failed to get your netdata version!

    You can always get the latest netdata from its github page.

    '); + } else if (sha2 === null) { + save = false; + versionLog('

    Failed to get the latest netdata version.

    You can always get the latest netdata from its github page.

    '); + } else if (versionsMatch(sha1, sha2)) { + save = true; + versionLog('

    You already have the latest netdata!

    No update yet?
    We probably need some motivation to keep going on!

    If you haven\'t already, give netdata a at its github page.

    '); + } else { + save = true; + var compare = 'https://learn.netdata.cloud/docs/agent/changelog/'; + versionLog('

    New version of netdata available!

    Latest version: ' + sha2 + '

    Click here for the changes log and
    click here for directions on updating your netdata installation.

    We suggest to review the changes log for new features you may be interested, or important bug fixes you may need.
    Keeping your netdata updated is generally a good idea.

    '); + + document.getElementById('update_badge').innerHTML = '!'; + } + + if (save) { + saveLocalStorage('last_update_check', now.toString()); + } + }); +} + +// ---------------------------------------------------------------------------- +// printing dashboards + +function showPageFooter() { + document.getElementById('footer').style.display = 'block'; +} + +function printPreflight() { + var url = document.location.origin.toString() + document.location.pathname.toString() + document.location.search.toString() + urlOptions.genHash() + ';mode=print'; + var width = 990; + var height = screen.height * 90 / 100; + //console.log(url); + //console.log(document.location); + window.open(url, '', 'width=' + width.toString() + ',height=' + height.toString() + ',menubar=no,toolbar=no,personalbar=no,location=no,resizable=no,scrollbars=yes,status=no,chrome=yes,centerscreen=yes,attention=yes,dialog=yes'); + $('#printPreflightModal').modal('hide'); +} + +function printPage() { + var print_is_rendering = true; + + $('#printModal').on('hide.bs.modal', function (e) { + if (print_is_rendering === true) { + e.preventDefault(); + return false; + } + + return true; + }); + + $('#printModal').on('show.bs.modal', function () { + var print_options = { + stop_updates_when_focus_is_lost: false, + update_only_visible: false, + sync_selection: false, + eliminate_zero_dimensions: false, + pan_and_zoom_data_padding: false, + show_help: false, + legend_toolbox: false, + resize_charts: false, + pixels_per_point: 1 + }; + + var x; + for (x in print_options) { + if (print_options.hasOwnProperty(x)) { + NETDATA.options.current[x] = print_options[x]; + } + } + + NETDATA.parseDom(); + showPageFooter(); + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], urlOptions.after, urlOptions.before); + // NETDATA.onresize(); + + var el = document.getElementById('printModalProgressBar'); + var eltxt = document.getElementById('printModalProgressBarText'); + + function update_chart(idx) { + var state = NETDATA.options.targets[--idx]; + + var pcent = (NETDATA.options.targets.length - idx) * 100 / NETDATA.options.targets.length; + $(el).css('width', pcent + '%').attr('aria-valuenow', pcent); + eltxt.innerText = Math.round(pcent).toString() + '%, ' + state.id; + + setTimeout(function () { + state.updateChart(function () { + NETDATA.options.targets[idx].resizeForPrint(); + + if (idx > 0) { + update_chart(idx); + } else { + print_is_rendering = false; + $('#printModal').modal('hide'); + window.print(); + window.close(); + } + }) + }, 0); + } + + print_is_rendering = true; + update_chart(NETDATA.options.targets.length); + }); + + $('#printModal').modal('show'); +} + +// -------------------------------------------------------------------- + +function jsonStringifyFn(obj) { + return JSON.stringify(obj, function (key, value) { + return (typeof value === 'function') ? value.toString() : value; + }); +} + +function jsonParseFn(str) { + return JSON.parse(str, function (key, value) { + if (typeof value != 'string') { + return value; + } + return (value.substring(0, 8) == 'function') ? eval('(' + value + ')') : value; + }); +} + +// -------------------------------------------------------------------- + +var snapshotOptions = { + bytes_per_chart: 2048, + compressionDefault: 'pako.deflate.base64', + + compressions: { + 'none': { + bytes_per_point_memory: 5.2, + bytes_per_point_disk: 5.6, + + compress: function (s) { + return s; + }, + + compressed_length: function (s) { + return s.length; + }, + + uncompress: function (s) { + return s; + } + }, + + 'pako.deflate.base64': { + bytes_per_point_memory: 1.8, + bytes_per_point_disk: 1.9, + + compress: function (s) { + return btoa(pako.deflate(s, { to: 'string' })); + }, + + compressed_length: function (s) { + return s.length; + }, + + uncompress: function (s) { + return pako.inflate(atob(s), { to: 'string' }); + } + }, + + 'pako.deflate': { + bytes_per_point_memory: 1.4, + bytes_per_point_disk: 3.2, + + compress: function (s) { + return pako.deflate(s, { to: 'string' }); + }, + + compressed_length: function (s) { + return s.length; + }, + + uncompress: function (s) { + return pako.inflate(s, { to: 'string' }); + } + }, + + 'lzstring.utf16': { + bytes_per_point_memory: 1.7, + bytes_per_point_disk: 2.6, + + compress: function (s) { + return LZString.compressToUTF16(s); + }, + + compressed_length: function (s) { + return s.length * 2; + }, + + uncompress: function (s) { + return LZString.decompressFromUTF16(s); + } + }, + + 'lzstring.base64': { + bytes_per_point_memory: 2.1, + bytes_per_point_disk: 2.3, + + compress: function (s) { + return LZString.compressToBase64(s); + }, + + compressed_length: function (s) { + return s.length; + }, + + uncompress: function (s) { + return LZString.decompressFromBase64(s); + } + }, + + 'lzstring.uri': { + bytes_per_point_memory: 2.1, + bytes_per_point_disk: 2.3, + + compress: function (s) { + return LZString.compressToEncodedURIComponent(s); + }, + + compressed_length: function (s) { + return s.length; + }, + + uncompress: function (s) { + return LZString.decompressFromEncodedURIComponent(s); + } + } + } +}; + +// -------------------------------------------------------------------- +// loading snapshots + +function loadSnapshotModalLog(priority, msg) { + document.getElementById('loadSnapshotStatus').className = "alert alert-" + priority; + document.getElementById('loadSnapshotStatus').innerHTML = msg; +} + +var tmpSnapshotData = null; + +function loadSnapshot() { + $('#loadSnapshotImport').addClass('disabled'); + + if (tmpSnapshotData === null) { + loadSnapshotPreflightEmpty(); + loadSnapshotModalLog('danger', 'no data have been loaded'); + return; + } + + loadPako(function () { + loadLzString(function () { + loadSnapshotModalLog('info', 'Please wait, activating snapshot...'); + $('#loadSnapshotModal').modal('hide'); + + netdataShowAlarms = false; + netdataRegistry = false; + netdataServer = tmpSnapshotData.server; + NETDATA.serverDefault = netdataServer; + + document.getElementById('charts_div').innerHTML = ''; + document.getElementById('sidebar').innerHTML = ''; + NETDATA.globalReset(); + + if (typeof tmpSnapshotData.hash !== 'undefined') { + urlOptions.hash = tmpSnapshotData.hash; + } else { + urlOptions.hash = '#'; + } + + if (typeof tmpSnapshotData.info !== 'undefined') { + var info = jsonParseFn(tmpSnapshotData.info); + if (typeof info.menu !== 'undefined') { + netdataDashboard.menu = info.menu; + } + + if (typeof info.submenu !== 'undefined') { + netdataDashboard.submenu = info.submenu; + } + + if (typeof info.context !== 'undefined') { + netdataDashboard.context = info.context; + } + } + + if (typeof tmpSnapshotData.compression !== 'string') { + tmpSnapshotData.compression = 'none'; + } + + if (typeof snapshotOptions.compressions[tmpSnapshotData.compression] === 'undefined') { + alert('unknown compression method: ' + tmpSnapshotData.compression); + tmpSnapshotData.compression = 'none'; + } + + tmpSnapshotData.uncompress = snapshotOptions.compressions[tmpSnapshotData.compression].uncompress; + netdataSnapshotData = tmpSnapshotData; + + urlOptions.after = tmpSnapshotData.after_ms; + urlOptions.before = tmpSnapshotData.before_ms; + + if (typeof tmpSnapshotData.highlight_after_ms !== 'undefined' + && tmpSnapshotData.highlight_after_ms !== null + && tmpSnapshotData.highlight_after_ms > 0 + && typeof tmpSnapshotData.highlight_before_ms !== 'undefined' + && tmpSnapshotData.highlight_before_ms !== null + && tmpSnapshotData.highlight_before_ms > 0 + ) { + urlOptions.highlight_after = tmpSnapshotData.highlight_after_ms; + urlOptions.highlight_before = tmpSnapshotData.highlight_before_ms; + urlOptions.highlight = true; + } else { + urlOptions.highlight_after = 0; + urlOptions.highlight_before = 0; + urlOptions.highlight = false; + } + + netdataCheckXSS = false; // disable the modal - this does not affect XSS checks, since dashboard.js is already loaded + NETDATA.xss.enabled = true; // we should not do any remote requests, but if we do, check them + NETDATA.xss.enabled_for_data = true; // check also snapshot data - that have been excluded from the initial check, due to compression + loadSnapshotPreflightEmpty(); + initializeDynamicDashboard(); + }); + }); +}; + +function loadSnapshotPreflightFile(file) { + var filename = NETDATA.xss.string(file.name); + var fr = new FileReader(); + fr.onload = function (e) { + document.getElementById('loadSnapshotFilename').innerHTML = filename; + var result = null; + try { + result = NETDATA.xss.checkAlways('snapshot', JSON.parse(e.target.result), /^(snapshot\.info|snapshot\.data)$/); + + //console.log(result); + var date_after = new Date(result.after_ms); + var date_before = new Date(result.before_ms); + + if (typeof result.charts_ok === 'undefined') { + result.charts_ok = 'unknown'; + } + + if (typeof result.charts_failed === 'undefined') { + result.charts_failed = 0; + } + + if (typeof result.compression === 'undefined') { + result.compression = 'none'; + } + + if (typeof result.data_size === 'undefined') { + result.data_size = 0; + } + + document.getElementById('loadSnapshotFilename').innerHTML = '' + filename + ''; + document.getElementById('loadSnapshotHostname').innerHTML = '' + result.hostname + ', netdata version: ' + result.netdata_version.toString() + ''; + document.getElementById('loadSnapshotURL').innerHTML = result.url; + document.getElementById('loadSnapshotCharts').innerHTML = result.charts.charts_count.toString() + ' charts, ' + result.charts.dimensions_count.toString() + ' dimensions, ' + result.data_points.toString() + ' points per dimension, ' + Math.round(result.duration_ms / result.data_points).toString() + ' ms per point'; + document.getElementById('loadSnapshotInfo').innerHTML = 'version: ' + result.snapshot_version.toString() + ', includes ' + result.charts_ok.toString() + ' unique chart data queries ' + ((result.charts_failed > 0) ? ('' + result.charts_failed.toString() + ' failed') : '').toString() + ', compressed with ' + result.compression.toString() + ', data size ' + (Math.round(result.data_size * 100 / 1024 / 1024) / 100).toString() + ' MB'; + document.getElementById('loadSnapshotTimeRange').innerHTML = '' + NETDATA.dateTime.localeDateString(date_after) + ' ' + NETDATA.dateTime.localeTimeString(date_after) + ' to ' + NETDATA.dateTime.localeDateString(date_before) + ' ' + NETDATA.dateTime.localeTimeString(date_before) + ''; + document.getElementById('loadSnapshotComments').innerHTML = ((result.comments) ? result.comments : '').toString(); + loadSnapshotModalLog('success', 'File loaded, click Import to render it!'); + $('#loadSnapshotImport').removeClass('disabled'); + + tmpSnapshotData = result; + } + catch (e) { + console.log(e); + document.getElementById('loadSnapshotStatus').className = "alert alert-danger"; + document.getElementById('loadSnapshotStatus').innerHTML = "Failed to parse this file!"; + $('#loadSnapshotImport').addClass('disabled'); + } + } + + //console.log(file); + fr.readAsText(file); +}; + +function loadSnapshotPreflightEmpty() { + document.getElementById('loadSnapshotFilename').innerHTML = ''; + document.getElementById('loadSnapshotHostname').innerHTML = ''; + document.getElementById('loadSnapshotURL').innerHTML = ''; + document.getElementById('loadSnapshotCharts').innerHTML = ''; + document.getElementById('loadSnapshotInfo').innerHTML = ''; + document.getElementById('loadSnapshotTimeRange').innerHTML = ''; + document.getElementById('loadSnapshotComments').innerHTML = ''; + loadSnapshotModalLog('success', 'Browse for a snapshot file (or drag it and drop it here), then click Import to render it.'); + $('#loadSnapshotImport').addClass('disabled'); +}; + +var loadSnapshotDragAndDropInitialized = false; + +function loadSnapshotDragAndDropSetup() { + if (loadSnapshotDragAndDropInitialized === false) { + loadSnapshotDragAndDropInitialized = true; + $('#loadSnapshotDragAndDrop') + .on('drag dragstart dragend dragover dragenter dragleave drop', function (e) { + e.preventDefault(); + e.stopPropagation(); + }) + .on('drop', function (e) { + if (e.originalEvent.dataTransfer.files.length) { + loadSnapshotPreflightFile(e.originalEvent.dataTransfer.files.item(0)); + } else { + loadSnapshotPreflightEmpty(); + loadSnapshotModalLog('danger', 'No file selected'); + } + }); + } +}; + +function loadSnapshotPreflight() { + var files = document.getElementById('loadSnapshotSelectFiles').files; + if (files.length <= 0) { + loadSnapshotPreflightEmpty(); + loadSnapshotModalLog('danger', 'No file selected'); + return; + } + + loadSnapshotModalLog('info', 'Loading file...'); + + loadSnapshotPreflightFile(files.item(0)); +} + +// -------------------------------------------------------------------- +// saving snapshots + +var saveSnapshotStop = false; + +function saveSnapshotCancel() { + saveSnapshotStop = true; +} + +var saveSnapshotModalInitialized = false; + +function saveSnapshotModalSetup() { + if (saveSnapshotModalInitialized === false) { + saveSnapshotModalInitialized = true; + $('#saveSnapshotModal') + .on('hide.bs.modal', saveSnapshotCancel) + .on('show.bs.modal', saveSnapshotModalInit) + .on('shown.bs.modal', function () { + $('#saveSnapshotResolutionSlider').find(".slider-handle:first").attr("tabindex", 1); + document.getElementById('saveSnapshotComments').focus(); + }); + } +}; + +function saveSnapshotModalLog(priority, msg) { + document.getElementById('saveSnapshotStatus').className = "alert alert-" + priority; + document.getElementById('saveSnapshotStatus').innerHTML = msg; +} + +function saveSnapshotModalShowExpectedSize() { + var points = Math.round(saveSnapshotViewDuration / saveSnapshotSelectedSecondsPerPoint); + var priority = 'info'; + var msg = 'A moderate snapshot.'; + + var sizemb = Math.round( + (options.data.charts_count * snapshotOptions.bytes_per_chart + + options.data.dimensions_count * points * snapshotOptions.compressions[saveSnapshotCompression].bytes_per_point_disk) + * 10 / 1024 / 1024) / 10; + + var memmb = Math.round( + (options.data.charts_count * snapshotOptions.bytes_per_chart + + options.data.dimensions_count * points * snapshotOptions.compressions[saveSnapshotCompression].bytes_per_point_memory) + * 10 / 1024 / 1024) / 10; + + if (sizemb < 10) { + priority = 'success'; + msg = 'A nice small snapshot!'; + } + if (sizemb > 50) { + priority = 'warning'; + msg = 'Will stress your browser...'; + } + if (sizemb > 100) { + priority = 'danger'; + msg = 'Hm... good luck...'; + } + + saveSnapshotModalLog(priority, 'The snapshot will have ' + points.toString() + ' points per dimension. Expected size on disk ' + sizemb + ' MB, at browser memory ' + memmb + ' MB.
    ' + msg); +} + +var saveSnapshotCompression = snapshotOptions.compressionDefault; + +function saveSnapshotSetCompression(name) { + saveSnapshotCompression = name; + document.getElementById('saveSnapshotCompressionName').innerHTML = saveSnapshotCompression; + saveSnapshotModalShowExpectedSize(); +} + +var saveSnapshotSlider = null; +var saveSnapshotSelectedSecondsPerPoint = 1; +var saveSnapshotViewDuration = 1; + +function saveSnapshotModalInit() { + $('#saveSnapshotModalProgressSection').hide(); + $('#saveSnapshotResolutionRadio').show(); + saveSnapshotModalLog('info', 'Select resolution and click Save'); + $('#saveSnapshotExport').removeClass('disabled'); + + loadBootstrapSlider(function () { + saveSnapshotViewDuration = options.duration; + var start_ms = Math.round(Date.now() - saveSnapshotViewDuration * 1000); + + if (NETDATA.globalPanAndZoom.isActive() === true) { + saveSnapshotViewDuration = Math.round((NETDATA.globalPanAndZoom.force_before_ms - NETDATA.globalPanAndZoom.force_after_ms) / 1000); + start_ms = NETDATA.globalPanAndZoom.force_after_ms; + } + + var start_date = new Date(start_ms); + var yyyymmddhhssmm = start_date.getFullYear() + NETDATA.zeropad(start_date.getMonth() + 1) + NETDATA.zeropad(start_date.getDate()) + '-' + NETDATA.zeropad(start_date.getHours()) + NETDATA.zeropad(start_date.getMinutes()) + NETDATA.zeropad(start_date.getSeconds()); + + document.getElementById('saveSnapshotFilename').value = 'netdata-' + options.hostname.toString() + '-' + yyyymmddhhssmm.toString() + '-' + saveSnapshotViewDuration.toString() + '.snapshot'; + saveSnapshotSetCompression(saveSnapshotCompression); + + var min = options.update_every; + var max = Math.round(saveSnapshotViewDuration / 100); + + if (NETDATA.globalPanAndZoom.isActive() === false) { + max = Math.round(saveSnapshotViewDuration / 50); + } + + var view = Math.round(saveSnapshotViewDuration / Math.round($(document.getElementById('charts_div')).width() / 2)); + + // console.log('view duration: ' + saveSnapshotViewDuration + ', min: ' + min + ', max: ' + max + ', view: ' + view); + + if (max < 10) { + max = 10; + } + if (max < min) { + max = min; + } + if (view < min) { + view = min; + } + if (view > max) { + view = max; + } + + if (saveSnapshotSlider !== null) { + saveSnapshotSlider.destroy(); + } + + saveSnapshotSlider = new Slider('#saveSnapshotResolutionSlider', { + ticks: [min, view, max], + min: min, + max: max, + step: options.update_every, + value: view, + scale: (max > 100) ? 'logarithmic' : 'linear', + tooltip: 'always', + formatter: function (value) { + if (value < 1) { + value = 1; + } + + if (value < options.data.update_every) { + value = options.data.update_every; + } + + saveSnapshotSelectedSecondsPerPoint = value; + saveSnapshotModalShowExpectedSize(); + + var seconds = ' seconds '; + if (value === 1) { + seconds = ' second '; + } + + return value + seconds + 'per point' + ((value === options.data.update_every) ? ', server default' : '').toString(); + } + }); + }); +} + +function saveSnapshot() { + loadPako(function () { + loadLzString(function () { + saveSnapshotStop = false; + $('#saveSnapshotModalProgressSection').show(); + $('#saveSnapshotResolutionRadio').hide(); + $('#saveSnapshotExport').addClass('disabled'); + + var filename = document.getElementById('saveSnapshotFilename').value; + // console.log(filename); + saveSnapshotModalLog('info', 'Generating snapshot as ' + filename.toString() + ''); + + var save_options = { + stop_updates_when_focus_is_lost: false, + update_only_visible: false, + sync_selection: false, + eliminate_zero_dimensions: true, + pan_and_zoom_data_padding: false, + show_help: false, + legend_toolbox: false, + resize_charts: false, + pixels_per_point: 1 + }; + var backedup_options = {}; + + var x; + for (x in save_options) { + if (save_options.hasOwnProperty(x)) { + backedup_options[x] = NETDATA.options.current[x]; + NETDATA.options.current[x] = save_options[x]; + } + } + + var el = document.getElementById('saveSnapshotModalProgressBar'); + var eltxt = document.getElementById('saveSnapshotModalProgressBarText'); + + options.data.charts_by_name = null; + + var saveData = { + hostname: options.hostname, + server: NETDATA.serverDefault, + netdata_version: options.data.version, + snapshot_version: 1, + after_ms: Date.now() - options.duration * 1000, + before_ms: Date.now(), + highlight_after_ms: urlOptions.highlight_after, + highlight_before_ms: urlOptions.highlight_before, + duration_ms: options.duration * 1000, + update_every_ms: options.update_every * 1000, + data_points: 0, + url: ((urlOptions.server !== null) ? urlOptions.server : document.location.origin.toString() + document.location.pathname.toString() + document.location.search.toString()).toString(), + comments: document.getElementById('saveSnapshotComments').value.toString(), + hash: urlOptions.hash, + charts: options.data, + info: jsonStringifyFn({ + menu: netdataDashboard.menu, + submenu: netdataDashboard.submenu, + context: netdataDashboard.context + }), + charts_ok: 0, + charts_failed: 0, + compression: saveSnapshotCompression, + data_size: 0, + data: {} + }; + + if (typeof snapshotOptions.compressions[saveData.compression] === 'undefined') { + alert('unknown compression method: ' + saveData.compression); + saveData.compression = 'none'; + } + + var compress = snapshotOptions.compressions[saveData.compression].compress; + var compressed_length = snapshotOptions.compressions[saveData.compression].compressed_length; + + function pack_api1_v1_chart_data(state) { + if (state.library_name === null || state.data === null) { + return; + } + + var data = state.data; + state.data = null; + data.state = null; + var str = JSON.stringify(data); + + if (typeof str === 'string') { + var cstr = compress(str); + saveData.data[state.chartDataUniqueID()] = cstr; + return compressed_length(cstr); + } else { + return 0; + } + } + + var clearPanAndZoom = false; + if (NETDATA.globalPanAndZoom.isActive() === false) { + NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], saveData.after_ms, saveData.before_ms); + clearPanAndZoom = true; + } + + saveData.after_ms = NETDATA.globalPanAndZoom.force_after_ms; + saveData.before_ms = NETDATA.globalPanAndZoom.force_before_ms; + saveData.duration_ms = saveData.before_ms - saveData.after_ms; + saveData.data_points = Math.round((saveData.before_ms - saveData.after_ms) / (saveSnapshotSelectedSecondsPerPoint * 1000)); + saveSnapshotModalLog('info', 'Generating snapshot with ' + saveData.data_points.toString() + ' data points per dimension...'); + + var charts_count = 0; + var charts_ok = 0; + var charts_failed = 0; + + function saveSnapshotRestore() { + $('#saveSnapshotModal').modal('hide'); + + // restore the options + var x; + for (x in backedup_options) { + if (backedup_options.hasOwnProperty(x)) { + NETDATA.options.current[x] = backedup_options[x]; + } + } + + $(el).css('width', '0%').attr('aria-valuenow', 0); + eltxt.innerText = '0%'; + + if (clearPanAndZoom) { + NETDATA.globalPanAndZoom.clearMaster(); + } + + NETDATA.options.force_data_points = 0; + NETDATA.options.fake_chart_rendering = false; + NETDATA.onscroll_updater_enabled = true; + NETDATA.onresize(); + NETDATA.unpause(); + + $('#saveSnapshotExport').removeClass('disabled'); + } + + NETDATA.globalSelectionSync.stop(); + NETDATA.options.force_data_points = saveData.data_points; + NETDATA.options.fake_chart_rendering = true; + NETDATA.onscroll_updater_enabled = false; + NETDATA.abortAllRefreshes(); + + var size = 0; + var info = ' Resolution: ' + saveSnapshotSelectedSecondsPerPoint.toString() + ((saveSnapshotSelectedSecondsPerPoint === 1) ? ' second ' : ' seconds ').toString() + 'per point.'; + + function update_chart(idx) { + if (saveSnapshotStop === true) { + saveSnapshotModalLog('info', 'Cancelled!'); + saveSnapshotRestore(); + return; + } + + var state = NETDATA.options.targets[--idx]; + + var pcent = (NETDATA.options.targets.length - idx) * 100 / NETDATA.options.targets.length; + $(el).css('width', pcent + '%').attr('aria-valuenow', pcent); + eltxt.innerText = Math.round(pcent).toString() + '%, ' + state.id; + + setTimeout(function () { + charts_count++; + state.isVisible(true); + state.current.force_after_ms = saveData.after_ms; + state.current.force_before_ms = saveData.before_ms; + + state.updateChart(function (status, reason) { + state.current.force_after_ms = null; + state.current.force_before_ms = null; + + if (status === true) { + charts_ok++; + // state.log('ok'); + size += pack_api1_v1_chart_data(state); + } else { + charts_failed++; + state.log('failed to be updated: ' + reason); + } + + saveSnapshotModalLog((charts_failed) ? 'danger' : 'info', 'Generated snapshot data size ' + (Math.round(size * 100 / 1024 / 1024) / 100).toString() + ' MB. ' + ((charts_failed) ? (charts_failed.toString() + ' charts have failed to be downloaded') : '').toString() + info); + + if (idx > 0) { + update_chart(idx); + } else { + saveData.charts_ok = charts_ok; + saveData.charts_failed = charts_failed; + saveData.data_size = size; + // console.log(saveData.compression + ': ' + (size / (options.data.dimensions_count * Math.round(saveSnapshotViewDuration / saveSnapshotSelectedSecondsPerPoint))).toString()); + + // save it + // console.log(saveData); + saveObjectToClient(saveData, filename); + + if (charts_failed > 0) { + alert(charts_failed.toString() + ' failed to be downloaded'); + } + + saveSnapshotRestore(); + saveData = null; + } + }) + }, 0); + } + + update_chart(NETDATA.options.targets.length); + }); + }); +} + +// -------------------------------------------------------------------- +// activate netdata on the page + +function dashboardSettingsSetup() { + 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'); + }; + var units_sync_option = function (option) { + var self = $('#' + option); + + if (self.prop('checked') !== (NETDATA.getOption('units') === 'auto')) { + self.bootstrapToggle(NETDATA.getOption('units') === 'auto' ? 'on' : 'off'); + } + + if (self.prop('checked') === true) { + $('#settingsLocaleTempRow').show(); + $('#settingsLocaleTimeRow').show(); + } else { + $('#settingsLocaleTempRow').hide(); + $('#settingsLocaleTimeRow').hide(); + } + }; + var temp_sync_option = function (option) { + var self = $('#' + option); + + if (self.prop('checked') !== (NETDATA.getOption('temperature') === 'celsius')) { + self.bootstrapToggle(NETDATA.getOption('temperature') === 'celsius' ? 'on' : 'off'); + } + }; + var timezone_sync_option = function (option) { + var self = $('#' + option); + + document.getElementById('browser_timezone').innerText = NETDATA.options.browser_timezone; + document.getElementById('server_timezone').innerText = NETDATA.options.server_timezone; + document.getElementById('current_timezone').innerText = (NETDATA.options.current.timezone === 'default') ? 'unset, using browser default' : NETDATA.options.current.timezone; + + if (self.prop('checked') === NETDATA.dateTime.using_timezone) { + self.bootstrapToggle(NETDATA.dateTime.using_timezone ? 'off' : 'on'); + } + }; + + sync_option('eliminate_zero_dimensions'); + sync_option('destroy_on_hide'); + sync_option('async_on_scroll'); + 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'); + sync_option('seconds_as_time'); + theme_sync_option('netdata_theme_control'); + units_sync_option('units_conversion'); + temp_sync_option('units_temp'); + timezone_sync_option('local_timezone'); + + 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')); + }); + $('#async_on_scroll').change(function () { + NETDATA.setOption('async_on_scroll', $(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 () { + urlOptions.update_always = !$(this).prop('checked'); + urlOptions.hashUpdate(); + + NETDATA.setOption('stop_updates_when_focus_is_lost', !urlOptions.update_always); + }); + $('#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')); + }); + $('#seconds_as_time').change(function () { + NETDATA.setOption('seconds_as_time', $(this).prop('checked')); + }); + $('#local_timezone').change(function () { + if ($(this).prop('checked')) { + selected_server_timezone('default', true); + } else { + selected_server_timezone('default', false); + } + }); + + $('#units_conversion').change(function () { + NETDATA.setOption('units', $(this).prop('checked') ? 'auto' : 'original'); + }); + $('#units_temp').change(function () { + NETDATA.setOption('temperature', $(this).prop('checked') ? 'celsius' : 'fahrenheit'); + }); + + $('#show_help').change(function () { + urlOptions.help = $(this).prop('checked'); + urlOptions.hashUpdate(); + + 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'; + urlOptions.hashUpdate(); + + if (setTheme(urlOptions.theme)) { + netdataReload(); + } + }); +} + +function scrollDashboardTo() { + if (netdataSnapshotData !== null && typeof netdataSnapshotData.hash !== 'undefined') { + //console.log(netdataSnapshotData.hash); + scrollToId(netdataSnapshotData.hash.replace('#', '')); + } else { + // check if we have to jump to a specific section + scrollToId(urlOptions.hash.replace('#', '')); + + if (urlOptions.chart !== null) { + NETDATA.alarms.scrollToChart(urlOptions.chart); + //urlOptions.hash = '#' + NETDATA.name2id('menu_' + charts[c].menu + '_submenu_' + charts[c].submenu); + //urlOptions.hash = '#chart_' + NETDATA.name2id(urlOptions.chart); + //console.log('hash = ' + urlOptions.hash); + } + } +} + +var modalHiddenCallback = null; + +function scrollToChartAfterHidingModal(chart, alarmDate, alarmStatus) { + modalHiddenCallback = function () { + NETDATA.alarms.scrollToChart(chart, alarmDate); + + if (['WARNING', 'CRITICAL'].includes(alarmStatus)) { + const currentChartState = NETDATA.options.targets.find( + (chartState) => chartState.id === chart, + ) + const twoMinutes = 2 * 60 * 1000 + NETDATA.globalPanAndZoom.setMaster( + currentChartState, + alarmDate - twoMinutes, + alarmDate + twoMinutes, + ) + } + }; +} + +// ---------------------------------------------------------------------------- + +function enableTooltipsAndPopovers() { + $('[data-toggle="tooltip"]').tooltip({ + animated: 'fade', + trigger: 'hover', + html: true, + delay: { show: 500, hide: 0 }, + container: 'body' + }); + $('[data-toggle="popover"]').popover(); +} + +// ---------------------------------------------------------------------------- + +var runOnceOnDashboardLastRun = 0; + +function runOnceOnDashboardWithjQuery() { + if (runOnceOnDashboardLastRun !== 0) { + scrollDashboardTo(); + + // restore the scrollspy at the proper position + $(document.body).scrollspy('refresh'); + $(document.body).scrollspy('process'); + + return; + } + + runOnceOnDashboardLastRun = Date.now(); + + // ------------------------------------------------------------------------ + // bootstrap modals + + // prevent bootstrap modals from scrolling the page + // maintains the current scroll position + // https://stackoverflow.com/a/34754029/4525767 + + var scrollPos = 0; + var modal_depth = 0; // how many modals are currently open + var modal_shown = false; // set to true, if a modal is shown + var netdata_paused_on_modal = false; // set to true, if the modal paused netdata + var scrollspyOffset = $(window).height() / 3; // will be updated below - the offset of scrollspy to select an item + + $('.modal') + .on('show.bs.modal', function () { + if (modal_depth === 0) { + scrollPos = window.scrollY; + + $('body').css({ + overflow: 'hidden', + position: 'fixed', + top: -scrollPos + }); + + modal_shown = true; + + if (NETDATA.options.pauseCallback === null) { + NETDATA.pause(function () { + }); + netdata_paused_on_modal = true; + } else { + netdata_paused_on_modal = false; + } + } + + modal_depth++; + //console.log(urlOptions.after); + + }) + .on('hide.bs.modal', function () { + + modal_depth--; + + if (modal_depth <= 0) { + modal_depth = 0; + + $('body') + .css({ + overflow: '', + position: '', + top: '' + }); + + // scroll to the position we had open before the modal + $('html, body') + .animate({ scrollTop: scrollPos }, 0); + + // unpause netdata, if we paused it + if (netdata_paused_on_modal === true) { + NETDATA.unpause(); + netdata_paused_on_modal = false; + } + + // restore the scrollspy at the proper position + $(document.body).scrollspy('process'); + } + //console.log(urlOptions.after); + }) + .on('hidden.bs.modal', function () { + if (modal_depth === 0) { + modal_shown = false; + } + + if (typeof modalHiddenCallback === 'function') { + modalHiddenCallback(); + } + + modalHiddenCallback = null; + //console.log(urlOptions.after); + }); + + // ------------------------------------------------------------------------ + // sidebar / affix + + if (shouldShowSignInBanner()) { + const el = document.getElementById("sign-in-banner"); + if (el) { + el.style.display = "initial"; + el.classList.add(`theme-${netdataTheme}`); + } + } + + $('#sidebar') + .affix({ + offset: { + top: (isdemo()) ? 150 : 0, + bottom: 0 + } + }) + .on('affixed.bs.affix', function () { + // fix scrolling of very long affix lists + // http://stackoverflow.com/questions/21691585/bootstrap-3-1-0-affix-too-long + + $(this).removeAttr('style'); + }) + .on('affix-top.bs.affix', function () { + // fix bootstrap affix click bug + // https://stackoverflow.com/a/37847981/4525767 + + if (modal_shown) { + return false; + } + }) + .on('activate.bs.scrollspy', function (e) { + // change the URL based on the current position of the screen + + if (modal_shown === false) { + var el = $(e.target); + var hash = el.find('a').attr('href'); + if (typeof hash === 'string' && hash.substring(0, 1) === '#' && urlOptions.hash.startsWith(hash + '_submenu_') === false) { + urlOptions.hash = hash; + urlOptions.hashUpdate(); + } + } + }); + + Ps.initialize(document.getElementById('sidebar'), { + wheelSpeed: 0.5, + wheelPropagation: true, + swipePropagation: true, + minScrollbarLength: null, + maxScrollbarLength: null, + useBothWheelAxes: false, + suppressScrollX: true, + suppressScrollY: false, + scrollXMarginOffset: 0, + scrollYMarginOffset: 0, + theme: 'default' + }); + + // ------------------------------------------------------------------------ + // scrollspy + + if (scrollspyOffset > 250) { + scrollspyOffset = 250; + } + if (scrollspyOffset < 75) { + scrollspyOffset = 75; + } + document.body.setAttribute('data-offset', scrollspyOffset); + + // scroll the dashboard, before activating the scrollspy, so that our + // hash will not be updated before we got the chance to scroll to it + scrollDashboardTo(); + + $(document.body).scrollspy({ + target: '#sidebar', + offset: scrollspyOffset // controls the diff of the element to the top, to select it + }); + + // ------------------------------------------------------------------------ + // my-netdata menu + + Ps.initialize(document.getElementById('my-netdata-dropdown-content'), { + wheelSpeed: 1, + wheelPropagation: false, + swipePropagation: false, + minScrollbarLength: null, + maxScrollbarLength: null, + useBothWheelAxes: false, + suppressScrollX: true, + suppressScrollY: false, + scrollXMarginOffset: 0, + scrollYMarginOffset: 0, + theme: 'default' + }); + + $('#myNetdataDropdownParent') + .on('show.bs.dropdown', function () { + var hash = urlOptions.genHash(); + $('.registry_link').each(function (idx) { + this.setAttribute('href', this.getAttribute("href").replace(/#.*$/, hash)); + }); + + NETDATA.pause(function () { + }); + }) + .on('shown.bs.dropdown', function () { + Ps.update(document.getElementById('my-netdata-dropdown-content')); + myNetdataMenuDidShow(); + }) + .on('hidden.bs.dropdown', function () { + NETDATA.unpause(); + }); + + $('#deleteRegistryModal') + .on('hidden.bs.modal', function () { + deleteRegistryGuid = null; + }); + + // ------------------------------------------------------------------------ + // update modal + + $('#updateModal') + .on('show.bs.modal', function () { + versionLog('checking, please wait...'); + }) + .on('shown.bs.modal', function () { + notifyForUpdate(true); + }); + + // ------------------------------------------------------------------------ + // alarms modal + + $('#alarmsModal') + .on('shown.bs.modal', function () { + alarmsUpdateModal(); + }) + .on('hidden.bs.modal', function () { + document.getElementById('alarms_active').innerHTML = + document.getElementById('alarms_all').innerHTML = + document.getElementById('alarms_log').innerHTML = + 'loading...'; + }); + + // ------------------------------------------------------------------------ + + dashboardSettingsSetup(); + loadSnapshotDragAndDropSetup(); + saveSnapshotModalSetup(); + showPageFooter(); + + // ------------------------------------------------------------------------ + // 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: ' show more information', + lessText: ' 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
    + 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); + } else { + // Add tag name chars to the result + 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 (var j = 0; j < openTags.length; j++) { + //console.log('Cierro tag ' + openTags[j]); + bag += ''; // 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 = $('
    ').html(bag + '' + config.ellipsesText + '').html(); + } else { + c += config.ellipsesText; + } + + var html = '
    ' + c + + '
    ' + content + + '
    ' + config.moreText + ''; + + $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 + } + }); + }; +} + +function finalizePage() { + // resize all charts - without starting the background thread + // this has to be done while NETDATA is paused + // if we omit this, the affix menu will be wrong, since all + // the Dom elements are initially zero-sized + NETDATA.parseDom(); + + // ------------------------------------------------------------------------ + + NETDATA.globalPanAndZoom.callback = null; + NETDATA.globalChartUnderlay.callback = null; + + if (urlOptions.pan_and_zoom === true && NETDATA.options.targets.length > 0) { + NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], urlOptions.after, urlOptions.before); + } + + // callback for us to track PanAndZoom operations + NETDATA.globalPanAndZoom.callback = urlOptions.netdataPanAndZoomCallback; + NETDATA.globalChartUnderlay.callback = urlOptions.netdataHighlightCallback; + + // ------------------------------------------------------------------------ + + // let it run (update the charts) + NETDATA.unpause(); + + runOnceOnDashboardWithjQuery(); + $(".shorten").shorten(); + enableTooltipsAndPopovers(); + + if (isdemo()) { + // do not to give errors on netdata demo servers for 60 seconds + NETDATA.options.current.retries_on_data_failures = 60; + + // 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', '/demosite/' + window.location.host); + }, 2000); + } else { + notifyForUpdate(); + } + + if (urlOptions.show_alarms === true) { + setTimeout(function () { + $('#alarmsModal').modal('show'); + }, 1000); + } + + NETDATA.onresizeCallback = function () { + Ps.update(document.getElementById('sidebar')); + Ps.update(document.getElementById('my-netdata-dropdown-content')); + }; + NETDATA.onresizeCallback(); + + if (netdataSnapshotData !== null) { + NETDATA.globalPanAndZoom.setMaster(NETDATA.options.targets[0], netdataSnapshotData.after_ms, netdataSnapshotData.before_ms); + } + + //if (urlOptions.nowelcome !== true) { + // setTimeout(function () { + // $('#welcomeModal').modal(); + // }, 2000); + //} + + // var netdataEnded = performance.now(); + // console.log('start up time: ' + (netdataEnded - netdataStarted).toString() + ' ms'); +} + +function resetDashboardOptions() { + var help = NETDATA.options.current.show_help; + + NETDATA.resetOptions(); + if (setTheme('slate')) { + netdataReload(); + } + + if (help !== NETDATA.options.current.show_help) { + netdataReload(); + } +} + +// callback to add the dashboard info to the +// parallel javascript downloader in netdata +var netdataPrepCallback = function () { + NETDATA.requiredCSS.push({ + url: NETDATA.serverStatic + 'css/bootstrap-toggle-2.2.2.min.css', + isAlreadyLoaded: function () { + return false; + } + }); + + NETDATA.requiredJs.push({ + url: NETDATA.serverStatic + 'lib/bootstrap-toggle-2.2.2.min.js', + isAlreadyLoaded: function () { + return false; + } + }); + + NETDATA.requiredJs.push({ + url: NETDATA.serverStatic + 'dashboard_info.js?v20181019-1', + async: false, + isAlreadyLoaded: function () { + return false; + } + }); + + if (isdemo()) { + document.getElementById('masthead').style.display = 'block'; + } else { + if (urlOptions.update_always === true) { + NETDATA.setOption('stop_updates_when_focus_is_lost', !urlOptions.update_always); + } + } +}; + +var selected_server_timezone = function (timezone, status) { + //console.log('called with timezone: ' + timezone + ", status: " + ((typeof status === 'undefined')?'undefined':status).toString()); + + // clear the error + document.getElementById('timezone_error_message').innerHTML = ''; + + if (typeof status === 'undefined') { + // the user selected a timezone from the menu + + NETDATA.setOption('user_set_server_timezone', timezone); + + if (NETDATA.dateTime.init(timezone) === false) { + NETDATA.dateTime.init(); + + if (!$('#local_timezone').prop('checked')) { + $('#local_timezone').bootstrapToggle('on'); + } + + document.getElementById('timezone_error_message').innerHTML = 'Ooops! That timezone was not accepted by your browser. Please open a github issue to help us fix it.'; + NETDATA.setOption('user_set_server_timezone', NETDATA.options.server_timezone); + } else { + if ($('#local_timezone').prop('checked')) { + $('#local_timezone').bootstrapToggle('off'); + } + } + } else if (status === true) { + // the user wants the browser default timezone to be activated + + NETDATA.dateTime.init(); + } else { + // the user wants the server default timezone to be activated + //console.log('found ' + NETDATA.options.current.user_set_server_timezone); + + if (NETDATA.options.current.user_set_server_timezone === 'default') { + NETDATA.options.current.user_set_server_timezone = NETDATA.options.server_timezone; + } + + timezone = NETDATA.options.current.user_set_server_timezone; + + if (NETDATA.dateTime.init(timezone) === false) { + NETDATA.dateTime.init(); + + if (!$('#local_timezone').prop('checked')) { + $('#local_timezone').bootstrapToggle('on'); + } + + document.getElementById('timezone_error_message').innerHTML = 'Sorry. The timezone "' + timezone.toString() + '" is not accepted by your browser. Please select one from the list.'; + NETDATA.setOption('user_set_server_timezone', NETDATA.options.server_timezone); + } + } + + document.getElementById('current_timezone').innerText = (NETDATA.options.current.timezone === 'default') ? 'unset, using browser default' : NETDATA.options.current.timezone; + return false; +}; + +// our entry point +// var netdataStarted = performance.now(); + +var netdataCallback = initializeDynamicDashboard; + +// ================================================================================================= +// netdata.cloud + +let registryAgents = []; + +let cloudAgents = []; + +let myNetdataMenuFilterValue = ""; + +let cloudAccountID = null; + +let cloudAccountName = null; + +let cloudToken = null; + +/// Enforces a maximum string length while retaining the prefix and the postfix of +/// the string. +function truncateString(str, maxLength) { + if (str.length <= maxLength) { + return str; + } + + const spanLength = Math.floor((maxLength - 3) / 2); + return `${str.substring(0, spanLength)}...${str.substring(str.length - spanLength)}`; +} + +// ------------------------------------------------------------------------------------------------- +// netdata.cloud API Client +// ------------------------------------------------------------------------------------------------- + +function isValidAgent(a) { + return a.urls != null && a.urls.length > 0; +} + +// https://github.com/netdata/hub/issues/146 +function getCloudAccountAgents() { + if (!isSignedIn()) { + return []; + } + + return fetch( + `${NETDATA.registry.cloudBaseURL}/api/v1/accounts/${cloudAccountID}/agents`, + { + method: "GET", + mode: "cors", + headers: { + "Authorization": `Bearer ${cloudToken}` + } + } + ).then((response) => { + if (!response.ok) { + throw Error("Cannot fetch known accounts"); + } + return response.json(); + }).then((payload) => { + const agents = payload.result ? payload.result.agents : null; + + if (!agents) { + return []; + } + + return agents.filter((a) => isValidAgent(a)).map((a) => { + return { + "guid": a.id, + "name": a.name, + "url": a.urls[0], + "alternate_urls": a.urls + } + }) + }).catch(function (error) { + console.log(error); + return null; + }); +} + +/** Updates the lastAccessTime and accessCount properties of the agent for the account. */ +function touchAgent() { + if (!isSignedIn()) { + return []; + } + + const touchUrl = `${NETDATA.registry.cloudBaseURL}/api/v1/agents/${NETDATA.registry.machine_guid}/touch?account_id=${cloudAccountID}`; + return fetch( + touchUrl, + { + method: "post", + body: "", + mode: "cors", + headers: { + "Authorization": `Bearer ${cloudToken}` + } + } + ).then((response) => { + if (!response.ok) { + throw Error("Cannot touch agent" + JSON.stringify(response)); + } + return response.json(); + }).then((payload) => { + + }).catch(function (error) { + console.log(error); + return null; + }); +} + +// https://github.com/netdata/hub/issues/128 +function postCloudAccountAgents(agentsToSync) { + if (!isSignedIn()) { + return []; + } + + const maskedURL = NETDATA.registry.MASKED_DATA; + + const agents = agentsToSync.map((a) => { + const urls = a.alternate_urls.filter((url) => url != maskedURL); + + return { + "id": a.guid, + "name": a.name, + "urls": urls + } + }).filter((a) => isValidAgent(a)) + + const payload = { + "accountID": cloudAccountID, + "agents": agents, + "merge": false, + }; + + return fetch( + `${NETDATA.registry.cloudBaseURL}/api/v1/accounts/${cloudAccountID}/agents`, + { + method: "POST", + mode: "cors", + headers: { + "Content-Type": "application/json; charset=utf-8", + "Authorization": `Bearer ${cloudToken}` + }, + body: JSON.stringify(payload) + } + ).then((response) => { + return response.json(); + }).then((payload) => { + const agents = payload.result ? payload.result.agents : null; + + if (!agents) { + return []; + } + + return agents.filter((a) => isValidAgent(a)).map((a) => { + return { + "guid": a.id, + "name": a.name, + "url": a.urls[0], + "alternate_urls": a.urls + } + }) + }); +} + +function deleteCloudAgentURL(agentID, url) { + if (!isSignedIn()) { + return []; + } + + return fetch( + `${NETDATA.registry.cloudBaseURL}/api/v1/accounts/${cloudAccountID}/agents/${agentID}/url?value=${encodeURIComponent(url)}`, + { + method: "DELETE", + mode: "cors", + headers: { + "Content-Type": "application/json; charset=utf-8", + "Authorization": `Bearer ${cloudToken}` + }, + } + ).then((response) => { + return response.json(); + }).then((payload) => { + const count = payload.result ? payload.result.count : 0; + return count; + }); +} + +// ------------------------------------------------------------------------------------------------- + +function signInDidClick(e) { + e.preventDefault(); + e.stopPropagation(); + + if (!NETDATA.registry.isUsingGlobalRegistry()) { + // If user is using a private registry, request his consent for + // synchronizing with cloud. + showSignInModal(); + return; + } + + signIn(); +} + +function shouldShowSignInBanner() { + return false; +} + +function closeSignInBanner() { + localStorage.setItem("signInBannerClosed", "true"); + const el = document.getElementById("sign-in-banner"); + if (el) { + el.style.display = "none"; + } +} + +function closeSignInBannerDidClick(e) { + closeSignInBanner(); +} + +function signOutDidClick(e) { + e.preventDefault(); + e.stopPropagation(); + signOut(); +} + +// ------------------------------------------------------------------------------------------------- + +function updateMyNetdataAfterFilterChange() { + const machinesEl = document.getElementById("my-netdata-menu-machines") + machinesEl.innerHTML = renderMachines(cloudAgents); + + if (options.hosts.length > 1) { + const streamedEl = document.getElementById("my-netdata-menu-streamed") + streamedEl.innerHTML = renderStreamedHosts(options); + } +} + +function myNetdataMenuDidShow() { + const filterEl = document.getElementById("my-netdata-menu-filter-input"); + if (filterEl) { + filterEl.focus(); + } +} + +function myNetdataFilterDidChange(e) { + const inputEl = e.target; + setTimeout(() => { + myNetdataMenuFilterValue = inputEl.value; + updateMyNetdataAfterFilterChange(); + }, 1); +} + +function myNetdataFilterClearDidClick(e) { + e.preventDefault(); + e.stopPropagation(); + + const inputEl = document.getElementById("my-netdata-menu-filter-input"); + inputEl.value = ""; + myNetdataMenuFilterValue = ""; + + updateMyNetdataAfterFilterChange(); + + inputEl.focus(); +} + +// ------------------------------------------------------------------------------------------------- + +function clearCloudVariables() { + cloudAccountID = null; + cloudAccountName = null; + cloudToken = null; +} + +function clearCloudLocalStorageItems() { + localStorage.removeItem("cloud.baseURL"); + localStorage.removeItem("cloud.agentID"); + localStorage.removeItem("cloud.sync"); +} + +function signIn() { + const url = `${NETDATA.registry.cloudBaseURL}/account/sign-in-agent?id=${NETDATA.registry.machine_guid}&name=${encodeURIComponent(NETDATA.registry.hostname)}&origin=${encodeURIComponent(window.location.origin + "/")}`; + window.open(url); +} + +function signOut() { + cloudSSOSignOut(); +} + +function handleMessage(e) { + switch (e.data.type) { + case "sign-in": + handleSignInMessage(e); + break; + + case "sign-out": + handleSignOutMessage(e); + break; + + default: + return; + } +} + +function handleSignInMessage(e) { + closeSignInBanner(); + localStorage.setItem("cloud.baseURL", NETDATA.registry.cloudBaseURL); + + cloudAccountID = e.data.accountID; + cloudAccountName = e.data.accountName; + cloudToken = e.data.token; + + netdataRegistryCallback(registryAgents); + if (e.data.redirectURI && !window.location.href.includes(e.data.redirectURI)) { + window.location.replace(e.data.redirectURI); + } +} + +function handleSignOutMessage(e) { + clearCloudVariables(); + renderMyNetdataMenu(registryAgents); +} + +function isSignedIn() { + return cloudToken != null && cloudAccountID != null; +} + +function sortedArraysEqual(a, b) { + if (a.length != b.length) return false; + + for (var i = 0; i < a.length; ++i) { + if (a[i] !== b[i]) return false; + } + + return true; +} + +// If merging is needed returns the merged agents set, otherwise returns null. +function mergeAgents(cloud, local) { + let dirty = false; + + const union = new Map(); + + for (const cagent of cloud) { + union.set(cagent.guid, cagent); + } + + for (const lagent of local) { + const cagent = union.get(lagent.guid); + if (cagent) { + for (const u of lagent.alternate_urls) { + if (u === NETDATA.registry.MASKED_DATA) { // TODO: temp until registry is updated. + continue; + } + + if (!cagent.alternate_urls.includes(u)) { + dirty = true; + cagent.alternate_urls.push(u); + } + } + } else { + dirty = true; + union.set(lagent.guid, lagent); + } + } + + if (dirty) { + return Array.from(union.values()); + } + + return null; +} + +function showSignInModal() { + document.getElementById("sim-registry").innerHTML = NETDATA.registry.server; + $("#signInModal").modal("show"); +} + +function explicitlySignIn() { + $("#signInModal").modal("hide"); + signIn(); +} + +function showSyncModal() { + document.getElementById("sync-registry-modal-registry").innerHTML = NETDATA.registry.server; + $("#syncRegistryModal").modal("show"); +} + +function explicitlySyncAgents() { + $("#syncRegistryModal").modal("hide"); + + const json = localStorage.getItem("cloud.sync"); + const sync = json ? JSON.parse(json) : {}; + delete sync[cloudAccountID]; + localStorage.setItem("cloud.sync", JSON.stringify(sync)); + + NETDATA.registry.init(); +} + +function syncAgents(callback) { + const json = localStorage.getItem("cloud.sync"); + const sync = json ? JSON.parse(json) : {}; + + const currentAgent = { + guid: NETDATA.registry.machine_guid, + name: NETDATA.registry.hostname, + url: NETDATA.serverDefault, + alternate_urls: [NETDATA.serverDefault], + } + + const localAgents = sync[cloudAccountID] + ? [currentAgent] + : registryAgents.concat([currentAgent]); + + console.log("Checking if sync is needed.", localAgents); + + const agentsToSync = mergeAgents(cloudAgents, localAgents); + + if ((!sync[cloudAccountID]) || agentsToSync) { + sync[cloudAccountID] = new Date().getTime(); + localStorage.setItem("cloud.sync", JSON.stringify(sync)); + } + + if (agentsToSync) { + console.log("Synchronizing with netdata.cloud."); + + postCloudAccountAgents(agentsToSync).then((agents) => { + // TODO: clear syncTime on error! + cloudAgents = agents; + callback(cloudAgents); + }); + + return + } + + callback(cloudAgents); +} + +let isCloudSSOInitialized = false; + +function cloudSSOInit() { + const iframeEl = document.getElementById("ssoifrm"); + const url = `${NETDATA.registry.cloudBaseURL}/account/sso-agent?id=${NETDATA.registry.machine_guid}`; + iframeEl.src = url; + isCloudSSOInitialized = true; +} + +function cloudSSOSignOut() { + const iframe = document.getElementById("ssoifrm"); + const url = `${NETDATA.registry.cloudBaseURL}/account/sign-out-agent`; + iframe.src = url; +} + +function initCloud() { + if (!NETDATA.registry.isCloudEnabled) { + clearCloudVariables(); + clearCloudLocalStorageItems(); + return; + } + + if (NETDATA.registry.cloudBaseURL != localStorage.getItem("cloud.baseURL")) { + clearCloudVariables(); + clearCloudLocalStorageItems(); + if (NETDATA.registry.cloudBaseURL) { + localStorage.setItem("cloud.baseURL", NETDATA.registry.cloudBaseURL); + } + } + + if (!isCloudSSOInitialized) { + cloudSSOInit(); + } + + touchAgent(); +} + +// This callback is called after NETDATA.registry is initialized. +function netdataRegistryCallback(machinesArray) { + localStorage.setItem("cloud.agentID", NETDATA.registry.machine_guid); + + initCloud(); + + registryAgents = machinesArray; + + if (isSignedIn()) { + // We call getCloudAccountAgents() here because it requires that + // NETDATA.registry is initialized. + clearMyNetdataMenu(); + getCloudAccountAgents().then((agents) => { + if (!agents) { + errorMyNetdataMenu(); + return; + } + cloudAgents = agents; + syncAgents((agents) => { + const agentsMap = {} + for (const agent of agents) { + agentsMap[agent.guid] = agent; + } + + NETDATA.registry.machines = agentsMap; + NETDATA.registry.machines_array = agents; + + renderMyNetdataMenu(agents); + }); + }); + } else { + renderMyNetdataMenu(machinesArray) + } +}; + +// If we know the cloudBaseURL and agentID from local storage render (eagerly) +// the account ui before receiving the definitive response from the web server. +// This improves the perceived performance. +function tryFastInitCloud() { + const baseURL = localStorage.getItem("cloud.baseURL"); + const agentID = localStorage.getItem("cloud.agentID"); + + if (baseURL && agentID) { + NETDATA.registry.cloudBaseURL = baseURL; + NETDATA.registry.machine_guid = agentID; + NETDATA.registry.isCloudEnabled = true; + + initCloud(); + } +} + +function initializeApp() { + window.addEventListener("message", handleMessage, false); + + // tryFastInitCloud(); +} + +if (document.readyState === "complete") { + initializeApp(); +} else { + document.addEventListener("readystatechange", () => { + if (document.readyState === "complete") { + initializeApp(); + } + }); +} diff --git a/web/gui/old/index.html b/web/gui/old/index.html new file mode 100644 index 00000000..4b5707a2 --- /dev/null +++ b/web/gui/old/index.html @@ -0,0 +1,1321 @@ + + + + + netdata dashboard + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    + You must enable JavaScript in order to use Netdata!
    + You can do this in your browser settings. +
    +
    + + + + + + + + +
    +
    +
    +
    +
    + +
    +
    + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/gui/registry-access.html b/web/gui/registry-access.html new file mode 100644 index 00000000..75a40303 --- /dev/null +++ b/web/gui/registry-access.html @@ -0,0 +1,73 @@ +Netdata Registry \ No newline at end of file diff --git a/web/gui/registry-alert-redirect.html b/web/gui/registry-alert-redirect.html new file mode 100644 index 00000000..66b4be51 --- /dev/null +++ b/web/gui/registry-alert-redirect.html @@ -0,0 +1,150 @@ +Netdata Agent Alert Redirect

    Netdata Alert Notifications

    Trying to find a Netdata Agent for this alert...
    \ No newline at end of file diff --git a/web/gui/registry-hello.html b/web/gui/registry-hello.html new file mode 100644 index 00000000..7fba5662 --- /dev/null +++ b/web/gui/registry-hello.html @@ -0,0 +1,94 @@ +Netdata Registry \ No newline at end of file diff --git a/web/gui/src/dashboard.js/alarms.js b/web/gui/src/dashboard.js/alarms.js new file mode 100644 index 00000000..82477671 --- /dev/null +++ b/web/gui/src/dashboard.js/alarms.js @@ -0,0 +1,422 @@ + +// Registry of netdata hosts + +NETDATA.alarms = { + onclick: null, // the callback to handle the click - it will be called with the alarm log entry + chart_div_offset: -50, // give that space above the chart when scrolling to it + chart_div_id_prefix: 'chart_', // the chart DIV IDs have this prefix (they should be NETDATA.name2id(chart.id)) + chart_div_animation_duration: 0,// the duration of the animation while scrolling to a chart + + ms_penalty: 0, // the time penalty of the next alarm + ms_between_notifications: 500, // firefox moves the alarms off-screen (above, outside the top of the screen) + // if alarms are shown faster than: one per 500ms + + update_every: 10000, // the time in ms between alarm checks + + notifications: false, // when true, the browser supports notifications (may not be granted though) + last_notification_id: 0, // the id of the last alarm_log we have raised an alarm for + first_notification_id: 0, // the id of the first alarm_log entry for this session + // this is used to prevent CLEAR notifications for past events + // notifications_shown: [], + + server: null, // the server to connect to for fetching alarms + current: null, // the list of raised alarms - updated in the background + + // a callback function to call every time the list of raised alarms is refreshed + callback: (typeof netdataAlarmsActiveCallback === 'function') ? netdataAlarmsActiveCallback : null, + + // a callback function to call every time a notification is shown + // the return value is used to decide if the notification will be shown + notificationCallback: (typeof netdataAlarmsNotifCallback === 'function') ? netdataAlarmsNotifCallback : null, + + recipients: null, // the list (array) of recipients to show alarms for, or null + + recipientMatches: function (to_string, wanted_array) { + if (typeof wanted_array === 'undefined' || wanted_array === null || Array.isArray(wanted_array) === false) { + return true; + } + + let r = ' ' + to_string.toString() + ' '; + let len = wanted_array.length; + while (len--) { + if (r.indexOf(' ' + wanted_array[len] + ' ') >= 0) { + return true; + } + } + + return false; + }, + + activeForRecipients: function () { + let active = {}; + let data = NETDATA.alarms.current; + + if (typeof data === 'undefined' || data === null) { + return active; + } + + for (let x in data.alarms) { + if (!data.alarms.hasOwnProperty(x)) { + continue; + } + + let alarm = data.alarms[x]; + if ((alarm.status === 'WARNING' || alarm.status === 'CRITICAL') && NETDATA.alarms.recipientMatches(alarm.recipient, NETDATA.alarms.recipients)) { + active[x] = alarm; + } + } + + return active; + }, + + notify: function (entry) { + // console.log('alarm ' + entry.unique_id); + + if (entry.updated) { + // console.log('alarm ' + entry.unique_id + ' has been updated by another alarm'); + return; + } + + let value_string = entry.value_string; + + if (NETDATA.alarms.current !== null) { + // get the current value_string + let t = NETDATA.alarms.current.alarms[entry.chart + '.' + entry.name]; + if (typeof t !== 'undefined' && entry.status === t.status && typeof t.value_string !== 'undefined') { + value_string = t.value_string; + } + } + + let name = entry.name.replace(/_/g, ' '); + let status = entry.status.toLowerCase(); + let title = name + ' = ' + value_string.toString(); + let tag = entry.alarm_id; + let icon = 'images/banner-icon-144x144.png'; + let interaction = false; + let data = entry; + let show = true; + + // console.log('alarm ' + entry.unique_id + ' ' + entry.chart + '.' + entry.name + ' is ' + entry.status); + + switch (entry.status) { + case 'REMOVED': + show = false; + break; + + case 'UNDEFINED': + return; + + case 'UNINITIALIZED': + return; + + case 'CLEAR': + if (entry.unique_id < NETDATA.alarms.first_notification_id) { + // console.log('alarm ' + entry.unique_id + ' is not current'); + return; + } + if (entry.old_status === 'UNINITIALIZED' || entry.old_status === 'UNDEFINED') { + // console.log('alarm' + entry.unique_id + ' switch to CLEAR from ' + entry.old_status); + return; + } + if (entry.no_clear_notification) { + // console.log('alarm' + entry.unique_id + ' is CLEAR but has no_clear_notification flag'); + return; + } + title = name + ' back to normal (' + value_string.toString() + ')'; + icon = 'images/check-mark-2-128-green.png'; + interaction = false; + break; + + case 'WARNING': + if (entry.old_status === 'CRITICAL') { + status = 'demoted to ' + entry.status.toLowerCase(); + } + + icon = 'images/alert-128-orange.png'; + interaction = false; + break; + + case 'CRITICAL': + if (entry.old_status === 'WARNING') { + status = 'escalated to ' + entry.status.toLowerCase(); + } + + icon = 'images/alert-128-red.png'; + interaction = true; + break; + + default: + console.log('invalid alarm status ' + entry.status); + return; + } + + // filter recipients + if (show) { + show = NETDATA.alarms.recipientMatches(entry.recipient, NETDATA.alarms.recipients); + } + + /* + // cleanup old notifications with the same alarm_id as this one + // it does not seem to work on any web browser - so notifications cannot be removed + + let len = NETDATA.alarms.notifications_shown.length; + while (len--) { + let n = NETDATA.alarms.notifications_shown[len]; + if (n.data.alarm_id === entry.alarm_id) { + console.log('removing old alarm ' + n.data.unique_id); + + // close the notification + n.close.bind(n); + + // remove it from the array + NETDATA.alarms.notifications_shown.splice(len, 1); + len = NETDATA.alarms.notifications_shown.length; + } + } + */ + + if (show) { + if (typeof NETDATA.alarms.notificationCallback === 'function') { + show = NETDATA.alarms.notificationCallback(entry); + } + + if (show) { + setTimeout(function () { + // show this notification + // console.log('new notification: ' + title); + let n = new Notification(title, { + body: entry.hostname + ' - ' + entry.chart + ' (' + entry.family + ') - ' + status + ': ' + entry.info, + tag: tag, + requireInteraction: interaction, + icon: NETDATA.serverStatic + icon, + data: data + }); + + n.onclick = function (event) { + event.preventDefault(); + NETDATA.alarms.onclick(event.target.data); + }; + + // console.log(n); + // NETDATA.alarms.notifications_shown.push(n); + // console.log(entry); + }, NETDATA.alarms.ms_penalty); + + NETDATA.alarms.ms_penalty += NETDATA.alarms.ms_between_notifications; + } + } + }, + + scrollToChart: function (chart_id) { + if (typeof chart_id === 'string') { + let offset = $('#' + NETDATA.alarms.chart_div_id_prefix + NETDATA.name2id(chart_id)).offset(); + if (typeof offset !== 'undefined') { + $('html, body').animate({scrollTop: offset.top + NETDATA.alarms.chart_div_offset}, NETDATA.alarms.chart_div_animation_duration); + return true; + } + } + return false; + }, + + scrollToAlarm: function (alarm) { + if (typeof alarm === 'object') { + let ret = NETDATA.alarms.scrollToChart(alarm.chart); + + if (ret && NETDATA.options.page_is_visible === false) { + window.focus(); + } + // alert('netdata dashboard will now scroll to chart: ' + alarm.chart + '\n\nThis alarm opened to bring the browser window in front of the screen. Click on the dashboard to prevent it from appearing again.'); + } + + }, + + notifyAll: function () { + // console.log('FETCHING ALARM LOG'); + NETDATA.alarms.get_log(NETDATA.alarms.last_notification_id, function (data) { + // console.log('ALARM LOG FETCHED'); + + if (data === null || typeof data !== 'object') { + console.log('invalid alarms log response'); + return; + } + + if (data.length === 0) { + console.log('received empty alarm log'); + return; + } + + // console.log('received alarm log of ' + data.length + ' entries, from ' + data[data.length - 1].unique_id.toString() + ' to ' + data[0].unique_id.toString()); + + data.sort(function (a, b) { + if (a.unique_id > b.unique_id) { + return -1; + } + if (a.unique_id < b.unique_id) { + return 1; + } + return 0; + }); + + NETDATA.alarms.ms_penalty = 0; + + let len = data.length; + while (len--) { + if (data[len].unique_id > NETDATA.alarms.last_notification_id) { + NETDATA.alarms.notify(data[len]); + } + //else + // console.log('ignoring alarm (older) with id ' + data[len].unique_id.toString()); + } + + NETDATA.alarms.last_notification_id = data[0].unique_id; + + if (typeof netdataAlarmsRemember === 'undefined' || netdataAlarmsRemember) { + NETDATA.localStorageSet('last_notification_id', NETDATA.alarms.last_notification_id, null); + } + // console.log('last notification id = ' + NETDATA.alarms.last_notification_id); + }) + }, + + check_notifications: function () { + // returns true if we should fire 1+ notifications + + if (NETDATA.alarms.notifications !== true) { + // console.log('web notifications are not available'); + return false; + } + + if (Notification.permission !== 'granted') { + // console.log('web notifications are not granted'); + return false; + } + + if (typeof NETDATA.alarms.current !== 'undefined' && typeof NETDATA.alarms.current.alarms === 'object') { + // console.log('can do alarms: old id = ' + NETDATA.alarms.last_notification_id + ' new id = ' + NETDATA.alarms.current.latest_alarm_log_unique_id); + + if (NETDATA.alarms.current.latest_alarm_log_unique_id > NETDATA.alarms.last_notification_id) { + // console.log('new alarms detected'); + return true; + } + //else console.log('no new alarms'); + } + // else console.log('cannot process alarms'); + + return false; + }, + + get: function (what, callback) { + $.ajax({ + url: NETDATA.alarms.server + '/api/v1/alarms?' + what.toString(), + async: true, + cache: false, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/alarms', data /*, '.*\.(calc|calc_parsed|warn|warn_parsed|crit|crit_parsed)$' */); + + if (NETDATA.alarms.first_notification_id === 0 && typeof data.latest_alarm_log_unique_id === 'number') { + NETDATA.alarms.first_notification_id = data.latest_alarm_log_unique_id; + } + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + NETDATA.error(415, NETDATA.alarms.server); + + if (typeof callback === 'function') { + return callback(null); + } + }); + }, + + update_forever: function () { + if (netdataShowAlarms !== true || netdataSnapshotData !== null) { + return; + } + + NETDATA.alarms.get('active', function (data) { + if (data !== null) { + NETDATA.alarms.current = data; + + if (NETDATA.alarms.check_notifications()) { + NETDATA.alarms.notifyAll(); + } + + if (typeof NETDATA.alarms.callback === 'function') { + NETDATA.alarms.callback(data); + } + + // Health monitoring is disabled on this netdata + if (data.status === false) { + return; + } + } + + setTimeout(NETDATA.alarms.update_forever, NETDATA.alarms.update_every); + }); + }, + + get_log: function (last_id, callback) { + // console.log('fetching all log after ' + last_id.toString()); + $.ajax({ + url: NETDATA.alarms.server + '/api/v1/alarm_log?after=' + last_id.toString(), + async: true, + cache: false, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/alarm_log', data); + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + NETDATA.error(416, NETDATA.alarms.server); + + if (typeof callback === 'function') { + return callback(null); + } + }); + }, + + init: function () { + NETDATA.alarms.server = NETDATA.fixHost(NETDATA.serverDefault); + + if (typeof netdataAlarmsRemember === 'undefined' || netdataAlarmsRemember) { + NETDATA.alarms.last_notification_id = + NETDATA.localStorageGet('last_notification_id', NETDATA.alarms.last_notification_id, null); + } + + if (NETDATA.alarms.onclick === null) { + NETDATA.alarms.onclick = NETDATA.alarms.scrollToAlarm; + } + + if (typeof netdataAlarmsRecipients !== 'undefined' && Array.isArray(netdataAlarmsRecipients)) { + NETDATA.alarms.recipients = netdataAlarmsRecipients; + } + + if (netdataShowAlarms) { + NETDATA.alarms.update_forever(); + + if ('Notification' in window) { + // console.log('notifications available'); + NETDATA.alarms.notifications = true; + + if (Notification.permission === 'default') { + Notification.requestPermission(); + } + } + } + } +}; diff --git a/web/gui/src/dashboard.js/boot.js b/web/gui/src/dashboard.js/boot.js new file mode 100644 index 00000000..c448213b --- /dev/null +++ b/web/gui/src/dashboard.js/boot.js @@ -0,0 +1,142 @@ + +// Load required JS libraries and CSS + +NETDATA.requiredJs = [ + { + url: NETDATA.serverStatic + 'lib/bootstrap-3.3.7.min.js', + async: false, + isAlreadyLoaded: function () { + // check if bootstrap is loaded + if (typeof $().emulateTransitionEnd === 'function') { + return true; + } else { + return typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap; + } + } + }, + { + url: NETDATA.serverStatic + 'lib/fontawesome-all-5.0.1.min.js', + async: true, + isAlreadyLoaded: function () { + return typeof netdataNoFontAwesome !== 'undefined' && netdataNoFontAwesome; + } + }, + { + url: NETDATA.serverStatic + 'lib/perfect-scrollbar-0.6.15.min.js', + isAlreadyLoaded: function () { + return false; + } + } +]; + +NETDATA.requiredCSS = [ + { + url: NETDATA.themes.current.bootstrap_css, + isAlreadyLoaded: function () { + return typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap; + } + }, + { + url: NETDATA.themes.current.dashboard_css, + isAlreadyLoaded: function () { + return false; + } + } +]; + +NETDATA.loadedRequiredJs = 0; +NETDATA.loadRequiredJs = function (index, callback) { + if (index >= NETDATA.requiredJs.length) { + if (typeof callback === 'function') { + return callback(); + } + return; + } + + if (NETDATA.requiredJs[index].isAlreadyLoaded()) { + NETDATA.loadedRequiredJs++; + NETDATA.loadRequiredJs(++index, callback); + return; + } + + if (NETDATA.options.debug.main_loop) { + console.log('loading ' + NETDATA.requiredJs[index].url); + } + + let async = true; + if (typeof NETDATA.requiredJs[index].async !== 'undefined' && NETDATA.requiredJs[index].async === false) { + async = false; + } + + $.ajax({ + url: NETDATA.requiredJs[index].url, + cache: true, + dataType: "script", + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function () { + if (NETDATA.options.debug.main_loop) { + console.log('loaded ' + NETDATA.requiredJs[index].url); + } + }) + .fail(function () { + alert('Cannot load required JS library: ' + NETDATA.requiredJs[index].url); + }) + .always(function () { + NETDATA.loadedRequiredJs++; + + // if (async === false) + if (!async) { + NETDATA.loadRequiredJs(++index, callback); + } + }); + + // if (async === true) + if (async) { + NETDATA.loadRequiredJs(++index, callback); + } +}; + +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) { + console.log('loading ' + NETDATA.requiredCSS[index].url); + } + + NETDATA._loadCSS(NETDATA.requiredCSS[index].url); + NETDATA.loadRequiredCSS(++index); +}; + +// Boot it! + +if (typeof netdataPrepCallback === 'function') { + netdataPrepCallback(); +} + +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) { + console.log('starting chart refresh thread'); + } + + NETDATA.start(); + } + }); +}); diff --git a/web/gui/src/dashboard.js/chart-registry.js b/web/gui/src/dashboard.js/chart-registry.js new file mode 100644 index 00000000..542f4e01 --- /dev/null +++ b/web/gui/src/dashboard.js/chart-registry.js @@ -0,0 +1,94 @@ + +// *** src/dashboard.js/chart-registry.js + +// 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.fixHost = function (host) { + while (host.slice(-1) === '/') { + host = host.substring(0, host.length - 1); + } + + return host; +}; + +NETDATA.chartRegistry = { + charts: {}, + + globalReset: function () { + this.charts = {}; + }, + + add: function (host, id, data) { + if (typeof this.charts[host] === 'undefined') { + this.charts[host] = {}; + } + + //console.log('added ' + host + '/' + id); + this.charts[host][id] = data; + }, + + get: function (host, 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) { + host = NETDATA.fixHost(host); + + let self = this; + + function got_data(h, data, callback) { + if (data !== null) { + self.charts[h] = data.charts; + + // update the server timezone in our options + if (typeof data.timezone === 'string') { + NETDATA.options.server_timezone = data.timezone; + } + } else { + NETDATA.error(406, h + '/api/v1/charts'); + } + + if (typeof callback === 'function') { + callback(data); + } + } + + if (netdataSnapshotData !== null) { + got_data(host, netdataSnapshotData.charts, callback); + } else { + $.ajax({ + url: host + '/api/v1/charts', + async: true, + cache: false, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/charts', data); + got_data(host, data, callback); + }) + .fail(function () { + NETDATA.error(405, host + '/api/v1/charts'); + + if (typeof callback === 'function') { + callback(null); + } + }); + } + } +}; diff --git a/web/gui/src/dashboard.js/charting.js b/web/gui/src/dashboard.js/charting.js new file mode 100644 index 00000000..1035ff06 --- /dev/null +++ b/web/gui/src/dashboard.js/charting.js @@ -0,0 +1,492 @@ + +// Charts Libraries Registration + +NETDATA.chartLibraries = { + "dygraph": { + initialize: NETDATA.dygraphInitialize, + create: NETDATA.dygraphChartCreate, + update: NETDATA.dygraphChartUpdate, + resize: function (state) { + if (typeof state.tmp.dygraph_instance !== 'undefined' && typeof state.tmp.dygraph_instance.resize === 'function') { + state.tmp.dygraph_instance.resize(); + } + }, + setSelection: NETDATA.dygraphSetSelection, + clearSelection: NETDATA.dygraphClearSelection, + toolboxPanAndZoom: NETDATA.dygraphToolboxPanAndZoom, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + format: function (state) { + void(state); + return 'json'; + }, + options: function (state) { + return 'ms' + '%7C' + 'flip' + (this.isLogScale(state) ? ('%7C' + 'abs') : '').toString(); + }, + legend: function (state) { + return (this.isSparkline(state) === false && NETDATA.dataAttributeBoolean(state.element, 'legend', true) === true) ? 'right-side' : null; + }, + autoresize: function (state) { + void(state); + return true; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return true; + }, + pixels_per_point: function (state) { + return (this.isSparkline(state) === false) ? 3 : 2; + }, + isSparkline: function (state) { + if (typeof state.tmp.dygraph_sparkline === 'undefined') { + state.tmp.dygraph_sparkline = (this.theme(state) === 'sparkline'); + } + return state.tmp.dygraph_sparkline; + }, + isLogScale: function (state) { + if (typeof state.tmp.dygraph_logscale === 'undefined') { + state.tmp.dygraph_logscale = (this.theme(state) === 'logscale'); + } + return state.tmp.dygraph_logscale; + }, + theme: function (state) { + if (typeof state.tmp.dygraph_theme === 'undefined') { + state.tmp.dygraph_theme = NETDATA.dataAttribute(state.element, 'dygraph-theme', 'default'); + } + return state.tmp.dygraph_theme; + }, + container_class: function (state) { + if (this.legend(state) !== null) { + return 'netdata-container-with-legend'; + } + return 'netdata-container'; + } + }, + "sparkline": { + initialize: NETDATA.sparklineInitialize, + create: NETDATA.sparklineChartCreate, + update: NETDATA.sparklineChartUpdate, + resize: null, + setSelection: undefined, // function(state, t) { void(state); return true; }, + clearSelection: undefined, // function(state) { void(state); return true; }, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + format: function (state) { + void(state); + return 'array'; + }, + options: function (state) { + void(state); + return 'flip' + '%7C' + 'abs'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + "peity": { + initialize: NETDATA.peityInitialize, + create: NETDATA.peityChartCreate, + update: NETDATA.peityChartUpdate, + resize: null, + setSelection: undefined, // function(state, t) { void(state); return true; }, + clearSelection: undefined, // function(state) { void(state); return true; }, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + format: function (state) { + void(state); + return 'ssvcomma'; + }, + options: function (state) { + void(state); + return 'null2zero' + '%7C' + 'flip' + '%7C' + 'abs'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + // "morris": { + // initialize: NETDATA.morrisInitialize, + // create: NETDATA.morrisChartCreate, + // update: NETDATA.morrisChartUpdate, + // resize: null, + // setSelection: undefined, // function(state, t) { void(state); return true; }, + // clearSelection: undefined, // function(state) { void(state); return true; }, + // toolboxPanAndZoom: null, + // initialized: false, + // enabled: true, + // xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + // format: function(state) { void(state); return 'json'; }, + // options: function(state) { void(state); return 'objectrows' + '%7C' + 'ms'; }, + // legend: function(state) { void(state); return null; }, + // autoresize: function(state) { void(state); return false; }, + // max_updates_to_recreate: function(state) { void(state); return 50; }, + // track_colors: function(state) { void(state); return false; }, + // pixels_per_point: function(state) { void(state); return 15; }, + // container_class: function(state) { void(state); return 'netdata-container'; } + // }, + "google": { + initialize: NETDATA.googleInitialize, + create: NETDATA.googleChartCreate, + update: NETDATA.googleChartUpdate, + resize: null, + setSelection: undefined, //function(state, t) { void(state); return true; }, + clearSelection: undefined, //function(state) { void(state); return true; }, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result.rows$'), + format: function (state) { + void(state); + return 'datatable'; + }, + options: function (state) { + void(state); + return ''; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 300; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 4; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + // "raphael": { + // initialize: NETDATA.raphaelInitialize, + // create: NETDATA.raphaelChartCreate, + // update: NETDATA.raphaelChartUpdate, + // resize: null, + // setSelection: undefined, // function(state, t) { void(state); return true; }, + // clearSelection: undefined, // function(state) { void(state); return true; }, + // toolboxPanAndZoom: null, + // initialized: false, + // enabled: true, + // xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + // format: function(state) { void(state); return 'json'; }, + // options: function(state) { void(state); return ''; }, + // legend: function(state) { void(state); return null; }, + // autoresize: function(state) { void(state); return false; }, + // max_updates_to_recreate: function(state) { void(state); return 5000; }, + // track_colors: function(state) { void(state); return false; }, + // pixels_per_point: function(state) { void(state); return 3; }, + // container_class: function(state) { void(state); return 'netdata-container'; } + // }, + // "c3": { + // initialize: NETDATA.c3Initialize, + // create: NETDATA.c3ChartCreate, + // update: NETDATA.c3ChartUpdate, + // resize: null, + // setSelection: undefined, // function(state, t) { void(state); return true; }, + // clearSelection: undefined, // function(state) { void(state); return true; }, + // toolboxPanAndZoom: null, + // initialized: false, + // enabled: true, + // xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + // format: function(state) { void(state); return 'csvjsonarray'; }, + // options: function(state) { void(state); return 'milliseconds'; }, + // legend: function(state) { void(state); return null; }, + // autoresize: function(state) { void(state); return false; }, + // max_updates_to_recreate: function(state) { void(state); return 5000; }, + // track_colors: function(state) { void(state); return false; }, + // pixels_per_point: function(state) { void(state); return 15; }, + // container_class: function(state) { void(state); return 'netdata-container'; } + // }, + "d3pie": { + initialize: NETDATA.d3pieInitialize, + create: NETDATA.d3pieChartCreate, + update: NETDATA.d3pieChartUpdate, + resize: null, + setSelection: NETDATA.d3pieSetSelection, + clearSelection: NETDATA.d3pieClearSelection, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + format: function (state) { + void(state); + return 'json'; + }, + options: function (state) { + void(state); + return 'objectrows' + '%7C' + 'ms'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 15; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + "d3": { + initialize: NETDATA.d3Initialize, + create: NETDATA.d3ChartCreate, + update: NETDATA.d3ChartUpdate, + resize: null, + setSelection: undefined, // function(state, t) { void(state); return true; }, + clearSelection: undefined, // function(state) { void(state); return true; }, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + format: function (state) { + void(state); + return 'json'; + }, + options: function (state) { + void(state); + return ''; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + "easypiechart": { + initialize: NETDATA.easypiechartInitialize, + create: NETDATA.easypiechartChartCreate, + update: NETDATA.easypiechartChartUpdate, + resize: null, + setSelection: NETDATA.easypiechartSetSelection, + clearSelection: NETDATA.easypiechartClearSelection, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + format: function (state) { + void(state); + return 'array'; + }, + options: function (state) { + void(state); + return 'absolute'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return true; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + aspect_ratio: 100, + container_class: function (state) { + void(state); + return 'netdata-container-easypiechart'; + } + }, + "gauge": { + initialize: NETDATA.gaugeInitialize, + create: NETDATA.gaugeChartCreate, + update: NETDATA.gaugeChartUpdate, + resize: null, + setSelection: NETDATA.gaugeSetSelection, + clearSelection: NETDATA.gaugeClearSelection, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + format: function (state) { + void(state); + return 'array'; + }, + options: function (state) { + void(state); + return 'absolute'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return true; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + aspect_ratio: 60, + container_class: function (state) { + void(state); + return 'netdata-container-gauge'; + } + }, + "textonly": { + autoresize: function (state) { + void(state); + return false; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + }, + create: NETDATA.textOnlyCreate, + enabled: true, + format: function (state) { + void(state); + return 'array'; + }, + initialized: true, + initialize: function (callback) { + callback(); + }, + legend: function (state) { + void(state); + return null; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + options: function (state) { + void(state); + return 'absolute'; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + track_colors: function (state) { + void(state); + return false; + }, + update: NETDATA.textOnlyUpdate, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + } +}; + +NETDATA.registerChartLibrary = function (library, url) { + if (NETDATA.options.debug.libraries) { + console.log("registering chart library: " + library); + } + + NETDATA.chartLibraries[library].url = url; + NETDATA.chartLibraries[library].initialized = true; + NETDATA.chartLibraries[library].enabled = true; +}; diff --git a/web/gui/src/dashboard.js/charting/_c3.js b/web/gui/src/dashboard.js/charting/_c3.js new file mode 100644 index 00000000..6688bbcc --- /dev/null +++ b/web/gui/src/dashboard.js/charting/_c3.js @@ -0,0 +1,114 @@ + +// DEPRECATED: will be removed! + +// 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") + return 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") + return callback(); + }); + } + } else { + NETDATA.chartLibraries.c3.enabled = false; + if (typeof callback === "function") + return 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.dateTime.xAxisTimeString(x); + } + } + } + }, + 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; +}; diff --git a/web/gui/src/dashboard.js/charting/_morris.js b/web/gui/src/dashboard.js/charting/_morris.js new file mode 100644 index 00000000..30789e4e --- /dev/null +++ b/web/gui/src/dashboard.js/charting/_morris.js @@ -0,0 +1,81 @@ + +// DEPRECATED: will be removed! + +// 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") + return 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") + return callback(); + }); + } + } else { + NETDATA.chartLibraries.morris.enabled = false; + if (typeof callback === "function") + return 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; +}; diff --git a/web/gui/src/dashboard.js/charting/_raphael.js b/web/gui/src/dashboard.js/charting/_raphael.js new file mode 100644 index 00000000..2d89a22a --- /dev/null +++ b/web/gui/src/dashboard.js/charting/_raphael.js @@ -0,0 +1,48 @@ + +// DEPRECATED: will be removed! + +// 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") + return callback(); + }); + } else { + NETDATA.chartLibraries.raphael.enabled = false; + if (typeof callback === "function") + return 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; +}; diff --git a/web/gui/src/dashboard.js/charting/d3.js b/web/gui/src/dashboard.js/charting/d3.js new file mode 100644 index 00000000..6528208c --- /dev/null +++ b/web/gui/src/dashboard.js/charting/d3.js @@ -0,0 +1,43 @@ + +// ---------------------------------------------------------------------------------------------------------------- +// 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") + return callback(); + }); + } else { + NETDATA.chartLibraries.d3.enabled = false; + if (typeof callback === "function") + return callback(); + } +}; + +NETDATA.d3ChartUpdate = function(state, data) { + void(state); + void(data); + + return false; +}; + +NETDATA.d3ChartCreate = function(state, data) { + void(state); + void(data); + + return false; +}; diff --git a/web/gui/src/dashboard.js/charting/d3pie.js b/web/gui/src/dashboard.js/charting/d3pie.js new file mode 100644 index 00000000..27cff854 --- /dev/null +++ b/web/gui/src/dashboard.js/charting/d3pie.js @@ -0,0 +1,341 @@ + +// d3pie + +NETDATA.d3pieInitialize = function (callback) { + if (typeof netdataNoD3pie === 'undefined' || !netdataNoD3pie) { + + // d3pie requires D3 + if (!NETDATA.chartLibraries.d3.initialized) { + if (NETDATA.chartLibraries.d3.enabled) { + NETDATA.d3Initialize(function () { + NETDATA.d3pieInitialize(callback); + }); + } else { + NETDATA.chartLibraries.d3pie.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } + } else { + $.ajax({ + url: NETDATA.d3pie_js, + cache: true, + dataType: "script", + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function () { + NETDATA.registerChartLibrary('d3pie', NETDATA.d3pie_js); + }) + .fail(function () { + NETDATA.chartLibraries.d3pie.enabled = false; + NETDATA.error(100, NETDATA.d3pie_js); + }) + .always(function () { + if (typeof callback === "function") { + return callback(); + } + }); + } + } else { + NETDATA.chartLibraries.d3pie.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } +}; + +NETDATA.d3pieSetContent = function (state, data, index) { + state.legendFormatValueDecimalsFromMinMax( + data.min, + data.max + ); + + let content = []; + let colors = state.chartColors(); + let len = data.result.labels.length; + for (let i = 1; i < len; i++) { + let label = data.result.labels[i]; + let value = data.result.data[index][label]; + let color = colors[i - 1]; + + if (value !== null && value > 0) { + content.push({ + label: label, + value: value, + color: color + }); + } + } + + if (content.length === 0) { + content.push({ + label: 'no data', + value: 100, + color: '#666666' + }); + } + + state.tmp.d3pie_last_slot = index; + return content; +}; + +NETDATA.d3pieDateRange = function (state, data, index) { + let dt = Math.round((data.before - data.after + 1) / data.points); + let dt_str = NETDATA.seconds4human(dt); + + let before = data.result.data[index].time; + let after = before - (dt * 1000); + + let d1 = NETDATA.dateTime.localeDateString(after); + let t1 = NETDATA.dateTime.localeTimeString(after); + let d2 = NETDATA.dateTime.localeDateString(before); + let t2 = NETDATA.dateTime.localeTimeString(before); + + if (d1 === d2) { + return d1 + ' ' + t1 + ' to ' + t2 + ', ' + dt_str; + } + + return d1 + ' ' + t1 + ' to ' + d2 + ' ' + t2 + ', ' + dt_str; +}; + +NETDATA.d3pieSetSelection = function (state, t) { + if (state.timeIsVisible(t) !== true) { + return NETDATA.d3pieClearSelection(state, true); + } + + let slot = state.calculateRowForTime(t); + slot = state.data.result.data.length - slot - 1; + + if (slot < 0 || slot >= state.data.result.length) { + return NETDATA.d3pieClearSelection(state, true); + } + + if (state.tmp.d3pie_last_slot === slot) { + // we already show this slot, don't do anything + return true; + } + + if (state.tmp.d3pie_timer === undefined) { + state.tmp.d3pie_timer = NETDATA.timeout.set(function () { + state.tmp.d3pie_timer = undefined; + NETDATA.d3pieChange(state, NETDATA.d3pieSetContent(state, state.data, slot), NETDATA.d3pieDateRange(state, state.data, slot)); + }, 0); + } + + return true; +}; + +NETDATA.d3pieClearSelection = function (state, force) { + if (typeof state.tmp.d3pie_timer !== 'undefined') { + NETDATA.timeout.clear(state.tmp.d3pie_timer); + state.tmp.d3pie_timer = undefined; + } + + if (state.isAutoRefreshable() && state.data !== null && force !== true) { + NETDATA.d3pieChartUpdate(state, state.data); + } else { + if (state.tmp.d3pie_last_slot !== -1) { + state.tmp.d3pie_last_slot = -1; + NETDATA.d3pieChange(state, [{label: 'no data', value: 1, color: '#666666'}], 'no data available'); + } + } + + return true; +}; + +NETDATA.d3pieChange = function (state, content, footer) { + if (state.d3pie_forced_subtitle === null) { + //state.d3pie_instance.updateProp("header.subtitle.text", state.units_current); + state.d3pie_instance.options.header.subtitle.text = state.units_current; + } + + if (state.d3pie_forced_footer === null) { + //state.d3pie_instance.updateProp("footer.text", footer); + state.d3pie_instance.options.footer.text = footer; + } + + //state.d3pie_instance.updateProp("data.content", content); + state.d3pie_instance.options.data.content = content; + state.d3pie_instance.destroy(); + state.d3pie_instance.recreate(); + return true; +}; + +NETDATA.d3pieChartUpdate = function (state, data) { + return NETDATA.d3pieChange(state, NETDATA.d3pieSetContent(state, data, 0), NETDATA.d3pieDateRange(state, data, 0)); +}; + +NETDATA.d3pieChartCreate = function (state, data) { + + state.element_chart.id = 'd3pie-' + state.uuid; + // console.log('id = ' + state.element_chart.id); + + let content = NETDATA.d3pieSetContent(state, data, 0); + + state.d3pie_forced_title = NETDATA.dataAttribute(state.element, 'd3pie-title', null); + state.d3pie_forced_subtitle = NETDATA.dataAttribute(state.element, 'd3pie-subtitle', null); + state.d3pie_forced_footer = NETDATA.dataAttribute(state.element, 'd3pie-footer', null); + + state.d3pie_options = { + header: { + title: { + text: (state.d3pie_forced_title !== null) ? state.d3pie_forced_title : state.title, + color: NETDATA.dataAttribute(state.element, 'd3pie-title-color', NETDATA.themes.current.d3pie.title), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-title-fontsize', 12), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-title-fontweight', "bold"), + font: NETDATA.dataAttribute(state.element, 'd3pie-title-font', "arial") + }, + subtitle: { + text: (state.d3pie_forced_subtitle !== null) ? state.d3pie_forced_subtitle : state.units_current, + color: NETDATA.dataAttribute(state.element, 'd3pie-subtitle-color', NETDATA.themes.current.d3pie.subtitle), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-subtitle-fontsize', 10), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-subtitle-fontweight', "normal"), + font: NETDATA.dataAttribute(state.element, 'd3pie-subtitle-font', "arial") + }, + titleSubtitlePadding: 1 + }, + footer: { + text: (state.d3pie_forced_footer !== null) ? state.d3pie_forced_footer : NETDATA.d3pieDateRange(state, data, 0), + color: NETDATA.dataAttribute(state.element, 'd3pie-footer-color', NETDATA.themes.current.d3pie.footer), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-footer-fontsize', 9), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-footer-fontweight', "bold"), + font: NETDATA.dataAttribute(state.element, 'd3pie-footer-font', "arial"), + location: NETDATA.dataAttribute(state.element, 'd3pie-footer-location', "bottom-center") // bottom-left, bottom-center, bottom-right + }, + size: { + canvasHeight: state.chartHeight(), + canvasWidth: state.chartWidth(), + pieInnerRadius: NETDATA.dataAttribute(state.element, 'd3pie-pieinnerradius', "45%"), + pieOuterRadius: NETDATA.dataAttribute(state.element, 'd3pie-pieouterradius', "80%") + }, + data: { + // none, random, value-asc, value-desc, label-asc, label-desc + sortOrder: NETDATA.dataAttribute(state.element, 'd3pie-sortorder', "value-desc"), + smallSegmentGrouping: { + enabled: NETDATA.dataAttributeBoolean(state.element, "d3pie-smallsegmentgrouping-enabled", false), + value: NETDATA.dataAttribute(state.element, 'd3pie-smallsegmentgrouping-value', 1), + // percentage, value + valueType: NETDATA.dataAttribute(state.element, 'd3pie-smallsegmentgrouping-valuetype', "percentage"), + label: NETDATA.dataAttribute(state.element, 'd3pie-smallsegmentgrouping-label', "other"), + color: NETDATA.dataAttribute(state.element, 'd3pie-smallsegmentgrouping-color', NETDATA.themes.current.d3pie.other) + }, + + // REQUIRED! This is where you enter your pie data; it needs to be an array of objects + // of this form: { label: "label", value: 1.5, color: "#000000" } - color is optional + content: content + }, + labels: { + outer: { + // label, value, percentage, label-value1, label-value2, label-percentage1, label-percentage2 + format: NETDATA.dataAttribute(state.element, 'd3pie-labels-outer-format', "label-value1"), + hideWhenLessThanPercentage: NETDATA.dataAttribute(state.element, 'd3pie-labels-outer-hidewhenlessthanpercentage', null), + pieDistance: NETDATA.dataAttribute(state.element, 'd3pie-labels-outer-piedistance', 15) + }, + inner: { + // label, value, percentage, label-value1, label-value2, label-percentage1, label-percentage2 + format: NETDATA.dataAttribute(state.element, 'd3pie-labels-inner-format', "percentage"), + hideWhenLessThanPercentage: NETDATA.dataAttribute(state.element, 'd3pie-labels-inner-hidewhenlessthanpercentage', 2) + }, + mainLabel: { + color: NETDATA.dataAttribute(state.element, 'd3pie-labels-mainLabel-color', NETDATA.themes.current.d3pie.mainlabel), // or 'segment' for dynamic color + font: NETDATA.dataAttribute(state.element, 'd3pie-labels-mainLabel-font', "arial"), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-labels-mainLabel-fontsize', 10), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-labels-mainLabel-fontweight', "normal") + }, + percentage: { + color: NETDATA.dataAttribute(state.element, 'd3pie-labels-percentage-color', NETDATA.themes.current.d3pie.percentage), + font: NETDATA.dataAttribute(state.element, 'd3pie-labels-percentage-font', "arial"), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-labels-percentage-fontsize', 10), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-labels-percentage-fontweight', "bold"), + decimalPlaces: 0 + }, + value: { + color: NETDATA.dataAttribute(state.element, 'd3pie-labels-value-color', NETDATA.themes.current.d3pie.value), + font: NETDATA.dataAttribute(state.element, 'd3pie-labels-value-font', "arial"), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-labels-value-fontsize', 10), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-labels-value-fontweight', "bold") + }, + lines: { + enabled: NETDATA.dataAttributeBoolean(state.element, 'd3pie-labels-lines-enabled', true), + style: NETDATA.dataAttribute(state.element, 'd3pie-labels-lines-style', "curved"), + color: NETDATA.dataAttribute(state.element, 'd3pie-labels-lines-color', "segment") // "segment" or a hex color + }, + truncation: { + enabled: NETDATA.dataAttributeBoolean(state.element, 'd3pie-labels-truncation-enabled', false), + truncateLength: NETDATA.dataAttribute(state.element, 'd3pie-labels-truncation-truncatelength', 30) + }, + formatter: function (context) { + // console.log(context); + if (context.part === 'value') { + return state.legendFormatValue(context.value); + } + if (context.part === 'percentage') { + return context.label + '%'; + } + + return context.label; + } + }, + effects: { + load: { + effect: "none", // none / default + speed: 0 // commented in the d3pie code to speed it up + }, + pullOutSegmentOnClick: { + effect: "bounce", // none / linear / bounce / elastic / back + speed: 400, + size: 5 + }, + highlightSegmentOnMouseover: true, + highlightLuminosity: -0.2 + }, + tooltips: { + enabled: false, + type: "placeholder", // caption|placeholder + string: "", + placeholderParser: null, // function + styles: { + fadeInSpeed: 250, + backgroundColor: NETDATA.themes.current.d3pie.tooltip_bg, + backgroundOpacity: 0.5, + color: NETDATA.themes.current.d3pie.tooltip_fg, + borderRadius: 2, + font: "arial", + fontSize: 12, + padding: 4 + } + }, + misc: { + colors: { + background: 'transparent', // transparent or color # + // segments: state.chartColors(), + segmentStroke: NETDATA.dataAttribute(state.element, 'd3pie-misc-colors-segmentstroke', NETDATA.themes.current.d3pie.segment_stroke) + }, + gradient: { + enabled: NETDATA.dataAttributeBoolean(state.element, 'd3pie-misc-gradient-enabled', false), + percentage: NETDATA.dataAttribute(state.element, 'd3pie-misc-colors-percentage', 95), + color: NETDATA.dataAttribute(state.element, 'd3pie-misc-gradient-color', NETDATA.themes.current.d3pie.gradient_color) + }, + canvasPadding: { + top: 5, + right: 5, + bottom: 5, + left: 5 + }, + pieCenterOffset: { + x: 0, + y: 0 + }, + cssPrefix: NETDATA.dataAttribute(state.element, 'd3pie-cssprefix', null) + }, + callbacks: { + onload: null, + onMouseoverSegment: null, + onMouseoutSegment: null, + onClickSegment: null + } + }; + + state.d3pie_instance = new d3pie(state.element_chart, state.d3pie_options); + return true; +}; diff --git a/web/gui/src/dashboard.js/charting/dygraph.js b/web/gui/src/dashboard.js/charting/dygraph.js new file mode 100644 index 00000000..4b44e7c4 --- /dev/null +++ b/web/gui/src/dashboard.js/charting/dygraph.js @@ -0,0 +1,1065 @@ +// dygraph + +// Codacy declarations +/* global smoothPlotter */ +/* global 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'); + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + state.tmp.dygraph_user_action = true; + state.tmp.dygraph_force_zoom = true; + // state.log('toolboxPanAndZoom'); + state.updateChartPanOrZoom(after, before); + NETDATA.globalPanAndZoom.setMaster(state, after, before); +}; + +NETDATA.dygraphSetSelection = function (state, t) { + if (typeof state.tmp.dygraph_instance !== 'undefined') { + let r = state.calculateRowForTime(t); + if (r !== -1) { + state.tmp.dygraph_instance.setSelection(r); + return true; + } else { + state.tmp.dygraph_instance.clearSelection(); + state.legendShowUndefined(); + } + } + + return false; +}; + +NETDATA.dygraphClearSelection = function (state) { + if (typeof state.tmp.dygraph_instance !== 'undefined') { + state.tmp.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") { + return 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 && NETDATA.options.current.smooth_plot) { + NETDATA.dygraphSmoothInitialize(callback); + } else if (typeof callback === "function") { + return callback(); + } + }); + } else { + NETDATA.chartLibraries.dygraph.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } +}; + +NETDATA.dygraphChartUpdate = function (state, data) { + let dygraph = state.tmp.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.tmp.dygraph_last_rendered) { + dygraph.resize(); + } + + let options = { + file: data.result.data, + colors: state.chartColors(), + labels: data.result.labels, + //labelsDivWidth: state.chartWidth() - 70, + includeZero: state.tmp.dygraph_include_zero, + visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names) + }; + + if (state.tmp.dygraph_chart_type === 'stacked') { + if (options.includeZero && state.dimensions_visibility.countSelected() < options.visibility.length) { + options.includeZero = 0; + } + } + + if (!NETDATA.chartLibraries.dygraph.isSparkline(state)) { + options.ylabel = state.units_current; // (state.units_desired === 'auto')?"":state.units_current; + } + + if (state.tmp.dygraph_force_zoom) { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphChartUpdate() forced zoom update'); + } + + options.dateWindow = (state.requested_padding !== null) ? [state.view_after, state.view_before] : null; + //options.isZoomedIgnoreProgrammaticZoom = true; + state.tmp.dygraph_force_zoom = false; + } else if (state.current.name !== 'auto') { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphChartUpdate() loose update'); + } + } else { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphChartUpdate() strict update'); + } + + options.dateWindow = (state.requested_padding !== null) ? [state.view_after, state.view_before] : null; + //options.isZoomedIgnoreProgrammaticZoom = true; + } + + options.valueRange = state.tmp.dygraph_options.valueRange; + + let oldMax = null, oldMin = null; + if (state.tmp.__commonMin !== null) { + state.data.min = state.tmp.dygraph_instance.axes_[0].extremeRange[0]; + oldMin = options.valueRange[0] = NETDATA.commonMin.get(state); + } + if (state.tmp.__commonMax !== null) { + state.data.max = state.tmp.dygraph_instance.axes_[0].extremeRange[1]; + oldMax = options.valueRange[1] = NETDATA.commonMax.get(state); + } + + if (state.tmp.dygraph_smooth_eligible) { + if ((NETDATA.options.current.smooth_plot && state.tmp.dygraph_options.plotter !== smoothPlotter) + || (NETDATA.options.current.smooth_plot === false && state.tmp.dygraph_options.plotter === smoothPlotter)) { + NETDATA.dygraphChartCreate(state, data); + return; + } + } + + if (netdataSnapshotData !== null && NETDATA.globalPanAndZoom.isActive() && NETDATA.globalPanAndZoom.isMaster(state) === false) { + // pan and zoom on snapshots + options.dateWindow = [NETDATA.globalPanAndZoom.force_after_ms, NETDATA.globalPanAndZoom.force_before_ms]; + //options.isZoomedIgnoreProgrammaticZoom = true; + } + + if (NETDATA.chartLibraries.dygraph.isLogScale(state)) { + if (Array.isArray(options.valueRange) && options.valueRange[0] <= 0) { + options.valueRange[0] = null; + } + } + + dygraph.updateOptions(options); + + let redraw = false; + if (oldMin !== null && oldMin > state.tmp.dygraph_instance.axes_[0].extremeRange[0]) { + state.data.min = state.tmp.dygraph_instance.axes_[0].extremeRange[0]; + options.valueRange[0] = NETDATA.commonMin.get(state); + redraw = true; + } + if (oldMax !== null && oldMax < state.tmp.dygraph_instance.axes_[0].extremeRange[1]) { + state.data.max = state.tmp.dygraph_instance.axes_[0].extremeRange[1]; + options.valueRange[1] = NETDATA.commonMax.get(state); + redraw = true; + } + + if (redraw) { + // state.log('forcing redraw to adapt to common- min/max'); + dygraph.updateOptions(options); + } + + state.tmp.dygraph_last_rendered = Date.now(); + return true; +}; + +NETDATA.dygraphChartCreate = function (state, data) { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphChartCreate()'); + } + + state.tmp.dygraph_chart_type = NETDATA.dataAttribute(state.element, 'dygraph-type', state.chart.chart_type); + if (state.tmp.dygraph_chart_type === 'stacked' && data.dimensions === 1) { + state.tmp.dygraph_chart_type = 'area'; + } + if (state.tmp.dygraph_chart_type === 'stacked' && NETDATA.chartLibraries.dygraph.isLogScale(state)) { + state.tmp.dygraph_chart_type = 'area'; + } + + let highlightCircleSize = NETDATA.chartLibraries.dygraph.isSparkline(state) ? 3 : 4; + + let smooth = NETDATA.dygraph.smooth + ? (NETDATA.dataAttributeBoolean(state.element, 'dygraph-smooth', (state.tmp.dygraph_chart_type === 'line' && NETDATA.chartLibraries.dygraph.isSparkline(state) === false))) + : false; + + state.tmp.dygraph_include_zero = NETDATA.dataAttribute(state.element, 'dygraph-includezero', (state.tmp.dygraph_chart_type === 'stacked')); + let drawAxis = NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawaxis', true); + + state.tmp.dygraph_options = { + colors: NETDATA.dataAttribute(state.element, 'dygraph-colors', state.chartColors()), + + // leave a few pixels empty on the right of the chart + rightGap: NETDATA.dataAttribute(state.element, 'dygraph-rightgap', 5), + showRangeSelector: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showrangeselector', false), + showRoller: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showroller', false), + title: NETDATA.dataAttribute(state.element, 'dygraph-title', state.title), + titleHeight: NETDATA.dataAttribute(state.element, 'dygraph-titleheight', 19), + legend: NETDATA.dataAttribute(state.element, 'dygraph-legend', 'always'), // we need this to get selection events + labels: data.result.labels, + labelsDiv: NETDATA.dataAttribute(state.element, 'dygraph-labelsdiv', state.element_legend_childs.hidden), + //labelsDivStyles: NETDATA.dataAttribute(state.element, 'dygraph-labelsdivstyles', { 'fontSize':'1px' }), + //labelsDivWidth: NETDATA.dataAttribute(state.element, 'dygraph-labelsdivwidth', state.chartWidth() - 70), + labelsSeparateLines: NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsseparatelines', true), + labelsShowZeroValues: NETDATA.chartLibraries.dygraph.isLogScale(state) ? false : NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsshowzerovalues', true), + labelsKMB: false, + labelsKMG2: false, + showLabelsOnHighlight: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showlabelsonhighlight', true), + hideOverlayOnMouseOut: NETDATA.dataAttributeBoolean(state.element, 'dygraph-hideoverlayonmouseout', true), + includeZero: state.tmp.dygraph_include_zero, + xRangePad: NETDATA.dataAttribute(state.element, 'dygraph-xrangepad', 0), + yRangePad: NETDATA.dataAttribute(state.element, 'dygraph-yrangepad', 1), + valueRange: NETDATA.dataAttribute(state.element, 'dygraph-valuerange', [null, null]), + ylabel: state.units_current, // (state.units_desired === 'auto')?"":state.units_current, + yLabelWidth: NETDATA.dataAttribute(state.element, '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: NETDATA.dataAttribute(state.element, 'dygraph-strokewidth', ((state.tmp.dygraph_chart_type === 'stacked') ? 0.1 : ((smooth === true) ? 1.5 : 0.7))), + strokePattern: NETDATA.dataAttribute(state.element, '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: NETDATA.dataAttributeBoolean(state.element, '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: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawgapedgepoints', true), + connectSeparatedPoints: NETDATA.chartLibraries.dygraph.isLogScale(state) ? false : NETDATA.dataAttributeBoolean(state.element, 'dygraph-connectseparatedpoints', false), + pointSize: NETDATA.dataAttribute(state.element, 'dygraph-pointsize', 1), + + // enabling this makes the chart with little square lines + stepPlot: NETDATA.dataAttributeBoolean(state.element, 'dygraph-stepplot', false), + + // Draw a border around graph lines to make crossing lines more easily + // distinguishable. Useful for graphs with many lines. + strokeBorderColor: NETDATA.dataAttribute(state.element, 'dygraph-strokebordercolor', NETDATA.themes.current.background), + strokeBorderWidth: NETDATA.dataAttribute(state.element, 'dygraph-strokeborderwidth', (state.tmp.dygraph_chart_type === 'stacked') ? 0.0 : 0.0), + fillGraph: NETDATA.dataAttribute(state.element, 'dygraph-fillgraph', (state.tmp.dygraph_chart_type === 'area' || state.tmp.dygraph_chart_type === 'stacked')), + fillAlpha: NETDATA.dataAttribute(state.element, 'dygraph-fillalpha', + ((state.tmp.dygraph_chart_type === 'stacked') + ? NETDATA.options.current.color_fill_opacity_stacked + : NETDATA.options.current.color_fill_opacity_area) + ), + stackedGraph: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraph', (state.tmp.dygraph_chart_type === 'stacked')), + stackedGraphNaNFill: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraphnanfill', 'none'), + drawAxis: drawAxis, + axisLabelFontSize: NETDATA.dataAttribute(state.element, 'dygraph-axislabelfontsize', 10), + axisLineColor: NETDATA.dataAttribute(state.element, 'dygraph-axislinecolor', NETDATA.themes.current.axis), + axisLineWidth: NETDATA.dataAttribute(state.element, 'dygraph-axislinewidth', 1.0), + drawGrid: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawgrid', true), + gridLinePattern: NETDATA.dataAttribute(state.element, 'dygraph-gridlinepattern', null), + gridLineWidth: NETDATA.dataAttribute(state.element, 'dygraph-gridlinewidth', 1.0), + gridLineColor: NETDATA.dataAttribute(state.element, 'dygraph-gridlinecolor', NETDATA.themes.current.grid), + maxNumberWidth: NETDATA.dataAttribute(state.element, 'dygraph-maxnumberwidth', 8), + sigFigs: NETDATA.dataAttribute(state.element, 'dygraph-sigfigs', null), + digitsAfterDecimal: NETDATA.dataAttribute(state.element, 'dygraph-digitsafterdecimal', 2), + valueFormatter: NETDATA.dataAttribute(state.element, 'dygraph-valueformatter', undefined), + highlightCircleSize: NETDATA.dataAttribute(state.element, 'dygraph-highlightcirclesize', highlightCircleSize), + highlightSeriesOpts: NETDATA.dataAttribute(state.element, 'dygraph-highlightseriesopts', null), // TOO SLOW: { strokeWidth: 1.5 }, + highlightSeriesBackgroundAlpha: NETDATA.dataAttribute(state.element, 'dygraph-highlightseriesbackgroundalpha', null), // TOO SLOW: (state.tmp.dygraph_chart_type === 'stacked')?0.7:0.5, + pointClickCallback: NETDATA.dataAttribute(state.element, 'dygraph-pointclickcallback', undefined), + visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names), + logscale: NETDATA.chartLibraries.dygraph.isLogScale(state) ? 'y' : undefined, + + // Expects a string in the format ": + diff --git a/web/gui/v1/dashboard-react.js b/web/gui/v1/dashboard-react.js new file mode 100644 index 00000000..aa067a72 --- /dev/null +++ b/web/gui/v1/dashboard-react.js @@ -0,0 +1,675 @@ +/* eslint-disable */ + +/** + * after react-dashboard refractor, this file can be renamed to 'dashboard.js' + * and it will: + * - setup global objects, so any assignments like 'NETDATA.options.current.destroy_on_hide = true' + * will not break. we need to add it in places where 'dashboard.js' is + * - create react root DOM node + * - load react app + * + * Later, for performance improvement, the bundle can be added to dashboard-rect.js, + * but we need to run the react-app part after DOM is created and ready + */ + +// ---------------------------------------------------------------------------- +// global namespace + +// Should stay var! +var NETDATA = window.NETDATA || {}; +window.NETDATA = NETDATA // when imported as npm module + +/// A heuristic for detecting slow devices. +let isSlowDeviceResult; +const isSlowDevice = function () { + if (!isSlowDeviceResult) { + return isSlowDeviceResult; + } + + try { + let ua = navigator.userAgent.toLowerCase(); + + let iOS = /ipad|iphone|ipod/.test(ua) && !window.MSStream; + let android = /android/.test(ua) && !window.MSStream; + isSlowDeviceResult = (iOS || android); + } catch (e) { + isSlowDeviceResult = false; + } + + return isSlowDeviceResult; +}; + +if (typeof window.netdataSnapshotData === 'undefined') { + window.netdataSnapshotData = null; +} + +if (typeof window.netdataShowHelp === 'undefined') { + window.netdataShowHelp = true; +} + +if (typeof window.netdataShowAlarms === 'undefined') { + window.netdataShowAlarms = false; +} + +if (typeof window.netdataRegistryAfterMs !== 'number' || window.netdataRegistryAfterMs < 0) { + window.netdataRegistryAfterMs = 0; // 1500; +} + +if (typeof window.netdataRegistry === 'undefined') { + // backward compatibility + window.netdataRegistry = (typeof netdataNoRegistry !== 'undefined' && netdataNoRegistry === false); +} + +if (window.netdataRegistry === false && typeof netdataRegistryCallback === 'function') { + window.netdataRegistry = true; +} + +// ---------------------------------------------------------------------------------------------------------------- +// the defaults for all charts + +// if the user does not specify any of these, the following will be used + +NETDATA.chartDefaults = { + 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 solid areas +}; + + + +// ---------------------------------------------------------------------------------------------------------------- +// global options + +NETDATA.options = { + pauseCallback: null, // a callback when we are really paused + + pause: false, // when enabled we don't auto-refresh the charts + + targets: [], // 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. + + auto_refresher_fast_weight: 0, // this is the current time in ms, spent + // rendering charts continuously. + // used with .current.fast_render_timeframe + + page_is_visible: true, // when true, this page is visible + + auto_refresher_stop_until: 0, // timestamp in ms - used internally, 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 + + on_scroll_refresher_stop_until: 0, // timestamp in ms - used to stop evaluating + // charts for some time, after a page scroll + + last_page_resize: Date.now(), // the timestamp of the last resize request + + last_page_scroll: 0, // the timestamp the last time the page was scrolled + + browser_timezone: (Intl && Intl.DateTimeFormat) + ? Intl.DateTimeFormat().resolvedOptions().timeZone // timezone detected by javascript + : "cannot-detect-it", + + server_timezone: 'unknown', // timezone reported by the server + + force_data_points: 0, // force the number of points to be returned for charts + fake_chart_rendering: false, // when set to true, the dashboard will download data but will not render the charts + + passive_events: null, // true if the browser supports passive events + + // the current profile + // we may have many... + current: { + units: 'auto', // can be 'auto' or 'original' + temperature: 'celsius', // can be 'celsius' or 'fahrenheit' + seconds_as_time: true, // show seconds as DDd:HH:MM:SS ? + timezone: 'default', // the timezone to use, or 'default' + user_set_server_timezone: 'default', // as set by the user on the dashboard + + legend_toolbox: true, // show the legend toolbox on charts + resize_charts: true, // show the resize handler on charts + + pixels_per_point: isSlowDevice() ? 5 : 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 + + fast_render_timeframe: 200, // ms - render continuously until this time of continuous + // 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_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 + + global_pan_sync_time: 300, // ms - when you pan or zoom a chart, the background + // auto-refreshing of charts is paused for this amount + // of time + + sync_selection_delay: 400, // 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 often 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 / used for printing + + parallel_refresher: !isSlowDevice(), // enable parallel refresh of charts + + concurrent_refreshes: true, // when parallel_refresher is enabled, sync also the charts + + destroy_on_hide: isSlowDevice(), // destroy charts when they are not visible + + // when enabled the charts will show some help + // when there's no bootstrap, we can't show it + show_help: netdataShowHelp && !window.netdataNoBootstrap, + 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: !isSlowDevice(), // enable smooth plot, where possible + + color_fill_opacity_line: 1.0, + color_fill_opacity_area: 0.2, + color_fill_opacity_fake_stacked: 1, + 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, // kill pending ajax page scroll + async_on_scroll: false, // sync/async onscroll handler + onscroll_worker_duration_threshold: 30, // time in ms, for async scroll handler + + retries_on_data_failures: 3, // how many retries to make if we can't fetch chart data from the server + + setOptionCallback: function () { + } + }, + + debug: { + show_boxes: false, + main_loop: false, + focus: false, + visibility: false, + chart_data_url: false, + chart_errors: true, // remember to set it to false before merging + chart_timing: false, + chart_calls: false, + libraries: false, + dygraph: false, + globalSelectionSync: false, + globalPanAndZoom: false + } +}; + + +NETDATA.statistics = { + refreshes_total: 0, + refreshes_active: 0, + refreshes_active_max: 0 +}; + +NETDATA.themes = { + white: { + bootstrap_css: "css/bootstrap-3.3.7.css", + dashboard_css: "css/dashboard.css?v20180210-1", + background: "#FFFFFF", + foreground: "#000000", + grid: "#F0F0F0", + axis: "#F0F0F0", + highlight: "#F5F5F5", + 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, + gauge_stop_color: "#FC8D5E", + gauge_start_color: "#B0E952", + d3pie: { + title: "#333333", + subtitle: "#666666", + footer: "#888888", + other: "#aaaaaa", + mainlabel: "#333333", + percentage: "#dddddd", + value: "#aaaa22", + tooltip_bg: "#000000", + tooltip_fg: "#efefef", + segment_stroke: "#ffffff", + gradient_color: "#000000", + }, + }, + slate: { + bootstrap_css: "css/bootstrap-slate-flat-3.3.7.css?v20161229-1", + dashboard_css: "css/dashboard.slate.css?v20180210-1", + background: "#272b30", + foreground: "#C8C8C8", + grid: "#283236", + axis: "#283236", + highlight: "#383838", + 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, + gauge_stop_color: "#FC8D5E", + gauge_start_color: "#B0E952", + d3pie: { + title: "#C8C8C8", + subtitle: "#283236", + footer: "#283236", + other: "#283236", + mainlabel: "#C8C8C8", + percentage: "#dddddd", + value: "#cccc44", + tooltip_bg: "#272b30", + tooltip_fg: "#C8C8C8", + segment_stroke: "#283236", + gradient_color: "#000000", + }, + }, +} + +// Codacy declarations +/* global netdataTheme */ + +NETDATA.updateTheme = function () { + if (typeof window.netdataTheme !== 'undefined' + && typeof NETDATA.themes[netdataTheme] !== 'undefined' + ) { + NETDATA.themes.current = NETDATA.themes[window.netdataTheme]; + } else { + NETDATA.themes.current = NETDATA.themes.white; + } + + NETDATA.colors = NETDATA.themes.current.colors; +} + +NETDATA.updateTheme() + +// 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' ]; +// dygraph + +// local storage options + +NETDATA.localStorage = { + default: {}, + current: {}, + callback: {} // only used for resetting back to defaults +}; + + +// todo temporary stuff which was originally in dashboard.js +// but needs to be refactored +NETDATA.name2id = function (s) { + return s + .replace(/ /g, '_') + .replace(/:/g, '_') + .replace(/\(/g, '_') + .replace(/\)/g, '_') + .replace(/\./g, '_') + .replace(/\//g, '_'); +}; + +NETDATA.globalChartUnderlay = { + clear: () => {}, + init: () => {}, +} + +NETDATA.globalPanAndZoom = { + callback: () => {}, +} +NETDATA.unpause = () => {} + + +// ---------------------------------------------------------------------------------------------------------------- +// XSS checks + +NETDATA.xss = { + enabled: (typeof netdataCheckXSS === 'undefined') ? false : netdataCheckXSS, + enabled_for_data: (typeof netdataCheckXSS === 'undefined') ? false : netdataCheckXSS, + + string: function (s) { + return s.toString() + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + }, + + object: function (name, obj, ignore_regex) { + if (typeof ignore_regex !== 'undefined' && ignore_regex.test(name)) { + // console.log('XSS: ignoring "' + name + '"'); + return obj; + } + + switch (typeof(obj)) { + case 'string': + const ret = this.string(obj); + if (ret !== obj) { + console.log('XSS protection changed string ' + name + ' from "' + obj + '" to "' + ret + '"'); + } + return ret; + + case 'object': + if (obj === null) { + return obj; + } + + if (Array.isArray(obj)) { + // console.log('checking array "' + name + '"'); + + let len = obj.length; + while (len--) { + obj[len] = this.object(name + '[' + len + ']', obj[len], ignore_regex); + } + } else { + // console.log('checking object "' + name + '"'); + + for (var i in obj) { + if (obj.hasOwnProperty(i) === false) { + continue; + } + if (this.string(i) !== i) { + console.log('XSS protection removed invalid object member "' + name + '.' + i + '"'); + delete obj[i]; + } else { + obj[i] = this.object(name + '.' + i, obj[i], ignore_regex); + } + } + } + return obj; + + default: + return obj; + } + }, + + checkOptional: function (name, obj, ignore_regex) { + if (this.enabled) { + //console.log('XSS: checking optional "' + name + '"...'); + return this.object(name, obj, ignore_regex); + } + return obj; + }, + + checkAlways: function (name, obj, ignore_regex) { + //console.log('XSS: checking always "' + name + '"...'); + return this.object(name, obj, ignore_regex); + }, + + checkData: function (name, obj, ignore_regex) { + if (this.enabled_for_data) { + //console.log('XSS: checking data "' + name + '"...'); + return this.object(name, obj, ignore_regex); + } + return obj; + } +}; + + + +const fixHost = (host) => { + while (host.slice(-1) === '/') { + host = host.substring(0, host.length - 1); + } + + return host.replace(/\/v1\/?$/, ""); +} + +NETDATA.chartRegistry = { + charts: {}, + + globalReset: function () { + this.charts = {}; + }, + + add: function (host, id, data) { + if (typeof this.charts[host] === 'undefined') { + this.charts[host] = {}; + } + + //console.log('added ' + host + '/' + id); + this.charts[host][id] = data; + }, + + get: function (host, 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) { + host = fixHost(host); + + let self = this; + + function got_data(h, data, callback) { + if (data !== null) { + self.charts[h] = data.charts; + window.charts = data.charts + + // update the server timezone in our options + if (typeof data.timezone === 'string') { + NETDATA.options.server_timezone = data.timezone; + } + } else { + NETDATA.error(406, h + '/api/v1/charts'); + } + + if (typeof callback === 'function') { + callback(data); + } + } + + if (window.netdataSnapshotData !== null) { + got_data(host, window.netdataSnapshotData.charts, callback); + } else { + $.ajax({ + url: host + '/api/v1/charts', + async: true, + cache: false, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/charts', data); + got_data(host, data, callback); + }) + .fail(function () { + NETDATA.error(405, host + '/api/v1/charts'); + + if (typeof callback === 'function') { + callback(null); + } + }); + } + } +}; + + +NETDATA.fixHost = function (host) { + while (host.slice(-1) === '/') { + host = host.substring(0, host.length - 1); + } + + return host.replace(/\/v1\/?$/, ""); +}; + + +NETDATA.registryHello = function (host, callback) { + host = NETDATA.fixHost(host); + + // 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, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/registry?action=hello', data); + + if (typeof data.status !== 'string' || data.status !== 'ok') { + // NETDATA.error(408, host + ' response: ' + JSON.stringify(data)); + data = null; + } + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + // NETDATA.error(407, host); + + if (typeof callback === 'function') { + return callback(null); + } + }); +} + +NETDATA.registrySearch = function (machine_guid, getFromRegistry, serverDefault, callback) { + // SEARCH for the URLs of a machine: + $.ajax({ + url: getFromRegistry("registryServer") + '/api/v1/registry?action=search&machine=' + + getFromRegistry("machineGuid") + '&name=' + encodeURIComponent(getFromRegistry("hostname")) + + '&url=' + encodeURIComponent(serverDefault) + '&for=' + machine_guid, + async: true, + cache: false, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkAlways('/api/v1/registry?action=search', data); + + if (typeof data.status !== 'string' || data.status !== 'ok') { + // NETDATA.error(417, getFromRegistry("registryServer") + ' responded with: ' + JSON.stringify(data)); + console.warn(getFromRegistry("registryServer") + ' responded with: ' + JSON.stringify(data)); + data = null; + } + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + // NETDATA.error(418, getFromRegistry("registryServer")); + console.warn("registry search call failed", getFromRegistry("registryServer")) + + if (typeof callback === 'function') { + return callback(null); + } + }); +} + +NETDATA.registryDelete = function (getFromRegistry, serverDefault, delete_url, callback) { + // send DELETE to a netdata registry: + $.ajax({ + url: getFromRegistry("registryServer") + '/api/v1/registry?action=delete&machine=' + + getFromRegistry("machineGuid") + '&name=' + encodeURIComponent(getFromRegistry("hostname")) + + '&url=' + encodeURIComponent(serverDefault) + '&delete_url=' + encodeURIComponent(delete_url), + // + '&url=' + encodeURIComponent("http://n5.katsuna.com:19999/") + '&delete_url=' + encodeURIComponent(delete_url), + async: true, + cache: false, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + // data = NETDATA.xss.checkAlways('/api/v1/registry?action=delete', data); + + if (typeof data.status !== 'string' || data.status !== 'ok') { + // NETDATA.error(411, NETDATA.registry.server + ' responded with: ' + JSON.stringify(data)); + console.warn(411, getFromRegistry("registryServer") + ' responded with: ' + JSON.stringify(data)); + data = null; + } + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + // NETDATA.error(412, NETDATA.registry.server); + console.warn(412, getFromRegistry("registryServer")); + + if (typeof callback === 'function') { + return callback(null); + } + }); +} + + +// NETDATA.currentScript = document.currentScript diff --git a/web/gui/v1/dashboard.css b/web/gui/v1/dashboard.css new file mode 100644 index 00000000..2d95a331 --- /dev/null +++ b/web/gui/v1/dashboard.css @@ -0,0 +1,785 @@ +/* SPDX-License-Identfier: GPL-3.0-or-later */ +:root { + --color-main: #35414A; + --color-primary: #00ab44; + --color-border: #93a3b0; +} + +html, +body { + /*font-family: Calibri,"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif;*/ + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-style: normal; + font-variant: normal; +} + +.morelink { + color: var(--color-attention, #765d9c); + text-decoration: none; +} + +.morelink:hover { + color: var(--color-attentionSecondary, #563d7c); + text-decoration: none; +} + +.morelink:focus { + color: var(--color-attention, #765d9c); + text-decoration: none; +} + +.netdata-chart-alignment { + /* 55 for legend-right */ + margin-left: 35px; +} + +.netdata-chart-row { + width: 100%; + text-align: center; + display: flex; + display: -webkit-flex; + display: -moz-flex; + align-items: baseline; + -moz-align-items: baseline; + -webkit-align-items: baseline; + justify-content: center; + -webkit-justify-content: center; + -moz-justify-content: center; + padding-top: 10px; +} + +.netdata-container { + display: inline-block; + overflow: hidden; + + transform: translate3d(0,0,0); + + /* required for child elements to have absolute position */ + position: relative; + + /* width and height is given per chart with data-width and data-height */ +} + +.netdata-container-gauge { + display: inline-block; + overflow: hidden; + + transform: translate3d(0,0,0); + + /* required for child elements to have absolute position */ + position: relative; + + /* width and height is given per chart with data-width and data-height */ +} + +.netdata-container-gauge:after { + padding-top: 60%; + display: block; + content: ''; +} + +.netdata-container-easypiechart { + display: inline-block; + overflow: hidden; + + transform: translate3d(0,0,0); + + /* required for child elements to have absolute position */ + position: relative; + + /* width and height is given per chart with data-width and data-height */ +} + +.netdata-container-easypiechart:after { + padding-top: 100%; + display: block; + content: ''; +} + +.netdata-aspect { + position: relative; + width: 100%; + padding: 0px; + margin: 0px; +} + +.netdata-container-with-legend { + display: inline-block; + overflow: hidden; + + transform: translate3d(0,0,0); + + /* fix minimum scrollbar issue in firefox */ + min-height: 99px; + + /* required for child elements to have absolute position */ + position: relative; + + /* width and height is given per chart with data-width and data-height */ +} + +.netdata-container-with-legend.netdata-container-with-legend--bottom { + display: flex; + flex-direction: column; +} + +.netdata-legend-resize-handler { + display: block; + position: absolute; + bottom: 0px; + right: 0px; + height: 15px; + width: 20px; + background-color: var(--color-mainBackground, #fff); + font-size: 15px; + vertical-align: middle; + line-height: 15px; + cursor: ns-resize; + color: var(--color-selected, #CDCDCD); + text-align: center; + overflow: hidden; + padding: 0px; + margin: 0px; +} + +.netdata-legend-toolbox { + display: block; + position: absolute; + bottom: 0px; + right: 0px; + height: 15px; + width: 110px; + font-size: 12px; + vertical-align: middle; + line-height: 15px; + color: var(--color-placeholder, #DDDDDD); + text-align: center; + overflow: hidden; + padding: 0px; + margin: 0px; + + /* prevent text selection after double click */ + -webkit-user-select: none; /* webkit (safari, chrome) browsers */ + -moz-user-select: none; /* mozilla browsers */ + -khtml-user-select: none; /* webkit (konqueror) browsers */ + -ms-user-select: none; /* IE10+ */ +} + +.netdata-legend-toolbox-button { + display: inline-block; + position: relative; + height: 15px; + width: 18px; + background-color: var(--color-mainBackground, #fff); + font-size: 12px; + vertical-align: middle; + line-height: 15px; + color: var(--color-selected, #CDCDCD); + text-align: center; + overflow: hidden; + padding: 0px; + margin: 0px; + cursor: pointer; + + /* prevent text selection after double click */ + -webkit-user-select: none; /* webkit (safari, chrome) browsers */ + -moz-user-select: none; /* mozilla browsers */ + -khtml-user-select: none; /* webkit (konqueror) browsers */ + -ms-user-select: none; /* IE10+ */ +} + +.netdata-message { + display: inline-block; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + text-align: left; + vertical-align: top; + font-weight: bold; + font-size: x-small; + overflow: hidden; + background: inherit; + z-index: 0; +} + +.netdata-message.hidden { + display: none; +} + +.netdata-message.icon { + color: var(--color-borderSecondary, #F8F8F8); + text-align: center; + vertical-align: middle; +} + +.netdata-chart-legend { + position: absolute; /* within .netdata-container */ + top: 26px; + bottom: 18px; + right: 0; + overflow-x: hidden; + overflow-y: auto; + text-overflow: ellipsis; + line-height: 14px; + display: block; + width: 140px; /* --legend-width */ + font-size: 10px; + margin-top: 5px; + text-align: left; + /* width and height is calculated (depends on the appearance of the legend) */ +} + +.netdata-legend-title-date { + font-size: 10px; + font-weight: normal; + margin-top: 0px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.netdata-legend-title-time { + font-size: 11px; + font-weight: bold; + margin-top: 0px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.netdata-legend-title-units { + position: absolute; + right: 10px; + float: right; + font-size: 11px; + vertical-align: top; + font-weight: normal; + margin-top: 0px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.netdata-legend-series { + position: absolute; + width: 140px; /* legend-width */ + height: calc(100% - 50px); + overflow: hidden; + text-overflow: ellipsis; + line-height: 14.5px; /* line spacing at the legend */ + display: block; + font-size: 10px; + margin-top: 0px; +} + +.netdata-legend-name-table-line { + display: inline-block; + width: 13px; + height: 4px; + border-width: 0px; + border-bottom-width: 2px; + border-bottom-style: solid; + border-bottom-color: white; +} + +.netdata-legend-name-table-area { + display: inline-block; + width: 13px; + height: 5px; + border-width: 1px; + border-top-width: 1px; + border-top-style: solid; + border-top-color: inherit; +} + +.netdata-legend-name-table-stacked { + display: inline-block; + width: 13px; + height: 5px; + border-width: 1px; + border-top-width: 1px; + border-top-style: solid; + border-top-color: inherit; +} + +.netdata-legend-name-tr { +} + +.netdata-legend-name-td { +} + +.netdata-legend-name { + text-align: left; + font-size: 11px; /* legend: dimension name size */ + font-weight: bold; + vertical-align: bottom; + margin-top: 0px; + z-index: 9; + padding: 0px; + width: 80px !important; + max-width: 80px !important; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + display: inline-block; + cursor: pointer; + -webkit-print-color-adjust: exact; +} + +.netdata-legend-value { + /*margin-left: 14px;*/ + position: absolute; + right: 10px; + float: right; + text-align: right; + font-size: 11px; /* legend: dimension value size */ + font-weight: bold; + vertical-align: bottom; + background-color: var(--color-mainBackground, #fff); + margin-top: 0px; + z-index: 10; + padding: 0px; + padding-left: 15px; + cursor: pointer; + /* -webkit-font-smoothing: none; */ +} + +.netdata-legend-value, .netdata-legend-name { + /* prevent highlight when shift-clicking */ + -webkit-user-select: none; + -ms-user-select: none; + -moz-user-select: none; + user-select: none; +} + +/* eslint recommends adding tabIndex for a11y, but the outline is showing on click */ +.netdata-legend-name:focus, .netdata-legend-value:focus { + outline: none; +} + +.netdata-legend-name.not-selected { + font-weight: normal; + opacity: 0.3; +} + +.netdata-chart { + position: absolute; /* within .netdata-container */ + top: 0; /* within .netdata-container */ + left: 0; /* within .netdata-container */ + display: inline-block; + overflow: hidden; + width: 100%; + height: 100%; + z-index: 5; + + /* width and height is calculated (depends on the appearance of the legend) */ +} + +.netdata-chart-with-legend-right { + position: absolute; /* within .netdata-container */ + top: 0; /* within .netdata-container */ + left: 0; /* within .netdata-container */ + display: block; + overflow: hidden; + margin-right: 140px; /* --legend-width */ + width: calc(100% - 140px); /* --legend-width */ + height: 100%; + z-index: 5; + flex-grow: 1; + + /* width and height is calculated (depends on the appearance of the legend) */ +} + +.netdata-chart-with-legend-bottom { + display: block; + overflow: hidden; + flex-grow: 1; +} + +.netdata-peity-chart { + +} + +.netdata-sparkline-chart { + +} + +.netdata-dygraph-chart { + +} + +.netdata-morris-chart { + +} + +.netdata-google-chart { + +} + +.dygraph-ylabel { +} + +.dygraph-axis-label-x { + overflow-x: hidden; +} + +.dygraph-label-rotate-left { + text-align: center; + /* See http://caniuse.com/#feat=transforms2d */ + transform: rotate(90deg); + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -o-transform: rotate(90deg); + -ms-transform: rotate(90deg); +} + +/* For y2-axis label */ +.dygraph-label-rotate-right { + text-align: center; + /* See http://caniuse.com/#feat=transforms2d */ + transform: rotate(-90deg); + -webkit-transform: rotate(-90deg); + -moz-transform: rotate(-90deg); + -o-transform: rotate(-90deg); + -ms-transform: rotate(-90deg); +} + +.dygraph-title { + /* 56 for legend-right */ + text-indent: 36px; + text-align: left; + position: absolute; + left: 0px; + top: 4px; + font-size: 11px; + font-weight: bold; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + +/* fix for sparkline tooltip under bootstrap */ +.jqstooltip { + width: auto !important; + height: auto !important; +} + +.easyPieChart { + position: relative; + text-align: center; +} + +.easyPieChart canvas { + position: absolute; + top: 0; + left: 0; +} + +.easyPieChartLabel { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 100%; + text-align: center; + color: var(--color-main); + font-weight: normal; + text-shadow: var(--color-elementBackground, #BBB) 0px 0px 1px; + /* -webkit-font-smoothing: none; */ +} + +.easyPieChartTitle { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 64%; + margin-left: 18% !important; + text-align: center; + color: var(--color-border, #999999); + font-weight: bold; +} + +.easyPieChartUnits { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 60%; + margin-left: 20% !important; + text-align: center; + color: var(--color-border, #999999); + font-weight: normal; +} + +.gaugeChart { + position: relative; + text-align: center; +} + +.gaugeChart canvas { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + z-index: 0; +} + +.gaugeChartLabel { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 100%; + text-align: center; + color: var(--color-main); + font-weight: bold; + z-index: 1; + text-shadow: var(--color-elementBackground, #777) 0px 0px 1px; + /* text-shadow: #CCC 1px 1px 0px, #CCC -1px -1px 0px, #CCC 1px -1px 0px, #CCC -1px 1px 0px; */ + /* -webkit-text-stroke: 1px #777; */ + /* -webkit-font-smoothing: none; */ +} + +.gaugeChartTitle { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 100%; + text-align: center; + color: var(--color-border, #999999); + font-weight: bold; +} + +.gaugeChartUnits { + display: inline-block; + position: absolute; + float: left; + left: 0; + bottom: 0; + width: 100%; + text-align: left; + margin-left: 5%; + color: var(--color-border, #999999); + font-weight: normal; +} + +.gaugeChartMin { + display: inline-block; + position: absolute; + float: left; + left: 0; + bottom: 8%; + width: 92%; + margin-left: 8%; + text-align: left; + color: var(--color-main); + font-weight: normal; +} + +.gaugeChartMax { + display: inline-block; + position: absolute; + float: left; + left: 0; + bottom: 8%; + width: 95%; + margin-right: 5%; + text-align: right; + color: var(--color-main); + font-weight: normal; +} + +.popover-title { + font-weight: bold; + font-size: 12px; +} + +.popover-content { + font-size: 11px; +} + +/* ---------------------------------------------------------------------------- + perfect-scrollbar settings + */ + +.ps-container { + -ms-touch-action: auto; + touch-action: auto; + overflow: hidden !important; + -ms-overflow-style: none; +} + +@supports (-ms-overflow-style: none) { + .ps-container { + overflow: auto !important; + } +} + +@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { + .ps-container { + overflow: auto !important; + } +} + +.ps-container.ps-active-x > .ps-scrollbar-x-rail, +.ps-container.ps-active-y > .ps-scrollbar-y-rail { + display: block; + background-color: transparent; +} + +.ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { + background-color: transparent; /* background color when dragged away */ + opacity: 0.9; +} + +.ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { + background-color: #aaa; /* scrollbar color when dragged away */ + height: 5px; +} + +.ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { + background-color: transparent; /* background color when dragged away */ + opacity: 0.9; +} + +.ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { + background-color: #aaa; /* scrollbar color when dragged away */ + width: 5px; +} + +.ps-container > .ps-scrollbar-x-rail { + display: none; + position: absolute; + /* please don't change 'position' */ + opacity: 0.2; /* the opacity when not on hover of the content */ + -webkit-transition: background-color .2s linear, opacity .2s linear; + -o-transition: background-color .2s linear, opacity .2s linear; + -moz-transition: background-color .2s linear, opacity .2s linear; + transition: background-color .2s linear, opacity .2s linear; + bottom: 0px; + /* there must be 'bottom' for ps-scrollbar-x-rail */ + height: 15px; +} + +.ps-container > .ps-scrollbar-x-rail > .ps-scrollbar-x { + position: absolute; + /* please don't change 'position' */ + background-color: var(--color-elementBackground, #666); /* #aaa; the color on content hover */ + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + -o-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + -moz-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + bottom: 2px; + /* there must be 'bottom' for ps-scrollbar-x */ + height: 5px; /* the width of the scrollbar */ +} + +.ps-container > .ps-scrollbar-x-rail:hover > .ps-scrollbar-x, .ps-container > .ps-scrollbar-x-rail:active > .ps-scrollbar-x { + height: 4px; +} + +.ps-container > .ps-scrollbar-y-rail { + display: none; + position: absolute; + /* please don't change 'position' */ + opacity: 0.2; /* the opacity when not on hover of the content */ + -webkit-transition: background-color .2s linear, opacity .2s linear; + -o-transition: background-color .2s linear, opacity .2s linear; + -moz-transition: background-color .2s linear, opacity .2s linear; + transition: background-color .2s linear, opacity .2s linear; + right: 0; + /* there must be 'right' for ps-scrollbar-y-rail */ + width: 15px; +} + +.ps-container > .ps-scrollbar-y-rail > .ps-scrollbar-y { + position: absolute; + /* please don't change 'position' */ + background-color: var(--color-elementBackground, #666); /* #aaa; the color on content hover */ + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + -o-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + -moz-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + right: 2px; + /* there must be 'right' for ps-scrollbar-y */ + width: 5px; /* the width of the scrollbar */ +} + +.ps-container > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y, .ps-container > .ps-scrollbar-y-rail:active > .ps-scrollbar-y { + width: 5px; +} + +.ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { + background-color: transparent; /* background color when dragged */ + opacity: 0.9; +} + +.ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { + background-color: #bbb; /* scrollbar color when dragged */ + height: 5px; +} + +.ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { + background-color: transparent; /* background color when dragged */ + opacity: 0.9; +} + +.ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { + background-color: #bbb; /* scrollbar color when dragged */ + width: 5px; +} + +.ps-container:hover > .ps-scrollbar-x-rail, +.ps-container:hover > .ps-scrollbar-y-rail { + opacity: 0.6; +} + +.ps-container:hover > .ps-scrollbar-x-rail:hover { + background-color: transparent; /* the background color on hover of the scrollbar */ + opacity: 0.9; +} + +.ps-container:hover > .ps-scrollbar-x-rail:hover > .ps-scrollbar-x { + background-color: #999; /* scrollbar color on hover */ +} + +.ps-container:hover > .ps-scrollbar-y-rail:hover { + background-color: transparent; /* the background color on hover of the scrollbar */ + opacity: 0.9; +} + +.ps-container:hover > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y { + background-color: #999; /* scrollbar color on hover */ +} + +.dygraph__history-tip { + position: absolute; + transform: translateY(-50%); + display: none; /* overridden in js */ + margin-right: 25px; + direction: rtl; + overflow: hidden; + pointer-events: none; +} + +.dygraph__history-tip-content { + display: inline-block; + white-space: nowrap; + direction: ltr; + pointer-events: auto; +} diff --git a/web/gui/v1/dashboard.html b/web/gui/v1/dashboard.html new file mode 100644 index 00000000..be0febf7 --- /dev/null +++ b/web/gui/v1/dashboard.html @@ -0,0 +1,699 @@ + + + + + Netdata Dashboard + + + + + + + + + + + + + + + + + + + + +
    + +

    Netdata Custom Dashboard

    + +This is a template for building custom dashboards. To build a dashboard you just do this: + +
    +<!DOCTYPE html>
    +<html lang="en">
    +<head>
    +    <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">
    +</head>
    +<body>
    +    <div data-netdata="system.processes"
    +        data-chart-library="dygraph"
    +        data-width="600"
    +        data-height="200"
    +        data-after="-600"
    +        ></div>
    +</body>
    +<script type="text/javascript" src="http://netdata.server:19999/dashboard.js"></script>
    +</html>
    +
    + +
      +
    • You can host your dashboard anywhere.
    • +
    • You can add as many charts as you like.
    • +
    • You can have charts from many different netdata servers (add
      data-host="http://another.netdata.server:19999/"
      to each chart).
    • +
    • You can use different chart libraries on the same page: peity, sparkline, dygraph, google
    • +
    • You can customize each chart to your preferences. For each chart library most of their attributes can be given in data- attributes.
    • +
    • Each chart can have each own duration - it is controlled with the data-after attribute to give that many seconds of data.
    • +
    • Depending on the width of the chart and data-after 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 yield in a chart updated once every 3 seconds.
    • +
    + + +
    +

    Sparkline Charts

    +Sparkline charts support 'NULL' values, so the charts can indicate that values are missing. +Sparkline charts stretch the values to show the variations between values in more detail. +They also have mouse-hover support. +
    +Sparklines are fantastic. You can inline charts in text. For example this +
    is my current cpu usage (last 30 seconds), + while this +
    is the bandwidth my netdata server is currently transmitting (last minute) + and this +
    is the requests/sec it serves (last 3 minutes). + +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    + + + +
    +

    Peity Charts

    +Peity charts do not support 'NULL' values, so the charts cannot indicate that values are missing. +Peity charts cannot have multiple dimensions on the charts - so netdata will use 'min2max' to show +the total of all dimensions. +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    + + + + +
    +

    Dygraph Charts

    +The fastest charting engine that can chart complete charts (not just sparklines). +The charts are zoomable (drag their contents to pan, shift with mouse wheel to zoom-in or zoom-out, double click to reset it). +Netdata magic! Realtime charts on your web page! +
    +Sparklines using dygraphs +
    + are also possible! This +
    + is an area chart, while this +
    is a stacked area chart! + + +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    + + + +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    + + + +
    +

    EasyPieChart

    +
    +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    + + +
    +

    Gauge.js

    +
    +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    + + +
    +

    Google Charts

    +Netdata was originally developed with Google Charts. +Netdata is a complete Google Visualization API provider. +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    +
    +
    +
    + rendered in X ms +
    + + + +
    +

    d3pie Charts

    +
    +
    +
    + rendered in X ms +
    + +
    +
    +
    + rendered in X ms +
    + +
    +
    +
    + rendered in X ms +
    +
    + + + + + + + + + + diff --git a/web/gui/v1/dashboard.js b/web/gui/v1/dashboard.js new file mode 100644 index 00000000..adb9ccf0 --- /dev/null +++ b/web/gui/v1/dashboard.js @@ -0,0 +1,10333 @@ +// SPDX-License-Identifier: GPL-3.0-or-later + +// DO NOT EDIT: This file is automatically generated from the source files in src/ + +// ---------------------------------------------------------------------------- +// You can set the following variables before loading this script: + +// 'use strict'; + +/*global netdataNoDygraphs *//* boolean, disable dygraph charts + * (default: false) */ +/*global netdataNoSparklines *//* boolean, disable sparkline charts + * (default: false) */ +/*global netdataNoPeitys *//* boolean, disable peity charts + * (default: false) */ +/*global netdataNoGoogleCharts *//* boolean, disable google charts + * (default: false) */ +/*global netdataNoMorris *//* boolean, disable morris charts + * (default: false) */ +/*global netdataNoEasyPieChart *//* boolean, disable easypiechart charts + * (default: false) */ +/*global netdataNoGauge *//* boolean, disable gauge.js charts + * (default: false) */ +/*global netdataNoD3 *//* boolean, disable d3 charts + * (default: false) */ +/*global netdataNoC3 *//* boolean, disable c3 charts + * (default: false) */ +/*global netdataNoD3pie *//* boolean, disable d3pie charts + * (default: false) */ +/*global netdataNoBootstrap *//* boolean, disable bootstrap - disables help too + * (default: false) */ +/*global netdataNoFontAwesome *//* boolean, disable fontawesome (do not load it) + * (default: false) */ +/*global netdataIcons *//* object, overwrite netdata fontawesome icons + * (default: null) */ +/*global netdataDontStart *//* boolean, do not start the thread to process the charts + * (default: false) */ +/*global netdataErrorCallback *//* function, callback to be called when the dashboard encounters an error + * (default: null) */ +/*global netdataRegistry:true *//* boolean, use the netdata registry + * (default: false) */ +/*global netdataNoRegistry *//* boolean, included only for compatibility with existing custom dashboard + * (obsolete - do not use this any more) */ +/*global netdataRegistryCallback *//* function, callback that will be invoked with one param: the URLs from the registry + * (default: null) */ +/*global netdataShowHelp:true *//* boolean, disable charts help + * (default: true) */ +/*global netdataShowAlarms:true *//* boolean, enable alarms checks and notifications + * (default: false) */ +/*global netdataRegistryAfterMs:true *//* ms, delay registry use at started + * (default: 1500) */ +/*global netdataCallback *//* function, callback to be called when netdata is ready to start + * (default: null) + * netdata will be running while this is called + * (call NETDATA.pause to stop it) */ +/*global netdataPrepCallback *//* function, callback to be called before netdata does anything else + * (default: null) */ +/*global netdataServer *//* string, the URL of the netdata server to use + * (default: the URL the page is hosted at) */ +/*global netdataServerStatic *//* string, the URL of the netdata server to use for static files + * (default: netdataServer) */ +/*global netdataSnapshotData *//* object, a netdata snapshot loaded + * (default: null) */ +/*global netdataAlarmsRecipients *//* array, an array of alarm recipients to show notifications for + * (default: null) */ +/*global netdataAlarmsRemember *//* boolean, keep our position in the alarm log at browser local storage + * (default: true) */ +/*global netdataAlarmsActiveCallback *//* function, a hook for the alarm logs + * (default: undefined) */ +/*global netdataAlarmsNotifCallback *//* function, a hook for alarm notifications + * (default: undefined) */ +/*global netdataIntersectionObserver *//* boolean, enable or disable the use of intersection observer + * (default: true) */ +/*global netdataCheckXSS *//* boolean, enable or disable checking for XSS issues + * (default: false) */ + +// ---------------------------------------------------------------------------- +// global namespace + +// Should stay var! +var NETDATA = window.NETDATA || {}; + +(function(window, document, $, undefined) { + +// *** src/dashboard.js/utils.js + +NETDATA.name2id = function (s) { + return s + .replace(/ /g, '_') + .replace(/:/g, '_') + .replace(/\(/g, '_') + .replace(/\)/g, '_') + .replace(/\./g, '_') + .replace(/\//g, '_'); +}; + +NETDATA.encodeURIComponent = function (s) { + if (typeof(s) === 'string') { + return encodeURIComponent(s); + } + + return s; +}; + +/// A heuristic for detecting slow devices. +let isSlowDeviceResult = undefined; +const isSlowDevice = function () { + if (!isSlowDeviceResult) { + return isSlowDeviceResult; + } + + try { + let ua = navigator.userAgent.toLowerCase(); + + let iOS = /ipad|iphone|ipod/.test(ua) && !window.MSStream; + let android = /android/.test(ua) && !window.MSStream; + isSlowDeviceResult = (iOS || android); + } catch (e) { + isSlowDeviceResult = false; + } + + return isSlowDeviceResult; +}; + +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(); + } +}; + +NETDATA.seconds4human = function (seconds, options) { + let defaultOptions = { + now: 'now', + space: ' ', + negative_suffix: 'ago', + day: 'day', + days: 'days', + hour: 'hour', + hours: 'hours', + minute: 'min', + minutes: 'mins', + second: 'sec', + seconds: 'secs', + and: 'and' + }; + + if (typeof options !== 'object') { + options = defaultOptions; + } else { + for (var x in defaultOptions) { + if (typeof options[x] !== 'string') { + options[x] = defaultOptions[x]; + } + } + } + + if (typeof seconds === 'string') { + seconds = parseInt(seconds, 10); + } + + if (seconds === 0) { + return options.now; + } + + let suffix = ''; + if (seconds < 0) { + seconds = -seconds; + if (options.negative_suffix !== '') { + suffix = options.space + options.negative_suffix; + } + } + + let days = Math.floor(seconds / 86400); + seconds -= (days * 86400); + + let hours = Math.floor(seconds / 3600); + seconds -= (hours * 3600); + + let minutes = Math.floor(seconds / 60); + seconds -= (minutes * 60); + + let strings = []; + + if (days > 1) { + strings.push(days.toString() + options.space + options.days); + } else if (days === 1) { + strings.push(days.toString() + options.space + options.day); + } + + if (hours > 1) { + strings.push(hours.toString() + options.space + options.hours); + } else if (hours === 1) { + strings.push(hours.toString() + options.space + options.hour); + } + + if (minutes > 1) { + strings.push(minutes.toString() + options.space + options.minutes); + } else if (minutes === 1) { + strings.push(minutes.toString() + options.space + options.minute); + } + + if (seconds > 1) { + strings.push(Math.floor(seconds).toString() + options.space + options.seconds); + } else if (seconds === 1) { + strings.push(Math.floor(seconds).toString() + options.space + options.second); + } + + if (strings.length === 1) { + return strings.pop() + suffix; + } + + let last = strings.pop(); + return strings.join(", ") + " " + options.and + " " + last + suffix; +}; + +// ---------------------------------------------------------------------------------------------------------------- +// element data attributes + +NETDATA.dataAttribute = function (element, attribute, def) { + let key = 'data-' + attribute.toString(); + if (element.hasAttribute(key)) { + let data = element.getAttribute(key); + + if (data === 'true') { + return true; + } + if (data === 'false') { + return false; + } + if (data === 'null') { + return null; + } + + // Only convert to a number if it doesn't change the string + if (data === +data + '') { + return +data; + } + + if (/^(?:\{[\w\W]*\}|\[[\w\W]*\])$/.test(data)) { + return JSON.parse(data); + } + + return data; + } else { + return def; + } +}; + +NETDATA.dataAttributeBoolean = function (element, attribute, def) { + let value = NETDATA.dataAttribute(element, attribute, def); + + if (value === true || value === false) // gmosx: Love this :) + { + return value; + } + + if (typeof(value) === 'string') { + if (value === 'yes' || value === 'on') { + return true; + } + + if (value === '' || value === 'no' || value === 'off' || value === 'null') { + return false; + } + + return def; + } + + if (typeof(value) === 'number') { + return value !== 0; + } + + return def; +}; + +// ---------------------------------------------------------------------------------------------------------------- +// fast numbers formatting + +NETDATA.fastNumberFormat = { + formattersFixed: [], + formattersZeroBased: [], + + // this is the fastest and the preferred + getIntlNumberFormat: function (min, max) { + let key = max; + if (min === max) { + if (typeof this.formattersFixed[key] === 'undefined') { + this.formattersFixed[key] = new Intl.NumberFormat(undefined, { + // style: 'decimal', + // minimumIntegerDigits: 1, + // minimumSignificantDigits: 1, + // maximumSignificantDigits: 1, + useGrouping: true, + minimumFractionDigits: min, + maximumFractionDigits: max + }); + } + + return this.formattersFixed[key]; + } else if (min === 0) { + if (typeof this.formattersZeroBased[key] === 'undefined') { + this.formattersZeroBased[key] = new Intl.NumberFormat(undefined, { + // style: 'decimal', + // minimumIntegerDigits: 1, + // minimumSignificantDigits: 1, + // maximumSignificantDigits: 1, + useGrouping: true, + minimumFractionDigits: min, + maximumFractionDigits: max + }); + } + + return this.formattersZeroBased[key]; + } else { + // this is never used + // it is added just for completeness + return new Intl.NumberFormat(undefined, { + // style: 'decimal', + // minimumIntegerDigits: 1, + // minimumSignificantDigits: 1, + // maximumSignificantDigits: 1, + useGrouping: true, + minimumFractionDigits: min, + maximumFractionDigits: max + }); + } + }, + + // this respects locale + getLocaleString: function (min, max) { + let key = max; + if (min === max) { + if (typeof this.formattersFixed[key] === 'undefined') { + this.formattersFixed[key] = { + format: function (value) { + return value.toLocaleString(undefined, { + // style: 'decimal', + // minimumIntegerDigits: 1, + // minimumSignificantDigits: 1, + // maximumSignificantDigits: 1, + useGrouping: true, + minimumFractionDigits: min, + maximumFractionDigits: max + }); + } + }; + } + + return this.formattersFixed[key]; + } else if (min === 0) { + if (typeof this.formattersZeroBased[key] === 'undefined') { + this.formattersZeroBased[key] = { + format: function (value) { + return value.toLocaleString(undefined, { + // style: 'decimal', + // minimumIntegerDigits: 1, + // minimumSignificantDigits: 1, + // maximumSignificantDigits: 1, + useGrouping: true, + minimumFractionDigits: min, + maximumFractionDigits: max + }); + } + }; + } + + return this.formattersZeroBased[key]; + } else { + return { + format: function (value) { + return value.toLocaleString(undefined, { + // style: 'decimal', + // minimumIntegerDigits: 1, + // minimumSignificantDigits: 1, + // maximumSignificantDigits: 1, + useGrouping: true, + minimumFractionDigits: min, + maximumFractionDigits: max + }); + } + }; + } + }, + + // the fallback + getFixed: function (min, max) { + let key = max; + if (min === max) { + if (typeof this.formattersFixed[key] === 'undefined') { + this.formattersFixed[key] = { + format: function (value) { + if (value === 0) { + return "0"; + } + return value.toFixed(max); + } + }; + } + + return this.formattersFixed[key]; + } else if (min === 0) { + if (typeof this.formattersZeroBased[key] === 'undefined') { + this.formattersZeroBased[key] = { + format: function (value) { + if (value === 0) { + return "0"; + } + return value.toFixed(max); + } + }; + } + + return this.formattersZeroBased[key]; + } else { + return { + format: function (value) { + if (value === 0) { + return "0"; + } + return value.toFixed(max); + } + }; + } + }, + + testIntlNumberFormat: function () { + let value = 1.12345; + let e1 = "1.12", e2 = "1,12"; + let s = ""; + + try { + let x = new Intl.NumberFormat(undefined, { + useGrouping: true, + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }); + + s = x.format(value); + } catch (e) { + s = ""; + } + + // console.log('NumberFormat: ', s); + return (s === e1 || s === e2); + }, + + testLocaleString: function () { + let value = 1.12345; + let e1 = "1.12", e2 = "1,12"; + let s = ""; + + try { + s = value.toLocaleString(undefined, { + useGrouping: true, + minimumFractionDigits: 2, + maximumFractionDigits: 2 + }); + } catch (e) { + s = ""; + } + + // console.log('localeString: ', s); + return (s === e1 || s === e2); + }, + + // on first run we decide which formatter to use + get: function (min, max) { + if (this.testIntlNumberFormat()) { + // console.log('numberformat'); + this.get = this.getIntlNumberFormat; + } else if (this.testLocaleString()) { + // console.log('localestring'); + this.get = this.getLocaleString; + } else { + // console.log('fixed'); + this.get = this.getFixed; + } + return this.get(min, max); + } +}; + +// ---------------------------------------------------------------------------------------------------------------- +// 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 () { + let script = null; + + if (typeof document.currentScript !== 'undefined') { + script = document.currentScript; + } else { + const 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; +}; + +// *** src/dashboard.js/server-detection.js + +if (typeof netdataServer !== 'undefined') { + NETDATA.serverDefault = netdataServer; +} else { + let 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 += '/'; +} + +if (typeof netdataServerStatic !== 'undefined' && netdataServerStatic !== null && netdataServerStatic !== '') { + NETDATA.serverStatic = netdataServerStatic; + if (NETDATA.serverStatic.slice(-1) !== '/') { + NETDATA.serverStatic += '/'; + } +} else { + NETDATA.serverStatic = NETDATA.serverDefault; +} + +// *** src/dashboard.js/dependencies.js + +// 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.serverStatic + 'lib/jquery-3.6.0.min.js'; +NETDATA.peity_js = NETDATA.serverStatic + 'lib/jquery.peity-3.2.0.min.js'; +NETDATA.sparkline_js = NETDATA.serverStatic + 'lib/jquery.sparkline-2.1.2.min.js'; +NETDATA.easypiechart_js = NETDATA.serverStatic + 'lib/jquery.easypiechart-97b5824.min.js'; +NETDATA.gauge_js = NETDATA.serverStatic + 'lib/gauge-1.3.2.min.js'; +NETDATA.dygraph_js = NETDATA.serverStatic + 'lib/dygraph-c91c859.min.js'; +NETDATA.dygraph_smooth_js = NETDATA.serverStatic + 'lib/dygraph-smooth-plotter-c91c859.js'; +// NETDATA.raphael_js = NETDATA.serverStatic + 'lib/raphael-2.2.4-min.js'; +// NETDATA.c3_js = NETDATA.serverStatic + 'lib/c3-0.4.18.min.js'; +// NETDATA.c3_css = NETDATA.serverStatic + 'css/c3-0.4.18.min.css'; +NETDATA.d3pie_js = NETDATA.serverStatic + 'lib/d3pie-0.2.1-netdata-3.js'; +NETDATA.d3_js = NETDATA.serverStatic + 'lib/d3-4.12.2.min.js'; +// NETDATA.morris_js = NETDATA.serverStatic + 'lib/morris-0.5.1.min.js'; +// NETDATA.morris_css = NETDATA.serverStatic + 'css/morris-0.5.1.css'; +NETDATA.google_js = 'https://www.google.com/jsapi'; +// 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}, + 417: {message: "Netdata registry server send invalid response to SEARCH ", alert: false}, + 418: {message: "Netdata registry SEARCH 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 = Date.now(); + + console.log("ERROR " + code + ": " + NETDATA.errorCodes[code].message + ": " + msg); + + let 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; +}; +// *** src/dashboard.js/compatibility.js + +// 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; + }; +} +// ---------------------------------------------------------------------------------------------------------------- +// XSS checks + +NETDATA.xss = { + enabled: (typeof netdataCheckXSS === 'undefined') ? false : netdataCheckXSS, + enabled_for_data: (typeof netdataCheckXSS === 'undefined') ? false : netdataCheckXSS, + + string: function (s) { + return s.toString() + .replace(//g, '>') + .replace(/"/g, '"') + .replace(/'/g, '''); + }, + + object: function (name, obj, ignore_regex) { + if (typeof ignore_regex !== 'undefined' && ignore_regex.test(name)) { + // console.log('XSS: ignoring "' + name + '"'); + return obj; + } + + switch (typeof(obj)) { + case 'string': + const ret = this.string(obj); + if (ret !== obj) { + console.log('XSS protection changed string ' + name + ' from "' + obj + '" to "' + ret + '"'); + } + return ret; + + case 'object': + if (obj === null) { + return obj; + } + + if (Array.isArray(obj)) { + // console.log('checking array "' + name + '"'); + + let len = obj.length; + while (len--) { + obj[len] = this.object(name + '[' + len + ']', obj[len], ignore_regex); + } + } else { + // console.log('checking object "' + name + '"'); + + for (var i in obj) { + if (obj.hasOwnProperty(i) === false) { + continue; + } + if (this.string(i) !== i) { + console.log('XSS protection removed invalid object member "' + name + '.' + i + '"'); + delete obj[i]; + } else { + obj[i] = this.object(name + '.' + i, obj[i], ignore_regex); + } + } + } + return obj; + + default: + return obj; + } + }, + + checkOptional: function (name, obj, ignore_regex) { + if (this.enabled) { + //console.log('XSS: checking optional "' + name + '"...'); + return this.object(name, obj, ignore_regex); + } + return obj; + }, + + checkAlways: function (name, obj, ignore_regex) { + //console.log('XSS: checking always "' + name + '"...'); + return this.object(name, obj, ignore_regex); + }, + + checkData: function (name, obj, ignore_regex) { + if (this.enabled_for_data) { + //console.log('XSS: checking data "' + name + '"...'); + return this.object(name, obj, ignore_regex); + } + return obj; + } +}; +NETDATA.colorHex2Rgb = function (hex) { + // Expand shorthand form (e.g. "03F") to full form (e.g. "0033FF") + let 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; + }); + + let 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 + let rgb = "#"; + for (let i = 0; i < 3; i++) { + let 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.unitsConversion = { + keys: {}, // keys for data-common-units + latest: {}, // latest selected units for data-common-units + + globalReset: function () { + this.keys = {}; + this.latest = {}; + }, + + scalableUnits: { + 'packets/s': { + 'pps': 1, + 'Kpps': 1000, + 'Mpps': 1000000 + }, + 'pps': { + 'pps': 1, + 'Kpps': 1000, + 'Mpps': 1000000 + }, + 'kilobits/s': { + 'bits/s': 1 / 1000, + 'kilobits/s': 1, + 'megabits/s': 1000, + 'gigabits/s': 1000000, + 'terabits/s': 1000000000 + }, + 'bytes/s': { + 'bytes/s': 1, + 'kilobytes/s': 1024, + 'megabytes/s': 1024 * 1024, + 'gigabytes/s': 1024 * 1024 * 1024, + 'terabytes/s': 1024 * 1024 * 1024 * 1024 + }, + 'kilobytes/s': { + 'bytes/s': 1 / 1024, + 'kilobytes/s': 1, + 'megabytes/s': 1024, + 'gigabytes/s': 1024 * 1024, + 'terabytes/s': 1024 * 1024 * 1024 + }, + 'B/s': { + 'B/s': 1, + 'KiB/s': 1024, + 'MiB/s': 1024 * 1024, + 'GiB/s': 1024 * 1024 * 1024, + 'TiB/s': 1024 * 1024 * 1024 * 1024 + }, + 'KB/s': { + 'B/s': 1 / 1024, + 'KB/s': 1, + 'MB/s': 1024, + 'GB/s': 1024 * 1024, + 'TB/s': 1024 * 1024 * 1024 + }, + 'KiB/s': { + 'B/s': 1 / 1024, + 'KiB/s': 1, + 'MiB/s': 1024, + 'GiB/s': 1024 * 1024, + 'TiB/s': 1024 * 1024 * 1024 + }, + 'bytes': { + 'bytes': 1, + 'kilobytes': 1024, + 'megabytes': 1024 * 1024, + 'gigabytes': 1024 * 1024 * 1024, + 'terabytes': 1024 * 1024 * 1024 * 1024 + }, + 'B': { + 'B': 1, + 'KiB': 1024, + 'MiB': 1024 * 1024, + 'GiB': 1024 * 1024 * 1024, + 'TiB': 1024 * 1024 * 1024 * 1024, + 'PiB': 1024 * 1024 * 1024 * 1024 * 1024 + }, + 'KB': { + 'B': 1 / 1024, + 'KB': 1, + 'MB': 1024, + 'GB': 1024 * 1024, + 'TB': 1024 * 1024 * 1024 + }, + 'KiB': { + 'B': 1 / 1024, + 'KiB': 1, + 'MiB': 1024, + 'GiB': 1024 * 1024, + 'TiB': 1024 * 1024 * 1024 + }, + 'MB': { + 'B': 1 / (1024 * 1024), + 'KB': 1 / 1024, + 'MB': 1, + 'GB': 1024, + 'TB': 1024 * 1024, + 'PB': 1024 * 1024 * 1024 + }, + 'MiB': { + 'B': 1 / (1024 * 1024), + 'KiB': 1 / 1024, + 'MiB': 1, + 'GiB': 1024, + 'TiB': 1024 * 1024, + 'PiB': 1024 * 1024 * 1024 + }, + 'GB': { + 'B': 1 / (1024 * 1024 * 1024), + 'KB': 1 / (1024 * 1024), + 'MB': 1 / 1024, + 'GB': 1, + 'TB': 1024, + 'PB': 1024 * 1024, + 'EB': 1024 * 1024 * 1024 + }, + 'GiB': { + 'B': 1 / (1024 * 1024 * 1024), + 'KiB': 1 / (1024 * 1024), + 'MiB': 1 / 1024, + 'GiB': 1, + 'TiB': 1024, + 'PiB': 1024 * 1024, + 'EiB': 1024 * 1024 * 1024 + }, + 'num': { + 'num': 1, + 'num (K)': 1000, + 'num (M)': 1000000, + 'num (G)': 1000000000, + 'num (T)': 1000000000000 + }, + 'Hz': { + 'Hz': 1, + 'kHz': 10 ** 3, + 'MHz': 10 ** 6, + 'GHz': 10 ** 9, + 'THz': 10 ** 12, + 'PHz': 10 ** 15, + 'EHz': 10 ** 18, + 'ZHz': 10 ** 21, + }, + /* + 'milliseconds': { + 'seconds': 1000 + }, + 'seconds': { + 'milliseconds': 0.001, + 'seconds': 1, + 'minutes': 60, + 'hours': 3600, + 'days': 86400 + } + */ + }, + + convertibleUnits: { + 'Celsius': { + 'Fahrenheit': { + check: function (max) { + void(max); + return NETDATA.options.current.temperature === 'fahrenheit'; + }, + convert: function (value) { + return value * 9 / 5 + 32; + } + } + }, + 'celsius': { + 'fahrenheit': { + check: function (max) { + void(max); + return NETDATA.options.current.temperature === 'fahrenheit'; + }, + convert: function (value) { + return value * 9 / 5 + 32; + } + } + }, + 'seconds': { + 'time': { + check: function (max) { + void(max); + return NETDATA.options.current.seconds_as_time; + }, + convert: function (seconds) { + return NETDATA.unitsConversion.seconds2time(seconds); + } + } + }, + 'milliseconds': { + 'milliseconds': { + check: function (max) { + return NETDATA.options.current.seconds_as_time && max < 1000; + }, + convert: function (milliseconds) { + let tms = Math.round(milliseconds * 10); + milliseconds = Math.floor(tms / 10); + + tms -= milliseconds * 10; + + return (milliseconds).toString() + '.' + tms.toString(); + } + }, + 'seconds': { + check: function (max) { + return NETDATA.options.current.seconds_as_time && max >= 1000 && max < 60000; + }, + convert: function (milliseconds) { + milliseconds = Math.round(milliseconds); + + let seconds = Math.floor(milliseconds / 1000); + milliseconds -= seconds * 1000; + + milliseconds = Math.round(milliseconds / 10); + + return seconds.toString() + '.' + + NETDATA.zeropad(milliseconds); + } + }, + 'M:SS.ms': { + check: function (max) { + return NETDATA.options.current.seconds_as_time && max >= 60000; + }, + convert: function (milliseconds) { + milliseconds = Math.round(milliseconds); + + let minutes = Math.floor(milliseconds / 60000); + milliseconds -= minutes * 60000; + + let seconds = Math.floor(milliseconds / 1000); + milliseconds -= seconds * 1000; + + milliseconds = Math.round(milliseconds / 10); + + return minutes.toString() + ':' + + NETDATA.zeropad(seconds) + '.' + + NETDATA.zeropad(milliseconds); + } + } + }, + 'nanoseconds': { + 'nanoseconds': { + check: function (max) { + return NETDATA.options.current.seconds_as_time && max < 1000; + }, + convert: function (nanoseconds) { + let tms = Math.round(nanoseconds * 10); + nanoseconds = Math.floor(tms / 10); + + tms -= nanoseconds * 10; + + return (nanoseconds).toString() + '.' + tms.toString(); + } + }, + 'microseconds': { + check: function (max) { + return NETDATA.options.current.seconds_as_time + && max >= 1000 && max < 1000 * 1000; + }, + convert: function (nanoseconds) { + nanoseconds = Math.round(nanoseconds); + + let microseconds = Math.floor(nanoseconds / 1000); + nanoseconds -= microseconds * 1000; + + nanoseconds = Math.round(nanoseconds / 10 ); + + return microseconds.toString() + '.' + + NETDATA.zeropad(nanoseconds); + } + }, + 'milliseconds': { + check: function (max) { + return NETDATA.options.current.seconds_as_time + && max >= 1000 * 1000 && max < 1000 * 1000 * 1000; + }, + convert: function (nanoseconds) { + nanoseconds = Math.round(nanoseconds); + + let milliseconds = Math.floor(nanoseconds / 1000 / 1000); + nanoseconds -= milliseconds * 1000 * 1000; + + nanoseconds = Math.round(nanoseconds / 1000 / 10); + + return milliseconds.toString() + '.' + + NETDATA.zeropad(nanoseconds); + } + }, + 'seconds': { + check: function (max) { + return NETDATA.options.current.seconds_as_time + && max >= 1000 * 1000 * 1000; + }, + convert: function (nanoseconds) { + nanoseconds = Math.round(nanoseconds); + + let seconds = Math.floor(nanoseconds / 1000 / 1000 / 1000); + nanoseconds -= seconds * 1000 * 1000 * 1000; + + nanoseconds = Math.round(nanoseconds / 1000 / 1000 / 10); + + return seconds.toString() + '.' + + NETDATA.zeropad(nanoseconds); + } + }, + } + }, + + seconds2time: function (seconds) { + seconds = Math.abs(seconds); + + let days = Math.floor(seconds / 86400); + seconds -= days * 86400; + + let hours = Math.floor(seconds / 3600); + seconds -= hours * 3600; + + let minutes = Math.floor(seconds / 60); + seconds -= minutes * 60; + + seconds = Math.round(seconds); + + let ms_txt = ''; + /* + let ms = seconds - Math.floor(seconds); + seconds -= ms; + ms = Math.round(ms * 1000); + + if (ms > 1) { + if (ms < 10) + ms_txt = '.00' + ms.toString(); + else if (ms < 100) + ms_txt = '.0' + ms.toString(); + else + ms_txt = '.' + ms.toString(); + } + */ + + return ((days > 0) ? days.toString() + 'd:' : '').toString() + + NETDATA.zeropad(hours) + ':' + + NETDATA.zeropad(minutes) + ':' + + NETDATA.zeropad(seconds) + + ms_txt; + }, + + // get a function that converts the units + // + every time units are switched call the callback + get: function (uuid, min, max, units, desired_units, common_units_name, switch_units_callback) { + // validate the parameters + if (typeof units === 'undefined') { + units = 'undefined'; + } + + // check if we support units conversion + if (typeof this.scalableUnits[units] === 'undefined' && typeof this.convertibleUnits[units] === 'undefined') { + // we can't convert these units + //console.log('DEBUG: ' + uuid.toString() + ' can\'t convert units: ' + units.toString()); + return function (value) { + return value; + }; + } + + // check if the caller wants the original units + if (typeof desired_units === 'undefined' || desired_units === null || desired_units === 'original' || desired_units === units) { + //console.log('DEBUG: ' + uuid.toString() + ' original units wanted'); + switch_units_callback(units); + return function (value) { + return value; + }; + } + + // now we know we can convert the units + // and the caller wants some kind of conversion + + let tunits = null; + let tdivider = 0; + + if (typeof this.scalableUnits[units] !== 'undefined') { + // units that can be scaled + // we decide a divider + + // console.log('NETDATA.unitsConversion.get(' + units.toString() + ', ' + desired_units.toString() + ', function()) decide divider with min = ' + min.toString() + ', max = ' + max.toString()); + + if (desired_units === 'auto') { + // the caller wants to auto-scale the units + + // find the absolute maximum value that is rendered on the chart + // based on this we decide the scale + min = Math.abs(min); + max = Math.abs(max); + if (min > max) { + max = min; + } + + // find the smallest scale that provides integers + // for (x in this.scalableUnits[units]) { + // if (this.scalableUnits[units].hasOwnProperty(x)) { + // let m = this.scalableUnits[units][x]; + // if (m <= max && m > tdivider) { + // tunits = x; + // tdivider = m; + // } + // } + // } + const sunit = this.scalableUnits[units]; + for (var x of Object.keys(sunit)) { + let m = sunit[x]; + if (m <= max && m > tdivider) { + tunits = x; + tdivider = m; + } + } + + if (tunits === null || tdivider <= 0) { + // we couldn't find one + //console.log('DEBUG: ' + uuid.toString() + ' cannot find an auto-scaling candidate for units: ' + units.toString() + ' (max: ' + max.toString() + ')'); + switch_units_callback(units); + return function (value) { + return value; + }; + } + + if (typeof common_units_name === 'string' && typeof uuid === 'string') { + // the caller wants several charts to have the same units + // data-common-units + + let common_units_key = common_units_name + '-' + units; + + // add our divider into the list of keys + let t = this.keys[common_units_key]; + if (typeof t === 'undefined') { + this.keys[common_units_key] = {}; + t = this.keys[common_units_key]; + } + t[uuid] = { + units: tunits, + divider: tdivider + }; + + // find the max divider of all charts + let common_units = t[uuid]; + for (var x in t) { + if (t.hasOwnProperty(x) && t[x].divider > common_units.divider) { + common_units = t[x]; + } + } + + // save our common_max to the latest keys + let latest = this.latest[common_units_key]; + if (typeof latest === 'undefined') { + this.latest[common_units_key] = {}; + latest = this.latest[common_units_key]; + } + latest.units = common_units.units; + latest.divider = common_units.divider; + + tunits = latest.units; + tdivider = latest.divider; + + //console.log('DEBUG: ' + uuid.toString() + ' converted units: ' + units.toString() + ' to units: ' + tunits.toString() + ' with divider ' + tdivider.toString() + ', common-units=' + common_units_name.toString() + ((t[uuid].divider !== tdivider)?' USED COMMON, mine was ' + t[uuid].units:' set common').toString()); + + // apply it to this chart + switch_units_callback(tunits); + return function (value) { + if (tdivider !== latest.divider) { + // another chart switched our common units + // we should switch them too + //console.log('DEBUG: ' + uuid + ' switching units due to a common-units change, from ' + tunits.toString() + ' to ' + latest.units.toString()); + tunits = latest.units; + tdivider = latest.divider; + switch_units_callback(tunits); + } + + return value / tdivider; + }; + } else { + // the caller did not give data-common-units + // this chart auto-scales independently of all others + //console.log('DEBUG: ' + uuid.toString() + ' converted units: ' + units.toString() + ' to units: ' + tunits.toString() + ' with divider ' + tdivider.toString() + ', autonomously'); + + switch_units_callback(tunits); + return function (value) { + return value / tdivider; + }; + } + } else { + // the caller wants specific units + + if (typeof this.scalableUnits[units][desired_units] !== 'undefined') { + // all good, set the new units + tdivider = this.scalableUnits[units][desired_units]; + // console.log('DEBUG: ' + uuid.toString() + ' converted units: ' + units.toString() + ' to units: ' + desired_units.toString() + ' with divider ' + tdivider.toString() + ', by reference'); + switch_units_callback(desired_units); + return function (value) { + return value / tdivider; + }; + } else { + // oops! switch back to original units + console.log('Units conversion from ' + units.toString() + ' to ' + desired_units.toString() + ' is not supported.'); + switch_units_callback(units); + return function (value) { + return value; + }; + } + } + } else if (typeof this.convertibleUnits[units] !== 'undefined') { + // units that can be converted + if (desired_units === 'auto') { + for (var x in this.convertibleUnits[units]) { + if (this.convertibleUnits[units].hasOwnProperty(x)) { + if (this.convertibleUnits[units][x].check(max)) { + //console.log('DEBUG: ' + uuid.toString() + ' converting ' + units.toString() + ' to: ' + x.toString()); + switch_units_callback(x); + return this.convertibleUnits[units][x].convert; + } + } + } + + // none checked ok + //console.log('DEBUG: ' + uuid.toString() + ' no conversion available for ' + units.toString() + ' to: ' + desired_units.toString()); + switch_units_callback(units); + return function (value) { + return value; + }; + } else if (typeof this.convertibleUnits[units][desired_units] !== 'undefined') { + switch_units_callback(desired_units); + return this.convertibleUnits[units][desired_units].convert; + } else { + console.log('Units conversion from ' + units.toString() + ' to ' + desired_units.toString() + ' is not supported.'); + switch_units_callback(units); + return function (value) { + return value; + }; + } + } else { + // hm... did we forget to implement the new type? + console.log(`Unmatched unit conversion method for units ${units.toString()}`); + switch_units_callback(units); + return function (value) { + return value; + }; + } + } +}; + +NETDATA.icons = { + left: '', + reset: '', + right: '', + zoomIn: '', + zoomOut: '', + resize: '', + lineChart: '', + areaChart: '', + noChart: '', + loading: '', + noData: '' +}; + +if (typeof netdataIcons === 'object') { + // for (let icon in NETDATA.icons) { + // if (NETDATA.icons.hasOwnProperty(icon) && typeof(netdataIcons[icon]) === 'string') + // NETDATA.icons[icon] = netdataIcons[icon]; + // } + for (var icon of Object.keys(NETDATA.icons)) { + if (typeof(netdataIcons[icon]) === 'string') { + NETDATA.icons[icon] = netdataIcons[icon] + } + } +} + +if (typeof netdataSnapshotData === 'undefined') { + netdataSnapshotData = null; +} + +if (typeof netdataShowHelp === 'undefined') { + netdataShowHelp = true; +} + +if (typeof netdataShowAlarms === 'undefined') { + netdataShowAlarms = false; +} + +if (typeof netdataRegistryAfterMs !== 'number' || netdataRegistryAfterMs < 0) { + netdataRegistryAfterMs = 0; // 1500; +} + +if (typeof netdataRegistry === 'undefined') { + // backward compatibility + netdataRegistry = (typeof netdataNoRegistry !== 'undefined' && netdataNoRegistry === false); +} + +if (netdataRegistry === false && typeof netdataRegistryCallback === 'function') { + netdataRegistry = true; +} + +// ---------------------------------------------------------------------------------------------------------------- +// the defaults for all charts + +// if the user does not specify any of these, the following will be used + +NETDATA.chartDefaults = { + 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 solid areas +}; + +// ---------------------------------------------------------------------------------------------------------------- +// global options + +NETDATA.options = { + pauseCallback: null, // a callback when we are really paused + + pause: false, // when enabled we don't auto-refresh the charts + + targets: [], // 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. + + auto_refresher_fast_weight: 0, // this is the current time in ms, spent + // rendering charts continuously. + // used with .current.fast_render_timeframe + + page_is_visible: true, // when true, this page is visible + + auto_refresher_stop_until: 0, // timestamp in ms - used internally, 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 + + on_scroll_refresher_stop_until: 0, // timestamp in ms - used to stop evaluating + // charts for some time, after a page scroll + + last_page_resize: Date.now(), // the timestamp of the last resize request + + last_page_scroll: 0, // the timestamp the last time the page was scrolled + + browser_timezone: 'unknown', // timezone detected by javascript + server_timezone: 'unknown', // timezone reported by the server + + force_data_points: 0, // force the number of points to be returned for charts + fake_chart_rendering: false, // when set to true, the dashboard will download data but will not render the charts + + passive_events: null, // true if the browser supports passive events + + // the current profile + // we may have many... + current: { + units: 'auto', // can be 'auto' or 'original' + temperature: 'celsius', // can be 'celsius' or 'fahrenheit' + seconds_as_time: true, // show seconds as DDd:HH:MM:SS ? + timezone: 'default', // the timezone to use, or 'default' + user_set_server_timezone: 'default', // as set by the user on the dashboard + + legend_toolbox: true, // show the legend toolbox on charts + resize_charts: true, // show the resize handler on charts + + pixels_per_point: isSlowDevice() ? 5 : 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 + + fast_render_timeframe: 200, // ms - render continuously until this time of continuous + // 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_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 + + global_pan_sync_time: 300, // ms - when you pan or zoom a chart, the background + // auto-refreshing of charts is paused for this amount + // of time + + sync_selection_delay: 400, // 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 often 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 / used for printing + + parallel_refresher: !isSlowDevice(), // enable parallel refresh of charts + + concurrent_refreshes: true, // when parallel_refresher is enabled, sync also the charts + + destroy_on_hide: isSlowDevice(), // 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: !isSlowDevice(), // enable smooth plot, where possible + + 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, // kill pending ajax page scroll + async_on_scroll: false, // sync/async onscroll handler + onscroll_worker_duration_threshold: 30, // time in ms, for async scroll handler + + retries_on_data_failures: 3, // how many retries to make if we can't fetch chart data from the server + + setOptionCallback: function () { + } + }, + + debug: { + show_boxes: false, + main_loop: false, + focus: false, + visibility: false, + chart_data_url: false, + chart_errors: true, // remember to set it to false before merging + chart_timing: false, + chart_calls: false, + libraries: false, + dygraph: false, + globalSelectionSync: false, + globalPanAndZoom: 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.localStorageTested = -1; +NETDATA.localStorageTest = function () { + if (NETDATA.localStorageTested !== -1) { + return NETDATA.localStorageTested; + } + + if (typeof Storage !== "undefined" && typeof localStorage === 'object') { + let test = 'test'; + try { + localStorage.setItem(test, test); + localStorage.removeItem(test); + NETDATA.localStorageTested = true; + } catch (e) { + NETDATA.localStorageTested = false; + } + } else { + NETDATA.localStorageTested = false; + } + + return NETDATA.localStorageTested; +}; + +NETDATA.localStorageGet = function (key, def, callback) { + let ret = def; + + if (typeof NETDATA.localStorage.default[key.toString()] === 'undefined') { + NETDATA.localStorage.default[key.toString()] = def; + NETDATA.localStorage.callback[key.toString()] = callback; + } + + if (NETDATA.localStorageTest()) { + 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 (NETDATA.localStorageTest()) { + // 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) { + let keys = Object.keys(obj); + let len = keys.length; + while (len--) { + let i = keys[len]; + + 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) { + let 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 () { + let keys = Object.keys(NETDATA.localStorage.default); + let len = keys.length; + + while (len--) { + let i = keys[len]; + let 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]); + } + } + } + + NETDATA.dateTime.init(NETDATA.options.current.timezone); +}; + +// *** src/dashboard.js/timeout.js + +// TODO: Better name needed + +NETDATA.timeout = { + // by default, these are just wrappers to setTimeout() / clearTimeout() + + step: function (callback) { + return window.setTimeout(callback, 1000 / 60); + }, + + set: function (callback, delay) { + return window.setTimeout(callback, delay); + }, + + clear: function (id) { + return window.clearTimeout(id); + }, + + init: function () { + let custom = true; + + if (window.requestAnimationFrame) { + this.step = function (callback) { + return window.requestAnimationFrame(callback); + }; + + this.clear = function (handle) { + return window.cancelAnimationFrame(handle.value); + }; + // } else if (window.webkitRequestAnimationFrame) { + // this.step = function (callback) { + // return window.webkitRequestAnimationFrame(callback); + // }; + + // if (window.webkitCancelAnimationFrame) { + // this.clear = function (handle) { + // return window.webkitCancelAnimationFrame(handle.value); + // }; + // } else if (window.webkitCancelRequestAnimationFrame) { + // this.clear = function (handle) { + // return window.webkitCancelRequestAnimationFrame(handle.value); + // }; + // } + // } else if (window.mozRequestAnimationFrame) { + // this.step = function (callback) { + // return window.mozRequestAnimationFrame(callback); + // }; + + // this.clear = function (handle) { + // return window.mozCancelRequestAnimationFrame(handle.value); + // }; + // } else if (window.oRequestAnimationFrame) { + // this.step = function (callback) { + // return window.oRequestAnimationFrame(callback); + // }; + + // this.clear = function (handle) { + // return window.oCancelRequestAnimationFrame(handle.value); + // }; + // } else if (window.msRequestAnimationFrame) { + // this.step = function (callback) { + // return window.msRequestAnimationFrame(callback); + // }; + + // this.clear = function (handle) { + // return window.msCancelRequestAnimationFrame(handle.value); + // }; + } else { + custom = false; + } + + if (custom) { + // we have installed custom .step() / .clear() functions + // overwrite the .set() too + + this.set = function (callback, delay) { + let start = Date.now(), + handle = new Object(); + + const loop = () => { + let current = Date.now(), + delta = current - start; + + if (delta >= delay) { + callback.call(); + } else { + handle.value = this.step(loop); + } + } + + handle.value = this.step(loop); + return handle; + }; + } + } +}; + +NETDATA.timeout.init(); +// Codacy declarations +/* global netdataTheme */ + +NETDATA.themes = { + white: { + bootstrap_css: NETDATA.serverStatic + 'css/bootstrap-3.3.7.css', + dashboard_css: NETDATA.serverStatic + 'dashboard.css?v20190902-0', + background: '#FFFFFF', + foreground: '#000000', + grid: '#F0F0F0', + axis: '#F0F0F0', + highlight: '#F5F5F5', + 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, + d3pie: { + title: '#333333', + subtitle: '#666666', + footer: '#888888', + other: '#aaaaaa', + mainlabel: '#333333', + percentage: '#dddddd', + value: '#aaaa22', + tooltip_bg: '#000000', + tooltip_fg: '#efefef', + segment_stroke: "#ffffff", + gradient_color: '#000000' + } + }, + slate: { + bootstrap_css: NETDATA.serverStatic + 'css/bootstrap-slate-flat-3.3.7.css?v20161229-1', + dashboard_css: NETDATA.serverStatic + 'dashboard.slate.css?v20190902-0', + background: '#272b30', + foreground: '#C8C8C8', + grid: '#283236', + axis: '#283236', + highlight: '#383838', + /* 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', + '#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, + d3pie: { + title: '#C8C8C8', + subtitle: '#283236', + footer: '#283236', + other: '#283236', + mainlabel: '#C8C8C8', + percentage: '#dddddd', + value: '#cccc44', + tooltip_bg: '#272b30', + tooltip_fg: '#C8C8C8', + segment_stroke: "#283236", + gradient_color: '#000000' + } + } +}; + +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' ]; + +// 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' ]; +// dygraph + +// Codacy declarations +/* global smoothPlotter */ +/* global 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'); + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + state.tmp.dygraph_user_action = true; + state.tmp.dygraph_force_zoom = true; + // state.log('toolboxPanAndZoom'); + state.updateChartPanOrZoom(after, before); + NETDATA.globalPanAndZoom.setMaster(state, after, before); +}; + +NETDATA.dygraphSetSelection = function (state, t) { + if (typeof state.tmp.dygraph_instance !== 'undefined') { + let r = state.calculateRowForTime(t); + if (r !== -1) { + state.tmp.dygraph_instance.setSelection(r); + return true; + } else { + state.tmp.dygraph_instance.clearSelection(); + state.legendShowUndefined(); + } + } + + return false; +}; + +NETDATA.dygraphClearSelection = function (state) { + if (typeof state.tmp.dygraph_instance !== 'undefined') { + state.tmp.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") { + return 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 && NETDATA.options.current.smooth_plot) { + NETDATA.dygraphSmoothInitialize(callback); + } else if (typeof callback === "function") { + return callback(); + } + }); + } else { + NETDATA.chartLibraries.dygraph.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } +}; + +NETDATA.dygraphChartUpdate = function (state, data) { + let dygraph = state.tmp.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.tmp.dygraph_last_rendered) { + dygraph.resize(); + } + + let options = { + file: data.result.data, + colors: state.chartColors(), + labels: data.result.labels, + //labelsDivWidth: state.chartWidth() - 70, + includeZero: state.tmp.dygraph_include_zero, + visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names) + }; + + if (state.tmp.dygraph_chart_type === 'stacked') { + if (options.includeZero && state.dimensions_visibility.countSelected() < options.visibility.length) { + options.includeZero = 0; + } + } + + if (!NETDATA.chartLibraries.dygraph.isSparkline(state)) { + options.ylabel = state.units_current; // (state.units_desired === 'auto')?"":state.units_current; + } + + if (state.tmp.dygraph_force_zoom) { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphChartUpdate() forced zoom update'); + } + + options.dateWindow = (state.requested_padding !== null) ? [state.view_after, state.view_before] : null; + //options.isZoomedIgnoreProgrammaticZoom = true; + state.tmp.dygraph_force_zoom = false; + } else if (state.current.name !== 'auto') { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphChartUpdate() loose update'); + } + } else { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphChartUpdate() strict update'); + } + + options.dateWindow = (state.requested_padding !== null) ? [state.view_after, state.view_before] : null; + //options.isZoomedIgnoreProgrammaticZoom = true; + } + + options.valueRange = state.tmp.dygraph_options.valueRange; + + let oldMax = null, oldMin = null; + if (state.tmp.__commonMin !== null) { + state.data.min = state.tmp.dygraph_instance.axes_[0].extremeRange[0]; + oldMin = options.valueRange[0] = NETDATA.commonMin.get(state); + } + if (state.tmp.__commonMax !== null) { + state.data.max = state.tmp.dygraph_instance.axes_[0].extremeRange[1]; + oldMax = options.valueRange[1] = NETDATA.commonMax.get(state); + } + + if (state.tmp.dygraph_smooth_eligible) { + if ((NETDATA.options.current.smooth_plot && state.tmp.dygraph_options.plotter !== smoothPlotter) + || (NETDATA.options.current.smooth_plot === false && state.tmp.dygraph_options.plotter === smoothPlotter)) { + NETDATA.dygraphChartCreate(state, data); + return; + } + } + + if (netdataSnapshotData !== null && NETDATA.globalPanAndZoom.isActive() && NETDATA.globalPanAndZoom.isMaster(state) === false) { + // pan and zoom on snapshots + options.dateWindow = [NETDATA.globalPanAndZoom.force_after_ms, NETDATA.globalPanAndZoom.force_before_ms]; + //options.isZoomedIgnoreProgrammaticZoom = true; + } + + if (NETDATA.chartLibraries.dygraph.isLogScale(state)) { + if (Array.isArray(options.valueRange) && options.valueRange[0] <= 0) { + options.valueRange[0] = null; + } + } + + dygraph.updateOptions(options); + + let redraw = false; + if (oldMin !== null && oldMin > state.tmp.dygraph_instance.axes_[0].extremeRange[0]) { + state.data.min = state.tmp.dygraph_instance.axes_[0].extremeRange[0]; + options.valueRange[0] = NETDATA.commonMin.get(state); + redraw = true; + } + if (oldMax !== null && oldMax < state.tmp.dygraph_instance.axes_[0].extremeRange[1]) { + state.data.max = state.tmp.dygraph_instance.axes_[0].extremeRange[1]; + options.valueRange[1] = NETDATA.commonMax.get(state); + redraw = true; + } + + if (redraw) { + // state.log('forcing redraw to adapt to common- min/max'); + dygraph.updateOptions(options); + } + + state.tmp.dygraph_last_rendered = Date.now(); + return true; +}; + +NETDATA.dygraphChartCreate = function (state, data) { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphChartCreate()'); + } + + state.tmp.dygraph_chart_type = NETDATA.dataAttribute(state.element, 'dygraph-type', state.chart.chart_type); + if (state.tmp.dygraph_chart_type === 'stacked' && data.dimensions === 1) { + state.tmp.dygraph_chart_type = 'area'; + } + if (state.tmp.dygraph_chart_type === 'stacked' && NETDATA.chartLibraries.dygraph.isLogScale(state)) { + state.tmp.dygraph_chart_type = 'area'; + } + + let highlightCircleSize = NETDATA.chartLibraries.dygraph.isSparkline(state) ? 3 : 4; + + let smooth = NETDATA.dygraph.smooth + ? (NETDATA.dataAttributeBoolean(state.element, 'dygraph-smooth', (state.tmp.dygraph_chart_type === 'line' && NETDATA.chartLibraries.dygraph.isSparkline(state) === false))) + : false; + + state.tmp.dygraph_include_zero = NETDATA.dataAttribute(state.element, 'dygraph-includezero', (state.tmp.dygraph_chart_type === 'stacked')); + let drawAxis = NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawaxis', true); + + state.tmp.dygraph_options = { + colors: NETDATA.dataAttribute(state.element, 'dygraph-colors', state.chartColors()), + + // leave a few pixels empty on the right of the chart + rightGap: NETDATA.dataAttribute(state.element, 'dygraph-rightgap', 5), + showRangeSelector: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showrangeselector', false), + showRoller: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showroller', false), + title: NETDATA.dataAttribute(state.element, 'dygraph-title', state.title), + titleHeight: NETDATA.dataAttribute(state.element, 'dygraph-titleheight', 19), + legend: NETDATA.dataAttribute(state.element, 'dygraph-legend', 'always'), // we need this to get selection events + labels: data.result.labels, + labelsDiv: NETDATA.dataAttribute(state.element, 'dygraph-labelsdiv', state.element_legend_childs.hidden), + //labelsDivStyles: NETDATA.dataAttribute(state.element, 'dygraph-labelsdivstyles', { 'fontSize':'1px' }), + //labelsDivWidth: NETDATA.dataAttribute(state.element, 'dygraph-labelsdivwidth', state.chartWidth() - 70), + labelsSeparateLines: NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsseparatelines', true), + labelsShowZeroValues: NETDATA.chartLibraries.dygraph.isLogScale(state) ? false : NETDATA.dataAttributeBoolean(state.element, 'dygraph-labelsshowzerovalues', true), + labelsKMB: false, + labelsKMG2: false, + showLabelsOnHighlight: NETDATA.dataAttributeBoolean(state.element, 'dygraph-showlabelsonhighlight', true), + hideOverlayOnMouseOut: NETDATA.dataAttributeBoolean(state.element, 'dygraph-hideoverlayonmouseout', true), + includeZero: state.tmp.dygraph_include_zero, + xRangePad: NETDATA.dataAttribute(state.element, 'dygraph-xrangepad', 0), + yRangePad: NETDATA.dataAttribute(state.element, 'dygraph-yrangepad', 1), + valueRange: NETDATA.dataAttribute(state.element, 'dygraph-valuerange', [null, null]), + ylabel: state.units_current, // (state.units_desired === 'auto')?"":state.units_current, + yLabelWidth: NETDATA.dataAttribute(state.element, '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: NETDATA.dataAttribute(state.element, 'dygraph-strokewidth', ((state.tmp.dygraph_chart_type === 'stacked') ? 0.1 : ((smooth === true) ? 1.5 : 0.7))), + strokePattern: NETDATA.dataAttribute(state.element, '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: NETDATA.dataAttributeBoolean(state.element, '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: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawgapedgepoints', true), + connectSeparatedPoints: NETDATA.chartLibraries.dygraph.isLogScale(state) ? false : NETDATA.dataAttributeBoolean(state.element, 'dygraph-connectseparatedpoints', false), + pointSize: NETDATA.dataAttribute(state.element, 'dygraph-pointsize', 1), + + // enabling this makes the chart with little square lines + stepPlot: NETDATA.dataAttributeBoolean(state.element, 'dygraph-stepplot', false), + + // Draw a border around graph lines to make crossing lines more easily + // distinguishable. Useful for graphs with many lines. + strokeBorderColor: NETDATA.dataAttribute(state.element, 'dygraph-strokebordercolor', NETDATA.themes.current.background), + strokeBorderWidth: NETDATA.dataAttribute(state.element, 'dygraph-strokeborderwidth', (state.tmp.dygraph_chart_type === 'stacked') ? 0.0 : 0.0), + fillGraph: NETDATA.dataAttribute(state.element, 'dygraph-fillgraph', (state.tmp.dygraph_chart_type === 'area' || state.tmp.dygraph_chart_type === 'stacked')), + fillAlpha: NETDATA.dataAttribute(state.element, 'dygraph-fillalpha', + ((state.tmp.dygraph_chart_type === 'stacked') + ? NETDATA.options.current.color_fill_opacity_stacked + : NETDATA.options.current.color_fill_opacity_area) + ), + stackedGraph: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraph', (state.tmp.dygraph_chart_type === 'stacked')), + stackedGraphNaNFill: NETDATA.dataAttribute(state.element, 'dygraph-stackedgraphnanfill', 'none'), + drawAxis: drawAxis, + axisLabelFontSize: NETDATA.dataAttribute(state.element, 'dygraph-axislabelfontsize', 10), + axisLineColor: NETDATA.dataAttribute(state.element, 'dygraph-axislinecolor', NETDATA.themes.current.axis), + axisLineWidth: NETDATA.dataAttribute(state.element, 'dygraph-axislinewidth', 1.0), + drawGrid: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawgrid', true), + gridLinePattern: NETDATA.dataAttribute(state.element, 'dygraph-gridlinepattern', null), + gridLineWidth: NETDATA.dataAttribute(state.element, 'dygraph-gridlinewidth', 1.0), + gridLineColor: NETDATA.dataAttribute(state.element, 'dygraph-gridlinecolor', NETDATA.themes.current.grid), + maxNumberWidth: NETDATA.dataAttribute(state.element, 'dygraph-maxnumberwidth', 8), + sigFigs: NETDATA.dataAttribute(state.element, 'dygraph-sigfigs', null), + digitsAfterDecimal: NETDATA.dataAttribute(state.element, 'dygraph-digitsafterdecimal', 2), + valueFormatter: NETDATA.dataAttribute(state.element, 'dygraph-valueformatter', undefined), + highlightCircleSize: NETDATA.dataAttribute(state.element, 'dygraph-highlightcirclesize', highlightCircleSize), + highlightSeriesOpts: NETDATA.dataAttribute(state.element, 'dygraph-highlightseriesopts', null), // TOO SLOW: { strokeWidth: 1.5 }, + highlightSeriesBackgroundAlpha: NETDATA.dataAttribute(state.element, 'dygraph-highlightseriesbackgroundalpha', null), // TOO SLOW: (state.tmp.dygraph_chart_type === 'stacked')?0.7:0.5, + pointClickCallback: NETDATA.dataAttribute(state.element, 'dygraph-pointclickcallback', undefined), + visibility: state.dimensions_visibility.selected2BooleanArray(state.data.dimension_names), + logscale: NETDATA.chartLibraries.dygraph.isLogScale(state) ? 'y' : undefined, + + axes: { + x: { + pixelsPerLabel: NETDATA.dataAttribute(state.element, 'dygraph-xpixelsperlabel', 50), + ticker: Dygraph.dateTicker, + axisLabelWidth: NETDATA.dataAttribute(state.element, 'dygraph-xaxislabelwidth', 60), + drawAxis: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawxaxis', drawAxis), + axisLabelFormatter: function (d, gran) { + void(gran); + return NETDATA.dateTime.xAxisTimeString(d); + } + }, + y: { + logscale: NETDATA.chartLibraries.dygraph.isLogScale(state) ? true : undefined, + pixelsPerLabel: NETDATA.dataAttribute(state.element, 'dygraph-ypixelsperlabel', 15), + axisLabelWidth: NETDATA.dataAttribute(state.element, 'dygraph-yaxislabelwidth', 50), + drawAxis: NETDATA.dataAttributeBoolean(state.element, 'dygraph-drawyaxis', drawAxis), + axisLabelFormatter: function (y) { + + // unfortunately, we have to call this every single time + state.legendFormatValueDecimalsFromMinMax( + this.axes_[0].extremeRange[0], + this.axes_[0].extremeRange[1] + ); + + let old_units = this.user_attrs_.ylabel; + let v = state.legendFormatValue(y); + let new_units = state.units_current; + + if (state.units_desired === 'auto' && typeof old_units !== 'undefined' && new_units !== old_units && !NETDATA.chartLibraries.dygraph.isSparkline(state)) { + // console.log(this); + // state.log('units discrepancy: old = ' + old_units + ', new = ' + new_units); + let len = this.plugins_.length; + while (len--) { + // console.log(this.plugins_[len]); + if (typeof this.plugins_[len].plugin.ylabel_div_ !== 'undefined' + && this.plugins_[len].plugin.ylabel_div_ !== null + && typeof this.plugins_[len].plugin.ylabel_div_.children !== 'undefined' + && this.plugins_[len].plugin.ylabel_div_.children !== null + && typeof this.plugins_[len].plugin.ylabel_div_.children[0].children !== 'undefined' + && this.plugins_[len].plugin.ylabel_div_.children[0].children !== null + ) { + this.plugins_[len].plugin.ylabel_div_.children[0].children[0].innerHTML = new_units; + this.user_attrs_.ylabel = new_units; + break; + } + } + + if (len < 0) { + state.log('units discrepancy, but cannot find dygraphs div to change: old = ' + old_units + ', new = ' + new_units); + } + } + + return v; + } + } + }, + legendFormatter: function (data) { + if (state.tmp.dygraph_mouse_down) { + return; + } + + let 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); + let i = data.series.length; + while (i--) { + let series = data.series[i]; + if (series.isVisible) { + state.legendSetLabelValue(series.label, series.y); + } else { + state.legendSetLabelValue(series.label, null); + } + } + } + + return ''; + }, + drawCallback: function (dygraph, is_initial) { + + // the user has panned the chart and this is called to re-draw the chart + // 1. refresh this chart by adding data to it + // 2. notify all the other charts about the update they need + + // to prevent an infinite loop (feedback), we use + // state.tmp.dygraph_user_action + // - when true, this is initiated by a user + // - when false, this is feedback + + if (state.current.name !== 'auto' && state.tmp.dygraph_user_action) { + state.tmp.dygraph_user_action = false; + + let x_range = dygraph.xAxisRange(); + let after = Math.round(x_range[0]); + let before = Math.round(x_range[1]); + + if (NETDATA.options.debug.dygraph) { + state.log('dygraphDrawCallback(dygraph, ' + is_initial + '): mode ' + state.current.name + ' ' + (after / 1000).toString() + ' - ' + (before / 1000).toString()); + //console.log(state); + } + + if (before <= state.netdata_last && after >= state.netdata_first) { + // update only when we are within the data limits + state.updateChartPanOrZoom(after, before); + } + } + }, + zoomCallback: function (minDate, maxDate, yRanges) { + + // the user has selected a range on the chart + // 1. refresh this chart by adding data to it + // 2. notify all the other charts about the update they need + + void(yRanges); + + if (NETDATA.options.debug.dygraph) { + state.log('dygraphZoomCallback(): ' + state.current.name); + } + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + state.setMode('zoom'); + + // refresh it to the greatest possible zoom level + state.tmp.dygraph_user_action = true; + state.tmp.dygraph_force_zoom = true; + state.updateChartPanOrZoom(minDate, maxDate); + }, + highlightCallback: function (event, x, points, row, seriesName) { + void(seriesName); + + 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 + // let 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); + + if (state.tmp.dygraph_mouse_down !== true) { + NETDATA.globalSelectionSync.sync(state, x); + } + + // fix legend zIndex using the internal structures of dygraph legend module + // this works, but it is a hack! + // state.tmp.dygraph_instance.plugins_[0].plugin.legend_div_.style.zIndex = 10000; + }, + unhighlightCallback: function (event) { + void(event); + + if (state.tmp.dygraph_mouse_down) { + return; + } + + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('dygraphUnhighlightCallback()'); + } + + state.unpauseChart(); + NETDATA.globalSelectionSync.stop(); + }, + underlayCallback: function (canvas, area, g) { + // the chart is about to be drawn + + // update history_tip_element + if (state.tmp.dygraph_history_tip_element) { + const xHookRightSide = g.toDomXCoord(state.netdata_first); + if (xHookRightSide > area.x) { + state.tmp.dygraph_history_tip_element_displayed = true; + // group the styles for possible better performance + state.tmp.dygraph_history_tip_element.setAttribute( + 'style', + `display: block; left: ${area.x}px; right: calc(100% - ${xHookRightSide}px);` + ) + } else { + if (state.tmp.dygraph_history_tip_element_displayed) { + // additional check just for performance + // don't update the DOM when it's not needed + state.tmp.dygraph_history_tip_element.style.display = 'none'; + state.tmp.dygraph_history_tip_element_displayed = false; + } + } + } + + // this function renders global highlighted time-frame + + if (NETDATA.globalChartUnderlay.isActive()) { + let after = NETDATA.globalChartUnderlay.after; + let before = NETDATA.globalChartUnderlay.before; + + if (after < state.view_after) { + after = state.view_after; + } + + if (before > state.view_before) { + before = state.view_before; + } + + if (after < before) { + let bottom_left = g.toDomCoords(after, -20); + let top_right = g.toDomCoords(before, +20); + + let left = bottom_left[0]; + let right = top_right[0]; + + canvas.fillStyle = NETDATA.themes.current.highlight; + canvas.fillRect(left, area.y, right - left, area.h); + } + } + }, + interactionModel: { + mousedown: function (event, dygraph, context) { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('interactionModel.mousedown()'); + } + + state.tmp.dygraph_user_action = true; + + if (NETDATA.options.debug.dygraph) { + state.log('dygraphMouseDown()'); + } + + // Right-click should not initiate anything. + if (event.button && event.button === 2) { + return; + } + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + state.tmp.dygraph_mouse_down = true; + context.initializeMouseDown(event, dygraph, context); + + //console.log(event); + if (event.button && event.button === 1) { + if (event.shiftKey) { + //console.log('middle mouse button dragging (PAN)'); + + state.setMode('pan'); + // NETDATA.globalSelectionSync.delay(); + state.tmp.dygraph_highlight_after = null; + Dygraph.startPan(event, dygraph, context); + } else if (event.altKey || event.ctrlKey || event.metaKey) { + //console.log('middle mouse button highlight'); + + if (!(event.offsetX && event.offsetY)) { + event.offsetX = event.layerX - event.target.offsetLeft; + event.offsetY = event.layerY - event.target.offsetTop; + } + state.tmp.dygraph_highlight_after = dygraph.toDataXCoord(event.offsetX); + Dygraph.startZoom(event, dygraph, context); + } else { + //console.log('middle mouse button selection for zoom (ZOOM)'); + + state.setMode('zoom'); + // NETDATA.globalSelectionSync.delay(); + state.tmp.dygraph_highlight_after = null; + Dygraph.startZoom(event, dygraph, context); + } + } else { + if (event.shiftKey) { + //console.log('left mouse button selection for zoom (ZOOM)'); + + state.setMode('zoom'); + // NETDATA.globalSelectionSync.delay(); + state.tmp.dygraph_highlight_after = null; + Dygraph.startZoom(event, dygraph, context); + } else if (event.altKey || event.ctrlKey || event.metaKey) { + //console.log('left mouse button highlight'); + + if (!(event.offsetX && event.offsetY)) { + event.offsetX = event.layerX - event.target.offsetLeft; + event.offsetY = event.layerY - event.target.offsetTop; + } + state.tmp.dygraph_highlight_after = dygraph.toDataXCoord(event.offsetX); + Dygraph.startZoom(event, dygraph, context); + } else { + //console.log('left mouse button dragging (PAN)'); + + state.setMode('pan'); + // NETDATA.globalSelectionSync.delay(); + state.tmp.dygraph_highlight_after = null; + Dygraph.startPan(event, dygraph, context); + } + } + }, + mousemove: function (event, dygraph, context) { + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('interactionModel.mousemove()'); + } + + if (state.tmp.dygraph_highlight_after !== null) { + //console.log('highlight selection...'); + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + state.tmp.dygraph_user_action = true; + Dygraph.moveZoom(event, dygraph, context); + event.preventDefault(); + } else if (context.isPanning) { + //console.log('panning...'); + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + state.tmp.dygraph_user_action = true; + //NETDATA.globalSelectionSync.stop(); + //NETDATA.globalSelectionSync.delay(); + state.setMode('pan'); + context.is2DPan = false; + Dygraph.movePan(event, dygraph, context); + } else if (context.isZooming) { + //console.log('zooming...'); + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + state.tmp.dygraph_user_action = true; + //NETDATA.globalSelectionSync.stop(); + //NETDATA.globalSelectionSync.delay(); + state.setMode('zoom'); + Dygraph.moveZoom(event, dygraph, context); + } + }, + mouseup: function (event, dygraph, context) { + state.tmp.dygraph_mouse_down = false; + + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('interactionModel.mouseup()'); + } + + if (state.tmp.dygraph_highlight_after !== null) { + //console.log('done highlight selection'); + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + if (!(event.offsetX && event.offsetY)) { + event.offsetX = event.layerX - event.target.offsetLeft; + event.offsetY = event.layerY - event.target.offsetTop; + } + + NETDATA.globalChartUnderlay.set(state + , state.tmp.dygraph_highlight_after + , dygraph.toDataXCoord(event.offsetX) + , state.view_after + , state.view_before + ); + + state.tmp.dygraph_highlight_after = null; + + context.isZooming = false; + dygraph.clearZoomRect_(); + dygraph.drawGraph_(false); + + // refresh all the charts immediately + NETDATA.options.auto_refresher_stop_until = 0; + } else if (context.isPanning) { + //console.log('done panning'); + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + state.tmp.dygraph_user_action = true; + Dygraph.endPan(event, dygraph, context); + + // refresh all the charts immediately + NETDATA.options.auto_refresher_stop_until = 0; + } else if (context.isZooming) { + //console.log('done zomming'); + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + state.tmp.dygraph_user_action = true; + Dygraph.endZoom(event, dygraph, context); + + // refresh all the charts immediately + NETDATA.options.auto_refresher_stop_until = 0; + } + }, + click: function (event, dygraph, context) { + void(dygraph); + void(context); + + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('interactionModel.click()'); + } + + event.preventDefault(); + }, + dblclick: function (event, dygraph, context) { + void(event); + void(dygraph); + void(context); + + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('interactionModel.dblclick()'); + } + NETDATA.resetAllCharts(state); + }, + wheel: function (event, dygraph, context) { + void(context); + + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('interactionModel.wheel()'); + } + + // 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. + let xOffset = g.toDomCoords(g.xAxisRange()[0], null)[0]; + let yar0 = g.yAxisRange(0); + + // This is calculating the pixel of the highest value. (Top pixel) + let 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). + let x = offsetX - xOffset; + let y = offsetY - yOffset; + + // This is computing the rightmost pixel, effectively defining the + // width. + let w = g.toDomCoords(g.xAxisRange()[1], null)[0] - xOffset; + + // This is computing the lowest pixel, effectively defining the height. + let h = g.toDomCoords(null, yar0[0])[1] - yOffset; + + // Percentage from the left. + let xPct = w === 0 ? 0 : (x / w); + // Percentage from the top. + let 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) { + let delta = axis[1] - axis[0]; + let increment = delta * zoomInPercentage; + let foo = [increment * bias, increment * (1 - bias)]; + + return [axis[0] + foo[0], axis[1] - foo[1]]; + } + + let yAxes = g.yAxisRanges(); + let newYAxes = []; + for (let 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.tmp.dygraph_user_action = true; + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + // http://dygraphs.com/gallery/interaction-api.js + let normal_def; + if (typeof event.wheelDelta === 'number' && !isNaN(event.wheelDelta)) + // chrome + { + normal_def = event.wheelDelta / 40; + } else + // firefox + { + normal_def = event.deltaY * -1.2; + } + + let normal = (event.detail) ? event.detail * -1 : normal_def; + let percentage = normal / 50; + + if (!(event.offsetX && event.offsetY)) { + event.offsetX = event.layerX - event.target.offsetLeft; + event.offsetY = event.layerY - event.target.offsetTop; + } + + let percentages = offsetToPercentage(dygraph, event.offsetX, event.offsetY); + let xPct = percentages[0]; + let yPct = percentages[1]; + + let new_x_range = zoomRange(dygraph, percentage, xPct, yPct); + let after = new_x_range[0]; + let before = new_x_range[1]; + + let first = state.netdata_first + state.data_update_every; + let last = state.netdata_last + state.data_update_every; + + if (before > last) { + after -= (before - last); + before = last; + } + if (after < first) { + after = first; + } + + state.setMode('zoom'); + state.updateChartPanOrZoom(after, before, function () { + dygraph.updateOptions({dateWindow: [after, before]}); + }); + + event.preventDefault(); + } + }, + touchstart: function (event, dygraph, context) { + state.tmp.dygraph_mouse_down = true; + + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('interactionModel.touchstart()'); + } + + state.tmp.dygraph_user_action = true; + state.setMode('zoom'); + state.pauseChart(); + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + Dygraph.defaultInteractionModel.touchstart(event, dygraph, context); + + // we overwrite the touch directions at the end, to overwrite + // the internal default of dygraph + context.touchDirections = {x: true, y: false}; + + state.dygraph_last_touch_start = Date.now(); + 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 || state.debug) { + state.log('interactionModel.touchmove()'); + } + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + state.tmp.dygraph_user_action = true; + Dygraph.defaultInteractionModel.touchmove(event, dygraph, context); + + state.dygraph_last_touch_move = Date.now(); + }, + touchend: function (event, dygraph, context) { + state.tmp.dygraph_mouse_down = false; + + if (NETDATA.options.debug.dygraph || state.debug) { + state.log('interactionModel.touchend()'); + } + + NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.delay(); + + state.tmp.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) { + NETDATA.globalSelectionSync.dontSyncBefore = 0; + NETDATA.globalSelectionSync.setMaster(state); + + // internal api of dygraph + let pct = (state.dygraph_last_touch_page_x - (dygraph.plotter_.area.x + state.element.getBoundingClientRect().left)) / dygraph.plotter_.area.w; + console.log('pct: ' + pct.toString()); + + let t = Math.round(state.view_after + (state.view_before - state.view_after) * pct); + if (NETDATA.dygraphSetSelection(state, t)) { + NETDATA.globalSelectionSync.sync(state, t); + } + } + + // if it was double tap within double click time, reset the charts + let now = Date.now(); + if (typeof state.dygraph_last_touch_end !== 'undefined') { + if (state.dygraph_last_touch_move === 0) { + let 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; + + // refresh all the charts immediately + NETDATA.options.auto_refresher_stop_until = 0; + } + } + }; + + if (NETDATA.chartLibraries.dygraph.isLogScale(state)) { + if (Array.isArray(state.tmp.dygraph_options.valueRange) && state.tmp.dygraph_options.valueRange[0] <= 0) { + state.tmp.dygraph_options.valueRange[0] = null; + } + } + + if (NETDATA.chartLibraries.dygraph.isSparkline(state)) { + state.tmp.dygraph_options.drawGrid = false; + state.tmp.dygraph_options.drawAxis = false; + state.tmp.dygraph_options.title = undefined; + state.tmp.dygraph_options.ylabel = undefined; + state.tmp.dygraph_options.yLabelWidth = 0; + //state.tmp.dygraph_options.labelsDivWidth = 120; + //state.tmp.dygraph_options.labelsDivStyles.width = '120px'; + state.tmp.dygraph_options.labelsSeparateLines = true; + state.tmp.dygraph_options.rightGap = 0; + state.tmp.dygraph_options.yRangePad = 1; + state.tmp.dygraph_options.axes.x.drawAxis = false; + state.tmp.dygraph_options.axes.y.drawAxis = false; + } + + if (smooth) { + state.tmp.dygraph_smooth_eligible = true; + + if (NETDATA.options.current.smooth_plot) { + state.tmp.dygraph_options.plotter = smoothPlotter; + } + } + else { + state.tmp.dygraph_smooth_eligible = false; + } + + if (netdataSnapshotData !== null && NETDATA.globalPanAndZoom.isActive() && NETDATA.globalPanAndZoom.isMaster(state) === false) { + // pan and zoom on snapshots + state.tmp.dygraph_options.dateWindow = [NETDATA.globalPanAndZoom.force_after_ms, NETDATA.globalPanAndZoom.force_before_ms]; + //state.tmp.dygraph_options.isZoomedIgnoreProgrammaticZoom = true; + } + + state.tmp.dygraph_instance = new Dygraph(state.element_chart, + data.result.data, state.tmp.dygraph_options); + + + state.tmp.dygraph_history_tip_element = document.createElement('div'); + state.tmp.dygraph_history_tip_element.innerHTML = ` + + Want to extend your history of real-time metrics? +
    + + Configure Netdata's history + or use the DB engine. +
    + `; + state.tmp.dygraph_history_tip_element.className = 'dygraph__history-tip'; + state.element_chart.appendChild(state.tmp.dygraph_history_tip_element); + + + state.tmp.dygraph_force_zoom = false; + state.tmp.dygraph_user_action = false; + state.tmp.dygraph_last_rendered = Date.now(); + state.tmp.dygraph_highlight_after = null; + + if (state.tmp.dygraph_options.valueRange[0] === null && state.tmp.dygraph_options.valueRange[1] === null) { + if (typeof state.tmp.dygraph_instance.axes_[0].extremeRange !== 'undefined') { + state.tmp.__commonMin = NETDATA.dataAttribute(state.element, 'common-min', null); + state.tmp.__commonMax = NETDATA.dataAttribute(state.element, 'common-max', null); + } else { + state.log('incompatible version of Dygraph detected'); + state.tmp.__commonMin = null; + state.tmp.__commonMax = null; + } + } else { + // if the user gave a valueRange, respect it + state.tmp.__commonMin = null; + state.tmp.__commonMax = null; + } + + 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") { + return callback(); + } + }); + } else { + NETDATA.chartLibraries.sparkline.enabled = false; + if (typeof callback === "function") { + return 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) { + let type = NETDATA.dataAttribute(state.element, 'sparkline-type', 'line'); + let lineColor = NETDATA.dataAttribute(state.element, 'sparkline-linecolor', state.chartCustomColors()[0]); + let fillColor = NETDATA.dataAttribute(state.element, 'sparkline-fillcolor', ((state.chart.chart_type === 'line') ? NETDATA.themes.current.background : NETDATA.colorLuminance(lineColor, NETDATA.chartDefaults.fill_luminance))); + let chartRangeMin = NETDATA.dataAttribute(state.element, 'sparkline-chartrangemin', undefined); + let chartRangeMax = NETDATA.dataAttribute(state.element, 'sparkline-chartrangemax', undefined); + let composite = NETDATA.dataAttribute(state.element, 'sparkline-composite', undefined); + let enableTagOptions = NETDATA.dataAttribute(state.element, 'sparkline-enabletagoptions', undefined); + let tagOptionPrefix = NETDATA.dataAttribute(state.element, 'sparkline-tagoptionprefix', undefined); + let tagValuesAttribute = NETDATA.dataAttribute(state.element, 'sparkline-tagvaluesattribute', undefined); + let disableHiddenCheck = NETDATA.dataAttribute(state.element, 'sparkline-disablehiddencheck', undefined); + let defaultPixelsPerValue = NETDATA.dataAttribute(state.element, 'sparkline-defaultpixelspervalue', undefined); + let spotColor = NETDATA.dataAttribute(state.element, 'sparkline-spotcolor', undefined); + let minSpotColor = NETDATA.dataAttribute(state.element, 'sparkline-minspotcolor', undefined); + let maxSpotColor = NETDATA.dataAttribute(state.element, 'sparkline-maxspotcolor', undefined); + let spotRadius = NETDATA.dataAttribute(state.element, 'sparkline-spotradius', undefined); + let valueSpots = NETDATA.dataAttribute(state.element, 'sparkline-valuespots', undefined); + let highlightSpotColor = NETDATA.dataAttribute(state.element, 'sparkline-highlightspotcolor', undefined); + let highlightLineColor = NETDATA.dataAttribute(state.element, 'sparkline-highlightlinecolor', undefined); + let lineWidth = NETDATA.dataAttribute(state.element, 'sparkline-linewidth', undefined); + let normalRangeMin = NETDATA.dataAttribute(state.element, 'sparkline-normalrangemin', undefined); + let normalRangeMax = NETDATA.dataAttribute(state.element, 'sparkline-normalrangemax', undefined); + let drawNormalOnTop = NETDATA.dataAttribute(state.element, 'sparkline-drawnormalontop', undefined); + let xvalues = NETDATA.dataAttribute(state.element, 'sparkline-xvalues', undefined); + let chartRangeClip = NETDATA.dataAttribute(state.element, 'sparkline-chartrangeclip', undefined); + let chartRangeMinX = NETDATA.dataAttribute(state.element, 'sparkline-chartrangeminx', undefined); + let chartRangeMaxX = NETDATA.dataAttribute(state.element, 'sparkline-chartrangemaxx', undefined); + let disableInteraction = NETDATA.dataAttributeBoolean(state.element, 'sparkline-disableinteraction', false); + let disableTooltips = NETDATA.dataAttributeBoolean(state.element, 'sparkline-disabletooltips', false); + let disableHighlight = NETDATA.dataAttributeBoolean(state.element, 'sparkline-disablehighlight', false); + let highlightLighten = NETDATA.dataAttribute(state.element, 'sparkline-highlightlighten', 1.4); + let highlightColor = NETDATA.dataAttribute(state.element, 'sparkline-highlightcolor', undefined); + let tooltipContainer = NETDATA.dataAttribute(state.element, 'sparkline-tooltipcontainer', undefined); + let tooltipClassname = NETDATA.dataAttribute(state.element, 'sparkline-tooltipclassname', undefined); + let tooltipFormat = NETDATA.dataAttribute(state.element, 'sparkline-tooltipformat', undefined); + let tooltipPrefix = NETDATA.dataAttribute(state.element, 'sparkline-tooltipprefix', undefined); + let tooltipSuffix = NETDATA.dataAttribute(state.element, 'sparkline-tooltipsuffix', ' ' + state.units_current); + let tooltipSkipNull = NETDATA.dataAttributeBoolean(state.element, 'sparkline-tooltipskipnull', true); + let tooltipValueLookups = NETDATA.dataAttribute(state.element, 'sparkline-tooltipvaluelookups', undefined); + let tooltipFormatFieldlist = NETDATA.dataAttribute(state.element, 'sparkline-tooltipformatfieldlist', undefined); + let tooltipFormatFieldlistKey = NETDATA.dataAttribute(state.element, 'sparkline-tooltipformatfieldlistkey', undefined); + let numberFormatter = NETDATA.dataAttribute(state.element, 'sparkline-numberformatter', function (n) { + return n.toFixed(2); + }); + let numberDigitGroupSep = NETDATA.dataAttribute(state.element, 'sparkline-numberdigitgroupsep', undefined); + let numberDecimalMark = NETDATA.dataAttribute(state.element, 'sparkline-numberdecimalmark', undefined); + let numberDigitGroupCount = NETDATA.dataAttribute(state.element, 'sparkline-numberdigitgroupcount', undefined); + let animatedZooms = NETDATA.dataAttributeBoolean(state.element, 'sparkline-animatedzooms', false); + + if (spotColor === 'disable') { + spotColor = ''; + } + if (minSpotColor === 'disable') { + minSpotColor = ''; + } + if (maxSpotColor === 'disable') { + maxSpotColor = ''; + } + + // state.log('sparkline type ' + type + ', lineColor: ' + lineColor + ', fillColor: ' + fillColor); + + 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; +}; +// google charts + +// Codacy declarations +/* global google */ + +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") { + return callback(); + } + }); + } else { + NETDATA.chartLibraries.google.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } +}; + +NETDATA.googleChartUpdate = function (state, data) { + let datatable = new google.visualization.DataTable(data.result); + state.google_instance.draw(datatable, state.google_options); + return true; +}; + +NETDATA.googleChartCreate = function (state, data) { + let 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_current, + 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; +}; +// 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") { + return callback(); + } + }) + } + else { + NETDATA.chartLibraries.gauge.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } +}; + +NETDATA.gaugeAnimation = function (state, status) { + let speed = 32; + + if (typeof status === 'boolean' && status === false) { + speed = 1000000000; + } else if (typeof status === 'number') { + speed = status; + } + + // console.log('gauge speed ' + speed); + state.tmp.gauge_instance.animationSpeed = speed; + state.tmp.___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) { + let t = min; + min = max; + max = t; + } + else if (min === max) { + max = min + 1; + } + + state.legendFormatValueDecimalsFromMinMax(min, max); + + // 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 + let pcent = (value - min) * 100 / (max - min); + + // bug fix for gauge.js 1.3.1 + // if the value is the absolute min or max, the chart is broken + if (pcent < 0.001) { + pcent = 0.001; + } + if (pcent > 99.999) { + pcent = 99.999; + } + + state.tmp.gauge_instance.set(pcent); + // console.log('gauge set ' + pcent + ', value ' + value + ', min ' + min + ', max ' + max); + + state.tmp.___gaugeOld__.value = value; + state.tmp.___gaugeOld__.min = min; + state.tmp.___gaugeOld__.max = max; +}; + +NETDATA.gaugeSetLabels = function (state, value, min, max) { + if (state.tmp.___gaugeOld__.valueLabel !== value) { + state.tmp.___gaugeOld__.valueLabel = value; + state.tmp.gaugeChartLabel.innerText = state.legendFormatValue(value); + } + if (state.tmp.___gaugeOld__.minLabel !== min) { + state.tmp.___gaugeOld__.minLabel = min; + state.tmp.gaugeChartMin.innerText = state.legendFormatValue(min); + } + if (state.tmp.___gaugeOld__.maxLabel !== max) { + state.tmp.___gaugeOld__.maxLabel = max; + state.tmp.gaugeChartMax.innerText = state.legendFormatValue(max); + } +}; + +NETDATA.gaugeClearSelection = function (state, force) { + if (typeof state.tmp.gaugeEvent !== 'undefined' && typeof state.tmp.gaugeEvent.timer !== 'undefined') { + NETDATA.timeout.clear(state.tmp.gaugeEvent.timer); + state.tmp.gaugeEvent.timer = undefined; + } + + if (state.isAutoRefreshable() && state.data !== null && force !== true) { + NETDATA.gaugeChartUpdate(state, state.data); + } else { + NETDATA.gaugeAnimation(state, false); + NETDATA.gaugeSetLabels(state, null, null, null); + NETDATA.gaugeSet(state, null, null, null); + } + + NETDATA.gaugeAnimation(state, true); + return true; +}; + +NETDATA.gaugeSetSelection = function (state, t) { + if (state.timeIsVisible(t) !== true) { + return NETDATA.gaugeClearSelection(state, true); + } + + let slot = state.calculateRowForTime(t); + if (slot < 0 || slot >= state.data.result.length) { + return NETDATA.gaugeClearSelection(state, true); + } + + if (typeof state.tmp.gaugeEvent === 'undefined') { + state.tmp.gaugeEvent = { + timer: undefined, + value: 0, + min: 0, + max: 0 + }; + } + + let value = state.data.result[state.data.result.length - 1 - slot]; + let min = (state.tmp.gaugeMin === null) ? NETDATA.commonMin.get(state) : state.tmp.gaugeMin; + let max = (state.tmp.gaugeMax === null) ? NETDATA.commonMax.get(state) : state.tmp.gaugeMax; + + // make sure it is zero based + // but only if it has not been set by the user + if (state.tmp.gaugeMin === null && min > 0) { + min = 0; + } + if (state.tmp.gaugeMax === null && max < 0) { + max = 0; + } + + state.tmp.gaugeEvent.value = value; + state.tmp.gaugeEvent.min = min; + state.tmp.gaugeEvent.max = max; + NETDATA.gaugeSetLabels(state, value, min, max); + + if (state.tmp.gaugeEvent.timer === undefined) { + NETDATA.gaugeAnimation(state, false); + + state.tmp.gaugeEvent.timer = NETDATA.timeout.set(function () { + state.tmp.gaugeEvent.timer = undefined; + NETDATA.gaugeSet(state, state.tmp.gaugeEvent.value, state.tmp.gaugeEvent.min, state.tmp.gaugeEvent.max); + }, 0); + } + + return true; +}; + +NETDATA.gaugeChartUpdate = function (state, data) { + let value, min, max; + + if (NETDATA.globalPanAndZoom.isActive() || state.isAutoRefreshable() === false) { + NETDATA.gaugeSetLabels(state, null, null, null); + state.tmp.gauge_instance.set(0); + } else { + value = data.result[0]; + min = (state.tmp.gaugeMin === null) ? NETDATA.commonMin.get(state) : state.tmp.gaugeMin; + max = (state.tmp.gaugeMax === null) ? NETDATA.commonMax.get(state) : state.tmp.gaugeMax; + if (value < min) { + min = value; + } + if (value > max) { + max = value; + } + + // make sure it is zero based + // but only if it has not been set by the user + if (state.tmp.gaugeMin === null && min > 0) { + min = 0; + } + if (state.tmp.gaugeMax === null && max < 0) { + max = 0; + } + + NETDATA.gaugeSet(state, value, min, max); + NETDATA.gaugeSetLabels(state, value, min, max); + } + + return true; +}; + +NETDATA.gaugeChartCreate = function (state, data) { + // let chart = $(state.element_chart); + + let value = data.result[0]; + let min = NETDATA.dataAttribute(state.element, 'gauge-min-value', null); + let max = NETDATA.dataAttribute(state.element, 'gauge-max-value', null); + // let adjust = NETDATA.dataAttribute(state.element, 'gauge-adjust', null); + let pointerColor = NETDATA.dataAttribute(state.element, 'gauge-pointer-color', NETDATA.themes.current.gauge_pointer); + let strokeColor = NETDATA.dataAttribute(state.element, 'gauge-stroke-color', NETDATA.themes.current.gauge_stroke); + let startColor = NETDATA.dataAttribute(state.element, 'gauge-start-color', state.chartCustomColors()[0]); + let stopColor = NETDATA.dataAttribute(state.element, 'gauge-stop-color', void 0); + let generateGradient = NETDATA.dataAttribute(state.element, 'gauge-generate-gradient', false); + + if (min === null) { + min = NETDATA.commonMin.get(state); + state.tmp.gaugeMin = null; + } else { + state.tmp.gaugeMin = min; + } + + if (max === null) { + max = NETDATA.commonMax.get(state); + state.tmp.gaugeMax = null; + } else { + state.tmp.gaugeMax = max; + } + + // make sure it is zero based + // but only if it has not been set by the user + if (state.tmp.gaugeMin === null && min > 0) { + min = 0; + } + if (state.tmp.gaugeMax === null && max < 0) { + max = 0; + } + + let width = state.chartWidth(), height = state.chartHeight(); //, ratio = 1.5; + // console.log('gauge width: ' + width.toString() + ', height: ' + height.toString()); + //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'; + + let lum_d = 0.05; + + let options = { + lines: 12, // The number of lines to draw + angle: 0.14, // The span of the gauge arc + lineWidth: 0.57, // The line thickness + radiusScale: 1.0, // Relative radius + pointer: { + length: 0.85, // 0.9 The radius of the inner circle + strokeWidth: 0.045, // The rotation offset + color: pointerColor // Fill color + }, + limitMax: true, // If false, the max value of the gauge will be updated if value surpass max + limitMin: true, // If true, the min value of the gauge will be fixed unless you set it manually + colorStart: startColor, // Colors + colorStop: stopColor, // just experiment with them + strokeColor: strokeColor, // to see which ones work best for you + generateGradient: (generateGradient === true), // gmosx: + gradientType: 0, + highDpiSupport: true // High resolution support + }; + + 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 = []; + let len = generateGradient.length; + while (len--) { + let pcent = generateGradient[len]; + let color = NETDATA.dataAttribute(state.element, 'gauge-gradient-percent-color-' + pcent.toString(), false); + if (color !== false) { + let a = []; + 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) { + //noinspection PointlessArithmeticExpressionJS + 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.tmp.gauge_canvas = document.createElement('canvas'); + state.tmp.gauge_canvas.id = 'gauge-' + state.uuid + '-canvas'; + state.tmp.gauge_canvas.className = 'gaugeChart'; + state.tmp.gauge_canvas.width = width; + state.tmp.gauge_canvas.height = height; + state.element_chart.appendChild(state.tmp.gauge_canvas); + + let valuefontsize = Math.floor(height / 5); + let valuetop = Math.round((height - valuefontsize) / 3.2); + state.tmp.gaugeChartLabel = document.createElement('span'); + state.tmp.gaugeChartLabel.className = 'gaugeChartLabel'; + state.tmp.gaugeChartLabel.style.fontSize = valuefontsize + 'px'; + state.tmp.gaugeChartLabel.style.top = valuetop.toString() + 'px'; + state.element_chart.appendChild(state.tmp.gaugeChartLabel); + + let titlefontsize = Math.round(valuefontsize / 2.1); + let titletop = 0; + state.tmp.gaugeChartTitle = document.createElement('span'); + state.tmp.gaugeChartTitle.className = 'gaugeChartTitle'; + state.tmp.gaugeChartTitle.innerText = state.title; + state.tmp.gaugeChartTitle.style.fontSize = titlefontsize + 'px'; + state.tmp.gaugeChartTitle.style.lineHeight = titlefontsize + 'px'; + state.tmp.gaugeChartTitle.style.top = titletop.toString() + 'px'; + state.element_chart.appendChild(state.tmp.gaugeChartTitle); + + let unitfontsize = Math.round(titlefontsize * 0.9); + state.tmp.gaugeChartUnits = document.createElement('span'); + state.tmp.gaugeChartUnits.className = 'gaugeChartUnits'; + state.tmp.gaugeChartUnits.innerText = state.units_current; + state.tmp.gaugeChartUnits.style.fontSize = unitfontsize + 'px'; + state.element_chart.appendChild(state.tmp.gaugeChartUnits); + + state.tmp.gaugeChartMin = document.createElement('span'); + state.tmp.gaugeChartMin.className = 'gaugeChartMin'; + state.tmp.gaugeChartMin.style.fontSize = Math.round(valuefontsize * 0.75).toString() + 'px'; + state.element_chart.appendChild(state.tmp.gaugeChartMin); + + state.tmp.gaugeChartMax = document.createElement('span'); + state.tmp.gaugeChartMax.className = 'gaugeChartMax'; + state.tmp.gaugeChartMax.style.fontSize = Math.round(valuefontsize * 0.75).toString() + 'px'; + state.element_chart.appendChild(state.tmp.gaugeChartMax); + + // when we just re-create the chart + // do not animate the first update + let animate = true; + if (typeof state.tmp.gauge_instance !== 'undefined') { + animate = false; + } + + state.tmp.gauge_instance = new Gauge(state.tmp.gauge_canvas).setOptions(options); // create sexy gauge! + + state.tmp.___gaugeOld__ = { + value: value, + min: min, + max: max, + valueLabel: null, + minLabel: null, + maxLabel: null + }; + + // we will always feed a percentage + state.tmp.gauge_instance.minValue = 0; + state.tmp.gauge_instance.maxValue = 100; + + NETDATA.gaugeAnimation(state, animate); + NETDATA.gaugeSet(state, value, min, max); + NETDATA.gaugeSetLabels(state, value, min, max); + NETDATA.gaugeAnimation(state, true); + + state.legendSetUnitsString = function (units) { + if (typeof state.tmp.gaugeChartUnits !== 'undefined' && state.tmp.units !== units) { + state.tmp.gaugeChartUnits.innerText = units; + state.tmp.___gaugeOld__.valueLabel = null; + state.tmp.___gaugeOld__.minLabel = null; + state.tmp.___gaugeOld__.maxLabel = null; + state.tmp.units = units; + } + }; + state.legendShowUndefined = function () { + if (typeof state.tmp.gauge_instance !== 'undefined') { + NETDATA.gaugeClearSelection(state); + } + }; + + return true; +}; +// ---------------------------------------------------------------------------------------------------------------- + +NETDATA.easypiechartPercentFromValueMinMax = function (state, value, min, max) { + if (typeof value !== 'number') { + value = 0; + } + if (typeof min !== 'number') { + min = 0; + } + if (typeof max !== 'number') { + max = 0; + } + + if (min > max) { + let t = min; + min = max; + max = t; + } + + if (min > value) { + min = value; + } + if (max < value) { + max = value; + } + + state.legendFormatValueDecimalsFromMinMax(min, max); + + if (state.tmp.easyPieChartMin === null && min > 0) { + min = 0; + } + if (state.tmp.easyPieChartMax === null && max < 0) { + max = 0; + } + + let pcent; + + if (min < 0 && max > 0) { + // it is both positive and negative + // zero at the top center of the chart + max = (-min > max) ? -min : max; + pcent = Math.round(value * 100 / max); + } else if (value >= 0 && min >= 0 && max >= 0) { + // clockwise + pcent = Math.round((value - min) * 100 / (max - min)); + if (pcent === 0) { + pcent = 0.1; + } + } else { + // counter clockwise + pcent = Math.round((value - max) * 100 / (max - min)); + if (pcent === 0) { + pcent = -0.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") { + return callback(); + } + }) + } else { + NETDATA.chartLibraries.easypiechart.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } +}; + +NETDATA.easypiechartClearSelection = function (state, force) { + if (typeof state.tmp.easyPieChartEvent !== 'undefined' && typeof state.tmp.easyPieChartEvent.timer !== 'undefined') { + NETDATA.timeout.clear(state.tmp.easyPieChartEvent.timer); + state.tmp.easyPieChartEvent.timer = undefined; + } + + if (state.isAutoRefreshable() && state.data !== null && force !== true) { + NETDATA.easypiechartChartUpdate(state, state.data); + } + else { + state.tmp.easyPieChartLabel.innerText = state.legendFormatValue(null); + state.tmp.easyPieChart_instance.update(0); + } + state.tmp.easyPieChart_instance.enableAnimation(); + + return true; +}; + +NETDATA.easypiechartSetSelection = function (state, t) { + if (state.timeIsVisible(t) !== true) { + return NETDATA.easypiechartClearSelection(state, true); + } + + let slot = state.calculateRowForTime(t); + if (slot < 0 || slot >= state.data.result.length) { + return NETDATA.easypiechartClearSelection(state, true); + } + + if (typeof state.tmp.easyPieChartEvent === 'undefined') { + state.tmp.easyPieChartEvent = { + timer: undefined, + value: 0, + pcent: 0 + }; + } + + let value = state.data.result[state.data.result.length - 1 - slot]; + let min = (state.tmp.easyPieChartMin === null) ? NETDATA.commonMin.get(state) : state.tmp.easyPieChartMin; + let max = (state.tmp.easyPieChartMax === null) ? NETDATA.commonMax.get(state) : state.tmp.easyPieChartMax; + let pcent = NETDATA.easypiechartPercentFromValueMinMax(state, value, min, max); + + state.tmp.easyPieChartEvent.value = value; + state.tmp.easyPieChartEvent.pcent = pcent; + state.tmp.easyPieChartLabel.innerText = state.legendFormatValue(value); + + if (state.tmp.easyPieChartEvent.timer === undefined) { + state.tmp.easyPieChart_instance.disableAnimation(); + + state.tmp.easyPieChartEvent.timer = NETDATA.timeout.set(function () { + state.tmp.easyPieChartEvent.timer = undefined; + state.tmp.easyPieChart_instance.update(state.tmp.easyPieChartEvent.pcent); + }, 0); + } + + return true; +}; + +NETDATA.easypiechartChartUpdate = function (state, data) { + let value, min, max, pcent; + + if (NETDATA.globalPanAndZoom.isActive() || state.isAutoRefreshable() === false) { + value = null; + pcent = 0; + } + else { + value = data.result[0]; + min = (state.tmp.easyPieChartMin === null) ? NETDATA.commonMin.get(state) : state.tmp.easyPieChartMin; + max = (state.tmp.easyPieChartMax === null) ? NETDATA.commonMax.get(state) : state.tmp.easyPieChartMax; + pcent = NETDATA.easypiechartPercentFromValueMinMax(state, value, min, max); + } + + state.tmp.easyPieChartLabel.innerText = state.legendFormatValue(value); + state.tmp.easyPieChart_instance.update(pcent); + return true; +}; + +NETDATA.easypiechartChartCreate = function (state, data) { + let chart = $(state.element_chart); + + let value = data.result[0]; + let min = NETDATA.dataAttribute(state.element, 'easypiechart-min-value', null); + let max = NETDATA.dataAttribute(state.element, 'easypiechart-max-value', null); + + if (min === null) { + min = NETDATA.commonMin.get(state); + state.tmp.easyPieChartMin = null; + } + else { + state.tmp.easyPieChartMin = min; + } + + if (max === null) { + max = NETDATA.commonMax.get(state); + state.tmp.easyPieChartMax = null; + } + else { + state.tmp.easyPieChartMax = max; + } + + let size = state.chartWidth(); + let stroke = Math.floor(size / 22); + if (stroke < 3) { + stroke = 2; + } + + let valuefontsize = Math.floor((size * 2 / 3) / 5); + let valuetop = Math.round((size - valuefontsize - (size / 40)) / 2); + state.tmp.easyPieChartLabel = document.createElement('span'); + state.tmp.easyPieChartLabel.className = 'easyPieChartLabel'; + state.tmp.easyPieChartLabel.innerText = state.legendFormatValue(value); + state.tmp.easyPieChartLabel.style.fontSize = valuefontsize + 'px'; + state.tmp.easyPieChartLabel.style.top = valuetop.toString() + 'px'; + state.element_chart.appendChild(state.tmp.easyPieChartLabel); + + let titlefontsize = Math.round(valuefontsize * 1.6 / 3); + let titletop = Math.round(valuetop - (titlefontsize * 2) - (size / 40)); + state.tmp.easyPieChartTitle = document.createElement('span'); + state.tmp.easyPieChartTitle.className = 'easyPieChartTitle'; + state.tmp.easyPieChartTitle.innerText = state.title; + state.tmp.easyPieChartTitle.style.fontSize = titlefontsize + 'px'; + state.tmp.easyPieChartTitle.style.lineHeight = titlefontsize + 'px'; + state.tmp.easyPieChartTitle.style.top = titletop.toString() + 'px'; + state.element_chart.appendChild(state.tmp.easyPieChartTitle); + + let unitfontsize = Math.round(titlefontsize * 0.9); + let unittop = Math.round(valuetop + (valuefontsize + unitfontsize) + (size / 40)); + state.tmp.easyPieChartUnits = document.createElement('span'); + state.tmp.easyPieChartUnits.className = 'easyPieChartUnits'; + state.tmp.easyPieChartUnits.innerText = state.units_current; + state.tmp.easyPieChartUnits.style.fontSize = unitfontsize + 'px'; + state.tmp.easyPieChartUnits.style.top = unittop.toString() + 'px'; + state.element_chart.appendChild(state.tmp.easyPieChartUnits); + + let barColor = NETDATA.dataAttribute(state.element, 'easypiechart-barcolor', undefined); + if (typeof barColor === 'undefined' || barColor === null) { + barColor = state.chartCustomColors()[0]; + } else { + //
    + let tmp = eval(barColor); + if (typeof tmp === 'function') { + barColor = tmp; + } + } + + let pcent = NETDATA.easypiechartPercentFromValueMinMax(state, value, min, max); + chart.data('data-percent', pcent); + + chart.easyPieChart({ + barColor: barColor, + trackColor: NETDATA.dataAttribute(state.element, 'easypiechart-trackcolor', NETDATA.themes.current.easypiechart_track), + scaleColor: NETDATA.dataAttribute(state.element, 'easypiechart-scalecolor', NETDATA.themes.current.easypiechart_scale), + scaleLength: NETDATA.dataAttribute(state.element, 'easypiechart-scalelength', 5), + lineCap: NETDATA.dataAttribute(state.element, 'easypiechart-linecap', 'round'), + lineWidth: NETDATA.dataAttribute(state.element, 'easypiechart-linewidth', stroke), + trackWidth: NETDATA.dataAttribute(state.element, 'easypiechart-trackwidth', undefined), + size: NETDATA.dataAttribute(state.element, 'easypiechart-size', size), + rotate: NETDATA.dataAttribute(state.element, 'easypiechart-rotate', 0), + animate: NETDATA.dataAttribute(state.element, 'easypiechart-animate', {duration: 500, enabled: true}), + easing: NETDATA.dataAttribute(state.element, 'easypiechart-easing', undefined) + }); + + // when we just re-create the chart + // do not animate the first update + let animate = true; + if (typeof state.tmp.easyPieChart_instance !== 'undefined') { + animate = false; + } + + state.tmp.easyPieChart_instance = chart.data('easyPieChart'); + if (animate === false) { + state.tmp.easyPieChart_instance.disableAnimation(); + } + state.tmp.easyPieChart_instance.update(pcent); + if (animate === false) { + state.tmp.easyPieChart_instance.enableAnimation(); + } + + state.legendSetUnitsString = function (units) { + if (typeof state.tmp.easyPieChartUnits !== 'undefined' && state.tmp.units !== units) { + state.tmp.easyPieChartUnits.innerText = units; + state.tmp.units = units; + } + }; + state.legendShowUndefined = function () { + if (typeof state.tmp.easyPieChart_instance !== 'undefined') { + NETDATA.easypiechartClearSelection(state); + } + }; + + return true; +}; + +// d3pie + +NETDATA.d3pieInitialize = function (callback) { + if (typeof netdataNoD3pie === 'undefined' || !netdataNoD3pie) { + + // d3pie requires D3 + if (!NETDATA.chartLibraries.d3.initialized) { + if (NETDATA.chartLibraries.d3.enabled) { + NETDATA.d3Initialize(function () { + NETDATA.d3pieInitialize(callback); + }); + } else { + NETDATA.chartLibraries.d3pie.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } + } else { + $.ajax({ + url: NETDATA.d3pie_js, + cache: true, + dataType: "script", + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function () { + NETDATA.registerChartLibrary('d3pie', NETDATA.d3pie_js); + }) + .fail(function () { + NETDATA.chartLibraries.d3pie.enabled = false; + NETDATA.error(100, NETDATA.d3pie_js); + }) + .always(function () { + if (typeof callback === "function") { + return callback(); + } + }); + } + } else { + NETDATA.chartLibraries.d3pie.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } +}; + +NETDATA.d3pieSetContent = function (state, data, index) { + state.legendFormatValueDecimalsFromMinMax( + data.min, + data.max + ); + + let content = []; + let colors = state.chartColors(); + let len = data.result.labels.length; + for (let i = 1; i < len; i++) { + let label = data.result.labels[i]; + let value = data.result.data[index][label]; + let color = colors[i - 1]; + + if (value !== null && value > 0) { + content.push({ + label: label, + value: value, + color: color + }); + } + } + + if (content.length === 0) { + content.push({ + label: 'no data', + value: 100, + color: '#666666' + }); + } + + state.tmp.d3pie_last_slot = index; + return content; +}; + +NETDATA.d3pieDateRange = function (state, data, index) { + let dt = Math.round((data.before - data.after + 1) / data.points); + let dt_str = NETDATA.seconds4human(dt); + + let before = data.result.data[index].time; + let after = before - (dt * 1000); + + let d1 = NETDATA.dateTime.localeDateString(after); + let t1 = NETDATA.dateTime.localeTimeString(after); + let d2 = NETDATA.dateTime.localeDateString(before); + let t2 = NETDATA.dateTime.localeTimeString(before); + + if (d1 === d2) { + return d1 + ' ' + t1 + ' to ' + t2 + ', ' + dt_str; + } + + return d1 + ' ' + t1 + ' to ' + d2 + ' ' + t2 + ', ' + dt_str; +}; + +NETDATA.d3pieSetSelection = function (state, t) { + if (state.timeIsVisible(t) !== true) { + return NETDATA.d3pieClearSelection(state, true); + } + + let slot = state.calculateRowForTime(t); + slot = state.data.result.data.length - slot - 1; + + if (slot < 0 || slot >= state.data.result.length) { + return NETDATA.d3pieClearSelection(state, true); + } + + if (state.tmp.d3pie_last_slot === slot) { + // we already show this slot, don't do anything + return true; + } + + if (state.tmp.d3pie_timer === undefined) { + state.tmp.d3pie_timer = NETDATA.timeout.set(function () { + state.tmp.d3pie_timer = undefined; + NETDATA.d3pieChange(state, NETDATA.d3pieSetContent(state, state.data, slot), NETDATA.d3pieDateRange(state, state.data, slot)); + }, 0); + } + + return true; +}; + +NETDATA.d3pieClearSelection = function (state, force) { + if (typeof state.tmp.d3pie_timer !== 'undefined') { + NETDATA.timeout.clear(state.tmp.d3pie_timer); + state.tmp.d3pie_timer = undefined; + } + + if (state.isAutoRefreshable() && state.data !== null && force !== true) { + NETDATA.d3pieChartUpdate(state, state.data); + } else { + if (state.tmp.d3pie_last_slot !== -1) { + state.tmp.d3pie_last_slot = -1; + NETDATA.d3pieChange(state, [{label: 'no data', value: 1, color: '#666666'}], 'no data available'); + } + } + + return true; +}; + +NETDATA.d3pieChange = function (state, content, footer) { + if (state.d3pie_forced_subtitle === null) { + //state.d3pie_instance.updateProp("header.subtitle.text", state.units_current); + state.d3pie_instance.options.header.subtitle.text = state.units_current; + } + + if (state.d3pie_forced_footer === null) { + //state.d3pie_instance.updateProp("footer.text", footer); + state.d3pie_instance.options.footer.text = footer; + } + + //state.d3pie_instance.updateProp("data.content", content); + state.d3pie_instance.options.data.content = content; + state.d3pie_instance.destroy(); + state.d3pie_instance.recreate(); + return true; +}; + +NETDATA.d3pieChartUpdate = function (state, data) { + return NETDATA.d3pieChange(state, NETDATA.d3pieSetContent(state, data, 0), NETDATA.d3pieDateRange(state, data, 0)); +}; + +NETDATA.d3pieChartCreate = function (state, data) { + + state.element_chart.id = 'd3pie-' + state.uuid; + // console.log('id = ' + state.element_chart.id); + + let content = NETDATA.d3pieSetContent(state, data, 0); + + state.d3pie_forced_title = NETDATA.dataAttribute(state.element, 'd3pie-title', null); + state.d3pie_forced_subtitle = NETDATA.dataAttribute(state.element, 'd3pie-subtitle', null); + state.d3pie_forced_footer = NETDATA.dataAttribute(state.element, 'd3pie-footer', null); + + state.d3pie_options = { + header: { + title: { + text: (state.d3pie_forced_title !== null) ? state.d3pie_forced_title : state.title, + color: NETDATA.dataAttribute(state.element, 'd3pie-title-color', NETDATA.themes.current.d3pie.title), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-title-fontsize', 12), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-title-fontweight', "bold"), + font: NETDATA.dataAttribute(state.element, 'd3pie-title-font', "arial") + }, + subtitle: { + text: (state.d3pie_forced_subtitle !== null) ? state.d3pie_forced_subtitle : state.units_current, + color: NETDATA.dataAttribute(state.element, 'd3pie-subtitle-color', NETDATA.themes.current.d3pie.subtitle), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-subtitle-fontsize', 10), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-subtitle-fontweight', "normal"), + font: NETDATA.dataAttribute(state.element, 'd3pie-subtitle-font', "arial") + }, + titleSubtitlePadding: 1 + }, + footer: { + text: (state.d3pie_forced_footer !== null) ? state.d3pie_forced_footer : NETDATA.d3pieDateRange(state, data, 0), + color: NETDATA.dataAttribute(state.element, 'd3pie-footer-color', NETDATA.themes.current.d3pie.footer), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-footer-fontsize', 9), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-footer-fontweight', "bold"), + font: NETDATA.dataAttribute(state.element, 'd3pie-footer-font', "arial"), + location: NETDATA.dataAttribute(state.element, 'd3pie-footer-location', "bottom-center") // bottom-left, bottom-center, bottom-right + }, + size: { + canvasHeight: state.chartHeight(), + canvasWidth: state.chartWidth(), + pieInnerRadius: NETDATA.dataAttribute(state.element, 'd3pie-pieinnerradius', "45%"), + pieOuterRadius: NETDATA.dataAttribute(state.element, 'd3pie-pieouterradius', "80%") + }, + data: { + // none, random, value-asc, value-desc, label-asc, label-desc + sortOrder: NETDATA.dataAttribute(state.element, 'd3pie-sortorder', "value-desc"), + smallSegmentGrouping: { + enabled: NETDATA.dataAttributeBoolean(state.element, "d3pie-smallsegmentgrouping-enabled", false), + value: NETDATA.dataAttribute(state.element, 'd3pie-smallsegmentgrouping-value', 1), + // percentage, value + valueType: NETDATA.dataAttribute(state.element, 'd3pie-smallsegmentgrouping-valuetype', "percentage"), + label: NETDATA.dataAttribute(state.element, 'd3pie-smallsegmentgrouping-label', "other"), + color: NETDATA.dataAttribute(state.element, 'd3pie-smallsegmentgrouping-color', NETDATA.themes.current.d3pie.other) + }, + + // REQUIRED! This is where you enter your pie data; it needs to be an array of objects + // of this form: { label: "label", value: 1.5, color: "#000000" } - color is optional + content: content + }, + labels: { + outer: { + // label, value, percentage, label-value1, label-value2, label-percentage1, label-percentage2 + format: NETDATA.dataAttribute(state.element, 'd3pie-labels-outer-format', "label-value1"), + hideWhenLessThanPercentage: NETDATA.dataAttribute(state.element, 'd3pie-labels-outer-hidewhenlessthanpercentage', null), + pieDistance: NETDATA.dataAttribute(state.element, 'd3pie-labels-outer-piedistance', 15) + }, + inner: { + // label, value, percentage, label-value1, label-value2, label-percentage1, label-percentage2 + format: NETDATA.dataAttribute(state.element, 'd3pie-labels-inner-format', "percentage"), + hideWhenLessThanPercentage: NETDATA.dataAttribute(state.element, 'd3pie-labels-inner-hidewhenlessthanpercentage', 2) + }, + mainLabel: { + color: NETDATA.dataAttribute(state.element, 'd3pie-labels-mainLabel-color', NETDATA.themes.current.d3pie.mainlabel), // or 'segment' for dynamic color + font: NETDATA.dataAttribute(state.element, 'd3pie-labels-mainLabel-font', "arial"), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-labels-mainLabel-fontsize', 10), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-labels-mainLabel-fontweight', "normal") + }, + percentage: { + color: NETDATA.dataAttribute(state.element, 'd3pie-labels-percentage-color', NETDATA.themes.current.d3pie.percentage), + font: NETDATA.dataAttribute(state.element, 'd3pie-labels-percentage-font', "arial"), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-labels-percentage-fontsize', 10), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-labels-percentage-fontweight', "bold"), + decimalPlaces: 0 + }, + value: { + color: NETDATA.dataAttribute(state.element, 'd3pie-labels-value-color', NETDATA.themes.current.d3pie.value), + font: NETDATA.dataAttribute(state.element, 'd3pie-labels-value-font', "arial"), + fontSize: NETDATA.dataAttribute(state.element, 'd3pie-labels-value-fontsize', 10), + fontWeight: NETDATA.dataAttribute(state.element, 'd3pie-labels-value-fontweight', "bold") + }, + lines: { + enabled: NETDATA.dataAttributeBoolean(state.element, 'd3pie-labels-lines-enabled', true), + style: NETDATA.dataAttribute(state.element, 'd3pie-labels-lines-style', "curved"), + color: NETDATA.dataAttribute(state.element, 'd3pie-labels-lines-color', "segment") // "segment" or a hex color + }, + truncation: { + enabled: NETDATA.dataAttributeBoolean(state.element, 'd3pie-labels-truncation-enabled', false), + truncateLength: NETDATA.dataAttribute(state.element, 'd3pie-labels-truncation-truncatelength', 30) + }, + formatter: function (context) { + // console.log(context); + if (context.part === 'value') { + return state.legendFormatValue(context.value); + } + if (context.part === 'percentage') { + return context.label + '%'; + } + + return context.label; + } + }, + effects: { + load: { + effect: "none", // none / default + speed: 0 // commented in the d3pie code to speed it up + }, + pullOutSegmentOnClick: { + effect: "bounce", // none / linear / bounce / elastic / back + speed: 400, + size: 5 + }, + highlightSegmentOnMouseover: true, + highlightLuminosity: -0.2 + }, + tooltips: { + enabled: false, + type: "placeholder", // caption|placeholder + string: "", + placeholderParser: null, // function + styles: { + fadeInSpeed: 250, + backgroundColor: NETDATA.themes.current.d3pie.tooltip_bg, + backgroundOpacity: 0.5, + color: NETDATA.themes.current.d3pie.tooltip_fg, + borderRadius: 2, + font: "arial", + fontSize: 12, + padding: 4 + } + }, + misc: { + colors: { + background: 'transparent', // transparent or color # + // segments: state.chartColors(), + segmentStroke: NETDATA.dataAttribute(state.element, 'd3pie-misc-colors-segmentstroke', NETDATA.themes.current.d3pie.segment_stroke) + }, + gradient: { + enabled: NETDATA.dataAttributeBoolean(state.element, 'd3pie-misc-gradient-enabled', false), + percentage: NETDATA.dataAttribute(state.element, 'd3pie-misc-colors-percentage', 95), + color: NETDATA.dataAttribute(state.element, 'd3pie-misc-gradient-color', NETDATA.themes.current.d3pie.gradient_color) + }, + canvasPadding: { + top: 5, + right: 5, + bottom: 5, + left: 5 + }, + pieCenterOffset: { + x: 0, + y: 0 + }, + cssPrefix: NETDATA.dataAttribute(state.element, 'd3pie-cssprefix', null) + }, + callbacks: { + onload: null, + onMouseoverSegment: null, + onMouseoutSegment: null, + onClickSegment: null + } + }; + + state.d3pie_instance = new d3pie(state.element_chart, state.d3pie_options); + 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") + return callback(); + }); + } else { + NETDATA.chartLibraries.d3.enabled = false; + if (typeof callback === "function") + return callback(); + } +}; + +NETDATA.d3ChartUpdate = function(state, data) { + void(state); + void(data); + + return false; +}; + +NETDATA.d3ChartCreate = function(state, data) { + void(state); + void(data); + + return false; +}; + +// 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") { + return callback(); + } + }); + } else { + NETDATA.chartLibraries.peity.enabled = false; + if (typeof callback === "function") { + return callback(); + } + } +}; + +NETDATA.peityChartUpdate = function (state, data) { + state.peity_instance.innerHTML = data.result; + + if (state.peity_options.stroke !== state.chartCustomColors()[0]) { + state.peity_options.stroke = state.chartCustomColors()[0]; + if (state.chart.chart_type === 'line') { + state.peity_options.fill = NETDATA.themes.current.background; + } else { + state.peity_options.fill = NETDATA.colorLuminance(state.chartCustomColors()[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); + + state.peity_options = { + stroke: NETDATA.themes.current.foreground, + strokeWidth: NETDATA.dataAttribute(state.element, 'peity-strokewidth', 1), + width: state.chartWidth(), + height: state.chartHeight(), + fill: NETDATA.themes.current.foreground + }; + + NETDATA.peityChartUpdate(state, data); + return true; +}; + +// ---------------------------------------------------------------------------------------------------------------- +// "Text-only" chart - Just renders the raw value to the DOM + +NETDATA.textOnlyCreate = function(state, data) { + var decimalPlaces = NETDATA.dataAttribute(state.element, 'textonly-decimal-places', 1); + var prefix = NETDATA.dataAttribute(state.element, 'textonly-prefix', ''); + var suffix = NETDATA.dataAttribute(state.element, 'textonly-suffix', ''); + + // Round based on number of decimal places to show + var precision = Math.pow(10, decimalPlaces); + var value = Math.round(data.result[0] * precision) / precision; + + state.element.textContent = prefix + value + suffix; + return true; +} + +NETDATA.textOnlyUpdate = NETDATA.textOnlyCreate; +// Charts Libraries Registration + +NETDATA.chartLibraries = { + "dygraph": { + initialize: NETDATA.dygraphInitialize, + create: NETDATA.dygraphChartCreate, + update: NETDATA.dygraphChartUpdate, + resize: function (state) { + if (typeof state.tmp.dygraph_instance !== 'undefined' && typeof state.tmp.dygraph_instance.resize === 'function') { + state.tmp.dygraph_instance.resize(); + } + }, + setSelection: NETDATA.dygraphSetSelection, + clearSelection: NETDATA.dygraphClearSelection, + toolboxPanAndZoom: NETDATA.dygraphToolboxPanAndZoom, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + format: function (state) { + void(state); + return 'json'; + }, + options: function (state) { + return 'ms' + '%7C' + 'flip' + (this.isLogScale(state) ? ('%7C' + 'abs') : '').toString(); + }, + legend: function (state) { + return (this.isSparkline(state) === false && NETDATA.dataAttributeBoolean(state.element, 'legend', true) === true) ? 'right-side' : null; + }, + autoresize: function (state) { + void(state); + return true; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return true; + }, + pixels_per_point: function (state) { + return (this.isSparkline(state) === false) ? 3 : 2; + }, + isSparkline: function (state) { + if (typeof state.tmp.dygraph_sparkline === 'undefined') { + state.tmp.dygraph_sparkline = (this.theme(state) === 'sparkline'); + } + return state.tmp.dygraph_sparkline; + }, + isLogScale: function (state) { + if (typeof state.tmp.dygraph_logscale === 'undefined') { + state.tmp.dygraph_logscale = (this.theme(state) === 'logscale'); + } + return state.tmp.dygraph_logscale; + }, + theme: function (state) { + if (typeof state.tmp.dygraph_theme === 'undefined') { + state.tmp.dygraph_theme = NETDATA.dataAttribute(state.element, 'dygraph-theme', 'default'); + } + return state.tmp.dygraph_theme; + }, + container_class: function (state) { + if (this.legend(state) !== null) { + return 'netdata-container-with-legend'; + } + return 'netdata-container'; + } + }, + "sparkline": { + initialize: NETDATA.sparklineInitialize, + create: NETDATA.sparklineChartCreate, + update: NETDATA.sparklineChartUpdate, + resize: null, + setSelection: undefined, // function(state, t) { void(state); return true; }, + clearSelection: undefined, // function(state) { void(state); return true; }, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + format: function (state) { + void(state); + return 'array'; + }, + options: function (state) { + void(state); + return 'flip' + '%7C' + 'abs'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + "peity": { + initialize: NETDATA.peityInitialize, + create: NETDATA.peityChartCreate, + update: NETDATA.peityChartUpdate, + resize: null, + setSelection: undefined, // function(state, t) { void(state); return true; }, + clearSelection: undefined, // function(state) { void(state); return true; }, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + format: function (state) { + void(state); + return 'ssvcomma'; + }, + options: function (state) { + void(state); + return 'null2zero' + '%7C' + 'flip' + '%7C' + 'abs'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + // "morris": { + // initialize: NETDATA.morrisInitialize, + // create: NETDATA.morrisChartCreate, + // update: NETDATA.morrisChartUpdate, + // resize: null, + // setSelection: undefined, // function(state, t) { void(state); return true; }, + // clearSelection: undefined, // function(state) { void(state); return true; }, + // toolboxPanAndZoom: null, + // initialized: false, + // enabled: true, + // xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + // format: function(state) { void(state); return 'json'; }, + // options: function(state) { void(state); return 'objectrows' + '%7C' + 'ms'; }, + // legend: function(state) { void(state); return null; }, + // autoresize: function(state) { void(state); return false; }, + // max_updates_to_recreate: function(state) { void(state); return 50; }, + // track_colors: function(state) { void(state); return false; }, + // pixels_per_point: function(state) { void(state); return 15; }, + // container_class: function(state) { void(state); return 'netdata-container'; } + // }, + "google": { + initialize: NETDATA.googleInitialize, + create: NETDATA.googleChartCreate, + update: NETDATA.googleChartUpdate, + resize: null, + setSelection: undefined, //function(state, t) { void(state); return true; }, + clearSelection: undefined, //function(state) { void(state); return true; }, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result.rows$'), + format: function (state) { + void(state); + return 'datatable'; + }, + options: function (state) { + void(state); + return ''; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 300; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 4; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + // "raphael": { + // initialize: NETDATA.raphaelInitialize, + // create: NETDATA.raphaelChartCreate, + // update: NETDATA.raphaelChartUpdate, + // resize: null, + // setSelection: undefined, // function(state, t) { void(state); return true; }, + // clearSelection: undefined, // function(state) { void(state); return true; }, + // toolboxPanAndZoom: null, + // initialized: false, + // enabled: true, + // xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + // format: function(state) { void(state); return 'json'; }, + // options: function(state) { void(state); return ''; }, + // legend: function(state) { void(state); return null; }, + // autoresize: function(state) { void(state); return false; }, + // max_updates_to_recreate: function(state) { void(state); return 5000; }, + // track_colors: function(state) { void(state); return false; }, + // pixels_per_point: function(state) { void(state); return 3; }, + // container_class: function(state) { void(state); return 'netdata-container'; } + // }, + // "c3": { + // initialize: NETDATA.c3Initialize, + // create: NETDATA.c3ChartCreate, + // update: NETDATA.c3ChartUpdate, + // resize: null, + // setSelection: undefined, // function(state, t) { void(state); return true; }, + // clearSelection: undefined, // function(state) { void(state); return true; }, + // toolboxPanAndZoom: null, + // initialized: false, + // enabled: true, + // xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + // format: function(state) { void(state); return 'csvjsonarray'; }, + // options: function(state) { void(state); return 'milliseconds'; }, + // legend: function(state) { void(state); return null; }, + // autoresize: function(state) { void(state); return false; }, + // max_updates_to_recreate: function(state) { void(state); return 5000; }, + // track_colors: function(state) { void(state); return false; }, + // pixels_per_point: function(state) { void(state); return 15; }, + // container_class: function(state) { void(state); return 'netdata-container'; } + // }, + "d3pie": { + initialize: NETDATA.d3pieInitialize, + create: NETDATA.d3pieChartCreate, + update: NETDATA.d3pieChartUpdate, + resize: null, + setSelection: NETDATA.d3pieSetSelection, + clearSelection: NETDATA.d3pieClearSelection, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + format: function (state) { + void(state); + return 'json'; + }, + options: function (state) { + void(state); + return 'objectrows' + '%7C' + 'ms'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 15; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + "d3": { + initialize: NETDATA.d3Initialize, + create: NETDATA.d3ChartCreate, + update: NETDATA.d3ChartUpdate, + resize: null, + setSelection: undefined, // function(state, t) { void(state); return true; }, + clearSelection: undefined, // function(state) { void(state); return true; }, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result.data$'), + format: function (state) { + void(state); + return 'json'; + }, + options: function (state) { + void(state); + return ''; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return false; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + } + }, + "easypiechart": { + initialize: NETDATA.easypiechartInitialize, + create: NETDATA.easypiechartChartCreate, + update: NETDATA.easypiechartChartUpdate, + resize: null, + setSelection: NETDATA.easypiechartSetSelection, + clearSelection: NETDATA.easypiechartClearSelection, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + format: function (state) { + void(state); + return 'array'; + }, + options: function (state) { + void(state); + return 'absolute'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return true; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + aspect_ratio: 100, + container_class: function (state) { + void(state); + return 'netdata-container-easypiechart'; + } + }, + "gauge": { + initialize: NETDATA.gaugeInitialize, + create: NETDATA.gaugeChartCreate, + update: NETDATA.gaugeChartUpdate, + resize: null, + setSelection: NETDATA.gaugeSetSelection, + clearSelection: NETDATA.gaugeClearSelection, + toolboxPanAndZoom: null, + initialized: false, + enabled: true, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + format: function (state) { + void(state); + return 'array'; + }, + options: function (state) { + void(state); + return 'absolute'; + }, + legend: function (state) { + void(state); + return null; + }, + autoresize: function (state) { + void(state); + return false; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + track_colors: function (state) { + void(state); + return true; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + aspect_ratio: 60, + container_class: function (state) { + void(state); + return 'netdata-container-gauge'; + } + }, + "textonly": { + autoresize: function (state) { + void(state); + return false; + }, + container_class: function (state) { + void(state); + return 'netdata-container'; + }, + create: NETDATA.textOnlyCreate, + enabled: true, + format: function (state) { + void(state); + return 'array'; + }, + initialized: true, + initialize: function (callback) { + callback(); + }, + legend: function (state) { + void(state); + return null; + }, + max_updates_to_recreate: function (state) { + void(state); + return 5000; + }, + options: function (state) { + void(state); + return 'absolute'; + }, + pixels_per_point: function (state) { + void(state); + return 3; + }, + track_colors: function (state) { + void(state); + return false; + }, + update: NETDATA.textOnlyUpdate, + xssRegexIgnore: new RegExp('^/api/v1/data\.result$'), + } +}; + +NETDATA.registerChartLibrary = function (library, url) { + if (NETDATA.options.debug.libraries) { + console.log("registering chart library: " + library); + } + + NETDATA.chartLibraries[library].url = url; + NETDATA.chartLibraries[library].initialized = true; + NETDATA.chartLibraries[library].enabled = true; +}; + +// *** src/dashboard.js/chart-registry.js + +// 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.fixHost = function (host) { + while (host.slice(-1) === '/') { + host = host.substring(0, host.length - 1); + } + + return host; +}; + +NETDATA.chartRegistry = { + charts: {}, + + globalReset: function () { + this.charts = {}; + }, + + add: function (host, id, data) { + if (typeof this.charts[host] === 'undefined') { + this.charts[host] = {}; + } + + //console.log('added ' + host + '/' + id); + this.charts[host][id] = data; + }, + + get: function (host, 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) { + host = NETDATA.fixHost(host); + + let self = this; + + function got_data(h, data, callback) { + if (data !== null) { + self.charts[h] = data.charts; + + // update the server timezone in our options + if (typeof data.timezone === 'string') { + NETDATA.options.server_timezone = data.timezone; + } + } else { + NETDATA.error(406, h + '/api/v1/charts'); + } + + if (typeof callback === 'function') { + callback(data); + } + } + + if (netdataSnapshotData !== null) { + got_data(host, netdataSnapshotData.charts, callback); + } else { + $.ajax({ + url: host + '/api/v1/charts', + async: true, + cache: false, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/charts', data); + got_data(host, data, callback); + }) + .fail(function () { + NETDATA.error(405, host + '/api/v1/charts'); + + if (typeof callback === 'function') { + callback(null); + } + }); + } + } +}; + +// Compute common (joint) values over multiple charts. + + +// commonMin & commonMax + +NETDATA.commonMin = { + keys: {}, + latest: {}, + + globalReset: function () { + this.keys = {}; + this.latest = {}; + }, + + get: function (state) { + if (typeof state.tmp.__commonMin === 'undefined') { + // get the commonMin setting + state.tmp.__commonMin = NETDATA.dataAttribute(state.element, 'common-min', null); + } + + let min = state.data.min; + let name = state.tmp.__commonMin; + + if (name === null) { + // we don't need commonMin + //state.log('no need for commonMin'); + return min; + } + + let t = this.keys[name]; + if (typeof t === 'undefined') { + // add our commonMin + this.keys[name] = {}; + t = this.keys[name]; + } + + let uuid = state.uuid; + if (typeof t[uuid] !== 'undefined') { + if (t[uuid] === min) { + //state.log('commonMin ' + state.tmp.__commonMin + ' not changed: ' + this.latest[name]); + return this.latest[name]; + } else if (min < this.latest[name]) { + //state.log('commonMin ' + state.tmp.__commonMin + ' increased: ' + min); + t[uuid] = min; + this.latest[name] = min; + return min; + } + } + + // add our min + t[uuid] = min; + + // find the common min + let m = min; + // for (let i in t) { + // if (t.hasOwnProperty(i) && t[i] < m) m = t[i]; + // } + for (var ti of Object.values(t)) { + if (ti < m) { + m = ti; + } + } + + //state.log('commonMin ' + state.tmp.__commonMin + ' updated: ' + m); + this.latest[name] = m; + return m; + } +}; + +NETDATA.commonMax = { + keys: {}, + latest: {}, + + globalReset: function () { + this.keys = {}; + this.latest = {}; + }, + + get: function (state) { + if (typeof state.tmp.__commonMax === 'undefined') { + // get the commonMax setting + state.tmp.__commonMax = NETDATA.dataAttribute(state.element, 'common-max', null); + } + + let max = state.data.max; + let name = state.tmp.__commonMax; + + if (name === null) { + // we don't need commonMax + //state.log('no need for commonMax'); + return max; + } + + let t = this.keys[name]; + if (typeof t === 'undefined') { + // add our commonMax + this.keys[name] = {}; + t = this.keys[name]; + } + + let uuid = state.uuid; + if (typeof t[uuid] !== 'undefined') { + if (t[uuid] === max) { + //state.log('commonMax ' + state.tmp.__commonMax + ' not changed: ' + this.latest[name]); + return this.latest[name]; + } else if (max > this.latest[name]) { + //state.log('commonMax ' + state.tmp.__commonMax + ' increased: ' + max); + t[uuid] = max; + this.latest[name] = max; + return max; + } + } + + // add our max + t[uuid] = max; + + // find the common max + let m = max; + // for (let i in t) { + // if (t.hasOwnProperty(i) && t[i] > m) m = t[i]; + // } + for (var ti of Object.values(t)) { + if (ti > m) { + m = ti; + } + } + + //state.log('commonMax ' + state.tmp.__commonMax + ' updated: ' + m); + this.latest[name] = m; + return m; + } +}; + +NETDATA.commonColors = { + keys: {}, + + globalReset: function () { + this.keys = {}; + }, + + get: function (state, label) { + let ret = this.refill(state); + + if (typeof ret.assigned[label] === 'undefined') { + ret.assigned[label] = ret.available.shift(); + } + + return ret.assigned[label]; + }, + + refill: function (state) { + let ret, len; + + if (typeof state.tmp.__commonColors === 'undefined') { + ret = this.prepare(state); + } else { + ret = this.keys[state.tmp.__commonColors]; + if (typeof ret === 'undefined') { + ret = this.prepare(state); + } + } + + if (ret.available.length === 0) { + if (ret.copy_theme || ret.custom.length === 0) { + // copy the theme colors + len = NETDATA.themes.current.colors.length; + while (len--) { + ret.available.unshift(NETDATA.themes.current.colors[len]); + } + } + + // copy the custom colors + len = ret.custom.length; + while (len--) { + ret.available.unshift(ret.custom[len]); + } + } + + state.colors_assigned = ret.assigned; + state.colors_available = ret.available; + state.colors_custom = ret.custom; + + return ret; + }, + + __read_custom_colors: function (state, ret) { + // add the user supplied colors + let c = NETDATA.dataAttribute(state.element, 'colors', undefined); + if (typeof c === 'string' && c.length > 0) { + c = c.split(' '); + let len = c.length; + + if (len > 0 && c[len - 1] === 'ONLY') { + len--; + ret.copy_theme = false; + } + + while (len--) { + ret.custom.unshift(c[len]); + } + } + }, + + prepare: function (state) { + let has_custom_colors = false; + + if (typeof state.tmp.__commonColors === 'undefined') { + let defname = state.chart.context; + + // if this chart has data-colors="" + // we should use the chart uuid as the default key (private palette) + // (data-common-colors="NAME" will be used anyways) + let c = NETDATA.dataAttribute(state.element, 'colors', undefined); + if (typeof c === 'string' && c.length > 0) { + defname = state.uuid; + has_custom_colors = true; + } + + // get the commonColors setting + state.tmp.__commonColors = NETDATA.dataAttribute(state.element, 'common-colors', defname); + } + + let name = state.tmp.__commonColors; + let ret = this.keys[name]; + + if (typeof ret === 'undefined') { + // add our commonMax + this.keys[name] = { + assigned: {}, // name-value of dimensions and their colors + available: [], // an array of colors available to be used + custom: [], // the array of colors defined by the user + charts: {}, // the charts linked to this + copy_theme: true + }; + ret = this.keys[name]; + } + + if (typeof ret.charts[state.uuid] === 'undefined') { + ret.charts[state.uuid] = state; + + if (has_custom_colors) { + this.__read_custom_colors(state, ret); + } + } + + return ret; + } +}; + +// *** src/dashboard.js/main.js + +// Codacy declarations +/* global clipboard */ +/* global Ps */ + +if (NETDATA.options.debug.main_loop) { + console.log('welcome to NETDATA'); +} + +NETDATA.onresizeCallback = null; +NETDATA.onresize = function () { + NETDATA.options.last_page_resize = Date.now(); + NETDATA.onscroll(); + + if (typeof NETDATA.onresizeCallback === 'function') { + NETDATA.onresizeCallback(); + } +}; + +NETDATA.abortAllRefreshes = function () { + let targets = NETDATA.options.targets; + let len = targets.length; + + while (len--) { + if (targets[len].fetching_data) { + if (typeof targets[len].xhr !== 'undefined') { + targets[len].xhr.abort(); + targets[len].running = false; + targets[len].fetching_data = false; + } + } + } +}; + +NETDATA.onscrollStartDelay = function () { + NETDATA.options.last_page_scroll = Date.now(); + + NETDATA.options.on_scroll_refresher_stop_until = + NETDATA.options.last_page_scroll + + (NETDATA.options.current.async_on_scroll ? 1000 : 0); +}; + +NETDATA.onscrollEndDelay = function () { + NETDATA.options.on_scroll_refresher_stop_until = + Date.now() + + (NETDATA.options.current.async_on_scroll ? NETDATA.options.current.onscroll_worker_duration_threshold : 0); +}; + +NETDATA.onscroll_updater_timeout_id = undefined; +NETDATA.onscrollUpdater = function () { + NETDATA.globalSelectionSync.stop(); + + if (NETDATA.options.abort_ajax_on_scroll) { + NETDATA.abortAllRefreshes(); + } + + // 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 + + if (!NETDATA.intersectionObserver.enabled()) { + if (!NETDATA.options.current.parallel_refresher) { + let targets = NETDATA.options.targets; + let len = targets.length; + + while (len--) { + if (!targets[len].running) { + targets[len].isVisible(); + } + } + } + } + + NETDATA.onscrollEndDelay(); +}; + +NETDATA.scrollUp = false; +NETDATA.scrollY = window.scrollY; +NETDATA.onscroll = function () { + //console.log('onscroll() begin'); + + NETDATA.onscrollStartDelay(); + NETDATA.chartRefresherReschedule(); + + NETDATA.scrollUp = (window.scrollY > NETDATA.scrollY); + NETDATA.scrollY = window.scrollY; + + if (NETDATA.onscroll_updater_timeout_id) { + NETDATA.timeout.clear(NETDATA.onscroll_updater_timeout_id); + } + + NETDATA.onscroll_updater_timeout_id = NETDATA.timeout.set(NETDATA.onscrollUpdater, 0); + //console.log('onscroll() end'); +}; + +NETDATA.supportsPassiveEvents = function () { + if (NETDATA.options.passive_events === null) { + let supportsPassive = false; + try { + let opts = Object.defineProperty({}, 'passive', { + get: function () { + supportsPassive = true; + } + }); + window.addEventListener("test", null, opts); + } catch (e) { + console.log('browser does not support passive events'); + } + + NETDATA.options.passive_events = supportsPassive; + } + + // console.log('passive ' + NETDATA.options.passive_events); + return NETDATA.options.passive_events; +}; + +window.addEventListener('resize', NETDATA.onresize, NETDATA.supportsPassiveEvents() ? {passive: true} : false); +window.addEventListener('scroll', NETDATA.onscroll, NETDATA.supportsPassiveEvents() ? {passive: true} : false); +// window.onresize = NETDATA.onresize; +// window.onscroll = NETDATA.onscroll; + +// ---------------------------------------------------------------------------------------------------------------- +// 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 synchronized + // to this time-range + + 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, + + globalReset: function () { + this.clearMaster(); + this.seq = 0; + this.master = null; + this.force_after_ms = null; + this.force_before_ms = null; + this.callback = null; + }, + + delay: function () { + if (NETDATA.options.debug.globalPanAndZoom) { + console.log('globalPanAndZoom.delay()'); + } + + NETDATA.options.auto_refresher_stop_until = Date.now() + NETDATA.options.current.global_pan_sync_time; + }, + + // set a new master + setMaster: function (state, after, before) { + this.delay(); + + if (!NETDATA.options.current.sync_pan_and_zoom) { + return; + } + + if (this.master === null) { + if (NETDATA.options.debug.globalPanAndZoom) { + console.log('globalPanAndZoom.setMaster(' + state.id + ', ' + after + ', ' + before + ') SET MASTER'); + } + } else if (this.master !== state) { + if (NETDATA.options.debug.globalPanAndZoom) { + console.log('globalPanAndZoom.setMaster(' + state.id + ', ' + after + ', ' + before + ') CHANGED MASTER'); + } + + this.master.resetChart(true, true); + } + + let now = Date.now(); + this.master = state; + this.seq = now; + this.force_after_ms = after; + this.force_before_ms = before; + + if (typeof this.callback === 'function') { + this.callback(true, after, before); + } + }, + + // clear the master + clearMaster: function () { + // if (NETDATA.options.debug.globalPanAndZoom === true) + // console.log('globalPanAndZoom.clearMaster()'); + if (NETDATA.options.debug.globalPanAndZoom) { + console.log('globalPanAndZoom.clearMaster()'); + } + + if (this.master !== null) { + let 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) { + return (this.master === state); + }, + + // are we currently have a global pan and zoom sync? + isActive: function () { + return (this.master !== null && this.force_before_ms !== null && this.force_after_ms !== null && this.seq !== 0); + }, + + // 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; + + return (state.tm.pan_and_zoom_seq !== this.seq); + } +}; + +// ---------------------------------------------------------------------------------------------------------------- +// global chart underlay (time-frame highlighting) + +NETDATA.globalChartUnderlay = { + callback: null, // what to call when a highlighted range is setup + after: null, // highlight after this time + before: null, // highlight before this time + view_after: null, // the charts after_ms viewport when the highlight was setup + view_before: null, // the charts before_ms viewport, when the highlight was setup + state: null, // the chart the highlight was setup + + isActive: function () { + return (this.after !== null && this.before !== null); + }, + + hasViewport: function () { + return (this.state !== null && this.view_after !== null && this.view_before !== null); + }, + + init: function (state, after, before, view_after, view_before) { + this.state = (typeof state !== 'undefined') ? state : null; + this.after = (typeof after !== 'undefined' && after !== null && after > 0) ? after : null; + this.before = (typeof before !== 'undefined' && before !== null && before > 0) ? before : null; + this.view_after = (typeof view_after !== 'undefined' && view_after !== null && view_after > 0) ? view_after : null; + this.view_before = (typeof view_before !== 'undefined' && view_before !== null && view_before > 0) ? view_before : null; + }, + + setup: function () { + if (this.isActive()) { + if (this.state === null) { + this.state = NETDATA.options.targets[0]; + } + + if (typeof this.callback === 'function') { + this.callback(true, this.after, this.before); + } + } else { + if (typeof this.callback === 'function') { + this.callback(false, 0, 0); + } + } + }, + + set: function (state, after, before, view_after, view_before) { + if (after > before) { + let t = after; + after = before; + before = t; + } + + this.init(state, after, before, view_after, view_before); + + // if (this.hasViewport() === true) + // NETDATA.globalPanAndZoom.setMaster(this.state, this.view_after, this.view_before); + if (this.hasViewport()) { + NETDATA.globalPanAndZoom.setMaster(this.state, this.view_after, this.view_before); + } + + this.setup(); + }, + + clear: function () { + this.after = null; + this.before = null; + this.state = null; + this.view_after = null; + this.view_before = null; + + if (typeof this.callback === 'function') { + this.callback(false, 0, 0); + } + }, + + focus: function () { + if (this.isActive() && this.hasViewport()) { + if (this.state === null) { + this.state = NETDATA.options.targets[0]; + } + + if (NETDATA.globalPanAndZoom.isMaster(this.state)) { + NETDATA.globalPanAndZoom.clearMaster(); + } + + NETDATA.globalPanAndZoom.setMaster(this.state, this.view_after, this.view_before, true); + } + } +}; + +// ---------------------------------------------------------------------------------------------------------------- +// dimensions selection + +// TODO +// move color assignment to dimensions, here + +let 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; + this.selected = (parent.unselected_count === 0); + + 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.setProperty('color', this.color, 'important'); + if (!this.selected) { + 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.setProperty('color', this.color, 'important'); + if (!this.selected) { + 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) { + return; + } + + let 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 || e.ctrlKey) { + // 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 || e.ctrlKey) { + // 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) { + 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) { + 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); + return this.enabled && this.selected; +}; + +// ---------------------------------------------------------------------------------------------------------------- + +let 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 () { + let keys = Object.keys(this.dimensions); + let len = keys.length; + while (len--) { + this.dimensions[keys[len]].invalidate(); + } +}; + +dimensionsVisibility.prototype.selectAll = function () { + let keys = Object.keys(this.dimensions); + let len = keys.length; + while (len--) { + this.dimensions[keys[len]].select(); + } +}; + +dimensionsVisibility.prototype.countSelected = function () { + let selected = 0; + let keys = Object.keys(this.dimensions); + let len = keys.length; + while (len--) { + if (this.dimensions[keys[len]].isSelected()) { + selected++; + } + } + + return selected; +}; + +dimensionsVisibility.prototype.selectNone = function () { + let keys = Object.keys(this.dimensions); + let len = keys.length; + while (len--) { + this.dimensions[keys[len]].unselect(); + } +}; + +dimensionsVisibility.prototype.selected2BooleanArray = function (array) { + let ret = []; + this.selected_count = 0; + this.unselected_count = 0; + + let len = array.length; + while (len--) { + let ds = this.dimensions[array[len]]; + if (typeof ds === 'undefined') { + // console.log(array[i] + ' is not found'); + ret.unshift(false); + } else if (ds.isSelected()) { + ret.unshift(true); + this.selected_count++; + } else { + ret.unshift(false); + this.unselected_count++; + } + } + + if (this.selected_count === 0 && this.unselected_count !== 0) { + this.selectAll(); + return this.selected2BooleanArray(array); + } + + return ret; +}; + +// ---------------------------------------------------------------------------------------------------------------- +// date/time conversion + +NETDATA.dateTime = { + using_timezone: false, + + // these are the old netdata functions + // we fallback to these, if the new ones fail + + localeDateStringNative: function (d) { + return d.toLocaleDateString(); + }, + + localeTimeStringNative: function (d) { + return d.toLocaleTimeString(); + }, + + xAxisTimeStringNative: function (d) { + return NETDATA.zeropad(d.getHours()) + ":" + + NETDATA.zeropad(d.getMinutes()) + ":" + + NETDATA.zeropad(d.getSeconds()); + }, + + // initialize the new date/time conversion + // functions. + // if this fails, we fallback to the above + init: function (timezone) { + //console.log('init with timezone: ' + timezone); + + // detect browser timezone + try { + NETDATA.options.browser_timezone = Intl.DateTimeFormat().resolvedOptions().timeZone; + } catch (e) { + console.log('failed to detect browser timezone: ' + e.toString()); + NETDATA.options.browser_timezone = 'cannot-detect-it'; + } + + let ret = false; + + try { + let dateOptions = { + localeMatcher: 'best fit', + formatMatcher: 'best fit', + weekday: 'short', + year: 'numeric', + month: 'short', + day: '2-digit' + }; + + let timeOptions = { + localeMatcher: 'best fit', + hour12: false, + formatMatcher: 'best fit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit' + }; + + let xAxisOptions = { + localeMatcher: 'best fit', + hour12: false, + formatMatcher: 'best fit', + hour: '2-digit', + minute: '2-digit', + second: '2-digit' + }; + + if (typeof timezone === 'string' && timezone !== '' && timezone !== 'default') { + dateOptions.timeZone = timezone; + timeOptions.timeZone = timezone; + timeOptions.timeZoneName = 'short'; + xAxisOptions.timeZone = timezone; + this.using_timezone = true; + } else { + timezone = 'default'; + this.using_timezone = false; + } + + this.dateFormat = new Intl.DateTimeFormat(navigator.language, dateOptions); + this.timeFormat = new Intl.DateTimeFormat(navigator.language, timeOptions); + this.xAxisFormat = new Intl.DateTimeFormat(navigator.language, xAxisOptions); + + this.localeDateString = function (d) { + return this.dateFormat.format(d); + }; + + this.localeTimeString = function (d) { + return this.timeFormat.format(d); + }; + + this.xAxisTimeString = function (d) { + return this.xAxisFormat.format(d); + }; + + //let d = new Date(); + //let t = this.dateFormat.format(d) + ' ' + this.timeFormat.format(d) + ' ' + this.xAxisFormat.format(d); + + ret = true; + } catch (e) { + console.log('Cannot setup Date/Time formatting: ' + e.toString()); + + timezone = 'default'; + this.localeDateString = this.localeDateStringNative; + this.localeTimeString = this.localeTimeStringNative; + this.xAxisTimeString = this.xAxisTimeStringNative; + this.using_timezone = false; + + ret = false; + } + + // save it + //console.log('init setOption timezone: ' + timezone); + NETDATA.setOption('timezone', timezone); + + return ret; + } +}; +NETDATA.dateTime.init(NETDATA.options.current.timezone); + +// ---------------------------------------------------------------------------------------------------------------- +// global selection sync + +NETDATA.globalSelectionSync = { + state: null, + dontSyncBefore: 0, + last_t: 0, + slaves: [], + timeoutId: undefined, + + globalReset: function () { + this.stop(); + this.state = null; + this.dontSyncBefore = 0; + this.last_t = 0; + this.slaves = []; + this.timeoutId = undefined; + }, + + active: function () { + return (this.state !== null); + }, + + // return true if global selection sync can be enabled now + enabled: function () { + // console.log('enabled()'); + // can we globally apply selection sync? + if (!NETDATA.options.current.sync_selection) { + return false; + } + + return (this.dontSyncBefore <= Date.now()); + }, + + // set the global selection sync master + setMaster: function (state) { + if (!this.enabled()) { + this.stop(); + return; + } + + if (this.state === state) { + return; + } + + if (this.state !== null) { + this.stop(); + } + + if (NETDATA.options.debug.globalSelectionSync) { + console.log('globalSelectionSync.setMaster(' + state.id + ')'); + } + + state.selected = true; + this.state = state; + this.last_t = 0; + + // find all slaves + let targets = NETDATA.intersectionObserver.targets(); + this.slaves = []; + let len = targets.length; + while (len--) { + let st = targets[len]; + if (this.state !== st && st.globalSelectionSyncIsEligible()) { + this.slaves.push(st); + } + } + + // this.delay(100); + }, + + // stop global selection sync + stop: function () { + if (this.state !== null) { + if (NETDATA.options.debug.globalSelectionSync) { + console.log('globalSelectionSync.stop()'); + } + + let len = this.slaves.length; + while (len--) { + this.slaves[len].clearSelection(); + } + + this.state.clearSelection(); + + this.last_t = 0; + this.slaves = []; + this.state = null; + } + }, + + // delay global selection sync for some time + delay: function (ms) { + if (NETDATA.options.current.sync_selection) { + // if (NETDATA.options.debug.globalSelectionSync === true) { + if (NETDATA.options.debug.globalSelectionSync) { + console.log('globalSelectionSync.delay()'); + } + + if (typeof ms === 'number') { + this.dontSyncBefore = Date.now() + ms; + } else { + this.dontSyncBefore = Date.now() + NETDATA.options.current.sync_selection_delay; + } + } + }, + + __syncSlaves: function () { + // if (NETDATA.globalSelectionSync.enabled() === true) { + if (NETDATA.globalSelectionSync.enabled()) { + // if (NETDATA.options.debug.globalSelectionSync === true) + if (NETDATA.options.debug.globalSelectionSync) { + console.log('globalSelectionSync.__syncSlaves()'); + } + + let t = NETDATA.globalSelectionSync.last_t; + let len = NETDATA.globalSelectionSync.slaves.length; + while (len--) { + NETDATA.globalSelectionSync.slaves[len].setSelection(t); + } + + this.timeoutId = undefined; + } + }, + + // sync all the visible charts to the given time + // this is to be called from the chart libraries + sync: function (state, t) { + // if (NETDATA.options.current.sync_selection === true) { + if (NETDATA.options.current.sync_selection) { + // if (NETDATA.options.debug.globalSelectionSync === true) + if (NETDATA.options.debug.globalSelectionSync) { + console.log('globalSelectionSync.sync(' + state.id + ', ' + t.toString() + ')'); + } + + this.setMaster(state); + + if (t === this.last_t) { + return; + } + + this.last_t = t; + + if (state.foreignElementSelection !== null) { + state.foreignElementSelection.innerText = NETDATA.dateTime.localeDateString(t) + ' ' + NETDATA.dateTime.localeTimeString(t); + } + + if (this.timeoutId) { + NETDATA.timeout.clear(this.timeoutId); + } + + this.timeoutId = NETDATA.timeout.set(this.__syncSlaves, 0); + } + } +}; + +NETDATA.intersectionObserver = { + observer: null, + visible_targets: [], + + options: { + root: null, + rootMargin: "0px", + threshold: null + }, + + enabled: function () { + return this.observer !== null; + }, + + globalReset: function () { + if (this.observer !== null) { + this.visible_targets = []; + this.observer.disconnect(); + this.init(); + } + }, + + targets: function () { + if (this.enabled() && this.visible_targets.length > 0) { + return this.visible_targets; + } else { + return NETDATA.options.targets; + } + }, + + switchChartVisibility: function () { + let old = this.__visibilityRatioOld; + + if (old !== this.__visibilityRatio) { + if (old === 0 && this.__visibilityRatio > 0) { + this.unhideChart(); + } else if (old > 0 && this.__visibilityRatio === 0) { + this.hideChart(); + } + + this.__visibilityRatioOld = this.__visibilityRatio; + } + }, + + handler: function (entries, observer) { + entries.forEach(function (entry) { + let state = NETDATA.chartState(entry.target); + + let idx; + if (entry.intersectionRatio > 0) { + idx = NETDATA.intersectionObserver.visible_targets.indexOf(state); + if (idx === -1) { + if (NETDATA.scrollUp) { + NETDATA.intersectionObserver.visible_targets.push(state); + } else { + NETDATA.intersectionObserver.visible_targets.unshift(state); + } + } + else if (state.__visibilityRatio === 0) { + state.log("was not visible until now, but was already in visible_targets"); + } + } else { + idx = NETDATA.intersectionObserver.visible_targets.indexOf(state); + if (idx !== -1) { + NETDATA.intersectionObserver.visible_targets.splice(idx, 1); + } else if (state.__visibilityRatio > 0) { + state.log("was visible, but not found in visible_targets"); + } + } + + state.__visibilityRatio = entry.intersectionRatio; + + if (!NETDATA.options.current.async_on_scroll) { + if (window.requestIdleCallback) { + window.requestIdleCallback(function () { + NETDATA.intersectionObserver.switchChartVisibility.call(state); + }, {timeout: 100}); + } else { + NETDATA.intersectionObserver.switchChartVisibility.call(state); + } + } + }); + }, + + observe: function (state) { + if (this.enabled()) { + state.__visibilityRatioOld = 0; + state.__visibilityRatio = 0; + this.observer.observe(state.element); + + state.isVisible = function () { + if (!NETDATA.options.current.update_only_visible) { + return true; + } + + NETDATA.intersectionObserver.switchChartVisibility.call(this); + + return this.__visibilityRatio > 0; + } + } + }, + + init: function () { + if (typeof netdataIntersectionObserver === 'undefined' || netdataIntersectionObserver) { + try { + this.observer = new IntersectionObserver(this.handler, this.options); + } catch (e) { + console.log("IntersectionObserver is not supported on this browser"); + this.observer = null; + } + } + //else { + // console.log("IntersectionObserver is disabled"); + //} + } +}; +NETDATA.intersectionObserver.init(); + +// ---------------------------------------------------------------------------------------------------------------- +// Our state object, where all per-chart values are stored + +let chartState = function (element) { + this.element = element; + + // IMPORTANT: + // all private functions should use 'that', instead of 'this' + // Alternatively, you can use arrow functions (related issue #4514) + let that = this; + + // ============================================================================================================ + // ERROR HANDLING + + /* error() - private + * show an error instead of the chart + */ + let error = (msg) => { + let ret = true; + + if (typeof netdataErrorCallback === 'function') { + ret = netdataErrorCallback('chart', this.id, msg); + } + + if (ret) { + this.element.innerHTML = this.id + ': ' + msg; + this.enabled = false; + this.current = this.pan; + } + }; + + // console logging + this.log = function (msg) { + console.log(this.id + ' (' + this.library_name + ' ' + this.uuid + '): ' + msg); + }; + + this.debugLog = function (msg) { + if (this.debug) { + this.log(msg); + } + }; + + // ============================================================================================================ + // EARLY INITIALIZATION + + // These are variables that should exist even if the chart is never to be rendered. + // Be careful what you add here - there may be thousands of charts on the page. + + // GUID - a unique identifier for the chart + this.uuid = NETDATA.guid(); + + // string - the name of chart + this.id = NETDATA.dataAttribute(this.element, 'netdata', undefined); + if (typeof this.id === 'undefined') { + error("netdata elements need data-netdata"); + return; + } + + // string - the key for localStorage settings + this.settings_id = NETDATA.dataAttribute(this.element, 'id', null); + + // the user given dimensions of the element + this.width = NETDATA.dataAttribute(this.element, 'width', NETDATA.chartDefaults.width); + this.height = NETDATA.dataAttribute(this.element, 'height', NETDATA.chartDefaults.height); + this.height_original = this.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); + }); + } + + // the chart library requested by the user + this.library_name = NETDATA.dataAttribute(this.element, 'chart-library', NETDATA.chartDefaults.library); + + // 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[this.library_name] === 'undefined') { + NETDATA.error(402, this.library_name); + error('chart library "' + this.library_name + '" is not found'); + this.enabled = false; + } else if (!NETDATA.chartLibraries[this.library_name].enabled) { + NETDATA.error(403, this.library_name); + error('chart library "' + this.library_name + '" is not enabled'); + this.enabled = false; + } else { + this.library = NETDATA.chartLibraries[this.library_name]; + } + + 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; + + this.running = false; // boolean - true when the chart is being refreshed now + this.enabled = true; // boolean - is the chart enabled for refresh? + + this.force_update_every = null; // number - overwrite the visualization update frequency of the chart + + this.tmp = {}; + + this.foreignElementBefore = null; + this.foreignElementAfter = null; + this.foreignElementDuration = null; + this.foreignElementUpdateEvery = null; + this.foreignElementSelection = null; + + // ============================================================================================================ + // PRIVATE FUNCTIONS + + // reset the runtime status variables to their defaults + const runtimeInit = () => { + this.paused = false; // boolean - is the chart paused for any reason? + this.selected = false; // boolean - is the chart shown a selection? + + this.chart_created = false; // boolean - is the library.create() been called? + this.dom_created = false; // boolean - is the chart DOM been created? + this.fetching_data = false; // boolean - true while we fetch data via ajax + + this.updates_counter = 0; // numeric - the number of refreshes made so far + this.updates_since_last_unhide = 0; // numeric - the number of refreshes made since the last time the chart was unhidden + this.updates_since_last_creation = 0; // numeric - the number of refreshes made since the last time the chart was created + + this.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 + }; + + this.data = null; // the last data as downloaded from the netdata server + this.data_url = 'invalid://'; // string - the last url used to update the chart + this.data_points = 0; // number - the number of points returned from netdata + this.data_after = 0; // milliseconds - the first timestamp of the data + this.data_before = 0; // milliseconds - the last timestamp of the data + this.data_update_every = 0; // milliseconds - the frequency to update the data + + this.tmp = {}; // members that can be destroyed to save memory + }; + + // initialize all the variables that are required for the chart to be rendered + const lateInitialization = () => { + if (typeof this.host !== 'undefined') { + return; + } + + // string - the netdata server URL, without any path + this.host = NETDATA.dataAttribute(this.element, 'host', NETDATA.serverDefault); + + // 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 = NETDATA.dataAttribute(this.element, 'method', NETDATA.chartDefaults.method); + this.gtime = NETDATA.dataAttribute(this.element, 'gtime', 0); + + // the time-range requested by the user + this.after = NETDATA.dataAttribute(this.element, 'after', NETDATA.chartDefaults.after); + this.before = NETDATA.dataAttribute(this.element, 'before', NETDATA.chartDefaults.before); + + // the pixels per point requested by the user + this.pixels_per_point = NETDATA.dataAttribute(this.element, 'pixels-per-point', 1); + this.points = NETDATA.dataAttribute(this.element, 'points', null); + + // the forced update_every + this.force_update_every = NETDATA.dataAttribute(this.element, 'update-every', null); + if (typeof this.force_update_every !== 'number' || this.force_update_every <= 1) { + if (this.force_update_every !== null) { + this.log('ignoring invalid value of property data-update-every'); + } + + this.force_update_every = null; + } else { + this.force_update_every *= 1000; + } + + // the dimensions requested by the user + this.dimensions = NETDATA.encodeURIComponent(NETDATA.dataAttribute(this.element, 'dimensions', null)); + + this.title = NETDATA.dataAttribute(this.element, 'title', null); // the title of the chart + this.units = NETDATA.dataAttribute(this.element, 'units', null); // the units of the chart dimensions + this.units_desired = NETDATA.dataAttribute(this.element, 'desired-units', NETDATA.options.current.units); // the units of the chart dimensions + this.units_current = this.units; + this.units_common = NETDATA.dataAttribute(this.element, 'common-units', null); + + // additional options to pass to netdata + this.append_options = NETDATA.encodeURIComponent(NETDATA.dataAttribute(this.element, 'append-options', null)); + + // override options to pass to netdata + this.override_options = NETDATA.encodeURIComponent(NETDATA.dataAttribute(this.element, 'override-options', null)); + + this.debug = NETDATA.dataAttributeBoolean(this.element, 'debug', false); + + this.value_decimal_detail = -1; + let d = NETDATA.dataAttribute(this.element, 'decimal-digits', -1); + if (typeof d === 'number') { + this.value_decimal_detail = d; + } else if (typeof d !== 'undefined') { + this.log('ignoring decimal-digits value: ' + d.toString()); + } + + // if we need to report the rendering speed + // find the element that needs to be updated + let refresh_dt_element_name = NETDATA.dataAttribute(this.element, '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(that); + + 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.refresh_dt_ms = 0; // milliseconds - the time the last refresh took + + // how many retries we have made to load chart data from the server + this.retries_on_data_failures = 0; + + // color management + this.colors = null; + this.colors_assigned = null; + this.colors_available = null; + this.colors_custom = null; + + this.element_message = null; // the element already created by the user + this.element_chart = null; // the element with the chart + this.element_legend = null; // the element with the legend of the chart (if created by us) + this.element_legend_childs = { + content: null, + hidden: null, + title_date: null, + title_time: null, + title_units: null, + perfect_scroller: null, // the container to apply perfect scroller to + series: null + }; + + this.chart_url = null; // string - the url to download chart info + this.chart = null; // object - the chart as downloaded from the server + + const getForeignElementById = (opt) => { + let id = NETDATA.dataAttribute(this.element, opt, null); + if (id === null) { + //this.log('option "' + opt + '" is undefined'); + return null; + } + + let el = document.getElementById(id); + if (typeof el === 'undefined') { + this.log('cannot find an element with name "' + id.toString() + '"'); + return null; + } + + return el; + }; + + this.foreignElementBefore = getForeignElementById('show-before-at'); + this.foreignElementAfter = getForeignElementById('show-after-at'); + this.foreignElementDuration = getForeignElementById('show-duration-at'); + this.foreignElementUpdateEvery = getForeignElementById('show-update-every-at'); + this.foreignElementSelection = getForeignElementById('show-selection-at'); + }; + + const destroyDOM = () => { + if (!this.enabled) { + return; + } + + if (this.debug) { + this.log('destroyDOM()'); + } + + // this.element.className = 'netdata-message icon'; + // this.element.innerHTML = ' netdata'; + this.element.innerHTML = ''; + this.element_message = null; + this.element_legend = null; + this.element_chart = null; + this.element_legend_childs.series = null; + + this.chart_created = false; + this.dom_created = false; + + this.tm.last_resized = 0; + this.tm.last_dom_created = 0; + }; + + const maxMessageFontSize = () => { + let screenHeight = screen.height; + let el = this.element; + + // normally we want a font size, as tall as the element + let h = el.clientHeight; + + // but give it some air, 20% let's say, or 5 pixels min + let lost = Math.max(h * 0.2, 5); + h -= lost; + + // center the text, vertically + let paddingTop = (lost - 5) / 2; + + // but check the width too + // it should fit 10 characters in it + let w = el.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 > screenHeight / 20) { + paddingTop += (h - (screenHeight / 20)) / 2; + h = screenHeight / 20; + } + + // set it + this.element_message.style.fontSize = h.toString() + 'px'; + this.element_message.style.paddingTop = paddingTop.toString() + 'px'; + }; + + const showMessageIcon = (icon) => { + this.element_message.innerHTML = icon; + maxMessageFontSize(); + $(this.element_message).removeClass('hidden'); + this.tmp.___messageHidden___ = undefined; + }; + + const showLoading = () => { + if (!this.chart_created) { + showMessageIcon(NETDATA.icons.loading + ' netdata'); + return true; + } + return false; + }; + + let createDOM = () => { + if (!this.enabled) { + return; + } + lateInitialization(); + + destroyDOM(); + + if (this.debug) { + this.log('createDOM()'); + } + + this.element_message = document.createElement('div'); + this.element_message.className = 'netdata-message icon hidden'; + this.element.appendChild(this.element_message); + + this.dom_created = true; + this.chart_created = false; + + this.tm.last_dom_created = this.tm.last_resized = Date.now(); + + showLoading(); + }; + + const initDOM = () => { + this.element.className = this.library.container_class(that); + + if (typeof(this.width) === 'string') { + this.element.style.width = this.width; + } else if (typeof(this.width) === 'number') { + this.element.style.width = this.width.toString() + 'px'; + } + + if (typeof(this.library.aspect_ratio) === 'undefined') { + if (typeof(this.height) === 'string') { + this.element.style.height = this.height; + } else if (typeof(this.height) === 'number') { + this.element.style.height = this.height.toString() + 'px'; + } + } + + if (NETDATA.chartDefaults.min_width !== null) { + this.element.style.min_width = NETDATA.chartDefaults.min_width; + } + }; + + const invisibleSearchableText = () => { + return '' + this.id + ''; + }; + + /* init() private + * initialize state variables + * destroy all (possibly) created state elements + * create the basic DOM for a chart + */ + const init = (opt) => { + if (!this.enabled) { + return; + } + + runtimeInit(); + this.element.innerHTML = invisibleSearchableText(); + + this.tm.last_initialized = Date.now(); + this.setMode('auto'); + + if (opt !== 'fast') { + if (this.isVisible(true) || opt === 'force') { + createDOM(); + } + } + }; + + const hideMessage = () => { + if (typeof this.tmp.___messageHidden___ === 'undefined') { + this.tmp.___messageHidden___ = true; + $(this.element_message).addClass('hidden'); + } + }; + + const showRendering = () => { + let icon; + if (this.chart !== null) { + if (this.chart.chart_type === 'line') { + icon = NETDATA.icons.lineChart; + } else { + icon = NETDATA.icons.areaChart; + } + } + else { + icon = NETDATA.icons.noChart; + } + + showMessageIcon(icon + ' netdata' + invisibleSearchableText()); + }; + + const isHidden = () => { + return (typeof this.tmp.___chartIsHidden___ !== 'undefined'); + }; + + // hide the chart, when it is not visible - called from isVisible() + this.hideChart = function () { + // hide it, if it is not already hidden + if (isHidden()) { + return; + } + + if (this.chart_created) { + if (NETDATA.options.current.show_help) { + if (this.element_legend_childs.toolbox !== null) { + if (this.debug) { + this.log('hideChart(): hiding legend popovers'); + } + + $(this.element_legend_childs.toolbox_left).popover('hide'); + $(this.element_legend_childs.toolbox_reset).popover('hide'); + $(this.element_legend_childs.toolbox_right).popover('hide'); + $(this.element_legend_childs.toolbox_zoomin).popover('hide'); + $(this.element_legend_childs.toolbox_zoomout).popover('hide'); + } + + if (this.element_legend_childs.resize_handler !== null) { + $(this.element_legend_childs.resize_handler).popover('hide'); + } + + if (this.element_legend_childs.content !== null) { + $(this.element_legend_childs.content).popover('hide'); + } + } + + if (NETDATA.options.current.destroy_on_hide) { + if (this.debug) { + this.log('hideChart(): initializing chart'); + } + + // we should destroy it + init('force'); + } else { + if (this.debug) { + this.log('hideChart(): hiding chart'); + } + + showRendering(); + this.element_chart.style.display = 'none'; + this.element.style.willChange = 'auto'; + if (this.element_legend !== null) { + this.element_legend.style.display = 'none'; + } + if (this.element_legend_childs.toolbox !== null) { + this.element_legend_childs.toolbox.style.display = 'none'; + } + if (this.element_legend_childs.resize_handler !== null) { + this.element_legend_childs.resize_handler.style.display = 'none'; + } + + this.tm.last_hidden = Date.now(); + + // 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 + // this.data = null; + } + } + + this.tmp.___chartIsHidden___ = true; + }; + + // unhide the chart, when it is visible - called from isVisible() + this.unhideChart = function () { + if (!isHidden()) { + return; + } + + this.tmp.___chartIsHidden___ = undefined; + this.updates_since_last_unhide = 0; + + if (!this.chart_created) { + if (this.debug) { + this.log('unhideChart(): initializing chart'); + } + + // we need to re-initialize it, to show our background + // logo in bootstrap tabs, until the chart loads + init('force'); + } else { + if (this.debug) { + this.log('unhideChart(): unhiding chart'); + } + + this.element.style.willChange = 'transform'; + this.tm.last_unhidden = Date.now(); + this.element_chart.style.display = ''; + if (this.element_legend !== null) { + this.element_legend.style.display = ''; + } + if (this.element_legend_childs.toolbox !== null) { + this.element_legend_childs.toolbox.style.display = ''; + } + if (this.element_legend_childs.resize_handler !== null) { + this.element_legend_childs.resize_handler.style.display = ''; + } + resizeChart(); + hideMessage(); + } + + if (this.__redraw_on_unhide) { + if (this.debug) { + this.log("redrawing chart on unhide"); + } + + this.__redraw_on_unhide = undefined; + this.redrawChart(); + } + }; + + const canBeRendered = (uncached_visibility) => { + if (this.debug) { + this.log('canBeRendered() called'); + } + + if (!NETDATA.options.current.update_only_visible) { + return true; + } + + let ret = ( + ( + NETDATA.options.page_is_visible || + NETDATA.options.current.stop_updates_when_focus_is_lost === false || + this.updates_since_last_unhide === 0 + ) + && isHidden() === false && this.isVisible(uncached_visibility) + ); + + if (this.debug) { + this.log('canBeRendered(): ' + ret); + } + + return ret; + }; + + // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers + const callChartLibraryUpdateSafely = (data) => { + let status; + + // we should not do this here + // if we prevent rendering the chart then: + // 1. globalSelectionSync will be wrong + // 2. globalPanAndZoom will be wrong + //if (canBeRendered(true) === false) + // return false; + + if (NETDATA.options.fake_chart_rendering) { + return true; + } + + this.updates_counter++; + this.updates_since_last_unhide++; + this.updates_since_last_creation++; + + if (NETDATA.options.debug.chart_errors) { + status = this.library.update(that, data); + } else { + try { + status = this.library.update(that, data); + } catch (err) { + status = false; + } + } + + if (!status) { + error('chart failed to be updated as ' + this.library_name); + return false; + } + + return true; + }; + + // https://github.com/petkaantonov/bluebird/wiki/Optimization-killers + const callChartLibraryCreateSafely = (data) => { + let status; + + // we should not do this here + // if we prevent rendering the chart then: + // 1. globalSelectionSync will be wrong + // 2. globalPanAndZoom will be wrong + //if (canBeRendered(true) === false) + // return false; + + if (NETDATA.options.fake_chart_rendering) { + return true; + } + + this.updates_counter++; + this.updates_since_last_unhide++; + this.updates_since_last_creation++; + + if (NETDATA.options.debug.chart_errors) { + status = this.library.create(that, data); + } else { + try { + status = this.library.create(that, data); + } catch (err) { + status = false; + } + } + + if (!status) { + error('chart failed to be created as ' + this.library_name); + return false; + } + + this.chart_created = true; + this.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 + const resizeChart = () => { + if (this.tm.last_resized < NETDATA.options.last_page_resize) { + if (!this.chart_created) { + return; + } + + if (this.needsRecreation()) { + if (this.debug) { + this.log('resizeChart(): initializing chart'); + } + + init('force'); + } else if (typeof this.library.resize === 'function') { + if (this.debug) { + this.log('resizeChart(): resizing chart'); + } + + this.library.resize(that); + + if (this.element_legend_childs.perfect_scroller !== null) { + Ps.update(this.element_legend_childs.perfect_scroller); + } + + maxMessageFontSize(); + } + + this.tm.last_resized = Date.now(); + } + }; + + // 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 + const resizeChartToHeight = (h) => { + // console.log(h); + this.element.style.height = h; + + if (this.settings_id !== null) { + NETDATA.localStorageSet('chart_heights.' + this.settings_id, h); + } + + let now = Date.now(); + NETDATA.options.last_page_scroll = now; + NETDATA.options.auto_refresher_stop_until = now + NETDATA.options.current.stop_updates_while_resizing; + + // force a resize + this.tm.last_resized = 0; + resizeChart(); + }; + + this.resizeForPrint = function () { + if (typeof this.element_legend_childs !== 'undefined' && this.element_legend_childs.perfect_scroller !== null) { + let current = this.element.clientHeight; + let optimal = current + + this.element_legend_childs.perfect_scroller.scrollHeight + - this.element_legend_childs.perfect_scroller.clientHeight; + + if (optimal > current) { + // this.log('resized'); + this.element.style.height = optimal + 'px'; + this.library.resize(this); + } + } + }; + + 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; + + let now = Date.now(); + if (now - this.event_resize.last <= NETDATA.options.current.double_click_speed && this.element_legend_childs.perfect_scroller !== null) { + // double click / double tap event + + // console.dir(this.element_legend_childs.content); + // console.dir(this.element_legend_childs.perfect_scroller); + + // the optimal height of the chart + // showing the entire legend + let optimal = this.event_resize.chart_last_h + + this.element_legend_childs.perfect_scroller.scrollHeight + - this.element_legend_childs.perfect_scroller.clientHeight; + + // if we are not optimal, be optimal + if (this.event_resize.chart_last_h !== optimal) { + // this.log('resize to optimal, current = ' + this.event_resize.chart_last_h.toString() + 'px, original = ' + this.event_resize.chart_original_h.toString() + 'px, optimal = ' + optimal.toString() + 'px, internal = ' + this.height_original.toString()); + resizeChartToHeight(optimal.toString() + 'px'); + } + + // else if the current height is not the original/saved height + // reset to the original/saved height + else if (this.event_resize.chart_last_h !== this.event_resize.chart_original_h) { + // this.log('resize to original, current = ' + this.event_resize.chart_last_h.toString() + 'px, original = ' + this.event_resize.chart_original_h.toString() + 'px, optimal = ' + optimal.toString() + 'px, internal = ' + this.height_original.toString()); + resizeChartToHeight(this.event_resize.chart_original_h.toString() + 'px'); + } + + // else if the current height is not the internal default height + // reset to the internal default height + else if ((this.event_resize.chart_last_h.toString() + 'px') !== this.height_original) { + // this.log('resize to internal default, current = ' + this.event_resize.chart_last_h.toString() + 'px, original = ' + this.event_resize.chart_original_h.toString() + 'px, optimal = ' + optimal.toString() + 'px, internal = ' + this.height_original.toString()); + resizeChartToHeight(this.height_original.toString()); + } + + // else if the current height is not the firstchild's clientheight + // resize to it + else if (typeof this.element_legend_childs.perfect_scroller.firstChild !== 'undefined') { + let parent_rect = this.element.getBoundingClientRect(); + let content_rect = this.element_legend_childs.perfect_scroller.firstElementChild.getBoundingClientRect(); + let wanted = content_rect.top - parent_rect.top + this.element_legend_childs.perfect_scroller.firstChild.clientHeight + 18; // 15 = toolbox + 3 space + + // console.log(parent_rect); + // console.log(content_rect); + // console.log(wanted); + + // this.log('resize to firstChild, current = ' + this.event_resize.chart_last_h.toString() + 'px, original = ' + this.event_resize.chart_original_h.toString() + 'px, optimal = ' + optimal.toString() + 'px, internal = ' + this.height_original.toString() + 'px, firstChild = ' + wanted.toString() + 'px' ); + if (this.event_resize.chart_last_h !== wanted) { + resizeChartToHeight(wanted.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) { + let 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) { + let 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) { + void(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; + }; + } + }; + + const noDataToShow = () => { + showMessageIcon(NETDATA.icons.noData + ' empty'); + this.legendUpdateDOM(); + this.tm.last_autorefreshed = Date.now(); + // this.data_update_every = 30 * 1000; + //this.element_chart.style.display = 'none'; + //if (this.element_legend !== null) this.element_legend.style.display = 'none'; + //this.tmp.___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 = Date.now(); + }; + + // ---------------------------------------------------------------------------------------------------------------- + // global selection sync for slaves + + // can the chart participate to the global selection sync as a slave? + this.globalSelectionSyncIsEligible = function () { + return ( + this.enabled && + this.library !== null && + typeof this.library.setSelection === 'function' && + this.isVisible() && + this.chart_created + ); + }; + + this.setSelection = function (t) { + if (typeof this.library.setSelection === 'function') { + // this.selected = this.library.setSelection(this, t) === true; + this.selected = this.library.setSelection(this, t); + } else { + this.selected = true; + } + + if (this.selected && this.debug) { + this.log('selection set to ' + t.toString()); + } + + if (this.foreignElementSelection !== null) { + this.foreignElementSelection.innerText = NETDATA.dateTime.localeDateString(t) + ' ' + NETDATA.dateTime.localeTimeString(t); + } + + return this.selected; + }; + + this.clearSelection = function () { + if (this.selected) { + if (typeof this.library.clearSelection === 'function') { + this.selected = (this.library.clearSelection(this) !== true); + } else { + this.selected = false; + } + + if (this.selected === false && this.debug) { + this.log('selection cleared'); + } + + if (this.foreignElementSelection !== null) { + this.foreignElementSelection.innerText = ''; + } + + this.legendReset(); + } + + return this.selected; + }; + + // ---------------------------------------------------------------------------------------------------------------- + + // find if a timestamp (ms) is shown in the current chart + this.timeIsVisible = function (t) { + return (t >= this.data_after && t <= this.data_before); + }; + + this.calculateRowForTime = function (t) { + if (!this.timeIsVisible(t)) { + return -1; + } + return Math.floor((t - this.data_after) / this.data_update_every); + }; + + // ---------------------------------------------------------------------------------------------------------------- + + this.pauseChart = function () { + if (!this.paused) { + if (this.debug) { + this.log('pauseChart()'); + } + + this.paused = true; + } + }; + + this.unpauseChart = function () { + if (this.paused) { + if (this.debug) { + this.log('unpauseChart()'); + } + + this.paused = false; + } + }; + + this.resetChart = function (dontClearMaster, dontUpdate) { + if (this.debug) { + this.log('resetChart(' + dontClearMaster + ', ' + dontUpdate + ') called'); + } + + if (typeof dontClearMaster === 'undefined') { + dontClearMaster = false; + } + + if (typeof dontUpdate === 'undefined') { + dontUpdate = false; + } + + if (dontClearMaster !== true && NETDATA.globalPanAndZoom.isMaster(this)) { + if (this.debug) { + 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 (dontUpdate !== true && this.isVisible()) { + this.updateChart(); + } + }; + + this.updateChartPanOrZoom = function (after, before, callback) { + let logme = 'updateChartPanOrZoom(' + after + ', ' + before + '): '; + let ret = true; + + NETDATA.globalPanAndZoom.delay(); + NETDATA.globalSelectionSync.delay(); + + if (this.debug) { + this.log(logme); + } + + if (before < after) { + if (this.debug) { + 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); + } + + let min_duration = this.fixed_min_duration; + let 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 + let 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) { + this.log(logme + 'too small: min_duration: ' + (min_duration / 1000).toString() + ', wanted: ' + (wanted_duration / 1000).toString()); + } + + min_duration = this.fixed_min_duration; + + let dt = (min_duration - wanted_duration) / 2; + before += dt; + after -= dt; + wanted_duration = before - after; + ret = false; + } + + let tolerance = this.data_update_every * 2; + let movement = Math.abs(before - this.view_before); + + if (Math.abs(current_duration - wanted_duration) <= tolerance && movement <= tolerance && ret) { + if (this.debug) { + 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) { + 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 = Date.now() + 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); + + if (ret && typeof callback === 'function') { + callback(); + } + + return ret; + }; + + this.updateChartPanOrZoomAsyncTimeOutId = undefined; + this.updateChartPanOrZoomAsync = function (after, before, callback) { + NETDATA.globalPanAndZoom.delay(); + NETDATA.globalSelectionSync.delay(); + + if (!NETDATA.globalPanAndZoom.isMaster(this)) { + this.pauseChart(); + NETDATA.globalPanAndZoom.setMaster(this, after, before); + // NETDATA.globalSelectionSync.stop(); + NETDATA.globalSelectionSync.setMaster(this); + } + + if (this.updateChartPanOrZoomAsyncTimeOutId) { + NETDATA.timeout.clear(this.updateChartPanOrZoomAsyncTimeOutId); + } + + NETDATA.timeout.set(function () { + that.updateChartPanOrZoomAsyncTimeOutId = undefined; + that.updateChartPanOrZoom(after, before, callback); + }, 0); + }; + + let _unitsConversionLastUnits = undefined; + let _unitsConversionLastUnitsDesired = undefined; + let _unitsConversionLastMin = undefined; + let _unitsConversionLastMax = undefined; + let _unitsConversion = function (value) { + return value; + }; + this.unitsConversionSetup = function (min, max) { + if (this.units !== _unitsConversionLastUnits + || this.units_desired !== _unitsConversionLastUnitsDesired + || min !== _unitsConversionLastMin + || max !== _unitsConversionLastMax) { + + _unitsConversionLastUnits = this.units; + _unitsConversionLastUnitsDesired = this.units_desired; + _unitsConversionLastMin = min; + _unitsConversionLastMax = max; + + _unitsConversion = NETDATA.unitsConversion.get(this.uuid, min, max, this.units, this.units_desired, this.units_common, function (units) { + // console.log('switching units from ' + that.units.toString() + ' to ' + units.toString()); + that.units_current = units; + that.legendSetUnitsString(that.units_current); + }); + } + }; + + let _legendFormatValueChartDecimalsLastMin = undefined; + let _legendFormatValueChartDecimalsLastMax = undefined; + let _legendFormatValueChartDecimals = -1; + let _intlNumberFormat = null; + this.legendFormatValueDecimalsFromMinMax = function (min, max) { + if (min === _legendFormatValueChartDecimalsLastMin && max === _legendFormatValueChartDecimalsLastMax) { + return; + } + + this.unitsConversionSetup(min, max); + if (_unitsConversion !== null) { + min = _unitsConversion(min); + max = _unitsConversion(max); + + if (typeof min !== 'number' || typeof max !== 'number') { + return; + } + } + + _legendFormatValueChartDecimalsLastMin = min; + _legendFormatValueChartDecimalsLastMax = max; + + let old = _legendFormatValueChartDecimals; + + if (this.data !== null && this.data.min === this.data.max) + // it is a fixed number, let the visualizer decide based on the value + { + _legendFormatValueChartDecimals = -1; + } else if (this.value_decimal_detail !== -1) + // there is an override + { + _legendFormatValueChartDecimals = this.value_decimal_detail; + } else { + // ok, let's calculate the proper number of decimal points + let delta; + + if (min === max) { + delta = Math.abs(min); + } else { + delta = Math.abs(max - min); + } + + if (delta > 1000) { + _legendFormatValueChartDecimals = 0; + } else if (delta > 10) { + _legendFormatValueChartDecimals = 1; + } else if (delta > 1) { + _legendFormatValueChartDecimals = 2; + } else if (delta > 0.1) { + _legendFormatValueChartDecimals = 2; + } else if (delta > 0.01) { + _legendFormatValueChartDecimals = 4; + } else if (delta > 0.001) { + _legendFormatValueChartDecimals = 5; + } else if (delta > 0.0001) { + _legendFormatValueChartDecimals = 6; + } else { + _legendFormatValueChartDecimals = 7; + } + } + + if (_legendFormatValueChartDecimals !== old) { + if (_legendFormatValueChartDecimals < 0) { + _intlNumberFormat = null; + } else { + _intlNumberFormat = NETDATA.fastNumberFormat.get( + _legendFormatValueChartDecimals, + _legendFormatValueChartDecimals + ); + } + } + }; + + this.legendFormatValue = function (value) { + if (typeof value !== 'number') { + return '-'; + } + + value = _unitsConversion(value); + + if (typeof value !== 'number') { + return value; + } + + if (_intlNumberFormat !== null) { + return _intlNumberFormat.format(value); + } + + let dmin, dmax; + if (this.value_decimal_detail !== -1) { + dmin = dmax = this.value_decimal_detail; + } else { + dmin = 0; + let abs = (value < 0) ? -value : value; + if (abs > 1000) { + dmax = 0; + } else if (abs > 10) { + dmax = 1; + } else if (abs > 1) { + dmax = 2; + } else if (abs > 0.1) { + dmax = 2; + } else if (abs > 0.01) { + dmax = 4; + } else if (abs > 0.001) { + dmax = 5; + } else if (abs > 0.0001) { + dmax = 6; + } else { + dmax = 7; + } + } + + return NETDATA.fastNumberFormat.get(dmin, dmax).format(value); + }; + + this.legendSetLabelValue = function (label, value) { + let series = this.element_legend_childs.series[label]; + if (typeof series === 'undefined') { + return; + } + if (series.value === null && series.user === null) { + return; + } + + /* + // this slows down firefox and edge significantly + // since it requires to use innerHTML(), instead of innerText() + + // if the value has not changed, skip DOM update + //if (series.last === value) return; + + let s, r; + if (typeof value === 'number') { + let v = Math.abs(value); + s = r = this.legendFormatValue(value); + + if (typeof series.last === 'number') { + if (v > series.last) s += ''; + else if (v < series.last) s += ''; + else s += ''; + } + else s += ''; + + series.last = v; + } + else { + if (value === null) + s = r = ''; + else + s = r = value; + + series.last = value; + } + */ + + let s = this.legendFormatValue(value); + + // caching: do not update the update to show the same value again + if (s === series.last_shown_value) { + return; + } + series.last_shown_value = s; + + if (series.value !== null) { + series.value.innerText = s; + } + if (series.user !== null) { + series.user.innerText = s; + } + }; + + this.legendSetDateString = function (date) { + if (this.element_legend_childs.title_date !== null && date !== this.tmp.__last_shown_legend_date) { + this.element_legend_childs.title_date.innerText = date; + this.tmp.__last_shown_legend_date = date; + } + }; + + this.legendSetTimeString = function (time) { + if (this.element_legend_childs.title_time !== null && time !== this.tmp.__last_shown_legend_time) { + this.element_legend_childs.title_time.innerText = time; + this.tmp.__last_shown_legend_time = time; + } + }; + + this.legendSetUnitsString = function (units) { + if (this.element_legend_childs.title_units !== null && units !== this.tmp.__last_shown_legend_units) { + this.element_legend_childs.title_units.innerText = units; + this.tmp.__last_shown_legend_units = units; + } + }; + + this.legendSetDateLast = { + ms: 0, + date: undefined, + time: undefined + }; + + this.legendSetDate = function (ms) { + if (typeof ms !== 'number') { + this.legendShowUndefined(); + return; + } + + if (this.legendSetDateLast.ms !== ms) { + let d = new Date(ms); + this.legendSetDateLast.ms = ms; + this.legendSetDateLast.date = NETDATA.dateTime.localeDateString(d); + this.legendSetDateLast.time = NETDATA.dateTime.localeTimeString(d); + } + + this.legendSetDateString(this.legendSetDateLast.date); + this.legendSetTimeString(this.legendSetDateLast.time); + this.legendSetUnitsString(this.units_current) + }; + + this.legendShowUndefined = function () { + this.legendSetDateString(this.legendPluginModuleString(false)); + this.legendSetTimeString(this.chart.context.toString()); + // this.legendSetUnitsString(' '); + + if (this.data && this.element_legend_childs.series !== null) { + let labels = this.data.dimension_names; + let i = labels.length; + while (i--) { + let label = labels[i]; + + if (typeof label === 'undefined' || 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; + } + + let 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); + + let labels = this.data.dimension_names; + let i = labels.length; + while (i--) { + let label = labels[i]; + + if (typeof label === 'undefined') { + continue; + } + if (typeof this.element_legend_childs.series[label] === 'undefined') { + continue; + } + + 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) { + let c = NETDATA.commonColors.get(this, label); + + // it is important to maintain a list of colors + // for this chart only, since the chart library + // uses this to assign colors to dimensions in the same + // order the dimension are given to it + this.colors.push(c); + + return c; + }; + + this.chartPrepareColorPalette = function () { + NETDATA.commonColors.refill(this); + }; + + // get the ordered list of chart colors + // this includes user defined colors + this.chartCustomColors = function () { + this.chartPrepareColorPalette(); + + let colors; + if (this.colors_custom.length) { + colors = this.colors_custom; + } else { + colors = this.colors; + } + + if (this.debug) { + this.log("chartCustomColors() returns:"); + this.log(colors); + } + + return colors; + }; + + // get the ordered list of chart ASSIGNED colors + // (this returns only the colors that have been + // assigned to dimensions, prepended with any + // custom colors defined) + this.chartColors = function () { + this.chartPrepareColorPalette(); + + if (this.debug) { + this.log("chartColors() returns:"); + this.log(this.colors); + } + + return this.colors; + }; + + this.legendPluginModuleString = function (withContext) { + let str = ' '; + let context = ''; + + if (typeof this.chart !== 'undefined') { + if (withContext && typeof this.chart.context === 'string') { + context = this.chart.context; + } + + if (typeof this.chart.plugin === 'string' && this.chart.plugin !== '') { + str = this.chart.plugin; + + if (str.endsWith(".plugin")) { + str = str.substring(0, str.length - 7); + } + + if (typeof this.chart.module === 'string' && this.chart.module !== '') { + str += ':' + this.chart.module; + } + + if (withContext && context !== '') { + str += ', ' + context; + } + } + else if (withContext && context !== '') { + str = context; + } + } + + return str; + }; + + this.legendResolutionTooltip = function () { + if (!this.chart) { + return ''; + } + + let collected = this.chart.update_every; + let viewed = (this.data) ? this.data.view_update_every : collected; + + if (collected === viewed) { + return "resolution " + NETDATA.seconds4human(collected); + } + + return "resolution " + NETDATA.seconds4human(viewed) + ", collected every " + NETDATA.seconds4human(collected); + }; + + this.legendUpdateDOM = function () { + let needed = false, dim, keys, len; + + // 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 { + let labels = this.data.dimension_names.toString(); + if (labels !== this.element_legend_childs.series.labels_key) { + needed = true; + + if (this.debug) { + this.log('NEW LABELS: "' + labels + '" NOT EQUAL OLD LABELS: "' + this.element_legend_childs.series.labels_key + '"'); + } + } + } + + if (!needed) { + // make sure colors available + this.chartPrepareColorPalette(); + + // 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) { + this.log('chart is in latest position... updating values on legend...'); + } + + //let labels = this.data.dimension_names; + //let i = labels.length; + //while (i--) + // this.legendSetLabelValue(labels[i], this.data.view_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()) { + this.colors = []; + keys = Object.keys(this.chart.dimensions); + len = keys.length; + for (let i = 0; i < len; i++) { + NETDATA.commonColors.get(this, this.chart.dimensions[keys[i]].name); + } + } + } + + // we will re-generate the colors for the chart + // based on the dimensions this result has data for + this.colors = []; + + if (this.debug) { + this.log('updating Legend DOM'); + } + + // mark all dimensions as invalid + this.dimensions_visibility.invalidateAll(); + + const genLabel = function (state, parent, dim, name, count) { + let color = state.__chartDimensionColor(name); + + let user_element = null; + let user_id = NETDATA.dataAttribute(state.element, 'show-value-of-' + name.toLowerCase() + '-at', null); + if (user_id === null) { + user_id = NETDATA.dataAttribute(state.element, 'show-value-of-' + dim.toLowerCase() + '-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, + last_shown_value: null + }; + + let 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); + + let rgb = NETDATA.colorHex2Rgb(color); + label.name.innerHTML = '
    '; + + let text = document.createTextNode(' ' + name); + label.name.appendChild(text); + + if (count > 0) { + parent.appendChild(document.createElement('br')); + } + + parent.appendChild(label.name); + parent.appendChild(label.value); + }; + + let content = document.createElement('div'); + + if (this.element_chart === null) { + this.element_chart = document.createElement('div'); + this.element_chart.id = this.library_name + '-' + this.uuid + '-chart'; + this.element.appendChild(this.element_chart); + + if (this.hasLegend()) { + this.element_chart.className = 'netdata-chart-with-legend-right netdata-' + this.library_name + '-chart-with-legend-right'; + } else { + this.element_chart.className = ' netdata-chart netdata-' + this.library_name + '-chart'; + } + } + + if (this.hasLegend()) { + if (this.element_legend === null) { + this.element_legend = document.createElement('div'); + this.element_legend.className = 'netdata-chart-legend netdata-' + this.library_name + '-legend'; + this.element.appendChild(this.element_legend); + } else { + this.element_legend.innerHTML = ''; + } + + 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: document.createElement('span'), + title_time: document.createElement('span'), + title_units: document.createElement('span'), + perfect_scroller: document.createElement('div'), + series: {} + }; + + if (NETDATA.options.current.legend_toolbox && this.library.toolboxPanAndZoom !== null) { + this.element_legend_childs.toolbox = document.createElement('div'); + this.element_legend_childs.toolbox_left = document.createElement('div'); + this.element_legend_childs.toolbox_right = document.createElement('div'); + this.element_legend_childs.toolbox_reset = document.createElement('div'); + this.element_legend_childs.toolbox_zoomin = document.createElement('div'); + this.element_legend_childs.toolbox_zoomout = document.createElement('div'); + this.element_legend_childs.toolbox_volume = document.createElement('div'); + + const getPanAndZoomStep = function (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 = NETDATA.icons.left; + this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_left); + this.element_legend_childs.toolbox_left.onclick = function (e) { + e.preventDefault(); + + let step = (that.view_before - that.view_after) * getPanAndZoomStep(e); + let before = that.view_before - step; + let after = that.view_after - step; + if (after >= that.netdata_first) { + that.library.toolboxPanAndZoom(that, after, before); + } + }; + if (NETDATA.options.current.show_help) { + $(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 drag it with your mouse or your finger (on touch devices).
    Help can be disabled from the settings.' + }); + } + + this.element_legend_childs.toolbox_reset.className += ' netdata-legend-toolbox-button'; + this.element_legend_childs.toolbox_reset.innerHTML = NETDATA.icons.reset; + 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) { + $(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 double click the chart contents with your mouse or your finger (on touch devices).
    Help can be disabled from the settings.' + }); + } + + this.element_legend_childs.toolbox_right.className += ' netdata-legend-toolbox-button'; + this.element_legend_childs.toolbox_right.innerHTML = NETDATA.icons.right; + this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_right); + this.element_legend_childs.toolbox_right.onclick = function (e) { + e.preventDefault(); + let step = (that.view_before - that.view_after) * getPanAndZoomStep(e); + let before = that.view_before + step; + let after = that.view_after + step; + if (before <= that.netdata_last) { + that.library.toolboxPanAndZoom(that, after, before); + } + }; + if (NETDATA.options.current.show_help) { + $(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 drag it with your mouse or your finger (on touch devices).
    Help can be disabled from the settings.' + }); + } + + this.element_legend_childs.toolbox_zoomin.className += ' netdata-legend-toolbox-button'; + this.element_legend_childs.toolbox_zoomin.innerHTML = NETDATA.icons.zoomIn; + this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomin); + this.element_legend_childs.toolbox_zoomin.onclick = function (e) { + e.preventDefault(); + let dt = ((that.view_before - that.view_after) * (getPanAndZoomStep(e) * 0.8) / 2); + let before = that.view_before - dt; + let after = that.view_after + dt; + that.library.toolboxPanAndZoom(that, after, before); + }; + if (NETDATA.options.current.show_help) { + $(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, or press SHIFT or ALT and use the mouse wheel or 2-finger touchpad scroll to zoom in or out.
    Help can be disabled from the settings.' + }); + } + + this.element_legend_childs.toolbox_zoomout.className += ' netdata-legend-toolbox-button'; + this.element_legend_childs.toolbox_zoomout.innerHTML = NETDATA.icons.zoomOut; + this.element_legend_childs.toolbox.appendChild(this.element_legend_childs.toolbox_zoomout); + this.element_legend_childs.toolbox_zoomout.onclick = function (e) { + e.preventDefault(); + let dt = (((that.view_before - that.view_after) / (1.0 - (getPanAndZoomStep(e) * 0.8)) - (that.view_before - that.view_after)) / 2); + let before = that.view_before + dt; + let after = that.view_after - dt; + + that.library.toolboxPanAndZoom(that, after, before); + }; + if (NETDATA.options.current.show_help) { + $(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. You can also press SHIFT or ALT and use the mouse wheel, or 2-finger touchpad scroll to zoom in or out.
    Help can be disabled from the settings.' + }); + } + + //this.element_legend_childs.toolbox_volume.className += ' netdata-legend-toolbox-button'; + //this.element_legend_childs.toolbox_volume.innerHTML = ''; + //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); + //} + } + + if (NETDATA.options.current.resize_charts) { + this.element_legend_childs.resize_handler = document.createElement('div'); + + this.element_legend_childs.resize_handler.className += " netdata-legend-resize-handler"; + this.element_legend_childs.resize_handler.innerHTML = NETDATA.icons.resize; + this.element.appendChild(this.element_legend_childs.resize_handler); + if (NETDATA.options.current.show_help) { + $(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 double click it or double tap it to reset between 2 states: the default and the one that fits all the values.
    Help can be disabled from the settings.' + }); + } + + // 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); + } + + if (this.chart) { + this.element_legend_childs.title_date.title = this.legendPluginModuleString(true); + this.element_legend_childs.title_time.title = this.legendResolutionTooltip(); + } + + this.element_legend_childs.title_date.className += " netdata-legend-title-date"; + this.element_legend.appendChild(this.element_legend_childs.title_date); + this.tmp.__last_shown_legend_date = undefined; + + 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.tmp.__last_shown_legend_time = undefined; + + this.element_legend.appendChild(document.createElement('br')); + + this.element_legend_childs.title_units.className += " netdata-legend-title-units"; + this.element_legend_childs.title_units.innerText = this.units_current; + this.element_legend.appendChild(this.element_legend_childs.title_units); + this.tmp.__last_shown_legend_units = undefined; + + this.element_legend.appendChild(document.createElement('br')); + + this.element_legend_childs.perfect_scroller.className = 'netdata-legend-series'; + this.element_legend.appendChild(this.element_legend_childs.perfect_scroller); + + content.className = 'netdata-legend-series-content'; + this.element_legend_childs.perfect_scroller.appendChild(content); + + this.element_legend_childs.content = content; + + if (NETDATA.options.current.show_help) { + $(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 dimensions. By pressing SHIFT or CONTROL, you can enable or disable multiple dimensions.
    Help can be disabled from the settings.' + }); + } + } 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, + perfect_scroller: null, + series: {} + }; + } + + if (this.data) { + this.element_legend_childs.series.labels_key = this.data.dimension_names.toString(); + if (this.debug) { + this.log('labels from data: "' + this.element_legend_childs.series.labels_key + '"'); + } + + for (let 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 { + let tmp = []; + keys = Object.keys(this.chart.dimensions); + for (let i = 0, len = keys.length; i < len; i++) { + dim = keys[i]; + 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) { + this.log('labels from chart: "' + this.element_legend_childs.series.labels_key + '"'); + } + } + + // create a hidden div to be used for hiding + // the original legend of the chart library + let 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.perfect_scroller !== null) { + Ps.initialize(this.element_legend_childs.perfect_scroller, { + wheelSpeed: 0.2, + wheelPropagation: true, + swipePropagation: true, + minScrollbarLength: null, + maxScrollbarLength: null, + useBothWheelAxes: false, + suppressScrollX: true, + suppressScrollY: false, + scrollXMarginOffset: 0, + scrollYMarginOffset: 0, + theme: 'default' + }); + Ps.update(this.element_legend_childs.perfect_scroller); + } + + this.legendShowLatestValues(); + }; + + this.hasLegend = function () { + if (typeof this.tmp.___hasLegendCache___ !== 'undefined') { + return this.tmp.___hasLegendCache___; + } + + let leg = false; + if (this.library && this.library.legend(this) === 'right-side') { + leg = true; + } + + this.tmp.___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 + let 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 () { + let ret = ( + this.chart_created && + this.library && + this.library.autoresize() === false && + this.tm.last_resized < NETDATA.options.last_page_resize + ); + + if (this.debug) { + this.log('needsRecreation(): ' + ret.toString() + ', chart_created = ' + this.chart_created.toString()); + } + + return ret; + }; + + this.chartDataUniqueID = function () { + return this.id + ',' + this.library_name + ',' + this.dimensions + ',' + this.chartURLOptions(true); + }; + + this.chartURLOptions = function (isForUniqueId) { + let ret = ''; + + if (this.override_options !== null) { + ret = this.override_options.toString(); + } else { + ret = this.library.options(this); + } + + if (this.append_options !== null) { + ret += '%7C' + this.append_options.toString(); + } + + ret += '%7C' + 'jsonwrap'; + + // always add `nonzero` when it's used to create a chartDataUniqueID + // we cannot just remove `nonzero` because of backwards compatibility with old snapshots + if (isForUniqueId || NETDATA.options.current.eliminate_zero_dimensions) { + ret += '%7C' + 'nonzero'; + } + + return ret; + }; + + this.chartURL = function () { + let after, before, points_multiplier = 1; + if (NETDATA.globalPanAndZoom.isActive()) { + 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) { + 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 = 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 { + 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; + + let data_points; + if (NETDATA.options.force_data_points !== 0) { + data_points = NETDATA.options.force_data_points; + this.data_points = data_points; + } else { + this.data_points = this.points || Math.round(this.chartWidth() / this.chartPixelsPerPoint()); + data_points = this.data_points * points_multiplier; + } + + // build the data URL + this.data_url = this.host + this.chart.data_url; + this.data_url += "&format=" + this.library.format(); + this.data_url += "&points=" + (data_points).toString(); + this.data_url += "&group=" + this.method; + this.data_url += ">ime=" + this.gtime; + this.data_url += "&options=" + this.chartURLOptions(); + + 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 || this.debug) { + this.log('chartURL(): ' + this.data_url + ' WxH:' + this.chartWidth() + 'x' + this.chartHeight() + ' points: ' + data_points.toString() + ' library: ' + this.library_name); + } + }; + + this.redrawChart = function () { + if (this.data !== null) { + this.updateChartWithData(this.data); + } + }; + + this.updateChartWithData = function (data) { + if (this.debug) { + this.log('updateChartWithData() called.'); + } + + // this may force the chart to be re-created + resizeChart(); + + this.data = data; + + let started = Date.now(); + let view_update_every = data.view_update_every * 1000; + + if (this.data_update_every !== view_update_every) { + if (this.element_legend_childs.title_time) { + this.element_legend_childs.title_time.title = this.legendResolutionTooltip(); + } + } + + // if the result is JSON, find the latest update-every + this.data_update_every = view_update_every; + 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 && this.requested_padding !== null) { + if (this.view_after < this.data_after) { + // console.log('adjusting 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('adjusting 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) { + 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) { + this.log('max updates of ' + this.updates_since_last_creation.toString() + ' reached. Forcing re-generation.'); + } + + init('force'); + return; + } + + // check and update the legend + this.legendUpdateDOM(); + + if (this.chart_created && typeof this.library.update === 'function') { + if (this.debug) { + this.log('updating chart...'); + } + + if (!callChartLibraryUpdateSafely(data)) { + return; + } + } else { + if (this.debug) { + this.log('creating chart...'); + } + + if (!callChartLibraryCreateSafely(data)) { + return; + } + } + + if (this.isVisible()) { + hideMessage(); + this.legendShowLatestValues(); + } else { + this.__redraw_on_unhide = true; + + if (this.debug) { + this.log("drawn while not visible"); + } + } + + if (this.selected) { + NETDATA.globalSelectionSync.stop(); + } + + // update the performance counters + let now = Date.now(); + 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 && NETDATA.options.current.concurrent_refreshes && typeof this.force_update_every !== 'number') { + 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.innerText = this.refresh_dt_ms.toString(); + } + + if (this.foreignElementBefore !== null) { + this.foreignElementBefore.innerText = NETDATA.dateTime.localeDateString(this.view_before) + ' ' + NETDATA.dateTime.localeTimeString(this.view_before); + } + + if (this.foreignElementAfter !== null) { + this.foreignElementAfter.innerText = NETDATA.dateTime.localeDateString(this.view_after) + ' ' + NETDATA.dateTime.localeTimeString(this.view_after); + } + + if (this.foreignElementDuration !== null) { + this.foreignElementDuration.innerText = NETDATA.seconds4human(Math.floor((this.view_before - this.view_after) / 1000) + 1); + } + + if (this.foreignElementUpdateEvery !== null) { + this.foreignElementUpdateEvery.innerText = NETDATA.seconds4human(Math.floor(this.data_update_every / 1000)); + } + }; + + this.getSnapshotData = function (key) { + if (this.debug) { + this.log('updating from snapshot: ' + key); + } + + if (typeof netdataSnapshotData.data[key] === 'undefined') { + this.log('snapshot does not include data for key "' + key + '"'); + return null; + } + + if (typeof netdataSnapshotData.data[key] !== 'string') { + this.log('snapshot data for key "' + key + '" is not string'); + return null; + } + + let uncompressed; + try { + uncompressed = netdataSnapshotData.uncompress(netdataSnapshotData.data[key]); + + if (uncompressed === null) { + this.log('uncompressed snapshot data for key ' + key + ' is null'); + return null; + } + + if (typeof uncompressed === 'undefined') { + this.log('uncompressed snapshot data for key ' + key + ' is undefined'); + return null; + } + } catch (e) { + this.log('decompression of snapshot data for key ' + key + ' failed'); + console.log(e); + uncompressed = null; + } + + if (typeof uncompressed !== 'string') { + this.log('uncompressed snapshot data for key ' + key + ' is not string'); + return null; + } + + let data; + try { + data = JSON.parse(uncompressed); + } catch (e) { + this.log('parsing snapshot data for key ' + key + ' failed'); + console.log(e); + data = null; + } + + return data; + }; + + this.updateChart = function (callback) { + if (this.debug) { + this.log('updateChart()'); + } + + if (this.fetching_data) { + if (this.debug) { + this.log('updateChart(): I am already updating...'); + } + + if (typeof callback === 'function') { + return callback(false, 'already running'); + } + + return; + } + + // due to late initialization of charts and libraries + // we need to check this too + if (!this.enabled) { + if (this.debug) { + this.log('updateChart(): I am not enabled'); + } + + if (typeof callback === 'function') { + return callback(false, 'not enabled'); + } + + return; + } + + if (!canBeRendered()) { + if (this.debug) { + this.log('updateChart(): cannot be rendered'); + } + + if (typeof callback === 'function') { + return callback(false, 'cannot be rendered'); + } + + return; + } + + if (that.dom_created !== true) { + if (this.debug) { + this.log('updateChart(): creating DOM'); + } + + createDOM(); + } + + if (this.chart === null) { + if (this.debug) { + this.log('updateChart(): getting chart'); + } + + return this.getChart(function () { + return that.updateChart(callback); + }); + } + + if (!this.library.initialized) { + if (this.library.enabled) { + if (this.debug) { + this.log('updateChart(): initializing chart library'); + } + + return this.library.initialize(function () { + return that.updateChart(callback); + }); + } else { + error('chart library "' + this.library_name + '" is not available.'); + + if (typeof callback === 'function') { + return callback(false, 'library not available'); + } + + return; + } + } + + this.clearSelection(); + this.chartURL(); + + 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; + } + + let ok = false; + this.fetching_data = true; + + if (netdataSnapshotData !== null) { + let key = this.chartDataUniqueID(); + let data = this.getSnapshotData(key); + if (data !== null) { + ok = true; + data = NETDATA.xss.checkData('/api/v1/data', data, this.library.xssRegexIgnore); + this.updateChartWithData(data); + } else { + ok = false; + error('cannot get data from snapshot for key: "' + key + '"'); + that.tm.last_autorefreshed = Date.now(); + } + + NETDATA.statistics.refreshes_active--; + this.fetching_data = false; + + if (typeof callback === 'function') { + callback(ok, 'snapshot'); + } + + return; + } + + if (this.debug) { + this.log('updating from ' + this.data_url); + } + + this.xhr = $.ajax({ + url: this.data_url, + cache: false, + async: true, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkData('/api/v1/data', data, that.library.xssRegexIgnore); + + that.xhr = undefined; + that.retries_on_data_failures = 0; + ok = true; + + if (that.debug) { + that.log('data received. updating chart.'); + } + + that.updateChartWithData(data); + }) + .fail(function (msg) { + that.xhr = undefined; + + if (msg.statusText !== 'abort') { + that.retries_on_data_failures++; + if (that.retries_on_data_failures > NETDATA.options.current.retries_on_data_failures) { + // that.log('failed ' + that.retries_on_data_failures.toString() + ' times - giving up'); + that.retries_on_data_failures = 0; + error('data download failed for url: ' + that.data_url); + } + else { + that.tm.last_autorefreshed = Date.now(); + // that.log('failed ' + that.retries_on_data_failures.toString() + ' times, but I will retry'); + } + } + }) + .always(function () { + that.xhr = undefined; + + NETDATA.statistics.refreshes_active--; + that.fetching_data = false; + + if (typeof callback === 'function') { + return callback(ok, 'download'); + } + }); + }; + + const __isVisible = function () { + let ret = true; + + if (NETDATA.options.current.update_only_visible !== false) { + // tolerance is the number of pixels a chart can be off-screen + // to consider it as visible and refresh it as if was visible + let tolerance = 0; + + that.tm.last_visible_check = Date.now(); + + let rect = that.element.getBoundingClientRect(); + + let screenTop = window.scrollY; + let screenBottom = screenTop + window.innerHeight; + + let chartTop = rect.top + screenTop; + let chartBottom = chartTop + rect.height; + + ret = !(rect.width === 0 || rect.height === 0 || chartBottom + tolerance < screenTop || chartTop - tolerance > screenBottom); + } + + if (that.debug) { + that.log('__isVisible(): ' + ret); + } + + return ret; + }; + + this.isVisible = function (nocache) { + // 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 ((typeof nocache !== 'undefined' && nocache) + || typeof this.tmp.___isVisible___ === 'undefined' + || this.tm.last_visible_check <= NETDATA.options.last_page_scroll) { + this.tmp.___isVisible___ = __isVisible(); + if (this.tmp.___isVisible___) { + this.unhideChart(); + } else { + this.hideChart(); + } + } + + if (this.debug) { + this.log('isVisible(' + nocache + '): ' + this.tmp.___isVisible___); + } + + return this.tmp.___isVisible___; + }; + + this.isAutoRefreshable = function () { + return (this.current.autorefresh); + }; + + this.canBeAutoRefreshed = function () { + if (!this.enabled) { + if (this.debug) { + this.log('canBeAutoRefreshed() -> not enabled'); + } + + return false; + } + + if (this.running) { + if (this.debug) { + this.log('canBeAutoRefreshed() -> already running'); + } + + return false; + } + + if (this.library === null || this.library.enabled === false) { + error('charting library "' + this.library_name + '" is not available'); + if (this.debug) { + this.log('canBeAutoRefreshed() -> chart library ' + this.library_name + ' is not available'); + } + + return false; + } + + if (!this.isVisible()) { + if (NETDATA.options.debug.visibility || this.debug) { + this.log('canBeAutoRefreshed() -> not visible'); + } + + return false; + } + + let now = Date.now(); + + if (this.current.force_update_at !== 0 && this.current.force_update_at < now) { + if (this.debug) { + this.log('canBeAutoRefreshed() -> timed force update - allowing this update'); + } + + this.current.force_update_at = 0; + return true; + } + + if (!this.isAutoRefreshable()) { + if (this.debug) { + this.log('canBeAutoRefreshed() -> not auto-refreshable'); + } + + return false; + } + + // allow the first update, even if the page is not visible + if (NETDATA.options.page_is_visible === false && this.updates_counter && this.updates_since_last_unhide) { + if (NETDATA.options.debug.focus || this.debug) { + this.log('canBeAutoRefreshed() -> not the first update, and page does not have focus'); + } + + return false; + } + + if (this.needsRecreation()) { + if (this.debug) { + this.log('canBeAutoRefreshed() -> needs re-creation.'); + } + + return true; + } + + if (NETDATA.options.auto_refresher_stop_until >= now) { + if (this.debug) { + this.log('canBeAutoRefreshed() -> stopped until is in future.'); + } + + return false; + } + + // options valid only for autoRefresh() + if (NETDATA.globalPanAndZoom.isActive()) { + if (NETDATA.globalPanAndZoom.shouldBeAutoRefreshed(this)) { + if (this.debug) { + this.log('canBeAutoRefreshed(): global panning: I need an update.'); + } + + return true; + } + else { + if (this.debug) { + this.log('canBeAutoRefreshed(): global panning: I am already up to date.'); + } + + return false; + } + } + + if (this.selected) { + if (this.debug) { + this.log('canBeAutoRefreshed(): I have a selection in place.'); + } + + return false; + } + + if (this.paused) { + if (this.debug) { + this.log('canBeAutoRefreshed(): I am paused.'); + } + + return false; + } + + let data_update_every = this.data_update_every; + if (typeof this.force_update_every === 'number') { + data_update_every = this.force_update_every; + } + + if (now - this.tm.last_autorefreshed >= data_update_every) { + if (this.debug) { + this.log('canBeAutoRefreshed(): It is time to update me. Now: ' + now.toString() + ', last_autorefreshed: ' + this.tm.last_autorefreshed + ', data_update_every: ' + data_update_every + ', delta: ' + (now - this.tm.last_autorefreshed).toString()); + } + + return true; + } + + return false; + }; + + this.autoRefresh = function (callback) { + let state = that; + + if (state.canBeAutoRefreshed() && state.running === false) { + state.running = true; + state.updateChart(function () { + state.running = false; + + if (typeof callback === 'function') { + return callback(); + } + }); + } else { + if (typeof callback === 'function') { + return 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 = Date.now(); + + if (this.title === null) { + this.title = chart.title; + } + + if (this.units === null) { + this.units = chart.units; + this.units_current = this.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') { + return callback(); + } + } else if (netdataSnapshotData !== null) { + // console.log(this); + // console.log(NETDATA.chartRegistry); + NETDATA.error(404, 'host: ' + this.host + ', chart: ' + this.id); + error('chart not found in snapshot'); + + if (typeof callback === 'function') { + return callback(); + } + } else { + this.chart_url = "/api/v1/chart?chart=" + this.id; + + if (this.debug) { + 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 = NETDATA.xss.checkOptional('/api/v1/chart', 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') { + return callback(); + } + }); + } + }; + + // ============================================================================================================ + // INITIALIZATION + + initDOM(); + init('fast'); +}; + +NETDATA.resetAllCharts = function (state) { + // first clear the global selection sync + // to make sure no chart is in selected state + NETDATA.globalSelectionSync.stop(); + + // there are 2 possibilities here + // a. state is the global Pan and Zoom master + // b. state is not the global Pan and Zoom master + + // let master = true; + // if (NETDATA.globalPanAndZoom.isMaster(state) === false) { + // master = false; + // } + const master = NETDATA.globalPanAndZoom.isMaster(state); + + // 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 || state.selected)) { + state.resetChart(); + } +}; + +// get or create a chart state, given a DOM element +NETDATA.chartState = function (element) { + let self = $(element); + + let state = self.data('netdata-state-object') || null; + if (state === null) { + state = new chartState(element); + self.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) { + console.log('loading ' + NETDATA.jQuery); + } + + let script = document.createElement('script'); + script.type = 'text/javascript'; + script.async = true; + script.src = NETDATA.jQuery; + + // script.onabort = onError; + script.onerror = function () { + NETDATA.error(101, NETDATA.jQuery); + }; + if (typeof callback === "function") { + script.onload = function () { + $ = jQuery; + return callback(); + }; + } + + let s = document.getElementsByTagName('script')[0]; + s.parentNode.insertBefore(script, s); + } + else if (typeof callback === "function") { + $ = jQuery; + return callback(); + } +}; + +NETDATA._loadCSS = function (filename) { + // don't use jQuery here + // styles are loaded before jQuery + // to eliminate showing an unstyled page to the user + + let 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); + } +}; + +// 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 (typeof callback === 'function') { + if (NETDATA.options.pause) { + return 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 sequential charts refresher +// it is meant to be autonomous +NETDATA.chartRefresherNoParallel = function (index, callback) { + let targets = NETDATA.intersectionObserver.targets(); + + if (NETDATA.options.debug.main_loop) { + console.log('NETDATA.chartRefresherNoParallel(' + index + ')'); + } + + if (NETDATA.options.updated_dom) { + // the dom has been updated + // get the dom parts again + NETDATA.parseDom(callback); + return; + } + if (index >= targets.length) { + if (NETDATA.options.debug.main_loop) { + console.log('waiting to restart main loop...'); + } + + NETDATA.options.auto_refresher_fast_weight = 0; + callback(); + } else { + let state = targets[index]; + + if (NETDATA.options.auto_refresher_fast_weight < NETDATA.options.current.fast_render_timeframe) { + if (NETDATA.options.debug.main_loop) { + console.log('fast rendering...'); + } + + if (state.isVisible()) { + NETDATA.timeout.set(function () { + state.autoRefresh(function () { + NETDATA.chartRefresherNoParallel(++index, callback); + }); + }, 0); + } else { + NETDATA.chartRefresherNoParallel(++index, callback); + } + } else { + if (NETDATA.options.debug.main_loop) { + console.log('waiting for next refresh...'); + } + NETDATA.options.auto_refresher_fast_weight = 0; + + NETDATA.timeout.set(function () { + state.autoRefresh(function () { + NETDATA.chartRefresherNoParallel(++index, callback); + }); + }, NETDATA.options.current.idle_between_charts); + } + } +}; + +NETDATA.chartRefresherWaitTime = function () { + return NETDATA.options.current.idle_parallel_loops; +}; + +// the default refresher +NETDATA.chartRefresherLastRun = 0; +NETDATA.chartRefresherRunsAfterParseDom = 0; +NETDATA.chartRefresherTimeoutId = undefined; + +NETDATA.chartRefresherReschedule = function () { + if (NETDATA.options.current.async_on_scroll) { + if (NETDATA.chartRefresherTimeoutId) { + NETDATA.timeout.clear(NETDATA.chartRefresherTimeoutId); + } + NETDATA.chartRefresherTimeoutId = NETDATA.timeout.set(NETDATA.chartRefresher, NETDATA.options.current.onscroll_worker_duration_threshold); + //console.log('chartRefresherReschedule()'); + } +}; + +NETDATA.chartRefresher = function () { + // console.log('chartRefresher() begin ' + (Date.now() - NETDATA.chartRefresherLastRun).toString() + ' ms since last run'); + + if (NETDATA.options.page_is_visible === false + && NETDATA.options.current.stop_updates_when_focus_is_lost + && NETDATA.chartRefresherLastRun > NETDATA.options.last_page_resize + && NETDATA.chartRefresherLastRun > NETDATA.options.last_page_scroll + && NETDATA.chartRefresherRunsAfterParseDom > 10 + ) { + setTimeout( + NETDATA.chartRefresher, + NETDATA.options.current.idle_lost_focus + ); + + // console.log('chartRefresher() page without focus, will run in ' + NETDATA.options.current.idle_lost_focus.toString() + ' ms, ' + NETDATA.chartRefresherRunsAfterParseDom.toString()); + return; + } + NETDATA.chartRefresherRunsAfterParseDom++; + + let now = Date.now(); + NETDATA.chartRefresherLastRun = now; + + if (now < NETDATA.options.on_scroll_refresher_stop_until) { + NETDATA.chartRefresherTimeoutId = NETDATA.timeout.set( + NETDATA.chartRefresher, + NETDATA.chartRefresherWaitTime() + ); + + // console.log('chartRefresher() end1 will run in ' + NETDATA.chartRefresherWaitTime().toString() + ' ms'); + return; + } + + if (now < NETDATA.options.auto_refresher_stop_until) { + NETDATA.chartRefresherTimeoutId = NETDATA.timeout.set( + NETDATA.chartRefresher, + NETDATA.chartRefresherWaitTime() + ); + + // console.log('chartRefresher() end2 will run in ' + NETDATA.chartRefresherWaitTime().toString() + ' ms'); + return; + } + + if (NETDATA.options.pause) { + // console.log('auto-refresher is paused'); + NETDATA.chartRefresherTimeoutId = NETDATA.timeout.set( + NETDATA.chartRefresher, + NETDATA.chartRefresherWaitTime() + ); + + // console.log('chartRefresher() end3 will run in ' + NETDATA.chartRefresherWaitTime().toString() + ' ms'); + return; + } + + if (typeof NETDATA.options.pauseCallback === 'function') { + // console.log('auto-refresher is calling pauseCallback'); + + NETDATA.options.pause = true; + NETDATA.options.pauseCallback(); + NETDATA.chartRefresher(); + + // console.log('chartRefresher() end4 (nested)'); + return; + } + + if (!NETDATA.options.current.parallel_refresher) { + // console.log('auto-refresher is calling chartRefresherNoParallel(0)'); + NETDATA.chartRefresherNoParallel(0, function () { + NETDATA.chartRefresherTimeoutId = NETDATA.timeout.set( + NETDATA.chartRefresher, + NETDATA.options.current.idle_between_loops + ); + }); + // console.log('chartRefresher() end5 (no parallel, nested)'); + return; + } + + if (NETDATA.options.updated_dom) { + // the dom has been updated + // get the dom parts again + // console.log('auto-refresher is calling parseDom()'); + NETDATA.parseDom(NETDATA.chartRefresher); + // console.log('chartRefresher() end6 (parseDom)'); + return; + } + + if (!NETDATA.globalSelectionSync.active()) { + let parallel = []; + let targets = NETDATA.intersectionObserver.targets(); + let len = targets.length; + let state; + while (len--) { + state = targets[len]; + if (state.running || state.isVisible() === false) { + continue; + } + + if (!state.library.initialized) { + if (state.library.enabled) { + state.library.initialize(NETDATA.chartRefresher); + //console.log('chartRefresher() end6 (library init)'); + return; + } + else { + state.error('chart library "' + state.library_name + '" is not enabled.'); + } + } + + if (NETDATA.scrollUp) { + parallel.unshift(state); + } else { + parallel.push(state); + } + } + + len = parallel.length; + while (len--) { + state = parallel[len]; + // console.log('auto-refresher executing in parallel for ' + parallel.length.toString() + ' charts'); + // this will execute the jobs in parallel + + if (!state.running) { + NETDATA.timeout.set(state.autoRefresh, 0); + } + } + //else { + // console.log('auto-refresher nothing to do'); + //} + } + + // run the next refresh iteration + NETDATA.chartRefresherTimeoutId = NETDATA.timeout.set( + NETDATA.chartRefresher, + NETDATA.chartRefresherWaitTime() + ); + + //console.log('chartRefresher() completed in ' + (Date.now() - now).toString() + ' ms'); +}; + +NETDATA.parseDom = function (callback) { + //console.log('parseDom()'); + + NETDATA.options.last_page_scroll = Date.now(); + NETDATA.options.updated_dom = false; + NETDATA.chartRefresherRunsAfterParseDom = 0; + + let targets = $('div[data-netdata]'); //.filter(':visible'); + + if (NETDATA.options.debug.main_loop) { + console.log('DOM updated - there are ' + targets.length + ' charts on page.'); + } + + NETDATA.intersectionObserver.globalReset(); + NETDATA.options.targets = []; + let len = targets.length; + while (len--) { + // the initialization will take care of sizing + // and the "loading..." message + let state = NETDATA.chartState(targets[len]); + NETDATA.options.targets.push(state); + NETDATA.intersectionObserver.observe(state); + } + + if (NETDATA.globalChartUnderlay.isActive()) { + NETDATA.globalChartUnderlay.setup(); + } else { + NETDATA.globalChartUnderlay.clear(); + } + + if (typeof callback === 'function') { + return callback(); + } +}; + +// this is the main function - where everything starts +NETDATA.started = false; +NETDATA.start = function () { + // this should be called only once + + if (NETDATA.started) { + console.log('netdata is already started'); + return; + } + + NETDATA.started = true; + NETDATA.options.page_is_visible = true; + + $(window).blur(function () { + if (NETDATA.options.current.stop_updates_when_focus_is_lost) { + NETDATA.options.page_is_visible = false; + if (NETDATA.options.debug.focus) { + console.log('Lost Focus!'); + } + } + }); + + $(window).focus(function () { + if (NETDATA.options.current.stop_updates_when_focus_is_lost) { + NETDATA.options.page_is_visible = true; + if (NETDATA.options.debug.focus) { + console.log('Focus restored!'); + } + } + }); + + if (typeof document.hasFocus === 'function' && !document.hasFocus()) { + if (NETDATA.options.current.stop_updates_when_focus_is_lost) { + NETDATA.options.page_is_visible = false; + if (NETDATA.options.debug.focus) { + console.log('Document has no focus!'); + } + } + } + + // bootstrap tab switching + $('a[data-toggle="tab"]').on('shown.bs.tab', NETDATA.onscroll); + + // bootstrap modal switching + let $modal = $('.modal'); + $modal.on('hidden.bs.modal', NETDATA.onscroll); + $modal.on('shown.bs.modal', NETDATA.onscroll); + + // bootstrap collapse switching + let $collapse = $('.collapse'); + $collapse.on('hidden.bs.collapse', NETDATA.onscroll); + $collapse.on('shown.bs.collapse', NETDATA.onscroll); + + NETDATA.parseDom(NETDATA.chartRefresher); + + // Alarms initialization + setTimeout(NETDATA.alarms.init, 1000); + + // Registry initialization + setTimeout(NETDATA.registry.init, netdataRegistryAfterMs); + + if (typeof netdataCallback === 'function') { + netdataCallback(); + } +}; + +NETDATA.globalReset = function () { + NETDATA.intersectionObserver.globalReset(); + NETDATA.globalSelectionSync.globalReset(); + NETDATA.globalPanAndZoom.globalReset(); + NETDATA.chartRegistry.globalReset(); + NETDATA.commonMin.globalReset(); + NETDATA.commonMax.globalReset(); + NETDATA.commonColors.globalReset(); + NETDATA.unitsConversion.globalReset(); + NETDATA.options.targets = []; + NETDATA.parseDom(); + NETDATA.unpause(); +}; + +// Registry of netdata hosts + +NETDATA.alarms = { + onclick: null, // the callback to handle the click - it will be called with the alarm log entry + chart_div_offset: -50, // give that space above the chart when scrolling to it + chart_div_id_prefix: 'chart_', // the chart DIV IDs have this prefix (they should be NETDATA.name2id(chart.id)) + chart_div_animation_duration: 0,// the duration of the animation while scrolling to a chart + + ms_penalty: 0, // the time penalty of the next alarm + ms_between_notifications: 500, // firefox moves the alarms off-screen (above, outside the top of the screen) + // if alarms are shown faster than: one per 500ms + + update_every: 10000, // the time in ms between alarm checks + + notifications: false, // when true, the browser supports notifications (may not be granted though) + last_notification_id: 0, // the id of the last alarm_log we have raised an alarm for + first_notification_id: 0, // the id of the first alarm_log entry for this session + // this is used to prevent CLEAR notifications for past events + // notifications_shown: [], + + server: null, // the server to connect to for fetching alarms + current: null, // the list of raised alarms - updated in the background + + // a callback function to call every time the list of raised alarms is refreshed + callback: (typeof netdataAlarmsActiveCallback === 'function') ? netdataAlarmsActiveCallback : null, + + // a callback function to call every time a notification is shown + // the return value is used to decide if the notification will be shown + notificationCallback: (typeof netdataAlarmsNotifCallback === 'function') ? netdataAlarmsNotifCallback : null, + + recipients: null, // the list (array) of recipients to show alarms for, or null + + recipientMatches: function (to_string, wanted_array) { + if (typeof wanted_array === 'undefined' || wanted_array === null || Array.isArray(wanted_array) === false) { + return true; + } + + let r = ' ' + to_string.toString() + ' '; + let len = wanted_array.length; + while (len--) { + if (r.indexOf(' ' + wanted_array[len] + ' ') >= 0) { + return true; + } + } + + return false; + }, + + activeForRecipients: function () { + let active = {}; + let data = NETDATA.alarms.current; + + if (typeof data === 'undefined' || data === null) { + return active; + } + + for (let x in data.alarms) { + if (!data.alarms.hasOwnProperty(x)) { + continue; + } + + let alarm = data.alarms[x]; + if ((alarm.status === 'WARNING' || alarm.status === 'CRITICAL') && NETDATA.alarms.recipientMatches(alarm.recipient, NETDATA.alarms.recipients)) { + active[x] = alarm; + } + } + + return active; + }, + + notify: function (entry) { + // console.log('alarm ' + entry.unique_id); + + if (entry.updated) { + // console.log('alarm ' + entry.unique_id + ' has been updated by another alarm'); + return; + } + + let value_string = entry.value_string; + + if (NETDATA.alarms.current !== null) { + // get the current value_string + let t = NETDATA.alarms.current.alarms[entry.chart + '.' + entry.name]; + if (typeof t !== 'undefined' && entry.status === t.status && typeof t.value_string !== 'undefined') { + value_string = t.value_string; + } + } + + let name = entry.name.replace(/_/g, ' '); + let status = entry.status.toLowerCase(); + let title = name + ' = ' + value_string.toString(); + let tag = entry.alarm_id; + let icon = 'images/banner-icon-144x144.png'; + let interaction = false; + let data = entry; + let show = true; + + // console.log('alarm ' + entry.unique_id + ' ' + entry.chart + '.' + entry.name + ' is ' + entry.status); + + switch (entry.status) { + case 'REMOVED': + show = false; + break; + + case 'UNDEFINED': + return; + + case 'UNINITIALIZED': + return; + + case 'CLEAR': + if (entry.unique_id < NETDATA.alarms.first_notification_id) { + // console.log('alarm ' + entry.unique_id + ' is not current'); + return; + } + if (entry.old_status === 'UNINITIALIZED' || entry.old_status === 'UNDEFINED') { + // console.log('alarm' + entry.unique_id + ' switch to CLEAR from ' + entry.old_status); + return; + } + if (entry.no_clear_notification) { + // console.log('alarm' + entry.unique_id + ' is CLEAR but has no_clear_notification flag'); + return; + } + title = name + ' back to normal (' + value_string.toString() + ')'; + icon = 'images/check-mark-2-128-green.png'; + interaction = false; + break; + + case 'WARNING': + if (entry.old_status === 'CRITICAL') { + status = 'demoted to ' + entry.status.toLowerCase(); + } + + icon = 'images/alert-128-orange.png'; + interaction = false; + break; + + case 'CRITICAL': + if (entry.old_status === 'WARNING') { + status = 'escalated to ' + entry.status.toLowerCase(); + } + + icon = 'images/alert-128-red.png'; + interaction = true; + break; + + default: + console.log('invalid alarm status ' + entry.status); + return; + } + + // filter recipients + if (show) { + show = NETDATA.alarms.recipientMatches(entry.recipient, NETDATA.alarms.recipients); + } + + /* + // cleanup old notifications with the same alarm_id as this one + // it does not seem to work on any web browser - so notifications cannot be removed + + let len = NETDATA.alarms.notifications_shown.length; + while (len--) { + let n = NETDATA.alarms.notifications_shown[len]; + if (n.data.alarm_id === entry.alarm_id) { + console.log('removing old alarm ' + n.data.unique_id); + + // close the notification + n.close.bind(n); + + // remove it from the array + NETDATA.alarms.notifications_shown.splice(len, 1); + len = NETDATA.alarms.notifications_shown.length; + } + } + */ + + if (show) { + if (typeof NETDATA.alarms.notificationCallback === 'function') { + show = NETDATA.alarms.notificationCallback(entry); + } + + if (show) { + setTimeout(function () { + // show this notification + // console.log('new notification: ' + title); + let n = new Notification(title, { + body: entry.hostname + ' - ' + entry.chart + ' (' + entry.family + ') - ' + status + ': ' + entry.info, + tag: tag, + requireInteraction: interaction, + icon: NETDATA.serverStatic + icon, + data: data + }); + + n.onclick = function (event) { + event.preventDefault(); + NETDATA.alarms.onclick(event.target.data); + }; + + // console.log(n); + // NETDATA.alarms.notifications_shown.push(n); + // console.log(entry); + }, NETDATA.alarms.ms_penalty); + + NETDATA.alarms.ms_penalty += NETDATA.alarms.ms_between_notifications; + } + } + }, + + scrollToChart: function (chart_id) { + if (typeof chart_id === 'string') { + let offset = $('#' + NETDATA.alarms.chart_div_id_prefix + NETDATA.name2id(chart_id)).offset(); + if (typeof offset !== 'undefined') { + $('html, body').animate({scrollTop: offset.top + NETDATA.alarms.chart_div_offset}, NETDATA.alarms.chart_div_animation_duration); + return true; + } + } + return false; + }, + + scrollToAlarm: function (alarm) { + if (typeof alarm === 'object') { + let ret = NETDATA.alarms.scrollToChart(alarm.chart); + + if (ret && NETDATA.options.page_is_visible === false) { + window.focus(); + } + // alert('netdata dashboard will now scroll to chart: ' + alarm.chart + '\n\nThis alarm opened to bring the browser window in front of the screen. Click on the dashboard to prevent it from appearing again.'); + } + + }, + + notifyAll: function () { + // console.log('FETCHING ALARM LOG'); + NETDATA.alarms.get_log(NETDATA.alarms.last_notification_id, function (data) { + // console.log('ALARM LOG FETCHED'); + + if (data === null || typeof data !== 'object') { + console.log('invalid alarms log response'); + return; + } + + if (data.length === 0) { + console.log('received empty alarm log'); + return; + } + + // console.log('received alarm log of ' + data.length + ' entries, from ' + data[data.length - 1].unique_id.toString() + ' to ' + data[0].unique_id.toString()); + + data.sort(function (a, b) { + if (a.unique_id > b.unique_id) { + return -1; + } + if (a.unique_id < b.unique_id) { + return 1; + } + return 0; + }); + + NETDATA.alarms.ms_penalty = 0; + + let len = data.length; + while (len--) { + if (data[len].unique_id > NETDATA.alarms.last_notification_id) { + NETDATA.alarms.notify(data[len]); + } + //else + // console.log('ignoring alarm (older) with id ' + data[len].unique_id.toString()); + } + + NETDATA.alarms.last_notification_id = data[0].unique_id; + + if (typeof netdataAlarmsRemember === 'undefined' || netdataAlarmsRemember) { + NETDATA.localStorageSet('last_notification_id', NETDATA.alarms.last_notification_id, null); + } + // console.log('last notification id = ' + NETDATA.alarms.last_notification_id); + }) + }, + + check_notifications: function () { + // returns true if we should fire 1+ notifications + + if (NETDATA.alarms.notifications !== true) { + // console.log('web notifications are not available'); + return false; + } + + if (Notification.permission !== 'granted') { + // console.log('web notifications are not granted'); + return false; + } + + if (typeof NETDATA.alarms.current !== 'undefined' && typeof NETDATA.alarms.current.alarms === 'object') { + // console.log('can do alarms: old id = ' + NETDATA.alarms.last_notification_id + ' new id = ' + NETDATA.alarms.current.latest_alarm_log_unique_id); + + if (NETDATA.alarms.current.latest_alarm_log_unique_id > NETDATA.alarms.last_notification_id) { + // console.log('new alarms detected'); + return true; + } + //else console.log('no new alarms'); + } + // else console.log('cannot process alarms'); + + return false; + }, + + get: function (what, callback) { + $.ajax({ + url: NETDATA.alarms.server + '/api/v1/alarms?' + what.toString(), + async: true, + cache: false, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/alarms', data /*, '.*\.(calc|calc_parsed|warn|warn_parsed|crit|crit_parsed)$' */); + + if (NETDATA.alarms.first_notification_id === 0 && typeof data.latest_alarm_log_unique_id === 'number') { + NETDATA.alarms.first_notification_id = data.latest_alarm_log_unique_id; + } + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + NETDATA.error(415, NETDATA.alarms.server); + + if (typeof callback === 'function') { + return callback(null); + } + }); + }, + + update_forever: function () { + if (netdataShowAlarms !== true || netdataSnapshotData !== null) { + return; + } + + NETDATA.alarms.get('active', function (data) { + if (data !== null) { + NETDATA.alarms.current = data; + + if (NETDATA.alarms.check_notifications()) { + NETDATA.alarms.notifyAll(); + } + + if (typeof NETDATA.alarms.callback === 'function') { + NETDATA.alarms.callback(data); + } + + // Health monitoring is disabled on this netdata + if (data.status === false) { + return; + } + } + + setTimeout(NETDATA.alarms.update_forever, NETDATA.alarms.update_every); + }); + }, + + get_log: function (last_id, callback) { + // console.log('fetching all log after ' + last_id.toString()); + $.ajax({ + url: NETDATA.alarms.server + '/api/v1/alarm_log?after=' + last_id.toString(), + async: true, + cache: false, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/alarm_log', data); + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + NETDATA.error(416, NETDATA.alarms.server); + + if (typeof callback === 'function') { + return callback(null); + } + }); + }, + + init: function () { + NETDATA.alarms.server = NETDATA.fixHost(NETDATA.serverDefault); + + if (typeof netdataAlarmsRemember === 'undefined' || netdataAlarmsRemember) { + NETDATA.alarms.last_notification_id = + NETDATA.localStorageGet('last_notification_id', NETDATA.alarms.last_notification_id, null); + } + + if (NETDATA.alarms.onclick === null) { + NETDATA.alarms.onclick = NETDATA.alarms.scrollToAlarm; + } + + if (typeof netdataAlarmsRecipients !== 'undefined' && Array.isArray(netdataAlarmsRecipients)) { + NETDATA.alarms.recipients = netdataAlarmsRecipients; + } + + if (netdataShowAlarms) { + NETDATA.alarms.update_forever(); + + if ('Notification' in window) { + // console.log('notifications available'); + NETDATA.alarms.notifications = true; + + if (Notification.permission === 'default') { + Notification.requestPermission(); + } + } + } + } +}; + +// Registry of netdata hosts + +NETDATA.registry = { + server: null, // the netdata registry server + isCloudEnabled: false,// is netdata.cloud functionality enabled? + cloudBaseURL: null, // the netdata cloud base url + person_guid: null, // the unique ID of this browser / user + machine_guid: null, // the unique ID the netdata server that served dashboard.js + hostname: 'unknown', // 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, + anonymous_statistics_checked: false, + MASKED_DATA: "***", + + isUsingGlobalRegistry: function() { + return NETDATA.registry.server == "https://registry.my-netdata.io"; + }, + + isRegistryEnabled: function() { + return !(NETDATA.registry.isUsingGlobalRegistry() || isSignedIn()) + }, + + parsePersonUrls: function (person_urls) { + NETDATA.registry.person_urls = person_urls; + + if (person_urls) { + NETDATA.registry.machines = {}; + NETDATA.registry.machines_array = []; + + let apu = person_urls; + let 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()); + + let obj = { + guid: apu[i][0], + url: apu[i][1], + last_t: apu[i][2], + accesses: apu[i][3], + name: apu[i][4], + alternate_urls: [] + }; + 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()); + + let 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 (netdataRegistry !== true) { + return; + } + + NETDATA.registry.hello(NETDATA.serverDefault, function (data) { + if (data) { + NETDATA.registry.server = data.registry; + if (data.cloud_base_url !== "") { + NETDATA.registry.isCloudEnabled = true; + NETDATA.registry.cloudBaseURL = data.cloud_base_url; + } else { + NETDATA.registry.isCloudEnabled = false; + NETDATA.registry.cloudBaseURL = ""; + } + NETDATA.registry.machine_guid = data.machine_guid; + NETDATA.registry.hostname = data.hostname; + if (!NETDATA.registry.anonymous_statistics_checked) { + NETDATA.registry.anonymous_statistics_checked=true; + if (data.anonymous_statistics) { + (function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start': + new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0], + j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=false;j.src= + 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); + })(window,document,'script','dataLayer','GTM-N6CBMJD'); + dataLayer.push({"anonymous_statistics" : "true", "machine_guid" : data.machine_guid}); + } + } + NETDATA.registry.access(2, function (person_urls) { + NETDATA.registry.parsePersonUrls(person_urls); + }); + } + }); + }, + + hello: function (host, callback) { + host = NETDATA.fixHost(host); + + // 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, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkOptional('/api/v1/registry?action=hello', data); + + if (typeof data.status !== 'string' || data.status !== 'ok') { + NETDATA.error(408, host + ' response: ' + JSON.stringify(data)); + data = null; + } + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + NETDATA.error(407, host); + + if (typeof callback === 'function') { + return callback(null); + } + }); + }, + + access: function (max_redirects, callback) { + let name = NETDATA.registry.hostname; + let url = NETDATA.serverDefault; + + console.log("ACCESS", name, url); + + // 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(name) + '&url=' + encodeURIComponent(url), // + '&visible_url=' + encodeURIComponent(document.location), + async: true, + cache: false, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkAlways('/api/v1/registry?action=access', data); + + let 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') { + return callback(null); + } + } + } else { + if (typeof data.person_guid === 'string') { + NETDATA.registry.person_guid = data.person_guid; + } + + if (typeof callback === 'function') { + const urls = data.urls.filter((u) => u[1] !== NETDATA.registry.MASKED_DATA); + return callback(urls); + } + } + }) + .fail(function () { + NETDATA.error(410, NETDATA.registry.server); + + if (typeof callback === 'function') { + return 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, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkAlways('/api/v1/registry?action=delete', 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') { + return callback(data); + } + }) + .fail(function () { + NETDATA.error(412, NETDATA.registry.server); + + if (typeof callback === 'function') { + return callback(null); + } + }); + }, + + search: function (machine_guid, callback) { + // SEARCH for the URLs of a machine: + $.ajax({ + url: NETDATA.registry.server + '/api/v1/registry?action=search&machine=' + NETDATA.registry.machine_guid + '&name=' + encodeURIComponent(NETDATA.registry.hostname) + '&url=' + encodeURIComponent(NETDATA.serverDefault) + '&for=' + machine_guid, + async: true, + cache: false, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkAlways('/api/v1/registry?action=search', data); + + if (typeof data.status !== 'string' || data.status !== 'ok') { + NETDATA.error(417, NETDATA.registry.server + ' responded with: ' + JSON.stringify(data)); + data = null; + } + + if (typeof callback === 'function') { + return callback(data); + } + }) + .fail(function () { + NETDATA.error(418, NETDATA.registry.server); + + if (typeof callback === 'function') { + return 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, + headers: { + 'Cache-Control': 'no-cache, no-store', + 'Pragma': 'no-cache' + }, + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function (data) { + data = NETDATA.xss.checkAlways('/api/v1/registry?action=switch', 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') { + return callback(data); + } + }) + .fail(function () { + NETDATA.error(414, NETDATA.registry.server); + + if (typeof callback === 'function') { + return callback(null); + } + }); + } +}; + +// Load required JS libraries and CSS + +NETDATA.requiredJs = [ + { + url: NETDATA.serverStatic + 'lib/bootstrap-3.3.7.min.js', + async: false, + isAlreadyLoaded: function () { + // check if bootstrap is loaded + if (typeof $().emulateTransitionEnd === 'function') { + return true; + } else { + return typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap; + } + } + }, + { + url: NETDATA.serverStatic + 'lib/fontawesome-all-5.0.1.min.js', + async: true, + isAlreadyLoaded: function () { + return typeof netdataNoFontAwesome !== 'undefined' && netdataNoFontAwesome; + } + }, + { + url: NETDATA.serverStatic + 'lib/perfect-scrollbar-0.6.15.min.js', + isAlreadyLoaded: function () { + return false; + } + } +]; + +NETDATA.requiredCSS = [ + { + url: NETDATA.themes.current.bootstrap_css, + isAlreadyLoaded: function () { + return typeof netdataNoBootstrap !== 'undefined' && netdataNoBootstrap; + } + }, + { + url: NETDATA.themes.current.dashboard_css, + isAlreadyLoaded: function () { + return false; + } + } +]; + +NETDATA.loadedRequiredJs = 0; +NETDATA.loadRequiredJs = function (index, callback) { + if (index >= NETDATA.requiredJs.length) { + if (typeof callback === 'function') { + return callback(); + } + return; + } + + if (NETDATA.requiredJs[index].isAlreadyLoaded()) { + NETDATA.loadedRequiredJs++; + NETDATA.loadRequiredJs(++index, callback); + return; + } + + if (NETDATA.options.debug.main_loop) { + console.log('loading ' + NETDATA.requiredJs[index].url); + } + + let async = true; + if (typeof NETDATA.requiredJs[index].async !== 'undefined' && NETDATA.requiredJs[index].async === false) { + async = false; + } + + $.ajax({ + url: NETDATA.requiredJs[index].url, + cache: true, + dataType: "script", + xhrFields: {withCredentials: true} // required for the cookie + }) + .done(function () { + if (NETDATA.options.debug.main_loop) { + console.log('loaded ' + NETDATA.requiredJs[index].url); + } + }) + .fail(function () { + alert('Cannot load required JS library: ' + NETDATA.requiredJs[index].url); + }) + .always(function () { + NETDATA.loadedRequiredJs++; + + // if (async === false) + if (!async) { + NETDATA.loadRequiredJs(++index, callback); + } + }); + + // if (async === true) + if (async) { + NETDATA.loadRequiredJs(++index, callback); + } +}; + +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) { + console.log('loading ' + NETDATA.requiredCSS[index].url); + } + + NETDATA._loadCSS(NETDATA.requiredCSS[index].url); + NETDATA.loadRequiredCSS(++index); +}; + +// Boot it! + +if (typeof netdataPrepCallback === 'function') { + netdataPrepCallback(); +} + +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) { + console.log('starting chart refresh thread'); + } + + NETDATA.start(); + } + }); +}); +})(window, document, (typeof jQuery === 'function')?jQuery:undefined); diff --git a/web/gui/v1/dashboard.slate.css b/web/gui/v1/dashboard.slate.css new file mode 100644 index 00000000..c4e5c65c --- /dev/null +++ b/web/gui/v1/dashboard.slate.css @@ -0,0 +1,803 @@ +/* SPDX-License-Identifier: GPL-3.0-or-later */ +:root { + --color-main: #FFFFFF; + --color-primary: #00ab44; + --color-border: #878b90; +} + +html, +body { + /*font-family: Calibri,"Segoe UI","Helvetica Neue",Helvetica,Arial,sans-serif;*/ + font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; + font-style: normal; + font-variant: normal; + color: #878b90; +} + +/* fixes for default slate theme */ +code { + color: #bbb; /*#c7254e;*/ + background-color: #555; /* #f9f2f4; */ +} + +.dashboard-sidebar .nav > .active > a, +.dashboard-sidebar .nav > .active:hover > a, +.dashboard-sidebar .nav > .active:focus > a { + color: #765d9c; + 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 { + /* 55 for legend-right */ + margin-left: 35px; +} + +.netdata-chart-row { + width: 100%; + text-align: center; + display: flex; + display: -webkit-flex; + display: -moz-flex; + align-items: flex-end; + -moz-align-items: flex-end; + -webkit-align-items: flex-end; + justify-content: center; + -moz--webkit-justify-content: center; + -moz-justify-content: center; + padding-top: 10px; +} + +.netdata-container { + display: inline-block; + overflow: hidden; + + transform: translate3d(0,0,0); + + /* required for child elements to have absolute position */ + position: relative; + + /* width and height is given per chart with data-width and data-height */ +} + +.netdata-container-gauge { + display: inline-block; + overflow: hidden; + + transform: translate3d(0,0,0); + + /* required for child elements to have absolute position */ + position: relative; + + /* width and height is given per chart with data-width and data-height */ +} + +.netdata-container-gauge:after { + padding-top: 60%; + display: block; + content: ''; +} + +.netdata-container-easypiechart { + display: inline-block; + overflow: hidden; + + transform: translate3d(0,0,0); + + /* required for child elements to have absolute position */ + position: relative; + + /* width and height is given per chart with data-width and data-height */ +} + +.netdata-container-easypiechart:after { + padding-top: 100%; + display: block; + content: ''; +} + +.netdata-aspect { + position: relative; + width: 100%; + padding: 0px; + margin: 0px; +} + +.netdata-container-with-legend { + display: inline-block; + overflow: hidden; + + transform: translate3d(0,0,0); + + /* fix minimum scrollbar issue in firefox */ + min-height: 99px; + + /* required for child elements to have absolute position */ + position: relative; + + /* width and height is given per chart with data-width and data-height */ +} + +.netdata-container-with-legend.netdata-container-with-legend--bottom { + display: flex; + flex-direction: column; +} + +.netdata-legend-resize-handler { + display: block; + position: absolute; + bottom: 0px; + right: 0px; + height: 15px; + width: 20px; + background-color: #272b30; + font-size: 15px; + vertical-align: middle; + line-height: 15px; + cursor: ns-resize; + color: var(--color-selected, #373b40); + text-align: center; + overflow: hidden; + padding: 0px; + margin: 0px; +} + +.netdata-legend-toolbox { + display: block; + position: absolute; + bottom: 0px; + right: 0px; + height: 15px; + width: 110px; + font-size: 12px; + vertical-align: middle; + line-height: 15px; + color: #373b40; + text-align: center; + overflow: hidden; + padding: 0px; + margin: 0px; + + /* prevent text selection after double click */ + -webkit-user-select: none; /* webkit (safari, chrome) browsers */ + -moz-user-select: none; /* mozilla browsers */ + -khtml-user-select: none; /* webkit (konqueror) browsers */ + -ms-user-select: none; /* IE10+ */ +} + +.netdata-legend-toolbox-button { + display: inline-block; + position: relative; + height: 15px; + width: 18px; + background-color: #272b30; + font-size: 12px; + vertical-align: middle; + line-height: 15px; + color: var(--color-selected, #373b40); + text-align: center; + overflow: hidden; + padding: 0px; + margin: 0px; + cursor: pointer; + + /* prevent text selection after double click */ + -webkit-user-select: none; /* webkit (safari, chrome) browsers */ + -moz-user-select: none; /* mozilla browsers */ + -khtml-user-select: none; /* webkit (konqueror) browsers */ + -ms-user-select: none; /* IE10+ */ +} + +.netdata-message { + display: inline-block; + position: absolute; + top: 0; + left: 0; + right: 0; + bottom: 0; + text-align: left; + vertical-align: top; + font-weight: bold; + font-size: x-small; + overflow: hidden; + background: inherit; + z-index: 0; +} + +.netdata-message.hidden { + display: none; +} + +.netdata-message.icon { + color: #2f3338; + text-align: center; + vertical-align: middle; +} + +.netdata-chart-legend { + position: absolute; /* within .netdata-container */ + top: 0; + right: 0; + overflow: hidden; + text-overflow: ellipsis; + line-height: 14px; + display: block; + width: 140px; /* --legend-width */ + height: calc(100% - 15px); /* 10px for the resize handler and 5px for the top margin */ + font-size: 10px; + margin-top: 5px; + text-align: left; + /* width and height is calculated (depends on the appearance of the legend) */ +} + +.netdata-legend-title-date { + font-size: 10px; + font-weight: normal; + margin-top: 0px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.netdata-legend-title-time { + font-size: 11px; + font-weight: bold; + margin-top: 0px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.netdata-legend-title-units { + position: absolute; + right: 10px; + float: right; + font-size: 11px; + vertical-align: top; + font-weight: normal; + margin-top: 0px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.netdata-legend-series { + position: absolute; + width: 140px; /* legend-width */ + height: calc(100% - 50px); + overflow: hidden; + text-overflow: ellipsis; + line-height: 14.5px; /* line spacing at the legend */ + display: block; + font-size: 10px; + margin-top: 0px; +} + +.netdata-legend-name-table-line { + display: inline-block; + width: 13px; + height: 4px; + border-width: 0px; + border-bottom-width: 2px; + border-bottom-style: solid; + border-bottom-color: #272b30; +} + +.netdata-legend-name-table-area { + display: inline-block; + width: 13px; + height: 5px; + border-width: 1px; + border-top-width: 1px; + border-top-style: solid; + border-top-color: inherit; +} + +.netdata-legend-name-table-stacked { + display: inline-block; + width: 13px; + height: 5px; + border-width: 1px; + border-top-width: 1px; + border-top-style: solid; + border-top-color: inherit; +} + +.netdata-legend-name-tr { +} + +.netdata-legend-name-td { +} + +.netdata-legend-name { + text-align: left; + font-size: 11px; /* legend: dimension name size */ + font-weight: bold; + vertical-align: bottom; + margin-top: 0px; + z-index: 9; + padding: 0px; + width: 80px !important; + max-width: 80px !important; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; + display: inline-block; + cursor: pointer; + -webkit-print-color-adjust: exact; +} + +.netdata-legend-value { + /*margin-left: 14px;*/ + position: absolute; + right: 10px; + float: right; + text-align: right; + font-size: 11px; /* legend: dimension value size */ + font-weight: bold; + vertical-align: bottom; + background-color: #272b30; + margin-top: 0px; + z-index: 10; + padding: 0px; + padding-left: 15px; + cursor: pointer; + /* -webkit-font-smoothing: none; */ +} + +.netdata-legend-value, .netdata-legend-name { + /* prevent highlight when shift-clicking */ + -webkit-user-select: none; + -ms-user-select: none; + -moz-user-select: none; + user-select: none; +} + +/* eslint recommends adding tabIndex for a11y, but the outline is showing on click */ +.netdata-legend-name:focus, .netdata-legend-value:focus { + outline: none; +} + +.netdata-legend-name.not-selected { + font-weight: normal; + opacity: 0.3; +} + +.netdata-chart { + position: absolute; /* within .netdata-container */ + top: 0; /* within .netdata-container */ + left: 0; /* within .netdata-container */ + display: inline-block; + overflow: hidden; + width: 100%; + height: 100%; + z-index: 5; + + /* width and height is calculated (depends on the appearance of the legend) */ +} + +.netdata-chart-with-legend-right { + position: absolute; /* within .netdata-container */ + top: 0; /* within .netdata-container */ + left: 0; /* within .netdata-container */ + display: block; + overflow: hidden; + margin-right: 140px; /* --legend-width */ + width: calc(100% - 140px); /* --legend-width */ + height: 100%; + z-index: 5; + flex-grow: 1; + + /* width and height is calculated (depends on the appearance of the legend) */ +} + +.netdata-chart-with-legend-bottom { + display: block; + overflow: hidden; + flex-grow: 1; +} + +.netdata-peity-chart { + +} + +.netdata-sparkline-chart { + +} + +.netdata-dygraph-chart { + +} + +.netdata-morris-chart { + +} + +.netdata-google-chart { + +} + +.dygraph-ylabel { +} + +.dygraph-axis-label-x { + overflow-x: hidden; +} + +.dygraph-axis-label { + color: #6c7075; +} + +.dygraph-label-rotate-left { + text-align: center; + /* See http://caniuse.com/#feat=transforms2d */ + transform: rotate(90deg); + -webkit-transform: rotate(90deg); + -moz-transform: rotate(90deg); + -o-transform: rotate(90deg); + -ms-transform: rotate(90deg); +} + +/* For y2-axis label */ +.dygraph-label-rotate-right { + text-align: center; + /* See http://caniuse.com/#feat=transforms2d */ + transform: rotate(-90deg); + -webkit-transform: rotate(-90deg); + -moz-transform: rotate(-90deg); + -o-transform: rotate(-90deg); + -ms-transform: rotate(-90deg); +} + +.dygraph-title { + /* 56 for legend-right */ + text-indent: 36px; + text-align: left; + position: absolute; + left: 0px; + top: 4px; + font-size: 11px; + font-weight: bold; + text-overflow: ellipsis; + overflow: hidden; + white-space: nowrap; +} + +/* fix for sparkline tooltip under bootstrap */ +.jqstooltip { + width: auto !important; + height: auto !important; +} + +.easyPieChart { + position: relative; + text-align: center; +} + +.easyPieChart canvas { + position: absolute; + top: 0; + left: 0; +} + +.easyPieChartLabel { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 100%; + text-align: center; + color: var(--color-main); + font-weight: normal; + text-shadow: #272b30 0px 0px 1px; + /* -webkit-font-smoothing: none; */ +} + +.easyPieChartTitle { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 64%; + margin-left: 18% !important; + text-align: center; + color: var(--color-border,#676b70); + font-weight: bold; +} + +.easyPieChartUnits { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 60%; + margin-left: 20% !important; + text-align: center; + color:var(--color-border,#676b70); + font-weight: normal; +} + +.gaugeChart { + position: relative; + text-align: center; +} + +.gaugeChart canvas { + position: absolute; + top: 0; + left: 0; + bottom: 0; + right: 0; + z-index: 0; +} + +.gaugeChartLabel { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 100%; + text-align: center; + color: var(--color-main); + font-weight: bold; + z-index: 1; + text-shadow: #272b30 0px 0px 1px; + /* text-shadow: #CCC 1px 1px 0px, #CCC -1px -1px 0px, #CCC 1px -1px 0px, #CCC -1px 1px 0px; */ + /* -webkit-text-stroke: 1px #777; */ + /* -webkit-font-smoothing: none; */ +} + +.gaugeChartTitle { + display: inline-block; + position: absolute; + float: left; + left: 0; + width: 100%; + text-align: center; + color: var(--color-border, #676b70); + font-weight: bold; +} + +.gaugeChartUnits { + display: inline-block; + position: absolute; + float: left; + left: 0; + bottom: 0; + width: 100%; + text-align: left; + margin-left: 5%; + color: var(--color-border,#676b70); + font-weight: normal; +} + +.gaugeChartMin { + display: inline-block; + position: absolute; + float: left; + left: 0; + bottom: 8%; + width: 92%; + margin-left: 8%; + text-align: left; + color: var(--color-main); + font-weight: normal; +} + +.gaugeChartMax { + display: inline-block; + position: absolute; + float: left; + left: 0; + bottom: 8%; + width: 95%; + margin-right: 5%; + text-align: right; + color: var(--color-main); + font-weight: normal; +} + +.popover-title { + font-weight: bold; + font-size: 12px; +} + +.popover-content { + font-size: 11px; +} + +/* ---------------------------------------------------------------------------- + perfect-scrollbar settings + */ + +.ps-container { + -ms-touch-action: auto; + touch-action: auto; + overflow: hidden !important; + -ms-overflow-style: none; +} + +@supports (-ms-overflow-style: none) { + .ps-container { + overflow: auto !important; + } +} + +@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) { + .ps-container { + overflow: auto !important; + } +} + +.ps-container.ps-active-x > .ps-scrollbar-x-rail, +.ps-container.ps-active-y > .ps-scrollbar-y-rail { + display: block; + background-color: transparent; +} + +.ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { + background-color: transparent; /* background color when dragged away */ + opacity: 0.9; +} + +.ps-container.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { + background-color: #aaa; /* scrollbar color when dragged away */ + height: 5px; +} + +.ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { + background-color: transparent; /* background color when dragged away */ + opacity: 0.9; +} + +.ps-container.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { + background-color: #aaa; /* scrollbar color when dragged away */ + width: 5px; +} + +.ps-container > .ps-scrollbar-x-rail { + display: none; + position: absolute; + /* please don't change 'position' */ + opacity: 0.2; /* the opacity when not on hover of the content */ + -webkit-transition: background-color .2s linear, opacity .2s linear; + -o-transition: background-color .2s linear, opacity .2s linear; + -moz-transition: background-color .2s linear, opacity .2s linear; + transition: background-color .2s linear, opacity .2s linear; + bottom: 0px; + /* there must be 'bottom' for ps-scrollbar-x-rail */ + height: 15px; +} + +.ps-container > .ps-scrollbar-x-rail > .ps-scrollbar-x { + position: absolute; + /* please don't change 'position' */ + background-color: #666; /* #aaa; the color on content hover */ + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + -o-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + -moz-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + bottom: 2px; + /* there must be 'bottom' for ps-scrollbar-x */ + height: 5px; /* the width of the scrollbar */ +} + +.ps-container > .ps-scrollbar-x-rail:hover > .ps-scrollbar-x, .ps-container > .ps-scrollbar-x-rail:active > .ps-scrollbar-x { + height: 5px; +} + +.ps-container > .ps-scrollbar-y-rail { + display: none; + position: absolute; + /* please don't change 'position' */ + opacity: 0.2; /* the opacity when not on hover of the content */ + -webkit-transition: background-color .2s linear, opacity .2s linear; + -o-transition: background-color .2s linear, opacity .2s linear; + -moz-transition: background-color .2s linear, opacity .2s linear; + transition: background-color .2s linear, opacity .2s linear; + right: 0; + /* there must be 'right' for ps-scrollbar-y-rail */ + width: 15px; +} + +.ps-container > .ps-scrollbar-y-rail > .ps-scrollbar-y { + position: absolute; + /* please don't change 'position' */ + background-color: #666; /* #aaa; the color on content hover */ + -webkit-border-radius: 6px; + -moz-border-radius: 6px; + border-radius: 6px; + -webkit-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, -webkit-border-radius .2s ease-in-out; + -o-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + -moz-transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out; + transition: background-color .2s linear, height .2s linear, width .2s ease-in-out, border-radius .2s ease-in-out, -webkit-border-radius .2s ease-in-out, -moz-border-radius .2s ease-in-out; + right: 2px; + /* there must be 'right' for ps-scrollbar-y */ + width: 5px; /* the width of the scrollbar */ +} + +.ps-container > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y, .ps-container > .ps-scrollbar-y-rail:active > .ps-scrollbar-y { + width: 5px; +} + +.ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail { + background-color: transparent; /* background color when dragged */ + opacity: 0.9; +} + +.ps-container:hover.ps-in-scrolling.ps-x > .ps-scrollbar-x-rail > .ps-scrollbar-x { + background-color: #bbb; /* scrollbar color when dragged */ + height: 5px; +} + +.ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail { + background-color: transparent; /* background color when dragged */ + opacity: 0.9; +} + +.ps-container:hover.ps-in-scrolling.ps-y > .ps-scrollbar-y-rail > .ps-scrollbar-y { + background-color: #bbb; /* scrollbar color when dragged */ + width: 5px; +} + +.ps-container:hover > .ps-scrollbar-x-rail, +.ps-container:hover > .ps-scrollbar-y-rail { + opacity: 0.6; +} + +.ps-container:hover > .ps-scrollbar-x-rail:hover { + background-color: transparent; /* the background color on hover of the scrollbar */ + opacity: 0.9; +} + +.ps-container:hover > .ps-scrollbar-x-rail:hover > .ps-scrollbar-x { + background-color: #999; /* scrollbar color on hover */ +} + +.ps-container:hover > .ps-scrollbar-y-rail:hover { + background-color: transparent; /* the background color on hover of the scrollbar */ + opacity: 0.9; +} + +.ps-container:hover > .ps-scrollbar-y-rail:hover > .ps-scrollbar-y { + background-color: #999; /* scrollbar color on hover */ +} + +.dygraph__history-tip { + position: absolute; + top: 50%; + transform: translateY(-50%); + display: none; /* overridden in js */ + margin-right: 25px; + direction: rtl; + overflow: hidden; + pointer-events: none; +} + +.dygraph__history-tip-content { + display: inline-block; + white-space: nowrap; + direction: ltr; + pointer-events: auto; +} diff --git a/web/gui/v1/demo.html b/web/gui/v1/demo.html new file mode 100644 index 00000000..642742a5 --- /dev/null +++ b/web/gui/v1/demo.html @@ -0,0 +1,51 @@ + + + + + Netdata Dashboard + + + + + + + + + + + + + + + + + + + + + +
    +
    +
    +
    +
    + + diff --git a/web/gui/v1/demo2.html b/web/gui/v1/demo2.html new file mode 100644 index 00000000..9a77fdde --- /dev/null +++ b/web/gui/v1/demo2.html @@ -0,0 +1,143 @@ + + + + + Netdata Dashboard + + + + + + + + + + + + + + + + + + + + + + +
    +
    why netdata?
    +
    +
    These charts visualize the same data...
    + + + + + + +
    +
    + +
    +
    I can trace an issue like this
    +
    +
    +
    +
    +
    Can you trace an issue like these?
     
    +
    +
    +
    +
    +
    + +
    +
    I can trace an issue like this
    +
    +
    +
    +
    +
    Can you trace an issue like these?
     
    +
    +
    +
    +
    +
    +
    Hover on the chart below, to see the selected value on the charts above!
    +
    +
    + + diff --git a/web/gui/v1/demosites.html b/web/gui/v1/demosites.html new file mode 100644 index 00000000..59435c2b --- /dev/null +++ b/web/gui/v1/demosites.html @@ -0,0 +1,1469 @@ + + + + + + + Netdata: Get control of your Linux Servers. Simple. Effective. Awesome. + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +

    Monitor your systems and applications, the right way!

    +

    + Unparalleled insights, in real-time, + of everything happening on your systems and applications, + with stunning, interactive web dashboards + and powerful performance and health alarms. +

    + +
    +
    +
    +

    Enter the world of Netdata!

    +
    +

    1s granularity

    +
    +
    +
    +

    + Per second data collection and visualization, for all metrics! +

    +

    + Netdata zooms into the problems by providing higher resolution information, compared to any other monitoring solution. +

    +
    +
    +

    + The world goes real-time. +
     
    + High resolution metrics are required to effectively monitor and troubleshoot systems and applications, especially on virtual environments. +

    +
    +
    +
    + +
    + +
    +
    +
    +

    Unlimited metrics

    +
    +
    +
    +

    + Use all the metrics, from all available sources! +

    +

    + Netdata collects all the metrics native console tools do. It has been designed to kill the console for troubleshooting infrastructure slowdowns and outages. +

    +
    +
    +

    + All metrics are important and all should be available when you need them. +
     
    + Filtering out most metrics is like reading a book by skipping most of its pages. +

    +
    +
    +
    + +
    +
    +
    +
    +

    Meaningful presentation

    +
    +
    +
    +

    + Explore all metrics in a meaningful, easy to understand way! +

    +

    + Netdata engineers and experts on our community organize metrics in a meaningful way, so that you can learn and understand them right on the job, while troubleshooting issues of your infrastructure. +

    +
    +
    +

    + Metrics are a lot more than name-value pairs over time. +

    + It is just not practical to require from all users to have a deep understanding of all metrics for monitoring their systems and applications. +

    +
    +
    +
    + +
    + +
    +
    +
    +

    Immediate results

    +
    +
    +
    +

    + Install and use immediately! Get fully functional visualization and alarms, in just a couple of seconds after installation! +

    +

    + Netdata decouples your skills from your monitoring infrastructure. + No matter how skillful or novice you are, Netdata will apply all the community knowledge and expertise to your monitoring infrastructure. +

    +
    +
    +

    + Most of our infrastructure is based on standardized systems and applications. +
     
    + It is a tremendous waste of time and effort, in a global scale, to require from all users to configure their infrastructure dashboards and alarms metric by metric. +

    +
    +
    +
    + +
    + +
    +

    How it works

    +
    +

    + Netdata is a monitoring agent you install on all your systems: +
    + physical servers, virtual servers, containers, IoT. +

    +

    + Netdata is lightweight, designed to permanently run on all systems without disrupting their core function. + By default, it needs just 1% CPU of a single core, a few MB or RAM and no disk I/O at all. +

    +

    + Each Netdata is (by default) autonomous, taking care of all the following. +
    But all your Netdata are integrated into one large distributed application. +

    +
    +
    +

    Collect

    +

    + Netdata automatically detects data collection sources on the host it runs. + It comes with hundreds of plugins for collecting system and application metrics, + including databases, web servers, and commonly used application servers. +

    + Netdata is also a high performance, distributed statsd server, allowing custom + application metrics to be collected and visualized. +

    +
    +

    Check (alarms)

    +

    + Each Netdata spawns a thread that examines the metrics as they get collected, + evaluates pre-configured alarm expressions and triggers alarm notifications. +

    + Netdata comes with hundreds of alarms to detect common system and application issues, + that are automatically attached to the collected metrics, + supporting dozens of alarm notification integrations. +

    +
    +

    Stream

    +

    + Each Netdata can stream its metrics, in real-time, to any other Netdata. + Streaming allows Netdata to be used in ephemeral nodes and containers in auto-scaled environments, + but it also allows building Netdata hierarchies for aggregating the metrics of multiple Netdata nodes. +

    +
    +

    Store

    +

    + Each Netdata has its own internal metrics database. This database is optimized + for minimal memory footprint, and due to its lockless design allows one writer + and multiple readers per metric, concurrently, contributing significantly to + the performance of Netdata. +

    +
    +

    Archive

    +

    + Netdata can archive its metrics to time-series databases (prometheus, graphite, opentsdb, json document dbs, etc) + so that Netdata can be integrated to existing monitoring tool-chains. +

    +
    +

    Visualize

    +

    + The best part of Netdata is its visualization. Low latency, speedy and snazzy. +

    + Netdata dashboards are optimized for visual anomaly detection, a powerful tool to troubleshoot + performance issues. +

    +
    +
    +
    +
    + +
    +   +
    + + +

    netdata live demo sites

    +
    +
    + +
    +
    +
    +
    +
    + Enter London! +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    + Enter Atlanta! +
    + Donated by CDN77.com +
    +
    +
    +
    +
    +
    +
    +
    + Enter California! +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    + Enter Canada! +
    + Donated by DigitalOcean.com +
    +
    +
    +
     
    +
    +
    +
    +
    +
    + Enter Germany! +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    + Enter New York! +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    + Enter Singapore! +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    + Enter India! +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    + Israel +
    +
    +
    + requests/s +
    +
    +
    +
    +
    +
    +
    + Enter Israel! +
    + Donated by octopuscs.com +
    +
    +
    + +
    +
    +
    + EU - Spain +
    +
    +
    + requests/s +
    +
    +
    +
    +
    +
    +
    + Enter Madrid! +
    + Donated by stackscale.com +
    +
    +
    +
    +
    +
    +
    +
    +
    + +
    + Charts are coming from all servers, in parallel. +
    + The servers are not aware of this multi-server dashboard. +
    + +
    +
    +
    + EU - London connected clients +
    +
    +
    +
    +
    +
    + +
    + Each server is not aware of the other servers. +
    + But on this dashboard they are one! (hover on the chart above) +
    + + + +
    +
    + +

    Who uses netdata?

    +
    +
    +

    + Netdata is used by hundreds of thousands of users all over the world. +
     
    + Check our GitHub watchers list. +
    + You will find people working for Amazon, Atos, Baidu, Cisco Systems, Citrix, + Deutsche Telekom, DigitalOcean, Elastic, EPAM Systems, Ericsson, Google, + Groupon, Hortonworks, HP, Huawei, IBM, Microsoft, NewRelic, + Nvidia, Red Hat, SAP, Selectel, TicketMaster, Vimeo, and many more! +

    + + The following figures come from users using the netdata public global registry.
    Counting since May 16th 2016. Actual figures may be a lot higher.
    +
    +
    +
    + netdata unique users +
    +
    +
    +
    +
    +
    +
    +
    +
    + netdata monitored servers +
    +
    +
    +
    +
    +
    +
    +
    +
    + netdata sessions served +
    +
    +
    +
    +
    +
    +

    + + +

    +

    + + netdata can generate auto-refreshing badges, like these: + +
    + + + +
    + These badges auto-refresh every minute. +

    +
    +
    + netdata is featured at the GitHub's state of the Octoverse 2016 +
    + + + +
    +
    + +
    +
    +
    +
    + + + + + + +
    +
    + + + + + + + + + + +
    + + + + + + + diff --git a/web/gui/v1/demosites2.html b/web/gui/v1/demosites2.html new file mode 100644 index 00000000..4b2be5c2 --- /dev/null +++ b/web/gui/v1/demosites2.html @@ -0,0 +1,1112 @@ + + + + + Netdata - Real-time performance monitoring, done right! + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    + +
    + netdata +
    +
    + real-time performance monitoring +
    +
    + scaled out! +
    +
    + pick a netdata demo server +
    +
    + these demo servers show what you will get by installing netdata +
    + +
    +
    + +
    +
    +
    +
    +
    +
     
    + +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    +
     
    + +
    + Donated by CDN77.com +
    +
    +
    +
    +
    +
    +
    +
    +
     
    + +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    +
     
    + +
    + Donated by DigitalOcean.com +
    +
    +
    +
     
    +
    +
    +
    +
    +
    +
     
    + +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    +
     
    + +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    +
     
    + +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    +
    +
    +
    +
     
    + +
    + Donated by DigitalOcean.com +
    +
    +
    +
    +
    + +
    + this page is a custom netdata dashboard +
    +
    + charts are coming from 8 servers, in parallel +
    + the servers are not aware of this multi-server dashboard, +
    + each server is not aware of the other servers, +
    + but on this dashboard they are one! +
    +
    + + hover on a chart below, or drag it to show the past - the others will follow! +
    + double click on a chart to reset them all +
    + +
    + our nginx performance +
    +
    + (we proxy netdata through nginx, on the demo sites) +
    + + + + + +
    +
    +
    +
    + EU - London web requests/s +
    +
    +
    +
    +
    + +
    +
    + US - Atlanta web requests/s +
    +
    +
    +
    +
    + +
    +
    + US - California web requests/s +
    +
    +
    +
    +
    + +
    +
    + Canada web requests/s +
    +
    +
    +
    +
    +
    + +
    +
    +
    + EU - London active connections +
    +
    +
    +
    +
    + +
    +
    + US - Atlanta active connections +
    +
    +
    +
    +
    + +
    +
    + US - California active connections +
    +
    +
    +
    +
    + +
    +
    + Canada active connections +
    +
    +
    +
    +
    +
    +
    + +
    + these charts are draggable and touchable, double click them to reset them +
    + + +
    + bandwidth consumption on the demo sites +
    +
    + Linux QoS is configured by FireQOS +
    + + + + + +
    +
    +
    +
    +
    + +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    + +
    +
    +
    + +
    + +
    +
    + +
    + +
    +
    +
    + +
    +
    +
    +
    +
    +
    + these legends are interactive and the charts are resizable here ^^^ +
    + +
    + DDoS protection performance on the demo sites +
    +
    + iptables SYNPROXY configured by FireHOL +
    + +
    + +
    +
    + EU - London, TCP SYN packets/s received +
    +
    +
    +
    +
    + +
    +
    + US - Atlanta, TCP SYN packets/s received +
    +
    +
    +
    +
    + +
    +
    + US - California, TCP SYN packets/s received +
    +
    +
    +
    +
    + +
    +
    + Canada, TCP SYN packets/s received +
    +
    +
    +
    +
    +
    +
    + did you notice the decimal numbers? +
    netdata interpolates collected values at second boundaries, with nanosecond detail!
    +
    + + +
    + CPU Utilization of the demo sites +
    + +
    +
    +
    +
    + +
    +
    +
    + +
    +
    +
    + +
    +
    +
    +
    +
    + what is using so much CPU? +
    The site iplists.firehol.org is maintained by FireHOL - the CPU is used for comparing security IP Lists.
    +
    + +
    + Netdata performance +
    +
    + netdata monitors users, user groups, applications (process trees) +
    + containers (lxc, docker, etc.) and SNMP devices. +
    + + + + + +
    +
    +
    +
    + EU - London, CPU % of a single core +
    +
    +
    +
    +
    + +
    +
    + US - Atlanta, CPU % of a single core +
    +
    +
    +
    +
    + +
    +
    + US - California, CPU % of a single core +
    +
    +
    +
    +
    + +
    +
    + Toronto, CPU % of a single core +
    +
    +
    +
    +
    + +
    + this utilization is about the whole netdata process tree and the percentage is of a single core! +
    including BASH plugins (it monitors mysql on the demo sites), node.js plugins (it monitors bind9 on the demo sites), etc. +
    and including the chart refreshes for the dashboards of all viewers.
    +
    +
    + +
    +
    +
    + EU - London, API average response time in milliseconds +
    +
    +
    +
    +
    + +
    +
    + US - Atlanta, API average response time in milliseconds +
    +
    +
    +
    +
    + +
    +
    + US - California, API average response time in milliseconds +
    +
    +
    +
    +
    + +
    +
    + Canada, API average response time in milliseconds +
    +
    +
    +
    +
    + +
    + netdata is really fast (the values are milliseconds!) +
    + These values include everything, from the reception of the first byte to the dispatch of the last, including gzip compression. +
    + Values above 2-3ms are usually chart refreshes of charts with several dimensions, charts with very long durations (zoomed out), or file transfers. +
    +
    +
    +
    + +
    + want to know more? +
    + jump to the netdata page at github +
    + it needs just 3 mins to be installed on your servers! +
    +   +
    +
    + + + diff --git a/web/gui/v1/favicon.ico b/web/gui/v1/favicon.ico new file mode 100644 index 00000000..064032ae Binary files /dev/null and b/web/gui/v1/favicon.ico differ diff --git a/web/gui/v1/fonts/glyphicons-halflings-regular.eot b/web/gui/v1/fonts/glyphicons-halflings-regular.eot new file mode 100644 index 00000000..b93a4953 Binary files /dev/null and b/web/gui/v1/fonts/glyphicons-halflings-regular.eot differ diff --git a/web/gui/v1/fonts/glyphicons-halflings-regular.svg b/web/gui/v1/fonts/glyphicons-halflings-regular.svg new file mode 100644 index 00000000..2a4aabac --- /dev/null +++ b/web/gui/v1/fonts/glyphicons-halflings-regular.svg @@ -0,0 +1,289 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/gui/v1/fonts/glyphicons-halflings-regular.ttf b/web/gui/v1/fonts/glyphicons-halflings-regular.ttf new file mode 100644 index 00000000..1413fc60 Binary files /dev/null and b/web/gui/v1/fonts/glyphicons-halflings-regular.ttf differ diff --git a/web/gui/v1/fonts/glyphicons-halflings-regular.woff b/web/gui/v1/fonts/glyphicons-halflings-regular.woff new file mode 100644 index 00000000..9e612858 Binary files /dev/null and b/web/gui/v1/fonts/glyphicons-halflings-regular.woff differ diff --git a/web/gui/v1/fonts/glyphicons-halflings-regular.woff2 b/web/gui/v1/fonts/glyphicons-halflings-regular.woff2 new file mode 100644 index 00000000..64539b54 Binary files /dev/null and b/web/gui/v1/fonts/glyphicons-halflings-regular.woff2 differ diff --git a/web/gui/v1/goto-host-from-alarm.html b/web/gui/v1/goto-host-from-alarm.html new file mode 100644 index 00000000..5d424c69 --- /dev/null +++ b/web/gui/v1/goto-host-from-alarm.html @@ -0,0 +1,250 @@ + + + + + Goto a host you know... + + + + + + + + + + + + + +
    +
    + Please wait... + +
    + +
    +
    +

    + This page can only find netdata URLs you have already visited and are linked to your account on this netdata registry. +

    +
    +
    + +
    + + diff --git a/web/gui/v1/images/alert-128-orange.png b/web/gui/v1/images/alert-128-orange.png new file mode 100644 index 00000000..c6182bfa Binary files /dev/null and b/web/gui/v1/images/alert-128-orange.png differ diff --git a/web/gui/v1/images/alert-128-red.png b/web/gui/v1/images/alert-128-red.png new file mode 100644 index 00000000..90b9c73e Binary files /dev/null and b/web/gui/v1/images/alert-128-red.png differ diff --git a/web/gui/v1/images/alert-multi-size-orange.ico b/web/gui/v1/images/alert-multi-size-orange.ico new file mode 100644 index 00000000..edca4387 Binary files /dev/null and b/web/gui/v1/images/alert-multi-size-orange.ico differ diff --git a/web/gui/v1/images/alert-multi-size-red.ico b/web/gui/v1/images/alert-multi-size-red.ico new file mode 100644 index 00000000..8f7cbd06 Binary files /dev/null and b/web/gui/v1/images/alert-multi-size-red.ico differ diff --git a/web/gui/v1/images/alerts.jpg b/web/gui/v1/images/alerts.jpg new file mode 100644 index 00000000..6593c72d Binary files /dev/null and b/web/gui/v1/images/alerts.jpg differ diff --git a/web/gui/v1/images/alerts.png b/web/gui/v1/images/alerts.png new file mode 100644 index 00000000..fe9940d3 Binary files /dev/null and b/web/gui/v1/images/alerts.png differ diff --git a/web/gui/v1/images/android-icon-144x144.png b/web/gui/v1/images/android-icon-144x144.png new file mode 100644 index 00000000..69efa5a2 Binary files /dev/null and b/web/gui/v1/images/android-icon-144x144.png differ diff --git a/web/gui/v1/images/android-icon-192x192.png b/web/gui/v1/images/android-icon-192x192.png new file mode 100644 index 00000000..e5744357 Binary files /dev/null and b/web/gui/v1/images/android-icon-192x192.png differ diff --git a/web/gui/v1/images/android-icon-36x36.png b/web/gui/v1/images/android-icon-36x36.png new file mode 100644 index 00000000..4ba804d9 Binary files /dev/null and b/web/gui/v1/images/android-icon-36x36.png differ diff --git a/web/gui/v1/images/android-icon-48x48.png b/web/gui/v1/images/android-icon-48x48.png new file mode 100644 index 00000000..04970d4b Binary files /dev/null and b/web/gui/v1/images/android-icon-48x48.png differ diff --git a/web/gui/v1/images/android-icon-72x72.png b/web/gui/v1/images/android-icon-72x72.png new file mode 100644 index 00000000..5cbc701e Binary files /dev/null and b/web/gui/v1/images/android-icon-72x72.png differ diff --git a/web/gui/v1/images/android-icon-96x96.png b/web/gui/v1/images/android-icon-96x96.png new file mode 100644 index 00000000..21f27cea Binary files /dev/null and b/web/gui/v1/images/android-icon-96x96.png differ diff --git a/web/gui/v1/images/animated.gif b/web/gui/v1/images/animated.gif new file mode 100644 index 00000000..0e94a20b Binary files /dev/null and b/web/gui/v1/images/animated.gif differ diff --git a/web/gui/v1/images/apple-icon-114x114.png b/web/gui/v1/images/apple-icon-114x114.png new file mode 100644 index 00000000..7993e055 Binary files /dev/null and b/web/gui/v1/images/apple-icon-114x114.png differ diff --git a/web/gui/v1/images/apple-icon-120x120.png b/web/gui/v1/images/apple-icon-120x120.png new file mode 100644 index 00000000..3fbe8fda Binary files /dev/null and b/web/gui/v1/images/apple-icon-120x120.png differ diff --git a/web/gui/v1/images/apple-icon-144x144.png b/web/gui/v1/images/apple-icon-144x144.png new file mode 100644 index 00000000..8d465692 Binary files /dev/null and b/web/gui/v1/images/apple-icon-144x144.png differ diff --git a/web/gui/v1/images/apple-icon-152x152.png b/web/gui/v1/images/apple-icon-152x152.png new file mode 100644 index 00000000..11a10723 Binary files /dev/null and b/web/gui/v1/images/apple-icon-152x152.png differ diff --git a/web/gui/v1/images/apple-icon-180x180.png b/web/gui/v1/images/apple-icon-180x180.png new file mode 100644 index 00000000..314efb12 Binary files /dev/null and b/web/gui/v1/images/apple-icon-180x180.png differ diff --git a/web/gui/v1/images/apple-icon-57x57.png b/web/gui/v1/images/apple-icon-57x57.png new file mode 100644 index 00000000..85283616 Binary files /dev/null and b/web/gui/v1/images/apple-icon-57x57.png differ diff --git a/web/gui/v1/images/apple-icon-60x60.png b/web/gui/v1/images/apple-icon-60x60.png new file mode 100644 index 00000000..2662e85d Binary files /dev/null and b/web/gui/v1/images/apple-icon-60x60.png differ diff --git a/web/gui/v1/images/apple-icon-72x72.png b/web/gui/v1/images/apple-icon-72x72.png new file mode 100644 index 00000000..4a6b056e Binary files /dev/null and b/web/gui/v1/images/apple-icon-72x72.png differ diff --git a/web/gui/v1/images/apple-icon-76x76.png b/web/gui/v1/images/apple-icon-76x76.png new file mode 100644 index 00000000..c2bf6c9f Binary files /dev/null and b/web/gui/v1/images/apple-icon-76x76.png differ diff --git a/web/gui/v1/images/apple-icon-precomposed.png b/web/gui/v1/images/apple-icon-precomposed.png new file mode 100644 index 00000000..9c3e73ef Binary files /dev/null and b/web/gui/v1/images/apple-icon-precomposed.png differ diff --git a/web/gui/v1/images/apple-icon.png b/web/gui/v1/images/apple-icon.png new file mode 100644 index 00000000..9c3e73ef Binary files /dev/null and b/web/gui/v1/images/apple-icon.png differ diff --git a/web/gui/v1/images/banner-icon-144x144.png b/web/gui/v1/images/banner-icon-144x144.png new file mode 100644 index 00000000..fef3dca1 Binary files /dev/null and b/web/gui/v1/images/banner-icon-144x144.png differ diff --git a/web/gui/v1/images/check-mark-2-128-green.png b/web/gui/v1/images/check-mark-2-128-green.png new file mode 100644 index 00000000..e04ddca1 Binary files /dev/null and b/web/gui/v1/images/check-mark-2-128-green.png differ diff --git a/web/gui/v1/images/check-mark-2-multi-size-green.ico b/web/gui/v1/images/check-mark-2-multi-size-green.ico new file mode 100644 index 00000000..2fc41411 Binary files /dev/null and b/web/gui/v1/images/check-mark-2-multi-size-green.ico differ diff --git a/web/gui/v1/images/dashboards.png b/web/gui/v1/images/dashboards.png new file mode 100644 index 00000000..46cdfbb2 Binary files /dev/null and b/web/gui/v1/images/dashboards.png differ diff --git a/web/gui/v1/images/favicon-128.png b/web/gui/v1/images/favicon-128.png new file mode 100644 index 00000000..5371f920 Binary files /dev/null and b/web/gui/v1/images/favicon-128.png differ diff --git a/web/gui/v1/images/favicon-16x16.png b/web/gui/v1/images/favicon-16x16.png new file mode 100644 index 00000000..5729f5a2 Binary files /dev/null and b/web/gui/v1/images/favicon-16x16.png differ diff --git a/web/gui/v1/images/favicon-196x196.png b/web/gui/v1/images/favicon-196x196.png new file mode 100644 index 00000000..a208c27f Binary files /dev/null and b/web/gui/v1/images/favicon-196x196.png differ diff --git a/web/gui/v1/images/favicon-32x32.png b/web/gui/v1/images/favicon-32x32.png new file mode 100644 index 00000000..cdb0a480 Binary files /dev/null and b/web/gui/v1/images/favicon-32x32.png differ diff --git a/web/gui/v1/images/favicon-96x96.png b/web/gui/v1/images/favicon-96x96.png new file mode 100644 index 00000000..dbe7dea2 Binary files /dev/null and b/web/gui/v1/images/favicon-96x96.png differ diff --git a/web/gui/v1/images/favicon.ico b/web/gui/v1/images/favicon.ico new file mode 100644 index 00000000..064032ae Binary files /dev/null and b/web/gui/v1/images/favicon.ico differ diff --git a/web/gui/v1/images/home.png b/web/gui/v1/images/home.png new file mode 100644 index 00000000..cf7db9db Binary files /dev/null and b/web/gui/v1/images/home.png differ diff --git a/web/gui/v1/images/ms-icon-144x144.png b/web/gui/v1/images/ms-icon-144x144.png new file mode 100644 index 00000000..8d465692 Binary files /dev/null and b/web/gui/v1/images/ms-icon-144x144.png differ diff --git a/web/gui/v1/images/ms-icon-150x150.png b/web/gui/v1/images/ms-icon-150x150.png new file mode 100644 index 00000000..4683d56a Binary files /dev/null and b/web/gui/v1/images/ms-icon-150x150.png differ diff --git a/web/gui/v1/images/ms-icon-310x150.png b/web/gui/v1/images/ms-icon-310x150.png new file mode 100644 index 00000000..5d4ac57b Binary files /dev/null and b/web/gui/v1/images/ms-icon-310x150.png differ diff --git a/web/gui/v1/images/ms-icon-310x310.png b/web/gui/v1/images/ms-icon-310x310.png new file mode 100644 index 00000000..bdb591b2 Binary files /dev/null and b/web/gui/v1/images/ms-icon-310x310.png differ diff --git a/web/gui/v1/images/ms-icon-36x36.png b/web/gui/v1/images/ms-icon-36x36.png new file mode 100644 index 00000000..e251302e Binary files /dev/null and b/web/gui/v1/images/ms-icon-36x36.png differ diff --git a/web/gui/v1/images/ms-icon-70x70.png b/web/gui/v1/images/ms-icon-70x70.png new file mode 100644 index 00000000..5371f920 Binary files /dev/null and b/web/gui/v1/images/ms-icon-70x70.png differ diff --git a/web/gui/v1/images/netdata-logomark.svg b/web/gui/v1/images/netdata-logomark.svg new file mode 100644 index 00000000..18152fb7 --- /dev/null +++ b/web/gui/v1/images/netdata-logomark.svg @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/web/gui/v1/images/netdata.svg b/web/gui/v1/images/netdata.svg new file mode 100644 index 00000000..f8ddbda1 --- /dev/null +++ b/web/gui/v1/images/netdata.svg @@ -0,0 +1,18 @@ + + + + + + Created by potrace 1.15, written by Peter Selinger 2001-2017 + + + + + + + + + + diff --git a/web/gui/v1/images/nodeView.png b/web/gui/v1/images/nodeView.png new file mode 100644 index 00000000..e9b3e1b6 Binary files /dev/null and b/web/gui/v1/images/nodeView.png differ diff --git a/web/gui/v1/images/nodes.jpg b/web/gui/v1/images/nodes.jpg new file mode 100644 index 00000000..3e93c0d6 Binary files /dev/null and b/web/gui/v1/images/nodes.jpg differ diff --git a/web/gui/v1/images/overview.png b/web/gui/v1/images/overview.png new file mode 100644 index 00000000..6e54db6a Binary files /dev/null and b/web/gui/v1/images/overview.png differ diff --git a/web/gui/v1/images/packaging-beta-tag.svg b/web/gui/v1/images/packaging-beta-tag.svg new file mode 100644 index 00000000..cebdc084 --- /dev/null +++ b/web/gui/v1/images/packaging-beta-tag.svg @@ -0,0 +1,42 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/web/gui/v1/images/post.png b/web/gui/v1/images/post.png new file mode 100644 index 00000000..6bad5474 Binary files /dev/null and b/web/gui/v1/images/post.png differ diff --git a/web/gui/v1/images/pricing.png b/web/gui/v1/images/pricing.png new file mode 100644 index 00000000..d5406e8a Binary files /dev/null and b/web/gui/v1/images/pricing.png differ diff --git a/web/gui/v1/images/seo-performance-128.png b/web/gui/v1/images/seo-performance-128.png new file mode 100644 index 00000000..2a212a47 Binary files /dev/null and b/web/gui/v1/images/seo-performance-128.png differ diff --git a/web/gui/v1/index-node-view.html b/web/gui/v1/index-node-view.html new file mode 100644 index 00000000..8483892e --- /dev/null +++ b/web/gui/v1/index-node-view.html @@ -0,0 +1,30 @@ + + + + + Netdata TV Dashboard + + + + + + + + + + + + + + + + + + + + + +
    + + + diff --git a/web/gui/v1/index.html b/web/gui/v1/index.html new file mode 100644 index 00000000..bd92748e --- /dev/null +++ b/web/gui/v1/index.html @@ -0,0 +1,35 @@ +netdata dashboard
    You must enable JavaScript in order to use Netdata!
    You can do this in your browser settings.
    \ No newline at end of file diff --git a/web/gui/v1/infographic.html b/web/gui/v1/infographic.html new file mode 100644 index 00000000..0d3f5637 --- /dev/null +++ b/web/gui/v1/infographic.html @@ -0,0 +1,171 @@ + + + + + + Netdata: Get control of your Linux Servers. Simple. Effective. Awesome. + + + + + + + + + + + + + + + + + + + + + + + + + + + +
    +
    +

    + Interactive infographic of netdata features and functions +

    +

    + Hover and click on the infographic, to open the related wiki page. +
    + + The links and the docs are still a work in progress. + The interactive infographic is a feature of draw.io. + +

    +
    + +
    +

    + New to netdata? Have a look at a netdata demo. You will love it! +

    +

    + + + +

    +
    +
    +
    +
    +
    +
    + + + + + + + + + +
    + + + + + + diff --git a/web/gui/v1/lib/bootstrap-3.3.7.min.js b/web/gui/v1/lib/bootstrap-3.3.7.min.js new file mode 100644 index 00000000..03a97168 --- /dev/null +++ b/web/gui/v1/lib/bootstrap-3.3.7.min.js @@ -0,0 +1,8 @@ +/*! + * Bootstrap v3.3.7 (http://getbootstrap.com) + * Copyright 2011-2016 Twitter, Inc. + * Licensed under the MIT license + * SPDX-License-Identifier: MIT + */ +if("undefined"==typeof jQuery)throw new Error("Bootstrap's JavaScript requires jQuery");+function(a){"use strict";var b=a.fn.jquery.split(" ")[0].split(".");if(b[0]<2&&b[1]<9||1==b[0]&&9==b[1]&&b[2]<1||b[0]>3)throw new Error("Bootstrap's JavaScript requires jQuery version 1.9.1 or higher, but lower than version 4")}(jQuery),+function(a){"use strict";function b(){var a=document.createElement("bootstrap"),b={WebkitTransition:"webkitTransitionEnd",MozTransition:"transitionend",OTransition:"oTransitionEnd otransitionend",transition:"transitionend"};for(var c in b)if(void 0!==a.style[c])return{end:b[c]};return!1}a.fn.emulateTransitionEnd=function(b){var c=!1,d=this;a(this).one("bsTransitionEnd",function(){c=!0});var e=function(){c||a(d).trigger(a.support.transition.end)};return setTimeout(e,b),this},a(function(){a.support.transition=b(),a.support.transition&&(a.event.special.bsTransitionEnd={bindType:a.support.transition.end,delegateType:a.support.transition.end,handle:function(b){if(a(b.target).is(this))return b.handleObj.handler.apply(this,arguments)}})})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var c=a(this),e=c.data("bs.alert");e||c.data("bs.alert",e=new d(this)),"string"==typeof b&&e[b].call(c)})}var c='[data-dismiss="alert"]',d=function(b){a(b).on("click",c,this.close)};d.VERSION="3.3.7",d.TRANSITION_DURATION=150,d.prototype.close=function(b){function c(){g.detach().trigger("closed.bs.alert").remove()}var e=a(this),f=e.attr("data-target");f||(f=e.attr("href"),f=f&&f.replace(/.*(?=#[^\s]*$)/,""));var g=a("#"===f?[]:f);b&&b.preventDefault(),g.length||(g=e.closest(".alert")),g.trigger(b=a.Event("close.bs.alert")),b.isDefaultPrevented()||(g.removeClass("in"),a.support.transition&&g.hasClass("fade")?g.one("bsTransitionEnd",c).emulateTransitionEnd(d.TRANSITION_DURATION):c())};var e=a.fn.alert;a.fn.alert=b,a.fn.alert.Constructor=d,a.fn.alert.noConflict=function(){return a.fn.alert=e,this},a(document).on("click.bs.alert.data-api",c,d.prototype.close)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.button"),f="object"==typeof b&&b;e||d.data("bs.button",e=new c(this,f)),"toggle"==b?e.toggle():b&&e.setState(b)})}var c=function(b,d){this.$element=a(b),this.options=a.extend({},c.DEFAULTS,d),this.isLoading=!1};c.VERSION="3.3.7",c.DEFAULTS={loadingText:"loading..."},c.prototype.setState=function(b){var c="disabled",d=this.$element,e=d.is("input")?"val":"html",f=d.data();b+="Text",null==f.resetText&&d.data("resetText",d[e]()),setTimeout(a.proxy(function(){d[e](null==f[b]?this.options[b]:f[b]),"loadingText"==b?(this.isLoading=!0,d.addClass(c).attr(c,c).prop(c,!0)):this.isLoading&&(this.isLoading=!1,d.removeClass(c).removeAttr(c).prop(c,!1))},this),0)},c.prototype.toggle=function(){var a=!0,b=this.$element.closest('[data-toggle="buttons"]');if(b.length){var c=this.$element.find("input");"radio"==c.prop("type")?(c.prop("checked")&&(a=!1),b.find(".active").removeClass("active"),this.$element.addClass("active")):"checkbox"==c.prop("type")&&(c.prop("checked")!==this.$element.hasClass("active")&&(a=!1),this.$element.toggleClass("active")),c.prop("checked",this.$element.hasClass("active")),a&&c.trigger("change")}else this.$element.attr("aria-pressed",!this.$element.hasClass("active")),this.$element.toggleClass("active")};var d=a.fn.button;a.fn.button=b,a.fn.button.Constructor=c,a.fn.button.noConflict=function(){return a.fn.button=d,this},a(document).on("click.bs.button.data-api",'[data-toggle^="button"]',function(c){var d=a(c.target).closest(".btn");b.call(d,"toggle"),a(c.target).is('input[type="radio"], input[type="checkbox"]')||(c.preventDefault(),d.is("input,button")?d.trigger("focus"):d.find("input:visible,button:visible").first().trigger("focus"))}).on("focus.bs.button.data-api blur.bs.button.data-api",'[data-toggle^="button"]',function(b){a(b.target).closest(".btn").toggleClass("focus",/^focus(in)?$/.test(b.type))})}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.carousel"),f=a.extend({},c.DEFAULTS,d.data(),"object"==typeof b&&b),g="string"==typeof b?b:f.slide;e||d.data("bs.carousel",e=new c(this,f)),"number"==typeof b?e.to(b):g?e[g]():f.interval&&e.pause().cycle()})}var c=function(b,c){this.$element=a(b),this.$indicators=this.$element.find(".carousel-indicators"),this.options=c,this.paused=null,this.sliding=null,this.interval=null,this.$active=null,this.$items=null,this.options.keyboard&&this.$element.on("keydown.bs.carousel",a.proxy(this.keydown,this)),"hover"==this.options.pause&&!("ontouchstart"in document.documentElement)&&this.$element.on("mouseenter.bs.carousel",a.proxy(this.pause,this)).on("mouseleave.bs.carousel",a.proxy(this.cycle,this))};c.VERSION="3.3.7",c.TRANSITION_DURATION=600,c.DEFAULTS={interval:5e3,pause:"hover",wrap:!0,keyboard:!0},c.prototype.keydown=function(a){if(!/input|textarea/i.test(a.target.tagName)){switch(a.which){case 37:this.prev();break;case 39:this.next();break;default:return}a.preventDefault()}},c.prototype.cycle=function(b){return b||(this.paused=!1),this.interval&&clearInterval(this.interval),this.options.interval&&!this.paused&&(this.interval=setInterval(a.proxy(this.next,this),this.options.interval)),this},c.prototype.getItemIndex=function(a){return this.$items=a.parent().children(".item"),this.$items.index(a||this.$active)},c.prototype.getItemForDirection=function(a,b){var c=this.getItemIndex(b),d="prev"==a&&0===c||"next"==a&&c==this.$items.length-1;if(d&&!this.options.wrap)return b;var e="prev"==a?-1:1,f=(c+e)%this.$items.length;return this.$items.eq(f)},c.prototype.to=function(a){var b=this,c=this.getItemIndex(this.$active=this.$element.find(".item.active"));if(!(a>this.$items.length-1||a<0))return this.sliding?this.$element.one("slid.bs.carousel",function(){b.to(a)}):c==a?this.pause().cycle():this.slide(a>c?"next":"prev",this.$items.eq(a))},c.prototype.pause=function(b){return b||(this.paused=!0),this.$element.find(".next, .prev").length&&a.support.transition&&(this.$element.trigger(a.support.transition.end),this.cycle(!0)),this.interval=clearInterval(this.interval),this},c.prototype.next=function(){if(!this.sliding)return this.slide("next")},c.prototype.prev=function(){if(!this.sliding)return this.slide("prev")},c.prototype.slide=function(b,d){var e=this.$element.find(".item.active"),f=d||this.getItemForDirection(b,e),g=this.interval,h="next"==b?"left":"right",i=this;if(f.hasClass("active"))return this.sliding=!1;var j=f[0],k=a.Event("slide.bs.carousel",{relatedTarget:j,direction:h});if(this.$element.trigger(k),!k.isDefaultPrevented()){if(this.sliding=!0,g&&this.pause(),this.$indicators.length){this.$indicators.find(".active").removeClass("active");var l=a(this.$indicators.children()[this.getItemIndex(f)]);l&&l.addClass("active")}var m=a.Event("slid.bs.carousel",{relatedTarget:j,direction:h});return a.support.transition&&this.$element.hasClass("slide")?(f.addClass(b),f[0].offsetWidth,e.addClass(h),f.addClass(h),e.one("bsTransitionEnd",function(){f.removeClass([b,h].join(" ")).addClass("active"),e.removeClass(["active",h].join(" ")),i.sliding=!1,setTimeout(function(){i.$element.trigger(m)},0)}).emulateTransitionEnd(c.TRANSITION_DURATION)):(e.removeClass("active"),f.addClass("active"),this.sliding=!1,this.$element.trigger(m)),g&&this.cycle(),this}};var d=a.fn.carousel;a.fn.carousel=b,a.fn.carousel.Constructor=c,a.fn.carousel.noConflict=function(){return a.fn.carousel=d,this};var e=function(c){var d,e=a(this),f=a(e.attr("data-target")||(d=e.attr("href"))&&d.replace(/.*(?=#[^\s]+$)/,""));if(f.hasClass("carousel")){var g=a.extend({},f.data(),e.data()),h=e.attr("data-slide-to");h&&(g.interval=!1),b.call(f,g),h&&f.data("bs.carousel").to(h),c.preventDefault()}};a(document).on("click.bs.carousel.data-api","[data-slide]",e).on("click.bs.carousel.data-api","[data-slide-to]",e),a(window).on("load",function(){a('[data-ride="carousel"]').each(function(){var c=a(this);b.call(c,c.data())})})}(jQuery),+function(a){"use strict";function b(b){var c,d=b.attr("data-target")||(c=b.attr("href"))&&c.replace(/.*(?=#[^\s]+$)/,"");return a(d)}function c(b){return this.each(function(){var c=a(this),e=c.data("bs.collapse"),f=a.extend({},d.DEFAULTS,c.data(),"object"==typeof b&&b);!e&&f.toggle&&/show|hide/.test(b)&&(f.toggle=!1),e||c.data("bs.collapse",e=new d(this,f)),"string"==typeof b&&e[b]()})}var d=function(b,c){this.$element=a(b),this.options=a.extend({},d.DEFAULTS,c),this.$trigger=a('[data-toggle="collapse"][href="#'+b.id+'"],[data-toggle="collapse"][data-target="#'+b.id+'"]'),this.transitioning=null,this.options.parent?this.$parent=this.getParent():this.addAriaAndCollapsedClass(this.$element,this.$trigger),this.options.toggle&&this.toggle()};d.VERSION="3.3.7",d.TRANSITION_DURATION=350,d.DEFAULTS={toggle:!0},d.prototype.dimension=function(){var a=this.$element.hasClass("width");return a?"width":"height"},d.prototype.show=function(){if(!this.transitioning&&!this.$element.hasClass("in")){var b,e=this.$parent&&this.$parent.children(".panel").children(".in, .collapsing");if(!(e&&e.length&&(b=e.data("bs.collapse"),b&&b.transitioning))){var f=a.Event("show.bs.collapse");if(this.$element.trigger(f),!f.isDefaultPrevented()){e&&e.length&&(c.call(e,"hide"),b||e.data("bs.collapse",null));var g=this.dimension();this.$element.removeClass("collapse").addClass("collapsing")[g](0).attr("aria-expanded",!0),this.$trigger.removeClass("collapsed").attr("aria-expanded",!0),this.transitioning=1;var h=function(){this.$element.removeClass("collapsing").addClass("collapse in")[g](""),this.transitioning=0,this.$element.trigger("shown.bs.collapse")};if(!a.support.transition)return h.call(this);var i=a.camelCase(["scroll",g].join("-"));this.$element.one("bsTransitionEnd",a.proxy(h,this)).emulateTransitionEnd(d.TRANSITION_DURATION)[g](this.$element[0][i])}}}},d.prototype.hide=function(){if(!this.transitioning&&this.$element.hasClass("in")){var b=a.Event("hide.bs.collapse");if(this.$element.trigger(b),!b.isDefaultPrevented()){var c=this.dimension();this.$element[c](this.$element[c]())[0].offsetHeight,this.$element.addClass("collapsing").removeClass("collapse in").attr("aria-expanded",!1),this.$trigger.addClass("collapsed").attr("aria-expanded",!1),this.transitioning=1;var e=function(){this.transitioning=0,this.$element.removeClass("collapsing").addClass("collapse").trigger("hidden.bs.collapse")};return a.support.transition?void this.$element[c](0).one("bsTransitionEnd",a.proxy(e,this)).emulateTransitionEnd(d.TRANSITION_DURATION):e.call(this)}}},d.prototype.toggle=function(){this[this.$element.hasClass("in")?"hide":"show"]()},d.prototype.getParent=function(){return a(this.options.parent).find('[data-toggle="collapse"][data-parent="'+this.options.parent+'"]').each(a.proxy(function(c,d){var e=a(d);this.addAriaAndCollapsedClass(b(e),e)},this)).end()},d.prototype.addAriaAndCollapsedClass=function(a,b){var c=a.hasClass("in");a.attr("aria-expanded",c),b.toggleClass("collapsed",!c).attr("aria-expanded",c)};var e=a.fn.collapse;a.fn.collapse=c,a.fn.collapse.Constructor=d,a.fn.collapse.noConflict=function(){return a.fn.collapse=e,this},a(document).on("click.bs.collapse.data-api",'[data-toggle="collapse"]',function(d){var e=a(this);e.attr("data-target")||d.preventDefault();var f=b(e),g=f.data("bs.collapse"),h=g?"toggle":e.data();c.call(f,h)})}(jQuery),+function(a){"use strict";function b(b){var c=b.attr("data-target");c||(c=b.attr("href"),c=c&&/#[A-Za-z]/.test(c)&&c.replace(/.*(?=#[^\s]*$)/,""));var d=c&&a(c);return d&&d.length?d:b.parent()}function c(c){c&&3===c.which||(a(e).remove(),a(f).each(function(){var d=a(this),e=b(d),f={relatedTarget:this};e.hasClass("open")&&(c&&"click"==c.type&&/input|textarea/i.test(c.target.tagName)&&a.contains(e[0],c.target)||(e.trigger(c=a.Event("hide.bs.dropdown",f)),c.isDefaultPrevented()||(d.attr("aria-expanded","false"),e.removeClass("open").trigger(a.Event("hidden.bs.dropdown",f)))))}))}function d(b){return this.each(function(){var c=a(this),d=c.data("bs.dropdown");d||c.data("bs.dropdown",d=new g(this)),"string"==typeof b&&d[b].call(c)})}var e=".dropdown-backdrop",f='[data-toggle="dropdown"]',g=function(b){a(b).on("click.bs.dropdown",this.toggle)};g.VERSION="3.3.7",g.prototype.toggle=function(d){var e=a(this);if(!e.is(".disabled, :disabled")){var f=b(e),g=f.hasClass("open");if(c(),!g){"ontouchstart"in document.documentElement&&!f.closest(".navbar-nav").length&&a(document.createElement("div")).addClass("dropdown-backdrop").insertAfter(a(this)).on("click",c);var h={relatedTarget:this};if(f.trigger(d=a.Event("show.bs.dropdown",h)),d.isDefaultPrevented())return;e.trigger("focus").attr("aria-expanded","true"),f.toggleClass("open").trigger(a.Event("shown.bs.dropdown",h))}return!1}},g.prototype.keydown=function(c){if(/(38|40|27|32)/.test(c.which)&&!/input|textarea/i.test(c.target.tagName)){var d=a(this);if(c.preventDefault(),c.stopPropagation(),!d.is(".disabled, :disabled")){var e=b(d),g=e.hasClass("open");if(!g&&27!=c.which||g&&27==c.which)return 27==c.which&&e.find(f).trigger("focus"),d.trigger("click");var h=" li:not(.disabled):visible a",i=e.find(".dropdown-menu"+h);if(i.length){var j=i.index(c.target);38==c.which&&j>0&&j--,40==c.which&&jdocument.documentElement.clientHeight;this.$element.css({paddingLeft:!this.bodyIsOverflowing&&a?this.scrollbarWidth:"",paddingRight:this.bodyIsOverflowing&&!a?this.scrollbarWidth:""})},c.prototype.resetAdjustments=function(){this.$element.css({paddingLeft:"",paddingRight:""})},c.prototype.checkScrollbar=function(){var a=window.innerWidth;if(!a){var b=document.documentElement.getBoundingClientRect();a=b.right-Math.abs(b.left)}this.bodyIsOverflowing=document.body.clientWidth
    ',trigger:"hover focus",title:"",delay:0,html:!1,container:!1,viewport:{selector:"body",padding:0}},c.prototype.init=function(b,c,d){if(this.enabled=!0,this.type=b,this.$element=a(c),this.options=this.getOptions(d),this.$viewport=this.options.viewport&&a(a.isFunction(this.options.viewport)?this.options.viewport.call(this,this.$element):this.options.viewport.selector||this.options.viewport),this.inState={click:!1,hover:!1,focus:!1},this.$element[0]instanceof document.constructor&&!this.options.selector)throw new Error("`selector` option must be specified when initializing "+this.type+" on the window.document object!");for(var e=this.options.trigger.split(" "),f=e.length;f--;){var g=e[f];if("click"==g)this.$element.on("click."+this.type,this.options.selector,a.proxy(this.toggle,this));else if("manual"!=g){var h="hover"==g?"mouseenter":"focusin",i="hover"==g?"mouseleave":"focusout";this.$element.on(h+"."+this.type,this.options.selector,a.proxy(this.enter,this)),this.$element.on(i+"."+this.type,this.options.selector,a.proxy(this.leave,this))}}this.options.selector?this._options=a.extend({},this.options,{trigger:"manual",selector:""}):this.fixTitle()},c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.getOptions=function(b){return b=a.extend({},this.getDefaults(),this.$element.data(),b),b.delay&&"number"==typeof b.delay&&(b.delay={show:b.delay,hide:b.delay}),b},c.prototype.getDelegateOptions=function(){var b={},c=this.getDefaults();return this._options&&a.each(this._options,function(a,d){c[a]!=d&&(b[a]=d)}),b},c.prototype.enter=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);return c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusin"==b.type?"focus":"hover"]=!0),c.tip().hasClass("in")||"in"==c.hoverState?void(c.hoverState="in"):(clearTimeout(c.timeout),c.hoverState="in",c.options.delay&&c.options.delay.show?void(c.timeout=setTimeout(function(){"in"==c.hoverState&&c.show()},c.options.delay.show)):c.show())},c.prototype.isInStateTrue=function(){for(var a in this.inState)if(this.inState[a])return!0;return!1},c.prototype.leave=function(b){var c=b instanceof this.constructor?b:a(b.currentTarget).data("bs."+this.type);if(c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c)),b instanceof a.Event&&(c.inState["focusout"==b.type?"focus":"hover"]=!1),!c.isInStateTrue())return clearTimeout(c.timeout),c.hoverState="out",c.options.delay&&c.options.delay.hide?void(c.timeout=setTimeout(function(){"out"==c.hoverState&&c.hide()},c.options.delay.hide)):c.hide()},c.prototype.show=function(){var b=a.Event("show.bs."+this.type);if(this.hasContent()&&this.enabled){this.$element.trigger(b);var d=a.contains(this.$element[0].ownerDocument.documentElement,this.$element[0]);if(b.isDefaultPrevented()||!d)return;var e=this,f=this.tip(),g=this.getUID(this.type);this.setContent(),f.attr("id",g),this.$element.attr("aria-describedby",g),this.options.animation&&f.addClass("fade");var h="function"==typeof this.options.placement?this.options.placement.call(this,f[0],this.$element[0]):this.options.placement,i=/\s?auto?\s?/i,j=i.test(h);j&&(h=h.replace(i,"")||"top"),f.detach().css({top:0,left:0,display:"block"}).addClass(h).data("bs."+this.type,this),this.options.container?f.appendTo(this.options.container):f.insertAfter(this.$element),this.$element.trigger("inserted.bs."+this.type);var k=this.getPosition(),l=f[0].offsetWidth,m=f[0].offsetHeight;if(j){var n=h,o=this.getPosition(this.$viewport);h="bottom"==h&&k.bottom+m>o.bottom?"top":"top"==h&&k.top-mo.width?"left":"left"==h&&k.left-lg.top+g.height&&(e.top=g.top+g.height-i)}else{var j=b.left-f,k=b.left+f+c;jg.right&&(e.left=g.left+g.width-k)}return e},c.prototype.getTitle=function(){var a,b=this.$element,c=this.options;return a=b.attr("data-original-title")||("function"==typeof c.title?c.title.call(b[0]):c.title)},c.prototype.getUID=function(a){do a+=~~(1e6*Math.random());while(document.getElementById(a));return a},c.prototype.tip=function(){if(!this.$tip&&(this.$tip=a(this.options.template),1!=this.$tip.length))throw new Error(this.type+" `template` option must consist of exactly 1 top-level element!");return this.$tip},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".tooltip-arrow")},c.prototype.enable=function(){this.enabled=!0},c.prototype.disable=function(){this.enabled=!1},c.prototype.toggleEnabled=function(){this.enabled=!this.enabled},c.prototype.toggle=function(b){var c=this;b&&(c=a(b.currentTarget).data("bs."+this.type),c||(c=new this.constructor(b.currentTarget,this.getDelegateOptions()),a(b.currentTarget).data("bs."+this.type,c))),b?(c.inState.click=!c.inState.click,c.isInStateTrue()?c.enter(c):c.leave(c)):c.tip().hasClass("in")?c.leave(c):c.enter(c)},c.prototype.destroy=function(){var a=this;clearTimeout(this.timeout),this.hide(function(){a.$element.off("."+a.type).removeData("bs."+a.type),a.$tip&&a.$tip.detach(),a.$tip=null,a.$arrow=null,a.$viewport=null,a.$element=null})};var d=a.fn.tooltip;a.fn.tooltip=b,a.fn.tooltip.Constructor=c,a.fn.tooltip.noConflict=function(){return a.fn.tooltip=d,this}}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.popover"),f="object"==typeof b&&b;!e&&/destroy|hide/.test(b)||(e||d.data("bs.popover",e=new c(this,f)),"string"==typeof b&&e[b]())})}var c=function(a,b){this.init("popover",a,b)};if(!a.fn.tooltip)throw new Error("Popover requires tooltip.js");c.VERSION="3.3.7",c.DEFAULTS=a.extend({},a.fn.tooltip.Constructor.DEFAULTS,{placement:"right",trigger:"click",content:"",template:''}),c.prototype=a.extend({},a.fn.tooltip.Constructor.prototype),c.prototype.constructor=c,c.prototype.getDefaults=function(){return c.DEFAULTS},c.prototype.setContent=function(){var a=this.tip(),b=this.getTitle(),c=this.getContent();a.find(".popover-title")[this.options.html?"html":"text"](b),a.find(".popover-content").children().detach().end()[this.options.html?"string"==typeof c?"html":"append":"text"](c),a.removeClass("fade top bottom left right in"),a.find(".popover-title").html()||a.find(".popover-title").hide()},c.prototype.hasContent=function(){return this.getTitle()||this.getContent()},c.prototype.getContent=function(){var a=this.$element,b=this.options;return a.attr("data-content")||("function"==typeof b.content?b.content.call(a[0]):b.content)},c.prototype.arrow=function(){return this.$arrow=this.$arrow||this.tip().find(".arrow")};var d=a.fn.popover;a.fn.popover=b,a.fn.popover.Constructor=c,a.fn.popover.noConflict=function(){return a.fn.popover=d,this}}(jQuery),+function(a){"use strict";function b(c,d){this.$body=a(document.body),this.$scrollElement=a(a(c).is(document.body)?window:c),this.options=a.extend({},b.DEFAULTS,d),this.selector=(this.options.target||"")+" .nav li > a",this.offsets=[],this.targets=[],this.activeTarget=null,this.scrollHeight=0,this.$scrollElement.on("scroll.bs.scrollspy",a.proxy(this.process,this)),this.refresh(),this.process()}function c(c){return this.each(function(){var d=a(this),e=d.data("bs.scrollspy"),f="object"==typeof c&&c;e||d.data("bs.scrollspy",e=new b(this,f)),"string"==typeof c&&e[c]()})}b.VERSION="3.3.7",b.DEFAULTS={offset:10},b.prototype.getScrollHeight=function(){return this.$scrollElement[0].scrollHeight||Math.max(this.$body[0].scrollHeight,document.documentElement.scrollHeight)},b.prototype.refresh=function(){var b=this,c="offset",d=0;this.offsets=[],this.targets=[],this.scrollHeight=this.getScrollHeight(),a.isWindow(this.$scrollElement[0])||(c="position",d=this.$scrollElement.scrollTop()),this.$body.find(this.selector).map(function(){var b=a(this),e=b.data("target")||b.attr("href"),f=/^#./.test(e)&&a(e);return f&&f.length&&f.is(":visible")&&[[f[c]().top+d,e]]||null}).sort(function(a,b){return a[0]-b[0]}).each(function(){b.offsets.push(this[0]),b.targets.push(this[1])})},b.prototype.process=function(){var a,b=this.$scrollElement.scrollTop()+this.options.offset,c=this.getScrollHeight(),d=this.options.offset+c-this.$scrollElement.height(),e=this.offsets,f=this.targets,g=this.activeTarget;if(this.scrollHeight!=c&&this.refresh(),b>=d)return g!=(a=f[f.length-1])&&this.activate(a);if(g&&b=e[a]&&(void 0===e[a+1]||b .dropdown-menu > .active").removeClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!1),b.addClass("active").find('[data-toggle="tab"]').attr("aria-expanded",!0),h?(b[0].offsetWidth,b.addClass("in")):b.removeClass("fade"),b.parent(".dropdown-menu").length&&b.closest("li.dropdown").addClass("active").end().find('[data-toggle="tab"]').attr("aria-expanded",!0),e&&e()}var g=d.find("> .active"),h=e&&a.support.transition&&(g.length&&g.hasClass("fade")||!!d.find("> .fade").length);g.length&&h?g.one("bsTransitionEnd",f).emulateTransitionEnd(c.TRANSITION_DURATION):f(),g.removeClass("in")};var d=a.fn.tab;a.fn.tab=b,a.fn.tab.Constructor=c,a.fn.tab.noConflict=function(){return a.fn.tab=d,this};var e=function(c){c.preventDefault(),b.call(a(this),"show")};a(document).on("click.bs.tab.data-api",'[data-toggle="tab"]',e).on("click.bs.tab.data-api",'[data-toggle="pill"]',e)}(jQuery),+function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.affix"),f="object"==typeof b&&b;e||d.data("bs.affix",e=new c(this,f)),"string"==typeof b&&e[b]()})}var c=function(b,d){this.options=a.extend({},c.DEFAULTS,d),this.$target=a(this.options.target).on("scroll.bs.affix.data-api",a.proxy(this.checkPosition,this)).on("click.bs.affix.data-api",a.proxy(this.checkPositionWithEventLoop,this)),this.$element=a(b),this.affixed=null,this.unpin=null,this.pinnedOffset=null,this.checkPosition()};c.VERSION="3.3.7",c.RESET="affix affix-top affix-bottom",c.DEFAULTS={offset:0,target:window},c.prototype.getState=function(a,b,c,d){var e=this.$target.scrollTop(),f=this.$element.offset(),g=this.$target.height();if(null!=c&&"top"==this.affixed)return e=a-d&&"bottom"},c.prototype.getPinnedOffset=function(){if(this.pinnedOffset)return this.pinnedOffset;this.$element.removeClass(c.RESET).addClass("affix");var a=this.$target.scrollTop(),b=this.$element.offset();return this.pinnedOffset=b.top-a},c.prototype.checkPositionWithEventLoop=function(){setTimeout(a.proxy(this.checkPosition,this),1)},c.prototype.checkPosition=function(){if(this.$element.is(":visible")){var b=this.$element.height(),d=this.options.offset,e=d.top,f=d.bottom,g=Math.max(a(document).height(),a(document.body).height());"object"!=typeof d&&(f=e=d),"function"==typeof e&&(e=d.top(this.$element)),"function"==typeof f&&(f=d.bottom(this.$element));var h=this.getState(g,b,e,f);if(this.affixed!=h){null!=this.unpin&&this.$element.css("top","");var i="affix"+(h?"-"+h:""),j=a.Event(i+".bs.affix");if(this.$element.trigger(j),j.isDefaultPrevented())return;this.affixed=h,this.unpin="bottom"==h?this.getPinnedOffset():null,this.$element.removeClass(c.RESET).addClass(i).trigger(i.replace("affix","affixed")+".bs.affix")}"bottom"==h&&this.$element.offset({top:g-b-f})}};var d=a.fn.affix;a.fn.affix=b,a.fn.affix.Constructor=c,a.fn.affix.noConflict=function(){return a.fn.affix=d,this},a(window).on("load",function(){a('[data-spy="affix"]').each(function(){var c=a(this),d=c.data();d.offset=d.offset||{},null!=d.offsetBottom&&(d.offset.bottom=d.offsetBottom),null!=d.offsetTop&&(d.offset.top=d.offsetTop),b.call(c,d)})})}(jQuery); diff --git a/web/gui/v1/lib/bootstrap-slider-10.0.0.min.js b/web/gui/v1/lib/bootstrap-slider-10.0.0.min.js new file mode 100644 index 00000000..87e83490 --- /dev/null +++ b/web/gui/v1/lib/bootstrap-slider-10.0.0.min.js @@ -0,0 +1,6 @@ +// SPDX-License-Identifier: MIT +/*! ======================================================= + VERSION 10.0.0 +========================================================= */ +"use strict";var _typeof="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(a){return typeof a}:function(a){return a&&"function"==typeof Symbol&&a.constructor===Symbol&&a!==Symbol.prototype?"symbol":typeof a},windowIsDefined="object"===("undefined"==typeof window?"undefined":_typeof(window));!function(a){if("function"==typeof define&&define.amd)define(["jquery"],a);else if("object"===("undefined"==typeof module?"undefined":_typeof(module))&&module.exports){var b;try{b=require("jquery")}catch(c){b=null}module.exports=a(b)}else window&&(window.Slider=a(window.jQuery))}(function(a){var b="slider",c="bootstrapSlider";windowIsDefined&&!window.console&&(window.console={}),windowIsDefined&&!window.console.log&&(window.console.log=function(){}),windowIsDefined&&!window.console.warn&&(window.console.warn=function(){});var d;return function(a){function b(){}function c(a){function c(b){b.prototype.option||(b.prototype.option=function(b){a.isPlainObject(b)&&(this.options=a.extend(!0,this.options,b))})}function e(b,c){a.fn[b]=function(e){if("string"==typeof e){for(var g=d.call(arguments,1),h=0,i=this.length;i>h;h++){var j=this[h],k=a.data(j,b);if(k)if(a.isFunction(k[e])&&"_"!==e.charAt(0)){var l=k[e].apply(k,g);if(void 0!==l&&l!==k)return l}else f("no such method '"+e+"' for "+b+" instance");else f("cannot call methods on "+b+" prior to initialization; attempted to call '"+e+"'")}return this}var m=this.map(function(){var d=a.data(this,b);return d?(d.option(e),d._init()):(d=new c(this,e),a.data(this,b,d)),a(this)});return!m||m.length>1?m:m[0]}}if(a){var f="undefined"==typeof console?b:function(a){console.error(a)};return a.bridget=function(a,b){c(b),e(a,b)},a.bridget}}var d=Array.prototype.slice;c(a)}(a),function(a){function e(b,c){function d(a,b){var c="data-slider-"+b.replace(/_/g,"-"),d=a.getAttribute(c);try{return JSON.parse(d)}catch(e){return d}}this._state={value:null,enabled:null,offset:null,size:null,percentage:null,inDrag:!1,over:!1},this.ticksCallbackMap={},this.handleCallbackMap={},"string"==typeof b?this.element=document.querySelector(b):b instanceof HTMLElement&&(this.element=b),c=c?c:{};for(var e=Object.keys(this.defaultOptions),f=0;f0)for(var t=0;t0){for(this.ticksContainer=document.createElement("div"),this.ticksContainer.className="slider-tick-container",f=0;f0)for(this.tickLabelContainer=document.createElement("div"),this.tickLabelContainer.className="slider-tick-label-container",f=0;f0&&(this.options.max=Math.max.apply(Math,this.options.ticks),this.options.min=Math.min.apply(Math,this.options.ticks)),Array.isArray(this.options.value)?(this.options.range=!0,this._state.value=this.options.value):this.options.range?this._state.value=[this.options.value,this.options.max]:this._state.value=this.options.value,this.trackLow=k||this.trackLow,this.trackSelection=j||this.trackSelection,this.trackHigh=l||this.trackHigh,"none"===this.options.selection?(this._addClass(this.trackLow,"hide"),this._addClass(this.trackSelection,"hide"),this._addClass(this.trackHigh,"hide")):("after"===this.options.selection||"before"===this.options.selection)&&(this._removeClass(this.trackLow,"hide"),this._removeClass(this.trackSelection,"hide"),this._removeClass(this.trackHigh,"hide")),this.handle1=m||this.handle1,this.handle2=n||this.handle2,p===!0)for(this._removeClass(this.handle1,"round triangle"),this._removeClass(this.handle2,"round triangle hide"),f=0;f0){for(var d,e,f,g=0,h=1;hthis.options.max?this.options.max:k},toPercentage:function(a){if(this.options.max===this.options.min)return 0;if(this.options.ticks_positions.length>0){for(var b,c,d,e=0,f=0;f0?this.options.ticks[f-1]:0,d=f>0?this.options.ticks_positions[f-1]:0,c=this.options.ticks[f],e=this.options.ticks_positions[f];break}if(f>0){var g=(a-b)/(c-b);return d+g*(e-d)}}return 100*(a-this.options.min)/(this.options.max-this.options.min)}},logarithmic:{toValue:function(a){var b=0===this.options.min?0:Math.log(this.options.min),c=Math.log(this.options.max),d=Math.exp(b+(c-b)*a/100);return Math.round(d)===this.options.max?this.options.max:(d=this.options.min+Math.round((d-this.options.min)/this.options.step)*this.options.step,dthis.options.max?this.options.max:d)},toPercentage:function(a){if(this.options.max===this.options.min)return 0;var b=Math.log(this.options.max),c=0===this.options.min?0:Math.log(this.options.min),d=0===a?0:Math.log(a);return 100*(d-c)/(b-c)}}};if(d=function(a,b){return e.call(this,a,b),this},d.prototype={_init:function(){},constructor:d,defaultOptions:{id:"",min:0,max:10,step:1,precision:0,orientation:"horizontal",value:5,range:!1,selection:"before",tooltip:"show",tooltip_split:!1,handle:"round",reversed:!1,rtl:"auto",enabled:!0,formatter:function(a){return Array.isArray(a)?a[0]+" : "+a[1]:a},natural_arrow_keys:!1,ticks:[],ticks_positions:[],ticks_labels:[],ticks_snap_bounds:0,ticks_tooltip:!1,scale:"linear",focus:!1,tooltip_position:null,labelledby:null,rangeHighlights:[]},getElement:function(){return this.sliderElem},getValue:function(){return this.options.range?this._state.value:this._state.value[0]},setValue:function(a,b,c){a||(a=0);var d=this.getValue();this._state.value=this._validateInputValue(a);var e=this._applyPrecision.bind(this);this.options.range?(this._state.value[0]=e(this._state.value[0]),this._state.value[1]=e(this._state.value[1]),this._state.value[0]=Math.max(this.options.min,Math.min(this.options.max,this._state.value[0])),this._state.value[1]=Math.max(this.options.min,Math.min(this.options.max,this._state.value[1]))):(this._state.value=e(this._state.value),this._state.value=[Math.max(this.options.min,Math.min(this.options.max,this._state.value))],this._addClass(this.handle2,"hide"),"after"===this.options.selection?this._state.value[1]=this.options.max:this._state.value[1]=this.options.min),this.options.max>this.options.min?this._state.percentage=[this._toPercentage(this._state.value[0]),this._toPercentage(this._state.value[1]),100*this.options.step/(this.options.max-this.options.min)]:this._state.percentage=[0,0,100],this._layout();var f=this.options.range?this._state.value:this._state.value[0];return this._setDataVal(f),b===!0&&this._trigger("slide",f),d!==f&&c===!0&&this._trigger("change",{oldValue:d,newValue:f}),this},destroy:function(){this._removeSliderEventHandlers(),this.sliderElem.parentNode.removeChild(this.sliderElem),this.element.style.display="",this._cleanUpEventCallbacksMap(),this.element.removeAttribute("data"),a&&(this._unbindJQueryEventHandlers(),this.$element.removeData("slider"))},disable:function(){return this._state.enabled=!1,this.handle1.removeAttribute("tabindex"),this.handle2.removeAttribute("tabindex"),this._addClass(this.sliderElem,"slider-disabled"),this._trigger("slideDisabled"),this},enable:function(){return this._state.enabled=!0,this.handle1.setAttribute("tabindex",0),this.handle2.setAttribute("tabindex",0),this._removeClass(this.sliderElem,"slider-disabled"),this._trigger("slideEnabled"),this},toggle:function(){return this._state.enabled?this.disable():this.enable(),this},isEnabled:function(){return this._state.enabled},on:function(a,b){return this._bindNonQueryEventHandler(a,b),this},off:function(b,c){a?(this.$element.off(b,c),this.$sliderElem.off(b,c)):this._unbindNonQueryEventHandler(b,c)},getAttribute:function(a){return a?this.options[a]:this.options},setAttribute:function(a,b){return this.options[a]=b,this},refresh:function(){return this._removeSliderEventHandlers(),e.call(this,this.element,this.options),a&&a.data(this.element,"slider",this),this},relayout:function(){return this._resize(),this._layout(),this},_removeSliderEventHandlers:function(){if(this.handle1.removeEventListener("keydown",this.handle1Keydown,!1),this.handle2.removeEventListener("keydown",this.handle2Keydown,!1),this.options.ticks_tooltip){for(var a=this.ticksContainer.getElementsByClassName("slider-tick"),b=0;b=0?c:this.attributes["aria-valuenow"].value,e=parseInt(d,10);b.value[0]=e,b.percentage[0]=a.options.ticks_positions[e],a._setToolTipOnMouseOver(b),a._showTooltip()};return b.addEventListener("mouseenter",d,!1),d},addMouseLeave:function(a,b){var c=function(){a._hideTooltip()};return b.addEventListener("mouseleave",c,!1),c}}},_layout:function(){var a;if(a=this.options.reversed?[100-this._state.percentage[0],this.options.range?100-this._state.percentage[1]:this._state.percentage[1]]:[this._state.percentage[0],this._state.percentage[1]],this.handle1.style[this.stylePos]=a[0]+"%",this.handle1.setAttribute("aria-valuenow",this._state.value[0]),isNaN(this.options.formatter(this._state.value[0]))&&this.handle1.setAttribute("aria-valuetext",this.options.formatter(this._state.value[0])),this.handle2.style[this.stylePos]=a[1]+"%",this.handle2.setAttribute("aria-valuenow",this._state.value[1]),isNaN(this.options.formatter(this._state.value[1]))&&this.handle2.setAttribute("aria-valuetext",this.options.formatter(this._state.value[1])),this.rangeHighlightElements.length>0&&Array.isArray(this.options.rangeHighlights)&&this.options.rangeHighlights.length>0)for(var b=0;b0){var g,h="vertical"===this.options.orientation?"height":"width";g="vertical"===this.options.orientation?"marginTop":this.options.rtl?"marginRight":"marginLeft";var i=this._state.size/(this.options.ticks.length-1);if(this.tickLabelContainer){var j=0;if(0===this.options.ticks_positions.length)"vertical"!==this.options.orientation&&(this.tickLabelContainer.style[g]=-i/2+"px"),j=this.tickLabelContainer.offsetHeight;else for(k=0;kj&&(j=this.tickLabelContainer.childNodes[k].offsetHeight);"horizontal"===this.options.orientation&&(this.sliderElem.style.marginBottom=j+"px")}for(var k=0;k=a[0]&&l<=a[1]&&this._addClass(this.ticks[k],"in-selection"):"after"===this.options.selection&&l>=a[0]?this._addClass(this.ticks[k],"in-selection"):"before"===this.options.selection&&l<=a[0]&&this._addClass(this.ticks[k],"in-selection"),this.tickLabels[k]&&(this.tickLabels[k].style[h]=i+"px","vertical"!==this.options.orientation&&void 0!==this.options.ticks_positions[k]?(this.tickLabels[k].style.position="absolute",this.tickLabels[k].style[this.stylePos]=l+"%",this.tickLabels[k].style[g]=-i/2+"px"):"vertical"===this.options.orientation&&(this.options.rtl?this.tickLabels[k].style.marginRight=this.sliderElem.offsetWidth+"px":this.tickLabels[k].style.marginLeft=this.sliderElem.offsetWidth+"px",this.tickLabelContainer.style[g]=this.sliderElem.offsetWidth/2*-1+"px"))}}var m;if(this.options.range){m=this.options.formatter(this._state.value),this._setText(this.tooltipInner,m),this.tooltip.style[this.stylePos]=(a[1]+a[0])/2+"%";var n=this.options.formatter(this._state.value[0]);this._setText(this.tooltipInner_min,n);var o=this.options.formatter(this._state.value[1]);this._setText(this.tooltipInner_max,o),this.tooltip_min.style[this.stylePos]=a[0]+"%",this.tooltip_max.style[this.stylePos]=a[1]+"%"}else m=this.options.formatter(this._state.value[0]),this._setText(this.tooltipInner,m),this.tooltip.style[this.stylePos]=a[0]+"%";if("vertical"===this.options.orientation)this.trackLow.style.top="0",this.trackLow.style.height=Math.min(a[0],a[1])+"%",this.trackSelection.style.top=Math.min(a[0],a[1])+"%",this.trackSelection.style.height=Math.abs(a[0]-a[1])+"%",this.trackHigh.style.bottom="0",this.trackHigh.style.height=100-Math.min(a[0],a[1])-Math.abs(a[0]-a[1])+"%";else{"right"===this.stylePos?this.trackLow.style.right="0":this.trackLow.style.left="0",this.trackLow.style.width=Math.min(a[0],a[1])+"%","right"===this.stylePos?this.trackSelection.style.right=Math.min(a[0],a[1])+"%":this.trackSelection.style.left=Math.min(a[0],a[1])+"%",this.trackSelection.style.width=Math.abs(a[0]-a[1])+"%","right"===this.stylePos?this.trackHigh.style.left="0":this.trackHigh.style.right="0",this.trackHigh.style.width=100-Math.min(a[0],a[1])-Math.abs(a[0]-a[1])+"%";var p=this.tooltip_min.getBoundingClientRect(),q=this.tooltip_max.getBoundingClientRect();"bottom"===this.options.tooltip_position?p.right>q.left?(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top="",this.tooltip_max.style.bottom="22px"):(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top=this.tooltip_min.style.top,this.tooltip_max.style.bottom=""):p.right>q.left?(this._removeClass(this.tooltip_max,"top"),this._addClass(this.tooltip_max,"bottom"),this.tooltip_max.style.top="18px"):(this._removeClass(this.tooltip_max,"bottom"),this._addClass(this.tooltip_max,"top"),this.tooltip_max.style.top=this.tooltip_min.style.top)}},_createHighlightRange:function(a,b){return this._isHighlightRange(a,b)?a>b?{start:b,size:a-b}:{start:a,size:b-a}:null},_isHighlightRange:function(a,b){return a>=0&&100>=a&&b>=0&&100>=b?!0:!1},_resize:function(a){this._state.offset=this._offset(this.sliderElem),this._state.size=this.sliderElem[this.sizePos],this._layout()},_removeProperty:function(a,b){a.style.removeProperty?a.style.removeProperty(b):a.style.removeAttribute(b)},_mousedown:function(a){if(!this._state.enabled)return!1;this._state.offset=this._offset(this.sliderElem),this._state.size=this.sliderElem[this.sizePos];var b=this._getPercentage(a);if(this.options.range){var c=Math.abs(this._state.percentage[0]-b),d=Math.abs(this._state.percentage[1]-b);this._state.dragged=d>c?0:1,this._adjustPercentageForRangeSliders(b)}else this._state.dragged=0;this._state.percentage[this._state.dragged]=b,this._layout(),this.touchCapable&&(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)),this.mousemove&&document.removeEventListener("mousemove",this.mousemove,!1),this.mouseup&&document.removeEventListener("mouseup",this.mouseup,!1),this.mousemove=this._mousemove.bind(this),this.mouseup=this._mouseup.bind(this),this.touchCapable&&(document.addEventListener("touchmove",this.mousemove,!1),document.addEventListener("touchend",this.mouseup,!1)),document.addEventListener("mousemove",this.mousemove,!1),document.addEventListener("mouseup",this.mouseup,!1),this._state.inDrag=!0;var e=this._calculateValue();return this._trigger("slideStart",e),this._setDataVal(e),this.setValue(e,!1,!0),a.returnValue=!1,this.options.focus&&this._triggerFocusOnHandle(this._state.dragged),!0},_touchstart:function(a){if(void 0===a.changedTouches)return void this._mousedown(a);var b=a.changedTouches[0];this.touchX=b.pageX,this.touchY=b.pageY},_triggerFocusOnHandle:function(a){0===a&&this.handle1.focus(),1===a&&this.handle2.focus()},_keydown:function(a,b){if(!this._state.enabled)return!1;var c;switch(b.keyCode){case 37:case 40:c=-1;break;case 39:case 38:c=1}if(c){if(this.options.natural_arrow_keys){var d="vertical"===this.options.orientation&&!this.options.reversed,e="horizontal"===this.options.orientation&&this.options.reversed;(d||e)&&(c=-c)}var f=this._state.value[a]+c*this.options.step,g=f/this.options.max*100;if(this._state.keyCtrl=a,this.options.range){this._adjustPercentageForRangeSliders(g);var h=this._state.keyCtrl?this._state.value[0]:f,i=this._state.keyCtrl?f:this._state.value[1];f=[h,i]}return this._trigger("slideStart",f),this._setDataVal(f),this.setValue(f,!0,!0),this._setDataVal(f),this._trigger("slideStop",f),this._layout(),this._pauseEvent(b),delete this._state.keyCtrl,!1}},_pauseEvent:function(a){a.stopPropagation&&a.stopPropagation(),a.preventDefault&&a.preventDefault(),a.cancelBubble=!0,a.returnValue=!1},_mousemove:function(a){if(!this._state.enabled)return!1;var b=this._getPercentage(a);this._adjustPercentageForRangeSliders(b),this._state.percentage[this._state.dragged]=b,this._layout();var c=this._calculateValue(!0);return this.setValue(c,!0,!0),!1},_touchmove:function(a){if(void 0!==a.changedTouches){var b=a.changedTouches[0],c=b.pageX-this.touchX,d=b.pageY-this.touchY;this._state.inDrag||("vertical"===this.options.orientation&&5>=c&&c>=-5&&(d>=15||-15>=d)?this._mousedown(a):5>=d&&d>=-5&&(c>=15||-15>=c)&&this._mousedown(a))}},_adjustPercentageForRangeSliders:function(a){if(this.options.range){var b=this._getNumDigitsAfterDecimalPlace(a);b=b?b-1:0;var c=this._applyToFixedAndParseFloat(a,b);0===this._state.dragged&&this._applyToFixedAndParseFloat(this._state.percentage[1],b)c?(this._state.percentage[1]=this._state.percentage[0],this._state.dragged=0):0===this._state.keyCtrl&&this._state.value[1]/this.options.max*100a&&(this._state.percentage[1]=this._state.percentage[0],this._state.keyCtrl=0,this.handle1.focus())}},_mouseup:function(){if(!this._state.enabled)return!1;this.touchCapable&&(document.removeEventListener("touchmove",this.mousemove,!1),document.removeEventListener("touchend",this.mouseup,!1)),document.removeEventListener("mousemove",this.mousemove,!1),document.removeEventListener("mouseup",this.mouseup,!1),this._state.inDrag=!1,this._state.over===!1&&this._hideTooltip();var a=this._calculateValue(!0);return this._layout(),this._setDataVal(a),this._trigger("slideStop",a),!1},_calculateValue:function(a){var b;if(this.options.range?(b=[this.options.min,this.options.max],0!==this._state.percentage[0]&&(b[0]=this._toValue(this._state.percentage[0]),b[0]=this._applyPrecision(b[0])),100!==this._state.percentage[1]&&(b[1]=this._toValue(this._state.percentage[1]),b[1]=this._applyPrecision(b[1]))):(b=this._toValue(this._state.percentage[0]),b=parseFloat(b),b=this._applyPrecision(b)),a){for(var c=[b,1/0],d=0;dd;d++)g[c][d]=!1;for(c=0;ce;e++)g[c+e][k]=!0;for(e=0;j>e;e++)g[c][k+e]=!0}},g=function(){if(null===b){var c,d,e=a("

    ").addClass("fixed-table-scroll-inner"),f=a("

    ").addClass("fixed-table-scroll-outer");f.append(e),a("body").append(f),c=e[0].offsetWidth,f.css("overflow","scroll"),d=e[0].offsetWidth,c===d&&(d=f[0].clientWidth),f.remove(),b=c-d}return b},h=function(b,d,e,f){var g=d;if("string"==typeof d){var h=d.split(".");h.length>1?(g=window,a.each(h,function(a,b){g=g[b]})):g=window[d]}return"object"==typeof g?g:"function"==typeof g?g.apply(b,e):!g&&"string"==typeof d&&c.apply(this,[d].concat(e))?c.apply(this,[d].concat(e)):f},i=function(b,c,d){var e=Object.getOwnPropertyNames(b),f=Object.getOwnPropertyNames(c),g="";if(d&&e.length!==f.length)return!1;for(var h=0;h-1&&b[g]!==c[g])return!1;return!0},j=function(a){return"string"==typeof a?a.replace(/&/g,"&").replace(//g,">").replace(/"/g,""").replace(/'/g,"'").replace(/`/g,"`"):a},k=function(b){var c=0;return b.children().each(function(){c0||navigator.userAgent.match(/Trident.*rv\:11\./))},o=function(){Object.keys||(Object.keys=function(){var a=Object.prototype.hasOwnProperty,b=!{toString:null}.propertyIsEnumerable("toString"),c=["toString","toLocaleString","valueOf","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","constructor"],d=c.length;return function(e){if("object"!=typeof e&&("function"!=typeof e||null===e))throw new TypeError("Object.keys called on non-object");var f,g,h=[];for(f in e)a.call(e,f)&&h.push(f);if(b)for(g=0;d>g;g++)a.call(e,c[g])&&h.push(c[g]);return h}}())},p=function(b,c){this.options=c,this.$el=a(b),this.$el_=this.$el.clone(),this.timeoutId_=0,this.timeoutFooter_=0,this.init()};p.DEFAULTS={classes:"table table-hover",locale:void 0,height:void 0,undefinedText:"-",sortName:void 0,sortOrder:"asc",sortStable:!1,striped:!1,columns:[[]],data:[],dataField:"rows",method:"get",url:void 0,ajax:void 0,cache:!0,contentType:"application/json",dataType:"json",ajaxOptions:{},queryParams:function(a){return a},queryParamsType:"limit",responseHandler:function(a){return a},pagination:!1,onlyInfoPagination:!1,sidePagination:"client",totalRows:0,pageNumber:1,pageSize:10,pageList:[10,25,50,100],paginationHAlign:"right",paginationVAlign:"bottom",paginationDetailHAlign:"left",paginationPreText:"‹",paginationNextText:"›",search:!1,searchOnEnterKey:!1,strictSearch:!1,searchAlign:"right",selectItemName:"btSelectItem",showHeader:!0,showFooter:!1,showColumns:!1,showPaginationSwitch:!1,showRefresh:!1,showToggle:!1,buttonsAlign:"right",smartDisplay:!0,escape:!1,minimumCountColumns:1,idField:void 0,uniqueId:void 0,cardView:!1,detailView:!1,detailFormatter:function(){return""},trimOnSearch:!0,clickToSelect:!1,singleSelect:!1,toolbar:void 0,toolbarAlign:"left",checkboxHeader:!0,sortable:!0,silentSort:!0,maintainSelected:!1,searchTimeOut:500,searchText:"",iconSize:void 0,buttonsClass:"default",iconsPrefix:"glyphicon",icons:{paginationSwitchDown:"glyphicon-collapse-down icon-chevron-down",paginationSwitchUp:"glyphicon-collapse-up icon-chevron-up",refresh:"glyphicon-refresh icon-refresh",toggle:"glyphicon-list-alt icon-list-alt",columns:"glyphicon-th icon-th",detailOpen:"glyphicon-plus icon-plus",detailClose:"glyphicon-minus icon-minus"},customSearch:a.noop,customSort:a.noop,rowStyle:function(){return{}},rowAttributes:function(){return{}},footerStyle:function(){return{}},onAll:function(){return!1},onClickCell:function(){return!1},onDblClickCell:function(){return!1},onClickRow:function(){return!1},onDblClickRow:function(){return!1},onSort:function(){return!1},onCheck:function(){return!1},onUncheck:function(){return!1},onCheckAll:function(){return!1},onUncheckAll:function(){return!1},onCheckSome:function(){return!1},onUncheckSome:function(){return!1},onLoadSuccess:function(){return!1},onLoadError:function(){return!1},onColumnSwitch:function(){return!1},onPageChange:function(){return!1},onSearch:function(){return!1},onToggle:function(){return!1},onPreBody:function(){return!1},onPostBody:function(){return!1},onPostHeader:function(){return!1},onExpandRow:function(){return!1},onCollapseRow:function(){return!1},onRefreshOptions:function(){return!1},onRefresh:function(){return!1},onResetView:function(){return!1}},p.LOCALES={},p.LOCALES["en-US"]=p.LOCALES.en={formatLoadingMessage:function(){return"Loading, please wait..."},formatRecordsPerPage:function(a){return c("%s rows per page",a)},formatShowingRows:function(a,b,d){return c("Showing %s to %s of %s rows",a,b,d)},formatDetailPagination:function(a){return c("Showing %s rows",a)},formatSearch:function(){return"Search"},formatNoMatches:function(){return"No matching records found"},formatPaginationSwitch:function(){return"Hide/Show pagination"},formatRefresh:function(){return"Refresh"},formatToggle:function(){return"Toggle"},formatColumns:function(){return"Columns"},formatAllRows:function(){return"All"}},a.extend(p.DEFAULTS,p.LOCALES["en-US"]),p.COLUMN_DEFAULTS={radio:!1,checkbox:!1,checkboxEnabled:!0,field:void 0,title:void 0,titleTooltip:void 0,"class":void 0,align:void 0,halign:void 0,falign:void 0,valign:void 0,width:void 0,sortable:!1,order:"asc",visible:!0,switchable:!0,clickToSelect:!0,formatter:void 0,footerFormatter:void 0,events:void 0,sorter:void 0,sortName:void 0,cellStyle:void 0,searchable:!0,searchFormatter:!0,cardVisible:!0},p.EVENTS={"all.bs.table":"onAll","click-cell.bs.table":"onClickCell","dbl-click-cell.bs.table":"onDblClickCell","click-row.bs.table":"onClickRow","dbl-click-row.bs.table":"onDblClickRow","sort.bs.table":"onSort","check.bs.table":"onCheck","uncheck.bs.table":"onUncheck","check-all.bs.table":"onCheckAll","uncheck-all.bs.table":"onUncheckAll","check-some.bs.table":"onCheckSome","uncheck-some.bs.table":"onUncheckSome","load-success.bs.table":"onLoadSuccess","load-error.bs.table":"onLoadError","column-switch.bs.table":"onColumnSwitch","page-change.bs.table":"onPageChange","search.bs.table":"onSearch","toggle.bs.table":"onToggle","pre-body.bs.table":"onPreBody","post-body.bs.table":"onPostBody","post-header.bs.table":"onPostHeader","expand-row.bs.table":"onExpandRow","collapse-row.bs.table":"onCollapseRow","refresh-options.bs.table":"onRefreshOptions","reset-view.bs.table":"onResetView","refresh.bs.table":"onRefresh"},p.prototype.init=function(){this.initLocale(),this.initContainer(),this.initTable(),this.initHeader(),this.initData(),this.initFooter(),this.initToolbar(),this.initPagination(),this.initBody(),this.initSearchText(),this.initServer()},p.prototype.initLocale=function(){if(this.options.locale){var b=this.options.locale.split(/-|_/);b[0].toLowerCase(),b[1]&&b[1].toUpperCase(),a.fn.bootstrapTable.locales[this.options.locale]?a.extend(this.options,a.fn.bootstrapTable.locales[this.options.locale]):a.fn.bootstrapTable.locales[b.join("-")]?a.extend(this.options,a.fn.bootstrapTable.locales[b.join("-")]):a.fn.bootstrapTable.locales[b[0]]&&a.extend(this.options,a.fn.bootstrapTable.locales[b[0]])}},p.prototype.initContainer=function(){this.$container=a(['
    ','
    ',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'
    ':"",'
    ','
    ','
    ','
    ',this.options.formatLoadingMessage(),"
    ","
    ",'',"bottom"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?'
    ':"","
    ","
    "].join("")),this.$container.insertAfter(this.$el),this.$tableContainer=this.$container.find(".fixed-table-container"),this.$tableHeader=this.$container.find(".fixed-table-header"),this.$tableBody=this.$container.find(".fixed-table-body"),this.$tableLoading=this.$container.find(".fixed-table-loading"),this.$tableFooter=this.$container.find(".fixed-table-footer"),this.$toolbar=this.$container.find(".fixed-table-toolbar"),this.$pagination=this.$container.find(".fixed-table-pagination"),this.$tableBody.append(this.$el),this.$container.after('
    '),this.$el.addClass(this.options.classes),this.options.striped&&this.$el.addClass("table-striped"),-1!==a.inArray("table-no-bordered",this.options.classes.split(" "))&&this.$tableContainer.addClass("table-no-bordered")},p.prototype.initTable=function(){var b=this,c=[],d=[];if(this.$header=this.$el.find(">thead"),this.$header.length||(this.$header=a("").appendTo(this.$el)),this.$header.find("tr").each(function(){var b=[];a(this).find("th").each(function(){"undefined"!=typeof a(this).data("field")&&a(this).data("field",a(this).data("field")+""),b.push(a.extend({},{title:a(this).html(),"class":a(this).attr("class"),titleTooltip:a(this).attr("title"),rowspan:a(this).attr("rowspan")?+a(this).attr("rowspan"):void 0,colspan:a(this).attr("colspan")?+a(this).attr("colspan"):void 0},a(this).data()))}),c.push(b)}),a.isArray(this.options.columns[0])||(this.options.columns=[this.options.columns]),this.options.columns=a.extend(!0,[],c,this.options.columns),this.columns=[],f(this.options.columns),a.each(this.options.columns,function(c,d){a.each(d,function(d,e){e=a.extend({},p.COLUMN_DEFAULTS,e),"undefined"!=typeof e.fieldIndex&&(b.columns[e.fieldIndex]=e),b.options.columns[c][d]=e})}),!this.options.data.length){var e=[];this.$el.find(">tbody>tr").each(function(c){var f={};f._id=a(this).attr("id"),f._class=a(this).attr("class"),f._data=l(a(this).data()),a(this).find(">td").each(function(d){for(var g,h,i=a(this),j=+i.attr("colspan")||1,k=+i.attr("rowspan")||1;e[c]&&e[c][d];d++);for(g=d;d+j>g;g++)for(h=c;c+k>h;h++)e[h]||(e[h]=[]),e[h][g]=!0;var m=b.columns[d].field;f[m]=a(this).html(),f["_"+m+"_id"]=a(this).attr("id"),f["_"+m+"_class"]=a(this).attr("class"),f["_"+m+"_rowspan"]=a(this).attr("rowspan"),f["_"+m+"_colspan"]=a(this).attr("colspan"),f["_"+m+"_title"]=a(this).attr("title"),f["_"+m+"_data"]=l(a(this).data())}),d.push(f)}),this.options.data=d,d.length&&(this.fromHtml=!0)}},p.prototype.initHeader=function(){var b=this,d={},e=[];this.header={fields:[],styles:[],classes:[],formatters:[],events:[],sorters:[],sortNames:[],cellStyles:[],searchables:[]},a.each(this.options.columns,function(f,g){e.push(""),0===f&&!b.options.cardView&&b.options.detailView&&e.push(c('
    ',b.options.columns.length)),a.each(g,function(a,f){var g="",h="",i="",j="",k=c(' class="%s"',f["class"]),l=(b.options.sortOrder||f.order,"px"),m=f.width;if(void 0===f.width||b.options.cardView||"string"==typeof f.width&&-1!==f.width.indexOf("%")&&(l="%"),f.width&&"string"==typeof f.width&&(m=f.width.replace("%","").replace("px","")),h=c("text-align: %s; ",f.halign?f.halign:f.align),i=c("text-align: %s; ",f.align),j=c("vertical-align: %s; ",f.valign),j+=c("width: %s; ",!f.checkbox&&!f.radio||m?m?m+l:void 0:"36px"),"undefined"!=typeof f.fieldIndex){if(b.header.fields[f.fieldIndex]=f.field,b.header.styles[f.fieldIndex]=i+j,b.header.classes[f.fieldIndex]=k,b.header.formatters[f.fieldIndex]=f.formatter,b.header.events[f.fieldIndex]=f.events,b.header.sorters[f.fieldIndex]=f.sorter,b.header.sortNames[f.fieldIndex]=f.sortName,b.header.cellStyles[f.fieldIndex]=f.cellStyle,b.header.searchables[f.fieldIndex]=f.searchable,!f.visible)return;if(b.options.cardView&&!f.cardVisible)return;d[f.field]=f}e.push(""),e.push(c('
    ',b.options.sortable&&f.sortable?"sortable both":"")),g=f.title,f.checkbox&&(!b.options.singleSelect&&b.options.checkboxHeader&&(g=''),b.header.stateField=f.field),f.radio&&(g="",b.header.stateField=f.field,b.options.singleSelect=!0),e.push(g),e.push("
    "),e.push('
    '),e.push("
    "),e.push("")}),e.push("")}),this.$header.html(e.join("")),this.$header.find("th[data-field]").each(function(){a(this).data(d[a(this).data("field")])}),this.$container.off("click",".th-inner").on("click",".th-inner",function(c){var d=a(this);return b.options.detailView&&d.closest(".bootstrap-table")[0]!==b.$container[0]?!1:void(b.options.sortable&&d.parent().data().sortable&&b.onSort(c))}),this.$header.children().children().off("keypress").on("keypress",function(c){if(b.options.sortable&&a(this).data().sortable){var d=c.keyCode||c.which;13==d&&b.onSort(c)}}),a(window).off("resize.bootstrap-table"),!this.options.showHeader||this.options.cardView?(this.$header.hide(),this.$tableHeader.hide(),this.$tableLoading.css("top",0)):(this.$header.show(),this.$tableHeader.show(),this.$tableLoading.css("top",this.$header.outerHeight()+1),this.getCaret(),a(window).on("resize.bootstrap-table",a.proxy(this.resetWidth,this))),this.$selectAll=this.$header.find('[name="btSelectAll"]'),this.$selectAll.off("click").on("click",function(){var c=a(this).prop("checked");b[c?"checkAll":"uncheckAll"](),b.updateSelected()})},p.prototype.initFooter=function(){!this.options.showFooter||this.options.cardView?this.$tableFooter.hide():this.$tableFooter.show()},p.prototype.initData=function(a,b){this.data="append"===b?this.data.concat(a):"prepend"===b?[].concat(a).concat(this.data):a||this.options.data,this.options.data="append"===b?this.options.data.concat(a):"prepend"===b?[].concat(a).concat(this.options.data):this.data,"server"!==this.options.sidePagination&&this.initSort()},p.prototype.initSort=function(){var b=this,c=this.options.sortName,d="desc"===this.options.sortOrder?-1:1,e=a.inArray(this.options.sortName,this.header.fields);return this.options.customSort!==a.noop?void this.options.customSort.apply(this,[this.options.sortName,this.options.sortOrder]):void(-1!==e&&(this.options.sortStable&&a.each(this.data,function(a,b){b.hasOwnProperty("_position")||(b._position=a)}),this.data.sort(function(f,g){b.header.sortNames[e]&&(c=b.header.sortNames[e]);var i=m(f,c,b.options.escape),j=m(g,c,b.options.escape),k=h(b.header,b.header.sorters[e],[i,j]);return void 0!==k?d*k:((void 0===i||null===i)&&(i=""),(void 0===j||null===j)&&(j=""),b.options.sortStable&&i===j&&(i=f._position,j=g._position),a.isNumeric(i)&&a.isNumeric(j)?(i=parseFloat(i),j=parseFloat(j),j>i?-1*d:d):i===j?0:("string"!=typeof i&&(i=i.toString()),-1===i.localeCompare(j)?-1*d:d))})))},p.prototype.onSort=function(b){var c="keypress"===b.type?a(b.currentTarget):a(b.currentTarget).parent(),d=this.$header.find("th").eq(c.index());return this.$header.add(this.$header_).find("span.order").remove(),this.options.sortName===c.data("field")?this.options.sortOrder="asc"===this.options.sortOrder?"desc":"asc":(this.options.sortName=c.data("field"),this.options.sortOrder="asc"===c.data("order")?"desc":"asc"),this.trigger("sort",this.options.sortName,this.options.sortOrder),c.add(d).data("order",this.options.sortOrder),this.getCaret(),"server"===this.options.sidePagination?void this.initServer(this.options.silentSort):(this.initSort(),void this.initBody())},p.prototype.initToolbar=function(){var b,d,e=this,f=[],g=0,i=0;this.$toolbar.find(".bs-bars").children().length&&a("body").append(a(this.options.toolbar)),this.$toolbar.html(""),("string"==typeof this.options.toolbar||"object"==typeof this.options.toolbar)&&a(c('
    ',this.options.toolbarAlign)).appendTo(this.$toolbar).append(a(this.options.toolbar)),f=[c('
    ',this.options.buttonsAlign,this.options.buttonsAlign)],"string"==typeof this.options.icons&&(this.options.icons=h(null,this.options.icons)),this.options.showPaginationSwitch&&f.push(c('"),this.options.showRefresh&&f.push(c('"),this.options.showToggle&&f.push(c('"),this.options.showColumns&&(f.push(c('
    ',this.options.formatColumns()),'",'","
    ")),f.push("
    "),(this.showToolbar||f.length>2)&&this.$toolbar.append(f.join("")),this.options.showPaginationSwitch&&this.$toolbar.find('button[name="paginationSwitch"]').off("click").on("click",a.proxy(this.togglePagination,this)),this.options.showRefresh&&this.$toolbar.find('button[name="refresh"]').off("click").on("click",a.proxy(this.refresh,this)),this.options.showToggle&&this.$toolbar.find('button[name="toggle"]').off("click").on("click",function(){e.toggleView()}),this.options.showColumns&&(b=this.$toolbar.find(".keep-open"),i<=this.options.minimumCountColumns&&b.find("input").prop("disabled",!0),b.find("li").off("click").on("click",function(a){a.stopImmediatePropagation()}),b.find("input").off("click").on("click",function(){var b=a(this);e.toggleColumn(a(this).val(),b.prop("checked"),!1),e.trigger("column-switch",a(this).data("field"),b.prop("checked"))})),this.options.search&&(f=[],f.push('"),this.$toolbar.append(f.join("")),d=this.$toolbar.find(".search input"),d.off("keyup drop").on("keyup drop",function(b){e.options.searchOnEnterKey&&13!==b.keyCode||a.inArray(b.keyCode,[37,38,39,40])>-1||(clearTimeout(g),g=setTimeout(function(){e.onSearch(b)},e.options.searchTimeOut))}),n()&&d.off("mouseup").on("mouseup",function(a){clearTimeout(g),g=setTimeout(function(){e.onSearch(a)},e.options.searchTimeOut)}))},p.prototype.onSearch=function(b){var c=a.trim(a(b.currentTarget).val());this.options.trimOnSearch&&a(b.currentTarget).val()!==c&&a(b.currentTarget).val(c),c!==this.searchText&&(this.searchText=c,this.options.searchText=c,this.options.pageNumber=1,this.initSearch(),this.updatePagination(),this.trigger("search",c))},p.prototype.initSearch=function(){var b=this;if("server"!==this.options.sidePagination){if(this.options.customSearch!==a.noop)return void this.options.customSearch.apply(this,[this.searchText]);var c=this.searchText&&(this.options.escape?j(this.searchText):this.searchText).toLowerCase(),d=a.isEmptyObject(this.filterColumns)?null:this.filterColumns;this.data=d?a.grep(this.options.data,function(b){for(var c in d)if(a.isArray(d[c])&&-1===a.inArray(b[c],d[c])||b[c]!==d[c])return!1;return!0}):this.options.data,this.data=c?a.grep(this.data,function(d,f){for(var g=0;g-1&&(n=!0)}this.totalPages=~~((this.options.totalRows-1)/this.options.pageSize)+1,this.options.totalPages=this.totalPages}if(this.totalPages>0&&this.options.pageNumber>this.totalPages&&(this.options.pageNumber=this.totalPages),this.pageFrom=(this.options.pageNumber-1)*this.options.pageSize+1,this.pageTo=this.options.pageNumber*this.options.pageSize,this.pageTo>this.options.totalRows&&(this.pageTo=this.options.totalRows),m.push('
    ','',this.options.onlyInfoPagination?this.options.formatDetailPagination(this.options.totalRows):this.options.formatShowingRows(this.pageFrom,this.pageTo,this.options.totalRows),""),!this.options.onlyInfoPagination){m.push('');var r=[c('',"top"===this.options.paginationVAlign||"both"===this.options.paginationVAlign?"dropdown":"dropup"),'",'"),m.push(this.options.formatRecordsPerPage(r.join(""))),m.push(""),m.push("
    ",'")}this.$pagination.html(m.join("")),this.options.onlyInfoPagination||(f=this.$pagination.find(".page-list a"),g=this.$pagination.find(".page-first"),h=this.$pagination.find(".page-pre"),i=this.$pagination.find(".page-next"),j=this.$pagination.find(".page-last"),k=this.$pagination.find(".page-number"),this.options.smartDisplay&&(this.totalPages<=1&&this.$pagination.find("div.pagination").hide(),(p.length<2||this.options.totalRows<=p[0])&&this.$pagination.find("span.page-list").hide(),this.$pagination[this.getData().length?"show":"hide"]()),n&&(this.options.pageSize=this.options.formatAllRows()),f.off("click").on("click",a.proxy(this.onPageListChange,this)),g.off("click").on("click",a.proxy(this.onPageFirst,this)),h.off("click").on("click",a.proxy(this.onPagePre,this)),i.off("click").on("click",a.proxy(this.onPageNext,this)),j.off("click").on("click",a.proxy(this.onPageLast,this)),k.off("click").on("click",a.proxy(this.onPageNumber,this)))},p.prototype.updatePagination=function(b){b&&a(b.currentTarget).hasClass("disabled")||(this.options.maintainSelected||this.resetRows(),this.initPagination(),"server"===this.options.sidePagination?this.initServer():this.initBody(),this.trigger("page-change",this.options.pageNumber,this.options.pageSize))},p.prototype.onPageListChange=function(b){var c=a(b.currentTarget);c.parent().addClass("active").siblings().removeClass("active"),this.options.pageSize=c.text().toUpperCase()===this.options.formatAllRows().toUpperCase()?this.options.formatAllRows():+c.text(),this.$toolbar.find(".page-size").text(this.options.pageSize),this.updatePagination(b)},p.prototype.onPageFirst=function(a){this.options.pageNumber=1,this.updatePagination(a)},p.prototype.onPagePre=function(a){this.options.pageNumber-1===0?this.options.pageNumber=this.options.totalPages:this.options.pageNumber--,this.updatePagination(a)},p.prototype.onPageNext=function(a){this.options.pageNumber+1>this.options.totalPages?this.options.pageNumber=1:this.options.pageNumber++,this.updatePagination(a)},p.prototype.onPageLast=function(a){this.options.pageNumber=this.totalPages,this.updatePagination(a)},p.prototype.onPageNumber=function(b){this.options.pageNumber!==+a(b.currentTarget).text()&&(this.options.pageNumber=+a(b.currentTarget).text(),this.updatePagination(b))},p.prototype.initBody=function(b){var f=this,g=[],i=this.getData();this.trigger("pre-body",i),this.$body=this.$el.find(">tbody"),this.$body.length||(this.$body=a("").appendTo(this.$el)),this.options.pagination&&"server"!==this.options.sidePagination||(this.pageFrom=1,this.pageTo=i.length);for(var k=this.pageFrom-1;k"),this.options.cardView&&g.push(c('
    ',this.header.fields.length)),!this.options.cardView&&this.options.detailView&&g.push("",'',c('',this.options.iconsPrefix,this.options.icons.detailOpen),"",""),a.each(this.header.fields,function(b,e){var i="",j=m(n,e,f.options.escape),l="",q={},r="",s=f.header.classes[b],t="",u="",v="",w="",x=f.columns[b];if(!(f.fromHtml&&"undefined"==typeof j||!x.visible||f.options.cardView&&!x.cardVisible)){if(o=c('style="%s"',p.concat(f.header.styles[b]).join("; ")),n["_"+e+"_id"]&&(r=c(' id="%s"',n["_"+e+"_id"])),n["_"+e+"_class"]&&(s=c(' class="%s"',n["_"+e+"_class"])),n["_"+e+"_rowspan"]&&(u=c(' rowspan="%s"',n["_"+e+"_rowspan"])),n["_"+e+"_colspan"]&&(v=c(' colspan="%s"',n["_"+e+"_colspan"])),n["_"+e+"_title"]&&(w=c(' title="%s"',n["_"+e+"_title"])),q=h(f.header,f.header.cellStyles[b],[j,n,k,e],q),q.classes&&(s=c(' class="%s"',q.classes)),q.css){var y=[];for(var z in q.css)y.push(z+": "+q.css[z]);o=c('style="%s"',y.concat(f.header.styles[b]).join("; "))}j=h(x,f.header.formatters[b],[j,n,k],j),n["_"+e+"_data"]&&!a.isEmptyObject(n["_"+e+"_data"])&&a.each(n["_"+e+"_data"],function(a,b){"index"!==a&&(t+=c(' data-%s="%s"',a,b))}),x.checkbox||x.radio?(l=x.checkbox?"checkbox":l,l=x.radio?"radio":l,i=[c(f.options.cardView?'
    ':'',x["class"]||""),"",f.header.formatters[b]&&"string"==typeof j?j:"",f.options.cardView?"
    ":""].join(""),n[f.header.stateField]=j===!0||j&&j.checked):(j="undefined"==typeof j||null===j?f.options.undefinedText:j,i=f.options.cardView?['
    ',f.options.showHeader?c('%s',o,d(f.columns,"field","title",e)):"",c('%s',j),"
    "].join(""):[c("",r,s,o,t,u,v,w),j,""].join(""),f.options.cardView&&f.options.smartDisplay&&""===j&&(i='
    ')),g.push(i)}}),this.options.cardView&&g.push("
    "),g.push("")}g.length||g.push('',c('%s',this.$header.find("th").length,this.options.formatNoMatches()),""),this.$body.html(g.join("")),b||this.scrollTo(0),this.$body.find("> tr[data-index] > td").off("click dblclick").on("click dblclick",function(b){var d=a(this),g=d.parent(),h=f.data[g.data("index")],i=d[0].cellIndex,j=f.getVisibleFields(),k=j[f.options.detailView&&!f.options.cardView?i-1:i],l=f.columns[e(f.columns,k)],n=m(h,k,f.options.escape);if(!d.find(".detail-icon").length&&(f.trigger("click"===b.type?"click-cell":"dbl-click-cell",k,n,h,d),f.trigger("click"===b.type?"click-row":"dbl-click-row",h,g,k), +"click"===b.type&&f.options.clickToSelect&&l.clickToSelect)){var o=g.find(c('[name="%s"]',f.options.selectItemName));o.length&&o[0].click()}}),this.$body.find("> tr[data-index] > td > .detail-icon").off("click").on("click",function(){var b=a(this),d=b.parent().parent(),e=d.data("index"),g=i[e];if(d.next().is("tr.detail-view"))b.find("i").attr("class",c("%s %s",f.options.iconsPrefix,f.options.icons.detailOpen)),d.next().remove(),f.trigger("collapse-row",e,g);else{b.find("i").attr("class",c("%s %s",f.options.iconsPrefix,f.options.icons.detailClose)),d.after(c('',d.find("td").length));var j=d.next().find("td"),k=h(f.options,f.options.detailFormatter,[e,g,j],"");1===j.length&&j.append(k),f.trigger("expand-row",e,g,j)}f.resetView()}),this.$selectItem=this.$body.find(c('[name="%s"]',this.options.selectItemName)),this.$selectItem.off("click").on("click",function(b){b.stopImmediatePropagation();var c=a(this),d=c.prop("checked"),e=f.data[c.data("index")];f.options.maintainSelected&&a(this).is(":radio")&&a.each(f.options.data,function(a,b){b[f.header.stateField]=!1}),e[f.header.stateField]=d,f.options.singleSelect&&(f.$selectItem.not(this).each(function(){f.data[a(this).data("index")][f.header.stateField]=!1}),f.$selectItem.filter(":checked").not(this).prop("checked",!1)),f.updateSelected(),f.trigger(d?"check":"uncheck",e,c)}),a.each(this.header.events,function(b,c){if(c){"string"==typeof c&&(c=h(null,c));var d=f.header.fields[b],e=a.inArray(d,f.getVisibleFields());f.options.detailView&&!f.options.cardView&&(e+=1);for(var g in c)f.$body.find(">tr:not(.no-records-found)").each(function(){var b=a(this),h=b.find(f.options.cardView?".card-view":"td").eq(e),i=g.indexOf(" "),j=g.substring(0,i),k=g.substring(i+1),l=c[g];h.find(k).off(j).on(j,function(a){var c=b.data("index"),e=f.data[c],g=e[d];l.apply(this,[a,g,e,c])})})}}),this.updateSelected(),this.resetView(),this.trigger("post-body",i)},p.prototype.initServer=function(b,c,d){var e,f=this,g={},i={searchText:this.searchText,sortName:this.options.sortName,sortOrder:this.options.sortOrder};this.options.pagination&&(i.pageSize=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize,i.pageNumber=this.options.pageNumber),(d||this.options.url||this.options.ajax)&&("limit"===this.options.queryParamsType&&(i={search:i.searchText,sort:i.sortName,order:i.sortOrder},this.options.pagination&&(i.offset=this.options.pageSize===this.options.formatAllRows()?0:this.options.pageSize*(this.options.pageNumber-1),i.limit=this.options.pageSize===this.options.formatAllRows()?this.options.totalRows:this.options.pageSize)),a.isEmptyObject(this.filterColumnsPartial)||(i.filter=JSON.stringify(this.filterColumnsPartial,null)),g=h(this.options,this.options.queryParams,[i],g),a.extend(g,c||{}),g!==!1&&(b||this.$tableLoading.show(),e=a.extend({},h(null,this.options.ajaxOptions),{type:this.options.method,url:d||this.options.url,data:"application/json"===this.options.contentType&&"post"===this.options.method?JSON.stringify(g):g,cache:this.options.cache,contentType:this.options.contentType,dataType:this.options.dataType,success:function(a){a=h(f.options,f.options.responseHandler,[a],a),f.load(a),f.trigger("load-success",a),b||f.$tableLoading.hide()},error:function(a){f.trigger("load-error",a.status,a),b||f.$tableLoading.hide()}}),this.options.ajax?h(this,this.options.ajax,[e],null):(this._xhr&&4!==this._xhr.readyState&&this._xhr.abort(),this._xhr=a.ajax(e))))},p.prototype.initSearchText=function(){if(this.options.search&&""!==this.options.searchText){var a=this.$toolbar.find(".search input");a.val(this.options.searchText),this.onSearch({currentTarget:a})}},p.prototype.getCaret=function(){var b=this;a.each(this.$header.find("th"),function(c,d){a(d).find(".sortable").removeClass("desc asc").addClass(a(d).data("field")===b.options.sortName?b.options.sortOrder:"both")})},p.prototype.updateSelected=function(){var b=this.$selectItem.filter(":enabled").length&&this.$selectItem.filter(":enabled").length===this.$selectItem.filter(":enabled").filter(":checked").length;this.$selectAll.add(this.$selectAll_).prop("checked",b),this.$selectItem.each(function(){a(this).closest("tr")[a(this).prop("checked")?"addClass":"removeClass"]("selected")})},p.prototype.updateRows=function(){var b=this;this.$selectItem.each(function(){b.data[a(this).data("index")][b.header.stateField]=a(this).prop("checked")})},p.prototype.resetRows=function(){var b=this;a.each(this.data,function(a,c){b.$selectAll.prop("checked",!1),b.$selectItem.prop("checked",!1),b.header.stateField&&(c[b.header.stateField]=!1)})},p.prototype.trigger=function(b){var c=Array.prototype.slice.call(arguments,1);b+=".bs.table",this.options[p.EVENTS[b]].apply(this.options,c),this.$el.trigger(a.Event(b),c),this.options.onAll(b,c),this.$el.trigger(a.Event("all.bs.table"),[b,c])},p.prototype.resetHeader=function(){clearTimeout(this.timeoutId_),this.timeoutId_=setTimeout(a.proxy(this.fitHeader,this),this.$el.is(":hidden")?100:0)},p.prototype.fitHeader=function(){var b,d,e,f,h=this;if(h.$el.is(":hidden"))return void(h.timeoutId_=setTimeout(a.proxy(h.fitHeader,h),100));if(b=this.$tableBody.get(0),d=b.scrollWidth>b.clientWidth&&b.scrollHeight>b.clientHeight+this.$header.outerHeight()?g():0,this.$el.css("margin-top",-this.$header.outerHeight()),e=a(":focus"),e.length>0){var i=e.parents("th");if(i.length>0){var j=i.attr("data-field");if(void 0!==j){var k=this.$header.find("[data-field='"+j+"']");k.length>0&&k.find(":input").addClass("focus-temp")}}}this.$header_=this.$header.clone(!0,!0),this.$selectAll_=this.$header_.find('[name="btSelectAll"]'),this.$tableHeader.css({"margin-right":d}).find("table").css("width",this.$el.outerWidth()).html("").attr("class",this.$el.attr("class")).append(this.$header_),f=a(".focus-temp:visible:eq(0)"),f.length>0&&(f.focus(),this.$header.find(".focus-temp").removeClass("focus-temp")),this.$header.find("th[data-field]").each(function(){h.$header_.find(c('th[data-field="%s"]',a(this).data("field"))).data(a(this).data())});var l=this.getVisibleFields(),m=this.$header_.find("th");this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(b){var d=a(this),e=b;h.options.detailView&&!h.options.cardView&&(0===b&&h.$header_.find("th.detail").find(".fht-cell").width(d.innerWidth()),e=b-1);var f=h.$header_.find(c('th[data-field="%s"]',l[e]));f.length>1&&(f=a(m[d[0].cellIndex])),f.find(".fht-cell").width(d.innerWidth())}),this.$tableBody.off("scroll").on("scroll",function(){h.$tableHeader.scrollLeft(a(this).scrollLeft()),h.options.showFooter&&!h.options.cardView&&h.$tableFooter.scrollLeft(a(this).scrollLeft())}),h.trigger("post-header")},p.prototype.resetFooter=function(){var b=this,d=b.getData(),e=[];this.options.showFooter&&!this.options.cardView&&(!this.options.cardView&&this.options.detailView&&e.push('
     
    '),a.each(this.columns,function(a,f){var g,i="",j="",k=[],l={},m=c(' class="%s"',f["class"]);if(f.visible&&(!b.options.cardView||f.cardVisible)){if(i=c("text-align: %s; ",f.falign?f.falign:f.align),j=c("vertical-align: %s; ",f.valign),l=h(null,b.options.footerStyle),l&&l.css)for(g in l.css)k.push(g+": "+l.css[g]);e.push(""),e.push('
    '),e.push(h(f,f.footerFormatter,[d]," ")||" "),e.push("
    "),e.push('
    '),e.push(""),e.push("")}}),this.$tableFooter.find("tr").html(e.join("")),this.$tableFooter.show(),clearTimeout(this.timeoutFooter_),this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),this.$el.is(":hidden")?100:0))},p.prototype.fitFooter=function(){var b,c,d;return clearTimeout(this.timeoutFooter_),this.$el.is(":hidden")?void(this.timeoutFooter_=setTimeout(a.proxy(this.fitFooter,this),100)):(c=this.$el.css("width"),d=c>this.$tableBody.width()?g():0,this.$tableFooter.css({"margin-right":d}).find("table").css("width",c).attr("class",this.$el.attr("class")),b=this.$tableFooter.find("td"),void this.$body.find(">tr:first-child:not(.no-records-found) > *").each(function(c){var d=a(this);b.eq(c).find(".fht-cell").width(d.innerWidth())}))},p.prototype.toggleColumn=function(a,b,d){if(-1!==a&&(this.columns[a].visible=b,this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns)){var e=this.$toolbar.find(".keep-open input").prop("disabled",!1);d&&e.filter(c('[value="%s"]',a)).prop("checked",b),e.filter(":checked").length<=this.options.minimumCountColumns&&e.filter(":checked").prop("disabled",!0)}},p.prototype.toggleRow=function(a,b,d){-1!==a&&this.$body.find("undefined"!=typeof a?c('tr[data-index="%s"]',a):c('tr[data-uniqueid="%s"]',b))[d?"show":"hide"]()},p.prototype.getVisibleFields=function(){var b=this,c=[];return a.each(this.header.fields,function(a,d){var f=b.columns[e(b.columns,d)];f.visible&&c.push(d)}),c},p.prototype.resetView=function(a){var b=0;if(a&&a.height&&(this.options.height=a.height),this.$selectAll.prop("checked",this.$selectItem.length>0&&this.$selectItem.length===this.$selectItem.filter(":checked").length),this.options.height){var c=k(this.$toolbar),d=k(this.$pagination),e=this.options.height-c-d;this.$tableContainer.css("height",e+"px")}return this.options.cardView?(this.$el.css("margin-top","0"),this.$tableContainer.css("padding-bottom","0"),void this.$tableFooter.hide()):(this.options.showHeader&&this.options.height?(this.$tableHeader.show(),this.resetHeader(),b+=this.$header.outerHeight()):(this.$tableHeader.hide(),this.trigger("post-header")),this.options.showFooter&&(this.resetFooter(),this.options.height&&(b+=this.$tableFooter.outerHeight()+1)),this.getCaret(),this.$tableContainer.css("padding-bottom",b+"px"),void this.trigger("reset-view"))},p.prototype.getData=function(b){return!this.searchText&&a.isEmptyObject(this.filterColumns)&&a.isEmptyObject(this.filterColumnsPartial)?b?this.options.data.slice(this.pageFrom-1,this.pageTo):this.options.data:b?this.data.slice(this.pageFrom-1,this.pageTo):this.data},p.prototype.load=function(b){var c=!1;"server"===this.options.sidePagination?(this.options.totalRows=b.total,c=b.fixedScroll,b=b[this.options.dataField]):a.isArray(b)||(c=b.fixedScroll,b=b.data),this.initData(b),this.initSearch(),this.initPagination(),this.initBody(c)},p.prototype.append=function(a){this.initData(a,"append"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},p.prototype.prepend=function(a){this.initData(a,"prepend"),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0)},p.prototype.remove=function(b){var c,d,e=this.options.data.length;if(b.hasOwnProperty("field")&&b.hasOwnProperty("values")){for(c=e-1;c>=0;c--)d=this.options.data[c],d.hasOwnProperty(b.field)&&-1!==a.inArray(d[b.field],b.values)&&this.options.data.splice(c,1);e!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))}},p.prototype.removeAll=function(){this.options.data.length>0&&(this.options.data.splice(0,this.options.data.length),this.initSearch(),this.initPagination(),this.initBody(!0))},p.prototype.getRowByUniqueId=function(a){var b,c,d,e=this.options.uniqueId,f=this.options.data.length,g=null;for(b=f-1;b>=0;b--){if(c=this.options.data[b],c.hasOwnProperty(e))d=c[e];else{if(!c._data.hasOwnProperty(e))continue;d=c._data[e]}if("string"==typeof d?a=a.toString():"number"==typeof d&&(Number(d)===d&&d%1===0?a=parseInt(a):d===Number(d)&&0!==d&&(a=parseFloat(a))),d===a){g=c;break}}return g},p.prototype.removeByUniqueId=function(a){var b=this.options.data.length,c=this.getRowByUniqueId(a);c&&this.options.data.splice(this.options.data.indexOf(c),1),b!==this.options.data.length&&(this.initSearch(),this.initPagination(),this.initBody(!0))},p.prototype.updateByUniqueId=function(b){var c=this,d=a.isArray(b)?b:[b];a.each(d,function(b,d){var e;d.hasOwnProperty("id")&&d.hasOwnProperty("row")&&(e=a.inArray(c.getRowByUniqueId(d.id),c.options.data),-1!==e&&a.extend(c.options.data[e],d.row))}),this.initSearch(),this.initSort(),this.initBody(!0)},p.prototype.insertRow=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("row")&&(this.data.splice(a.index,0,a.row),this.initSearch(),this.initPagination(),this.initSort(),this.initBody(!0))},p.prototype.updateRow=function(b){var c=this,d=a.isArray(b)?b:[b];a.each(d,function(b,d){d.hasOwnProperty("index")&&d.hasOwnProperty("row")&&a.extend(c.options.data[d.index],d.row)}),this.initSearch(),this.initSort(),this.initBody(!0)},p.prototype.showRow=function(a){(a.hasOwnProperty("index")||a.hasOwnProperty("uniqueId"))&&this.toggleRow(a.index,a.uniqueId,!0)},p.prototype.hideRow=function(a){(a.hasOwnProperty("index")||a.hasOwnProperty("uniqueId"))&&this.toggleRow(a.index,a.uniqueId,!1)},p.prototype.getRowsHidden=function(b){var c=a(this.$body[0]).children().filter(":hidden"),d=0;if(b)for(;dtr");if(this.options.detailView&&!this.options.cardView&&(g+=1),e=j.eq(f).find(">td").eq(g),!(0>f||0>g||f>=this.data.length)){for(c=f;f+h>c;c++)for(d=g;g+i>d;d++)j.eq(c).find(">td").eq(d).hide();e.attr("rowspan",h).attr("colspan",i).show()}},p.prototype.updateCell=function(a){a.hasOwnProperty("index")&&a.hasOwnProperty("field")&&a.hasOwnProperty("value")&&(this.data[a.index][a.field]=a.value,a.reinit!==!1&&(this.initSort(),this.initBody(!0)))},p.prototype.getOptions=function(){return this.options},p.prototype.getSelections=function(){var b=this;return a.grep(this.options.data,function(a){return a[b.header.stateField]})},p.prototype.getAllSelections=function(){var b=this;return a.grep(this.options.data,function(a){return a[b.header.stateField]})},p.prototype.checkAll=function(){this.checkAll_(!0)},p.prototype.uncheckAll=function(){this.checkAll_(!1)},p.prototype.checkInvert=function(){var b=this,c=b.$selectItem.filter(":enabled"),d=c.filter(":checked");c.each(function(){a(this).prop("checked",!a(this).prop("checked"))}),b.updateRows(),b.updateSelected(),b.trigger("uncheck-some",d),d=b.getSelections(),b.trigger("check-some",d)},p.prototype.checkAll_=function(a){var b;a||(b=this.getSelections()),this.$selectAll.add(this.$selectAll_).prop("checked",a),this.$selectItem.filter(":enabled").prop("checked",a),this.updateRows(),a&&(b=this.getSelections()),this.trigger(a?"check-all":"uncheck-all",b)},p.prototype.check=function(a){this.check_(!0,a)},p.prototype.uncheck=function(a){this.check_(!1,a)},p.prototype.check_=function(a,b){var d=this.$selectItem.filter(c('[data-index="%s"]',b)).prop("checked",a);this.data[b][this.header.stateField]=a,this.updateSelected(),this.trigger(a?"check":"uncheck",this.data[b],d)},p.prototype.checkBy=function(a){this.checkBy_(!0,a)},p.prototype.uncheckBy=function(a){this.checkBy_(!1,a)},p.prototype.checkBy_=function(b,d){if(d.hasOwnProperty("field")&&d.hasOwnProperty("values")){var e=this,f=[];a.each(this.options.data,function(g,h){if(!h.hasOwnProperty(d.field))return!1;if(-1!==a.inArray(h[d.field],d.values)){var i=e.$selectItem.filter(":enabled").filter(c('[data-index="%s"]',g)).prop("checked",b);h[e.header.stateField]=b,f.push(h),e.trigger(b?"check":"uncheck",h,i)}}),this.updateSelected(),this.trigger(b?"check-some":"uncheck-some",f)}},p.prototype.destroy=function(){this.$el.insertBefore(this.$container),a(this.options.toolbar).insertBefore(this.$el),this.$container.next().remove(),this.$container.remove(),this.$el.html(this.$el_.html()).css("margin-top","0").attr("class",this.$el_.attr("class")||"")},p.prototype.showLoading=function(){this.$tableLoading.show()},p.prototype.hideLoading=function(){this.$tableLoading.hide()},p.prototype.togglePagination=function(){this.options.pagination=!this.options.pagination;var a=this.$toolbar.find('button[name="paginationSwitch"] i');this.options.pagination?a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchDown):a.attr("class",this.options.iconsPrefix+" "+this.options.icons.paginationSwitchUp),this.updatePagination()},p.prototype.refresh=function(a){a&&a.url&&(this.options.pageNumber=1),this.initServer(a&&a.silent,a&&a.query,a&&a.url),this.trigger("refresh",a)},p.prototype.resetWidth=function(){this.options.showHeader&&this.options.height&&this.fitHeader(),this.options.showFooter&&this.fitFooter()},p.prototype.showColumn=function(a){this.toggleColumn(e(this.columns,a),!0,!0)},p.prototype.hideColumn=function(a){this.toggleColumn(e(this.columns,a),!1,!0)},p.prototype.getHiddenColumns=function(){return a.grep(this.columns,function(a){return!a.visible})},p.prototype.getVisibleColumns=function(){return a.grep(this.columns,function(a){return a.visible})},p.prototype.toggleAllColumns=function(b){if(a.each(this.columns,function(a){this.columns[a].visible=b}),this.initHeader(),this.initSearch(),this.initPagination(),this.initBody(),this.options.showColumns){var c=this.$toolbar.find(".keep-open input").prop("disabled",!1);c.filter(":checked").length<=this.options.minimumCountColumns&&c.filter(":checked").prop("disabled",!0)}},p.prototype.showAllColumns=function(){this.toggleAllColumns(!0)},p.prototype.hideAllColumns=function(){this.toggleAllColumns(!1)},p.prototype.filterBy=function(b){this.filterColumns=a.isEmptyObject(b)?{}:b,this.options.pageNumber=1,this.initSearch(),this.updatePagination()},p.prototype.scrollTo=function(a){return"string"==typeof a&&(a="bottom"===a?this.$tableBody[0].scrollHeight:0),"number"==typeof a&&this.$tableBody.scrollTop(a),"undefined"==typeof a?this.$tableBody.scrollTop():void 0},p.prototype.getScrollPosition=function(){return this.scrollTo()},p.prototype.selectPage=function(a){a>0&&a<=this.options.totalPages&&(this.options.pageNumber=a,this.updatePagination())},p.prototype.prevPage=function(){this.options.pageNumber>1&&(this.options.pageNumber--,this.updatePagination())},p.prototype.nextPage=function(){this.options.pageNumber tr[data-index="%s"]',b));d.next().is("tr.detail-view")===(a?!1:!0)&&d.find("> td > .detail-icon").click()},p.prototype.expandRow=function(a){this.expandRow_(!0,a)},p.prototype.collapseRow=function(a){this.expandRow_(!1,a)},p.prototype.expandAllRows=function(b){if(b){var d=this.$body.find(c('> tr[data-index="%s"]',0)),e=this,f=null,g=!1,h=-1;if(d.next().is("tr.detail-view")?d.next().next().is("tr.detail-view")||(d.next().find(".detail-icon").click(),g=!0):(d.find("> td > .detail-icon").click(),g=!0),g)try{h=setInterval(function(){f=e.$body.find("tr.detail-view").last().find(".detail-icon"),f.length>0?f.click():clearInterval(h)},1)}catch(i){clearInterval(h)}}else for(var j=this.$body.children(),k=0;k.btn-group"),g=f.find("div.export");if(!g.length){g=a(['
    ','",'","
    "].join("")).appendTo(f);var h=g.find(".dropdown-menu"),i=this.options.exportTypes;if("string"==typeof this.options.exportTypes){var j=this.options.exportTypes.slice(1,-1).replace(/ /g,"").split(",");i=[],a.each(j,function(a,b){i.push(b.slice(1,-1))})}a.each(i,function(a,b){c.hasOwnProperty(b)&&h.append(['
  • ','',c[b],"","
  • "].join(""))}),h.find("li").click(function(){var b=a(this).data("type"),c=function(){d.$el.tableExport(a.extend({},d.options.exportOptions,{type:b,escape:!1}))};if("all"===d.options.exportDataType&&d.options.pagination)d.$el.one("server"===d.options.sidePagination?"post-body.bs.table":"page-change.bs.table",function(){c(),d.togglePagination()}),d.togglePagination();else if("selected"===d.options.exportDataType){var e=d.getData(),f=d.getAllSelections();d.load(f),c(),d.load(e)}else c()})}}}}(jQuery); diff --git a/web/gui/v1/lib/bootstrap-toggle-2.2.2.min.js b/web/gui/v1/lib/bootstrap-toggle-2.2.2.min.js new file mode 100644 index 00000000..a11e156f --- /dev/null +++ b/web/gui/v1/lib/bootstrap-toggle-2.2.2.min.js @@ -0,0 +1,10 @@ +/*! ======================================================================== + * Bootstrap Toggle: bootstrap-toggle.js v2.2.0 + * http://www.bootstraptoggle.com + * ======================================================================== + * Copyright 2014 Min Hur, The New York Times Company + * Licensed under MIT + * SPDX-License-Identifier: MIT + * ======================================================================== */ ++function(a){"use strict";function b(b){return this.each(function(){var d=a(this),e=d.data("bs.toggle"),f="object"==typeof b&&b;e||d.data("bs.toggle",e=new c(this,f)),"string"==typeof b&&e[b]&&e[b]()})}var c=function(b,c){this.$element=a(b),this.options=a.extend({},this.defaults(),c),this.render()};c.VERSION="2.2.0",c.DEFAULTS={on:"On",off:"Off",onstyle:"primary",offstyle:"default",size:"normal",style:"",width:null,height:null},c.prototype.defaults=function(){return{on:this.$element.attr("data-on")||c.DEFAULTS.on,off:this.$element.attr("data-off")||c.DEFAULTS.off,onstyle:this.$element.attr("data-onstyle")||c.DEFAULTS.onstyle,offstyle:this.$element.attr("data-offstyle")||c.DEFAULTS.offstyle,size:this.$element.attr("data-size")||c.DEFAULTS.size,style:this.$element.attr("data-style")||c.DEFAULTS.style,width:this.$element.attr("data-width")||c.DEFAULTS.width,height:this.$element.attr("data-height")||c.DEFAULTS.height}},c.prototype.render=function(){this._onstyle="btn-"+this.options.onstyle,this._offstyle="btn-"+this.options.offstyle;var b="large"===this.options.size?"btn-lg":"small"===this.options.size?"btn-sm":"mini"===this.options.size?"btn-xs":"",c=a('