remove dist/ from git (use release branch or github release for publish)
3
.gitignore
vendored
@@ -30,7 +30,8 @@ awsconfig
|
||||
/tmp
|
||||
vendor/phantomjs/phantomjs
|
||||
|
||||
# dist/
|
||||
# Built plugin
|
||||
dist/
|
||||
|
||||
# locally required config files
|
||||
public/css/*.min.css
|
||||
|
||||
22
dist/README.md
vendored
@@ -1,22 +0,0 @@
|
||||
# Zabbix plugin for Grafana
|
||||
|
||||
[](https://github.com/alexanderzobnin/grafana-zabbix/releases)
|
||||
[](https://github.com/alexanderzobnin/grafana-zabbix/blob/master/CHANGELOG.md)
|
||||
[](http://docs.grafana-zabbix.org)
|
||||
|
||||
Visualize your Zabbix metrics with the leading open source software for time series analytics.
|
||||
|
||||
### Live Demo
|
||||
|
||||
See all features overview and dashboards examples at Grafana-Zabbix [Live demo](http://play.grafana-zabbix.org) site.
|
||||
|
||||
### Features
|
||||
|
||||
- Select multiple metrics [by using Regex](http://docs.grafana-zabbix.org/guides/gettingstarted/#multiple-items-on-one-graph)
|
||||
- Create interactive and reusable dashboards with [template variables](http://docs.grafana-zabbix.org/guides/templating/)
|
||||
- Show events on graphs with [Annotations](http://docs.grafana.org/reference/annotations/)
|
||||
- Display active problems with Triggers panel
|
||||
- Transform and shape your data with [metric processing functions](http://docs.grafana-zabbix.org/reference/functions/) (Avg, Median, Min, Max, Multiply, Summarize, Time shift, Alias)
|
||||
- Find problems faster with [Alerting](http://docs.grafana-zabbix.org/reference/alerting/) feature
|
||||
- Mix metrics from multiple data sources in the same dashboard or even graph
|
||||
- Discover and share [dashboards](https://grafana.com/dashboards) in the official library
|
||||
1
dist/components/config.html
vendored
@@ -1 +0,0 @@
|
||||
<h3 class="page-heading">Zabbix Plugin Config</h3>
|
||||
27
dist/components/config.js
vendored
@@ -1,27 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var ZabbixAppConfigCtrl;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_export('ZabbixAppConfigCtrl', ZabbixAppConfigCtrl = function ZabbixAppConfigCtrl() {
|
||||
_classCallCheck(this, ZabbixAppConfigCtrl);
|
||||
});
|
||||
|
||||
_export('ZabbixAppConfigCtrl', ZabbixAppConfigCtrl);
|
||||
|
||||
ZabbixAppConfigCtrl.templateUrl = 'components/config.html';
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=config.js.map
|
||||
1
dist/components/config.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/components/config.js"],"names":["ZabbixAppConfigCtrl","templateUrl"],"mappings":";;;;;;;;;;;;;;;;qCAAaA,mB,GACX,+BAAc;AAAA;AAAG,O;;;;AAEnBA,0BAAoBC,WAApB,GAAkC,wBAAlC","file":"config.js","sourcesContent":["export class ZabbixAppConfigCtrl {\n constructor() { }\n}\nZabbixAppConfigCtrl.templateUrl = 'components/config.html';\n"]}
|
||||
127
dist/css/grafana-zabbix.dark.css
vendored
@@ -1,127 +0,0 @@
|
||||
.triggers-panel-scroll {
|
||||
overflow: auto; }
|
||||
|
||||
.triggers-panel-container {
|
||||
position: relative; }
|
||||
.triggers-panel-container .zabbix-trigger-name {
|
||||
font-weight: bold; }
|
||||
.triggers-panel-container .zabbix-hostname {
|
||||
color: #8e8e8e;
|
||||
margin-left: 1rem;
|
||||
font-weight: 500; }
|
||||
.triggers-panel-container .zbx-description {
|
||||
color: #b3b3b3;
|
||||
font-weight: normal;
|
||||
margin-left: 0.6rem; }
|
||||
.triggers-panel-container .zbx-description--newline {
|
||||
margin-left: 0rem; }
|
||||
.triggers-panel-container .zbx-trigger-tags {
|
||||
margin-left: 0.6rem; }
|
||||
.triggers-panel-container .zbx-trigger-tags .zbx-tag {
|
||||
color: #ECECEC;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
margin-right: 4px;
|
||||
padding: 1px 6px;
|
||||
cursor: pointer; }
|
||||
.triggers-panel-container .trigger-info-block {
|
||||
display: flex; }
|
||||
.triggers-panel-container .trigger-info-block i, .triggers-panel-container .trigger-info-block a {
|
||||
margin-right: 0.3rem;
|
||||
color: #8e8e8e; }
|
||||
.triggers-panel-container .zabbix-trigger-source {
|
||||
margin-right: 1.5rem;
|
||||
margin-left: 1rem;
|
||||
font-weight: 500; }
|
||||
.triggers-panel-container .zabbix-trigger-source .gicon-datasources {
|
||||
opacity: 0.4; }
|
||||
|
||||
.zbx-trigger-card {
|
||||
position: relative;
|
||||
padding: 0.5rem 1rem; }
|
||||
|
||||
.zabbix-trigger--blinked {
|
||||
opacity: 0.4;
|
||||
animation: zabbix-triggers-icon 0.8s cubic-bezier(0.46, 0.03, 0.52, 0.96) 0s infinite alternate; }
|
||||
|
||||
.zbx-maintenance-icon {
|
||||
color: #eb7b18; }
|
||||
|
||||
.zbx-trigger-highlighted {
|
||||
color: #fff; }
|
||||
.zbx-trigger-highlighted .alert-rule-item__body,
|
||||
.zbx-trigger-highlighted .alert-rule-item__header,
|
||||
.zbx-trigger-highlighted .alert-rule-item__time,
|
||||
.zbx-trigger-highlighted .zabbix-hostname,
|
||||
.zbx-trigger-highlighted .zbx-description {
|
||||
color: #fff; }
|
||||
.zbx-trigger-highlighted .alert-rule-item__text .zbx-trigger-state,
|
||||
.zbx-trigger-highlighted .alert-rule-item__text .zbx-trigger-severity {
|
||||
color: #fff; }
|
||||
.zbx-trigger-highlighted .zbx-trigger-lastchange .trigger-info-block.zbx-status-icons a, .zbx-trigger-highlighted .zbx-trigger-lastchange .trigger-info-block.zbx-status-icons i {
|
||||
color: #fff; }
|
||||
|
||||
@keyframes zabbix-triggers-icon {
|
||||
100% {
|
||||
opacity: 1; } }
|
||||
|
||||
.triggers-panel-footer {
|
||||
text-align: center;
|
||||
font-size: 90%;
|
||||
line-height: 2px;
|
||||
padding-top: 4px; }
|
||||
.triggers-panel-footer ul {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
margin-left: 0;
|
||||
margin-bottom: 0; }
|
||||
.triggers-panel-footer ul > li {
|
||||
display: inline; }
|
||||
.triggers-panel-footer ul > li > a {
|
||||
float: left;
|
||||
padding: 4px 12px;
|
||||
text-decoration: none;
|
||||
border-left-width: 0; }
|
||||
.triggers-panel-footer ul > li > a:hover {
|
||||
background-color: #333; }
|
||||
.triggers-panel-footer ul > li > a.active {
|
||||
font-weight: bold;
|
||||
color: #33b5e5; }
|
||||
|
||||
.ack-tooltip .drop-content {
|
||||
max-width: 70rem !important;
|
||||
min-width: 30rem !important; }
|
||||
|
||||
.ack-tooltip .ack-comments {
|
||||
width: 60%; }
|
||||
|
||||
.ack-tooltip .ack-add-button {
|
||||
padding-top: 1rem; }
|
||||
|
||||
.ack-tooltip table td, .ack-tooltip th {
|
||||
padding-right: 1rem; }
|
||||
|
||||
.ack-tooltip .ack-input-group {
|
||||
padding-top: 1rem; }
|
||||
.ack-tooltip .ack-input-group input {
|
||||
border: 1px solid;
|
||||
border-radius: 2px;
|
||||
width: 50%; }
|
||||
.ack-tooltip .ack-input-group button {
|
||||
margin-left: 1rem; }
|
||||
|
||||
.triggers-severity-config.gf-form-label {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
border-radius: 0px; }
|
||||
|
||||
.triggers-severity-config .icon-gf {
|
||||
font-size: 200%; }
|
||||
|
||||
.zbx-regex {
|
||||
color: #d69e2e; }
|
||||
|
||||
.zbx-variable {
|
||||
color: #32d1df; }
|
||||
|
||||
/*# sourceMappingURL=grafana-zabbix.dark.css.map */
|
||||
14
dist/css/grafana-zabbix.dark.css.map
vendored
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"file": "grafana-zabbix.dark.css",
|
||||
"sources": [
|
||||
"../../src/sass/grafana-zabbix.dark.scss",
|
||||
"../../src/sass/_variables.dark.scss",
|
||||
"../../src/sass/grafana-zabbix.scss",
|
||||
"../../src/sass/_variables.scss",
|
||||
"../../src/sass/_panel-triggers.scss",
|
||||
"../../src/sass/_query_editor.scss"
|
||||
],
|
||||
"mappings": "AIAA,AAAA,sBAAsB,CAAC;EACrB,QAAQ,EAAE,IAAK,GAChB;;AAED,AAAA,yBAAyB,CAAC;EACxB,QAAQ,EAAE,QAAS,GAoDpB;EArDD,AAGE,yBAHuB,CAGvB,oBAAoB,CAAC;IACnB,WAAW,EAAE,IAAK,GACnB;EALH,AAOE,yBAPuB,CAOvB,gBAAgB,CAAC;IACf,KAAK,EHHU,OAAO;IGItB,WAAW,EAAE,IAAK;IAClB,WAAW,EAAE,GAAI,GAClB;EAXH,AAaE,yBAbuB,CAavB,gBAAgB,CAAC;IACf,KAAK,EHRU,OAAO;IGStB,WAAW,EAAE,MAAO;IACpB,WAAW,EAAE,MAAO,GAKrB;IArBH,AAaE,yBAbuB,CAavB,yBAAgB,CAKH;MACT,WAAW,EAAE,IAAK,GACnB;EApBL,AAuBE,yBAvBuB,CAuBvB,iBAAiB,CAAC;IAChB,WAAW,EAAE,MAAO,GAUrB;IAlCH,AA0BI,yBA1BqB,CAuBvB,iBAAiB,CAGf,QAAQ,CAAC;MACP,KAAK,EHnBQ,OAAO;MGoBpB,WAAW,EAAE,GAAI;MACjB,SAAS,EAAE,IAAK;MAChB,YAAY,EAAE,GAAI;MAClB,OAAO,EAAE,OAAQ;MACjB,MAAM,EAAE,OAAQ,GACjB;EAjCL,AAoCE,yBApCuB,CAoCvB,mBAAmB,CAAC;IAClB,OAAO,EAAE,IAAK,GAMf;IA3CH,AAuCI,yBAvCqB,CAoCvB,mBAAmB,CAGjB,CAAC,EAvCL,AAuCO,yBAvCkB,CAoCvB,mBAAmB,CAGd,CAAC,CAAC;MACH,YAAY,EAAE,MAAO;MACrB,KAAK,EHpCQ,OAAO,GGqCrB;EA1CL,AA6CE,yBA7CuB,CA6CvB,sBAAsB,CAAC;IACrB,YAAY,EAAE,MAAO;IACrB,WAAW,EAAE,IAAK;IAClB,WAAW,EAAE,GAAI,GAIlB;IApDH,AAiDI,yBAjDqB,CA6CvB,sBAAsB,CAIpB,kBAAkB,CAAC;MACjB,OAAO,EAAE,GAAI,GACd;;AAIL,AAAA,iBAAiB,CAAC;EAChB,QAAQ,EAAE,QAAS;EACnB,OAAO,EAAE,WAAY,GACtB;;AAED,AAAA,wBAAe,CACF;EACT,OAAO,EAAE,GAAI;EACb,SAAS,EAAE,oBAAoB,CAAC,IAAI,CAAC,oCAAY,CAAyB,EAAE,CAAC,QAAQ,CAAC,SAAS,GAChG;;AAGH,AAAA,qBAAqB,CAAC;EACpB,KAAK,EH5CY,OAAO,GG6CzB;;AAED,AAAA,wBAAwB,CAAC;EACvB,KAAK,EH3DY,IAAI,GGiFtB;EAvBD,AAGE,wBAHsB,CAGtB,sBAAsB;EAHxB,AAIE,wBAJsB,CAItB,wBAAwB;EAJ1B,AAKE,wBALsB,CAKtB,sBAAsB;EALxB,AAME,wBANsB,CAMtB,gBAAgB;EANlB,AAOE,wBAPsB,CAOtB,gBAAgB,CAAC;IACf,KAAK,EHlEU,IAAI,GGmEpB;EATH,AAYI,wBAZoB,CAWtB,sBAAsB,CACpB,kBAAkB;EAZtB,AAaI,wBAboB,CAWtB,sBAAsB,CAEpB,qBAAqB,CAAC;IACpB,KAAK,EHxEQ,IAAI,GGyElB;EAfL,AAmBI,wBAnBoB,CAkBtB,uBAAuB,CAAC,mBAAmB,AAAA,iBAAiB,CAC1D,CAAC,EAnBL,AAmBO,wBAnBiB,CAkBtB,uBAAuB,CAAC,mBAAmB,AAAA,iBAAiB,CACvD,CAAC,CAAC;IACH,KAAK,EH9EQ,IAAI,GG+ElB;;AAIL,UAAU,CAAV,oBAAU;EACR,AAAA,IAAI;IACF,OAAO,EAAE,CAAE;;AAIf,AAAA,sBAAsB,CAAC;EACrB,UAAU,EAAE,MAAO;EACnB,SAAS,EAAE,GAAI;EACf,WAAW,EAAE,GAAI;EACjB,WAAW,EAAE,GAAI,GA0BlB;EA9BD,AAME,sBANoB,CAMpB,EAAE,CAAC;IACD,QAAQ,EAAE,QAAS;IACnB,OAAO,EAAE,YAAa;IACtB,WAAW,EAAE,CAAE;IACf,aAAa,EAAE,CAAE,GAClB;EAXH,AAYO,sBAZe,CAYpB,EAAE,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,MAAO,GACjB;EAdH,AAeY,sBAfU,CAepB,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACV,KAAK,EAAE,IAAK;IACZ,OAAO,EAAE,QAAS;IAClB,eAAe,EAAE,IAAK;IACtB,iBAAiB,EAAE,CAAE,GAUtB;IA7BH,AAeY,sBAfU,CAepB,EAAE,GAAG,EAAE,GAAG,CAAC,AAMR,MAAM,CAAC;MACN,gBAAgB,EH7FE,IAAI,GG8FvB;IAvBL,AAeY,sBAfU,CAepB,EAAE,GAAG,EAAE,GAAG,CAAC,AAUR,OAAO,CAAC;MACP,WAAW,EAAE,IAAK;MAClB,KAAK,EHhHQ,OAAO,GGiHrB;;AAIL,AACE,YADU,CACV,aAAa,CAAC;EAEZ,SAAS,EAAE,gBAAiB;EAC5B,SAAS,EAAE,gBAAiB,GAC7B;;AALH,AAOE,YAPU,CAOV,aAAa,CAAC;EACZ,KAAK,EAAE,GAAI,GACZ;;AATH,AAWE,YAXU,CAWV,eAAe,CAAC;EACd,WAAW,EAAE,IAAK,GACnB;;AAbH,AAeQ,YAfI,CAeV,KAAK,CAAC,EAAE,EAfV,AAeY,YAfA,CAeA,EAAE,CAAC;EACX,aAAa,EAAE,IAAK,GACrB;;AAjBH,AAmBE,YAnBU,CAmBV,gBAAgB,CAAC;EACf,WAAW,EAAE,IAAK,GAWnB;EA/BH,AAsBI,YAtBQ,CAmBV,gBAAgB,CAGd,KAAK,CAAC;IACJ,MAAM,EAAE,SAAU;IAClB,aAAa,EAAE,GAAI;IACnB,KAAK,EAAE,GAAI,GACZ;EA1BL,AA4BI,YA5BQ,CAmBV,gBAAgB,CASd,MAAM,CAAC;IACL,WAAW,EAAE,IAAK,GACnB;;AAIL,AAAA,yBAAyB,AACtB,cAAc,CAAC;EACd,WAAW,EAAE,GAAI;EACjB,cAAc,EAAE,GAAI;EACpB,aAAa,EAAE,GAAI,GACpB;;AALH,AAOE,yBAPuB,CAOvB,QAAQ,CAAC;EACP,SAAS,EAAE,IAAK,GACjB;;ACrLH,AAAA,UAAU,CAAC;EACT,KAAK,EJ6BY,OAAO,GI5BzB;;AAED,AAAA,aAAa,CAAC;EACZ,KAAK,EJwBY,OAAO,GIvBzB",
|
||||
"names": []
|
||||
}
|
||||
127
dist/css/grafana-zabbix.light.css
vendored
@@ -1,127 +0,0 @@
|
||||
.triggers-panel-scroll {
|
||||
overflow: auto; }
|
||||
|
||||
.triggers-panel-container {
|
||||
position: relative; }
|
||||
.triggers-panel-container .zabbix-trigger-name {
|
||||
font-weight: bold; }
|
||||
.triggers-panel-container .zabbix-hostname {
|
||||
color: #767980;
|
||||
margin-left: 1rem;
|
||||
font-weight: 500; }
|
||||
.triggers-panel-container .zbx-description {
|
||||
color: #acb6bf;
|
||||
font-weight: normal;
|
||||
margin-left: 0.6rem; }
|
||||
.triggers-panel-container .zbx-description--newline {
|
||||
margin-left: 0rem; }
|
||||
.triggers-panel-container .zbx-trigger-tags {
|
||||
margin-left: 0.6rem; }
|
||||
.triggers-panel-container .zbx-trigger-tags .zbx-tag {
|
||||
color: #e9edf2;
|
||||
font-weight: 500;
|
||||
font-size: 12px;
|
||||
margin-right: 4px;
|
||||
padding: 1px 6px;
|
||||
cursor: pointer; }
|
||||
.triggers-panel-container .trigger-info-block {
|
||||
display: flex; }
|
||||
.triggers-panel-container .trigger-info-block i, .triggers-panel-container .trigger-info-block a {
|
||||
margin-right: 0.3rem;
|
||||
color: #767980; }
|
||||
.triggers-panel-container .zabbix-trigger-source {
|
||||
margin-right: 1.5rem;
|
||||
margin-left: 1rem;
|
||||
font-weight: 500; }
|
||||
.triggers-panel-container .zabbix-trigger-source .gicon-datasources {
|
||||
opacity: 0.4; }
|
||||
|
||||
.zbx-trigger-card {
|
||||
position: relative;
|
||||
padding: 0.5rem 1rem; }
|
||||
|
||||
.zabbix-trigger--blinked {
|
||||
opacity: 0.4;
|
||||
animation: zabbix-triggers-icon 0.8s cubic-bezier(0.46, 0.03, 0.52, 0.96) 0s infinite alternate; }
|
||||
|
||||
.zbx-maintenance-icon {
|
||||
color: #ff7941; }
|
||||
|
||||
.zbx-trigger-highlighted {
|
||||
color: #000; }
|
||||
.zbx-trigger-highlighted .alert-rule-item__body,
|
||||
.zbx-trigger-highlighted .alert-rule-item__header,
|
||||
.zbx-trigger-highlighted .alert-rule-item__time,
|
||||
.zbx-trigger-highlighted .zabbix-hostname,
|
||||
.zbx-trigger-highlighted .zbx-description {
|
||||
color: #000; }
|
||||
.zbx-trigger-highlighted .alert-rule-item__text .zbx-trigger-state,
|
||||
.zbx-trigger-highlighted .alert-rule-item__text .zbx-trigger-severity {
|
||||
color: #000; }
|
||||
.zbx-trigger-highlighted .zbx-trigger-lastchange .trigger-info-block.zbx-status-icons a, .zbx-trigger-highlighted .zbx-trigger-lastchange .trigger-info-block.zbx-status-icons i {
|
||||
color: #000; }
|
||||
|
||||
@keyframes zabbix-triggers-icon {
|
||||
100% {
|
||||
opacity: 1; } }
|
||||
|
||||
.triggers-panel-footer {
|
||||
text-align: center;
|
||||
font-size: 90%;
|
||||
line-height: 2px;
|
||||
padding-top: 4px; }
|
||||
.triggers-panel-footer ul {
|
||||
position: relative;
|
||||
display: inline-block;
|
||||
margin-left: 0;
|
||||
margin-bottom: 0; }
|
||||
.triggers-panel-footer ul > li {
|
||||
display: inline; }
|
||||
.triggers-panel-footer ul > li > a {
|
||||
float: left;
|
||||
padding: 4px 12px;
|
||||
text-decoration: none;
|
||||
border-left-width: 0; }
|
||||
.triggers-panel-footer ul > li > a:hover {
|
||||
background-color: #dde4ed; }
|
||||
.triggers-panel-footer ul > li > a.active {
|
||||
font-weight: bold;
|
||||
color: #1ca4d6; }
|
||||
|
||||
.ack-tooltip .drop-content {
|
||||
max-width: 70rem !important;
|
||||
min-width: 30rem !important; }
|
||||
|
||||
.ack-tooltip .ack-comments {
|
||||
width: 60%; }
|
||||
|
||||
.ack-tooltip .ack-add-button {
|
||||
padding-top: 1rem; }
|
||||
|
||||
.ack-tooltip table td, .ack-tooltip th {
|
||||
padding-right: 1rem; }
|
||||
|
||||
.ack-tooltip .ack-input-group {
|
||||
padding-top: 1rem; }
|
||||
.ack-tooltip .ack-input-group input {
|
||||
border: 1px solid;
|
||||
border-radius: 2px;
|
||||
width: 50%; }
|
||||
.ack-tooltip .ack-input-group button {
|
||||
margin-left: 1rem; }
|
||||
|
||||
.triggers-severity-config.gf-form-label {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
border-radius: 0px; }
|
||||
|
||||
.triggers-severity-config .icon-gf {
|
||||
font-size: 200%; }
|
||||
|
||||
.zbx-regex {
|
||||
color: #aa7b1d; }
|
||||
|
||||
.zbx-variable {
|
||||
color: #1ca4d6; }
|
||||
|
||||
/*# sourceMappingURL=grafana-zabbix.light.css.map */
|
||||
14
dist/css/grafana-zabbix.light.css.map
vendored
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"version": 3,
|
||||
"file": "grafana-zabbix.light.css",
|
||||
"sources": [
|
||||
"../../src/sass/grafana-zabbix.light.scss",
|
||||
"../../src/sass/_variables.light.scss",
|
||||
"../../src/sass/grafana-zabbix.scss",
|
||||
"../../src/sass/_variables.scss",
|
||||
"../../src/sass/_panel-triggers.scss",
|
||||
"../../src/sass/_query_editor.scss"
|
||||
],
|
||||
"mappings": "AIAA,AAAA,sBAAsB,CAAC;EACrB,QAAQ,EAAE,IAAK,GAChB;;AAED,AAAA,yBAAyB,CAAC;EACxB,QAAQ,EAAE,QAAS,GAoDpB;EArDD,AAGE,yBAHuB,CAGvB,oBAAoB,CAAC;IACnB,WAAW,EAAE,IAAK,GACnB;EALH,AAOE,yBAPuB,CAOvB,gBAAgB,CAAC;IACf,KAAK,EHHU,OAAO;IGItB,WAAW,EAAE,IAAK;IAClB,WAAW,EAAE,GAAI,GAClB;EAXH,AAaE,yBAbuB,CAavB,gBAAgB,CAAC;IACf,KAAK,EHRU,OAAO;IGStB,WAAW,EAAE,MAAO;IACpB,WAAW,EAAE,MAAO,GAKrB;IArBH,AAaE,yBAbuB,CAavB,yBAAgB,CAKH;MACT,WAAW,EAAE,IAAK,GACnB;EApBL,AAuBE,yBAvBuB,CAuBvB,iBAAiB,CAAC;IAChB,WAAW,EAAE,MAAO,GAUrB;IAlCH,AA0BI,yBA1BqB,CAuBvB,iBAAiB,CAGf,QAAQ,CAAC;MACP,KAAK,EHlBQ,OAAO;MGmBpB,WAAW,EAAE,GAAI;MACjB,SAAS,EAAE,IAAK;MAChB,YAAY,EAAE,GAAI;MAClB,OAAO,EAAE,OAAQ;MACjB,MAAM,EAAE,OAAQ,GACjB;EAjCL,AAoCE,yBApCuB,CAoCvB,mBAAmB,CAAC;IAClB,OAAO,EAAE,IAAK,GAMf;IA3CH,AAuCI,yBAvCqB,CAoCvB,mBAAmB,CAGjB,CAAC,EAvCL,AAuCO,yBAvCkB,CAoCvB,mBAAmB,CAGd,CAAC,CAAC;MACH,YAAY,EAAE,MAAO;MACrB,KAAK,EHpCQ,OAAO,GGqCrB;EA1CL,AA6CE,yBA7CuB,CA6CvB,sBAAsB,CAAC;IACrB,YAAY,EAAE,MAAO;IACrB,WAAW,EAAE,IAAK;IAClB,WAAW,EAAE,GAAI,GAIlB;IApDH,AAiDI,yBAjDqB,CA6CvB,sBAAsB,CAIpB,kBAAkB,CAAC;MACjB,OAAO,EAAE,GAAI,GACd;;AAIL,AAAA,iBAAiB,CAAC;EAChB,QAAQ,EAAE,QAAS;EACnB,OAAO,EAAE,WAAY,GACtB;;AAED,AAAA,wBAAe,CACF;EACT,OAAO,EAAE,GAAI;EACb,SAAS,EAAE,oBAAoB,CAAC,IAAI,CAAC,oCAAY,CAAyB,EAAE,CAAC,QAAQ,CAAC,SAAS,GAChG;;AAGH,AAAA,qBAAqB,CAAC;EACpB,KAAK,EH/CY,OAAO,GGgDzB;;AAED,AAAA,wBAAwB,CAAC;EACvB,KAAK,EH1EY,IAAI,GGgGtB;EAvBD,AAGE,wBAHsB,CAGtB,sBAAsB;EAHxB,AAIE,wBAJsB,CAItB,wBAAwB;EAJ1B,AAKE,wBALsB,CAKtB,sBAAsB;EALxB,AAME,wBANsB,CAMtB,gBAAgB;EANlB,AAOE,wBAPsB,CAOtB,gBAAgB,CAAC;IACf,KAAK,EHjFU,IAAI,GGkFpB;EATH,AAYI,wBAZoB,CAWtB,sBAAsB,CACpB,kBAAkB;EAZtB,AAaI,wBAboB,CAWtB,sBAAsB,CAEpB,qBAAqB,CAAC;IACpB,KAAK,EHvFQ,IAAI,GGwFlB;EAfL,AAmBI,wBAnBoB,CAkBtB,uBAAuB,CAAC,mBAAmB,AAAA,iBAAiB,CAC1D,CAAC,EAnBL,AAmBO,wBAnBiB,CAkBtB,uBAAuB,CAAC,mBAAmB,AAAA,iBAAiB,CACvD,CAAC,CAAC;IACH,KAAK,EH7FQ,IAAI,GG8FlB;;AAIL,UAAU,CAAV,oBAAU;EACR,AAAA,IAAI;IACF,OAAO,EAAE,CAAE;;AAIf,AAAA,sBAAsB,CAAC;EACrB,UAAU,EAAE,MAAO;EACnB,SAAS,EAAE,GAAI;EACf,WAAW,EAAE,GAAI;EACjB,WAAW,EAAE,GAAI,GA0BlB;EA9BD,AAME,sBANoB,CAMpB,EAAE,CAAC;IACD,QAAQ,EAAE,QAAS;IACnB,OAAO,EAAE,YAAa;IACtB,WAAW,EAAE,CAAE;IACf,aAAa,EAAE,CAAE,GAClB;EAXH,AAYO,sBAZe,CAYpB,EAAE,GAAG,EAAE,CAAC;IACN,OAAO,EAAE,MAAO,GACjB;EAdH,AAeY,sBAfU,CAepB,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACV,KAAK,EAAE,IAAK;IACZ,OAAO,EAAE,QAAS;IAClB,eAAe,EAAE,IAAK;IACtB,iBAAiB,EAAE,CAAE,GAUtB;IA7BH,AAeY,sBAfU,CAepB,EAAE,GAAG,EAAE,GAAG,CAAC,AAMR,MAAM,CAAC;MACN,gBAAgB,EHpHH,OAAO,GGqHrB;IAvBL,AAeY,sBAfU,CAepB,EAAE,GAAG,EAAE,GAAG,CAAC,AAUR,OAAO,CAAC;MACP,WAAW,EAAE,IAAK;MAClB,KAAK,EHjHQ,OAAO,GGkHrB;;AAIL,AACE,YADU,CACV,aAAa,CAAC;EAEZ,SAAS,EAAE,gBAAiB;EAC5B,SAAS,EAAE,gBAAiB,GAC7B;;AALH,AAOE,YAPU,CAOV,aAAa,CAAC;EACZ,KAAK,EAAE,GAAI,GACZ;;AATH,AAWE,YAXU,CAWV,eAAe,CAAC;EACd,WAAW,EAAE,IAAK,GACnB;;AAbH,AAeQ,YAfI,CAeV,KAAK,CAAC,EAAE,EAfV,AAeY,YAfA,CAeA,EAAE,CAAC;EACX,aAAa,EAAE,IAAK,GACrB;;AAjBH,AAmBE,YAnBU,CAmBV,gBAAgB,CAAC;EACf,WAAW,EAAE,IAAK,GAWnB;EA/BH,AAsBI,YAtBQ,CAmBV,gBAAgB,CAGd,KAAK,CAAC;IACJ,MAAM,EAAE,SAAU;IAClB,aAAa,EAAE,GAAI;IACnB,KAAK,EAAE,GAAI,GACZ;EA1BL,AA4BI,YA5BQ,CAmBV,gBAAgB,CASd,MAAM,CAAC;IACL,WAAW,EAAE,IAAK,GACnB;;AAIL,AAAA,yBAAyB,AACtB,cAAc,CAAC;EACd,WAAW,EAAE,GAAI;EACjB,cAAc,EAAE,GAAI;EACpB,aAAa,EAAE,GAAI,GACpB;;AALH,AAOE,yBAPuB,CAOvB,QAAQ,CAAC;EACP,SAAS,EAAE,IAAK,GACjB;;ACrLH,AAAA,UAAU,CAAC;EACT,KAAK,EJ4BY,OAAO,GI3BzB;;AAED,AAAA,aAAa,CAAC;EACZ,KAAK,EJeY,OAAO,GIdzB",
|
||||
"names": []
|
||||
}
|
||||
447
dist/dashboards/template_linux_server.json
vendored
@@ -1,447 +0,0 @@
|
||||
{
|
||||
"__inputs": [
|
||||
{
|
||||
"name": "DS_NAME",
|
||||
"type": "datasource",
|
||||
"pluginId": "alexanderzobnin-zabbix-datasource"
|
||||
}
|
||||
],
|
||||
"title": "Zabbix Template Linux Server",
|
||||
"revision": 1,
|
||||
"annotations": {
|
||||
"list": []
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"hideControls": false,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"rows": [
|
||||
{
|
||||
"collapse": false,
|
||||
"height": "250px",
|
||||
"panels": [
|
||||
{
|
||||
"aliasColors": {
|
||||
"CPU iowait time": "#B7DBAB",
|
||||
"CPU system time": "#BF1B00",
|
||||
"CPU user time": "#EAB839"
|
||||
},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "${DS_NAME}",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fill": 3,
|
||||
"grid": {},
|
||||
"id": 1,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 1,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"percentage": false,
|
||||
"pointradius": 2,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"span": 6,
|
||||
"stack": true,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": "CPU"
|
||||
},
|
||||
"countTriggers": true,
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "$group"
|
||||
},
|
||||
"host": {
|
||||
"filter": "$host"
|
||||
},
|
||||
"item": {
|
||||
"filter": "/CPU/"
|
||||
},
|
||||
"minSeverity": 3,
|
||||
"mode": 0,
|
||||
"options": {
|
||||
"showDisabledItems": false
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "CPU",
|
||||
"tooltip": {
|
||||
"msResolution": false,
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "percent",
|
||||
"logBase": 1,
|
||||
"max": 100,
|
||||
"min": 0,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"aliasColors": {
|
||||
"Processor load (1 min average per core)": "#1F78C1"
|
||||
},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "${DS_NAME}",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fill": 1,
|
||||
"grid": {},
|
||||
"id": 2,
|
||||
"legend": {
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [],
|
||||
"spaceLength": 10,
|
||||
"span": 6,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": "CPU"
|
||||
},
|
||||
"countTriggers": true,
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "$group"
|
||||
},
|
||||
"host": {
|
||||
"filter": "$host"
|
||||
},
|
||||
"item": {
|
||||
"filter": "Processor load (15 min average per core)"
|
||||
},
|
||||
"minSeverity": 3,
|
||||
"mode": 0,
|
||||
"options": {
|
||||
"showDisabledItems": false
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "System load",
|
||||
"tooltip": {
|
||||
"msResolution": false,
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "cumulative"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": 0,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"repeat": null,
|
||||
"repeatIteration": null,
|
||||
"repeatRowId": null,
|
||||
"showTitle": true,
|
||||
"title": "CPU",
|
||||
"titleSize": "h6"
|
||||
},
|
||||
{
|
||||
"collapse": false,
|
||||
"height": "250px",
|
||||
"panels": [
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"dashLength": 10,
|
||||
"dashes": false,
|
||||
"datasource": "${DS_NAME}",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fill": 3,
|
||||
"grid": {},
|
||||
"id": 3,
|
||||
"legend": {
|
||||
"alignAsTable": false,
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"rightSide": false,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"minSpan": 4,
|
||||
"nullPointMode": "connected",
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"repeat": "netif",
|
||||
"seriesOverrides": [
|
||||
{
|
||||
"alias": "/Incoming/",
|
||||
"transform": "negative-Y"
|
||||
}
|
||||
],
|
||||
"spaceLength": 10,
|
||||
"span": 12,
|
||||
"stack": false,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": ""
|
||||
},
|
||||
"countTriggers": true,
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "$group"
|
||||
},
|
||||
"host": {
|
||||
"filter": "$host"
|
||||
},
|
||||
"item": {
|
||||
"filter": "/$netif/"
|
||||
},
|
||||
"minSeverity": 3,
|
||||
"mode": 0,
|
||||
"options": {
|
||||
"showDisabledItems": false
|
||||
},
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": [],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "Network traffic on $netif",
|
||||
"tooltip": {
|
||||
"msResolution": false,
|
||||
"shared": true,
|
||||
"sort": 0,
|
||||
"value_type": "cumulative"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"buckets": null,
|
||||
"mode": "time",
|
||||
"name": null,
|
||||
"show": true,
|
||||
"values": []
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "bps",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"repeat": null,
|
||||
"repeatIteration": null,
|
||||
"repeatRowId": null,
|
||||
"showTitle": true,
|
||||
"title": "Network",
|
||||
"titleSize": "h6"
|
||||
}
|
||||
],
|
||||
"schemaVersion": 14,
|
||||
"style": "dark",
|
||||
"tags": [
|
||||
"zabbix",
|
||||
"example"
|
||||
],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"allFormat": "regex values",
|
||||
"allValue": null,
|
||||
"current": {},
|
||||
"datasource": "${DS_NAME}",
|
||||
"hide": 0,
|
||||
"includeAll": false,
|
||||
"label": "Group",
|
||||
"multi": false,
|
||||
"multiFormat": "glob",
|
||||
"name": "group",
|
||||
"options": [],
|
||||
"query": "*",
|
||||
"refresh": 1,
|
||||
"refresh_on_load": false,
|
||||
"regex": "",
|
||||
"sort": 0,
|
||||
"tagValuesQuery": "",
|
||||
"tags": [],
|
||||
"tagsQuery": "",
|
||||
"type": "query",
|
||||
"useTags": false
|
||||
},
|
||||
{
|
||||
"allFormat": "glob",
|
||||
"allValue": null,
|
||||
"current": {},
|
||||
"datasource": "${DS_NAME}",
|
||||
"hide": 0,
|
||||
"includeAll": false,
|
||||
"label": "Host",
|
||||
"multi": false,
|
||||
"multiFormat": "glob",
|
||||
"name": "host",
|
||||
"options": [],
|
||||
"query": "$group.*",
|
||||
"refresh": 1,
|
||||
"refresh_on_load": false,
|
||||
"regex": "",
|
||||
"sort": 0,
|
||||
"tagValuesQuery": "",
|
||||
"tags": [],
|
||||
"tagsQuery": "",
|
||||
"type": "query",
|
||||
"useTags": false
|
||||
},
|
||||
{
|
||||
"allFormat": "regex values",
|
||||
"allValue": null,
|
||||
"current": {},
|
||||
"datasource": "${DS_NAME}",
|
||||
"hide": 0,
|
||||
"hideLabel": false,
|
||||
"includeAll": true,
|
||||
"label": "Network interface",
|
||||
"multi": true,
|
||||
"multiFormat": "regex values",
|
||||
"name": "netif",
|
||||
"options": [],
|
||||
"query": "*.$host.Network interfaces.*",
|
||||
"refresh": 1,
|
||||
"refresh_on_load": false,
|
||||
"regex": "/(?:Incoming|Outgoing) network traffic on (.*)/",
|
||||
"sort": 0,
|
||||
"tagValuesQuery": "",
|
||||
"tags": [],
|
||||
"tagsQuery": "",
|
||||
"type": "query",
|
||||
"useTags": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": {
|
||||
"from": "now-3h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"now": true,
|
||||
"refresh_intervals": [
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"3h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"time_options": [
|
||||
"5m",
|
||||
"15m",
|
||||
"1h",
|
||||
"6h",
|
||||
"12h",
|
||||
"24h",
|
||||
"2d",
|
||||
"7d",
|
||||
"30d"
|
||||
]
|
||||
},
|
||||
"timezone": "browser"
|
||||
}
|
||||
646
dist/dashboards/zabbix_server_dashboard.json
vendored
@@ -1,646 +0,0 @@
|
||||
{
|
||||
"id": null,
|
||||
"title": "Zabbix Server Dashboard",
|
||||
"originalTitle": "Zabbix Server Dashboard",
|
||||
"tags": [
|
||||
"zabbix",
|
||||
"example"
|
||||
],
|
||||
"style": "dark",
|
||||
"timezone": "browser",
|
||||
"editable": true,
|
||||
"hideControls": false,
|
||||
"sharedCrosshair": false,
|
||||
"rows": [
|
||||
{
|
||||
"collapse": false,
|
||||
"editable": true,
|
||||
"height": "100px",
|
||||
"panels": [
|
||||
{
|
||||
"cacheTimeout": null,
|
||||
"colorBackground": false,
|
||||
"colorValue": false,
|
||||
"colors": [
|
||||
"rgba(245, 54, 54, 0.9)",
|
||||
"rgba(237, 129, 40, 0.89)",
|
||||
"rgba(50, 172, 45, 0.97)"
|
||||
],
|
||||
"datasource": "$datasource",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"format": "none",
|
||||
"id": 3,
|
||||
"interval": null,
|
||||
"isNew": true,
|
||||
"links": [],
|
||||
"maxDataPoints": 100,
|
||||
"nullPointMode": "connected",
|
||||
"nullText": null,
|
||||
"postfix": "",
|
||||
"postfixFontSize": "50%",
|
||||
"prefix": "",
|
||||
"prefixFontSize": "50%",
|
||||
"span": 4,
|
||||
"sparkline": {
|
||||
"fillColor": "rgba(31, 118, 189, 0.18)",
|
||||
"full": false,
|
||||
"lineColor": "rgb(31, 120, 193)",
|
||||
"show": false
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": "General"
|
||||
},
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "Zabbix servers"
|
||||
},
|
||||
"host": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"item": {
|
||||
"filter": "Host name"
|
||||
},
|
||||
"mode": 2,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": "",
|
||||
"title": "Host name",
|
||||
"type": "singlestat",
|
||||
"valueFontSize": "80%",
|
||||
"valueMaps": [
|
||||
{
|
||||
"op": "=",
|
||||
"text": "N/A",
|
||||
"value": "null"
|
||||
}
|
||||
],
|
||||
"valueName": "avg"
|
||||
},
|
||||
{
|
||||
"cacheTimeout": null,
|
||||
"colorBackground": false,
|
||||
"colorValue": false,
|
||||
"colors": [
|
||||
"rgba(245, 54, 54, 0.9)",
|
||||
"rgba(237, 129, 40, 0.89)",
|
||||
"rgba(50, 172, 45, 0.97)"
|
||||
],
|
||||
"datasource": "$datasource",
|
||||
"decimals": 0,
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"format": "s",
|
||||
"id": 4,
|
||||
"interval": null,
|
||||
"isNew": true,
|
||||
"links": [],
|
||||
"maxDataPoints": "",
|
||||
"nullPointMode": "connected",
|
||||
"nullText": null,
|
||||
"postfix": "",
|
||||
"postfixFontSize": "50%",
|
||||
"prefix": "",
|
||||
"prefixFontSize": "50%",
|
||||
"span": 4,
|
||||
"sparkline": {
|
||||
"fillColor": "rgba(31, 118, 189, 0.18)",
|
||||
"full": false,
|
||||
"lineColor": "rgb(31, 120, 193)",
|
||||
"show": false
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": "General"
|
||||
},
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "Zabbix servers"
|
||||
},
|
||||
"host": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"item": {
|
||||
"filter": "System uptime"
|
||||
},
|
||||
"mode": 0,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": "",
|
||||
"title": "Uptime",
|
||||
"type": "singlestat",
|
||||
"valueFontSize": "80%",
|
||||
"valueMaps": [
|
||||
{
|
||||
"op": "=",
|
||||
"text": "N/A",
|
||||
"value": "null"
|
||||
}
|
||||
],
|
||||
"valueName": "current"
|
||||
},
|
||||
{
|
||||
"cacheTimeout": null,
|
||||
"colorBackground": false,
|
||||
"colorValue": false,
|
||||
"colors": [
|
||||
"rgba(245, 54, 54, 0.9)",
|
||||
"rgba(237, 129, 40, 0.89)",
|
||||
"rgba(50, 172, 45, 0.97)"
|
||||
],
|
||||
"datasource": "$datasource",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"format": "none",
|
||||
"id": 5,
|
||||
"interval": null,
|
||||
"isNew": true,
|
||||
"links": [],
|
||||
"maxDataPoints": "",
|
||||
"nullPointMode": "connected",
|
||||
"nullText": null,
|
||||
"postfix": "",
|
||||
"postfixFontSize": "50%",
|
||||
"prefix": "",
|
||||
"prefixFontSize": "50%",
|
||||
"span": 4,
|
||||
"sparkline": {
|
||||
"fillColor": "rgba(31, 118, 189, 0.18)",
|
||||
"full": false,
|
||||
"lineColor": "rgb(31, 120, 193)",
|
||||
"show": false
|
||||
},
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "Zabbix servers"
|
||||
},
|
||||
"host": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"item": {
|
||||
"filter": "/Required performance of Zabbix server/"
|
||||
},
|
||||
"mode": 0,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"thresholds": "",
|
||||
"title": "Required performance, NVPS",
|
||||
"type": "singlestat",
|
||||
"valueFontSize": "80%",
|
||||
"valueMaps": [
|
||||
{
|
||||
"op": "=",
|
||||
"text": "N/A",
|
||||
"value": "null"
|
||||
}
|
||||
],
|
||||
"valueName": "current"
|
||||
}
|
||||
],
|
||||
"title": "General"
|
||||
},
|
||||
{
|
||||
"collapse": false,
|
||||
"editable": true,
|
||||
"height": "300px",
|
||||
"panels": [
|
||||
{
|
||||
"aliasColors": {},
|
||||
"bars": false,
|
||||
"datasource": "$datasource",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fill": 1,
|
||||
"grid": {
|
||||
"threshold1": null,
|
||||
"threshold1Color": "rgba(216, 200, 27, 0.27)",
|
||||
"threshold2": null,
|
||||
"threshold2Color": "rgba(234, 112, 112, 0.22)"
|
||||
},
|
||||
"id": 1,
|
||||
"isNew": true,
|
||||
"legend": {
|
||||
"alignAsTable": true,
|
||||
"avg": false,
|
||||
"current": false,
|
||||
"max": false,
|
||||
"min": false,
|
||||
"rightSide": true,
|
||||
"show": true,
|
||||
"total": false,
|
||||
"values": false
|
||||
},
|
||||
"lines": true,
|
||||
"linewidth": 2,
|
||||
"links": [],
|
||||
"nullPointMode": "connected",
|
||||
"percentage": false,
|
||||
"pointradius": 5,
|
||||
"points": false,
|
||||
"renderer": "flot",
|
||||
"seriesOverrides": [
|
||||
{
|
||||
"alias": "/user/",
|
||||
"color": "#1F78C1"
|
||||
},
|
||||
{
|
||||
"alias": "/system/",
|
||||
"color": "#BF1B00"
|
||||
},
|
||||
{
|
||||
"alias": "/iowait/",
|
||||
"color": "#E5AC0E"
|
||||
}
|
||||
],
|
||||
"span": 7,
|
||||
"stack": true,
|
||||
"steppedLine": false,
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": "CPU"
|
||||
},
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "Zabbix servers"
|
||||
},
|
||||
"host": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"item": {
|
||||
"filter": "/CPU (?!idle)/"
|
||||
},
|
||||
"mode": 0,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"title": "CPU",
|
||||
"tooltip": {
|
||||
"msResolution": false,
|
||||
"shared": true,
|
||||
"value_type": "individual"
|
||||
},
|
||||
"type": "graph",
|
||||
"xaxis": {
|
||||
"show": true
|
||||
},
|
||||
"yaxes": [
|
||||
{
|
||||
"format": "percent",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
},
|
||||
{
|
||||
"format": "short",
|
||||
"label": null,
|
||||
"logBase": 1,
|
||||
"max": null,
|
||||
"min": null,
|
||||
"show": true
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"columns": [
|
||||
{
|
||||
"text": "Current",
|
||||
"value": "current"
|
||||
},
|
||||
{
|
||||
"text": "Avg",
|
||||
"value": "avg"
|
||||
}
|
||||
],
|
||||
"datasource": "$datasource",
|
||||
"editable": true,
|
||||
"error": false,
|
||||
"fontSize": "100%",
|
||||
"id": 2,
|
||||
"isNew": true,
|
||||
"links": [],
|
||||
"pageSize": null,
|
||||
"scroll": true,
|
||||
"showHeader": true,
|
||||
"sort": {
|
||||
"col": 2,
|
||||
"desc": true
|
||||
},
|
||||
"span": 5,
|
||||
"styles": [
|
||||
{
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"pattern": "Time",
|
||||
"type": "date"
|
||||
},
|
||||
{
|
||||
"colorMode": "cell",
|
||||
"colors": [
|
||||
"rgb(41, 170, 106)",
|
||||
"rgba(239, 148, 21, 0.89)",
|
||||
"rgba(239, 10, 10, 0.9)"
|
||||
],
|
||||
"decimals": 1,
|
||||
"pattern": "/.*/",
|
||||
"thresholds": [
|
||||
"50",
|
||||
"80"
|
||||
],
|
||||
"type": "number",
|
||||
"unit": "percent"
|
||||
}
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "Zabbix servers"
|
||||
},
|
||||
"host": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"item": {
|
||||
"filter": "/Zabbix busy/"
|
||||
},
|
||||
"mode": 0,
|
||||
"refId": "A"
|
||||
}
|
||||
],
|
||||
"title": "Zabbix processes",
|
||||
"transform": "timeseries_aggregations",
|
||||
"type": "table"
|
||||
}
|
||||
],
|
||||
"title": "Row"
|
||||
},
|
||||
{
|
||||
"title": "New row",
|
||||
"height": "380",
|
||||
"editable": true,
|
||||
"collapse": false,
|
||||
"panels": [
|
||||
{
|
||||
"title": "Zabbix busy processes",
|
||||
"error": false,
|
||||
"span": 7.069277691711851,
|
||||
"editable": true,
|
||||
"type": "graph",
|
||||
"isNew": true,
|
||||
"id": 6,
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"mode": 0,
|
||||
"group": {
|
||||
"filter": "Zabbix servers"
|
||||
},
|
||||
"host": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"application": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"item": {
|
||||
"filter": "/Zabbix busy/"
|
||||
},
|
||||
"functions": []
|
||||
}
|
||||
],
|
||||
"datasource": "$datasource",
|
||||
"renderer": "flot",
|
||||
"yaxes": [
|
||||
{
|
||||
"label": null,
|
||||
"show": true,
|
||||
"logBase": 1,
|
||||
"min": null,
|
||||
"max": null,
|
||||
"format": "percent"
|
||||
},
|
||||
{
|
||||
"label": null,
|
||||
"show": true,
|
||||
"logBase": 1,
|
||||
"min": null,
|
||||
"max": null,
|
||||
"format": "short"
|
||||
}
|
||||
],
|
||||
"xaxis": {
|
||||
"show": true
|
||||
},
|
||||
"grid": {
|
||||
"threshold1": null,
|
||||
"threshold2": null,
|
||||
"threshold1Color": "rgba(216, 200, 27, 0.27)",
|
||||
"threshold2Color": "rgba(234, 112, 112, 0.22)"
|
||||
},
|
||||
"lines": true,
|
||||
"fill": 0,
|
||||
"linewidth": 2,
|
||||
"points": false,
|
||||
"pointradius": 5,
|
||||
"bars": false,
|
||||
"stack": false,
|
||||
"percentage": false,
|
||||
"legend": {
|
||||
"show": true,
|
||||
"values": false,
|
||||
"min": false,
|
||||
"max": false,
|
||||
"current": false,
|
||||
"total": false,
|
||||
"avg": false,
|
||||
"hideEmpty": true,
|
||||
"hideZero": true,
|
||||
"alignAsTable": true,
|
||||
"rightSide": true
|
||||
},
|
||||
"nullPointMode": "connected",
|
||||
"steppedLine": false,
|
||||
"tooltip": {
|
||||
"value_type": "cumulative",
|
||||
"shared": true,
|
||||
"msResolution": false
|
||||
},
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"aliasColors": {},
|
||||
"seriesOverrides": [],
|
||||
"links": []
|
||||
},
|
||||
{
|
||||
"title": "Zabbix Queue",
|
||||
"error": false,
|
||||
"span": 4.930722308288148,
|
||||
"editable": true,
|
||||
"type": "graph",
|
||||
"isNew": true,
|
||||
"id": 7,
|
||||
"targets": [
|
||||
{
|
||||
"refId": "A",
|
||||
"mode": 0,
|
||||
"group": {
|
||||
"filter": "Zabbix servers"
|
||||
},
|
||||
"host": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"application": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"item": {
|
||||
"filter": "Zabbix queue"
|
||||
},
|
||||
"functions": []
|
||||
},
|
||||
{
|
||||
"refId": "B",
|
||||
"mode": 0,
|
||||
"group": {
|
||||
"filter": "Zabbix servers"
|
||||
},
|
||||
"host": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"application": {
|
||||
"filter": "Zabbix server"
|
||||
},
|
||||
"item": {
|
||||
"filter": "/Values processed/"
|
||||
},
|
||||
"functions": []
|
||||
}
|
||||
],
|
||||
"datasource": "$datasource",
|
||||
"renderer": "flot",
|
||||
"yaxes": [
|
||||
{
|
||||
"label": null,
|
||||
"show": true,
|
||||
"logBase": 1,
|
||||
"min": null,
|
||||
"max": null,
|
||||
"format": "short"
|
||||
},
|
||||
{
|
||||
"label": null,
|
||||
"show": true,
|
||||
"logBase": 1,
|
||||
"min": null,
|
||||
"max": null,
|
||||
"format": "short"
|
||||
}
|
||||
],
|
||||
"xaxis": {
|
||||
"show": true
|
||||
},
|
||||
"grid": {
|
||||
"threshold1": null,
|
||||
"threshold2": null,
|
||||
"threshold1Color": "rgba(216, 200, 27, 0.27)",
|
||||
"threshold2Color": "rgba(234, 112, 112, 0.22)"
|
||||
},
|
||||
"lines": true,
|
||||
"fill": 0,
|
||||
"linewidth": 2,
|
||||
"points": false,
|
||||
"pointradius": 5,
|
||||
"bars": false,
|
||||
"stack": false,
|
||||
"percentage": false,
|
||||
"legend": {
|
||||
"show": true,
|
||||
"values": false,
|
||||
"min": false,
|
||||
"max": false,
|
||||
"current": false,
|
||||
"total": false,
|
||||
"avg": false
|
||||
},
|
||||
"nullPointMode": "connected",
|
||||
"steppedLine": false,
|
||||
"tooltip": {
|
||||
"value_type": "cumulative",
|
||||
"shared": true,
|
||||
"msResolution": false
|
||||
},
|
||||
"timeFrom": null,
|
||||
"timeShift": null,
|
||||
"aliasColors": {},
|
||||
"seriesOverrides": [],
|
||||
"links": []
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"current": {},
|
||||
"hide": 0,
|
||||
"label": "Zabbix Data Source",
|
||||
"name": "datasource",
|
||||
"options": [],
|
||||
"query": "alexanderzobnin-zabbix-datasource",
|
||||
"refresh": 1,
|
||||
"regex": "",
|
||||
"type": "datasource"
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": [
|
||||
"5s",
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"time_options": [
|
||||
"5m",
|
||||
"15m",
|
||||
"1h",
|
||||
"6h",
|
||||
"12h",
|
||||
"24h",
|
||||
"2d",
|
||||
"7d",
|
||||
"30d"
|
||||
]
|
||||
},
|
||||
"annotations": {
|
||||
"list": []
|
||||
},
|
||||
"schemaVersion": 12,
|
||||
"version": 7,
|
||||
"links": []
|
||||
}
|
||||
370
dist/dashboards/zabbix_system_status.json
vendored
@@ -1,370 +0,0 @@
|
||||
{
|
||||
"__inputs": [
|
||||
{
|
||||
"name": "DS_NAME",
|
||||
"type": "datasource",
|
||||
"pluginId": "alexanderzobnin-zabbix-datasource"
|
||||
}
|
||||
],
|
||||
"title": "Zabbix System Status",
|
||||
"revision": "1.0",
|
||||
"annotations": {
|
||||
"list": []
|
||||
},
|
||||
"editable": true,
|
||||
"gnetId": null,
|
||||
"graphTooltip": 0,
|
||||
"hideControls": false,
|
||||
"id": null,
|
||||
"links": [],
|
||||
"rows": [
|
||||
{
|
||||
"collapse": false,
|
||||
"height": 250,
|
||||
"panels": [
|
||||
{
|
||||
"columns": [],
|
||||
"datasource": "${DS_NAME}",
|
||||
"fontSize": "100%",
|
||||
"id": 9,
|
||||
"links": [],
|
||||
"pageSize": null,
|
||||
"scroll": true,
|
||||
"showHeader": true,
|
||||
"sort": {
|
||||
"col": 0,
|
||||
"desc": true
|
||||
},
|
||||
"span": 12,
|
||||
"styles": [
|
||||
{
|
||||
"alias": "Time",
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"pattern": "Time",
|
||||
"type": "date"
|
||||
},
|
||||
{
|
||||
"alias": "",
|
||||
"colorMode": "cell",
|
||||
"colors": [
|
||||
"rgba(45, 172, 121, 0.97)",
|
||||
"rgba(45, 172, 121, 0.97)",
|
||||
"#58140c"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 0,
|
||||
"pattern": "Disaster",
|
||||
"thresholds": [
|
||||
"0",
|
||||
"1"
|
||||
],
|
||||
"type": "number",
|
||||
"unit": "none"
|
||||
},
|
||||
{
|
||||
"alias": "",
|
||||
"colorMode": "cell",
|
||||
"colors": [
|
||||
"#99440a",
|
||||
"rgba(45, 172, 121, 0.97)",
|
||||
"#99440a"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 0,
|
||||
"pattern": "High",
|
||||
"thresholds": [
|
||||
"0",
|
||||
"1"
|
||||
],
|
||||
"type": "number",
|
||||
"unit": "short"
|
||||
},
|
||||
{
|
||||
"alias": "",
|
||||
"colorMode": "cell",
|
||||
"colors": [
|
||||
"rgba(50, 172, 45, 0.97)",
|
||||
"rgba(45, 172, 121, 0.97)",
|
||||
"#c15c17"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 0,
|
||||
"pattern": "Average",
|
||||
"thresholds": [
|
||||
"0",
|
||||
"1"
|
||||
],
|
||||
"type": "number",
|
||||
"unit": "short"
|
||||
},
|
||||
{
|
||||
"alias": "",
|
||||
"colorMode": "cell",
|
||||
"colors": [
|
||||
"rgba(50, 172, 45, 0.97)",
|
||||
"rgba(45, 172, 121, 0.97)",
|
||||
"#cca300"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 0,
|
||||
"pattern": "Warning",
|
||||
"thresholds": [
|
||||
"0",
|
||||
"1"
|
||||
],
|
||||
"type": "number",
|
||||
"unit": "short"
|
||||
},
|
||||
{
|
||||
"alias": "",
|
||||
"colorMode": "cell",
|
||||
"colors": [
|
||||
"rgba(50, 172, 45, 0.97)",
|
||||
"rgba(45, 172, 121, 0.97)",
|
||||
"#64b0c8"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 0,
|
||||
"pattern": "Information",
|
||||
"thresholds": [
|
||||
"0",
|
||||
"1"
|
||||
],
|
||||
"type": "number",
|
||||
"unit": "short"
|
||||
},
|
||||
{
|
||||
"alias": "",
|
||||
"colorMode": "cell",
|
||||
"colors": [
|
||||
"rgba(50, 172, 45, 0.97)",
|
||||
"rgba(45, 172, 121, 0.97)",
|
||||
"rgb(176, 176, 176)"
|
||||
],
|
||||
"dateFormat": "YYYY-MM-DD HH:mm:ss",
|
||||
"decimals": 0,
|
||||
"pattern": "Not classified",
|
||||
"thresholds": [
|
||||
"0",
|
||||
"1"
|
||||
],
|
||||
"type": "number",
|
||||
"unit": "short"
|
||||
},
|
||||
{
|
||||
"alias": "",
|
||||
"colorMode": null,
|
||||
"colors": [
|
||||
"rgba(245, 54, 54, 0.9)",
|
||||
"rgba(237, 129, 40, 0.89)",
|
||||
"rgba(50, 172, 45, 0.97)"
|
||||
],
|
||||
"decimals": 0,
|
||||
"pattern": "/.*/",
|
||||
"thresholds": [],
|
||||
"type": "number",
|
||||
"unit": "none"
|
||||
}
|
||||
],
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": ""
|
||||
},
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "/.*/"
|
||||
},
|
||||
"host": {
|
||||
"filter": "/.*/"
|
||||
},
|
||||
"item": {
|
||||
"filter": ""
|
||||
},
|
||||
"mode": 4,
|
||||
"triggers": {
|
||||
"count": false,
|
||||
"minSeverity": 0,
|
||||
"acknowledged": 2
|
||||
},
|
||||
"refId": "A",
|
||||
"target": ""
|
||||
}
|
||||
],
|
||||
"title": "System status",
|
||||
"transform": "table",
|
||||
"type": "table"
|
||||
}
|
||||
],
|
||||
"repeat": null,
|
||||
"repeatIteration": null,
|
||||
"repeatRowId": null,
|
||||
"showTitle": false,
|
||||
"title": "Dashboard Row",
|
||||
"titleSize": "h6"
|
||||
},
|
||||
{
|
||||
"collapse": false,
|
||||
"height": "150px",
|
||||
"panels": [
|
||||
{
|
||||
"cacheTimeout": null,
|
||||
"colorBackground": true,
|
||||
"colorValue": false,
|
||||
"colors": [
|
||||
"rgba(50, 172, 45, 0.97)",
|
||||
"rgba(16, 154, 113, 0.97)",
|
||||
"#890f02"
|
||||
],
|
||||
"datasource": "${DS_NAME}",
|
||||
"format": "none",
|
||||
"gauge": {
|
||||
"maxValue": 100,
|
||||
"minValue": 0,
|
||||
"show": false,
|
||||
"thresholdLabels": false,
|
||||
"thresholdMarkers": true
|
||||
},
|
||||
"id": 1,
|
||||
"interval": null,
|
||||
"links": [],
|
||||
"mappingType": 1,
|
||||
"mappingTypes": [
|
||||
{
|
||||
"name": "value to text",
|
||||
"value": 1
|
||||
},
|
||||
{
|
||||
"name": "range to text",
|
||||
"value": 2
|
||||
}
|
||||
],
|
||||
"maxDataPoints": 100,
|
||||
"minSpan": 2,
|
||||
"nullPointMode": "connected",
|
||||
"nullText": null,
|
||||
"postfix": "",
|
||||
"postfixFontSize": "50%",
|
||||
"prefix": "",
|
||||
"prefixFontSize": "50%",
|
||||
"rangeMaps": [
|
||||
{
|
||||
"from": "null",
|
||||
"text": "N/A",
|
||||
"to": "null"
|
||||
}
|
||||
],
|
||||
"repeat": "group",
|
||||
"span": 2,
|
||||
"sparkline": {
|
||||
"fillColor": "rgba(31, 118, 189, 0.18)",
|
||||
"full": false,
|
||||
"lineColor": "rgb(31, 120, 193)",
|
||||
"show": false
|
||||
},
|
||||
"tableColumn": "",
|
||||
"targets": [
|
||||
{
|
||||
"application": {
|
||||
"filter": ""
|
||||
},
|
||||
"functions": [],
|
||||
"group": {
|
||||
"filter": "$group"
|
||||
},
|
||||
"host": {
|
||||
"filter": "/.*/"
|
||||
},
|
||||
"item": {
|
||||
"filter": ""
|
||||
},
|
||||
"mode": 4,
|
||||
"triggers": {
|
||||
"count": true,
|
||||
"minSeverity": 3,
|
||||
"acknowledged": 2
|
||||
},
|
||||
"refId": "A",
|
||||
"target": ""
|
||||
}
|
||||
],
|
||||
"thresholds": "0,1",
|
||||
"title": "$group",
|
||||
"type": "singlestat",
|
||||
"valueFontSize": "120%",
|
||||
"valueMaps": [
|
||||
{
|
||||
"op": "=",
|
||||
"text": "N/A",
|
||||
"value": "null"
|
||||
}
|
||||
],
|
||||
"valueName": "avg"
|
||||
}
|
||||
],
|
||||
"repeat": null,
|
||||
"repeatIteration": null,
|
||||
"repeatRowId": null,
|
||||
"showTitle": false,
|
||||
"title": "Dashboard Row",
|
||||
"titleSize": "h6"
|
||||
}
|
||||
],
|
||||
"schemaVersion": 14,
|
||||
"style": "dark",
|
||||
"tags": [],
|
||||
"templating": {
|
||||
"list": [
|
||||
{
|
||||
"allValue": null,
|
||||
"current": {},
|
||||
"datasource": "${DS_NAME}",
|
||||
"hide": 0,
|
||||
"includeAll": true,
|
||||
"label": null,
|
||||
"multi": true,
|
||||
"name": "group",
|
||||
"options": [],
|
||||
"query": "*",
|
||||
"refresh": 1,
|
||||
"regex": "",
|
||||
"sort": 0,
|
||||
"tagValuesQuery": "",
|
||||
"tags": [],
|
||||
"tagsQuery": "",
|
||||
"type": "query",
|
||||
"useTags": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"time": {
|
||||
"from": "now-6h",
|
||||
"to": "now"
|
||||
},
|
||||
"timepicker": {
|
||||
"refresh_intervals": [
|
||||
"5s",
|
||||
"10s",
|
||||
"30s",
|
||||
"1m",
|
||||
"5m",
|
||||
"15m",
|
||||
"30m",
|
||||
"1h",
|
||||
"2h",
|
||||
"1d"
|
||||
],
|
||||
"time_options": [
|
||||
"5m",
|
||||
"15m",
|
||||
"1h",
|
||||
"6h",
|
||||
"12h",
|
||||
"24h",
|
||||
"2d",
|
||||
"7d",
|
||||
"30d"
|
||||
]
|
||||
},
|
||||
"timezone": ""
|
||||
}
|
||||
@@ -1,118 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['angular', 'lodash', 'jquery', './metricFunctions'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var angular, _, $, metricFunctions;
|
||||
|
||||
function getAllFunctionNames(categories) {
|
||||
return _.reduce(categories, function (list, category) {
|
||||
_.each(category, function (func) {
|
||||
list.push(func.name);
|
||||
});
|
||||
return list;
|
||||
}, []);
|
||||
}
|
||||
|
||||
function createFunctionDropDownMenu(categories) {
|
||||
return _.map(categories, function (list, category) {
|
||||
return {
|
||||
text: category,
|
||||
submenu: _.map(list, function (value) {
|
||||
return {
|
||||
text: value.name,
|
||||
click: "ctrl.addFunction('" + value.name + "')"
|
||||
};
|
||||
})
|
||||
};
|
||||
});
|
||||
}
|
||||
return {
|
||||
setters: [function (_angular) {
|
||||
angular = _angular.default;
|
||||
}, function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_jquery) {
|
||||
$ = _jquery.default;
|
||||
}, function (_metricFunctions) {
|
||||
metricFunctions = _metricFunctions;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
angular.module('grafana.directives').directive('addMetricFunction',
|
||||
|
||||
/** @ngInject */
|
||||
function ($compile) {
|
||||
var inputTemplate = '<input type="text"' + ' class="gf-form-input"' + ' spellcheck="false" style="display:none"></input>';
|
||||
|
||||
var buttonTemplate = '<a class="gf-form-label tight-form-func dropdown-toggle query-part"' + ' tabindex="1" gf-dropdown="functionMenu" data-toggle="dropdown">' + '<i class="fa fa-plus"></i></a>';
|
||||
|
||||
return {
|
||||
link: function link($scope, elem) {
|
||||
var categories = metricFunctions.getCategories();
|
||||
var allFunctions = getAllFunctionNames(categories);
|
||||
|
||||
$scope.functionMenu = createFunctionDropDownMenu(categories);
|
||||
|
||||
var $input = $(inputTemplate);
|
||||
var $button = $(buttonTemplate);
|
||||
$input.appendTo(elem);
|
||||
$button.appendTo(elem);
|
||||
|
||||
$input.attr('data-provide', 'typeahead');
|
||||
$input.typeahead({
|
||||
source: allFunctions,
|
||||
minLength: 1,
|
||||
items: 10,
|
||||
updater: function updater(value) {
|
||||
var funcDef = metricFunctions.getFuncDef(value);
|
||||
if (!funcDef) {
|
||||
// try find close match
|
||||
value = value.toLowerCase();
|
||||
funcDef = _.find(allFunctions, function (funcName) {
|
||||
return funcName.toLowerCase().indexOf(value) === 0;
|
||||
});
|
||||
|
||||
if (!funcDef) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
$scope.$apply(function () {
|
||||
$scope.addFunction(funcDef);
|
||||
});
|
||||
|
||||
$input.trigger('blur');
|
||||
return '';
|
||||
}
|
||||
});
|
||||
|
||||
$button.click(function () {
|
||||
$button.hide();
|
||||
$input.show();
|
||||
$input.focus();
|
||||
});
|
||||
|
||||
$input.keyup(function () {
|
||||
elem.toggleClass('open', $input.val() === '');
|
||||
});
|
||||
|
||||
$input.blur(function () {
|
||||
// clicking the function dropdown menu wont
|
||||
// work if you remove class at once
|
||||
setTimeout(function () {
|
||||
$input.val('');
|
||||
$input.hide();
|
||||
$button.show();
|
||||
elem.removeClass('open');
|
||||
}, 200);
|
||||
});
|
||||
|
||||
$compile(elem.contents())($scope);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=add-metric-function.directive.js.map
|
||||
@@ -1,77 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', '../timeseries'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, ts, datapoints, series_set, growing_series;
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_timeseries) {
|
||||
ts = _timeseries.default;
|
||||
}],
|
||||
execute: function () {
|
||||
datapoints = [[10.7104, 1498409636085], [10.578, 1498409651011], [10.5985, 1498409666628], [10.6877, 1498409681525], [10.5495, 1498409696586], [10.5981, 1498409711009], [10.5076, 1498409726949], [11.4807, 1498409741853], [11.6165, 1498409756165], [11.8575, 1498409771018], [11.9936, 1498409786056], [10.7566, 1498409801942], [10.7484, 1498409816010], [10.6038, 1498409831018], [10.2932, 1498409846010], [10.4912, 1498409861946], [10.4151, 1498409876871], [10.2401, 1498409891710], [10.4921, 1498409906143], [10.4413, 1498409921477], [10.6318, 1498409936147], [10.5277, 1498409951915], [10.6333, 1498409966052], [10.6417, 1498409981944], [10.4505, 1498409996867], [10.5812, 1498410011770], [10.4934, 1498410026573], [10.5731, 1498410041317], [10.5, 1498410056213], [10.6505, 1498410071013], [9.4035, 1498410086387]];
|
||||
series_set = [[[1.0247, 1498409631773], [0.9988, 1498409646697], [0.9817, 1498409661239], [0.9569, 1498409676045], [1.0331, 1498409691922], [1.0755, 1498409706546], [1.1862, 1498409721525], [1.2984, 1498409736175], [1.2389, 1498409751817], [1.1452, 1498409766783], [1.102, 1498409781699], [0.9647, 1498409796664], [1.0063, 1498409811627], [1.0318, 1498409826887], [1.065, 1498409841645], [1.0907, 1498409856647], [1.0229, 1498409871521], [1.0654, 1498409886031], [1.0568, 1498409901544], [1.0818, 1498409916194], [1.1335, 1498409931672], [1.057, 1498409946673], [1.0243, 1498409961669], [1.0329, 1498409976637], [1.1428, 1498409991563], [1.2198, 1498410006441], [1.2192, 1498410021230], [1.2615, 1498410036027], [1.1765, 1498410051907], [1.2352, 1498410066109], [1.0557, 1498410081043]], [[10.7104, 1498409636085], [10.578, 1498409651011], [10.5985, 1498409666628], [10.6877, 1498409681525], [10.5495, 1498409696586], [10.5981, 1498409711009], [10.5076, 1498409726949], [11.4807, 1498409741853], [11.6165, 1498409756165], [11.8575, 1498409771018], [11.9936, 1498409786056], [10.7566, 1498409801942], [10.7484, 1498409816010], [10.6038, 1498409831018], [10.2932, 1498409846010], [10.4912, 1498409861946], [10.4151, 1498409876871], [10.2401, 1498409891710], [10.4921, 1498409906143], [10.4413, 1498409921477], [10.6318, 1498409936147], [10.5277, 1498409951915], [10.6333, 1498409966052], [10.6417, 1498409981944], [10.4505, 1498409996867], [10.5812, 1498410011770], [10.4934, 1498410026573], [10.5731, 1498410041317], [10.5, 1498410056213], [10.6505, 1498410071013], [9.4035, 1498410086387]]];
|
||||
growing_series = [[10755200, 1498332216642], [10761200, 1498332276802], [10767200, 1498332336367], [10773200, 1498332396584], [10779200, 1498332456880], [10785200, 1498332516479], [10791200, 1498332576610], [10797200, 1498332636353], [10803200, 1498332696513], [10809200, 1498332756884], [10815200, 1498332816890], [10821200, 1498332876305], [10827200, 1498332936384], [10833200, 1498332996659], [10839200, 1498333056965], [10845200, 1498333116748], [10851200, 1498333176687], [10857200, 1498333236646], [10863200, 1498333297034], [10869200, 1498333356358], [10875200, 1498333416445], [4800, 1498333536686], [17900, 1498333667962], [24000, 1498333729157], [29500, 1498333783662], [34800, 1498333836813], [40700, 1498333896403], [46800, 1498333956953], [52800, 1498334016976], [6000, 1498334136593], [12000, 1498334196567]];
|
||||
|
||||
|
||||
module.exports = [{
|
||||
name: 'groupBy',
|
||||
tests: {
|
||||
'groupBy(AVERAGE)': function groupByAVERAGE() {
|
||||
ts.groupBy(datapoints, '5m', ts.AVERAGE);
|
||||
},
|
||||
'groupBy(MAX)': function groupByMAX() {
|
||||
ts.groupBy(datapoints, '5m', ts.COUNT);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'sumSeries',
|
||||
tests: {
|
||||
'sumSeries()': function sumSeries() {
|
||||
ts.sumSeries(series_set);
|
||||
},
|
||||
'groupBy(MAX)->sumSeries()': function groupByMAXSumSeries() {
|
||||
var prepeared_series = _.map(series_set, function (datapoints) {
|
||||
return ts.groupBy(datapoints, '5m', ts.MAX);
|
||||
});
|
||||
ts.sumSeries(prepeared_series);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'delta vs rate',
|
||||
tests: {
|
||||
'delta()': function delta() {
|
||||
ts.delta(growing_series);
|
||||
},
|
||||
'rate()': function rate() {
|
||||
ts.rate(growing_series);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'scale',
|
||||
tests: {
|
||||
'scale()': function scale() {
|
||||
ts.scale(datapoints, 42);
|
||||
},
|
||||
'scale_perf()': function scale_perf() {
|
||||
ts.scale_perf(datapoints, 42);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
name: 'groupBy vs groupBy_perf',
|
||||
tests: {
|
||||
'groupBy()': function groupBy() {
|
||||
ts.groupBy(datapoints, '5m', ts.AVERAGE);
|
||||
},
|
||||
'groupBy_perf()': function groupBy_perf() {
|
||||
ts.groupBy_perf(datapoints, '5m', ts.AVERAGE);
|
||||
}
|
||||
}
|
||||
}];
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=timeseries_bench.js.map
|
||||
80
dist/datasource-zabbix/config.controller.js
vendored
@@ -1,80 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', './migrations'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, migrateDSConfig, _createClass, SUPPORTED_SQL_DS, defaultConfig, ZabbixDSConfigController;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_migrations) {
|
||||
migrateDSConfig = _migrations.migrateDSConfig;
|
||||
}],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
SUPPORTED_SQL_DS = ['mysql', 'postgres'];
|
||||
defaultConfig = {
|
||||
trends: false,
|
||||
dbConnectionEnable: false,
|
||||
dbConnectionDatasourceId: null,
|
||||
alerting: false,
|
||||
addThresholds: false,
|
||||
alertingMinSeverity: 3,
|
||||
disableReadOnlyUsersAck: false
|
||||
};
|
||||
|
||||
_export('ZabbixDSConfigController', ZabbixDSConfigController = function () {
|
||||
|
||||
/** @ngInject */
|
||||
function ZabbixDSConfigController($scope, $injector, datasourceSrv) {
|
||||
_classCallCheck(this, ZabbixDSConfigController);
|
||||
|
||||
this.datasourceSrv = datasourceSrv;
|
||||
|
||||
this.current.jsonData = migrateDSConfig(this.current.jsonData);
|
||||
_.defaults(this.current.jsonData, defaultConfig);
|
||||
this.sqlDataSources = this.getSupportedSQLDataSources();
|
||||
}
|
||||
|
||||
_createClass(ZabbixDSConfigController, [{
|
||||
key: 'getSupportedSQLDataSources',
|
||||
value: function getSupportedSQLDataSources() {
|
||||
var datasources = this.datasourceSrv.getAll();
|
||||
return _.filter(datasources, function (ds) {
|
||||
return _.includes(SUPPORTED_SQL_DS, ds.type);
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixDSConfigController;
|
||||
}());
|
||||
|
||||
_export('ZabbixDSConfigController', ZabbixDSConfigController);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=config.controller.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/config.controller.js"],"names":["_","migrateDSConfig","SUPPORTED_SQL_DS","defaultConfig","trends","dbConnectionEnable","dbConnectionDatasourceId","alerting","addThresholds","alertingMinSeverity","disableReadOnlyUsersAck","ZabbixDSConfigController","$scope","$injector","datasourceSrv","current","jsonData","defaults","sqlDataSources","getSupportedSQLDataSources","datasources","getAll","filter","includes","ds","type"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;AACEC,qB,eAAAA,e;;;;;;;;;;;;;;;;;;;;;AAEHC,sB,GAAmB,CAAC,OAAD,EAAU,UAAV,C;AAEnBC,mB,GAAgB;AACpBC,gBAAQ,KADY;AAEpBC,4BAAoB,KAFA;AAGpBC,kCAA0B,IAHN;AAIpBC,kBAAU,KAJU;AAKpBC,uBAAe,KALK;AAMpBC,6BAAqB,CAND;AAOpBC,iCAAyB;AAPL,O;;0CAUTC,wB;;AAEX;AACA,0CAAYC,MAAZ,EAAoBC,SAApB,EAA+BC,aAA/B,EAA8C;AAAA;;AAC5C,eAAKA,aAAL,GAAqBA,aAArB;;AAEA,eAAKC,OAAL,CAAaC,QAAb,GAAwBf,gBAAgB,KAAKc,OAAL,CAAaC,QAA7B,CAAxB;AACAhB,YAAEiB,QAAF,CAAW,KAAKF,OAAL,CAAaC,QAAxB,EAAkCb,aAAlC;AACA,eAAKe,cAAL,GAAsB,KAAKC,0BAAL,EAAtB;AACD;;;;uDAE4B;AAC3B,gBAAIC,cAAc,KAAKN,aAAL,CAAmBO,MAAnB,EAAlB;AACA,mBAAOrB,EAAEsB,MAAF,CAASF,WAAT,EAAsB,cAAM;AACjC,qBAAOpB,EAAEuB,QAAF,CAAWrB,gBAAX,EAA6BsB,GAAGC,IAAhC,CAAP;AACD,aAFM,CAAP;AAGD","file":"config.controller.js","sourcesContent":["import _ from 'lodash';\nimport { migrateDSConfig } from './migrations';\n\nconst SUPPORTED_SQL_DS = ['mysql', 'postgres'];\n\nconst defaultConfig = {\n trends: false,\n dbConnectionEnable: false,\n dbConnectionDatasourceId: null,\n alerting: false,\n addThresholds: false,\n alertingMinSeverity: 3,\n disableReadOnlyUsersAck: false\n};\n\nexport class ZabbixDSConfigController {\n\n /** @ngInject */\n constructor($scope, $injector, datasourceSrv) {\n this.datasourceSrv = datasourceSrv;\n\n this.current.jsonData = migrateDSConfig(this.current.jsonData);\n _.defaults(this.current.jsonData, defaultConfig);\n this.sqlDataSources = this.getSupportedSQLDataSources();\n }\n\n getSupportedSQLDataSources() {\n let datasources = this.datasourceSrv.getAll();\n return _.filter(datasources, ds => {\n return _.includes(SUPPORTED_SQL_DS, ds.type);\n });\n }\n}\n"]}
|
||||
80
dist/datasource-zabbix/constants.js
vendored
@@ -1,80 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var MODE_METRICS, MODE_ITSERVICE, MODE_TEXT, MODE_ITEMID, MODE_TRIGGERS, SEV_NOT_CLASSIFIED, SEV_INFORMATION, SEV_WARNING, SEV_AVERAGE, SEV_HIGH, SEV_DISASTER, SHOW_ALL_TRIGGERS, SHOW_ALL_EVENTS, SHOW_OK_EVENTS, DATAPOINT_VALUE, DATAPOINT_TS, TRIGGER_SEVERITY;
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_export('MODE_METRICS', MODE_METRICS = 0);
|
||||
|
||||
_export('MODE_METRICS', MODE_METRICS);
|
||||
|
||||
_export('MODE_ITSERVICE', MODE_ITSERVICE = 1);
|
||||
|
||||
_export('MODE_ITSERVICE', MODE_ITSERVICE);
|
||||
|
||||
_export('MODE_TEXT', MODE_TEXT = 2);
|
||||
|
||||
_export('MODE_TEXT', MODE_TEXT);
|
||||
|
||||
_export('MODE_ITEMID', MODE_ITEMID = 3);
|
||||
|
||||
_export('MODE_ITEMID', MODE_ITEMID);
|
||||
|
||||
_export('MODE_TRIGGERS', MODE_TRIGGERS = 4);
|
||||
|
||||
_export('MODE_TRIGGERS', MODE_TRIGGERS);
|
||||
|
||||
_export('SEV_NOT_CLASSIFIED', SEV_NOT_CLASSIFIED = 0);
|
||||
|
||||
_export('SEV_NOT_CLASSIFIED', SEV_NOT_CLASSIFIED);
|
||||
|
||||
_export('SEV_INFORMATION', SEV_INFORMATION = 1);
|
||||
|
||||
_export('SEV_INFORMATION', SEV_INFORMATION);
|
||||
|
||||
_export('SEV_WARNING', SEV_WARNING = 2);
|
||||
|
||||
_export('SEV_WARNING', SEV_WARNING);
|
||||
|
||||
_export('SEV_AVERAGE', SEV_AVERAGE = 3);
|
||||
|
||||
_export('SEV_AVERAGE', SEV_AVERAGE);
|
||||
|
||||
_export('SEV_HIGH', SEV_HIGH = 4);
|
||||
|
||||
_export('SEV_HIGH', SEV_HIGH);
|
||||
|
||||
_export('SEV_DISASTER', SEV_DISASTER = 5);
|
||||
|
||||
_export('SEV_DISASTER', SEV_DISASTER);
|
||||
|
||||
_export('SHOW_ALL_TRIGGERS', SHOW_ALL_TRIGGERS = [0, 1]);
|
||||
|
||||
_export('SHOW_ALL_TRIGGERS', SHOW_ALL_TRIGGERS);
|
||||
|
||||
_export('SHOW_ALL_EVENTS', SHOW_ALL_EVENTS = [0, 1]);
|
||||
|
||||
_export('SHOW_ALL_EVENTS', SHOW_ALL_EVENTS);
|
||||
|
||||
_export('SHOW_OK_EVENTS', SHOW_OK_EVENTS = 1);
|
||||
|
||||
_export('SHOW_OK_EVENTS', SHOW_OK_EVENTS);
|
||||
|
||||
_export('DATAPOINT_VALUE', DATAPOINT_VALUE = 0);
|
||||
|
||||
_export('DATAPOINT_VALUE', DATAPOINT_VALUE);
|
||||
|
||||
_export('DATAPOINT_TS', DATAPOINT_TS = 1);
|
||||
|
||||
_export('DATAPOINT_TS', DATAPOINT_TS);
|
||||
|
||||
_export('TRIGGER_SEVERITY', TRIGGER_SEVERITY = [{ val: 0, text: 'Not classified' }, { val: 1, text: 'Information' }, { val: 2, text: 'Warning' }, { val: 3, text: 'Average' }, { val: 4, text: 'High' }, { val: 5, text: 'Disaster' }]);
|
||||
|
||||
_export('TRIGGER_SEVERITY', TRIGGER_SEVERITY);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=constants.js.map
|
||||
1
dist/datasource-zabbix/constants.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/constants.js"],"names":["MODE_METRICS","MODE_ITSERVICE","MODE_TEXT","MODE_ITEMID","MODE_TRIGGERS","SEV_NOT_CLASSIFIED","SEV_INFORMATION","SEV_WARNING","SEV_AVERAGE","SEV_HIGH","SEV_DISASTER","SHOW_ALL_TRIGGERS","SHOW_ALL_EVENTS","SHOW_OK_EVENTS","DATAPOINT_VALUE","DATAPOINT_TS","TRIGGER_SEVERITY","val","text"],"mappings":";;;;;;;;;8BACaA,Y,GAAe,C;;;;gCACfC,c,GAAiB,C;;;;2BACjBC,S,GAAY,C;;;;6BACZC,W,GAAc,C;;;;+BACdC,a,GAAgB,C;;;;oCAGhBC,kB,GAAqB,C;;;;iCACrBC,e,GAAkB,C;;;;6BAClBC,W,GAAc,C;;;;6BACdC,W,GAAc,C;;;;0BACdC,Q,GAAW,C;;;;8BACXC,Y,GAAe,C;;;;mCAEfC,iB,GAAoB,CAAC,CAAD,EAAI,CAAJ,C;;;;iCACpBC,e,GAAkB,CAAC,CAAD,EAAI,CAAJ,C;;;;gCAClBC,c,GAAiB,C;;;;iCAGjBC,e,GAAkB,C;;;;8BAClBC,Y,GAAe,C;;;;kCAEfC,gB,GAAmB,CAC9B,EAACC,KAAK,CAAN,EAASC,MAAM,gBAAf,EAD8B,EAE9B,EAACD,KAAK,CAAN,EAASC,MAAM,aAAf,EAF8B,EAG9B,EAACD,KAAK,CAAN,EAASC,MAAM,SAAf,EAH8B,EAI9B,EAACD,KAAK,CAAN,EAASC,MAAM,SAAf,EAJ8B,EAK9B,EAACD,KAAK,CAAN,EAASC,MAAM,MAAf,EAL8B,EAM9B,EAACD,KAAK,CAAN,EAASC,MAAM,UAAf,EAN8B,C","file":"constants.js","sourcesContent":["// Editor modes\nexport const MODE_METRICS = 0;\nexport const MODE_ITSERVICE = 1;\nexport const MODE_TEXT = 2;\nexport const MODE_ITEMID = 3;\nexport const MODE_TRIGGERS = 4;\n\n// Triggers severity\nexport const SEV_NOT_CLASSIFIED = 0;\nexport const SEV_INFORMATION = 1;\nexport const SEV_WARNING = 2;\nexport const SEV_AVERAGE = 3;\nexport const SEV_HIGH = 4;\nexport const SEV_DISASTER = 5;\n\nexport const SHOW_ALL_TRIGGERS = [0, 1];\nexport const SHOW_ALL_EVENTS = [0, 1];\nexport const SHOW_OK_EVENTS = 1;\n\n// Data point\nexport const DATAPOINT_VALUE = 0;\nexport const DATAPOINT_TS = 1;\n\nexport const TRIGGER_SEVERITY = [\n {val: 0, text: 'Not classified'},\n {val: 1, text: 'Information'},\n {val: 2, text: 'Warning'},\n {val: 3, text: 'Average'},\n {val: 4, text: 'High'},\n {val: 5, text: 'Disaster'}\n];\n"]}
|
||||
194
dist/datasource-zabbix/dataProcessor.js
vendored
@@ -1,194 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', './utils', './timeseries'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, utils, ts, downsampleSeries, groupBy, groupBy_exported, sumSeries, delta, rate, scale, simpleMovingAverage, expMovingAverage, SUM, COUNT, AVERAGE, MIN, MAX, MEDIAN, PERCENTIL, metricFunctions, aggregationFunctions;
|
||||
|
||||
function limit(order, n, orderByFunc, timeseries) {
|
||||
var orderByCallback = aggregationFunctions[orderByFunc];
|
||||
var sortByIteratee = function sortByIteratee(ts) {
|
||||
var values = _.map(ts.datapoints, function (point) {
|
||||
return point[0];
|
||||
});
|
||||
return orderByCallback(values);
|
||||
};
|
||||
var sortedTimeseries = _.sortBy(timeseries, sortByIteratee);
|
||||
if (order === 'bottom') {
|
||||
return sortedTimeseries.slice(0, n);
|
||||
} else {
|
||||
return sortedTimeseries.slice(-n);
|
||||
}
|
||||
}
|
||||
|
||||
function sortSeries(direction, timeseries) {
|
||||
return _.orderBy(timeseries, [function (ts) {
|
||||
return ts.target.toLowerCase();
|
||||
}], direction);
|
||||
}
|
||||
|
||||
function setAlias(alias, timeseries) {
|
||||
timeseries.target = alias;
|
||||
return timeseries;
|
||||
}
|
||||
|
||||
function replaceAlias(regexp, newAlias, timeseries) {
|
||||
var pattern = void 0;
|
||||
if (utils.isRegex(regexp)) {
|
||||
pattern = utils.buildRegex(regexp);
|
||||
} else {
|
||||
pattern = regexp;
|
||||
}
|
||||
|
||||
var alias = timeseries.target.replace(pattern, newAlias);
|
||||
timeseries.target = alias;
|
||||
return timeseries;
|
||||
}
|
||||
|
||||
function setAliasByRegex(alias, timeseries) {
|
||||
timeseries.target = extractText(timeseries.target, alias);
|
||||
return timeseries;
|
||||
}
|
||||
|
||||
function extractText(str, pattern) {
|
||||
var extractPattern = new RegExp(pattern);
|
||||
var extractedValue = extractPattern.exec(str);
|
||||
extractedValue = extractedValue[0];
|
||||
return extractedValue;
|
||||
}
|
||||
|
||||
function groupByWrapper(interval, groupFunc, datapoints) {
|
||||
var groupByCallback = aggregationFunctions[groupFunc];
|
||||
return groupBy(datapoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function aggregateByWrapper(interval, aggregateFunc, datapoints) {
|
||||
// Flatten all points in frame and then just use groupBy()
|
||||
var flattenedPoints = _.flatten(datapoints, true);
|
||||
// groupBy_perf works with sorted series only
|
||||
var sortedPoints = ts.sortByTime(flattenedPoints);
|
||||
var groupByCallback = aggregationFunctions[aggregateFunc];
|
||||
return groupBy(sortedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function aggregateWrapper(groupByCallback, interval, datapoints) {
|
||||
var flattenedPoints = _.flatten(datapoints, true);
|
||||
return groupBy(flattenedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function percentil(interval, n, datapoints) {
|
||||
var flattenedPoints = _.flatten(datapoints, true);
|
||||
var groupByCallback = _.partial(PERCENTIL, n);
|
||||
return groupBy(flattenedPoints, interval, groupByCallback);
|
||||
}
|
||||
|
||||
function timeShift(interval, range) {
|
||||
var shift = utils.parseTimeShiftInterval(interval) / 1000;
|
||||
return _.map(range, function (time) {
|
||||
return time - shift;
|
||||
});
|
||||
}
|
||||
|
||||
function unShiftTimeSeries(interval, datapoints) {
|
||||
var unshift = utils.parseTimeShiftInterval(interval);
|
||||
return _.map(datapoints, function (dp) {
|
||||
return [dp[0], dp[1] + unshift];
|
||||
});
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_utils) {
|
||||
utils = _utils;
|
||||
}, function (_timeseries) {
|
||||
ts = _timeseries.default;
|
||||
}],
|
||||
execute: function () {
|
||||
downsampleSeries = ts.downsample;
|
||||
groupBy = ts.groupBy_perf;
|
||||
|
||||
groupBy_exported = function groupBy_exported(interval, groupFunc, datapoints) {
|
||||
return groupBy(datapoints, interval, groupFunc);
|
||||
};
|
||||
|
||||
sumSeries = ts.sumSeries;
|
||||
delta = ts.delta;
|
||||
rate = ts.rate;
|
||||
|
||||
scale = function scale(factor, datapoints) {
|
||||
return ts.scale_perf(datapoints, factor);
|
||||
};
|
||||
|
||||
simpleMovingAverage = function simpleMovingAverage(n, datapoints) {
|
||||
return ts.simpleMovingAverage(datapoints, n);
|
||||
};
|
||||
|
||||
expMovingAverage = function expMovingAverage(a, datapoints) {
|
||||
return ts.expMovingAverage(datapoints, a);
|
||||
};
|
||||
|
||||
SUM = ts.SUM;
|
||||
COUNT = ts.COUNT;
|
||||
AVERAGE = ts.AVERAGE;
|
||||
MIN = ts.MIN;
|
||||
MAX = ts.MAX;
|
||||
MEDIAN = ts.MEDIAN;
|
||||
PERCENTIL = ts.PERCENTIL;
|
||||
metricFunctions = {
|
||||
groupBy: groupByWrapper,
|
||||
scale: scale,
|
||||
delta: delta,
|
||||
rate: rate,
|
||||
movingAverage: simpleMovingAverage,
|
||||
exponentialMovingAverage: expMovingAverage,
|
||||
aggregateBy: aggregateByWrapper,
|
||||
// Predefined aggs
|
||||
percentil: percentil,
|
||||
average: _.partial(aggregateWrapper, AVERAGE),
|
||||
min: _.partial(aggregateWrapper, MIN),
|
||||
max: _.partial(aggregateWrapper, MAX),
|
||||
median: _.partial(aggregateWrapper, MEDIAN),
|
||||
sum: _.partial(aggregateWrapper, SUM),
|
||||
count: _.partial(aggregateWrapper, COUNT),
|
||||
sumSeries: sumSeries,
|
||||
top: _.partial(limit, 'top'),
|
||||
bottom: _.partial(limit, 'bottom'),
|
||||
sortSeries: sortSeries,
|
||||
timeShift: timeShift,
|
||||
setAlias: setAlias,
|
||||
setAliasByRegex: setAliasByRegex,
|
||||
replaceAlias: replaceAlias
|
||||
};
|
||||
aggregationFunctions = {
|
||||
avg: AVERAGE,
|
||||
min: MIN,
|
||||
max: MAX,
|
||||
median: MEDIAN,
|
||||
sum: SUM,
|
||||
count: COUNT
|
||||
};
|
||||
|
||||
_export('default', {
|
||||
downsampleSeries: downsampleSeries,
|
||||
groupBy: groupBy_exported,
|
||||
AVERAGE: AVERAGE,
|
||||
MIN: MIN,
|
||||
MAX: MAX,
|
||||
MEDIAN: MEDIAN,
|
||||
SUM: SUM,
|
||||
COUNT: COUNT,
|
||||
unShiftTimeSeries: unShiftTimeSeries,
|
||||
|
||||
get aggregationFunctions() {
|
||||
return aggregationFunctions;
|
||||
},
|
||||
|
||||
get metricFunctions() {
|
||||
return metricFunctions;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=dataProcessor.js.map
|
||||
1
dist/datasource-zabbix/dataProcessor.js.map
vendored
798
dist/datasource-zabbix/datasource.js
vendored
@@ -1,798 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', 'app/core/utils/datemath', './utils', './migrations', './metricFunctions', './constants', './dataProcessor', './responseHandler', './zabbix/zabbix', './zabbix/connectors/zabbix_api/zabbixAPICore'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, dateMath, utils, migrations, metricFunctions, c, dataProcessor, responseHandler, Zabbix, ZabbixAPIError, _slicedToArray, _createClass, ZabbixDatasource;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
function bindFunctionDefs(functionDefs, category) {
|
||||
var aggregationFunctions = _.map(metricFunctions.getCategories()[category], 'name');
|
||||
var aggFuncDefs = _.filter(functionDefs, function (func) {
|
||||
return _.includes(aggregationFunctions, func.def.name);
|
||||
});
|
||||
|
||||
return _.map(aggFuncDefs, function (func) {
|
||||
var funcInstance = metricFunctions.createFuncInstance(func.def, func.params);
|
||||
return funcInstance.bindFunction(dataProcessor.metricFunctions);
|
||||
});
|
||||
}
|
||||
|
||||
function getConsolidateBy(target) {
|
||||
var consolidateBy = void 0;
|
||||
var funcDef = _.find(target.functions, function (func) {
|
||||
return func.def.name === 'consolidateBy';
|
||||
});
|
||||
if (funcDef && funcDef.params && funcDef.params.length) {
|
||||
consolidateBy = funcDef.params[0];
|
||||
}
|
||||
return consolidateBy;
|
||||
}
|
||||
|
||||
function downsampleSeries(timeseries_data, options) {
|
||||
var defaultAgg = dataProcessor.aggregationFunctions['avg'];
|
||||
var consolidateByFunc = dataProcessor.aggregationFunctions[options.consolidateBy] || defaultAgg;
|
||||
return _.map(timeseries_data, function (timeseries) {
|
||||
if (timeseries.datapoints.length > options.maxDataPoints) {
|
||||
timeseries.datapoints = dataProcessor.groupBy(options.interval, consolidateByFunc, timeseries.datapoints);
|
||||
}
|
||||
return timeseries;
|
||||
});
|
||||
}
|
||||
|
||||
function formatMetric(metricObj) {
|
||||
return {
|
||||
text: metricObj.name,
|
||||
expandable: false
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Custom formatter for template variables.
|
||||
* Default Grafana "regex" formatter returns
|
||||
* value1|value2
|
||||
* This formatter returns
|
||||
* (value1|value2)
|
||||
* This format needed for using in complex regex with
|
||||
* template variables, for example
|
||||
* /CPU $cpu_item.*time/ where $cpu_item is system,user,iowait
|
||||
*/
|
||||
function zabbixTemplateFormat(value) {
|
||||
if (typeof value === 'string') {
|
||||
return utils.escapeRegex(value);
|
||||
}
|
||||
|
||||
var escapedValues = _.map(value, utils.escapeRegex);
|
||||
return '(' + escapedValues.join('|') + ')';
|
||||
}
|
||||
|
||||
_export('zabbixTemplateFormat', zabbixTemplateFormat);
|
||||
|
||||
function zabbixItemIdsTemplateFormat(value) {
|
||||
if (typeof value === 'string') {
|
||||
return value;
|
||||
}
|
||||
return value.join(',');
|
||||
}
|
||||
|
||||
/**
|
||||
* If template variables are used in request, replace it using regex format
|
||||
* and wrap with '/' for proper multi-value work. Example:
|
||||
* $variable selected as a, b, c
|
||||
* We use filter $variable
|
||||
* $variable -> a|b|c -> /a|b|c/
|
||||
* /$variable/ -> /a|b|c/ -> /a|b|c/
|
||||
*/
|
||||
function replaceTemplateVars(templateSrv, target, scopedVars) {
|
||||
var replacedTarget = templateSrv.replace(target, scopedVars, zabbixTemplateFormat);
|
||||
if (target !== replacedTarget && !utils.isRegex(replacedTarget)) {
|
||||
replacedTarget = '/^' + replacedTarget + '$/';
|
||||
}
|
||||
return replacedTarget;
|
||||
}
|
||||
|
||||
function filterEnabledTargets(targets) {
|
||||
return _.filter(targets, function (target) {
|
||||
return !(target.hide || !target.group || !target.host || !target.item);
|
||||
});
|
||||
}
|
||||
|
||||
function getTriggerThreshold(expression) {
|
||||
var thresholdPattern = /.*[<>=]{1,2}([\d\.]+)/;
|
||||
var finded_thresholds = expression.match(thresholdPattern);
|
||||
if (finded_thresholds && finded_thresholds.length >= 2) {
|
||||
var threshold = finded_thresholds[1];
|
||||
threshold = Number(threshold);
|
||||
return threshold;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
// Fix for backward compatibility with lodash 2.4
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_appCoreUtilsDatemath) {
|
||||
dateMath = _appCoreUtilsDatemath;
|
||||
}, function (_utils) {
|
||||
utils = _utils;
|
||||
}, function (_migrations) {
|
||||
migrations = _migrations;
|
||||
}, function (_metricFunctions) {
|
||||
metricFunctions = _metricFunctions;
|
||||
}, function (_constants) {
|
||||
c = _constants;
|
||||
}, function (_dataProcessor) {
|
||||
dataProcessor = _dataProcessor.default;
|
||||
}, function (_responseHandler) {
|
||||
responseHandler = _responseHandler.default;
|
||||
}, function (_zabbixZabbix) {
|
||||
Zabbix = _zabbixZabbix.Zabbix;
|
||||
}, function (_zabbixConnectorsZabbix_apiZabbixAPICore) {
|
||||
ZabbixAPIError = _zabbixConnectorsZabbix_apiZabbixAPICore.ZabbixAPIError;
|
||||
}],
|
||||
execute: function () {
|
||||
_slicedToArray = function () {
|
||||
function sliceIterator(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"]) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
return function (arr, i) {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr;
|
||||
} else if (Symbol.iterator in Object(arr)) {
|
||||
return sliceIterator(arr, i);
|
||||
} else {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
_export('ZabbixDatasource', ZabbixDatasource = function () {
|
||||
|
||||
/** @ngInject */
|
||||
function ZabbixDatasource(instanceSettings, templateSrv, backendSrv, datasourceSrv, zabbixAlertingSrv) {
|
||||
_classCallCheck(this, ZabbixDatasource);
|
||||
|
||||
this.templateSrv = templateSrv;
|
||||
this.zabbixAlertingSrv = zabbixAlertingSrv;
|
||||
|
||||
// Use custom format for template variables
|
||||
this.replaceTemplateVars = _.partial(replaceTemplateVars, this.templateSrv);
|
||||
|
||||
// General data source settings
|
||||
this.name = instanceSettings.name;
|
||||
this.url = instanceSettings.url;
|
||||
this.basicAuth = instanceSettings.basicAuth;
|
||||
this.withCredentials = instanceSettings.withCredentials;
|
||||
|
||||
var jsonData = migrations.migrateDSConfig(instanceSettings.jsonData);
|
||||
|
||||
// Zabbix API credentials
|
||||
this.username = jsonData.username;
|
||||
this.password = jsonData.password;
|
||||
|
||||
// Use trends instead history since specified time
|
||||
this.trends = jsonData.trends;
|
||||
this.trendsFrom = jsonData.trendsFrom || '7d';
|
||||
this.trendsRange = jsonData.trendsRange || '4d';
|
||||
|
||||
// Set cache update interval
|
||||
var ttl = jsonData.cacheTTL || '1h';
|
||||
this.cacheTTL = utils.parseInterval(ttl);
|
||||
|
||||
// Alerting options
|
||||
this.alertingEnabled = jsonData.alerting;
|
||||
this.addThresholds = jsonData.addThresholds;
|
||||
this.alertingMinSeverity = jsonData.alertingMinSeverity || c.SEV_WARNING;
|
||||
|
||||
// Other options
|
||||
this.disableReadOnlyUsersAck = jsonData.disableReadOnlyUsersAck;
|
||||
|
||||
// Direct DB Connection options
|
||||
this.enableDirectDBConnection = jsonData.dbConnectionEnable || false;
|
||||
this.dbConnectionDatasourceId = jsonData.dbConnectionDatasourceId;
|
||||
this.dbConnectionDatasourceName = jsonData.dbConnectionDatasourceName;
|
||||
|
||||
var zabbixOptions = {
|
||||
url: this.url,
|
||||
username: this.username,
|
||||
password: this.password,
|
||||
basicAuth: this.basicAuth,
|
||||
withCredentials: this.withCredentials,
|
||||
cacheTTL: this.cacheTTL,
|
||||
enableDirectDBConnection: this.enableDirectDBConnection,
|
||||
dbConnectionDatasourceId: this.dbConnectionDatasourceId,
|
||||
dbConnectionDatasourceName: this.dbConnectionDatasourceName
|
||||
};
|
||||
|
||||
this.zabbix = new Zabbix(zabbixOptions, backendSrv, datasourceSrv);
|
||||
}
|
||||
|
||||
////////////////////////
|
||||
// Datasource methods //
|
||||
////////////////////////
|
||||
|
||||
/**
|
||||
* Query panel data. Calls for each panel in dashboard.
|
||||
* @param {Object} options Contains time range, targets and other info.
|
||||
* @return {Object} Grafana metrics object with timeseries data for each target.
|
||||
*/
|
||||
|
||||
|
||||
_createClass(ZabbixDatasource, [{
|
||||
key: 'query',
|
||||
value: function query(options) {
|
||||
var _this = this;
|
||||
|
||||
// Get alerts for current panel
|
||||
if (this.alertingEnabled) {
|
||||
this.alertQuery(options).then(function (alert) {
|
||||
_this.zabbixAlertingSrv.setPanelAlertState(options.panelId, alert.state);
|
||||
|
||||
_this.zabbixAlertingSrv.removeZabbixThreshold(options.panelId);
|
||||
if (_this.addThresholds) {
|
||||
_.forEach(alert.thresholds, function (threshold) {
|
||||
_this.zabbixAlertingSrv.setPanelThreshold(options.panelId, threshold);
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
// Create request for each target
|
||||
var promises = _.map(options.targets, function (t) {
|
||||
// Don't request for hidden targets
|
||||
if (t.hide) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var timeFrom = Math.ceil(dateMath.parse(options.range.from) / 1000);
|
||||
var timeTo = Math.ceil(dateMath.parse(options.range.to) / 1000);
|
||||
|
||||
// Prevent changes of original object
|
||||
var target = _.cloneDeep(t);
|
||||
_this.replaceTargetVariables(target, options);
|
||||
|
||||
// Apply Time-related functions (timeShift(), etc)
|
||||
var timeFunctions = bindFunctionDefs(target.functions, 'Time');
|
||||
if (timeFunctions.length) {
|
||||
var _utils$sequence = utils.sequence(timeFunctions)([timeFrom, timeTo]),
|
||||
_utils$sequence2 = _slicedToArray(_utils$sequence, 2),
|
||||
time_from = _utils$sequence2[0],
|
||||
time_to = _utils$sequence2[1];
|
||||
|
||||
timeFrom = time_from;
|
||||
timeTo = time_to;
|
||||
}
|
||||
var timeRange = [timeFrom, timeTo];
|
||||
|
||||
var useTrends = _this.isUseTrends(timeRange);
|
||||
|
||||
// Metrics or Text query mode
|
||||
if (!target.mode || target.mode === c.MODE_METRICS || target.mode === c.MODE_TEXT) {
|
||||
// Migrate old targets
|
||||
target = migrations.migrate(target);
|
||||
|
||||
// Don't request undefined targets
|
||||
if (!target.group || !target.host || !target.item) {
|
||||
return [];
|
||||
}
|
||||
|
||||
if (!target.mode || target.mode === c.MODE_METRICS) {
|
||||
return _this.queryNumericData(target, timeRange, useTrends, options);
|
||||
} else if (target.mode === c.MODE_TEXT) {
|
||||
return _this.queryTextData(target, timeRange);
|
||||
}
|
||||
} else if (target.mode === c.MODE_ITEMID) {
|
||||
// Item ID mode
|
||||
if (!target.itemids) {
|
||||
return [];
|
||||
}
|
||||
return _this.queryItemIdData(target, timeRange, useTrends, options);
|
||||
} else if (target.mode === c.MODE_ITSERVICE) {
|
||||
// IT services mode
|
||||
return _this.queryITServiceData(target, timeRange, options);
|
||||
} else if (target.mode === c.MODE_TRIGGERS) {
|
||||
// Triggers mode
|
||||
return _this.queryTriggersData(target, timeRange);
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
});
|
||||
|
||||
// Data for panel (all targets)
|
||||
return Promise.all(_.flatten(promises)).then(_.flatten).then(function (data) {
|
||||
return { data: data };
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'queryNumericData',
|
||||
value: function queryNumericData(target, timeRange, useTrends, options) {
|
||||
var _this2 = this;
|
||||
|
||||
var getItemOptions = {
|
||||
itemtype: 'num'
|
||||
};
|
||||
return this.zabbix.getItemsFromTarget(target, getItemOptions).then(function (items) {
|
||||
return _this2.queryNumericDataForItems(items, target, timeRange, useTrends, options);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'queryNumericDataForItems',
|
||||
value: function queryNumericDataForItems(items, target, timeRange, useTrends, options) {
|
||||
var _this3 = this;
|
||||
|
||||
var getHistoryPromise = void 0;
|
||||
options.valueType = this.getTrendValueType(target);
|
||||
options.consolidateBy = getConsolidateBy(target) || options.valueType;
|
||||
|
||||
if (useTrends) {
|
||||
getHistoryPromise = this.zabbix.getTrends(items, timeRange, options);
|
||||
} else {
|
||||
getHistoryPromise = this.zabbix.getHistoryTS(items, timeRange, options);
|
||||
}
|
||||
|
||||
return getHistoryPromise.then(function (timeseries) {
|
||||
return _this3.applyDataProcessingFunctions(timeseries, target);
|
||||
}).then(function (timeseries) {
|
||||
return downsampleSeries(timeseries, options);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getTrendValueType',
|
||||
value: function getTrendValueType(target) {
|
||||
// Find trendValue() function and get specified trend value
|
||||
var trendFunctions = _.map(metricFunctions.getCategories()['Trends'], 'name');
|
||||
var trendValueFunc = _.find(target.functions, function (func) {
|
||||
return _.includes(trendFunctions, func.def.name);
|
||||
});
|
||||
return trendValueFunc ? trendValueFunc.params[0] : "avg";
|
||||
}
|
||||
}, {
|
||||
key: 'applyDataProcessingFunctions',
|
||||
value: function applyDataProcessingFunctions(timeseries_data, target) {
|
||||
var transformFunctions = bindFunctionDefs(target.functions, 'Transform');
|
||||
var aggregationFunctions = bindFunctionDefs(target.functions, 'Aggregate');
|
||||
var filterFunctions = bindFunctionDefs(target.functions, 'Filter');
|
||||
var aliasFunctions = bindFunctionDefs(target.functions, 'Alias');
|
||||
|
||||
// Apply transformation functions
|
||||
timeseries_data = _.cloneDeep(_.map(timeseries_data, function (timeseries) {
|
||||
timeseries.datapoints = utils.sequence(transformFunctions)(timeseries.datapoints);
|
||||
return timeseries;
|
||||
}));
|
||||
|
||||
// Apply filter functions
|
||||
if (filterFunctions.length) {
|
||||
timeseries_data = utils.sequence(filterFunctions)(timeseries_data);
|
||||
}
|
||||
|
||||
// Apply aggregations
|
||||
if (aggregationFunctions.length) {
|
||||
var dp = _.map(timeseries_data, 'datapoints');
|
||||
dp = utils.sequence(aggregationFunctions)(dp);
|
||||
|
||||
var aggFuncNames = _.map(metricFunctions.getCategories()['Aggregate'], 'name');
|
||||
var lastAgg = _.findLast(target.functions, function (func) {
|
||||
return _.includes(aggFuncNames, func.def.name);
|
||||
});
|
||||
|
||||
timeseries_data = [{
|
||||
target: lastAgg.text,
|
||||
datapoints: dp
|
||||
}];
|
||||
}
|
||||
|
||||
// Apply alias functions
|
||||
_.forEach(timeseries_data, utils.sequence(aliasFunctions));
|
||||
|
||||
// Apply Time-related functions (timeShift(), etc)
|
||||
// Find timeShift() function and get specified trend value
|
||||
this.applyTimeShiftFunction(timeseries_data, target);
|
||||
|
||||
return timeseries_data;
|
||||
}
|
||||
}, {
|
||||
key: 'applyTimeShiftFunction',
|
||||
value: function applyTimeShiftFunction(timeseries_data, target) {
|
||||
// Find timeShift() function and get specified interval
|
||||
var timeShiftFunc = _.find(target.functions, function (func) {
|
||||
return func.def.name === 'timeShift';
|
||||
});
|
||||
if (timeShiftFunc) {
|
||||
var shift = timeShiftFunc.params[0];
|
||||
_.forEach(timeseries_data, function (series) {
|
||||
series.datapoints = dataProcessor.unShiftTimeSeries(shift, series.datapoints);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'queryTextData',
|
||||
value: function queryTextData(target, timeRange) {
|
||||
var _this4 = this;
|
||||
|
||||
var options = {
|
||||
itemtype: 'text'
|
||||
};
|
||||
return this.zabbix.getItemsFromTarget(target, options).then(function (items) {
|
||||
return _this4.zabbix.getHistoryText(items, timeRange, target);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'queryItemIdData',
|
||||
value: function queryItemIdData(target, timeRange, useTrends, options) {
|
||||
var _this5 = this;
|
||||
|
||||
var itemids = target.itemids;
|
||||
itemids = this.templateSrv.replace(itemids, options.scopedVars, zabbixItemIdsTemplateFormat);
|
||||
itemids = _.map(itemids.split(','), function (itemid) {
|
||||
return itemid.trim();
|
||||
});
|
||||
|
||||
if (!itemids) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return this.zabbix.getItemsByIDs(itemids).then(function (items) {
|
||||
return _this5.queryNumericDataForItems(items, target, timeRange, useTrends, options);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'queryITServiceData',
|
||||
value: function queryITServiceData(target, timeRange, options) {
|
||||
var _this6 = this;
|
||||
|
||||
// Don't show undefined and hidden targets
|
||||
if (target.hide || !target.itservice && !target.itServiceFilter || !target.slaProperty) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var itServiceFilter = void 0;
|
||||
options.isOldVersion = target.itservice && !target.itServiceFilter;
|
||||
|
||||
if (options.isOldVersion) {
|
||||
// Backward compatibility
|
||||
itServiceFilter = '/.*/';
|
||||
} else {
|
||||
itServiceFilter = this.replaceTemplateVars(target.itServiceFilter, options.scopedVars);
|
||||
}
|
||||
|
||||
return this.zabbix.getITServices(itServiceFilter).then(function (itservices) {
|
||||
return _this6.zabbix.getSLA(itservices, timeRange, target, options);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'queryTriggersData',
|
||||
value: function queryTriggersData(target, timeRange) {
|
||||
var _this7 = this;
|
||||
|
||||
var _timeRange = _slicedToArray(timeRange, 2),
|
||||
timeFrom = _timeRange[0],
|
||||
timeTo = _timeRange[1];
|
||||
|
||||
return this.zabbix.getHostsFromTarget(target).then(function (results) {
|
||||
var _results = _slicedToArray(results, 2),
|
||||
hosts = _results[0],
|
||||
apps = _results[1];
|
||||
|
||||
if (hosts.length) {
|
||||
var hostids = _.map(hosts, 'hostid');
|
||||
var appids = _.map(apps, 'applicationid');
|
||||
var options = {
|
||||
minSeverity: target.triggers.minSeverity,
|
||||
acknowledged: target.triggers.acknowledged,
|
||||
count: target.triggers.count,
|
||||
timeFrom: timeFrom,
|
||||
timeTo: timeTo
|
||||
};
|
||||
return _this7.zabbix.getHostAlerts(hostids, appids, options).then(function (triggers) {
|
||||
return responseHandler.handleTriggersResponse(triggers, timeRange);
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'testDatasource',
|
||||
value: function testDatasource() {
|
||||
return this.zabbix.testDataSource().then(function (result) {
|
||||
var zabbixVersion = result.zabbixVersion,
|
||||
dbConnectorStatus = result.dbConnectorStatus;
|
||||
|
||||
var message = 'Zabbix API version: ' + zabbixVersion;
|
||||
if (dbConnectorStatus) {
|
||||
message += ', DB connector type: ' + dbConnectorStatus.dsType;
|
||||
}
|
||||
return {
|
||||
status: "success",
|
||||
title: "Success",
|
||||
message: message
|
||||
};
|
||||
}).catch(function (error) {
|
||||
if (error instanceof ZabbixAPIError) {
|
||||
return {
|
||||
status: "error",
|
||||
title: error.message,
|
||||
message: error.message
|
||||
};
|
||||
} else if (error.data && error.data.message) {
|
||||
return {
|
||||
status: "error",
|
||||
title: "Connection failed",
|
||||
message: "Connection failed: " + error.data.message
|
||||
};
|
||||
} else if (typeof error === 'string') {
|
||||
return {
|
||||
status: "error",
|
||||
title: "Connection failed",
|
||||
message: "Connection failed: " + error
|
||||
};
|
||||
} else {
|
||||
console.log(error);
|
||||
return {
|
||||
status: "error",
|
||||
title: "Connection failed",
|
||||
message: "Could not connect to given url"
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'metricFindQuery',
|
||||
value: function metricFindQuery(query) {
|
||||
var _this8 = this;
|
||||
|
||||
var result = void 0;
|
||||
var parts = [];
|
||||
|
||||
// Split query. Query structure: group.host.app.item
|
||||
_.each(utils.splitTemplateQuery(query), function (part) {
|
||||
part = _this8.replaceTemplateVars(part, {});
|
||||
|
||||
// Replace wildcard to regex
|
||||
if (part === '*') {
|
||||
part = '/.*/';
|
||||
}
|
||||
parts.push(part);
|
||||
});
|
||||
var template = _.zipObject(['group', 'host', 'app', 'item'], parts);
|
||||
|
||||
// Get items
|
||||
if (parts.length === 4) {
|
||||
// Search for all items, even it's not belong to any application
|
||||
if (template.app === '/.*/') {
|
||||
template.app = '';
|
||||
}
|
||||
result = this.zabbix.getItems(template.group, template.host, template.app, template.item);
|
||||
} else if (parts.length === 3) {
|
||||
// Get applications
|
||||
result = this.zabbix.getApps(template.group, template.host, template.app);
|
||||
} else if (parts.length === 2) {
|
||||
// Get hosts
|
||||
result = this.zabbix.getHosts(template.group, template.host);
|
||||
} else if (parts.length === 1) {
|
||||
// Get groups
|
||||
result = this.zabbix.getGroups(template.group);
|
||||
} else {
|
||||
result = Promise.resolve([]);
|
||||
}
|
||||
|
||||
return result.then(function (metrics) {
|
||||
return _.map(metrics, formatMetric);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'annotationQuery',
|
||||
value: function annotationQuery(options) {
|
||||
var _this9 = this;
|
||||
|
||||
var timeFrom = Math.ceil(dateMath.parse(options.rangeRaw.from) / 1000);
|
||||
var timeTo = Math.ceil(dateMath.parse(options.rangeRaw.to) / 1000);
|
||||
var annotation = options.annotation;
|
||||
var showOkEvents = annotation.showOkEvents ? c.SHOW_ALL_EVENTS : c.SHOW_OK_EVENTS;
|
||||
|
||||
// Show all triggers
|
||||
var triggersOptions = {
|
||||
showTriggers: c.SHOW_ALL_TRIGGERS,
|
||||
hideHostsInMaintenance: false
|
||||
};
|
||||
|
||||
var getTriggers = this.zabbix.getTriggers(this.replaceTemplateVars(annotation.group, {}), this.replaceTemplateVars(annotation.host, {}), this.replaceTemplateVars(annotation.application, {}), triggersOptions);
|
||||
|
||||
return getTriggers.then(function (triggers) {
|
||||
|
||||
// Filter triggers by description
|
||||
var triggerName = _this9.replaceTemplateVars(annotation.trigger, {});
|
||||
if (utils.isRegex(triggerName)) {
|
||||
triggers = _.filter(triggers, function (trigger) {
|
||||
return utils.buildRegex(triggerName).test(trigger.description);
|
||||
});
|
||||
} else if (triggerName) {
|
||||
triggers = _.filter(triggers, function (trigger) {
|
||||
return trigger.description === triggerName;
|
||||
});
|
||||
}
|
||||
|
||||
// Remove events below the chose severity
|
||||
triggers = _.filter(triggers, function (trigger) {
|
||||
return Number(trigger.priority) >= Number(annotation.minseverity);
|
||||
});
|
||||
|
||||
var objectids = _.map(triggers, 'triggerid');
|
||||
return _this9.zabbix.getEvents(objectids, timeFrom, timeTo, showOkEvents).then(function (events) {
|
||||
var indexedTriggers = _.keyBy(triggers, 'triggerid');
|
||||
|
||||
// Hide acknowledged events if option enabled
|
||||
if (annotation.hideAcknowledged) {
|
||||
events = _.filter(events, function (event) {
|
||||
return !event.acknowledges.length;
|
||||
});
|
||||
}
|
||||
|
||||
return _.map(events, function (event) {
|
||||
var tags = void 0;
|
||||
if (annotation.showHostname) {
|
||||
tags = _.map(event.hosts, 'name');
|
||||
}
|
||||
|
||||
// Show event type (OK or Problem)
|
||||
var title = Number(event.value) ? 'Problem' : 'OK';
|
||||
|
||||
var formatted_acknowledges = utils.formatAcknowledges(event.acknowledges);
|
||||
return {
|
||||
annotation: annotation,
|
||||
time: event.clock * 1000,
|
||||
title: title,
|
||||
tags: tags,
|
||||
text: indexedTriggers[event.objectid].description + formatted_acknowledges
|
||||
};
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'alertQuery',
|
||||
value: function alertQuery(options) {
|
||||
var _this10 = this;
|
||||
|
||||
var enabled_targets = filterEnabledTargets(options.targets);
|
||||
var getPanelItems = _.map(enabled_targets, function (t) {
|
||||
var target = _.cloneDeep(t);
|
||||
_this10.replaceTargetVariables(target, options);
|
||||
return _this10.zabbix.getItemsFromTarget(target, { itemtype: 'num' });
|
||||
});
|
||||
|
||||
return Promise.all(getPanelItems).then(function (results) {
|
||||
var items = _.flatten(results);
|
||||
var itemids = _.map(items, 'itemid');
|
||||
|
||||
if (itemids.length === 0) {
|
||||
return [];
|
||||
}
|
||||
return _this10.zabbix.getAlerts(itemids);
|
||||
}).then(function (triggers) {
|
||||
triggers = _.filter(triggers, function (trigger) {
|
||||
return trigger.priority >= _this10.alertingMinSeverity;
|
||||
});
|
||||
|
||||
if (!triggers || triggers.length === 0) {
|
||||
return {};
|
||||
}
|
||||
|
||||
var state = 'ok';
|
||||
|
||||
var firedTriggers = _.filter(triggers, { value: '1' });
|
||||
if (firedTriggers.length) {
|
||||
state = 'alerting';
|
||||
}
|
||||
|
||||
var thresholds = _.map(triggers, function (trigger) {
|
||||
return getTriggerThreshold(trigger.expression);
|
||||
});
|
||||
|
||||
return {
|
||||
panelId: options.panelId,
|
||||
state: state,
|
||||
thresholds: thresholds
|
||||
};
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'replaceTargetVariables',
|
||||
value: function replaceTargetVariables(target, options) {
|
||||
var _this11 = this;
|
||||
|
||||
var parts = ['group', 'host', 'application', 'item'];
|
||||
_.forEach(parts, function (p) {
|
||||
if (target[p] && target[p].filter) {
|
||||
target[p].filter = _this11.replaceTemplateVars(target[p].filter, options.scopedVars);
|
||||
}
|
||||
});
|
||||
target.textFilter = this.replaceTemplateVars(target.textFilter, options.scopedVars);
|
||||
|
||||
_.forEach(target.functions, function (func) {
|
||||
func.params = _.map(func.params, function (param) {
|
||||
if (typeof param === 'number') {
|
||||
return +_this11.templateSrv.replace(param.toString(), options.scopedVars);
|
||||
} else {
|
||||
return _this11.templateSrv.replace(param, options.scopedVars);
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'isUseTrends',
|
||||
value: function isUseTrends(timeRange) {
|
||||
var _timeRange2 = _slicedToArray(timeRange, 2),
|
||||
timeFrom = _timeRange2[0],
|
||||
timeTo = _timeRange2[1];
|
||||
|
||||
var useTrendsFrom = Math.ceil(dateMath.parse('now-' + this.trendsFrom) / 1000);
|
||||
var useTrendsRange = Math.ceil(utils.parseInterval(this.trendsRange) / 1000);
|
||||
var useTrends = this.trends && (timeFrom <= useTrendsFrom || timeTo - timeFrom >= useTrendsRange);
|
||||
return useTrends;
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixDatasource;
|
||||
}());
|
||||
|
||||
_export('ZabbixDatasource', ZabbixDatasource);
|
||||
|
||||
if (!_.includes) {
|
||||
_.includes = _.contains;
|
||||
}
|
||||
if (!_.keyBy) {
|
||||
_.keyBy = _.indexBy;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=datasource.js.map
|
||||
1
dist/datasource-zabbix/datasource.js.map
vendored
107
dist/datasource-zabbix/img/zabbix_app_logo.svg
vendored
@@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="100px"
|
||||
height="100px"
|
||||
viewBox="692 0 100 100"
|
||||
style="enable-background:new 692 0 100 100;"
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.91 r"
|
||||
sodipodi:docname="zabbix_app_logo.svg"
|
||||
enable-background="new"><metadata
|
||||
id="metadata13"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs11"><linearGradient
|
||||
id="SVGID_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="2.6005001"
|
||||
y1="65.475197"
|
||||
x2="94.377701"
|
||||
y2="30.245199"><stop
|
||||
id="stop34"
|
||||
style="stop-color:#58595B"
|
||||
offset="0.2583" /><stop
|
||||
id="stop32"
|
||||
style="stop-color:#646C70"
|
||||
offset="0.2917" /><stop
|
||||
id="stop30"
|
||||
style="stop-color:#6C8087"
|
||||
offset="0.3398" /><stop
|
||||
id="stop28"
|
||||
style="stop-color:#6D8F9B"
|
||||
offset="0.3927" /><stop
|
||||
id="stop26"
|
||||
style="stop-color:#689BAA"
|
||||
offset="0.4499" /><stop
|
||||
id="stop24"
|
||||
style="stop-color:#5FA3B5"
|
||||
offset="0.5128" /><stop
|
||||
id="stop22"
|
||||
style="stop-color:#53A8BD"
|
||||
offset="0.5837" /><stop
|
||||
id="stop20"
|
||||
style="stop-color:#47ABC2"
|
||||
offset="0.6674" /><stop
|
||||
id="stop18"
|
||||
style="stop-color:#3FAEC5"
|
||||
offset="0.7759" /><stop
|
||||
id="stop16"
|
||||
style="stop-color:#3CAFC7"
|
||||
offset="1" /><stop
|
||||
id="stop14"
|
||||
style="stop-color:#3BB0C9"
|
||||
offset="1" /></linearGradient></defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1615"
|
||||
inkscape:window-height="1026"
|
||||
id="namedview9"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.285"
|
||||
inkscape:cx="50.424685"
|
||||
inkscape:cy="23.581186"
|
||||
inkscape:window-x="65"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g5194" /><style
|
||||
type="text/css"
|
||||
id="style3">
|
||||
.st0{fill:#787878;}
|
||||
</style><g
|
||||
inkscape:groupmode="layer"
|
||||
id="g5194"
|
||||
inkscape:label="Zabbix BG Original"
|
||||
style="display:inline"><rect
|
||||
style="fill:#d40000;fill-opacity:1"
|
||||
id="rect5196"
|
||||
width="100"
|
||||
height="100"
|
||||
x="692"
|
||||
y="0" /></g><g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer6"
|
||||
inkscape:label="Zabbix Original Z"
|
||||
style="display:inline"><path
|
||||
d="m 715.54426,16.689227 52.91147,0 0,6.87033 -42.58255,52.167008 43.62047,0 0,7.584207 -54.9873,0 0,-6.871516 42.58255,-52.166552 -41.54464,0 0,-7.583477 z"
|
||||
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path4169-6"
|
||||
inkscape:connector-curvature="0" /></g></svg>
|
||||
|
Before Width: | Height: | Size: 3.5 KiB |
@@ -1,255 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['angular', 'lodash', 'jquery'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var angular, _, $, DOCS_FUNC_REF_URL;
|
||||
|
||||
return {
|
||||
setters: [function (_angular) {
|
||||
angular = _angular.default;
|
||||
}, function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_jquery) {
|
||||
$ = _jquery.default;
|
||||
}],
|
||||
execute: function () {
|
||||
DOCS_FUNC_REF_URL = 'http://docs.grafana-zabbix.org/reference/functions/';
|
||||
|
||||
|
||||
angular.module('grafana.directives').directive('metricFunctionEditor',
|
||||
|
||||
/** @ngInject */
|
||||
function ($compile, templateSrv) {
|
||||
|
||||
var funcSpanTemplate = '<a ng-click="">{{func.def.name}}</a><span>(</span>';
|
||||
var paramTemplate = '<input type="text" style="display:none"' + ' class="input-mini tight-form-func-param"></input>';
|
||||
|
||||
var funcControlsTemplate = '<div class="tight-form-func-controls">' + '<span class="pointer fa fa-arrow-left"></span>' + '<span class="pointer fa fa-question-circle"></span>' + '<span class="pointer fa fa-remove" ></span>' + '<span class="pointer fa fa-arrow-right"></span>' + '</div>';
|
||||
|
||||
return {
|
||||
restrict: 'A',
|
||||
link: function postLink($scope, elem) {
|
||||
var $funcLink = $(funcSpanTemplate);
|
||||
var $funcControls = $(funcControlsTemplate);
|
||||
var ctrl = $scope.ctrl;
|
||||
var func = $scope.func;
|
||||
var funcDef = func.def;
|
||||
var scheduledRelink = false;
|
||||
var paramCountAtLink = 0;
|
||||
|
||||
function clickFuncParam(paramIndex) {
|
||||
/*jshint validthis:true */
|
||||
|
||||
var $link = $(this);
|
||||
var $input = $link.next();
|
||||
|
||||
$input.val(func.params[paramIndex]);
|
||||
$input.css('width', $link.width() + 16 + 'px');
|
||||
|
||||
$link.hide();
|
||||
$input.show();
|
||||
$input.focus();
|
||||
$input.select();
|
||||
|
||||
var typeahead = $input.data('typeahead');
|
||||
if (typeahead) {
|
||||
$input.val('');
|
||||
typeahead.lookup();
|
||||
}
|
||||
}
|
||||
|
||||
function scheduledRelinkIfNeeded() {
|
||||
if (paramCountAtLink === func.params.length) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!scheduledRelink) {
|
||||
scheduledRelink = true;
|
||||
setTimeout(function () {
|
||||
relink();
|
||||
scheduledRelink = false;
|
||||
}, 200);
|
||||
}
|
||||
}
|
||||
|
||||
function inputBlur(paramIndex) {
|
||||
/*jshint validthis:true */
|
||||
var $input = $(this);
|
||||
var $link = $input.prev();
|
||||
var newValue = $input.val();
|
||||
|
||||
if (newValue !== '' || func.def.params[paramIndex].optional) {
|
||||
$link.html(templateSrv.highlightVariablesAsHtml(newValue));
|
||||
|
||||
func.updateParam($input.val(), paramIndex);
|
||||
scheduledRelinkIfNeeded();
|
||||
|
||||
$scope.$apply(function () {
|
||||
ctrl.targetChanged();
|
||||
});
|
||||
|
||||
$input.hide();
|
||||
$link.show();
|
||||
}
|
||||
}
|
||||
|
||||
function inputKeyPress(paramIndex, e) {
|
||||
/*jshint validthis:true */
|
||||
if (e.which === 13) {
|
||||
inputBlur.call(this, paramIndex);
|
||||
}
|
||||
}
|
||||
|
||||
function inputKeyDown() {
|
||||
/*jshint validthis:true */
|
||||
this.style.width = (3 + this.value.length) * 8 + 'px';
|
||||
}
|
||||
|
||||
function addTypeahead($input, paramIndex) {
|
||||
$input.attr('data-provide', 'typeahead');
|
||||
|
||||
var options = funcDef.params[paramIndex].options;
|
||||
if (funcDef.params[paramIndex].type === 'int' || funcDef.params[paramIndex].type === 'float') {
|
||||
options = _.map(options, function (val) {
|
||||
return val.toString();
|
||||
});
|
||||
}
|
||||
|
||||
$input.typeahead({
|
||||
source: options,
|
||||
minLength: 0,
|
||||
items: 20,
|
||||
updater: function updater(value) {
|
||||
setTimeout(function () {
|
||||
inputBlur.call($input[0], paramIndex);
|
||||
}, 0);
|
||||
return value;
|
||||
}
|
||||
});
|
||||
|
||||
var typeahead = $input.data('typeahead');
|
||||
typeahead.lookup = function () {
|
||||
this.query = this.$element.val() || '';
|
||||
return this.process(this.source);
|
||||
};
|
||||
}
|
||||
|
||||
function toggleFuncControls() {
|
||||
var targetDiv = elem.closest('.tight-form');
|
||||
|
||||
if (elem.hasClass('show-function-controls')) {
|
||||
elem.removeClass('show-function-controls');
|
||||
targetDiv.removeClass('has-open-function');
|
||||
$funcControls.hide();
|
||||
return;
|
||||
}
|
||||
|
||||
elem.addClass('show-function-controls');
|
||||
targetDiv.addClass('has-open-function');
|
||||
|
||||
$funcControls.show();
|
||||
}
|
||||
|
||||
function addElementsAndCompile() {
|
||||
$funcControls.appendTo(elem);
|
||||
$funcLink.appendTo(elem);
|
||||
|
||||
_.each(funcDef.params, function (param, index) {
|
||||
if (param.optional && func.params.length <= index) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (index > 0) {
|
||||
$('<span>, </span>').appendTo(elem);
|
||||
}
|
||||
|
||||
var paramValue = templateSrv.highlightVariablesAsHtml(func.params[index]);
|
||||
var $paramLink = $('<a ng-click="" class="graphite-func-param-link">' + paramValue + '</a>');
|
||||
var $input = $(paramTemplate);
|
||||
|
||||
paramCountAtLink++;
|
||||
|
||||
$paramLink.appendTo(elem);
|
||||
$input.appendTo(elem);
|
||||
|
||||
$input.blur(_.partial(inputBlur, index));
|
||||
$input.keyup(inputKeyDown);
|
||||
$input.keypress(_.partial(inputKeyPress, index));
|
||||
$paramLink.click(_.partial(clickFuncParam, index));
|
||||
|
||||
if (funcDef.params[index].options) {
|
||||
addTypeahead($input, index);
|
||||
}
|
||||
});
|
||||
|
||||
$('<span>)</span>').appendTo(elem);
|
||||
|
||||
$compile(elem.contents())($scope);
|
||||
}
|
||||
|
||||
function ifJustAddedFocusFistParam() {
|
||||
if ($scope.func.added) {
|
||||
$scope.func.added = false;
|
||||
setTimeout(function () {
|
||||
elem.find('.graphite-func-param-link').first().click();
|
||||
}, 10);
|
||||
}
|
||||
}
|
||||
|
||||
function registerFuncControlsToggle() {
|
||||
$funcLink.click(toggleFuncControls);
|
||||
}
|
||||
|
||||
function registerFuncControlsActions() {
|
||||
$funcControls.click(function (e) {
|
||||
var $target = $(e.target);
|
||||
if ($target.hasClass('fa-remove')) {
|
||||
toggleFuncControls();
|
||||
$scope.$apply(function () {
|
||||
ctrl.removeFunction($scope.func);
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target.hasClass('fa-arrow-left')) {
|
||||
$scope.$apply(function () {
|
||||
_.move($scope.target.functions, $scope.$index, $scope.$index - 1);
|
||||
ctrl.targetChanged();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target.hasClass('fa-arrow-right')) {
|
||||
$scope.$apply(function () {
|
||||
_.move($scope.target.functions, $scope.$index, $scope.$index + 1);
|
||||
ctrl.targetChanged();
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
if ($target.hasClass('fa-question-circle')) {
|
||||
var docSite = DOCS_FUNC_REF_URL;
|
||||
window.open(docSite + '#' + funcDef.name.toLowerCase(), '_blank');
|
||||
return;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
function relink() {
|
||||
elem.children().remove();
|
||||
|
||||
addElementsAndCompile();
|
||||
ifJustAddedFocusFistParam();
|
||||
registerFuncControlsToggle();
|
||||
registerFuncControlsActions();
|
||||
}
|
||||
|
||||
relink();
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=metric-function-editor.directive.js.map
|
||||
380
dist/datasource-zabbix/metricFunctions.js
vendored
@@ -1,380 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', 'jquery'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, $, _createClass, index, categories, FuncInstance;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
function addFuncDef(funcDef) {
|
||||
funcDef.params = funcDef.params || [];
|
||||
funcDef.defaultParams = funcDef.defaultParams || [];
|
||||
|
||||
if (funcDef.category) {
|
||||
categories[funcDef.category].push(funcDef);
|
||||
}
|
||||
index[funcDef.name] = funcDef;
|
||||
index[funcDef.shortName || funcDef.name] = funcDef;
|
||||
}
|
||||
|
||||
// Transform
|
||||
|
||||
function createFuncInstance(funcDef, params) {
|
||||
if (_.isString(funcDef)) {
|
||||
if (!index[funcDef]) {
|
||||
throw { message: 'Method not found ' + name };
|
||||
}
|
||||
funcDef = index[funcDef];
|
||||
}
|
||||
return new FuncInstance(funcDef, params);
|
||||
}
|
||||
|
||||
_export('createFuncInstance', createFuncInstance);
|
||||
|
||||
function getFuncDef(name) {
|
||||
return index[name];
|
||||
}
|
||||
|
||||
_export('getFuncDef', getFuncDef);
|
||||
|
||||
function getCategories() {
|
||||
return categories;
|
||||
}
|
||||
|
||||
_export('getCategories', getCategories);
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_jquery) {
|
||||
$ = _jquery.default;
|
||||
}],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
index = [];
|
||||
categories = {
|
||||
Transform: [],
|
||||
Aggregate: [],
|
||||
Filter: [],
|
||||
Trends: [],
|
||||
Time: [],
|
||||
Alias: [],
|
||||
Special: []
|
||||
};
|
||||
addFuncDef({
|
||||
name: 'groupBy',
|
||||
category: 'Transform',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: ['1m', 'avg']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'scale',
|
||||
category: 'Transform',
|
||||
params: [{ name: 'factor', type: 'float', options: [100, 0.01, 10, -1] }],
|
||||
defaultParams: [100]
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'delta',
|
||||
category: 'Transform',
|
||||
params: [],
|
||||
defaultParams: []
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'rate',
|
||||
category: 'Transform',
|
||||
params: [],
|
||||
defaultParams: []
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'movingAverage',
|
||||
category: 'Transform',
|
||||
params: [{ name: 'factor', type: 'int', options: [6, 10, 60, 100, 600] }],
|
||||
defaultParams: [10]
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'exponentialMovingAverage',
|
||||
category: 'Transform',
|
||||
params: [{ name: 'smoothing', type: 'float', options: [6, 10, 60, 100, 600] }],
|
||||
defaultParams: [0.2]
|
||||
});
|
||||
|
||||
// Aggregate
|
||||
|
||||
addFuncDef({
|
||||
name: 'sumSeries',
|
||||
category: 'Aggregate',
|
||||
params: [],
|
||||
defaultParams: []
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'median',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'average',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'percentil',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'percent', type: 'float', options: [25, 50, 75, 90, 95, 99, 99.9] }],
|
||||
defaultParams: ['1m', 95]
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'min',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'max',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'sum',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'count',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }],
|
||||
defaultParams: ['1m']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'aggregateBy',
|
||||
category: 'Aggregate',
|
||||
params: [{ name: 'interval', type: 'string' }, { name: 'function', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: ['1m', 'avg']
|
||||
});
|
||||
|
||||
// Filter
|
||||
|
||||
addFuncDef({
|
||||
name: 'top',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: [5, 'avg']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'bottom',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'number', type: 'int' }, { name: 'value', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count', 'median'] }],
|
||||
defaultParams: [5, 'avg']
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'sortSeries',
|
||||
category: 'Filter',
|
||||
params: [{ name: 'direction', type: 'string', options: ['asc', 'desc'] }],
|
||||
defaultParams: ['asc']
|
||||
});
|
||||
|
||||
// Trends
|
||||
|
||||
addFuncDef({
|
||||
name: 'trendValue',
|
||||
category: 'Trends',
|
||||
params: [{ name: 'type', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count'] }],
|
||||
defaultParams: ['avg']
|
||||
});
|
||||
|
||||
// Time
|
||||
|
||||
addFuncDef({
|
||||
name: 'timeShift',
|
||||
category: 'Time',
|
||||
params: [{ name: 'interval', type: 'string', options: ['24h', '7d', '1M', '+24h', '-24h'] }],
|
||||
defaultParams: ['24h']
|
||||
});
|
||||
|
||||
//Alias
|
||||
|
||||
addFuncDef({
|
||||
name: 'setAlias',
|
||||
category: 'Alias',
|
||||
params: [{ name: 'alias', type: 'string' }],
|
||||
defaultParams: []
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'setAliasByRegex',
|
||||
category: 'Alias',
|
||||
params: [{ name: 'aliasByRegex', type: 'string' }],
|
||||
defaultParams: []
|
||||
});
|
||||
|
||||
addFuncDef({
|
||||
name: 'replaceAlias',
|
||||
category: 'Alias',
|
||||
params: [{ name: 'regexp', type: 'string' }, { name: 'newAlias', type: 'string' }],
|
||||
defaultParams: ['/(.*)/', '$1']
|
||||
});
|
||||
|
||||
// Special
|
||||
addFuncDef({
|
||||
name: 'consolidateBy',
|
||||
category: 'Special',
|
||||
params: [{ name: 'type', type: 'string', options: ['avg', 'min', 'max', 'sum', 'count'] }],
|
||||
defaultParams: ['avg']
|
||||
});
|
||||
|
||||
_.each(categories, function (funcList, catName) {
|
||||
categories[catName] = _.sortBy(funcList, 'name');
|
||||
});
|
||||
|
||||
FuncInstance = function () {
|
||||
function FuncInstance(funcDef, params) {
|
||||
_classCallCheck(this, FuncInstance);
|
||||
|
||||
this.def = funcDef;
|
||||
|
||||
if (params) {
|
||||
this.params = params;
|
||||
} else {
|
||||
// Create with default params
|
||||
this.params = [];
|
||||
this.params = funcDef.defaultParams.slice(0);
|
||||
}
|
||||
|
||||
this.updateText();
|
||||
}
|
||||
|
||||
_createClass(FuncInstance, [{
|
||||
key: 'bindFunction',
|
||||
value: function bindFunction(metricFunctions) {
|
||||
var func = metricFunctions[this.def.name];
|
||||
if (func) {
|
||||
|
||||
// Bind function arguments
|
||||
var bindedFunc = func;
|
||||
var param;
|
||||
for (var i = 0; i < this.params.length; i++) {
|
||||
param = this.params[i];
|
||||
|
||||
// Convert numeric params
|
||||
if (this.def.params[i].type === 'int' || this.def.params[i].type === 'float') {
|
||||
param = Number(param);
|
||||
}
|
||||
bindedFunc = _.partial(bindedFunc, param);
|
||||
}
|
||||
return bindedFunc;
|
||||
} else {
|
||||
throw { message: 'Method not found ' + this.def.name };
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'render',
|
||||
value: function render(metricExp) {
|
||||
var str = this.def.name + '(';
|
||||
var parameters = _.map(this.params, function (value, index) {
|
||||
|
||||
var paramType = this.def.params[index].type;
|
||||
if (paramType === 'int' || paramType === 'float' || paramType === 'value_or_series' || paramType === 'boolean') {
|
||||
return value;
|
||||
} else if (paramType === 'int_or_interval' && $.isNumeric(value)) {
|
||||
return value;
|
||||
}
|
||||
|
||||
return "'" + value + "'";
|
||||
}, this);
|
||||
|
||||
if (metricExp) {
|
||||
parameters.unshift(metricExp);
|
||||
}
|
||||
|
||||
return str + parameters.join(', ') + ')';
|
||||
}
|
||||
}, {
|
||||
key: '_hasMultipleParamsInString',
|
||||
value: function _hasMultipleParamsInString(strValue, index) {
|
||||
if (strValue.indexOf(',') === -1) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return this.def.params[index + 1] && this.def.params[index + 1].optional;
|
||||
}
|
||||
}, {
|
||||
key: 'updateParam',
|
||||
value: function updateParam(strValue, index) {
|
||||
// handle optional parameters
|
||||
// if string contains ',' and next param is optional, split and update both
|
||||
if (this._hasMultipleParamsInString(strValue, index)) {
|
||||
_.each(strValue.split(','), function (partVal, idx) {
|
||||
this.updateParam(partVal.trim(), idx);
|
||||
}, this);
|
||||
return;
|
||||
}
|
||||
|
||||
if (strValue === '' && this.def.params[index].optional) {
|
||||
this.params.splice(index, 1);
|
||||
} else {
|
||||
this.params[index] = strValue;
|
||||
}
|
||||
|
||||
this.updateText();
|
||||
}
|
||||
}, {
|
||||
key: 'updateText',
|
||||
value: function updateText() {
|
||||
if (this.params.length === 0) {
|
||||
this.text = this.def.name + '()';
|
||||
return;
|
||||
}
|
||||
|
||||
var text = this.def.name + '(';
|
||||
text += this.params.join(', ');
|
||||
text += ')';
|
||||
this.text = text;
|
||||
}
|
||||
}]);
|
||||
|
||||
return FuncInstance;
|
||||
}();
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=metricFunctions.js.map
|
||||
84
dist/datasource-zabbix/migrations.js
vendored
@@ -1,84 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var DS_CONFIG_SCHEMA;
|
||||
/**
|
||||
* Query format migration.
|
||||
* This module can detect query format version and make migration.
|
||||
*/
|
||||
|
||||
function isGrafana2target(target) {
|
||||
if (!target.mode || target.mode === 0 || target.mode === 2) {
|
||||
if ((target.hostFilter || target.itemFilter || target.downsampleFunction || target.host && target.host.host) && target.item.filter === undefined && target.host.filter === undefined) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_export("isGrafana2target", isGrafana2target);
|
||||
|
||||
function migrateFrom2To3version(target) {
|
||||
target.group.filter = target.group.name === "*" ? "/.*/" : target.group.name;
|
||||
target.host.filter = target.host.name === "*" ? convertToRegex(target.hostFilter) : target.host.name;
|
||||
target.application.filter = target.application.name === "*" ? "" : target.application.name;
|
||||
target.item.filter = target.item.name === "All" ? convertToRegex(target.itemFilter) : target.item.name;
|
||||
return target;
|
||||
}
|
||||
_export("migrateFrom2To3version", migrateFrom2To3version);
|
||||
|
||||
function migrate(target) {
|
||||
target.resultFormat = target.resultFormat || 'time_series';
|
||||
if (isGrafana2target(target)) {
|
||||
return migrateFrom2To3version(target);
|
||||
} else {
|
||||
return target;
|
||||
}
|
||||
}
|
||||
|
||||
_export("migrate", migrate);
|
||||
|
||||
function convertToRegex(str) {
|
||||
if (str) {
|
||||
return '/' + str + '/';
|
||||
} else {
|
||||
return '/.*/';
|
||||
}
|
||||
}function migrateDSConfig(jsonData) {
|
||||
if (!jsonData) {
|
||||
jsonData = {};
|
||||
}
|
||||
var oldVersion = jsonData.schema || 1;
|
||||
jsonData.schema = DS_CONFIG_SCHEMA;
|
||||
|
||||
if (oldVersion === DS_CONFIG_SCHEMA) {
|
||||
return jsonData;
|
||||
}
|
||||
|
||||
if (oldVersion < 2) {
|
||||
var dbConnectionOptions = jsonData.dbConnection || {};
|
||||
jsonData.dbConnectionEnable = dbConnectionOptions.enable || false;
|
||||
jsonData.dbConnectionDatasourceId = dbConnectionOptions.datasourceId || null;
|
||||
delete jsonData.dbConnection;
|
||||
}
|
||||
|
||||
return jsonData;
|
||||
}
|
||||
|
||||
_export("migrateDSConfig", migrateDSConfig);
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_export("DS_CONFIG_SCHEMA", DS_CONFIG_SCHEMA = 2);
|
||||
|
||||
_export("DS_CONFIG_SCHEMA", DS_CONFIG_SCHEMA);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=migrations.js.map
|
||||
1
dist/datasource-zabbix/migrations.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/migrations.js"],"names":["isGrafana2target","target","mode","hostFilter","itemFilter","downsampleFunction","host","item","filter","undefined","migrateFrom2To3version","group","name","convertToRegex","application","migrate","resultFormat","str","migrateDSConfig","jsonData","oldVersion","schema","DS_CONFIG_SCHEMA","dbConnectionOptions","dbConnection","dbConnectionEnable","enable","dbConnectionDatasourceId","datasourceId"],"mappings":";;;;;;AAAA;;;;;AAKO,WAASA,gBAAT,CAA0BC,MAA1B,EAAkC;AACvC,QAAI,CAACA,OAAOC,IAAR,IAAgBD,OAAOC,IAAP,KAAgB,CAAhC,IAAqCD,OAAOC,IAAP,KAAgB,CAAzD,EAA4D;AAC1D,UAAI,CAACD,OAAOE,UAAP,IAAqBF,OAAOG,UAA5B,IAA0CH,OAAOI,kBAAjD,IACAJ,OAAOK,IAAP,IAAeL,OAAOK,IAAP,CAAYA,IAD5B,KAECL,OAAOM,IAAP,CAAYC,MAAZ,KAAuBC,SAAvB,IAAoCR,OAAOK,IAAP,CAAYE,MAAZ,KAAuBC,SAFhE,EAE4E;AAC1E,eAAO,IAAP;AACD,OAJD,MAIO;AACL,eAAO,KAAP;AACD;AACF,KARD,MAQO;AACL,aAAO,KAAP;AACD;AACF;;8BAZeT,gB;;AAcT,WAASU,sBAAT,CAAgCT,MAAhC,EAAwC;AAC7CA,WAAOU,KAAP,CAAaH,MAAb,GAAsBP,OAAOU,KAAP,CAAaC,IAAb,KAAsB,GAAtB,GAA4B,MAA5B,GAAqCX,OAAOU,KAAP,CAAaC,IAAxE;AACAX,WAAOK,IAAP,CAAYE,MAAZ,GAAqBP,OAAOK,IAAP,CAAYM,IAAZ,KAAqB,GAArB,GAA2BC,eAAeZ,OAAOE,UAAtB,CAA3B,GAA+DF,OAAOK,IAAP,CAAYM,IAAhG;AACAX,WAAOa,WAAP,CAAmBN,MAAnB,GAA4BP,OAAOa,WAAP,CAAmBF,IAAnB,KAA4B,GAA5B,GAAkC,EAAlC,GAAuCX,OAAOa,WAAP,CAAmBF,IAAtF;AACAX,WAAOM,IAAP,CAAYC,MAAZ,GAAqBP,OAAOM,IAAP,CAAYK,IAAZ,KAAqB,KAArB,GAA6BC,eAAeZ,OAAOG,UAAtB,CAA7B,GAAiEH,OAAOM,IAAP,CAAYK,IAAlG;AACA,WAAOX,MAAP;AACD;oCANeS,sB;;AAQT,WAASK,OAAT,CAAiBd,MAAjB,EAAyB;AAC9BA,WAAOe,YAAP,GAAsBf,OAAOe,YAAP,IAAuB,aAA7C;AACA,QAAIhB,iBAAiBC,MAAjB,CAAJ,EAA8B;AAC5B,aAAOS,uBAAuBT,MAAvB,CAAP;AACD,KAFD,MAEO;AACL,aAAOA,MAAP;AACD;AACF;;qBAPec,O;;AAShB,WAASF,cAAT,CAAwBI,GAAxB,EAA6B;AAC3B,QAAIA,GAAJ,EAAS;AACP,aAAO,MAAMA,GAAN,GAAY,GAAnB;AACD,KAFD,MAEO;AACL,aAAO,MAAP;AACD;AACF,GAGM,SAASC,eAAT,CAAyBC,QAAzB,EAAmC;AACxC,QAAI,CAACA,QAAL,EAAe;AACbA,iBAAW,EAAX;AACD;AACD,QAAMC,aAAaD,SAASE,MAAT,IAAmB,CAAtC;AACAF,aAASE,MAAT,GAAkBC,gBAAlB;;AAEA,QAAIF,eAAeE,gBAAnB,EAAqC;AACnC,aAAOH,QAAP;AACD;;AAED,QAAIC,aAAa,CAAjB,EAAoB;AAClB,UAAMG,sBAAsBJ,SAASK,YAAT,IAAyB,EAArD;AACAL,eAASM,kBAAT,GAA8BF,oBAAoBG,MAApB,IAA8B,KAA5D;AACAP,eAASQ,wBAAT,GAAoCJ,oBAAoBK,YAApB,IAAoC,IAAxE;AACA,aAAOT,SAASK,YAAhB;AACD;;AAED,WAAOL,QAAP;AACD;;6BAnBeD,e;;;;;kCADHI,gB,GAAmB,C","file":"migrations.js","sourcesContent":["/**\n * Query format migration.\n * This module can detect query format version and make migration.\n */\n\nexport function isGrafana2target(target) {\n if (!target.mode || target.mode === 0 || target.mode === 2) {\n if ((target.hostFilter || target.itemFilter || target.downsampleFunction ||\n (target.host && target.host.host)) &&\n (target.item.filter === undefined && target.host.filter === undefined)) {\n return true;\n } else {\n return false;\n }\n } else {\n return false;\n }\n}\n\nexport function migrateFrom2To3version(target) {\n target.group.filter = target.group.name === \"*\" ? \"/.*/\" : target.group.name;\n target.host.filter = target.host.name === \"*\" ? convertToRegex(target.hostFilter) : target.host.name;\n target.application.filter = target.application.name === \"*\" ? \"\" : target.application.name;\n target.item.filter = target.item.name === \"All\" ? convertToRegex(target.itemFilter) : target.item.name;\n return target;\n}\n\nexport function migrate(target) {\n target.resultFormat = target.resultFormat || 'time_series';\n if (isGrafana2target(target)) {\n return migrateFrom2To3version(target);\n } else {\n return target;\n }\n}\n\nfunction convertToRegex(str) {\n if (str) {\n return '/' + str + '/';\n } else {\n return '/.*/';\n }\n}\n\nexport const DS_CONFIG_SCHEMA = 2;\nexport function migrateDSConfig(jsonData) {\n if (!jsonData) {\n jsonData = {};\n }\n const oldVersion = jsonData.schema || 1;\n jsonData.schema = DS_CONFIG_SCHEMA;\n\n if (oldVersion === DS_CONFIG_SCHEMA) {\n return jsonData;\n }\n\n if (oldVersion < 2) {\n const dbConnectionOptions = jsonData.dbConnection || {};\n jsonData.dbConnectionEnable = dbConnectionOptions.enable || false;\n jsonData.dbConnectionDatasourceId = dbConnectionOptions.datasourceId || null;\n delete jsonData.dbConnection;\n }\n\n return jsonData;\n}\n"]}
|
||||
58
dist/datasource-zabbix/module.js
vendored
@@ -1,58 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['app/plugins/sdk', './datasource', './query.controller', './config.controller', './zabbixAlerting.service.js', './add-metric-function.directive', './metric-function-editor.directive'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var loadPluginCss, ZabbixDatasource, ZabbixQueryController, ZabbixDSConfigController, ZabbixQueryOptionsController, ZabbixAnnotationsQueryController;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_appPluginsSdk) {
|
||||
loadPluginCss = _appPluginsSdk.loadPluginCss;
|
||||
}, function (_datasource) {
|
||||
ZabbixDatasource = _datasource.ZabbixDatasource;
|
||||
}, function (_queryController) {
|
||||
ZabbixQueryController = _queryController.ZabbixQueryController;
|
||||
}, function (_configController) {
|
||||
ZabbixDSConfigController = _configController.ZabbixDSConfigController;
|
||||
}, function (_zabbixAlertingServiceJs) {}, function (_addMetricFunctionDirective) {}, function (_metricFunctionEditorDirective) {}],
|
||||
execute: function () {
|
||||
|
||||
loadPluginCss({
|
||||
dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',
|
||||
light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'
|
||||
});
|
||||
|
||||
_export('QueryOptionsCtrl', ZabbixQueryOptionsController = function ZabbixQueryOptionsController() {
|
||||
_classCallCheck(this, ZabbixQueryOptionsController);
|
||||
});
|
||||
|
||||
ZabbixQueryOptionsController.templateUrl = 'datasource-zabbix/partials/query.options.html';
|
||||
|
||||
_export('AnnotationsQueryCtrl', ZabbixAnnotationsQueryController = function ZabbixAnnotationsQueryController() {
|
||||
_classCallCheck(this, ZabbixAnnotationsQueryController);
|
||||
});
|
||||
|
||||
ZabbixAnnotationsQueryController.templateUrl = 'datasource-zabbix/partials/annotations.editor.html';
|
||||
|
||||
ZabbixQueryController.templateUrl = 'datasource-zabbix/partials/query.editor.html';
|
||||
ZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';
|
||||
|
||||
_export('Datasource', ZabbixDatasource);
|
||||
|
||||
_export('ConfigCtrl', ZabbixDSConfigController);
|
||||
|
||||
_export('QueryCtrl', ZabbixQueryController);
|
||||
|
||||
_export('QueryOptionsCtrl', ZabbixQueryOptionsController);
|
||||
|
||||
_export('AnnotationsQueryCtrl', ZabbixAnnotationsQueryController);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=module.js.map
|
||||
1
dist/datasource-zabbix/module.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/datasource-zabbix/module.js"],"names":["loadPluginCss","ZabbixDatasource","ZabbixQueryController","ZabbixDSConfigController","dark","light","ZabbixQueryOptionsController","templateUrl","ZabbixAnnotationsQueryController"],"mappings":";;;;;;;;;;;;;;;AAASA,mB,kBAAAA,a;;AACAC,sB,eAAAA,gB;;AACAC,2B,oBAAAA,qB;;AACAC,8B,qBAAAA,wB;;;;AAKTH,oBAAc;AACZI,cAAM,gEADM;AAEZC,eAAO;AAFK,OAAd;;kCAKMC,4B;;;;AACNA,mCAA6BC,WAA7B,GAA2C,+CAA3C;;sCAEMC,gC;;;;AACNA,uCAAiCD,WAAjC,GAA+C,oDAA/C;;AAEAL,4BAAsBK,WAAtB,GAAoC,8CAApC;AACAJ,+BAAyBI,WAAzB,GAAuC,wCAAvC;;4BAGEN,gB;;4BACAE,wB;;2BACAD,qB;;kCACAI,4B;;sCACAE,gC","file":"module.js","sourcesContent":["import { loadPluginCss } from 'app/plugins/sdk';\nimport { ZabbixDatasource } from './datasource';\nimport { ZabbixQueryController } from './query.controller';\nimport { ZabbixDSConfigController } from './config.controller';\nimport './zabbixAlerting.service.js';\nimport './add-metric-function.directive';\nimport './metric-function-editor.directive';\n\nloadPluginCss({\n dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',\n light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'\n});\n\nclass ZabbixQueryOptionsController {}\nZabbixQueryOptionsController.templateUrl = 'datasource-zabbix/partials/query.options.html';\n\nclass ZabbixAnnotationsQueryController {}\nZabbixAnnotationsQueryController.templateUrl = 'datasource-zabbix/partials/annotations.editor.html';\n\nZabbixQueryController.templateUrl = 'datasource-zabbix/partials/query.editor.html';\nZabbixDSConfigController.templateUrl = 'datasource-zabbix/partials/config.html';\n\nexport {\n ZabbixDatasource as Datasource,\n ZabbixDSConfigController as ConfigCtrl,\n ZabbixQueryController as QueryCtrl,\n ZabbixQueryOptionsController as QueryOptionsCtrl,\n ZabbixAnnotationsQueryController as AnnotationsQueryCtrl\n};\n"]}
|
||||
@@ -1,65 +0,0 @@
|
||||
<div class="gf-form-group">
|
||||
<h6>Filter Triggers</h6>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Group</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.group">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Host</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.host">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Application</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.application">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Trigger</span>
|
||||
<input type="text"
|
||||
class="gf-form-input max-width-16"
|
||||
ng-model="ctrl.annotation.trigger">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-group">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">Minimum severity</span>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input gf-size-auto"
|
||||
ng-init='ctrl.annotation.minseverity = ctrl.annotation.minseverity || 0'
|
||||
ng-model='ctrl.annotation.minseverity'
|
||||
ng-options="v as k for (k, v) in {
|
||||
'Not classified': 0,
|
||||
'Information': 1,
|
||||
'Warning': 2,
|
||||
'Average': 3,
|
||||
'High': 4,
|
||||
'Disaster': 5
|
||||
}"
|
||||
ng-change="render()">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-group">
|
||||
<h6>Options</h6>
|
||||
<div class="gf-form">
|
||||
<editor-checkbox text="Show OK events" model="ctrl.annotation.showOkEvents"></editor-checkbox>
|
||||
<editor-checkbox text="Hide acknowledged events" model="ctrl.annotation.hideAcknowledged"></editor-checkbox>
|
||||
<editor-checkbox text="Show hostname" model="ctrl.annotation.showHostname"></editor-checkbox>
|
||||
</div>
|
||||
</div>
|
||||
136
dist/datasource-zabbix/partials/config.html
vendored
@@ -1,136 +0,0 @@
|
||||
<datasource-http-settings current="ctrl.current" suggest-url="http://localhost/zabbix/api_jsonrpc.php">
|
||||
</datasource-http-settings>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Zabbix API details</h3>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">
|
||||
Username
|
||||
</span>
|
||||
<input class="gf-form-input max-width-21"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.username'
|
||||
placeholder="user"
|
||||
required>
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-7">
|
||||
Password
|
||||
</span>
|
||||
<input class="gf-form-input max-width-21"
|
||||
type="password"
|
||||
ng-model='ctrl.current.jsonData.password'
|
||||
placeholder="password">
|
||||
</input>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label-class="width-7"
|
||||
label="Trends"
|
||||
checked="ctrl.current.jsonData.trends"
|
||||
switch-class="max-width-5">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form" ng-if="ctrl.current.jsonData.trends">
|
||||
<span class="gf-form-label width-7">
|
||||
After
|
||||
<info-popover mode="right-normal">
|
||||
Time after which trends will be used.
|
||||
Best practice is to set this value to your history storage period (7d, 30d, etc).
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.trendsFrom'
|
||||
placeholder="7d">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form" ng-if="ctrl.current.jsonData.trends">
|
||||
<span class="gf-form-label width-7">
|
||||
Range
|
||||
<info-popover mode="right-normal">
|
||||
Time range width after which trends will be used instead of history.
|
||||
It's better to set this value in range of 4 to 7 days to prevent loading large amount of history data.
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5" type="text" ng-model='ctrl.current.jsonData.trendsRange' placeholder="4d">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-12">
|
||||
Cache TTL
|
||||
<info-popover mode="right-normal">
|
||||
Zabbix data source caches metric names in memory. Specify how often data will be updated.
|
||||
</info-popover>
|
||||
</span>
|
||||
<input class="gf-form-input max-width-5"
|
||||
type="text"
|
||||
ng-model='ctrl.current.jsonData.cacheTTL'
|
||||
placeholder="1h">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Direct DB Connection</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Enable"
|
||||
checked="ctrl.current.jsonData.dbConnectionEnable">
|
||||
</gf-form-switch>
|
||||
<div ng-if="ctrl.current.jsonData.dbConnectionEnable">
|
||||
<div class="gf-form max-width-20">
|
||||
<span class="gf-form-label width-12">
|
||||
SQL Data Source
|
||||
<info-popover mode="right-normal">
|
||||
Select SQL Data Source for Zabbix database.
|
||||
In order to use this feature you should <a href="/datasources/new" target="_blank">create</a> and
|
||||
configure it first. Zabbix plugin uses this data source for querying history data directly from database.
|
||||
This way usually faster than pulling data from Zabbix API, especially on the wide time ranges, and reduces
|
||||
amount of data transfered.
|
||||
</info-popover>
|
||||
</span>
|
||||
<div class="gf-form-select-wrapper max-width-16">
|
||||
<select class="gf-form-input" ng-model="ctrl.current.jsonData.dbConnectionDatasourceId"
|
||||
ng-options="ds.id as ds.name for ds in ctrl.sqlDataSources">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Alerting</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Enable alerting"
|
||||
checked="ctrl.current.jsonData.alerting">
|
||||
</gf-form-switch>
|
||||
<div ng-if="ctrl.current.jsonData.alerting">
|
||||
<gf-form-switch class="gf-form" label-class="width-12"
|
||||
label="Add thresholds"
|
||||
checked="ctrl.current.jsonData.addThresholds">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form max-width-20">
|
||||
<span class="gf-form-label width-12">Min severity</span>
|
||||
<div class="gf-form-select-wrapper max-width-16">
|
||||
<select class="gf-form-input" ng-model="ctrl.current.jsonData.alertingMinSeverity"
|
||||
ng-options="s.val as s.text for s in [
|
||||
{val: 0, text: 'Not classified'}, {val: 1, text:'Information'},
|
||||
{val: 2, text: 'Warning'}, {val: 3, text: 'Average'},
|
||||
{val: 4, text: 'High'}, {val: 5, text: 'Disaster'}]">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-group">
|
||||
<h3 class="page-heading">Other</h3>
|
||||
<gf-form-switch class="gf-form" label-class="width-20"
|
||||
label="Disable acknowledges for read-only users"
|
||||
checked="ctrl.current.jsonData.disableReadOnlyUsersAck">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
235
dist/datasource-zabbix/partials/query.editor.html
vendored
@@ -1,235 +0,0 @@
|
||||
<query-editor-row query-ctrl="ctrl" can-collapse="false">
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label width-7">Query Mode</label>
|
||||
<div class="gf-form-select-wrapper max-width-20">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.switchEditorMode(ctrl.target.mode)"
|
||||
ng-model="ctrl.target.mode"
|
||||
ng-options="m.mode as m.text for m in ctrl.editorModes">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form" ng-show="ctrl.target.mode == editorMode.TEXT">
|
||||
<label class="gf-form-label query-keyword width-8">Format As</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input gf-size-auto" ng-model="ctrl.target.resultFormat" ng-options="f.value as f.text for f in ctrl.resultFormats" ng-change="ctrl.refresh()"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- IT Service editor -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.ITSERVICE">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">IT Service</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.itServiceFilter"
|
||||
bs-typeahead="ctrl.getITServices"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.itServiceFilter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.itServiceFilter)
|
||||
}">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword">Property</label>
|
||||
<div class="gf-form-select-wrapper">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.slaProperty"
|
||||
ng-options="slaProperty.name for slaProperty in ctrl.slaPropertyList track by slaProperty.name">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT || ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<!-- Select Group -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Group</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.group.filter"
|
||||
bs-typeahead="ctrl.getGroupNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.group.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.group.filter)
|
||||
}"></input>
|
||||
</div>
|
||||
<!-- Select Host -->
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-8">Host</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.host.filter"
|
||||
bs-typeahead="ctrl.getHostNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.host.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.host.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT || ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<!-- Select Application -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Application</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.application.filter"
|
||||
bs-typeahead="ctrl.getApplicationNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.application.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.application.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<!-- Select Item -->
|
||||
<div class="gf-form" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.TEXT">
|
||||
<label class="gf-form-label query-keyword width-8">Item</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.item.filter"
|
||||
bs-typeahead="ctrl.getItemNames"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.item.filter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.item.filter)
|
||||
}">
|
||||
</div>
|
||||
|
||||
<div class="gf-form max-width-23" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<label class="gf-form-label query-keyword width-8">Min Severity</label>
|
||||
<div class="gf-form-select-wrapper width-16">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.triggers.minSeverity"
|
||||
ng-options="s.val as s.text for s in ctrl.triggerSeverity">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form max-width-20" ng-show="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<label class="gf-form-label query-keyword width-8">Acknowledged</label>
|
||||
<div class="gf-form-select-wrapper width-12">
|
||||
<select class="gf-form-input"
|
||||
ng-change="ctrl.onTargetBlur()"
|
||||
ng-model="ctrl.target.triggers.acknowledged"
|
||||
ng-options="a.value as a.text for a in ctrl.ackFilters">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Count" ng-show="ctrl.target.mode == editorMode.TRIGGERS"
|
||||
checked="ctrl.target.triggers.count" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
|
||||
<div class="gf-form gf-form--grow">
|
||||
<label class="gf-form-label gf-form-label--grow">
|
||||
<a ng-click="ctrl.toggleQueryOptions()" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<i class="fa fa-caret-down" ng-show="ctrl.showQueryOptions"></i>
|
||||
<i class="fa fa-caret-right" ng-hide="ctrl.showQueryOptions"></i>
|
||||
{{ctrl.queryOptionsText}}
|
||||
</a>
|
||||
</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Query options -->
|
||||
<div class="gf-form-group" ng-if="ctrl.showQueryOptions">
|
||||
<div class="gf-form offset-width-7" ng-hide="ctrl.target.mode == editorMode.TRIGGERS">
|
||||
<gf-form-switch class="gf-form" label-class="width-10"
|
||||
label="Show disabled items"
|
||||
checked="ctrl.target.options.showDisabledItems"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
<div class="gf-form offset-width-7" ng-show="ctrl.target.mode === editorMode.TEXT && ctrl.target.resultFormat === 'table'">
|
||||
<gf-form-switch class="gf-form" label-class="width-10"
|
||||
label="Skip empty values"
|
||||
checked="ctrl.target.options.skipEmptyValues"
|
||||
on-change="ctrl.onQueryOptionChange()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Item IDs editor mode -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.ITEMID">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Item IDs</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.target.itemids"
|
||||
bs-typeahead="ctrl.getVariables"
|
||||
ng-blur="ctrl.onTargetBlur()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': ctrl.isVariable(ctrl.target.itServiceFilter),
|
||||
'zbx-regex': ctrl.isRegex(ctrl.target.itServiceFilter)
|
||||
}">
|
||||
</input>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Metric processing functions -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.METRICS || ctrl.target.mode == editorMode.ITEMID">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">Functions</label>
|
||||
<div ng-repeat="func in ctrl.target.functions" class="gf-form-label query-part" metric-function-editor></div>
|
||||
</div>
|
||||
<div class="gf-form dropdown" add-metric-function>
|
||||
</div>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Text mode options -->
|
||||
<div class="gf-form-inline" ng-show="ctrl.target.mode == editorMode.TEXT">
|
||||
<!-- Text metric regex -->
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Text filter</label>
|
||||
<input type="text"
|
||||
class="gf-form-input"
|
||||
ng-model="ctrl.target.textFilter"
|
||||
spellcheck='false'
|
||||
placeholder="Text filter (regex)"
|
||||
ng-blur="ctrl.onTargetBlur()">
|
||||
</div>
|
||||
|
||||
<gf-form-switch class="gf-form" label="Use capture groups" checked="ctrl.target.useCaptureGroups" on-change="ctrl.onTargetBlur()">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form gf-form--grow">
|
||||
<div class="gf-form-label gf-form-label--grow"></div>
|
||||
</div>
|
||||
</div>
|
||||
</query-editor-row>
|
||||
@@ -1,88 +0,0 @@
|
||||
<section class="grafana-metric-options gf-form-group">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-15">
|
||||
<span class="gf-form-label">Max data points</span>
|
||||
<input type="text"
|
||||
class="gf-form-input"
|
||||
ng-model="ctrl.panelCtrl.panel.maxDataPoints"
|
||||
bs-tooltip="'Override max data points, automatically set to graph width in pixels.'"
|
||||
data-placement="right"
|
||||
ng-model-onblur ng-change="ctrl.panelCtrl.refresh()"
|
||||
spellcheck='false'
|
||||
placeholder="auto">
|
||||
</input>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<span class="gf-form-label width-10">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(1);" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
Max data points
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-10">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(2);" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
IT services
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-12">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(3)" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
IT service property
|
||||
</a>
|
||||
</span>
|
||||
<span class="gf-form-label width-8">
|
||||
<i class="fa fa-info-circle"></i>
|
||||
<a ng-click="ctrl.panelCtrl.toggleEditorHelp(4)" bs-tooltip="'click to show helpful info'" data-placement="bottom">
|
||||
Text filter
|
||||
</a>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
<div class="editor-row">
|
||||
<div class="pull-left">
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 1">
|
||||
<h5>Max data points</h5>
|
||||
<ul>
|
||||
<li>Grafana-Zabbix plugin uses maxDataPoints parameter to consolidate the real number of values down to this
|
||||
number
|
||||
</li>
|
||||
<li>If there are more real values, then by default they will be consolidated using averages</li>
|
||||
<li>This could hide real peaks and max values in your series</li>
|
||||
<li>Point consolidation will effect series legend values (min,max,total,current)</li>
|
||||
<li>If you override maxDataPoint and set a high value performance can be severely effected</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 2">
|
||||
<h5>IT services</h5>
|
||||
<ul>
|
||||
<li>Select "IT services" in targets menu to activate IT services mode.</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 3">
|
||||
<h5>IT service property</h5>
|
||||
<ul>
|
||||
<li>Zabbix returns the following availability information about IT service</li>
|
||||
<li>Status - current status of the IT service</li>
|
||||
<li>SLA - SLA for the given time interval</li>
|
||||
<li>OK time - time the service was in OK state, in seconds</li>
|
||||
<li>Problem time - time the service was in problem state, in seconds</li>
|
||||
<li>Down time - time the service was in scheduled downtime, in seconds</li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
<div class="grafana-info-box span8" ng-if="ctrl.panelCtrl.editorHelpIndex === 4">
|
||||
<h5>Text filter</h5>
|
||||
<ul>
|
||||
<li>Use regex to extract a part of the returned value.</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
36
dist/datasource-zabbix/plugin.json
vendored
@@ -1,36 +0,0 @@
|
||||
{
|
||||
"type": "datasource",
|
||||
"name": "Zabbix",
|
||||
"id": "alexanderzobnin-zabbix-datasource",
|
||||
|
||||
"includes": [
|
||||
{
|
||||
"type": "dashboard",
|
||||
"name": "Zabbix System Status",
|
||||
"path": "../dashboards/zabbix_system_status.json"
|
||||
},
|
||||
{
|
||||
"type": "dashboard",
|
||||
"name": "Zabbix Template Linux Server",
|
||||
"path": "../dashboards/template_linux_server.json"
|
||||
}
|
||||
],
|
||||
|
||||
"metrics": true,
|
||||
"annotations": true,
|
||||
|
||||
"queryOptions": {
|
||||
"maxDataPoints": true
|
||||
},
|
||||
|
||||
"info": {
|
||||
"author": {
|
||||
"name": "Alexander Zobnin",
|
||||
"url": "https://github.com/alexanderzobnin/grafana-zabbix"
|
||||
},
|
||||
"logos": {
|
||||
"small": "img/zabbix_app_logo.svg",
|
||||
"large": "img/zabbix_app_logo.svg"
|
||||
}
|
||||
}
|
||||
}
|
||||
407
dist/datasource-zabbix/query.controller.js
vendored
@@ -1,407 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['app/plugins/sdk', 'lodash', './constants', './utils', './metricFunctions', './migrations'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var QueryCtrl, _, c, utils, metricFunctions, migrations, _createClass, ZabbixQueryController;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
function _possibleConstructorReturn(self, call) {
|
||||
if (!self) {
|
||||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||||
}
|
||||
|
||||
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
||||
}
|
||||
|
||||
function _inherits(subClass, superClass) {
|
||||
if (typeof superClass !== "function" && superClass !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
||||
}
|
||||
|
||||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||
constructor: {
|
||||
value: subClass,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_appPluginsSdk) {
|
||||
QueryCtrl = _appPluginsSdk.QueryCtrl;
|
||||
}, function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_constants) {
|
||||
c = _constants;
|
||||
}, function (_utils) {
|
||||
utils = _utils;
|
||||
}, function (_metricFunctions) {
|
||||
metricFunctions = _metricFunctions;
|
||||
}, function (_migrations) {
|
||||
migrations = _migrations;
|
||||
}],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
_export('ZabbixQueryController', ZabbixQueryController = function (_QueryCtrl) {
|
||||
_inherits(ZabbixQueryController, _QueryCtrl);
|
||||
|
||||
// ZabbixQueryCtrl constructor
|
||||
function ZabbixQueryController($scope, $injector, $rootScope, $sce, templateSrv) {
|
||||
_classCallCheck(this, ZabbixQueryController);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (ZabbixQueryController.__proto__ || Object.getPrototypeOf(ZabbixQueryController)).call(this, $scope, $injector));
|
||||
|
||||
_this.zabbix = _this.datasource.zabbix;
|
||||
|
||||
// Use custom format for template variables
|
||||
_this.replaceTemplateVars = _this.datasource.replaceTemplateVars;
|
||||
_this.templateSrv = templateSrv;
|
||||
|
||||
_this.editorModes = [{ value: 'num', text: 'Metrics', mode: c.MODE_METRICS }, { value: 'text', text: 'Text', mode: c.MODE_TEXT }, { value: 'itservice', text: 'IT Services', mode: c.MODE_ITSERVICE }, { value: 'itemid', text: 'Item ID', mode: c.MODE_ITEMID }, { value: 'triggers', text: 'Triggers', mode: c.MODE_TRIGGERS }];
|
||||
|
||||
_this.$scope.editorMode = {
|
||||
METRICS: c.MODE_METRICS,
|
||||
TEXT: c.MODE_TEXT,
|
||||
ITSERVICE: c.MODE_ITSERVICE,
|
||||
ITEMID: c.MODE_ITEMID,
|
||||
TRIGGERS: c.MODE_TRIGGERS
|
||||
};
|
||||
|
||||
_this.slaPropertyList = [{ name: "Status", property: "status" }, { name: "SLA", property: "sla" }, { name: "OK time", property: "okTime" }, { name: "Problem time", property: "problemTime" }, { name: "Down time", property: "downtimeTime" }];
|
||||
|
||||
_this.ackFilters = [{ text: 'all triggers', value: 2 }, { text: 'unacknowledged', value: 0 }, { text: 'acknowledged', value: 1 }];
|
||||
|
||||
_this.resultFormats = [{ text: 'Time series', value: 'time_series' }, { text: 'Table', value: 'table' }];
|
||||
|
||||
_this.triggerSeverity = c.TRIGGER_SEVERITY;
|
||||
|
||||
// Map functions for bs-typeahead
|
||||
_this.getGroupNames = _.bind(_this.getMetricNames, _this, 'groupList');
|
||||
_this.getHostNames = _.bind(_this.getMetricNames, _this, 'hostList', true);
|
||||
_this.getApplicationNames = _.bind(_this.getMetricNames, _this, 'appList');
|
||||
_this.getItemNames = _.bind(_this.getMetricNames, _this, 'itemList');
|
||||
_this.getITServices = _.bind(_this.getMetricNames, _this, 'itServiceList');
|
||||
_this.getVariables = _.bind(_this.getTemplateVariables, _this);
|
||||
|
||||
// Update metric suggestion when template variable was changed
|
||||
$rootScope.$on('template-variable-value-updated', function () {
|
||||
return _this.onVariableChange();
|
||||
});
|
||||
|
||||
// Update metrics when item selected from dropdown
|
||||
$scope.$on('typeahead-updated', function () {
|
||||
_this.onTargetBlur();
|
||||
});
|
||||
|
||||
_this.init = function () {
|
||||
var target = this.target;
|
||||
|
||||
// Migrate old targets
|
||||
target = migrations.migrate(target);
|
||||
|
||||
var scopeDefaults = {
|
||||
metric: {},
|
||||
oldTarget: _.cloneDeep(this.target),
|
||||
queryOptionsText: this.renderQueryOptionsText()
|
||||
};
|
||||
_.defaults(this, scopeDefaults);
|
||||
|
||||
// Load default values
|
||||
var targetDefaults = {
|
||||
'mode': c.MODE_METRICS,
|
||||
'group': { 'filter': "" },
|
||||
'host': { 'filter': "" },
|
||||
'application': { 'filter': "" },
|
||||
'item': { 'filter': "" },
|
||||
'functions': [],
|
||||
'triggers': {
|
||||
'count': true,
|
||||
'minSeverity': 3,
|
||||
'acknowledged': 2
|
||||
},
|
||||
'options': {
|
||||
'showDisabledItems': false,
|
||||
'skipEmptyValues': false
|
||||
},
|
||||
'table': {
|
||||
'skipEmptyValues': false
|
||||
}
|
||||
};
|
||||
_.defaults(target, targetDefaults);
|
||||
|
||||
// Create function instances from saved JSON
|
||||
target.functions = _.map(target.functions, function (func) {
|
||||
return metricFunctions.createFuncInstance(func.def, func.params);
|
||||
});
|
||||
|
||||
if (target.mode === c.MODE_METRICS || target.mode === c.MODE_TEXT || target.mode === c.MODE_TRIGGERS) {
|
||||
this.initFilters();
|
||||
} else if (target.mode === c.MODE_ITSERVICE) {
|
||||
_.defaults(target, { slaProperty: { name: "SLA", property: "sla" } });
|
||||
this.suggestITServices();
|
||||
}
|
||||
};
|
||||
|
||||
_this.init();
|
||||
_this.queryOptionsText = _this.renderQueryOptionsText();
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(ZabbixQueryController, [{
|
||||
key: 'initFilters',
|
||||
value: function initFilters() {
|
||||
var itemtype = _.find(this.editorModes, { 'mode': this.target.mode });
|
||||
itemtype = itemtype ? itemtype.value : null;
|
||||
return Promise.all([this.suggestGroups(), this.suggestHosts(), this.suggestApps(), this.suggestItems(itemtype)]);
|
||||
}
|
||||
}, {
|
||||
key: 'getMetricNames',
|
||||
value: function getMetricNames(metricList, addAllValue) {
|
||||
var metrics = _.uniq(_.map(this.metric[metricList], 'name'));
|
||||
|
||||
// Add template variables
|
||||
_.forEach(this.templateSrv.variables, function (variable) {
|
||||
metrics.unshift('$' + variable.name);
|
||||
});
|
||||
|
||||
if (addAllValue) {
|
||||
metrics.unshift('/.*/');
|
||||
}
|
||||
|
||||
return metrics;
|
||||
}
|
||||
}, {
|
||||
key: 'getTemplateVariables',
|
||||
value: function getTemplateVariables() {
|
||||
return _.map(this.templateSrv.variables, function (variable) {
|
||||
return '$' + variable.name;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'suggestGroups',
|
||||
value: function suggestGroups() {
|
||||
var _this2 = this;
|
||||
|
||||
return this.zabbix.getAllGroups().then(function (groups) {
|
||||
_this2.metric.groupList = groups;
|
||||
return groups;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'suggestHosts',
|
||||
value: function suggestHosts() {
|
||||
var _this3 = this;
|
||||
|
||||
var groupFilter = this.replaceTemplateVars(this.target.group.filter);
|
||||
return this.zabbix.getAllHosts(groupFilter).then(function (hosts) {
|
||||
_this3.metric.hostList = hosts;
|
||||
return hosts;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'suggestApps',
|
||||
value: function suggestApps() {
|
||||
var _this4 = this;
|
||||
|
||||
var groupFilter = this.replaceTemplateVars(this.target.group.filter);
|
||||
var hostFilter = this.replaceTemplateVars(this.target.host.filter);
|
||||
return this.zabbix.getAllApps(groupFilter, hostFilter).then(function (apps) {
|
||||
_this4.metric.appList = apps;
|
||||
return apps;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'suggestItems',
|
||||
value: function suggestItems() {
|
||||
var _this5 = this;
|
||||
|
||||
var itemtype = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'num';
|
||||
|
||||
var groupFilter = this.replaceTemplateVars(this.target.group.filter);
|
||||
var hostFilter = this.replaceTemplateVars(this.target.host.filter);
|
||||
var appFilter = this.replaceTemplateVars(this.target.application.filter);
|
||||
var options = {
|
||||
itemtype: itemtype,
|
||||
showDisabledItems: this.target.options.showDisabledItems
|
||||
};
|
||||
|
||||
return this.zabbix.getAllItems(groupFilter, hostFilter, appFilter, options).then(function (items) {
|
||||
_this5.metric.itemList = items;
|
||||
return items;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'suggestITServices',
|
||||
value: function suggestITServices() {
|
||||
var _this6 = this;
|
||||
|
||||
return this.zabbix.getITService().then(function (itservices) {
|
||||
_this6.metric.itServiceList = itservices;
|
||||
return itservices;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'isRegex',
|
||||
value: function isRegex(str) {
|
||||
return utils.isRegex(str);
|
||||
}
|
||||
}, {
|
||||
key: 'isVariable',
|
||||
value: function isVariable(str) {
|
||||
return utils.isTemplateVariable(str, this.templateSrv.variables);
|
||||
}
|
||||
}, {
|
||||
key: 'onTargetBlur',
|
||||
value: function onTargetBlur() {
|
||||
var newTarget = _.cloneDeep(this.target);
|
||||
if (!_.isEqual(this.oldTarget, this.target)) {
|
||||
this.oldTarget = newTarget;
|
||||
this.targetChanged();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'onVariableChange',
|
||||
value: function onVariableChange() {
|
||||
if (this.isContainsVariables()) {
|
||||
this.targetChanged();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'isContainsVariables',
|
||||
value: function isContainsVariables() {
|
||||
var _this7 = this;
|
||||
|
||||
return _.some(['group', 'host', 'application'], function (field) {
|
||||
if (_this7.target[field] && _this7.target[field].filter) {
|
||||
return utils.isTemplateVariable(_this7.target[field].filter, _this7.templateSrv.variables);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'parseTarget',
|
||||
value: function parseTarget() {}
|
||||
// Parse target
|
||||
|
||||
|
||||
// Validate target and set validation info
|
||||
|
||||
}, {
|
||||
key: 'validateTarget',
|
||||
value: function validateTarget() {
|
||||
// validate
|
||||
}
|
||||
}, {
|
||||
key: 'targetChanged',
|
||||
value: function targetChanged() {
|
||||
this.initFilters();
|
||||
this.parseTarget();
|
||||
this.panelCtrl.refresh();
|
||||
}
|
||||
}, {
|
||||
key: 'addFunction',
|
||||
value: function addFunction(funcDef) {
|
||||
var newFunc = metricFunctions.createFuncInstance(funcDef);
|
||||
newFunc.added = true;
|
||||
this.target.functions.push(newFunc);
|
||||
|
||||
this.moveAliasFuncLast();
|
||||
|
||||
if (newFunc.params.length && newFunc.added || newFunc.def.params.length === 0) {
|
||||
this.targetChanged();
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'removeFunction',
|
||||
value: function removeFunction(func) {
|
||||
this.target.functions = _.without(this.target.functions, func);
|
||||
this.targetChanged();
|
||||
}
|
||||
}, {
|
||||
key: 'moveAliasFuncLast',
|
||||
value: function moveAliasFuncLast() {
|
||||
var aliasFunc = _.find(this.target.functions, function (func) {
|
||||
return func.def.name === 'alias' || func.def.name === 'aliasByNode' || func.def.name === 'aliasByMetric';
|
||||
});
|
||||
|
||||
if (aliasFunc) {
|
||||
this.target.functions = _.without(this.target.functions, aliasFunc);
|
||||
this.target.functions.push(aliasFunc);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'toggleQueryOptions',
|
||||
value: function toggleQueryOptions() {
|
||||
this.showQueryOptions = !this.showQueryOptions;
|
||||
}
|
||||
}, {
|
||||
key: 'onQueryOptionChange',
|
||||
value: function onQueryOptionChange() {
|
||||
this.queryOptionsText = this.renderQueryOptionsText();
|
||||
this.onTargetBlur();
|
||||
}
|
||||
}, {
|
||||
key: 'renderQueryOptionsText',
|
||||
value: function renderQueryOptionsText() {
|
||||
var optionsMap = {
|
||||
showDisabledItems: "Show disabled items",
|
||||
skipEmptyValues: "Skip empty values"
|
||||
};
|
||||
var options = [];
|
||||
_.forOwn(this.target.options, function (value, key) {
|
||||
if (value) {
|
||||
if (value === true) {
|
||||
// Show only option name (if enabled) for boolean options
|
||||
options.push(optionsMap[key]);
|
||||
} else {
|
||||
// Show "option = value" for another options
|
||||
options.push(optionsMap[key] + " = " + value);
|
||||
}
|
||||
}
|
||||
});
|
||||
return "Options: " + options.join(', ');
|
||||
}
|
||||
}, {
|
||||
key: 'switchEditorMode',
|
||||
value: function switchEditorMode(mode) {
|
||||
this.target.mode = mode;
|
||||
this.init();
|
||||
this.targetChanged();
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixQueryController;
|
||||
}(QueryCtrl));
|
||||
|
||||
_export('ZabbixQueryController', ZabbixQueryController);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=query.controller.js.map
|
||||
31
dist/datasource-zabbix/query_help.md
vendored
@@ -1,31 +0,0 @@
|
||||
#### Max data points
|
||||
Override max data points, automatically set to graph width in pixels. Grafana-Zabbix plugin uses maxDataPoints parameter to consolidate the real number of values down to this number. If there are more real values, then by default they will be consolidated using averages. This could hide real peaks and max values in your series. Point consolidation will affect series legend values (min,max,total,current).
|
||||
|
||||
#### Query Mode
|
||||
##### Merics
|
||||
Data from numeric items.
|
||||
|
||||
##### Text
|
||||
Data from items with `Character`, `Text` or `Log` type.
|
||||
|
||||
##### IT Services
|
||||
Time series representation of IT Services data
|
||||
###### IT service property
|
||||
Zabbix returns the following availability information about IT service:
|
||||
- Status - current status of the IT service
|
||||
- SLA - SLA for the given time interval
|
||||
- OK time - time the service was in OK state, in seconds
|
||||
- Problem time - time the service was in problem state, in seconds
|
||||
- Down time - time the service was in scheduled downtime, in seconds
|
||||
|
||||
##### Item ID
|
||||
Data from items with specified ID's (comma separated).
|
||||
This mode is suitable for rendering charts in grafana by passing itemids as url params.
|
||||
1. Create multivalue template variable with type _Custom_, for example, `itemids`.
|
||||
1. Create graph with desired parameters and use `$itemids` in _Item IDs_ filed.
|
||||
1. Save dashboard.
|
||||
1. Click to graph title and select _Share_ -> _Direct link rendered image_.
|
||||
1. Use this URL for graph png image and set `var-itemids` param to desired IDs. Note, for multiple IDs you should pass multiple params, like `&var-itemids=28276&var-itemids=28277`.
|
||||
|
||||
##### Triggers
|
||||
Active triggers count for selected hosts or table data like Zabbix _System status_ panel on the main dashboard.
|
||||
248
dist/datasource-zabbix/responseHandler.js
vendored
@@ -1,248 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', 'app/core/table_model', './constants'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, TableModel, c;
|
||||
|
||||
function _toConsumableArray(arr) {
|
||||
if (Array.isArray(arr)) {
|
||||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
||||
arr2[i] = arr[i];
|
||||
}
|
||||
|
||||
return arr2;
|
||||
} else {
|
||||
return Array.from(arr);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert Zabbix API history.get response to Grafana format
|
||||
*
|
||||
* @return {Array} Array of timeseries in Grafana format
|
||||
* {
|
||||
* target: "Metric name",
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
* }
|
||||
*/
|
||||
function convertHistory(history, items, addHostName, convertPointCallback) {
|
||||
/**
|
||||
* Response should be in the format:
|
||||
* data: [
|
||||
* {
|
||||
* target: "Metric name",
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
* }, ...
|
||||
* ]
|
||||
*/
|
||||
|
||||
// Group history by itemid
|
||||
var grouped_history = _.groupBy(history, 'itemid');
|
||||
var hosts = _.uniqBy(_.flatten(_.map(items, 'hosts')), 'hostid'); //uniqBy is needed to deduplicate
|
||||
|
||||
return _.map(grouped_history, function (hist, itemid) {
|
||||
var item = _.find(items, { 'itemid': itemid });
|
||||
var alias = item.name;
|
||||
if (_.keys(hosts).length > 1 && addHostName) {
|
||||
//only when actual multi hosts selected
|
||||
var host = _.find(hosts, { 'hostid': item.hostid });
|
||||
alias = host.name + ": " + alias;
|
||||
}
|
||||
return {
|
||||
target: alias,
|
||||
datapoints: _.map(hist, convertPointCallback)
|
||||
};
|
||||
});
|
||||
}
|
||||
|
||||
function sortTimeseries(timeseries) {
|
||||
// Sort trend data, issue #202
|
||||
_.forEach(timeseries, function (series) {
|
||||
series.datapoints = _.sortBy(series.datapoints, function (point) {
|
||||
return point[c.DATAPOINT_TS];
|
||||
});
|
||||
});
|
||||
return timeseries;
|
||||
}function handleHistory(history, items) {
|
||||
var addHostName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
|
||||
return convertHistory(history, items, addHostName, convertHistoryPoint);
|
||||
}
|
||||
|
||||
function handleTrends(history, items, valueType) {
|
||||
var addHostName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
||||
|
||||
var convertPointCallback = _.partial(convertTrendPoint, valueType);
|
||||
return convertHistory(history, items, addHostName, convertPointCallback);
|
||||
}function handleText(history, items, target) {
|
||||
var addHostName = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
|
||||
|
||||
var convertTextCallback = _.partial(convertText, target);
|
||||
return convertHistory(history, items, addHostName, convertTextCallback);
|
||||
}
|
||||
|
||||
function handleHistoryAsTable(history, items, target) {
|
||||
var table = new TableModel();
|
||||
table.addColumn({ text: 'Host' });
|
||||
table.addColumn({ text: 'Item' });
|
||||
table.addColumn({ text: 'Key' });
|
||||
table.addColumn({ text: 'Last value' });
|
||||
|
||||
var grouped_history = _.groupBy(history, 'itemid');
|
||||
_.each(items, function (item) {
|
||||
var itemHistory = grouped_history[item.itemid] || [];
|
||||
var lastPoint = _.last(itemHistory);
|
||||
var lastValue = lastPoint ? lastPoint.value : null;
|
||||
|
||||
if (target.options.skipEmptyValues && (!lastValue || lastValue === '')) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Regex-based extractor
|
||||
if (target.textFilter) {
|
||||
lastValue = extractText(lastValue, target.textFilter, target.useCaptureGroups);
|
||||
}
|
||||
|
||||
var host = _.first(item.hosts);
|
||||
host = host ? host.name : "";
|
||||
|
||||
table.rows.push([host, item.name, item.key_, lastValue]);
|
||||
});
|
||||
|
||||
return table;
|
||||
}function convertText(target, point) {
|
||||
var value = point.value;
|
||||
|
||||
// Regex-based extractor
|
||||
if (target.textFilter) {
|
||||
value = extractText(point.value, target.textFilter, target.useCaptureGroups);
|
||||
}
|
||||
|
||||
return [value, point.clock * 1000 + Math.round(point.ns / 1000000)];
|
||||
}
|
||||
|
||||
function extractText(str, pattern, useCaptureGroups) {
|
||||
var extractPattern = new RegExp(pattern);
|
||||
var extractedValue = extractPattern.exec(str);
|
||||
if (extractedValue) {
|
||||
if (useCaptureGroups) {
|
||||
extractedValue = extractedValue[1];
|
||||
} else {
|
||||
extractedValue = extractedValue[0];
|
||||
}
|
||||
}
|
||||
return extractedValue;
|
||||
}function handleSLAResponse(itservice, slaProperty, slaObject) {
|
||||
var targetSLA = slaObject[itservice.serviceid].sla[0];
|
||||
if (slaProperty.property === 'status') {
|
||||
var targetStatus = parseInt(slaObject[itservice.serviceid].status);
|
||||
return {
|
||||
target: itservice.name + ' ' + slaProperty.name,
|
||||
datapoints: [[targetStatus, targetSLA.to * 1000]]
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
target: itservice.name + ' ' + slaProperty.name,
|
||||
datapoints: [[targetSLA[slaProperty.property], targetSLA.from * 1000], [targetSLA[slaProperty.property], targetSLA.to * 1000]]
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
function handleTriggersResponse(triggers, timeRange) {
|
||||
if (_.isNumber(triggers)) {
|
||||
return {
|
||||
target: "triggers count",
|
||||
datapoints: [[triggers, timeRange[1] * 1000]]
|
||||
};
|
||||
} else {
|
||||
var stats = getTriggerStats(triggers);
|
||||
var table = new TableModel();
|
||||
table.addColumn({ text: 'Host group' });
|
||||
_.each(_.orderBy(c.TRIGGER_SEVERITY, ['val'], ['desc']), function (severity) {
|
||||
table.addColumn({ text: severity.text });
|
||||
});
|
||||
_.each(stats, function (severity_stats, group) {
|
||||
var row = _.map(_.orderBy(_.toPairs(severity_stats), function (s) {
|
||||
return s[0];
|
||||
}, ['desc']), function (s) {
|
||||
return s[1];
|
||||
});
|
||||
row = _.concat.apply(_, [[group]].concat(_toConsumableArray(row)));
|
||||
table.rows.push(row);
|
||||
});
|
||||
return table;
|
||||
}
|
||||
}function getTriggerStats(triggers) {
|
||||
var groups = _.uniq(_.flattenDeep(_.map(triggers, function (trigger) {
|
||||
return _.map(trigger.groups, 'name');
|
||||
})));
|
||||
// let severity = _.map(c.TRIGGER_SEVERITY, 'text');
|
||||
var stats = {};
|
||||
_.each(groups, function (group) {
|
||||
stats[group] = { 0: 0, 1: 0, 2: 0, 3: 0, 4: 0, 5: 0 }; // severity:count
|
||||
});
|
||||
_.each(triggers, function (trigger) {
|
||||
_.each(trigger.groups, function (group) {
|
||||
stats[group.name][trigger.priority]++;
|
||||
});
|
||||
});
|
||||
return stats;
|
||||
}
|
||||
|
||||
function convertHistoryPoint(point) {
|
||||
// Value must be a number for properly work
|
||||
return [Number(point.value), point.clock * 1000 + Math.round(point.ns / 1000000)];
|
||||
}function convertTrendPoint(valueType, point) {
|
||||
var value;
|
||||
switch (valueType) {
|
||||
case "min":
|
||||
value = point.value_min;
|
||||
break;
|
||||
case "max":
|
||||
value = point.value_max;
|
||||
break;
|
||||
case "avg":
|
||||
value = point.value_avg;
|
||||
break;
|
||||
case "sum":
|
||||
value = point.value_sum;
|
||||
break;
|
||||
case "count":
|
||||
value = point.value_count;
|
||||
break;
|
||||
default:
|
||||
value = point.value_avg;
|
||||
}
|
||||
|
||||
return [Number(value), point.clock * 1000];
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_appCoreTable_model) {
|
||||
TableModel = _appCoreTable_model.default;
|
||||
}, function (_constants) {
|
||||
c = _constants;
|
||||
}],
|
||||
execute: function () {
|
||||
_export('default', {
|
||||
handleHistory: handleHistory,
|
||||
convertHistory: convertHistory,
|
||||
handleTrends: handleTrends,
|
||||
handleText: handleText,
|
||||
handleHistoryAsTable: handleHistoryAsTable,
|
||||
handleSLAResponse: handleSLAResponse,
|
||||
handleTriggersResponse: handleTriggersResponse,
|
||||
sortTimeseries: sortTimeseries
|
||||
});
|
||||
|
||||
// Fix for backward compatibility with lodash 2.4
|
||||
if (!_.uniqBy) {
|
||||
_.uniqBy = _.uniq;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=responseHandler.js.map
|
||||
@@ -1,56 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', '../dataProcessor'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, dataProcessor;
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_dataProcessor) {
|
||||
dataProcessor = _dataProcessor.default;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
describe('dataProcessor', function () {
|
||||
var ctx = {};
|
||||
|
||||
beforeEach(function () {
|
||||
ctx.datapoints = [[[10, 1500000000000], [2, 1500000001000], [7, 1500000002000], [1, 1500000003000]], [[9, 1500000000000], [3, 1500000001000], [4, 1500000002000], [8, 1500000003000]]];
|
||||
});
|
||||
|
||||
describe('When apply groupBy() functions', function () {
|
||||
it('should return series average', function () {
|
||||
var aggregateBy = dataProcessor.metricFunctions['groupBy'];
|
||||
var avg2s = _.map(ctx.datapoints, function (dp) {
|
||||
return aggregateBy('2s', 'avg', dp);
|
||||
});
|
||||
expect(avg2s).toEqual([[[6, 1500000000000], [4, 1500000002000]], [[6, 1500000000000], [6, 1500000002000]]]);
|
||||
|
||||
var avg10s = _.map(ctx.datapoints, function (dp) {
|
||||
return aggregateBy('10s', 'avg', dp);
|
||||
});
|
||||
expect(avg10s).toEqual([[[5, 1500000000000]], [[6, 1500000000000]]]);
|
||||
|
||||
// not aligned
|
||||
var dp = [[10, 1500000001000], [2, 1500000002000], [7, 1500000003000], [1, 1500000004000]];
|
||||
expect(aggregateBy('2s', 'avg', dp)).toEqual([[10, 1500000000000], [4.5, 1500000002000], [1, 1500000004000]]);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When apply aggregateBy() functions', function () {
|
||||
it('should return series average', function () {
|
||||
var aggregateBy = dataProcessor.metricFunctions['aggregateBy'];
|
||||
var avg1s = aggregateBy('1s', 'avg', ctx.datapoints);
|
||||
expect(avg1s).toEqual([[9.5, 1500000000000], [2.5, 1500000001000], [5.5, 1500000002000], [4.5, 1500000003000]]);
|
||||
|
||||
var avg10s = aggregateBy('10s', 'avg', ctx.datapoints);
|
||||
expect(avg10s).toEqual([[5.5, 1500000000000]]);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=dataProcessor.spec.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/datasource-zabbix/specs/dataProcessor.spec.js"],"names":["_","dataProcessor","describe","ctx","beforeEach","datapoints","it","aggregateBy","metricFunctions","avg2s","map","dp","expect","toEqual","avg10s","avg1s"],"mappings":";;;;;;;;;AAAOA,O;;AACAC,mB;;;;AAEPC,eAAS,eAAT,EAA0B,YAAM;AAC9B,YAAIC,MAAM,EAAV;;AAEAC,mBAAW,YAAM;AACfD,cAAIE,UAAJ,GAAiB,CACf,CAAC,CAAC,EAAD,EAAK,aAAL,CAAD,EAAsB,CAAC,CAAD,EAAI,aAAJ,CAAtB,EAA0C,CAAC,CAAD,EAAI,aAAJ,CAA1C,EAA8D,CAAC,CAAD,EAAI,aAAJ,CAA9D,CADe,EAEf,CAAC,CAAC,CAAD,EAAI,aAAJ,CAAD,EAAsB,CAAC,CAAD,EAAI,aAAJ,CAAtB,EAA0C,CAAC,CAAD,EAAI,aAAJ,CAA1C,EAA8D,CAAC,CAAD,EAAI,aAAJ,CAA9D,CAFe,CAAjB;AAID,SALD;;AAOAH,iBAAS,gCAAT,EAA2C,YAAM;AAC/CI,aAAG,8BAAH,EAAmC,YAAM;AACvC,gBAAIC,cAAcN,cAAcO,eAAd,CAA8B,SAA9B,CAAlB;AACA,gBAAMC,QAAQT,EAAEU,GAAF,CAAMP,IAAIE,UAAV,EAAsB,UAACM,EAAD;AAAA,qBAAQJ,YAAY,IAAZ,EAAkB,KAAlB,EAAyBI,EAAzB,CAAR;AAAA,aAAtB,CAAd;AACAC,mBAAOH,KAAP,EAAcI,OAAd,CAAsB,CACpB,CAAC,CAAC,CAAD,EAAI,aAAJ,CAAD,EAAqB,CAAC,CAAD,EAAI,aAAJ,CAArB,CADoB,EAEpB,CAAC,CAAC,CAAD,EAAI,aAAJ,CAAD,EAAqB,CAAC,CAAD,EAAI,aAAJ,CAArB,CAFoB,CAAtB;;AAKA,gBAAMC,SAASd,EAAEU,GAAF,CAAMP,IAAIE,UAAV,EAAsB,UAACM,EAAD;AAAA,qBAAQJ,YAAY,KAAZ,EAAmB,KAAnB,EAA0BI,EAA1B,CAAR;AAAA,aAAtB,CAAf;AACAC,mBAAOE,MAAP,EAAeD,OAAf,CAAuB,CACrB,CAAC,CAAC,CAAD,EAAI,aAAJ,CAAD,CADqB,EAErB,CAAC,CAAC,CAAD,EAAI,aAAJ,CAAD,CAFqB,CAAvB;;AAKA;AACA,gBAAMF,KAAK,CAAC,CAAC,EAAD,EAAK,aAAL,CAAD,EAAsB,CAAC,CAAD,EAAI,aAAJ,CAAtB,EAA0C,CAAC,CAAD,EAAI,aAAJ,CAA1C,EAA8D,CAAC,CAAD,EAAI,aAAJ,CAA9D,CAAX;AACAC,mBAAOL,YAAY,IAAZ,EAAkB,KAAlB,EAAyBI,EAAzB,CAAP,EAAqCE,OAArC,CAA6C,CAC3C,CAAC,EAAD,EAAK,aAAL,CAD2C,EACtB,CAAC,GAAD,EAAM,aAAN,CADsB,EACA,CAAC,CAAD,EAAI,aAAJ,CADA,CAA7C;AAGD,WAnBD;AAoBD,SArBD;;AAuBAX,iBAAS,oCAAT,EAA+C,YAAM;AACnDI,aAAG,8BAAH,EAAmC,YAAM;AACvC,gBAAIC,cAAcN,cAAcO,eAAd,CAA8B,aAA9B,CAAlB;AACA,gBAAMO,QAAQR,YAAY,IAAZ,EAAkB,KAAlB,EAAyBJ,IAAIE,UAA7B,CAAd;AACAO,mBAAOG,KAAP,EAAcF,OAAd,CAAsB,CACpB,CAAC,GAAD,EAAM,aAAN,CADoB,EACE,CAAC,GAAD,EAAM,aAAN,CADF,EACwB,CAAC,GAAD,EAAM,aAAN,CADxB,EAC8C,CAAC,GAAD,EAAM,aAAN,CAD9C,CAAtB;;AAIA,gBAAMC,SAASP,YAAY,KAAZ,EAAmB,KAAnB,EAA0BJ,IAAIE,UAA9B,CAAf;AACAO,mBAAOE,MAAP,EAAeD,OAAf,CAAuB,CACrB,CAAC,GAAD,EAAM,aAAN,CADqB,CAAvB;AAGD,WAXD;AAYD,SAbD;AAcD,OA/CD","file":"dataProcessor.spec.js","sourcesContent":["import _ from 'lodash';\nimport dataProcessor from '../dataProcessor';\n\ndescribe('dataProcessor', () => {\n let ctx = {};\n\n beforeEach(() => {\n ctx.datapoints = [\n [[10, 1500000000000], [2, 1500000001000], [7, 1500000002000], [1, 1500000003000]],\n [[9, 1500000000000], [3, 1500000001000], [4, 1500000002000], [8, 1500000003000]],\n ];\n });\n\n describe('When apply groupBy() functions', () => {\n it('should return series average', () => {\n let aggregateBy = dataProcessor.metricFunctions['groupBy'];\n const avg2s = _.map(ctx.datapoints, (dp) => aggregateBy('2s', 'avg', dp));\n expect(avg2s).toEqual([\n [[6, 1500000000000], [4, 1500000002000]],\n [[6, 1500000000000], [6, 1500000002000]],\n ]);\n\n const avg10s = _.map(ctx.datapoints, (dp) => aggregateBy('10s', 'avg', dp));\n expect(avg10s).toEqual([\n [[5, 1500000000000]],\n [[6, 1500000000000]],\n ]);\n\n // not aligned\n const dp = [[10, 1500000001000], [2, 1500000002000], [7, 1500000003000], [1, 1500000004000]];\n expect(aggregateBy('2s', 'avg', dp)).toEqual([\n [10, 1500000000000], [4.5, 1500000002000], [1, 1500000004000]\n ]);\n });\n });\n\n describe('When apply aggregateBy() functions', () => {\n it('should return series average', () => {\n let aggregateBy = dataProcessor.metricFunctions['aggregateBy'];\n const avg1s = aggregateBy('1s', 'avg', ctx.datapoints);\n expect(avg1s).toEqual([\n [9.5, 1500000000000], [2.5, 1500000001000], [5.5, 1500000002000], [4.5, 1500000003000]\n ]);\n\n const avg10s = aggregateBy('10s', 'avg', ctx.datapoints);\n expect(avg10s).toEqual([\n [5.5, 1500000000000]\n ]);\n });\n });\n});\n"]}
|
||||
489
dist/datasource-zabbix/specs/datasource.spec.js
vendored
@@ -1,489 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
System.register(["lodash", "../module", "../datasource"], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, Datasource, zabbixTemplateFormat;
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_module) {
|
||||
Datasource = _module.Datasource;
|
||||
}, function (_datasource) {
|
||||
zabbixTemplateFormat = _datasource.zabbixTemplateFormat;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
describe('ZabbixDatasource', function () {
|
||||
var ctx = {};
|
||||
|
||||
beforeEach(function () {
|
||||
ctx.instanceSettings = {
|
||||
jsonData: {
|
||||
alerting: false,
|
||||
username: 'zabbix',
|
||||
password: 'zabbix',
|
||||
trends: true,
|
||||
trendsFrom: '14d',
|
||||
trendsRange: '7d',
|
||||
dbConnectionEnable: false
|
||||
}
|
||||
};
|
||||
ctx.templateSrv = {};
|
||||
ctx.backendSrv = {
|
||||
datasourceRequest: jest.fn()
|
||||
};
|
||||
ctx.datasourceSrv = {};
|
||||
ctx.zabbixAlertingSrv = {
|
||||
setPanelAlertState: jest.fn(),
|
||||
removeZabbixThreshold: jest.fn()
|
||||
};
|
||||
|
||||
ctx.ds = new Datasource(ctx.instanceSettings, ctx.templateSrv, ctx.backendSrv, ctx.datasourceSrv, ctx.zabbixAlertingSrv);
|
||||
});
|
||||
|
||||
describe('When querying data', function () {
|
||||
beforeEach(function () {
|
||||
ctx.ds.replaceTemplateVars = function (str) {
|
||||
return str;
|
||||
};
|
||||
});
|
||||
|
||||
ctx.options = {
|
||||
targets: [{
|
||||
group: { filter: "" },
|
||||
host: { filter: "" },
|
||||
application: { filter: "" },
|
||||
item: { filter: "" }
|
||||
}],
|
||||
range: { from: 'now-7d', to: 'now' }
|
||||
};
|
||||
|
||||
it('should return an empty array when no targets are set', function (done) {
|
||||
var options = {
|
||||
targets: [],
|
||||
range: { from: 'now-6h', to: 'now' }
|
||||
};
|
||||
ctx.ds.query(options).then(function (result) {
|
||||
expect(result.data.length).toBe(0);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should use trends if it enabled and time more than trendsFrom', function (done) {
|
||||
var ranges = ['now-7d', 'now-168h', 'now-1M', 'now-1y'];
|
||||
|
||||
_.forEach(ranges, function (range) {
|
||||
ctx.options.range.from = range;
|
||||
ctx.ds.queryNumericData = jest.fn();
|
||||
ctx.ds.query(ctx.options);
|
||||
|
||||
// Check that useTrends options is true
|
||||
var callArgs = ctx.ds.queryNumericData.mock.calls[0];
|
||||
expect(callArgs[2]).toBe(true);
|
||||
ctx.ds.queryNumericData.mockClear();
|
||||
});
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('shouldnt use trends if it enabled and time less than trendsFrom', function (done) {
|
||||
var ranges = ['now-6d', 'now-167h', 'now-1h', 'now-30m', 'now-30s'];
|
||||
|
||||
_.forEach(ranges, function (range) {
|
||||
ctx.options.range.from = range;
|
||||
ctx.ds.queryNumericData = jest.fn();
|
||||
ctx.ds.query(ctx.options);
|
||||
|
||||
// Check that useTrends options is false
|
||||
var callArgs = ctx.ds.queryNumericData.mock.calls[0];
|
||||
expect(callArgs[2]).toBe(false);
|
||||
ctx.ds.queryNumericData.mockClear();
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When querying text data', function () {
|
||||
beforeEach(function () {
|
||||
ctx.ds.replaceTemplateVars = function (str) {
|
||||
return str;
|
||||
};
|
||||
ctx.ds.zabbix.zabbixAPI.getHistory = jest.fn().mockReturnValue(Promise.resolve([{ clock: "1500010200", itemid: "10100", ns: "900111000", value: "Linux first" }, { clock: "1500010300", itemid: "10100", ns: "900111000", value: "Linux 2nd" }, { clock: "1500010400", itemid: "10100", ns: "900111000", value: "Linux last" }]));
|
||||
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([{
|
||||
hosts: [{ hostid: "10001", name: "Zabbix server" }],
|
||||
itemid: "10100",
|
||||
name: "System information",
|
||||
key_: "system.uname"
|
||||
}]));
|
||||
|
||||
ctx.options = {
|
||||
range: { from: 'now-1h', to: 'now' },
|
||||
targets: [{
|
||||
group: { filter: "" },
|
||||
host: { filter: "Zabbix server" },
|
||||
application: { filter: "" },
|
||||
item: { filter: "System information" },
|
||||
textFilter: "",
|
||||
useCaptureGroups: true,
|
||||
mode: 2,
|
||||
resultFormat: "table",
|
||||
options: {
|
||||
skipEmptyValues: false
|
||||
}
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
it('should return data in table format', function (done) {
|
||||
ctx.ds.query(ctx.options).then(function (result) {
|
||||
expect(result.data.length).toBe(1);
|
||||
|
||||
var tableData = result.data[0];
|
||||
expect(tableData.columns).toEqual([{ text: 'Host' }, { text: 'Item' }, { text: 'Key' }, { text: 'Last value' }]);
|
||||
expect(tableData.rows).toEqual([['Zabbix server', 'System information', 'system.uname', 'Linux last']]);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should extract value if regex with capture group is used', function (done) {
|
||||
ctx.options.targets[0].textFilter = "Linux (.*)";
|
||||
ctx.ds.query(ctx.options).then(function (result) {
|
||||
var tableData = result.data[0];
|
||||
expect(tableData.rows[0][3]).toEqual('last');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('should skip item when last value is empty', function () {
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve([{
|
||||
hosts: [{ hostid: "10001", name: "Zabbix server" }],
|
||||
itemid: "10100", name: "System information", key_: "system.uname"
|
||||
}, {
|
||||
hosts: [{ hostid: "10002", name: "Server02" }],
|
||||
itemid: "90109", name: "System information", key_: "system.uname"
|
||||
}]));
|
||||
|
||||
ctx.options.targets[0].options.skipEmptyValues = true;
|
||||
ctx.ds.zabbix.getHistory = jest.fn().mockReturnValue(Promise.resolve([{ clock: "1500010200", itemid: "10100", ns: "900111000", value: "Linux first" }, { clock: "1500010300", itemid: "10100", ns: "900111000", value: "Linux 2nd" }, { clock: "1500010400", itemid: "10100", ns: "900111000", value: "Linux last" }, { clock: "1500010200", itemid: "90109", ns: "900111000", value: "Non empty value" }, { clock: "1500010500", itemid: "90109", ns: "900111000", value: "" }]));
|
||||
return ctx.ds.query(ctx.options).then(function (result) {
|
||||
var tableData = result.data[0];
|
||||
expect(tableData.rows.length).toBe(1);
|
||||
expect(tableData.rows[0][3]).toEqual('Linux last');
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe('When replacing template variables', function () {
|
||||
|
||||
function testReplacingVariable(target, varValue, expectedResult, done) {
|
||||
ctx.ds.templateSrv.replace = function () {
|
||||
return zabbixTemplateFormat(varValue);
|
||||
};
|
||||
|
||||
var result = ctx.ds.replaceTemplateVars(target);
|
||||
expect(result).toBe(expectedResult);
|
||||
done();
|
||||
}
|
||||
|
||||
/*
|
||||
* Alphanumerics, spaces, dots, dashes and underscores
|
||||
* are allowed in Zabbix host name.
|
||||
* 'AaBbCc0123 .-_'
|
||||
*/
|
||||
it('should return properly escaped regex', function (done) {
|
||||
var target = '$host';
|
||||
var template_var_value = 'AaBbCc0123 .-_';
|
||||
var expected_result = '/^AaBbCc0123 \\.-_$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
|
||||
/*
|
||||
* Single-value variable
|
||||
* $host = backend01
|
||||
* $host => /^backend01|backend01$/
|
||||
*/
|
||||
it('should return proper regex for single value', function (done) {
|
||||
var target = '$host';
|
||||
var template_var_value = 'backend01';
|
||||
var expected_result = '/^backend01$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
|
||||
/*
|
||||
* Multi-value variable
|
||||
* $host = [backend01, backend02]
|
||||
* $host => /^(backend01|backend01)$/
|
||||
*/
|
||||
it('should return proper regex for multi-value', function (done) {
|
||||
var target = '$host';
|
||||
var template_var_value = ['backend01', 'backend02'];
|
||||
var expected_result = '/^(backend01|backend02)$/';
|
||||
|
||||
testReplacingVariable(target, template_var_value, expected_result, done);
|
||||
});
|
||||
});
|
||||
|
||||
describe('When invoking metricFindQuery()', function () {
|
||||
beforeEach(function () {
|
||||
ctx.ds.replaceTemplateVars = function (str) {
|
||||
return str;
|
||||
};
|
||||
ctx.ds.zabbix = {
|
||||
getGroups: jest.fn().mockReturnValue(Promise.resolve([])),
|
||||
getHosts: jest.fn().mockReturnValue(Promise.resolve([])),
|
||||
getApps: jest.fn().mockReturnValue(Promise.resolve([])),
|
||||
getItems: jest.fn().mockReturnValue(Promise.resolve([]))
|
||||
};
|
||||
});
|
||||
|
||||
it('should return groups', function (done) {
|
||||
var tests = [{ query: '*', expect: '/.*/' }, { query: '', expect: '' }, { query: 'Backend', expect: 'Backend' }, { query: 'Back*', expect: 'Back*' }];
|
||||
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = tests[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var test = _step.value;
|
||||
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getGroups).toBeCalledWith(test.expect);
|
||||
ctx.ds.zabbix.getGroups.mockClear();
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return hosts', function (done) {
|
||||
var tests = [{ query: '*.*', expect: ['/.*/', '/.*/'] }, { query: '.', expect: ['', ''] }, { query: 'Backend.*', expect: ['Backend', '/.*/'] }, { query: 'Back*.', expect: ['Back*', ''] }];
|
||||
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = tests[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var test = _step2.value;
|
||||
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getHosts).toBeCalledWith(test.expect[0], test.expect[1]);
|
||||
ctx.ds.zabbix.getHosts.mockClear();
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return applications', function (done) {
|
||||
var tests = [{ query: '*.*.*', expect: ['/.*/', '/.*/', '/.*/'] }, { query: '.*.', expect: ['', '/.*/', ''] }, { query: 'Backend.backend01.*', expect: ['Backend', 'backend01', '/.*/'] }, { query: 'Back*.*.', expect: ['Back*', '/.*/', ''] }];
|
||||
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator3 = tests[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
||||
var test = _step3.value;
|
||||
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getApps).toBeCalledWith(test.expect[0], test.expect[1], test.expect[2]);
|
||||
ctx.ds.zabbix.getApps.mockClear();
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should return items', function (done) {
|
||||
var tests = [{ query: '*.*.*.*', expect: ['/.*/', '/.*/', '', '/.*/'] }, { query: '.*.*.*', expect: ['', '/.*/', '', '/.*/'] }, { query: 'Backend.backend01.*.*', expect: ['Backend', 'backend01', '', '/.*/'] }, { query: 'Back*.*.cpu.*', expect: ['Back*', '/.*/', 'cpu', '/.*/'] }];
|
||||
|
||||
var _iteratorNormalCompletion4 = true;
|
||||
var _didIteratorError4 = false;
|
||||
var _iteratorError4 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator4 = tests[Symbol.iterator](), _step4; !(_iteratorNormalCompletion4 = (_step4 = _iterator4.next()).done); _iteratorNormalCompletion4 = true) {
|
||||
var test = _step4.value;
|
||||
|
||||
ctx.ds.metricFindQuery(test.query);
|
||||
expect(ctx.ds.zabbix.getItems).toBeCalledWith(test.expect[0], test.expect[1], test.expect[2], test.expect[3]);
|
||||
ctx.ds.zabbix.getItems.mockClear();
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError4 = true;
|
||||
_iteratorError4 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion4 && _iterator4.return) {
|
||||
_iterator4.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError4) {
|
||||
throw _iteratorError4;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
done();
|
||||
});
|
||||
|
||||
it('should invoke method with proper arguments', function (done) {
|
||||
var query = '*.*';
|
||||
|
||||
ctx.ds.metricFindQuery(query);
|
||||
expect(ctx.ds.zabbix.getHosts).toBeCalledWith('/.*/', '/.*/');
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('When querying alerts', function () {
|
||||
var options = {};
|
||||
|
||||
beforeEach(function () {
|
||||
ctx.ds.replaceTemplateVars = function (str) {
|
||||
return str;
|
||||
};
|
||||
|
||||
var targetItems = [{
|
||||
"itemid": "1",
|
||||
"name": "test item",
|
||||
"key_": "test.key",
|
||||
"value_type": "3",
|
||||
"hostid": "10631",
|
||||
"status": "0",
|
||||
"state": "0",
|
||||
"hosts": [{ "hostid": "10631", "name": "Test host" }],
|
||||
"item": "Test item"
|
||||
}];
|
||||
ctx.ds.zabbix.getItemsFromTarget = jest.fn().mockReturnValue(Promise.resolve(targetItems));
|
||||
|
||||
options = {
|
||||
"panelId": 10,
|
||||
"targets": [{
|
||||
"application": { "filter": "" },
|
||||
"group": { "filter": "Test group" },
|
||||
"host": { "filter": "Test host" },
|
||||
"item": { "filter": "Test item" }
|
||||
}]
|
||||
};
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `less than`', function () {
|
||||
|
||||
var itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}<100"
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
|
||||
|
||||
return ctx.ds.alertQuery(options).then(function (resp) {
|
||||
expect(resp.thresholds).toHaveLength(1);
|
||||
expect(resp.thresholds[0]).toBe(100);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `less than or equal`', function () {
|
||||
|
||||
var itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}<=100"
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
|
||||
|
||||
return ctx.ds.alertQuery(options).then(function (resp) {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(100);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `greater than or equal`', function () {
|
||||
|
||||
var itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}>=30"
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
|
||||
|
||||
return ctx.ds.alertQuery(options).then(function (resp) {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(30);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
|
||||
it('should return threshold when comparative symbol is `equal`', function () {
|
||||
|
||||
var itemTriggers = [{
|
||||
"triggerid": "15383",
|
||||
"priority": "4",
|
||||
"expression": "{15915}=50"
|
||||
}];
|
||||
|
||||
ctx.ds.zabbix.getAlerts = jest.fn().mockReturnValue(Promise.resolve(itemTriggers));
|
||||
|
||||
return ctx.ds.alertQuery(options).then(function (resp) {
|
||||
expect(resp.thresholds.length).toBe(1);
|
||||
expect(resp.thresholds[0]).toBe(50);
|
||||
return resp;
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=datasource.spec.js.map
|
||||
62
dist/datasource-zabbix/specs/dbConnector.test.js
vendored
@@ -1,62 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['../zabbix/connectors/dbConnector'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var DBConnector;
|
||||
return {
|
||||
setters: [function (_zabbixConnectorsDbConnector) {
|
||||
DBConnector = _zabbixConnectorsDbConnector.default;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
describe('DBConnector', function () {
|
||||
var ctx = {};
|
||||
var backendSrvMock = {};
|
||||
var datasourceSrvMock = {
|
||||
loadDatasource: jest.fn().mockResolvedValue({ id: 42, name: 'foo', meta: {} }),
|
||||
getAll: jest.fn().mockReturnValue([{ id: 42, name: 'foo' }])
|
||||
};
|
||||
|
||||
describe('When init DB connector', function () {
|
||||
beforeEach(function () {
|
||||
ctx.options = {
|
||||
datasourceId: 42,
|
||||
datasourceName: undefined
|
||||
};
|
||||
});
|
||||
|
||||
it('should load datasource by name by default', function () {
|
||||
ctx.options = {
|
||||
datasourceName: 'bar'
|
||||
};
|
||||
var dbConnector = new DBConnector(ctx.options, backendSrvMock, datasourceSrvMock);
|
||||
dbConnector.loadDBDataSource();
|
||||
expect(datasourceSrvMock.getAll).not.toHaveBeenCalled();
|
||||
expect(datasourceSrvMock.loadDatasource).toHaveBeenCalledWith('bar');
|
||||
});
|
||||
|
||||
it('should load datasource by id if name not present', function () {
|
||||
var dbConnector = new DBConnector(ctx.options, backendSrvMock, datasourceSrvMock);
|
||||
dbConnector.loadDBDataSource();
|
||||
expect(datasourceSrvMock.getAll).toHaveBeenCalled();
|
||||
expect(datasourceSrvMock.loadDatasource).toHaveBeenCalledWith('foo');
|
||||
});
|
||||
|
||||
it('should throw error if no name and id specified', function () {
|
||||
ctx.options = {};
|
||||
var dbConnector = new DBConnector(ctx.options, backendSrvMock, datasourceSrvMock);
|
||||
return expect(dbConnector.loadDBDataSource()).rejects.toBe('SQL Data Source name should be specified');
|
||||
});
|
||||
|
||||
it('should throw error if datasource with given id is not found', function () {
|
||||
ctx.options.datasourceId = 45;
|
||||
var dbConnector = new DBConnector(ctx.options, backendSrvMock, datasourceSrvMock);
|
||||
return expect(dbConnector.loadDBDataSource()).rejects.toBe('SQL Data Source with ID 45 not found');
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=dbConnector.test.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/datasource-zabbix/specs/dbConnector.test.js"],"names":["DBConnector","describe","ctx","backendSrvMock","datasourceSrvMock","loadDatasource","jest","fn","mockResolvedValue","id","name","meta","getAll","mockReturnValue","beforeEach","options","datasourceId","datasourceName","undefined","it","dbConnector","loadDBDataSource","expect","not","toHaveBeenCalled","toHaveBeenCalledWith","rejects","toBe"],"mappings":";;;;;;;;AAAOA,iB;;;;AAEPC,eAAS,aAAT,EAAwB,YAAM;AAC5B,YAAIC,MAAM,EAAV;AACA,YAAMC,iBAAiB,EAAvB;AACA,YAAMC,oBAAoB;AACxBC,0BAAgBC,KAAKC,EAAL,GAAUC,iBAAV,CACd,EAAEC,IAAI,EAAN,EAAUC,MAAM,KAAhB,EAAuBC,MAAM,EAA7B,EADc,CADQ;AAIxBC,kBAAQN,KAAKC,EAAL,GAAUM,eAAV,CAA0B,CAChC,EAAEJ,IAAI,EAAN,EAAUC,MAAM,KAAhB,EADgC,CAA1B;AAJgB,SAA1B;;AASAT,iBAAS,wBAAT,EAAmC,YAAM;AACvCa,qBAAW,YAAM;AACfZ,gBAAIa,OAAJ,GAAc;AACZC,4BAAc,EADF;AAEZC,8BAAgBC;AAFJ,aAAd;AAID,WALD;;AAOAC,aAAG,2CAAH,EAAgD,YAAM;AACpDjB,gBAAIa,OAAJ,GAAc;AACZE,8BAAgB;AADJ,aAAd;AAGA,gBAAMG,cAAc,IAAIpB,WAAJ,CAAgBE,IAAIa,OAApB,EAA6BZ,cAA7B,EAA6CC,iBAA7C,CAApB;AACAgB,wBAAYC,gBAAZ;AACAC,mBAAOlB,kBAAkBQ,MAAzB,EAAiCW,GAAjC,CAAqCC,gBAArC;AACAF,mBAAOlB,kBAAkBC,cAAzB,EAAyCoB,oBAAzC,CAA8D,KAA9D;AACD,WARD;;AAUAN,aAAG,kDAAH,EAAuD,YAAM;AAC3D,gBAAMC,cAAc,IAAIpB,WAAJ,CAAgBE,IAAIa,OAApB,EAA6BZ,cAA7B,EAA6CC,iBAA7C,CAApB;AACAgB,wBAAYC,gBAAZ;AACAC,mBAAOlB,kBAAkBQ,MAAzB,EAAiCY,gBAAjC;AACAF,mBAAOlB,kBAAkBC,cAAzB,EAAyCoB,oBAAzC,CAA8D,KAA9D;AACD,WALD;;AAOAN,aAAG,gDAAH,EAAqD,YAAM;AACzDjB,gBAAIa,OAAJ,GAAc,EAAd;AACA,gBAAMK,cAAc,IAAIpB,WAAJ,CAAgBE,IAAIa,OAApB,EAA6BZ,cAA7B,EAA6CC,iBAA7C,CAApB;AACA,mBAAOkB,OAAOF,YAAYC,gBAAZ,EAAP,EAAuCK,OAAvC,CAA+CC,IAA/C,CAAoD,0CAApD,CAAP;AACD,WAJD;;AAMAR,aAAG,6DAAH,EAAkE,YAAM;AACtEjB,gBAAIa,OAAJ,CAAYC,YAAZ,GAA2B,EAA3B;AACA,gBAAMI,cAAc,IAAIpB,WAAJ,CAAgBE,IAAIa,OAApB,EAA6BZ,cAA7B,EAA6CC,iBAA7C,CAApB;AACA,mBAAOkB,OAAOF,YAAYC,gBAAZ,EAAP,EAAuCK,OAAvC,CAA+CC,IAA/C,CAAoD,sCAApD,CAAP;AACD,WAJD;AAKD,SApCD;AAqCD,OAjDD","file":"dbConnector.test.js","sourcesContent":["import DBConnector from '../zabbix/connectors/dbConnector';\n\ndescribe('DBConnector', () => {\n let ctx = {};\n const backendSrvMock = {};\n const datasourceSrvMock = {\n loadDatasource: jest.fn().mockResolvedValue(\n { id: 42, name: 'foo', meta: {} }\n ),\n getAll: jest.fn().mockReturnValue([\n { id: 42, name: 'foo' }\n ])\n };\n\n describe('When init DB connector', () => {\n beforeEach(() => {\n ctx.options = {\n datasourceId: 42,\n datasourceName: undefined\n };\n });\n\n it('should load datasource by name by default', () => {\n ctx.options = {\n datasourceName: 'bar'\n };\n const dbConnector = new DBConnector(ctx.options, backendSrvMock, datasourceSrvMock);\n dbConnector.loadDBDataSource();\n expect(datasourceSrvMock.getAll).not.toHaveBeenCalled();\n expect(datasourceSrvMock.loadDatasource).toHaveBeenCalledWith('bar');\n });\n\n it('should load datasource by id if name not present', () => {\n const dbConnector = new DBConnector(ctx.options, backendSrvMock, datasourceSrvMock);\n dbConnector.loadDBDataSource();\n expect(datasourceSrvMock.getAll).toHaveBeenCalled();\n expect(datasourceSrvMock.loadDatasource).toHaveBeenCalledWith('foo');\n });\n\n it('should throw error if no name and id specified', () => {\n ctx.options = {};\n const dbConnector = new DBConnector(ctx.options, backendSrvMock, datasourceSrvMock);\n return expect(dbConnector.loadDBDataSource()).rejects.toBe('SQL Data Source name should be specified');\n });\n\n it('should throw error if datasource with given id is not found', () => {\n ctx.options.datasourceId = 45;\n const dbConnector = new DBConnector(ctx.options, backendSrvMock, datasourceSrvMock);\n return expect(dbConnector.loadDBDataSource()).rejects.toBe('SQL Data Source with ID 45 not found');\n });\n });\n});\n"]}
|
||||
56
dist/datasource-zabbix/specs/migrations.test.js
vendored
@@ -1,56 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['../migrations'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var migrateDSConfig, DS_CONFIG_SCHEMA;
|
||||
return {
|
||||
setters: [function (_migrations) {
|
||||
migrateDSConfig = _migrations.migrateDSConfig;
|
||||
DS_CONFIG_SCHEMA = _migrations.DS_CONFIG_SCHEMA;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
describe('Migrations', function () {
|
||||
var ctx = {};
|
||||
|
||||
describe('When migrating datasource config', function () {
|
||||
beforeEach(function () {
|
||||
ctx.jsonData = {
|
||||
dbConnection: {
|
||||
enable: true,
|
||||
datasourceId: 1
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should change direct DB connection setting to flat style', function () {
|
||||
migrateDSConfig(ctx.jsonData);
|
||||
expect(ctx.jsonData).toMatchObject({
|
||||
dbConnectionEnable: true,
|
||||
dbConnectionDatasourceId: 1,
|
||||
schema: DS_CONFIG_SCHEMA
|
||||
});
|
||||
});
|
||||
|
||||
it('should not touch anything if schema is up to date', function () {
|
||||
ctx.jsonData = {
|
||||
futureOptionOne: 'foo',
|
||||
futureOptionTwo: 'bar',
|
||||
schema: DS_CONFIG_SCHEMA
|
||||
};
|
||||
migrateDSConfig(ctx.jsonData);
|
||||
expect(ctx.jsonData).toMatchObject({
|
||||
futureOptionOne: 'foo',
|
||||
futureOptionTwo: 'bar',
|
||||
schema: DS_CONFIG_SCHEMA
|
||||
});
|
||||
expect(ctx.jsonData.dbConnectionEnable).toBeUndefined();
|
||||
expect(ctx.jsonData.dbConnectionDatasourceId).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=migrations.test.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/datasource-zabbix/specs/migrations.test.js"],"names":["migrateDSConfig","DS_CONFIG_SCHEMA","describe","ctx","beforeEach","jsonData","dbConnection","enable","datasourceId","it","expect","toMatchObject","dbConnectionEnable","dbConnectionDatasourceId","schema","futureOptionOne","futureOptionTwo","toBeUndefined"],"mappings":";;;;;;;;AAASA,qB,eAAAA,e;AAAiBC,sB,eAAAA,gB;;;;AAE1BC,eAAS,YAAT,EAAuB,YAAM;AAC3B,YAAIC,MAAM,EAAV;;AAEAD,iBAAS,kCAAT,EAA6C,YAAM;AACjDE,qBAAW,YAAM;AACfD,gBAAIE,QAAJ,GAAe;AACbC,4BAAc;AACZC,wBAAQ,IADI;AAEZC,8BAAc;AAFF;AADD,aAAf;AAMD,WAPD;;AASAC,aAAG,0DAAH,EAA+D,YAAM;AACnET,4BAAgBG,IAAIE,QAApB;AACAK,mBAAOP,IAAIE,QAAX,EAAqBM,aAArB,CAAmC;AACjCC,kCAAoB,IADa;AAEjCC,wCAA0B,CAFO;AAGjCC,sBAAQb;AAHyB,aAAnC;AAKD,WAPD;;AASAQ,aAAG,mDAAH,EAAwD,YAAM;AAC5DN,gBAAIE,QAAJ,GAAe;AACbU,+BAAiB,KADJ;AAEbC,+BAAiB,KAFJ;AAGbF,sBAAQb;AAHK,aAAf;AAKAD,4BAAgBG,IAAIE,QAApB;AACAK,mBAAOP,IAAIE,QAAX,EAAqBM,aAArB,CAAmC;AACjCI,+BAAiB,KADgB;AAEjCC,+BAAiB,KAFgB;AAGjCF,sBAAQb;AAHyB,aAAnC;AAKAS,mBAAOP,IAAIE,QAAJ,CAAaO,kBAApB,EAAwCK,aAAxC;AACAP,mBAAOP,IAAIE,QAAJ,CAAaQ,wBAApB,EAA8CI,aAA9C;AACD,WAdD;AAeD,SAlCD;AAmCD,OAtCD","file":"migrations.test.js","sourcesContent":["import { migrateDSConfig, DS_CONFIG_SCHEMA } from '../migrations';\n\ndescribe('Migrations', () => {\n let ctx = {};\n\n describe('When migrating datasource config', () => {\n beforeEach(() => {\n ctx.jsonData = {\n dbConnection: {\n enable: true,\n datasourceId: 1\n }\n };\n });\n\n it('should change direct DB connection setting to flat style', () => {\n migrateDSConfig(ctx.jsonData);\n expect(ctx.jsonData).toMatchObject({\n dbConnectionEnable: true,\n dbConnectionDatasourceId: 1,\n schema: DS_CONFIG_SCHEMA\n });\n });\n\n it('should not touch anything if schema is up to date', () => {\n ctx.jsonData = {\n futureOptionOne: 'foo',\n futureOptionTwo: 'bar',\n schema: DS_CONFIG_SCHEMA\n };\n migrateDSConfig(ctx.jsonData);\n expect(ctx.jsonData).toMatchObject({\n futureOptionOne: 'foo',\n futureOptionTwo: 'bar',\n schema: DS_CONFIG_SCHEMA\n });\n expect(ctx.jsonData.dbConnectionEnable).toBeUndefined();\n expect(ctx.jsonData.dbConnectionDatasourceId).toBeUndefined();\n });\n });\n});\n"]}
|
||||
41
dist/datasource-zabbix/specs/timeseries.spec.js
vendored
@@ -1,41 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['../timeseries'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var ts;
|
||||
return {
|
||||
setters: [function (_timeseries) {
|
||||
ts = _timeseries.default;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
describe('timeseries processing functions', function () {
|
||||
|
||||
describe('sumSeries()', function () {
|
||||
it('should properly sum series', function (done) {
|
||||
var series = [[[0, 1], [1, 2], [1, 3]], [[2, 1], [3, 2], [4, 3]]];
|
||||
|
||||
var expected = [[2, 1], [4, 2], [5, 3]];
|
||||
|
||||
var result = ts.sumSeries(series);
|
||||
expect(result).toEqual(expected);
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly sum series with nulls', function (done) {
|
||||
// issue #286
|
||||
var series = [[[1, 1], [1, 2], [1, 3]], [[3, 2], [4, 3]]];
|
||||
|
||||
var expected = [[1, 1], [4, 2], [5, 3]];
|
||||
|
||||
var result = ts.sumSeries(series);
|
||||
expect(result).toEqual(expected);
|
||||
done();
|
||||
});
|
||||
});
|
||||
}); // import _ from 'lodash';
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=timeseries.spec.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../src/datasource-zabbix/specs/timeseries.spec.js"],"names":["ts","describe","it","done","series","expected","result","sumSeries","expect","toEqual"],"mappings":";;;;;;;;AACOA,Q;;;;AAEPC,eAAS,iCAAT,EAA4C,YAAM;;AAEhDA,iBAAS,aAAT,EAAwB,YAAM;AAC5BC,aAAG,4BAAH,EAAiC,UAACC,IAAD,EAAU;AACzC,gBAAIC,SAAS,CACX,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,CAAT,EAAiB,CAAC,CAAD,EAAI,CAAJ,CAAjB,CADW,EAEX,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,CAAT,EAAiB,CAAC,CAAD,EAAI,CAAJ,CAAjB,CAFW,CAAb;;AAKA,gBAAIC,WAAW,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,CAAT,EAAiB,CAAC,CAAD,EAAI,CAAJ,CAAjB,CAAf;;AAEA,gBAAIC,SAASN,GAAGO,SAAH,CAAaH,MAAb,CAAb;AACAI,mBAAOF,MAAP,EAAeG,OAAf,CAAuBJ,QAAvB;AACAF;AACD,WAXD;;AAaAD,aAAG,uCAAH,EAA4C,UAACC,IAAD,EAAU;AACpD;AACA,gBAAIC,SAAS,CACX,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,CAAT,EAAiB,CAAC,CAAD,EAAI,CAAJ,CAAjB,CADW,EAEX,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,CAAT,CAFW,CAAb;;AAKA,gBAAIC,WAAW,CAAC,CAAC,CAAD,EAAI,CAAJ,CAAD,EAAS,CAAC,CAAD,EAAI,CAAJ,CAAT,EAAiB,CAAC,CAAD,EAAI,CAAJ,CAAjB,CAAf;;AAEA,gBAAIC,SAASN,GAAGO,SAAH,CAAaH,MAAb,CAAb;AACAI,mBAAOF,MAAP,EAAeG,OAAf,CAAuBJ,QAAvB;AACAF;AACD,WAZD;AAaD,SA3BD;AA4BD,OA9BD,E,CAHA","file":"timeseries.spec.js","sourcesContent":["// import _ from 'lodash';\nimport ts from '../timeseries';\n\ndescribe('timeseries processing functions', () => {\n\n describe('sumSeries()', () => {\n it('should properly sum series', (done) => {\n let series = [\n [[0, 1], [1, 2], [1, 3]],\n [[2, 1], [3, 2], [4, 3]]\n ];\n\n let expected = [[2, 1], [4, 2], [5, 3]];\n\n let result = ts.sumSeries(series);\n expect(result).toEqual(expected);\n done();\n });\n\n it('should properly sum series with nulls', (done) => {\n // issue #286\n let series = [\n [[1, 1], [1, 2], [1, 3]],\n [[3, 2], [4, 3]]\n ];\n\n let expected = [[1, 1], [4, 2], [5, 3]];\n\n let result = ts.sumSeries(series);\n expect(result).toEqual(expected);\n done();\n });\n });\n});\n"]}
|
||||
136
dist/datasource-zabbix/specs/utils.spec.js
vendored
@@ -1,136 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', '../utils'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, utils;
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_utils) {
|
||||
utils = _utils;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
describe('Utils', function () {
|
||||
|
||||
describe('expandItemName()', function () {
|
||||
|
||||
it('should properly expand unquoted params', function (done) {
|
||||
var test_cases = [{
|
||||
name: 'CPU $2 time',
|
||||
key: 'system.cpu.util[,user,avg1]',
|
||||
expected: "CPU user time"
|
||||
}, {
|
||||
name: 'CPU $2 time - $3',
|
||||
key: 'system.cpu.util[,system,avg1]',
|
||||
expected: "CPU system time - avg1"
|
||||
}, {
|
||||
name: 'CPU - $1 - $2 - $3',
|
||||
key: 'system.cpu.util[,system,avg1]',
|
||||
expected: "CPU - - system - avg1"
|
||||
}];
|
||||
|
||||
_.each(test_cases, function (test_case) {
|
||||
var expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly expand quoted params with commas', function (done) {
|
||||
var test_cases = [{
|
||||
name: 'CPU $2 time',
|
||||
key: 'system.cpu.util["type=user,value=avg",user]',
|
||||
expected: "CPU user time"
|
||||
}, {
|
||||
name: 'CPU $1 time',
|
||||
key: 'system.cpu.util["type=user,value=avg","user"]',
|
||||
expected: "CPU type=user,value=avg time"
|
||||
}, {
|
||||
name: 'CPU $1 time $3',
|
||||
key: 'system.cpu.util["type=user,value=avg",,"user"]',
|
||||
expected: "CPU type=user,value=avg time user"
|
||||
}, {
|
||||
name: 'CPU $1 $2 $3',
|
||||
key: 'system.cpu.util["type=user,value=avg",time,"user"]',
|
||||
expected: "CPU type=user,value=avg time user"
|
||||
}];
|
||||
|
||||
_.each(test_cases, function (test_case) {
|
||||
var expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly expand array params', function (done) {
|
||||
var test_cases = [{
|
||||
name: 'CPU $2 - $3 time',
|
||||
key: 'system.cpu.util[,[user,system],avg1]',
|
||||
expected: "CPU user,system - avg1 time"
|
||||
}, {
|
||||
name: 'CPU $2 - $3 time',
|
||||
key: 'system.cpu.util[,["user,system",iowait],avg1]',
|
||||
expected: 'CPU "user,system",iowait - avg1 time'
|
||||
}, {
|
||||
name: 'CPU - $2 - $3 - $4',
|
||||
key: 'system.cpu.util[,[],["user,system",iowait],avg1]',
|
||||
expected: 'CPU - - "user,system",iowait - avg1'
|
||||
}];
|
||||
|
||||
_.each(test_cases, function (test_case) {
|
||||
var expandedName = utils.expandItemName(test_case.name, test_case.key);
|
||||
expect(expandedName).toBe(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
describe('splitTemplateQuery()', function () {
|
||||
|
||||
// Backward compatibility
|
||||
it('should properly split query in old format', function (done) {
|
||||
var test_cases = [{
|
||||
query: '/alu/./tw-(nyc|que|brx|dwt|brk)-sta_(w|d)*-alu-[0-9{2}/',
|
||||
expected: ['/alu/', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9{2}/']
|
||||
}, {
|
||||
query: 'a.b.c.d',
|
||||
expected: ['a', 'b', 'c', 'd']
|
||||
}];
|
||||
|
||||
_.each(test_cases, function (test_case) {
|
||||
var splitQuery = utils.splitTemplateQuery(test_case.query);
|
||||
expect(splitQuery).toEqual(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
|
||||
it('should properly split query', function (done) {
|
||||
var test_cases = [{
|
||||
query: '{alu}{/tw-(nyc|que|brx|dwt|brk)-sta_(w|d)*-alu-[0-9]*/}',
|
||||
expected: ['alu', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]*/']
|
||||
}, {
|
||||
query: '{alu}{/tw-(nyc|que|brx|dwt|brk)-sta_(w|d)*-alu-[0-9]{2}/}',
|
||||
expected: ['alu', '/tw-(nyc|que|brx|dwt|brk)-sta_(\w|\d)*-alu-[0-9]{2}/']
|
||||
}, {
|
||||
query: '{a}{b}{c}{d}',
|
||||
expected: ['a', 'b', 'c', 'd']
|
||||
}, {
|
||||
query: '{a}{b.c.d}',
|
||||
expected: ['a', 'b.c.d']
|
||||
}];
|
||||
|
||||
_.each(test_cases, function (test_case) {
|
||||
var splitQuery = utils.splitTemplateQuery(test_case.query);
|
||||
expect(splitQuery).toEqual(test_case.expected);
|
||||
});
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=utils.spec.js.map
|
||||
491
dist/datasource-zabbix/timeseries.js
vendored
@@ -1,491 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', './utils'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, utils, POINT_VALUE, POINT_TIMESTAMP, exportedFunctions;
|
||||
|
||||
/**
|
||||
* Downsample time series by using given function (avg, min, max).
|
||||
*/
|
||||
function downsample(datapoints, time_to, ms_interval, func) {
|
||||
var downsampledSeries = [];
|
||||
var timeWindow = {
|
||||
from: time_to * 1000 - ms_interval,
|
||||
to: time_to * 1000
|
||||
};
|
||||
|
||||
var points_sum = 0;
|
||||
var points_num = 0;
|
||||
var value_avg = 0;
|
||||
var frame = [];
|
||||
|
||||
for (var i = datapoints.length - 1; i >= 0; i -= 1) {
|
||||
if (timeWindow.from < datapoints[i][1] && datapoints[i][1] <= timeWindow.to) {
|
||||
points_sum += datapoints[i][0];
|
||||
points_num++;
|
||||
frame.push(datapoints[i][0]);
|
||||
} else {
|
||||
value_avg = points_num ? points_sum / points_num : 0;
|
||||
|
||||
if (func === "max") {
|
||||
downsampledSeries.push([_.max(frame), timeWindow.to]);
|
||||
} else if (func === "min") {
|
||||
downsampledSeries.push([_.min(frame), timeWindow.to]);
|
||||
}
|
||||
|
||||
// avg by default
|
||||
else {
|
||||
downsampledSeries.push([value_avg, timeWindow.to]);
|
||||
}
|
||||
|
||||
// Shift time window
|
||||
timeWindow.to = timeWindow.from;
|
||||
timeWindow.from -= ms_interval;
|
||||
|
||||
points_sum = 0;
|
||||
points_num = 0;
|
||||
frame = [];
|
||||
|
||||
// Process point again
|
||||
i++;
|
||||
}
|
||||
}
|
||||
return downsampledSeries.reverse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Group points by given time interval
|
||||
* datapoints: [[<value>, <unixtime>], ...]
|
||||
*/
|
||||
function groupBy(datapoints, interval, groupByCallback) {
|
||||
var ms_interval = utils.parseInterval(interval);
|
||||
|
||||
// Calculate frame timestamps
|
||||
var frames = _.groupBy(datapoints, function (point) {
|
||||
// Calculate time for group of points
|
||||
return Math.floor(point[1] / ms_interval) * ms_interval;
|
||||
});
|
||||
|
||||
// frame: { '<unixtime>': [[<value>, <unixtime>], ...] }
|
||||
// return [{ '<unixtime>': <value> }, { '<unixtime>': <value> }, ...]
|
||||
var grouped = _.mapValues(frames, function (frame) {
|
||||
var points = _.map(frame, function (point) {
|
||||
return point[0];
|
||||
});
|
||||
return groupByCallback(points);
|
||||
});
|
||||
|
||||
// Convert points to Grafana format
|
||||
return sortByTime(_.map(grouped, function (value, timestamp) {
|
||||
return [Number(value), Number(timestamp)];
|
||||
}));
|
||||
}
|
||||
|
||||
function groupBy_perf(datapoints, interval, groupByCallback) {
|
||||
if (datapoints.length === 0) {
|
||||
return [];
|
||||
}
|
||||
|
||||
var ms_interval = utils.parseInterval(interval);
|
||||
var grouped_series = [];
|
||||
var frame_values = [];
|
||||
var frame_value = void 0;
|
||||
var frame_ts = datapoints.length ? getPointTimeFrame(datapoints[0][POINT_TIMESTAMP], ms_interval) : 0;
|
||||
var point_frame_ts = frame_ts;
|
||||
var point = void 0;
|
||||
|
||||
for (var i = 0; i < datapoints.length; i++) {
|
||||
point = datapoints[i];
|
||||
point_frame_ts = getPointTimeFrame(point[POINT_TIMESTAMP], ms_interval);
|
||||
if (point_frame_ts === frame_ts) {
|
||||
frame_values.push(point[POINT_VALUE]);
|
||||
} else if (point_frame_ts > frame_ts) {
|
||||
frame_value = groupByCallback(frame_values);
|
||||
grouped_series.push([frame_value, frame_ts]);
|
||||
|
||||
// Move frame window to next non-empty interval and fill empty by null
|
||||
frame_ts += ms_interval;
|
||||
while (frame_ts < point_frame_ts) {
|
||||
grouped_series.push([null, frame_ts]);
|
||||
frame_ts += ms_interval;
|
||||
}
|
||||
frame_values = [point[POINT_VALUE]];
|
||||
}
|
||||
}
|
||||
|
||||
frame_value = groupByCallback(frame_values);
|
||||
grouped_series.push([frame_value, frame_ts]);
|
||||
|
||||
return grouped_series;
|
||||
}
|
||||
|
||||
/**
|
||||
* Summarize set of time series into one.
|
||||
* @param {datapoints[]} timeseries array of time series
|
||||
*/
|
||||
function sumSeries(timeseries) {
|
||||
|
||||
// Calculate new points for interpolation
|
||||
var new_timestamps = _.uniq(_.map(_.flatten(timeseries, true), function (point) {
|
||||
return point[1];
|
||||
}));
|
||||
new_timestamps = _.sortBy(new_timestamps);
|
||||
|
||||
var interpolated_timeseries = _.map(timeseries, function (series) {
|
||||
series = fillZeroes(series, new_timestamps);
|
||||
var timestamps = _.map(series, function (point) {
|
||||
return point[1];
|
||||
});
|
||||
var new_points = _.map(_.difference(new_timestamps, timestamps), function (timestamp) {
|
||||
return [null, timestamp];
|
||||
});
|
||||
var new_series = series.concat(new_points);
|
||||
return sortByTime(new_series);
|
||||
});
|
||||
|
||||
_.each(interpolated_timeseries, interpolateSeries);
|
||||
|
||||
var new_timeseries = [];
|
||||
var sum;
|
||||
for (var i = new_timestamps.length - 1; i >= 0; i--) {
|
||||
sum = 0;
|
||||
for (var j = interpolated_timeseries.length - 1; j >= 0; j--) {
|
||||
sum += interpolated_timeseries[j][i][0];
|
||||
}
|
||||
new_timeseries.push([sum, new_timestamps[i]]);
|
||||
}
|
||||
|
||||
return sortByTime(new_timeseries);
|
||||
}
|
||||
|
||||
function scale(datapoints, factor) {
|
||||
return _.map(datapoints, function (point) {
|
||||
return [point[0] * factor, point[1]];
|
||||
});
|
||||
}
|
||||
|
||||
function scale_perf(datapoints, factor) {
|
||||
for (var i = 0; i < datapoints.length; i++) {
|
||||
datapoints[i] = [datapoints[i][POINT_VALUE] * factor, datapoints[i][POINT_TIMESTAMP]];
|
||||
}
|
||||
|
||||
return datapoints;
|
||||
}
|
||||
|
||||
/**
|
||||
* Simple delta. Calculate value delta between points.
|
||||
* @param {*} datapoints
|
||||
*/
|
||||
function delta(datapoints) {
|
||||
var newSeries = [];
|
||||
var deltaValue = void 0;
|
||||
for (var i = 1; i < datapoints.length; i++) {
|
||||
deltaValue = datapoints[i][0] - datapoints[i - 1][0];
|
||||
newSeries.push([deltaValue, datapoints[i][1]]);
|
||||
}
|
||||
return newSeries;
|
||||
}
|
||||
|
||||
/**
|
||||
* Calculates rate per second. Resistant to counter reset.
|
||||
* @param {*} datapoints
|
||||
*/
|
||||
function rate(datapoints) {
|
||||
var newSeries = [];
|
||||
var point = void 0,
|
||||
point_prev = void 0;
|
||||
var valueDelta = 0;
|
||||
var timeDelta = 0;
|
||||
for (var i = 1; i < datapoints.length; i++) {
|
||||
point = datapoints[i];
|
||||
point_prev = datapoints[i - 1];
|
||||
|
||||
// Convert ms to seconds
|
||||
timeDelta = (point[POINT_TIMESTAMP] - point_prev[POINT_TIMESTAMP]) / 1000;
|
||||
|
||||
// Handle counter reset - use previous value
|
||||
if (point[POINT_VALUE] >= point_prev[POINT_VALUE]) {
|
||||
valueDelta = (point[POINT_VALUE] - point_prev[POINT_VALUE]) / timeDelta;
|
||||
}
|
||||
|
||||
newSeries.push([valueDelta, point[POINT_TIMESTAMP]]);
|
||||
}
|
||||
return newSeries;
|
||||
}
|
||||
|
||||
function simpleMovingAverage(datapoints, n) {
|
||||
var sma = [];
|
||||
var w_sum = void 0;
|
||||
var w_avg = null;
|
||||
var w_count = 0;
|
||||
|
||||
// Initial window
|
||||
for (var j = n; j > 0; j--) {
|
||||
if (datapoints[n - j][POINT_VALUE] !== null) {
|
||||
w_avg += datapoints[n - j][POINT_VALUE];
|
||||
w_count++;
|
||||
}
|
||||
}
|
||||
if (w_count > 0) {
|
||||
w_avg = w_avg / w_count;
|
||||
} else {
|
||||
w_avg = null;
|
||||
}
|
||||
sma.push([w_avg, datapoints[n - 1][POINT_TIMESTAMP]]);
|
||||
|
||||
for (var i = n; i < datapoints.length; i++) {
|
||||
// Insert next value
|
||||
if (datapoints[i][POINT_VALUE] !== null) {
|
||||
w_sum = w_avg * w_count;
|
||||
w_avg = (w_sum + datapoints[i][POINT_VALUE]) / (w_count + 1);
|
||||
w_count++;
|
||||
}
|
||||
// Remove left side point
|
||||
if (datapoints[i - n][POINT_VALUE] !== null) {
|
||||
w_sum = w_avg * w_count;
|
||||
if (w_count > 1) {
|
||||
w_avg = (w_sum - datapoints[i - n][POINT_VALUE]) / (w_count - 1);
|
||||
w_count--;
|
||||
} else {
|
||||
w_avg = null;
|
||||
w_count = 0;
|
||||
}
|
||||
}
|
||||
sma.push([w_avg, datapoints[i][POINT_TIMESTAMP]]);
|
||||
}
|
||||
return sma;
|
||||
}
|
||||
|
||||
function expMovingAverage(datapoints, n) {
|
||||
var ema = [datapoints[0]];
|
||||
var ema_prev = datapoints[0][POINT_VALUE];
|
||||
var ema_cur = void 0;
|
||||
var a = void 0;
|
||||
|
||||
if (n > 1) {
|
||||
// Calculate a from window size
|
||||
a = 2 / (n + 1);
|
||||
|
||||
// Initial window, use simple moving average
|
||||
var w_avg = null;
|
||||
var w_count = 0;
|
||||
for (var j = n; j > 0; j--) {
|
||||
if (datapoints[n - j][POINT_VALUE] !== null) {
|
||||
w_avg += datapoints[n - j][POINT_VALUE];
|
||||
w_count++;
|
||||
}
|
||||
}
|
||||
if (w_count > 0) {
|
||||
w_avg = w_avg / w_count;
|
||||
// Actually, we should set timestamp from datapoints[n-1] and start calculation of EMA from n.
|
||||
// But in order to start EMA from first point (not from Nth) we should expand time range and request N additional
|
||||
// points outside left side of range. We can't do that, so this trick is used for pretty view of first N points.
|
||||
// We calculate AVG for first N points, but then start from 2nd point, not from Nth. In general, it means we
|
||||
// assume that previous N values (0-N, 0-(N-1), ..., 0-1) have the same average value as a first N values.
|
||||
ema = [[w_avg, datapoints[0][POINT_TIMESTAMP]]];
|
||||
ema_prev = w_avg;
|
||||
n = 1;
|
||||
}
|
||||
} else {
|
||||
// Use predefined a and start from 1st point (use it as initial EMA value)
|
||||
a = n;
|
||||
n = 1;
|
||||
}
|
||||
|
||||
for (var i = n; i < datapoints.length; i++) {
|
||||
if (datapoints[i][POINT_VALUE] !== null) {
|
||||
ema_cur = a * datapoints[i][POINT_VALUE] + (1 - a) * ema_prev;
|
||||
ema_prev = ema_cur;
|
||||
ema.push([ema_cur, datapoints[i][POINT_TIMESTAMP]]);
|
||||
} else {
|
||||
ema.push([null, datapoints[i][POINT_TIMESTAMP]]);
|
||||
}
|
||||
}
|
||||
return ema;
|
||||
}
|
||||
|
||||
function PERCENTIL(n, values) {
|
||||
var sorted = _.sortBy(values);
|
||||
return sorted[Math.floor(sorted.length * n / 100)];
|
||||
}
|
||||
|
||||
function COUNT(values) {
|
||||
return values.length;
|
||||
}
|
||||
|
||||
function SUM(values) {
|
||||
var sum = null;
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
if (values[i] !== null) {
|
||||
sum += values[i];
|
||||
}
|
||||
}
|
||||
return sum;
|
||||
}
|
||||
|
||||
function AVERAGE(values) {
|
||||
var values_non_null = getNonNullValues(values);
|
||||
if (values_non_null.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return SUM(values_non_null) / values_non_null.length;
|
||||
}
|
||||
|
||||
function getNonNullValues(values) {
|
||||
var values_non_null = [];
|
||||
for (var i = 0; i < values.length; i++) {
|
||||
if (values[i] !== null) {
|
||||
values_non_null.push(values[i]);
|
||||
}
|
||||
}
|
||||
return values_non_null;
|
||||
}
|
||||
|
||||
function MIN(values) {
|
||||
return _.min(values);
|
||||
}
|
||||
|
||||
function MAX(values) {
|
||||
return _.max(values);
|
||||
}
|
||||
|
||||
function MEDIAN(values) {
|
||||
var sorted = _.sortBy(values);
|
||||
return sorted[Math.floor(sorted.length / 2)];
|
||||
}
|
||||
|
||||
///////////////////////
|
||||
// Utility functions //
|
||||
///////////////////////
|
||||
|
||||
/**
|
||||
* For given point calculate corresponding time frame.
|
||||
*
|
||||
* |__*_|_*__|___*| -> |*___|*___|*___|
|
||||
*
|
||||
* @param {*} timestamp
|
||||
* @param {*} ms_interval
|
||||
*/
|
||||
function getPointTimeFrame(timestamp, ms_interval) {
|
||||
return Math.floor(timestamp / ms_interval) * ms_interval;
|
||||
}
|
||||
|
||||
function sortByTime(series) {
|
||||
return _.sortBy(series, function (point) {
|
||||
return point[1];
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Fill empty front and end of series by zeroes.
|
||||
*
|
||||
* | *** | | *** |
|
||||
* |___ ___| -> |*** ***|
|
||||
* @param {*} series
|
||||
* @param {*} timestamps
|
||||
*/
|
||||
function fillZeroes(series, timestamps) {
|
||||
var prepend = [];
|
||||
var append = [];
|
||||
var new_point = void 0;
|
||||
for (var i = 0; i < timestamps.length; i++) {
|
||||
if (timestamps[i] < series[0][POINT_TIMESTAMP]) {
|
||||
new_point = [0, timestamps[i]];
|
||||
prepend.push(new_point);
|
||||
} else if (timestamps[i] > series[series.length - 1][POINT_TIMESTAMP]) {
|
||||
new_point = [0, timestamps[i]];
|
||||
append.push(new_point);
|
||||
}
|
||||
}
|
||||
return _.concat(_.concat(prepend, series), append);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interpolate series with gaps
|
||||
*/
|
||||
function interpolateSeries(series) {
|
||||
var left, right;
|
||||
|
||||
// Interpolate series
|
||||
for (var i = series.length - 1; i >= 0; i--) {
|
||||
if (!series[i][0]) {
|
||||
left = findNearestLeft(series, i);
|
||||
right = findNearestRight(series, i);
|
||||
if (!left) {
|
||||
left = right;
|
||||
}
|
||||
if (!right) {
|
||||
right = left;
|
||||
}
|
||||
series[i][0] = linearInterpolation(series[i][1], left, right);
|
||||
}
|
||||
}
|
||||
return series;
|
||||
}
|
||||
|
||||
function linearInterpolation(timestamp, left, right) {
|
||||
if (left[1] === right[1]) {
|
||||
return (left[0] + right[0]) / 2;
|
||||
} else {
|
||||
return left[0] + (right[0] - left[0]) / (right[1] - left[1]) * (timestamp - left[1]);
|
||||
}
|
||||
}
|
||||
|
||||
function findNearestRight(series, pointIndex) {
|
||||
for (var i = pointIndex; i < series.length; i++) {
|
||||
if (series[i][0] !== null) {
|
||||
return series[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
function findNearestLeft(series, pointIndex) {
|
||||
for (var i = pointIndex; i > 0; i--) {
|
||||
if (series[i][0] !== null) {
|
||||
return series[i];
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
////////////
|
||||
// Export //
|
||||
////////////
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_utils) {
|
||||
utils = _utils;
|
||||
}],
|
||||
execute: function () {
|
||||
POINT_VALUE = 0;
|
||||
POINT_TIMESTAMP = 1;
|
||||
exportedFunctions = {
|
||||
downsample: downsample,
|
||||
groupBy: groupBy,
|
||||
groupBy_perf: groupBy_perf,
|
||||
sumSeries: sumSeries,
|
||||
scale: scale,
|
||||
scale_perf: scale_perf,
|
||||
delta: delta,
|
||||
rate: rate,
|
||||
simpleMovingAverage: simpleMovingAverage,
|
||||
expMovingAverage: expMovingAverage,
|
||||
SUM: SUM,
|
||||
COUNT: COUNT,
|
||||
AVERAGE: AVERAGE,
|
||||
MIN: MIN,
|
||||
MAX: MAX,
|
||||
MEDIAN: MEDIAN,
|
||||
PERCENTIL: PERCENTIL,
|
||||
sortByTime: sortByTime
|
||||
};
|
||||
|
||||
_export('default', exportedFunctions);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=timeseries.js.map
|
||||
1
dist/datasource-zabbix/timeseries.js.map
vendored
292
dist/datasource-zabbix/utils.js
vendored
@@ -1,292 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', 'moment'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, moment, MACRO_PATTERN, regexPattern;
|
||||
|
||||
/**
|
||||
* Expand Zabbix item name
|
||||
*
|
||||
* @param {string} name item name, ie "CPU $2 time"
|
||||
* @param {string} key item key, ie system.cpu.util[,system,avg1]
|
||||
* @return {string} expanded name, ie "CPU system time"
|
||||
*/
|
||||
function expandItemName(name, key) {
|
||||
|
||||
// extract params from key:
|
||||
// "system.cpu.util[,system,avg1]" --> ["", "system", "avg1"]
|
||||
var key_params_str = key.substring(key.indexOf('[') + 1, key.lastIndexOf(']'));
|
||||
var key_params = splitKeyParams(key_params_str);
|
||||
|
||||
// replace item parameters
|
||||
for (var i = key_params.length; i >= 1; i--) {
|
||||
name = name.replace('$' + i, key_params[i - 1]);
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
_export('expandItemName', expandItemName);
|
||||
|
||||
function expandItems(items) {
|
||||
_.forEach(items, function (item) {
|
||||
item.item = item.name;
|
||||
item.name = expandItemName(item.item, item.key_);
|
||||
return item;
|
||||
});
|
||||
return items;
|
||||
}
|
||||
_export('expandItems', expandItems);
|
||||
|
||||
function splitKeyParams(paramStr) {
|
||||
var params = [];
|
||||
var quoted = false;
|
||||
var in_array = false;
|
||||
var split_symbol = ',';
|
||||
var param = '';
|
||||
|
||||
_.forEach(paramStr, function (symbol) {
|
||||
if (symbol === '"' && in_array) {
|
||||
param += symbol;
|
||||
} else if (symbol === '"' && quoted) {
|
||||
quoted = false;
|
||||
} else if (symbol === '"' && !quoted) {
|
||||
quoted = true;
|
||||
} else if (symbol === '[' && !quoted) {
|
||||
in_array = true;
|
||||
} else if (symbol === ']' && !quoted) {
|
||||
in_array = false;
|
||||
} else if (symbol === split_symbol && !quoted && !in_array) {
|
||||
params.push(param);
|
||||
param = '';
|
||||
} else {
|
||||
param += symbol;
|
||||
}
|
||||
});
|
||||
|
||||
params.push(param);
|
||||
return params;
|
||||
}
|
||||
|
||||
function containsMacro(itemName) {
|
||||
return MACRO_PATTERN.test(itemName);
|
||||
}
|
||||
|
||||
_export('containsMacro', containsMacro);
|
||||
|
||||
function replaceMacro(item, macros) {
|
||||
var itemName = item.name;
|
||||
var item_macros = itemName.match(MACRO_PATTERN);
|
||||
_.forEach(item_macros, function (macro) {
|
||||
var host_macros = _.filter(macros, function (m) {
|
||||
if (m.hostid) {
|
||||
return m.hostid === item.hostid;
|
||||
} else {
|
||||
// Add global macros
|
||||
return true;
|
||||
}
|
||||
});
|
||||
|
||||
var macro_def = _.find(host_macros, { macro: macro });
|
||||
if (macro_def && macro_def.value) {
|
||||
var macro_value = macro_def.value;
|
||||
var macro_regex = new RegExp(escapeMacro(macro));
|
||||
itemName = itemName.replace(macro_regex, macro_value);
|
||||
}
|
||||
});
|
||||
|
||||
return itemName;
|
||||
}
|
||||
|
||||
_export('replaceMacro', replaceMacro);
|
||||
|
||||
function escapeMacro(macro) {
|
||||
macro = macro.replace(/\$/, '\\\$');
|
||||
return macro;
|
||||
}
|
||||
|
||||
/**
|
||||
* Split template query to parts of zabbix entities
|
||||
* group.host.app.item -> [group, host, app, item]
|
||||
* {group}{host.com} -> [group, host.com]
|
||||
*/
|
||||
function splitTemplateQuery(query) {
|
||||
var splitPattern = /\{[^\{\}]*\}|\{\/.*\/\}/g;
|
||||
var split = void 0;
|
||||
|
||||
if (isContainsBraces(query)) {
|
||||
var result = query.match(splitPattern);
|
||||
split = _.map(result, function (part) {
|
||||
return _.trim(part, '{}');
|
||||
});
|
||||
} else {
|
||||
split = query.split('.');
|
||||
}
|
||||
|
||||
return split;
|
||||
}
|
||||
|
||||
_export('splitTemplateQuery', splitTemplateQuery);
|
||||
|
||||
function isContainsBraces(query) {
|
||||
var bracesPattern = /^\{.+\}$/;
|
||||
return bracesPattern.test(query);
|
||||
}
|
||||
|
||||
// Pattern for testing regex
|
||||
function isRegex(str) {
|
||||
return regexPattern.test(str);
|
||||
}
|
||||
|
||||
_export('isRegex', isRegex);
|
||||
|
||||
function isTemplateVariable(str, templateVariables) {
|
||||
var variablePattern = /^\$\w+/;
|
||||
if (variablePattern.test(str)) {
|
||||
var variables = _.map(templateVariables, function (variable) {
|
||||
return '$' + variable.name;
|
||||
});
|
||||
return _.includes(variables, str);
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
_export('isTemplateVariable', isTemplateVariable);
|
||||
|
||||
function buildRegex(str) {
|
||||
var matches = str.match(regexPattern);
|
||||
var pattern = matches[1];
|
||||
var flags = matches[2] !== "" ? matches[2] : undefined;
|
||||
return new RegExp(pattern, flags);
|
||||
}
|
||||
|
||||
// Need for template variables replace
|
||||
// From Grafana's templateSrv.js
|
||||
|
||||
_export('buildRegex', buildRegex);
|
||||
|
||||
function escapeRegex(value) {
|
||||
return value.replace(/[\\^$*+?.()|[\]{}\/]/g, '\\$&');
|
||||
}
|
||||
|
||||
_export('escapeRegex', escapeRegex);
|
||||
|
||||
function parseInterval(interval) {
|
||||
var intervalPattern = /(^[\d]+)(y|M|w|d|h|m|s)/g;
|
||||
var momentInterval = intervalPattern.exec(interval);
|
||||
return moment.duration(Number(momentInterval[1]), momentInterval[2]).valueOf();
|
||||
}
|
||||
|
||||
_export('parseInterval', parseInterval);
|
||||
|
||||
function parseTimeShiftInterval(interval) {
|
||||
var intervalPattern = /^([\+\-]*)([\d]+)(y|M|w|d|h|m|s)/g;
|
||||
var momentInterval = intervalPattern.exec(interval);
|
||||
var duration = 0;
|
||||
|
||||
if (momentInterval[1] === '+') {
|
||||
duration = 0 - moment.duration(Number(momentInterval[2]), momentInterval[3]).valueOf();
|
||||
} else {
|
||||
duration = moment.duration(Number(momentInterval[2]), momentInterval[3]).valueOf();
|
||||
}
|
||||
|
||||
return duration;
|
||||
}
|
||||
|
||||
/**
|
||||
* Format acknowledges.
|
||||
*
|
||||
* @param {array} acknowledges array of Zabbix acknowledge objects
|
||||
* @return {string} HTML-formatted table
|
||||
*/
|
||||
|
||||
_export('parseTimeShiftInterval', parseTimeShiftInterval);
|
||||
|
||||
function formatAcknowledges(acknowledges) {
|
||||
if (acknowledges.length) {
|
||||
var formatted_acknowledges = '<br><br>Acknowledges:<br><table><tr><td><b>Time</b></td>' + '<td><b>User</b></td><td><b>Comments</b></td></tr>';
|
||||
_.each(_.map(acknowledges, function (ack) {
|
||||
var timestamp = moment.unix(ack.clock);
|
||||
return '<tr><td><i>' + timestamp.format("DD MMM YYYY HH:mm:ss") + '</i></td><td>' + ack.alias + ' (' + ack.name + ' ' + ack.surname + ')' + '</td><td>' + ack.message + '</td></tr>';
|
||||
}), function (ack) {
|
||||
formatted_acknowledges = formatted_acknowledges.concat(ack);
|
||||
});
|
||||
formatted_acknowledges = formatted_acknowledges.concat('</table>');
|
||||
return formatted_acknowledges;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
_export('formatAcknowledges', formatAcknowledges);
|
||||
|
||||
function convertToZabbixAPIUrl(url) {
|
||||
var zabbixAPIUrlPattern = /.*api_jsonrpc.php$/;
|
||||
var trimSlashPattern = /(.*?)[\/]*$/;
|
||||
if (url.match(zabbixAPIUrlPattern)) {
|
||||
return url;
|
||||
} else {
|
||||
return url.replace(trimSlashPattern, "$1");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap function to prevent multiple calls
|
||||
* when waiting for result.
|
||||
*/
|
||||
|
||||
_export('convertToZabbixAPIUrl', convertToZabbixAPIUrl);
|
||||
|
||||
function callOnce(func, promiseKeeper) {
|
||||
return function () {
|
||||
if (!promiseKeeper) {
|
||||
promiseKeeper = Promise.resolve(func.apply(this, arguments).then(function (result) {
|
||||
promiseKeeper = null;
|
||||
return result;
|
||||
}));
|
||||
}
|
||||
return promiseKeeper;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Apply function one by one: `sequence([a(), b(), c()]) = c(b(a()))`
|
||||
* @param {*} funcsArray functions to apply
|
||||
*/
|
||||
|
||||
_export('callOnce', callOnce);
|
||||
|
||||
function sequence(funcsArray) {
|
||||
return function (result) {
|
||||
for (var i = 0; i < funcsArray.length; i++) {
|
||||
result = funcsArray[i].call(this, result);
|
||||
}
|
||||
return result;
|
||||
};
|
||||
}
|
||||
|
||||
// Fix for backward compatibility with lodash 2.4
|
||||
|
||||
_export('sequence', sequence);
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_moment) {
|
||||
moment = _moment.default;
|
||||
}],
|
||||
execute: function () {
|
||||
MACRO_PATTERN = /{\$[A-Z0-9_\.]+}/g;
|
||||
|
||||
_export('regexPattern', regexPattern = /^\/(.*)\/([gmi]*)$/m);
|
||||
|
||||
_export('regexPattern', regexPattern);
|
||||
|
||||
if (!_.includes) {
|
||||
_.includes = _.contains;
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=utils.js.map
|
||||
1
dist/datasource-zabbix/utils.js.map
vendored
@@ -1,116 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, _createClass, DBConnector, ZabbixNotImplemented;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
DBConnector = function () {
|
||||
function DBConnector(options, backendSrv, datasourceSrv) {
|
||||
_classCallCheck(this, DBConnector);
|
||||
|
||||
this.backendSrv = backendSrv;
|
||||
this.datasourceSrv = datasourceSrv;
|
||||
this.datasourceId = options.datasourceId;
|
||||
this.datasourceName = options.datasourceName;
|
||||
this.datasourceTypeId = null;
|
||||
this.datasourceTypeName = null;
|
||||
}
|
||||
|
||||
_createClass(DBConnector, [{
|
||||
key: 'loadDBDataSource',
|
||||
value: function loadDBDataSource() {
|
||||
var _this = this;
|
||||
|
||||
if (!this.datasourceName && this.datasourceId !== undefined) {
|
||||
var ds = _.find(this.datasourceSrv.getAll(), { 'id': this.datasourceId });
|
||||
if (!ds) {
|
||||
return Promise.reject('SQL Data Source with ID ' + this.datasourceId + ' not found');
|
||||
}
|
||||
this.datasourceName = ds.name;
|
||||
}
|
||||
if (this.datasourceName) {
|
||||
return this.datasourceSrv.loadDatasource(this.datasourceName).then(function (ds) {
|
||||
_this.datasourceTypeId = ds.meta.id;
|
||||
_this.datasourceTypeName = ds.meta.name;
|
||||
return ds;
|
||||
});
|
||||
} else {
|
||||
return Promise.reject('SQL Data Source name should be specified');
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'testDataSource',
|
||||
value: function testDataSource() {
|
||||
throw new ZabbixNotImplemented('testDataSource()');
|
||||
}
|
||||
}, {
|
||||
key: 'getHistory',
|
||||
value: function getHistory() {
|
||||
throw new ZabbixNotImplemented('getHistory()');
|
||||
}
|
||||
}, {
|
||||
key: 'getTrends',
|
||||
value: function getTrends() {
|
||||
throw new ZabbixNotImplemented('getTrends()');
|
||||
}
|
||||
}]);
|
||||
|
||||
return DBConnector;
|
||||
}();
|
||||
|
||||
_export('default', DBConnector);
|
||||
|
||||
_export('ZabbixNotImplemented', ZabbixNotImplemented = function () {
|
||||
function ZabbixNotImplemented(methodName) {
|
||||
_classCallCheck(this, ZabbixNotImplemented);
|
||||
|
||||
this.code = null;
|
||||
this.name = 'ZabbixNotImplemented';
|
||||
this.message = 'Zabbix DB Connector Error: method ' + (methodName || '') + ' should be implemented in subclass of DBConnector';
|
||||
}
|
||||
|
||||
_createClass(ZabbixNotImplemented, [{
|
||||
key: 'toString',
|
||||
value: function toString() {
|
||||
return this.message;
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixNotImplemented;
|
||||
}());
|
||||
|
||||
_export('ZabbixNotImplemented', ZabbixNotImplemented);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=dbConnector.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../../src/datasource-zabbix/zabbix/connectors/dbConnector.js"],"names":["_","DBConnector","options","backendSrv","datasourceSrv","datasourceId","datasourceName","datasourceTypeId","datasourceTypeName","undefined","ds","find","getAll","Promise","reject","name","loadDatasource","then","meta","id","ZabbixNotImplemented","methodName","code","message"],"mappings":";;;;;;;;;;;;;;;AAAOA,O;;;;;;;;;;;;;;;;;;;;;AAMcC,iB;AACnB,6BAAYC,OAAZ,EAAqBC,UAArB,EAAiCC,aAAjC,EAAgD;AAAA;;AAC9C,eAAKD,UAAL,GAAkBA,UAAlB;AACA,eAAKC,aAAL,GAAqBA,aAArB;AACA,eAAKC,YAAL,GAAoBH,QAAQG,YAA5B;AACA,eAAKC,cAAL,GAAsBJ,QAAQI,cAA9B;AACA,eAAKC,gBAAL,GAAwB,IAAxB;AACA,eAAKC,kBAAL,GAA0B,IAA1B;AACD;;;;6CAEkB;AAAA;;AACjB,gBAAI,CAAC,KAAKF,cAAN,IAAwB,KAAKD,YAAL,KAAsBI,SAAlD,EAA6D;AAC3D,kBAAIC,KAAKV,EAAEW,IAAF,CAAO,KAAKP,aAAL,CAAmBQ,MAAnB,EAAP,EAAoC,EAAC,MAAM,KAAKP,YAAZ,EAApC,CAAT;AACA,kBAAI,CAACK,EAAL,EAAS;AACP,uBAAOG,QAAQC,MAAR,8BAA0C,KAAKT,YAA/C,gBAAP;AACD;AACD,mBAAKC,cAAL,GAAsBI,GAAGK,IAAzB;AACD;AACD,gBAAI,KAAKT,cAAT,EAAyB;AACvB,qBAAO,KAAKF,aAAL,CAAmBY,cAAnB,CAAkC,KAAKV,cAAvC,EACNW,IADM,CACD,cAAM;AACV,sBAAKV,gBAAL,GAAwBG,GAAGQ,IAAH,CAAQC,EAAhC;AACA,sBAAKX,kBAAL,GAA0BE,GAAGQ,IAAH,CAAQH,IAAlC;AACA,uBAAOL,EAAP;AACD,eALM,CAAP;AAMD,aAPD,MAOO;AACL,qBAAOG,QAAQC,MAAR,4CAAP;AACD;AACF;;;2CAKgB;AACf,kBAAM,IAAIM,oBAAJ,CAAyB,kBAAzB,CAAN;AACD;;;uCAKY;AACX,kBAAM,IAAIA,oBAAJ,CAAyB,cAAzB,CAAN;AACD;;;sCAKW;AACV,kBAAM,IAAIA,oBAAJ,CAAyB,aAAzB,CAAN;AACD;;;;;;yBAjDkBnB,W;;sCAqDRmB,oB;AACX,sCAAYC,UAAZ,EAAwB;AAAA;;AACtB,eAAKC,IAAL,GAAY,IAAZ;AACA,eAAKP,IAAL,GAAY,sBAAZ;AACA,eAAKQ,OAAL,2CAAoDF,cAAc,EAAlE;AACD;;;;qCAEU;AACT,mBAAO,KAAKE,OAAZ;AACD","file":"dbConnector.js","sourcesContent":["import _ from 'lodash';\n\n/**\n * Base class for external history database connectors. Subclasses should implement `getHistory()`, `getTrends()` and\n * `testDataSource()` methods, which describe how to fetch data from source other than Zabbix API.\n */\nexport default class DBConnector {\n constructor(options, backendSrv, datasourceSrv) {\n this.backendSrv = backendSrv;\n this.datasourceSrv = datasourceSrv;\n this.datasourceId = options.datasourceId;\n this.datasourceName = options.datasourceName;\n this.datasourceTypeId = null;\n this.datasourceTypeName = null;\n }\n\n loadDBDataSource() {\n if (!this.datasourceName && this.datasourceId !== undefined) {\n let ds = _.find(this.datasourceSrv.getAll(), {'id': this.datasourceId});\n if (!ds) {\n return Promise.reject(`SQL Data Source with ID ${this.datasourceId} not found`);\n }\n this.datasourceName = ds.name;\n }\n if (this.datasourceName) {\n return this.datasourceSrv.loadDatasource(this.datasourceName)\n .then(ds => {\n this.datasourceTypeId = ds.meta.id;\n this.datasourceTypeName = ds.meta.name;\n return ds;\n });\n } else {\n return Promise.reject(`SQL Data Source name should be specified`);\n }\n }\n\n /**\n * Send test request to datasource in order to ensure it's working.\n */\n testDataSource() {\n throw new ZabbixNotImplemented('testDataSource()');\n }\n\n /**\n * Get history data from external sources.\n */\n getHistory() {\n throw new ZabbixNotImplemented('getHistory()');\n }\n\n /**\n * Get trends data from external sources.\n */\n getTrends() {\n throw new ZabbixNotImplemented('getTrends()');\n }\n}\n\n// Define Zabbix DB Connector exception type for non-implemented methods\nexport class ZabbixNotImplemented {\n constructor(methodName) {\n this.code = null;\n this.name = 'ZabbixNotImplemented';\n this.message = `Zabbix DB Connector Error: method ${methodName || ''} should be implemented in subclass of DBConnector`;\n }\n\n toString() {\n return this.message;\n }\n}\n"]}
|
||||
@@ -1,41 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var TEST_QUERY, mysql;
|
||||
/**
|
||||
* MySQL queries
|
||||
*/
|
||||
|
||||
function historyQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction) {
|
||||
var time_expression = "clock DIV " + intervalSec + " * " + intervalSec;
|
||||
var query = "\n SELECT CAST(itemid AS CHAR) AS metric, " + time_expression + " AS time_sec, " + aggFunction + "(value) AS value\n FROM " + table + "\n WHERE itemid IN (" + itemids + ")\n AND clock > " + timeFrom + " AND clock < " + timeTill + "\n GROUP BY " + time_expression + ", metric\n ORDER BY time_sec ASC\n ";
|
||||
return query;
|
||||
}
|
||||
|
||||
function trendsQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction, valueColumn) {
|
||||
var time_expression = "clock DIV " + intervalSec + " * " + intervalSec;
|
||||
var query = "\n SELECT CAST(itemid AS CHAR) AS metric, " + time_expression + " AS time_sec, " + aggFunction + "(" + valueColumn + ") AS value\n FROM " + table + "\n WHERE itemid IN (" + itemids + ")\n AND clock > " + timeFrom + " AND clock < " + timeTill + "\n GROUP BY " + time_expression + ", metric\n ORDER BY time_sec ASC\n ";
|
||||
return query;
|
||||
}
|
||||
|
||||
function testQuery() {
|
||||
return TEST_QUERY;
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
TEST_QUERY = "SELECT CAST(itemid AS CHAR) AS metric, clock AS time_sec, value_avg AS value FROM trends_uint LIMIT 1";
|
||||
mysql = {
|
||||
historyQuery: historyQuery,
|
||||
trendsQuery: trendsQuery,
|
||||
testQuery: testQuery
|
||||
};
|
||||
|
||||
_export("default", mysql);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=mysql.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../../../src/datasource-zabbix/zabbix/connectors/sql/mysql.js"],"names":["historyQuery","itemids","table","timeFrom","timeTill","intervalSec","aggFunction","time_expression","query","trendsQuery","valueColumn","testQuery","TEST_QUERY","mysql"],"mappings":";;;;;;AAAA;;;;AAIA,WAASA,YAAT,CAAsBC,OAAtB,EAA+BC,KAA/B,EAAsCC,QAAtC,EAAgDC,QAAhD,EAA0DC,WAA1D,EAAuEC,WAAvE,EAAoF;AAClF,QAAIC,iCAA+BF,WAA/B,WAAgDA,WAApD;AACA,QAAIG,0DACuCD,eADvC,sBACuED,WADvE,mCAEKJ,KAFL,+BAGiBD,OAHjB,6BAIcE,QAJd,qBAIsCC,QAJtC,uBAKSG,eALT,4CAAJ;AAQA,WAAOC,KAAP;AACD;;AAED,WAASC,WAAT,CAAqBR,OAArB,EAA8BC,KAA9B,EAAqCC,QAArC,EAA+CC,QAA/C,EAAyDC,WAAzD,EAAsEC,WAAtE,EAAmFI,WAAnF,EAAgG;AAC9F,QAAIH,iCAA+BF,WAA/B,WAAgDA,WAApD;AACA,QAAIG,0DACuCD,eADvC,sBACuED,WADvE,SACsFI,WADtF,6BAEKR,KAFL,+BAGiBD,OAHjB,6BAIcE,QAJd,qBAIsCC,QAJtC,uBAKSG,eALT,4CAAJ;AAQA,WAAOC,KAAP;AACD;;AAID,WAASG,SAAT,GAAqB;AACnB,WAAOC,UAAP;AACD;;;;;AAJKA,gB;AAMAC,W,GAAQ;AACZb,kCADY;AAEZS,gCAFY;AAGZE;AAHY,O;;yBAMCE,K","file":"mysql.js","sourcesContent":["/**\n * MySQL queries\n */\n\nfunction historyQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction) {\n let time_expression = `clock DIV ${intervalSec} * ${intervalSec}`;\n let query = `\n SELECT CAST(itemid AS CHAR) AS metric, ${time_expression} AS time_sec, ${aggFunction}(value) AS value\n FROM ${table}\n WHERE itemid IN (${itemids})\n AND clock > ${timeFrom} AND clock < ${timeTill}\n GROUP BY ${time_expression}, metric\n ORDER BY time_sec ASC\n `;\n return query;\n}\n\nfunction trendsQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction, valueColumn) {\n let time_expression = `clock DIV ${intervalSec} * ${intervalSec}`;\n let query = `\n SELECT CAST(itemid AS CHAR) AS metric, ${time_expression} AS time_sec, ${aggFunction}(${valueColumn}) AS value\n FROM ${table}\n WHERE itemid IN (${itemids})\n AND clock > ${timeFrom} AND clock < ${timeTill}\n GROUP BY ${time_expression}, metric\n ORDER BY time_sec ASC\n `;\n return query;\n}\n\nconst TEST_QUERY = `SELECT CAST(itemid AS CHAR) AS metric, clock AS time_sec, value_avg AS value FROM trends_uint LIMIT 1`;\n\nfunction testQuery() {\n return TEST_QUERY;\n}\n\nconst mysql = {\n historyQuery,\n trendsQuery,\n testQuery\n};\n\nexport default mysql;\n"]}
|
||||
@@ -1,40 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var ITEMID_FORMAT, TEST_QUERY, postgres;
|
||||
|
||||
|
||||
function historyQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction) {
|
||||
var time_expression = 'clock / ' + intervalSec + ' * ' + intervalSec;
|
||||
var query = '\n SELECT to_char(itemid, \'' + ITEMID_FORMAT + '\') AS metric, ' + time_expression + ' AS time, ' + aggFunction + '(value) AS value\n FROM ' + table + '\n WHERE itemid IN (' + itemids + ')\n AND clock > ' + timeFrom + ' AND clock < ' + timeTill + '\n GROUP BY 1, 2\n ORDER BY time ASC\n ';
|
||||
return query;
|
||||
}
|
||||
|
||||
function trendsQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction, valueColumn) {
|
||||
var time_expression = 'clock / ' + intervalSec + ' * ' + intervalSec;
|
||||
var query = '\n SELECT to_char(itemid, \'' + ITEMID_FORMAT + '\') AS metric, ' + time_expression + ' AS time, ' + aggFunction + '(' + valueColumn + ') AS value\n FROM ' + table + '\n WHERE itemid IN (' + itemids + ')\n AND clock > ' + timeFrom + ' AND clock < ' + timeTill + '\n GROUP BY 1, 2\n ORDER BY time ASC\n ';
|
||||
return query;
|
||||
}
|
||||
|
||||
function testQuery() {
|
||||
return TEST_QUERY;
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
ITEMID_FORMAT = 'FM99999999999999999999';
|
||||
TEST_QUERY = '\n SELECT to_char(itemid, \'' + ITEMID_FORMAT + '\') AS metric, clock AS time, value_avg AS value\n FROM trends_uint LIMIT 1\n';
|
||||
postgres = {
|
||||
historyQuery: historyQuery,
|
||||
trendsQuery: trendsQuery,
|
||||
testQuery: testQuery
|
||||
};
|
||||
|
||||
_export('default', postgres);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=postgres.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../../../src/datasource-zabbix/zabbix/connectors/sql/postgres.js"],"names":["historyQuery","itemids","table","timeFrom","timeTill","intervalSec","aggFunction","time_expression","query","ITEMID_FORMAT","trendsQuery","valueColumn","testQuery","TEST_QUERY","postgres"],"mappings":";;;;;;;;AAMA,WAASA,YAAT,CAAsBC,OAAtB,EAA+BC,KAA/B,EAAsCC,QAAtC,EAAgDC,QAAhD,EAA0DC,WAA1D,EAAuEC,WAAvE,EAAoF;AAClF,QAAIC,+BAA6BF,WAA7B,WAA8CA,WAAlD;AACA,QAAIG,4CACwBC,aADxB,uBACsDF,eADtD,kBACkFD,WADlF,mCAEKJ,KAFL,+BAGiBD,OAHjB,6BAIcE,QAJd,qBAIsCC,QAJtC,mDAAJ;AAQA,WAAOI,KAAP;AACD;;AAED,WAASE,WAAT,CAAqBT,OAArB,EAA8BC,KAA9B,EAAqCC,QAArC,EAA+CC,QAA/C,EAAyDC,WAAzD,EAAsEC,WAAtE,EAAmFK,WAAnF,EAAgG;AAC9F,QAAIJ,+BAA6BF,WAA7B,WAA8CA,WAAlD;AACA,QAAIG,4CACwBC,aADxB,uBACsDF,eADtD,kBACkFD,WADlF,SACiGK,WADjG,6BAEKT,KAFL,+BAGiBD,OAHjB,6BAIcE,QAJd,qBAIsCC,QAJtC,mDAAJ;AAQA,WAAOI,KAAP;AACD;;AAOD,WAASI,SAAT,GAAqB;AACnB,WAAOC,UAAP;AACD;;;;;AAnCKJ,mB,GAAgB,wB;AA4BhBI,gB,qCACsBJ,a;AAQtBK,c,GAAW;AACfd,kCADe;AAEfU,gCAFe;AAGfE;AAHe,O;;yBAMFE,Q","file":"postgres.js","sourcesContent":["/**\n * Postgres queries\n */\n\nconst ITEMID_FORMAT = 'FM99999999999999999999';\n\nfunction historyQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction) {\n let time_expression = `clock / ${intervalSec} * ${intervalSec}`;\n let query = `\n SELECT to_char(itemid, '${ITEMID_FORMAT}') AS metric, ${time_expression} AS time, ${aggFunction}(value) AS value\n FROM ${table}\n WHERE itemid IN (${itemids})\n AND clock > ${timeFrom} AND clock < ${timeTill}\n GROUP BY 1, 2\n ORDER BY time ASC\n `;\n return query;\n}\n\nfunction trendsQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction, valueColumn) {\n let time_expression = `clock / ${intervalSec} * ${intervalSec}`;\n let query = `\n SELECT to_char(itemid, '${ITEMID_FORMAT}') AS metric, ${time_expression} AS time, ${aggFunction}(${valueColumn}) AS value\n FROM ${table}\n WHERE itemid IN (${itemids})\n AND clock > ${timeFrom} AND clock < ${timeTill}\n GROUP BY 1, 2\n ORDER BY time ASC\n `;\n return query;\n}\n\nconst TEST_QUERY = `\n SELECT to_char(itemid, '${ITEMID_FORMAT}') AS metric, clock AS time, value_avg AS value\n FROM trends_uint LIMIT 1\n`;\n\nfunction testQuery() {\n return TEST_QUERY;\n}\n\nconst postgres = {\n historyQuery,\n trendsQuery,\n testQuery\n};\n\nexport default postgres;\n"]}
|
||||
@@ -1,282 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', './mysql', './postgres', '../dbConnector'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, mysql, postgres, DBConnector, _createClass, _get, supportedDatabases, DEFAULT_QUERY_LIMIT, HISTORY_TO_TABLE_MAP, TREND_TO_TABLE_MAP, consolidateByFunc, consolidateByTrendColumns, SQLConnector;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
function _possibleConstructorReturn(self, call) {
|
||||
if (!self) {
|
||||
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
|
||||
}
|
||||
|
||||
return call && (typeof call === "object" || typeof call === "function") ? call : self;
|
||||
}
|
||||
|
||||
function _inherits(subClass, superClass) {
|
||||
if (typeof superClass !== "function" && superClass !== null) {
|
||||
throw new TypeError("Super expression must either be null or a function, not " + typeof superClass);
|
||||
}
|
||||
|
||||
subClass.prototype = Object.create(superClass && superClass.prototype, {
|
||||
constructor: {
|
||||
value: subClass,
|
||||
enumerable: false,
|
||||
writable: true,
|
||||
configurable: true
|
||||
}
|
||||
});
|
||||
if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
function convertGrafanaTSResponse(time_series, items, addHostName) {
|
||||
//uniqBy is needed to deduplicate
|
||||
var hosts = _.uniqBy(_.flatten(_.map(items, 'hosts')), 'hostid');
|
||||
var grafanaSeries = _.map(time_series, function (series) {
|
||||
var itemid = series.name;
|
||||
var item = _.find(items, { 'itemid': itemid });
|
||||
var alias = item.name;
|
||||
//only when actual multi hosts selected
|
||||
if (_.keys(hosts).length > 1 && addHostName) {
|
||||
var host = _.find(hosts, { 'hostid': item.hostid });
|
||||
alias = host.name + ": " + alias;
|
||||
}
|
||||
// CachingProxy deduplicates requests and returns one time series for equal queries.
|
||||
// Clone is needed to prevent changing of series object shared between all targets.
|
||||
var datapoints = _.cloneDeep(series.points);
|
||||
return {
|
||||
target: alias,
|
||||
datapoints: datapoints
|
||||
};
|
||||
});
|
||||
|
||||
return _.sortBy(grafanaSeries, 'target');
|
||||
}
|
||||
|
||||
function compactSQLQuery(query) {
|
||||
return query.replace(/\s+/g, ' ');
|
||||
}
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_mysql) {
|
||||
mysql = _mysql.default;
|
||||
}, function (_postgres) {
|
||||
postgres = _postgres.default;
|
||||
}, function (_dbConnector) {
|
||||
DBConnector = _dbConnector.default;
|
||||
}],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
_get = function get(object, property, receiver) {
|
||||
if (object === null) object = Function.prototype;
|
||||
var desc = Object.getOwnPropertyDescriptor(object, property);
|
||||
|
||||
if (desc === undefined) {
|
||||
var parent = Object.getPrototypeOf(object);
|
||||
|
||||
if (parent === null) {
|
||||
return undefined;
|
||||
} else {
|
||||
return get(parent, property, receiver);
|
||||
}
|
||||
} else if ("value" in desc) {
|
||||
return desc.value;
|
||||
} else {
|
||||
var getter = desc.get;
|
||||
|
||||
if (getter === undefined) {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
return getter.call(receiver);
|
||||
}
|
||||
};
|
||||
|
||||
supportedDatabases = {
|
||||
mysql: 'mysql',
|
||||
postgres: 'postgres'
|
||||
};
|
||||
DEFAULT_QUERY_LIMIT = 10000;
|
||||
HISTORY_TO_TABLE_MAP = {
|
||||
'0': 'history',
|
||||
'1': 'history_str',
|
||||
'2': 'history_log',
|
||||
'3': 'history_uint',
|
||||
'4': 'history_text'
|
||||
};
|
||||
TREND_TO_TABLE_MAP = {
|
||||
'0': 'trends',
|
||||
'3': 'trends_uint'
|
||||
};
|
||||
consolidateByFunc = {
|
||||
'avg': 'AVG',
|
||||
'min': 'MIN',
|
||||
'max': 'MAX',
|
||||
'sum': 'SUM',
|
||||
'count': 'COUNT'
|
||||
};
|
||||
consolidateByTrendColumns = {
|
||||
'avg': 'value_avg',
|
||||
'min': 'value_min',
|
||||
'max': 'value_max'
|
||||
};
|
||||
|
||||
_export('SQLConnector', SQLConnector = function (_DBConnector) {
|
||||
_inherits(SQLConnector, _DBConnector);
|
||||
|
||||
function SQLConnector(options, backendSrv, datasourceSrv) {
|
||||
_classCallCheck(this, SQLConnector);
|
||||
|
||||
var _this = _possibleConstructorReturn(this, (SQLConnector.__proto__ || Object.getPrototypeOf(SQLConnector)).call(this, options, backendSrv, datasourceSrv));
|
||||
|
||||
_this.limit = options.limit || DEFAULT_QUERY_LIMIT;
|
||||
_this.sqlDialect = null;
|
||||
|
||||
_get(SQLConnector.prototype.__proto__ || Object.getPrototypeOf(SQLConnector.prototype), 'loadDBDataSource', _this).call(_this).then(function () {
|
||||
return _this.loadSQLDialect();
|
||||
});
|
||||
return _this;
|
||||
}
|
||||
|
||||
_createClass(SQLConnector, [{
|
||||
key: 'loadSQLDialect',
|
||||
value: function loadSQLDialect() {
|
||||
if (this.datasourceTypeId === supportedDatabases.postgres) {
|
||||
this.sqlDialect = postgres;
|
||||
} else {
|
||||
this.sqlDialect = mysql;
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'testDataSource',
|
||||
value: function testDataSource() {
|
||||
var testQuery = this.sqlDialect.testQuery();
|
||||
return this.invokeSQLQuery(testQuery);
|
||||
}
|
||||
}, {
|
||||
key: 'getHistory',
|
||||
value: function getHistory(items, timeFrom, timeTill, options) {
|
||||
var _this2 = this;
|
||||
|
||||
var intervalMs = options.intervalMs,
|
||||
consolidateBy = options.consolidateBy;
|
||||
|
||||
var intervalSec = Math.ceil(intervalMs / 1000);
|
||||
|
||||
consolidateBy = consolidateBy || 'avg';
|
||||
var aggFunction = consolidateByFunc[consolidateBy];
|
||||
|
||||
// Group items by value type and perform request for each value type
|
||||
var grouped_items = _.groupBy(items, 'value_type');
|
||||
var promises = _.map(grouped_items, function (items, value_type) {
|
||||
var itemids = _.map(items, 'itemid').join(', ');
|
||||
var table = HISTORY_TO_TABLE_MAP[value_type];
|
||||
var query = _this2.sqlDialect.historyQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction);
|
||||
|
||||
query = compactSQLQuery(query);
|
||||
return _this2.invokeSQLQuery(query);
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(function (results) {
|
||||
return _.flatten(results);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getTrends',
|
||||
value: function getTrends(items, timeFrom, timeTill, options) {
|
||||
var _this3 = this;
|
||||
|
||||
var intervalMs = options.intervalMs,
|
||||
consolidateBy = options.consolidateBy;
|
||||
|
||||
var intervalSec = Math.ceil(intervalMs / 1000);
|
||||
|
||||
consolidateBy = consolidateBy || 'avg';
|
||||
var aggFunction = consolidateByFunc[consolidateBy];
|
||||
|
||||
// Group items by value type and perform request for each value type
|
||||
var grouped_items = _.groupBy(items, 'value_type');
|
||||
var promises = _.map(grouped_items, function (items, value_type) {
|
||||
var itemids = _.map(items, 'itemid').join(', ');
|
||||
var table = TREND_TO_TABLE_MAP[value_type];
|
||||
var valueColumn = _.includes(['avg', 'min', 'max'], consolidateBy) ? consolidateBy : 'avg';
|
||||
valueColumn = consolidateByTrendColumns[valueColumn];
|
||||
var query = _this3.sqlDialect.trendsQuery(itemids, table, timeFrom, timeTill, intervalSec, aggFunction, valueColumn);
|
||||
|
||||
query = compactSQLQuery(query);
|
||||
return _this3.invokeSQLQuery(query);
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(function (results) {
|
||||
return _.flatten(results);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'handleGrafanaTSResponse',
|
||||
value: function handleGrafanaTSResponse(history, items) {
|
||||
var addHostName = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : true;
|
||||
|
||||
return convertGrafanaTSResponse(history, items, addHostName);
|
||||
}
|
||||
}, {
|
||||
key: 'invokeSQLQuery',
|
||||
value: function invokeSQLQuery(query) {
|
||||
var queryDef = {
|
||||
refId: 'A',
|
||||
format: 'time_series',
|
||||
datasourceId: this.datasourceId,
|
||||
rawSql: query,
|
||||
maxDataPoints: this.limit
|
||||
};
|
||||
|
||||
return this.backendSrv.datasourceRequest({
|
||||
url: '/api/tsdb/query',
|
||||
method: 'POST',
|
||||
data: {
|
||||
queries: [queryDef]
|
||||
}
|
||||
}).then(function (response) {
|
||||
var results = response.data.results;
|
||||
if (results['A']) {
|
||||
return results['A'].series;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return SQLConnector;
|
||||
}(DBConnector));
|
||||
|
||||
_export('SQLConnector', SQLConnector);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=sqlConnector.js.map
|
||||
@@ -1,545 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', '../../../utils', './zabbixAPICore'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, utils, ZabbixAPICore, _slicedToArray, _createClass, ZabbixAPIConnector;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
function filterTriggersByAcknowledge(triggers, acknowledged) {
|
||||
if (acknowledged === 0) {
|
||||
return _.filter(triggers, function (trigger) {
|
||||
return trigger.lastEvent.acknowledged === "0";
|
||||
});
|
||||
} else if (acknowledged === 1) {
|
||||
return _.filter(triggers, function (trigger) {
|
||||
return trigger.lastEvent.acknowledged === "1";
|
||||
});
|
||||
} else {
|
||||
return triggers;
|
||||
}
|
||||
}
|
||||
|
||||
function isNotAuthorized(message) {
|
||||
return message === "Session terminated, re-login, please." || message === "Not authorised." || message === "Not authorized.";
|
||||
}
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_utils) {
|
||||
utils = _utils;
|
||||
}, function (_zabbixAPICore) {
|
||||
ZabbixAPICore = _zabbixAPICore.ZabbixAPICore;
|
||||
}],
|
||||
execute: function () {
|
||||
_slicedToArray = function () {
|
||||
function sliceIterator(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"]) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
return function (arr, i) {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr;
|
||||
} else if (Symbol.iterator in Object(arr)) {
|
||||
return sliceIterator(arr, i);
|
||||
} else {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
_export('ZabbixAPIConnector', ZabbixAPIConnector = function () {
|
||||
function ZabbixAPIConnector(api_url, username, password, basicAuth, withCredentials, backendSrv) {
|
||||
_classCallCheck(this, ZabbixAPIConnector);
|
||||
|
||||
this.url = api_url;
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.auth = "";
|
||||
|
||||
this.requestOptions = {
|
||||
basicAuth: basicAuth,
|
||||
withCredentials: withCredentials
|
||||
};
|
||||
|
||||
this.loginPromise = null;
|
||||
this.loginErrorCount = 0;
|
||||
this.maxLoginAttempts = 3;
|
||||
|
||||
this.zabbixAPICore = new ZabbixAPICore(backendSrv);
|
||||
|
||||
this.getTrend = this.getTrend_ZBXNEXT1193;
|
||||
//getTrend = getTrend_30;
|
||||
}
|
||||
|
||||
//////////////////////////
|
||||
// Core method wrappers //
|
||||
//////////////////////////
|
||||
|
||||
_createClass(ZabbixAPIConnector, [{
|
||||
key: 'request',
|
||||
value: function request(method, params) {
|
||||
var _this = this;
|
||||
|
||||
return this.zabbixAPICore.request(this.url, method, params, this.requestOptions, this.auth).catch(function (error) {
|
||||
if (isNotAuthorized(error.data)) {
|
||||
// Handle auth errors
|
||||
_this.loginErrorCount++;
|
||||
if (_this.loginErrorCount > _this.maxLoginAttempts) {
|
||||
_this.loginErrorCount = 0;
|
||||
return null;
|
||||
} else {
|
||||
return _this.loginOnce().then(function () {
|
||||
return _this.request(method, params);
|
||||
});
|
||||
}
|
||||
} else {
|
||||
// Handle API errors
|
||||
var message = error.data ? error.data : error.statusText;
|
||||
return Promise.reject(message);
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'loginOnce',
|
||||
value: function loginOnce() {
|
||||
var _this2 = this;
|
||||
|
||||
if (!this.loginPromise) {
|
||||
this.loginPromise = Promise.resolve(this.login().then(function (auth) {
|
||||
_this2.auth = auth;
|
||||
_this2.loginPromise = null;
|
||||
return auth;
|
||||
}));
|
||||
}
|
||||
return this.loginPromise;
|
||||
}
|
||||
}, {
|
||||
key: 'login',
|
||||
value: function login() {
|
||||
return this.zabbixAPICore.login(this.url, this.username, this.password, this.requestOptions);
|
||||
}
|
||||
}, {
|
||||
key: 'getVersion',
|
||||
value: function getVersion() {
|
||||
return this.zabbixAPICore.getVersion(this.url, this.requestOptions);
|
||||
}
|
||||
}, {
|
||||
key: 'acknowledgeEvent',
|
||||
value: function acknowledgeEvent(eventid, message) {
|
||||
var params = {
|
||||
eventids: eventid,
|
||||
message: message
|
||||
};
|
||||
|
||||
return this.request('event.acknowledge', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getGroups',
|
||||
value: function getGroups() {
|
||||
var params = {
|
||||
output: ['name'],
|
||||
sortfield: 'name',
|
||||
real_hosts: true
|
||||
};
|
||||
|
||||
return this.request('hostgroup.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getHosts',
|
||||
value: function getHosts(groupids) {
|
||||
var params = {
|
||||
output: ['name', 'host'],
|
||||
sortfield: 'name'
|
||||
};
|
||||
if (groupids) {
|
||||
params.groupids = groupids;
|
||||
}
|
||||
|
||||
return this.request('host.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getApps',
|
||||
value: function getApps(hostids) {
|
||||
var params = {
|
||||
output: 'extend',
|
||||
hostids: hostids
|
||||
};
|
||||
|
||||
return this.request('application.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getItems',
|
||||
value: function getItems(hostids, appids, itemtype) {
|
||||
var params = {
|
||||
output: ['name', 'key_', 'value_type', 'hostid', 'status', 'state'],
|
||||
sortfield: 'name',
|
||||
webitems: true,
|
||||
filter: {},
|
||||
selectHosts: ['hostid', 'name']
|
||||
};
|
||||
if (hostids) {
|
||||
params.hostids = hostids;
|
||||
}
|
||||
if (appids) {
|
||||
params.applicationids = appids;
|
||||
}
|
||||
if (itemtype === 'num') {
|
||||
// Return only numeric metrics
|
||||
params.filter.value_type = [0, 3];
|
||||
}
|
||||
if (itemtype === 'text') {
|
||||
// Return only text metrics
|
||||
params.filter.value_type = [1, 2, 4];
|
||||
}
|
||||
|
||||
return this.request('item.get', params).then(utils.expandItems);
|
||||
}
|
||||
}, {
|
||||
key: 'getItemsByIDs',
|
||||
value: function getItemsByIDs(itemids) {
|
||||
var params = {
|
||||
itemids: itemids,
|
||||
output: ['name', 'key_', 'value_type', 'hostid', 'status', 'state'],
|
||||
webitems: true,
|
||||
selectHosts: ['hostid', 'name']
|
||||
};
|
||||
|
||||
return this.request('item.get', params).then(utils.expandItems);
|
||||
}
|
||||
}, {
|
||||
key: 'getMacros',
|
||||
value: function getMacros(hostids) {
|
||||
var params = {
|
||||
output: 'extend',
|
||||
hostids: hostids
|
||||
};
|
||||
|
||||
return this.request('usermacro.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getGlobalMacros',
|
||||
value: function getGlobalMacros() {
|
||||
var params = {
|
||||
output: 'extend',
|
||||
globalmacro: true
|
||||
};
|
||||
|
||||
return this.request('usermacro.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getLastValue',
|
||||
value: function getLastValue(itemid) {
|
||||
var params = {
|
||||
output: ['lastvalue'],
|
||||
itemids: itemid
|
||||
};
|
||||
return this.request('item.get', params).then(function (items) {
|
||||
return items.length ? items[0].lastvalue : null;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getHistory',
|
||||
value: function getHistory(items, timeFrom, timeTill) {
|
||||
var _this3 = this;
|
||||
|
||||
// Group items by value type and perform request for each value type
|
||||
var grouped_items = _.groupBy(items, 'value_type');
|
||||
var promises = _.map(grouped_items, function (items, value_type) {
|
||||
var itemids = _.map(items, 'itemid');
|
||||
var params = {
|
||||
output: 'extend',
|
||||
history: value_type,
|
||||
itemids: itemids,
|
||||
sortfield: 'clock',
|
||||
sortorder: 'ASC',
|
||||
time_from: timeFrom
|
||||
};
|
||||
|
||||
// Relative queries (e.g. last hour) don't include an end time
|
||||
if (timeTill) {
|
||||
params.time_till = timeTill;
|
||||
}
|
||||
|
||||
return _this3.request('history.get', params);
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(_.flatten);
|
||||
}
|
||||
}, {
|
||||
key: 'getTrend_ZBXNEXT1193',
|
||||
value: function getTrend_ZBXNEXT1193(items, timeFrom, timeTill) {
|
||||
var _this4 = this;
|
||||
|
||||
// Group items by value type and perform request for each value type
|
||||
var grouped_items = _.groupBy(items, 'value_type');
|
||||
var promises = _.map(grouped_items, function (items, value_type) {
|
||||
var itemids = _.map(items, 'itemid');
|
||||
var params = {
|
||||
output: 'extend',
|
||||
trend: value_type,
|
||||
itemids: itemids,
|
||||
sortfield: 'clock',
|
||||
sortorder: 'ASC',
|
||||
time_from: timeFrom
|
||||
};
|
||||
|
||||
// Relative queries (e.g. last hour) don't include an end time
|
||||
if (timeTill) {
|
||||
params.time_till = timeTill;
|
||||
}
|
||||
|
||||
return _this4.request('trend.get', params);
|
||||
});
|
||||
|
||||
return Promise.all(promises).then(_.flatten);
|
||||
}
|
||||
}, {
|
||||
key: 'getTrend_30',
|
||||
value: function getTrend_30(items, time_from, time_till, value_type) {
|
||||
var self = this;
|
||||
var itemids = _.map(items, 'itemid');
|
||||
|
||||
var params = {
|
||||
output: ["itemid", "clock", value_type],
|
||||
itemids: itemids,
|
||||
time_from: time_from
|
||||
};
|
||||
|
||||
// Relative queries (e.g. last hour) don't include an end time
|
||||
if (time_till) {
|
||||
params.time_till = time_till;
|
||||
}
|
||||
|
||||
return self.request('trend.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getITService',
|
||||
value: function getITService(serviceids) {
|
||||
var params = {
|
||||
output: 'extend',
|
||||
serviceids: serviceids
|
||||
};
|
||||
return this.request('service.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getSLA',
|
||||
value: function getSLA(serviceids, timeRange) {
|
||||
var _timeRange = _slicedToArray(timeRange, 2),
|
||||
timeFrom = _timeRange[0],
|
||||
timeTo = _timeRange[1];
|
||||
|
||||
var params = {
|
||||
serviceids: serviceids,
|
||||
intervals: [{
|
||||
from: timeFrom,
|
||||
to: timeTo
|
||||
}]
|
||||
};
|
||||
return this.request('service.getsla', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getTriggers',
|
||||
value: function getTriggers(groupids, hostids, applicationids, options) {
|
||||
var showTriggers = options.showTriggers,
|
||||
maintenance = options.maintenance,
|
||||
timeFrom = options.timeFrom,
|
||||
timeTo = options.timeTo;
|
||||
|
||||
|
||||
var params = {
|
||||
output: 'extend',
|
||||
groupids: groupids,
|
||||
hostids: hostids,
|
||||
applicationids: applicationids,
|
||||
expandDescription: true,
|
||||
expandData: true,
|
||||
expandComment: true,
|
||||
monitored: true,
|
||||
skipDependent: true,
|
||||
//only_true: true,
|
||||
filter: {
|
||||
value: 1
|
||||
},
|
||||
selectGroups: ['name'],
|
||||
selectHosts: ['name', 'host', 'maintenance_status'],
|
||||
selectItems: ['name', 'key_', 'lastvalue'],
|
||||
selectLastEvent: 'extend',
|
||||
selectTags: 'extend'
|
||||
};
|
||||
|
||||
if (showTriggers) {
|
||||
params.filter.value = showTriggers;
|
||||
}
|
||||
|
||||
if (maintenance) {
|
||||
params.maintenance = true;
|
||||
}
|
||||
|
||||
if (timeFrom || timeTo) {
|
||||
params.lastChangeSince = timeFrom;
|
||||
params.lastChangeTill = timeTo;
|
||||
}
|
||||
|
||||
return this.request('trigger.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getEvents',
|
||||
value: function getEvents(objectids, timeFrom, timeTo, showEvents) {
|
||||
var params = {
|
||||
output: 'extend',
|
||||
time_from: timeFrom,
|
||||
time_till: timeTo,
|
||||
objectids: objectids,
|
||||
select_acknowledges: 'extend',
|
||||
selectHosts: 'extend',
|
||||
value: showEvents
|
||||
};
|
||||
|
||||
return this.request('event.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getAcknowledges',
|
||||
value: function getAcknowledges(eventids) {
|
||||
var params = {
|
||||
output: 'extend',
|
||||
eventids: eventids,
|
||||
preservekeys: true,
|
||||
select_acknowledges: 'extend',
|
||||
sortfield: 'clock',
|
||||
sortorder: 'DESC'
|
||||
};
|
||||
|
||||
return this.request('event.get', params).then(function (events) {
|
||||
return _.filter(events, function (event) {
|
||||
return event.acknowledges.length;
|
||||
});
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getAlerts',
|
||||
value: function getAlerts(itemids, timeFrom, timeTo) {
|
||||
var params = {
|
||||
output: 'extend',
|
||||
itemids: itemids,
|
||||
expandDescription: true,
|
||||
expandData: true,
|
||||
expandComment: true,
|
||||
monitored: true,
|
||||
skipDependent: true,
|
||||
//only_true: true,
|
||||
// filter: {
|
||||
// value: 1
|
||||
// },
|
||||
selectLastEvent: 'extend'
|
||||
};
|
||||
|
||||
if (timeFrom || timeTo) {
|
||||
params.lastChangeSince = timeFrom;
|
||||
params.lastChangeTill = timeTo;
|
||||
}
|
||||
|
||||
return this.request('trigger.get', params);
|
||||
}
|
||||
}, {
|
||||
key: 'getHostAlerts',
|
||||
value: function getHostAlerts(hostids, applicationids, options) {
|
||||
var minSeverity = options.minSeverity,
|
||||
acknowledged = options.acknowledged,
|
||||
count = options.count,
|
||||
timeFrom = options.timeFrom,
|
||||
timeTo = options.timeTo;
|
||||
|
||||
var params = {
|
||||
output: 'extend',
|
||||
hostids: hostids,
|
||||
min_severity: minSeverity,
|
||||
filter: { value: 1 },
|
||||
expandDescription: true,
|
||||
expandData: true,
|
||||
expandComment: true,
|
||||
monitored: true,
|
||||
skipDependent: true,
|
||||
selectLastEvent: 'extend',
|
||||
selectGroups: 'extend',
|
||||
selectHosts: ['host', 'name']
|
||||
};
|
||||
|
||||
if (count && acknowledged !== 0 && acknowledged !== 1) {
|
||||
params.countOutput = true;
|
||||
}
|
||||
|
||||
if (applicationids && applicationids.length) {
|
||||
params.applicationids = applicationids;
|
||||
}
|
||||
|
||||
if (timeFrom || timeTo) {
|
||||
params.lastChangeSince = timeFrom;
|
||||
params.lastChangeTill = timeTo;
|
||||
}
|
||||
|
||||
return this.request('trigger.get', params).then(function (triggers) {
|
||||
if (!count || acknowledged === 0 || acknowledged === 1) {
|
||||
triggers = filterTriggersByAcknowledge(triggers, acknowledged);
|
||||
if (count) {
|
||||
triggers = triggers.length;
|
||||
}
|
||||
}
|
||||
return triggers;
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixAPIConnector;
|
||||
}());
|
||||
|
||||
_export('ZabbixAPIConnector', ZabbixAPIConnector);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=zabbixAPIConnector.js.map
|
||||
@@ -1,148 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _createClass, ZabbixAPICore, ZabbixAPIError;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
_export("ZabbixAPICore", ZabbixAPICore = function () {
|
||||
|
||||
/** @ngInject */
|
||||
function ZabbixAPICore(backendSrv) {
|
||||
_classCallCheck(this, ZabbixAPICore);
|
||||
|
||||
this.backendSrv = backendSrv;
|
||||
}
|
||||
|
||||
/**
|
||||
* Request data from Zabbix API
|
||||
* @return {object} response.result
|
||||
*/
|
||||
|
||||
|
||||
_createClass(ZabbixAPICore, [{
|
||||
key: "request",
|
||||
value: function request(api_url, method, params, options, auth) {
|
||||
var requestData = {
|
||||
jsonrpc: '2.0',
|
||||
method: method,
|
||||
params: params,
|
||||
id: 1
|
||||
};
|
||||
|
||||
if (auth === "") {
|
||||
// Reject immediately if not authenticated
|
||||
return Promise.reject(new ZabbixAPIError({ data: "Not authorised." }));
|
||||
} else if (auth) {
|
||||
// Set auth parameter only if it needed
|
||||
requestData.auth = auth;
|
||||
}
|
||||
|
||||
var requestOptions = {
|
||||
method: 'POST',
|
||||
url: api_url,
|
||||
data: requestData,
|
||||
headers: {
|
||||
'Content-Type': 'application/json'
|
||||
}
|
||||
};
|
||||
|
||||
// Set request options for basic auth
|
||||
if (options.basicAuth || options.withCredentials) {
|
||||
requestOptions.withCredentials = true;
|
||||
}
|
||||
if (options.basicAuth) {
|
||||
requestOptions.headers.Authorization = options.basicAuth;
|
||||
}
|
||||
|
||||
return this.datasourceRequest(requestOptions);
|
||||
}
|
||||
}, {
|
||||
key: "datasourceRequest",
|
||||
value: function datasourceRequest(requestOptions) {
|
||||
return this.backendSrv.datasourceRequest(requestOptions).then(function (response) {
|
||||
if (!response.data) {
|
||||
return Promise.reject(new ZabbixAPIError({ data: "General Error, no data" }));
|
||||
} else if (response.data.error) {
|
||||
|
||||
// Handle Zabbix API errors
|
||||
return Promise.reject(new ZabbixAPIError(response.data.error));
|
||||
}
|
||||
|
||||
// Success
|
||||
return response.data.result;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: "login",
|
||||
value: function login(api_url, username, password, options) {
|
||||
var params = {
|
||||
user: username,
|
||||
password: password
|
||||
};
|
||||
return this.request(api_url, 'user.login', params, options, null);
|
||||
}
|
||||
}, {
|
||||
key: "getVersion",
|
||||
value: function getVersion(api_url, options) {
|
||||
return this.request(api_url, 'apiinfo.version', [], options);
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixAPICore;
|
||||
}());
|
||||
|
||||
_export("ZabbixAPICore", ZabbixAPICore);
|
||||
|
||||
_export("ZabbixAPIError", ZabbixAPIError = function () {
|
||||
function ZabbixAPIError(error) {
|
||||
_classCallCheck(this, ZabbixAPIError);
|
||||
|
||||
this.code = error.code || null;
|
||||
this.name = error.message || "";
|
||||
this.data = error.data || "";
|
||||
this.message = "Zabbix API Error: " + this.name + " " + this.data;
|
||||
}
|
||||
|
||||
_createClass(ZabbixAPIError, [{
|
||||
key: "toString",
|
||||
value: function toString() {
|
||||
return this.name + " " + this.data;
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixAPIError;
|
||||
}());
|
||||
|
||||
_export("ZabbixAPIError", ZabbixAPIError);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=zabbixAPICore.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../../../../src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPICore.js"],"names":["ZabbixAPICore","backendSrv","api_url","method","params","options","auth","requestData","jsonrpc","id","Promise","reject","ZabbixAPIError","data","requestOptions","url","headers","basicAuth","withCredentials","Authorization","datasourceRequest","then","response","error","result","username","password","user","request","code","name","message"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;+BAIaA,a;;AAEX;AACA,+BAAYC,UAAZ,EAAwB;AAAA;;AACtB,eAAKA,UAAL,GAAkBA,UAAlB;AACD;;AAED;;;;;;;;kCAIQC,O,EAASC,M,EAAQC,M,EAAQC,O,EAASC,I,EAAM;AAC9C,gBAAIC,cAAc;AAChBC,uBAAS,KADO;AAEhBL,sBAAQA,MAFQ;AAGhBC,sBAAQA,MAHQ;AAIhBK,kBAAI;AAJY,aAAlB;;AAOA,gBAAIH,SAAS,EAAb,EAAiB;AACf;AACA,qBAAOI,QAAQC,MAAR,CAAe,IAAIC,cAAJ,CAAmB,EAACC,MAAM,iBAAP,EAAnB,CAAf,CAAP;AACD,aAHD,MAGO,IAAIP,IAAJ,EAAU;AACf;AACAC,0BAAYD,IAAZ,GAAmBA,IAAnB;AACD;;AAED,gBAAIQ,iBAAiB;AACnBX,sBAAQ,MADW;AAEnBY,mBAAKb,OAFc;AAGnBW,oBAAMN,WAHa;AAInBS,uBAAS;AACP,gCAAgB;AADT;AAJU,aAArB;;AASA;AACA,gBAAIX,QAAQY,SAAR,IAAqBZ,QAAQa,eAAjC,EAAkD;AAChDJ,6BAAeI,eAAf,GAAiC,IAAjC;AACD;AACD,gBAAIb,QAAQY,SAAZ,EAAuB;AACrBH,6BAAeE,OAAf,CAAuBG,aAAvB,GAAuCd,QAAQY,SAA/C;AACD;;AAED,mBAAO,KAAKG,iBAAL,CAAuBN,cAAvB,CAAP;AACD;;;4CAEiBA,c,EAAgB;AAChC,mBAAO,KAAKb,UAAL,CAAgBmB,iBAAhB,CAAkCN,cAAlC,EACNO,IADM,CACD,UAACC,QAAD,EAAc;AAClB,kBAAI,CAACA,SAAST,IAAd,EAAoB;AAClB,uBAAOH,QAAQC,MAAR,CAAe,IAAIC,cAAJ,CAAmB,EAACC,MAAM,wBAAP,EAAnB,CAAf,CAAP;AACD,eAFD,MAEO,IAAIS,SAAST,IAAT,CAAcU,KAAlB,EAAyB;;AAE9B;AACA,uBAAOb,QAAQC,MAAR,CAAe,IAAIC,cAAJ,CAAmBU,SAAST,IAAT,CAAcU,KAAjC,CAAf,CAAP;AACD;;AAED;AACA,qBAAOD,SAAST,IAAT,CAAcW,MAArB;AACD,aAZM,CAAP;AAaD;;;gCAMKtB,O,EAASuB,Q,EAAUC,Q,EAAUrB,O,EAAS;AAC1C,gBAAID,SAAS;AACXuB,oBAAMF,QADK;AAEXC,wBAAUA;AAFC,aAAb;AAIA,mBAAO,KAAKE,OAAL,CAAa1B,OAAb,EAAsB,YAAtB,EAAoCE,MAApC,EAA4CC,OAA5C,EAAqD,IAArD,CAAP;AACD;;;qCAMUH,O,EAASG,O,EAAS;AAC3B,mBAAO,KAAKuB,OAAL,CAAa1B,OAAb,EAAsB,iBAAtB,EAAyC,EAAzC,EAA6CG,OAA7C,CAAP;AACD;;;;;;;;gCAIUO,c;AACX,gCAAYW,KAAZ,EAAmB;AAAA;;AACjB,eAAKM,IAAL,GAAYN,MAAMM,IAAN,IAAc,IAA1B;AACA,eAAKC,IAAL,GAAYP,MAAMQ,OAAN,IAAiB,EAA7B;AACA,eAAKlB,IAAL,GAAYU,MAAMV,IAAN,IAAc,EAA1B;AACA,eAAKkB,OAAL,GAAe,uBAAuB,KAAKD,IAA5B,GAAmC,GAAnC,GAAyC,KAAKjB,IAA7D;AACD;;;;qCAEU;AACT,mBAAO,KAAKiB,IAAL,GAAY,GAAZ,GAAkB,KAAKjB,IAA9B;AACD","file":"zabbixAPICore.js","sourcesContent":["/**\n * General Zabbix API methods\n */\n\nexport class ZabbixAPICore {\n\n /** @ngInject */\n constructor(backendSrv) {\n this.backendSrv = backendSrv;\n }\n\n /**\n * Request data from Zabbix API\n * @return {object} response.result\n */\n request(api_url, method, params, options, auth) {\n let requestData = {\n jsonrpc: '2.0',\n method: method,\n params: params,\n id: 1\n };\n\n if (auth === \"\") {\n // Reject immediately if not authenticated\n return Promise.reject(new ZabbixAPIError({data: \"Not authorised.\"}));\n } else if (auth) {\n // Set auth parameter only if it needed\n requestData.auth = auth;\n }\n\n let requestOptions = {\n method: 'POST',\n url: api_url,\n data: requestData,\n headers: {\n 'Content-Type': 'application/json'\n }\n };\n\n // Set request options for basic auth\n if (options.basicAuth || options.withCredentials) {\n requestOptions.withCredentials = true;\n }\n if (options.basicAuth) {\n requestOptions.headers.Authorization = options.basicAuth;\n }\n\n return this.datasourceRequest(requestOptions);\n }\n\n datasourceRequest(requestOptions) {\n return this.backendSrv.datasourceRequest(requestOptions)\n .then((response) => {\n if (!response.data) {\n return Promise.reject(new ZabbixAPIError({data: \"General Error, no data\"}));\n } else if (response.data.error) {\n\n // Handle Zabbix API errors\n return Promise.reject(new ZabbixAPIError(response.data.error));\n }\n\n // Success\n return response.data.result;\n });\n }\n\n /**\n * Get authentication token.\n * @return {string} auth token\n */\n login(api_url, username, password, options) {\n let params = {\n user: username,\n password: password\n };\n return this.request(api_url, 'user.login', params, options, null);\n }\n\n /**\n * Get Zabbix API version\n * Matches the version of Zabbix starting from Zabbix 2.0.4\n */\n getVersion(api_url, options) {\n return this.request(api_url, 'apiinfo.version', [], options);\n }\n}\n\n// Define zabbix API exception type\nexport class ZabbixAPIError {\n constructor(error) {\n this.code = error.code || null;\n this.name = error.message || \"\";\n this.data = error.data || \"\";\n this.message = \"Zabbix API Error: \" + this.name + \" \" + this.data;\n }\n\n toString() {\n return this.name + \" \" + this.data;\n }\n}\n"]}
|
||||
150
dist/datasource-zabbix/zabbix/proxy/cachingProxy.js
vendored
@@ -1,150 +0,0 @@
|
||||
"use strict";
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _createClass, CachingProxy;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap request to prevent multiple calls
|
||||
* with same params when waiting for result.
|
||||
*/
|
||||
function callOnce(func, promiseKeeper, funcScope) {
|
||||
return function () {
|
||||
var hash = getRequestHash(arguments);
|
||||
if (!promiseKeeper[hash]) {
|
||||
promiseKeeper[hash] = Promise.resolve(func.apply(funcScope, arguments).then(function (result) {
|
||||
promiseKeeper[hash] = null;
|
||||
return result;
|
||||
}));
|
||||
}
|
||||
return promiseKeeper[hash];
|
||||
};
|
||||
}
|
||||
|
||||
function _cacheRequest(func, funcName, funcScope, self) {
|
||||
return function () {
|
||||
if (!self.cache[funcName]) {
|
||||
self.cache[funcName] = {};
|
||||
}
|
||||
|
||||
var cacheObject = self.cache[funcName];
|
||||
var hash = getRequestHash(arguments);
|
||||
if (self.cacheEnabled && !self._isExpired(cacheObject[hash])) {
|
||||
return Promise.resolve(cacheObject[hash].value);
|
||||
} else {
|
||||
return func.apply(funcScope, arguments).then(function (result) {
|
||||
cacheObject[hash] = {
|
||||
value: result,
|
||||
timestamp: Date.now()
|
||||
};
|
||||
return result;
|
||||
});
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function getRequestHash(args) {
|
||||
var argsJson = JSON.stringify(args);
|
||||
return argsJson.getHash();
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
_export("CachingProxy", CachingProxy = function () {
|
||||
function CachingProxy(cacheOptions) {
|
||||
_classCallCheck(this, CachingProxy);
|
||||
|
||||
this.cacheEnabled = cacheOptions.enabled;
|
||||
this.ttl = cacheOptions.ttl || 600000; // 10 minutes by default
|
||||
|
||||
// Internal objects for data storing
|
||||
this.cache = {};
|
||||
this.promises = {};
|
||||
}
|
||||
|
||||
/**
|
||||
* Check that result is present in the cache and is up to date or send request otherwise.
|
||||
*/
|
||||
|
||||
|
||||
_createClass(CachingProxy, [{
|
||||
key: "cacheRequest",
|
||||
value: function cacheRequest(func, funcName, funcScope) {
|
||||
return _cacheRequest(func, funcName, funcScope, this);
|
||||
}
|
||||
}, {
|
||||
key: "proxyfy",
|
||||
value: function proxyfy(func, funcName, funcScope) {
|
||||
if (!this.promises[funcName]) {
|
||||
this.promises[funcName] = {};
|
||||
}
|
||||
var promiseKeeper = this.promises[funcName];
|
||||
return callOnce(func, promiseKeeper, funcScope);
|
||||
}
|
||||
}, {
|
||||
key: "proxyfyWithCache",
|
||||
value: function proxyfyWithCache(func, funcName, funcScope) {
|
||||
var proxyfied = this.proxyfy(func, funcName, funcScope);
|
||||
return this.cacheRequest(proxyfied, funcName, funcScope);
|
||||
}
|
||||
}, {
|
||||
key: "_isExpired",
|
||||
value: function _isExpired(cacheObject) {
|
||||
if (cacheObject) {
|
||||
var object_age = Date.now() - cacheObject.timestamp;
|
||||
return !(cacheObject.timestamp && object_age < this.ttl);
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
return CachingProxy;
|
||||
}());
|
||||
|
||||
_export("CachingProxy", CachingProxy);
|
||||
|
||||
String.prototype.getHash = function () {
|
||||
var hash = 0,
|
||||
i,
|
||||
chr,
|
||||
len;
|
||||
if (this.length !== 0) {
|
||||
for (i = 0, len = this.length; i < len; i++) {
|
||||
chr = this.charCodeAt(i);
|
||||
hash = (hash << 5) - hash + chr;
|
||||
hash |= 0; // Convert to 32bit integer
|
||||
}
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=cachingProxy.js.map
|
||||
568
dist/datasource-zabbix/zabbix/zabbix.js
vendored
@@ -1,568 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', '../utils', '../responseHandler', './connectors/zabbix_api/zabbixAPIConnector', './connectors/sql/sqlConnector', './proxy/cachingProxy', './connectors/dbConnector'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, utils, responseHandler, ZabbixAPIConnector, SQLConnector, CachingProxy, ZabbixNotImplemented, _slicedToArray, _createClass, REQUESTS_TO_PROXYFY, REQUESTS_TO_CACHE, REQUESTS_TO_BIND, Zabbix;
|
||||
|
||||
function _toConsumableArray(arr) {
|
||||
if (Array.isArray(arr)) {
|
||||
for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) {
|
||||
arr2[i] = arr[i];
|
||||
}
|
||||
|
||||
return arr2;
|
||||
} else {
|
||||
return Array.from(arr);
|
||||
}
|
||||
}
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
/**
|
||||
* Find group, host, app or item by given name.
|
||||
* @param list list of groups, apps or other
|
||||
* @param name visible name
|
||||
* @return array with finded element or empty array
|
||||
*/
|
||||
function findByName(list, name) {
|
||||
var finded = _.find(list, { 'name': name });
|
||||
if (finded) {
|
||||
return [finded];
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Different hosts can contains applications and items with same name.
|
||||
* For this reason use _.filter, which return all elements instead _.find,
|
||||
* which return only first finded.
|
||||
* @param {[type]} list list of elements
|
||||
* @param {[type]} name app name
|
||||
* @return {[type]} array with finded element or empty array
|
||||
*/
|
||||
function filterByName(list, name) {
|
||||
var finded = _.filter(list, { 'name': name });
|
||||
if (finded) {
|
||||
return finded;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
|
||||
function filterByRegex(list, regex) {
|
||||
var filterPattern = utils.buildRegex(regex);
|
||||
return _.filter(list, function (zbx_obj) {
|
||||
return filterPattern.test(zbx_obj.name);
|
||||
});
|
||||
}
|
||||
|
||||
function findByFilter(list, filter) {
|
||||
if (utils.isRegex(filter)) {
|
||||
return filterByRegex(list, filter);
|
||||
} else {
|
||||
return findByName(list, filter);
|
||||
}
|
||||
}
|
||||
|
||||
function filterByQuery(list, filter) {
|
||||
if (utils.isRegex(filter)) {
|
||||
return filterByRegex(list, filter);
|
||||
} else {
|
||||
return filterByName(list, filter);
|
||||
}
|
||||
}
|
||||
|
||||
function getHostIds(items) {
|
||||
var hostIds = _.map(items, function (item) {
|
||||
return _.map(item.hosts, 'hostid');
|
||||
});
|
||||
return _.uniq(_.flatten(hostIds));
|
||||
}
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_utils) {
|
||||
utils = _utils;
|
||||
}, function (_responseHandler) {
|
||||
responseHandler = _responseHandler.default;
|
||||
}, function (_connectorsZabbix_apiZabbixAPIConnector) {
|
||||
ZabbixAPIConnector = _connectorsZabbix_apiZabbixAPIConnector.ZabbixAPIConnector;
|
||||
}, function (_connectorsSqlSqlConnector) {
|
||||
SQLConnector = _connectorsSqlSqlConnector.SQLConnector;
|
||||
}, function (_proxyCachingProxy) {
|
||||
CachingProxy = _proxyCachingProxy.CachingProxy;
|
||||
}, function (_connectorsDbConnector) {
|
||||
ZabbixNotImplemented = _connectorsDbConnector.ZabbixNotImplemented;
|
||||
}],
|
||||
execute: function () {
|
||||
_slicedToArray = function () {
|
||||
function sliceIterator(arr, i) {
|
||||
var _arr = [];
|
||||
var _n = true;
|
||||
var _d = false;
|
||||
var _e = undefined;
|
||||
|
||||
try {
|
||||
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
||||
_arr.push(_s.value);
|
||||
|
||||
if (i && _arr.length === i) break;
|
||||
}
|
||||
} catch (err) {
|
||||
_d = true;
|
||||
_e = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_n && _i["return"]) _i["return"]();
|
||||
} finally {
|
||||
if (_d) throw _e;
|
||||
}
|
||||
}
|
||||
|
||||
return _arr;
|
||||
}
|
||||
|
||||
return function (arr, i) {
|
||||
if (Array.isArray(arr)) {
|
||||
return arr;
|
||||
} else if (Symbol.iterator in Object(arr)) {
|
||||
return sliceIterator(arr, i);
|
||||
} else {
|
||||
throw new TypeError("Invalid attempt to destructure non-iterable instance");
|
||||
}
|
||||
};
|
||||
}();
|
||||
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
REQUESTS_TO_PROXYFY = ['getHistory', 'getTrend', 'getGroups', 'getHosts', 'getApps', 'getItems', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts', 'getAcknowledges', 'getITService', 'getSLA', 'getVersion'];
|
||||
REQUESTS_TO_CACHE = ['getGroups', 'getHosts', 'getApps', 'getItems', 'getMacros', 'getItemsByIDs', 'getITService'];
|
||||
REQUESTS_TO_BIND = ['getHistory', 'getTrend', 'getMacros', 'getItemsByIDs', 'getEvents', 'getAlerts', 'getHostAlerts', 'getAcknowledges', 'getITService', 'getVersion', 'login'];
|
||||
|
||||
_export('Zabbix', Zabbix = function () {
|
||||
function Zabbix(options, backendSrv, datasourceSrv) {
|
||||
_classCallCheck(this, Zabbix);
|
||||
|
||||
var url = options.url,
|
||||
username = options.username,
|
||||
password = options.password,
|
||||
basicAuth = options.basicAuth,
|
||||
withCredentials = options.withCredentials,
|
||||
cacheTTL = options.cacheTTL,
|
||||
enableDirectDBConnection = options.enableDirectDBConnection,
|
||||
dbConnectionDatasourceId = options.dbConnectionDatasourceId,
|
||||
dbConnectionDatasourceName = options.dbConnectionDatasourceName;
|
||||
|
||||
|
||||
this.enableDirectDBConnection = enableDirectDBConnection;
|
||||
|
||||
// Initialize caching proxy for requests
|
||||
var cacheOptions = {
|
||||
enabled: true,
|
||||
ttl: cacheTTL
|
||||
};
|
||||
this.cachingProxy = new CachingProxy(cacheOptions);
|
||||
|
||||
this.zabbixAPI = new ZabbixAPIConnector(url, username, password, basicAuth, withCredentials, backendSrv);
|
||||
|
||||
if (enableDirectDBConnection) {
|
||||
var dbConnectorOptions = {
|
||||
datasourceId: dbConnectionDatasourceId,
|
||||
datasourceName: dbConnectionDatasourceName
|
||||
};
|
||||
this.dbConnector = new SQLConnector(dbConnectorOptions, backendSrv, datasourceSrv);
|
||||
this.getHistoryDB = this.cachingProxy.proxyfyWithCache(this.dbConnector.getHistory, 'getHistory', this.dbConnector);
|
||||
this.getTrendsDB = this.cachingProxy.proxyfyWithCache(this.dbConnector.getTrends, 'getTrends', this.dbConnector);
|
||||
}
|
||||
|
||||
this.proxyfyRequests();
|
||||
this.cacheRequests();
|
||||
this.bindRequests();
|
||||
}
|
||||
|
||||
_createClass(Zabbix, [{
|
||||
key: 'proxyfyRequests',
|
||||
value: function proxyfyRequests() {
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = REQUESTS_TO_PROXYFY[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var request = _step.value;
|
||||
|
||||
this.zabbixAPI[request] = this.cachingProxy.proxyfy(this.zabbixAPI[request], request, this.zabbixAPI);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'cacheRequests',
|
||||
value: function cacheRequests() {
|
||||
var _iteratorNormalCompletion2 = true;
|
||||
var _didIteratorError2 = false;
|
||||
var _iteratorError2 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator2 = REQUESTS_TO_CACHE[Symbol.iterator](), _step2; !(_iteratorNormalCompletion2 = (_step2 = _iterator2.next()).done); _iteratorNormalCompletion2 = true) {
|
||||
var request = _step2.value;
|
||||
|
||||
this.zabbixAPI[request] = this.cachingProxy.cacheRequest(this.zabbixAPI[request], request, this.zabbixAPI);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError2 = true;
|
||||
_iteratorError2 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion2 && _iterator2.return) {
|
||||
_iterator2.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError2) {
|
||||
throw _iteratorError2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'bindRequests',
|
||||
value: function bindRequests() {
|
||||
var _iteratorNormalCompletion3 = true;
|
||||
var _didIteratorError3 = false;
|
||||
var _iteratorError3 = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator3 = REQUESTS_TO_BIND[Symbol.iterator](), _step3; !(_iteratorNormalCompletion3 = (_step3 = _iterator3.next()).done); _iteratorNormalCompletion3 = true) {
|
||||
var request = _step3.value;
|
||||
|
||||
this[request] = this.zabbixAPI[request].bind(this.zabbixAPI);
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError3 = true;
|
||||
_iteratorError3 = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion3 && _iterator3.return) {
|
||||
_iterator3.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError3) {
|
||||
throw _iteratorError3;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'testDataSource',
|
||||
value: function testDataSource() {
|
||||
var _this = this;
|
||||
|
||||
var zabbixVersion = void 0;
|
||||
var dbConnectorStatus = void 0;
|
||||
return this.getVersion().then(function (version) {
|
||||
zabbixVersion = version;
|
||||
return _this.login();
|
||||
}).then(function () {
|
||||
if (_this.enableDirectDBConnection) {
|
||||
return _this.dbConnector.testDataSource();
|
||||
} else {
|
||||
return Promise.resolve();
|
||||
}
|
||||
}).catch(function (error) {
|
||||
if (error instanceof ZabbixNotImplemented) {
|
||||
return Promise.resolve();
|
||||
}
|
||||
return Promise.reject(error);
|
||||
}).then(function (testResult) {
|
||||
if (testResult) {
|
||||
dbConnectorStatus = {
|
||||
dsType: _this.dbConnector.datasourceTypeName,
|
||||
dsName: _this.dbConnector.datasourceName
|
||||
};
|
||||
}
|
||||
return { zabbixVersion: zabbixVersion, dbConnectorStatus: dbConnectorStatus };
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getItemsFromTarget',
|
||||
value: function getItemsFromTarget(target, options) {
|
||||
var parts = ['group', 'host', 'application', 'item'];
|
||||
var filters = _.map(parts, function (p) {
|
||||
return target[p].filter;
|
||||
});
|
||||
return this.getItems.apply(this, _toConsumableArray(filters).concat([options]));
|
||||
}
|
||||
}, {
|
||||
key: 'getHostsFromTarget',
|
||||
value: function getHostsFromTarget(target) {
|
||||
var parts = ['group', 'host', 'application'];
|
||||
var filters = _.map(parts, function (p) {
|
||||
return target[p].filter;
|
||||
});
|
||||
return Promise.all([this.getHosts.apply(this, _toConsumableArray(filters)), this.getApps.apply(this, _toConsumableArray(filters))]).then(function (results) {
|
||||
var _results = _slicedToArray(results, 2),
|
||||
hosts = _results[0],
|
||||
apps = _results[1];
|
||||
|
||||
if (apps.appFilterEmpty) {
|
||||
apps = [];
|
||||
}
|
||||
return [hosts, apps];
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getAllGroups',
|
||||
value: function getAllGroups() {
|
||||
return this.zabbixAPI.getGroups();
|
||||
}
|
||||
}, {
|
||||
key: 'getGroups',
|
||||
value: function getGroups(groupFilter) {
|
||||
return this.getAllGroups().then(function (groups) {
|
||||
return findByFilter(groups, groupFilter);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getAllHosts',
|
||||
value: function getAllHosts(groupFilter) {
|
||||
var _this2 = this;
|
||||
|
||||
return this.getGroups(groupFilter).then(function (groups) {
|
||||
var groupids = _.map(groups, 'groupid');
|
||||
return _this2.zabbixAPI.getHosts(groupids);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getHosts',
|
||||
value: function getHosts(groupFilter, hostFilter) {
|
||||
return this.getAllHosts(groupFilter).then(function (hosts) {
|
||||
return findByFilter(hosts, hostFilter);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getAllApps',
|
||||
value: function getAllApps(groupFilter, hostFilter) {
|
||||
var _this3 = this;
|
||||
|
||||
return this.getHosts(groupFilter, hostFilter).then(function (hosts) {
|
||||
var hostids = _.map(hosts, 'hostid');
|
||||
return _this3.zabbixAPI.getApps(hostids);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getApps',
|
||||
value: function getApps(groupFilter, hostFilter, appFilter) {
|
||||
var _this4 = this;
|
||||
|
||||
return this.getHosts(groupFilter, hostFilter).then(function (hosts) {
|
||||
var hostids = _.map(hosts, 'hostid');
|
||||
if (appFilter) {
|
||||
return _this4.zabbixAPI.getApps(hostids).then(function (apps) {
|
||||
return filterByQuery(apps, appFilter);
|
||||
});
|
||||
} else {
|
||||
return {
|
||||
appFilterEmpty: true,
|
||||
hostids: hostids
|
||||
};
|
||||
}
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getAllItems',
|
||||
value: function getAllItems(groupFilter, hostFilter, appFilter) {
|
||||
var _this5 = this;
|
||||
|
||||
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
|
||||
|
||||
return this.getApps(groupFilter, hostFilter, appFilter).then(function (apps) {
|
||||
if (apps.appFilterEmpty) {
|
||||
return _this5.zabbixAPI.getItems(apps.hostids, undefined, options.itemtype);
|
||||
} else {
|
||||
var appids = _.map(apps, 'applicationid');
|
||||
return _this5.zabbixAPI.getItems(undefined, appids, options.itemtype);
|
||||
}
|
||||
}).then(function (items) {
|
||||
if (!options.showDisabledItems) {
|
||||
items = _.filter(items, { 'status': '0' });
|
||||
}
|
||||
|
||||
return items;
|
||||
}).then(this.expandUserMacro.bind(this));
|
||||
}
|
||||
}, {
|
||||
key: 'expandUserMacro',
|
||||
value: function expandUserMacro(items) {
|
||||
var hostids = getHostIds(items);
|
||||
return this.getMacros(hostids).then(function (macros) {
|
||||
_.forEach(items, function (item) {
|
||||
if (utils.containsMacro(item.name)) {
|
||||
item.name = utils.replaceMacro(item, macros);
|
||||
}
|
||||
});
|
||||
return items;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getItems',
|
||||
value: function getItems(groupFilter, hostFilter, appFilter, itemFilter) {
|
||||
var options = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
|
||||
|
||||
return this.getAllItems(groupFilter, hostFilter, appFilter, options).then(function (items) {
|
||||
return filterByQuery(items, itemFilter);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getITServices',
|
||||
value: function getITServices(itServiceFilter) {
|
||||
return this.zabbixAPI.getITService().then(function (itServices) {
|
||||
return findByFilter(itServices, itServiceFilter);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getTriggers',
|
||||
value: function getTriggers(groupFilter, hostFilter, appFilter, options) {
|
||||
var _this6 = this;
|
||||
|
||||
var promises = [this.getGroups(groupFilter), this.getHosts(groupFilter, hostFilter), this.getApps(groupFilter, hostFilter, appFilter)];
|
||||
|
||||
return Promise.all(promises).then(function (results) {
|
||||
var filteredGroups = results[0];
|
||||
var filteredHosts = results[1];
|
||||
var filteredApps = results[2];
|
||||
var query = {};
|
||||
|
||||
if (appFilter) {
|
||||
query.applicationids = _.flatten(_.map(filteredApps, 'applicationid'));
|
||||
}
|
||||
if (hostFilter) {
|
||||
query.hostids = _.map(filteredHosts, 'hostid');
|
||||
}
|
||||
if (groupFilter) {
|
||||
query.groupids = _.map(filteredGroups, 'groupid');
|
||||
}
|
||||
|
||||
return query;
|
||||
}).then(function (query) {
|
||||
return _this6.zabbixAPI.getTriggers(query.groupids, query.hostids, query.applicationids, options);
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getHistoryTS',
|
||||
value: function getHistoryTS(items, timeRange, options) {
|
||||
var _this7 = this;
|
||||
|
||||
var _timeRange = _slicedToArray(timeRange, 2),
|
||||
timeFrom = _timeRange[0],
|
||||
timeTo = _timeRange[1];
|
||||
|
||||
if (this.enableDirectDBConnection) {
|
||||
return this.getHistoryDB(items, timeFrom, timeTo, options).then(function (history) {
|
||||
return _this7.dbConnector.handleGrafanaTSResponse(history, items);
|
||||
});
|
||||
} else {
|
||||
return this.zabbixAPI.getHistory(items, timeFrom, timeTo).then(function (history) {
|
||||
return responseHandler.handleHistory(history, items);
|
||||
});
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'getTrends',
|
||||
value: function getTrends(items, timeRange, options) {
|
||||
var _this8 = this;
|
||||
|
||||
var _timeRange2 = _slicedToArray(timeRange, 2),
|
||||
timeFrom = _timeRange2[0],
|
||||
timeTo = _timeRange2[1];
|
||||
|
||||
if (this.enableDirectDBConnection) {
|
||||
return this.getTrendsDB(items, timeFrom, timeTo, options).then(function (history) {
|
||||
return _this8.dbConnector.handleGrafanaTSResponse(history, items);
|
||||
});
|
||||
} else {
|
||||
var valueType = options.consolidateBy || options.valueType;
|
||||
return this.zabbixAPI.getTrend(items, timeFrom, timeTo).then(function (history) {
|
||||
return responseHandler.handleTrends(history, items, valueType);
|
||||
}).then(responseHandler.sortTimeseries); // Sort trend data, issue #202
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'getHistoryText',
|
||||
value: function getHistoryText(items, timeRange, target) {
|
||||
var _timeRange3 = _slicedToArray(timeRange, 2),
|
||||
timeFrom = _timeRange3[0],
|
||||
timeTo = _timeRange3[1];
|
||||
|
||||
if (items.length) {
|
||||
return this.zabbixAPI.getHistory(items, timeFrom, timeTo).then(function (history) {
|
||||
if (target.resultFormat === 'table') {
|
||||
return responseHandler.handleHistoryAsTable(history, items, target);
|
||||
} else {
|
||||
return responseHandler.handleText(history, items, target);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
return Promise.resolve([]);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'getSLA',
|
||||
value: function getSLA(itservices, timeRange, target, options) {
|
||||
var itServices = itservices;
|
||||
if (options.isOldVersion) {
|
||||
itServices = _.filter(itServices, { 'serviceid': target.itservice.serviceid });
|
||||
}
|
||||
var itServiceIds = _.map(itServices, 'serviceid');
|
||||
return this.zabbixAPI.getSLA(itServiceIds, timeRange).then(function (slaResponse) {
|
||||
return _.map(itServiceIds, function (serviceid) {
|
||||
var itservice = _.find(itServices, { 'serviceid': serviceid });
|
||||
return responseHandler.handleSLAResponse(itservice, target.slaProperty, slaResponse);
|
||||
});
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return Zabbix;
|
||||
}());
|
||||
|
||||
_export('Zabbix', Zabbix);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=zabbix.js.map
|
||||
1
dist/datasource-zabbix/zabbix/zabbix.js.map
vendored
147
dist/datasource-zabbix/zabbixAlerting.service.js
vendored
@@ -1,147 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', 'jquery', 'angular'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, $, angular, _createClass, ZabbixAlertingService;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_jquery) {
|
||||
$ = _jquery.default;
|
||||
}, function (_angular) {
|
||||
angular = _angular.default;
|
||||
}],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
ZabbixAlertingService = function () {
|
||||
|
||||
/** @ngInject */
|
||||
function ZabbixAlertingService(dashboardSrv) {
|
||||
_classCallCheck(this, ZabbixAlertingService);
|
||||
|
||||
this.dashboardSrv = dashboardSrv;
|
||||
}
|
||||
|
||||
_createClass(ZabbixAlertingService, [{
|
||||
key: 'isFullScreen',
|
||||
value: function isFullScreen() {
|
||||
return this.dashboardSrv.dash.meta.fullscreen;
|
||||
}
|
||||
}, {
|
||||
key: 'setPanelAlertState',
|
||||
value: function setPanelAlertState(panelId, alertState) {
|
||||
var panelIndex = void 0;
|
||||
|
||||
var panelContainers = _.filter($('.panel-container'), function (elem) {
|
||||
return elem.clientHeight && elem.clientWidth;
|
||||
});
|
||||
|
||||
var panelModels = this.getPanelModels();
|
||||
|
||||
if (this.isFullScreen()) {
|
||||
panelIndex = 0;
|
||||
} else {
|
||||
panelIndex = _.findIndex(panelModels, function (panel) {
|
||||
return panel.id === panelId;
|
||||
});
|
||||
}
|
||||
|
||||
if (panelIndex >= 0) {
|
||||
var alertClass = "panel-has-alert panel-alert-state--ok panel-alert-state--alerting";
|
||||
$(panelContainers[panelIndex]).removeClass(alertClass);
|
||||
|
||||
if (alertState) {
|
||||
if (alertState === 'alerting') {
|
||||
alertClass = "panel-has-alert panel-alert-state--" + alertState;
|
||||
$(panelContainers[panelIndex]).addClass(alertClass);
|
||||
}
|
||||
if (alertState === 'ok') {
|
||||
alertClass = "panel-alert-state--" + alertState;
|
||||
$(panelContainers[panelIndex]).addClass(alertClass);
|
||||
$(panelContainers[panelIndex]).removeClass("panel-has-alert");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'getPanelModels',
|
||||
value: function getPanelModels() {
|
||||
return _.filter(this.dashboardSrv.dash.panels, function (panel) {
|
||||
return panel.type !== 'row';
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'getPanelModel',
|
||||
value: function getPanelModel(panelId) {
|
||||
var panelModels = this.getPanelModels();
|
||||
|
||||
return _.find(panelModels, function (panel) {
|
||||
return panel.id === panelId;
|
||||
});
|
||||
}
|
||||
}, {
|
||||
key: 'setPanelThreshold',
|
||||
value: function setPanelThreshold(panelId, threshold) {
|
||||
var panel = this.getPanelModel(panelId);
|
||||
var containsThreshold = _.find(panel.thresholds, { value: threshold });
|
||||
|
||||
if (panel && panel.type === "graph" && !containsThreshold) {
|
||||
var thresholdOptions = {
|
||||
colorMode: "custom",
|
||||
fill: false,
|
||||
line: true,
|
||||
lineColor: "rgb(255, 0, 0)",
|
||||
op: "gt",
|
||||
value: threshold,
|
||||
source: "zabbix"
|
||||
};
|
||||
|
||||
panel.thresholds.push(thresholdOptions);
|
||||
}
|
||||
}
|
||||
}, {
|
||||
key: 'removeZabbixThreshold',
|
||||
value: function removeZabbixThreshold(panelId) {
|
||||
var panel = this.getPanelModel(panelId);
|
||||
|
||||
if (panel && panel.type === "graph") {
|
||||
panel.thresholds = _.filter(panel.thresholds, function (threshold) {
|
||||
return threshold.source !== "zabbix";
|
||||
});
|
||||
}
|
||||
}
|
||||
}]);
|
||||
|
||||
return ZabbixAlertingService;
|
||||
}();
|
||||
|
||||
angular.module('grafana.services').service('zabbixAlertingSrv', ZabbixAlertingService);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=zabbixAlerting.service.js.map
|
||||
BIN
dist/img/screenshot-annotations.png
vendored
|
Before Width: | Height: | Size: 173 KiB |
BIN
dist/img/screenshot-dashboard01.png
vendored
|
Before Width: | Height: | Size: 371 KiB |
BIN
dist/img/screenshot-metric_editor.png
vendored
|
Before Width: | Height: | Size: 40 KiB |
BIN
dist/img/screenshot-showcase.png
vendored
|
Before Width: | Height: | Size: 255 KiB |
BIN
dist/img/screenshot-triggers.png
vendored
|
Before Width: | Height: | Size: 168 KiB |
107
dist/img/zabbix_app_logo.svg
vendored
@@ -1,107 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
|
||||
<!-- Generator: Adobe Illustrator 19.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
|
||||
<svg
|
||||
xmlns:dc="http://purl.org/dc/elements/1.1/"
|
||||
xmlns:cc="http://creativecommons.org/ns#"
|
||||
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
|
||||
xmlns:svg="http://www.w3.org/2000/svg"
|
||||
xmlns="http://www.w3.org/2000/svg"
|
||||
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
|
||||
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
|
||||
version="1.0"
|
||||
id="Layer_1"
|
||||
x="0px"
|
||||
y="0px"
|
||||
width="100px"
|
||||
height="100px"
|
||||
viewBox="692 0 100 100"
|
||||
style="enable-background:new 692 0 100 100;"
|
||||
xml:space="preserve"
|
||||
inkscape:version="0.91 r"
|
||||
sodipodi:docname="zabbix_app_logo.svg"
|
||||
enable-background="new"><metadata
|
||||
id="metadata13"><rdf:RDF><cc:Work
|
||||
rdf:about=""><dc:format>image/svg+xml</dc:format><dc:type
|
||||
rdf:resource="http://purl.org/dc/dcmitype/StillImage" /><dc:title></dc:title></cc:Work></rdf:RDF></metadata><defs
|
||||
id="defs11"><linearGradient
|
||||
id="SVGID_1_"
|
||||
gradientUnits="userSpaceOnUse"
|
||||
x1="2.6005001"
|
||||
y1="65.475197"
|
||||
x2="94.377701"
|
||||
y2="30.245199"><stop
|
||||
id="stop34"
|
||||
style="stop-color:#58595B"
|
||||
offset="0.2583" /><stop
|
||||
id="stop32"
|
||||
style="stop-color:#646C70"
|
||||
offset="0.2917" /><stop
|
||||
id="stop30"
|
||||
style="stop-color:#6C8087"
|
||||
offset="0.3398" /><stop
|
||||
id="stop28"
|
||||
style="stop-color:#6D8F9B"
|
||||
offset="0.3927" /><stop
|
||||
id="stop26"
|
||||
style="stop-color:#689BAA"
|
||||
offset="0.4499" /><stop
|
||||
id="stop24"
|
||||
style="stop-color:#5FA3B5"
|
||||
offset="0.5128" /><stop
|
||||
id="stop22"
|
||||
style="stop-color:#53A8BD"
|
||||
offset="0.5837" /><stop
|
||||
id="stop20"
|
||||
style="stop-color:#47ABC2"
|
||||
offset="0.6674" /><stop
|
||||
id="stop18"
|
||||
style="stop-color:#3FAEC5"
|
||||
offset="0.7759" /><stop
|
||||
id="stop16"
|
||||
style="stop-color:#3CAFC7"
|
||||
offset="1" /><stop
|
||||
id="stop14"
|
||||
style="stop-color:#3BB0C9"
|
||||
offset="1" /></linearGradient></defs><sodipodi:namedview
|
||||
pagecolor="#ffffff"
|
||||
bordercolor="#666666"
|
||||
borderopacity="1"
|
||||
objecttolerance="10"
|
||||
gridtolerance="10"
|
||||
guidetolerance="10"
|
||||
inkscape:pageopacity="0"
|
||||
inkscape:pageshadow="2"
|
||||
inkscape:window-width="1615"
|
||||
inkscape:window-height="1026"
|
||||
id="namedview9"
|
||||
showgrid="false"
|
||||
inkscape:zoom="4.285"
|
||||
inkscape:cx="50.424685"
|
||||
inkscape:cy="23.581186"
|
||||
inkscape:window-x="65"
|
||||
inkscape:window-y="24"
|
||||
inkscape:window-maximized="1"
|
||||
inkscape:current-layer="g5194" /><style
|
||||
type="text/css"
|
||||
id="style3">
|
||||
.st0{fill:#787878;}
|
||||
</style><g
|
||||
inkscape:groupmode="layer"
|
||||
id="g5194"
|
||||
inkscape:label="Zabbix BG Original"
|
||||
style="display:inline"><rect
|
||||
style="fill:#d40000;fill-opacity:1"
|
||||
id="rect5196"
|
||||
width="100"
|
||||
height="100"
|
||||
x="692"
|
||||
y="0" /></g><g
|
||||
inkscape:groupmode="layer"
|
||||
id="layer6"
|
||||
inkscape:label="Zabbix Original Z"
|
||||
style="display:inline"><path
|
||||
d="m 715.54426,16.689227 52.91147,0 0,6.87033 -42.58255,52.167008 43.62047,0 0,7.584207 -54.9873,0 0,-6.871516 42.58255,-52.166552 -41.54464,0 0,-7.583477 z"
|
||||
style="display:inline;fill:#ffffff;fill-opacity:1;fill-rule:nonzero;stroke:none"
|
||||
id="path4169-6"
|
||||
inkscape:connector-curvature="0" /></g></svg>
|
||||
|
Before Width: | Height: | Size: 3.5 KiB |
24
dist/module.js
vendored
@@ -1,24 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['./components/config', 'app/plugins/sdk'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var ZabbixAppConfigCtrl, loadPluginCss;
|
||||
return {
|
||||
setters: [function (_componentsConfig) {
|
||||
ZabbixAppConfigCtrl = _componentsConfig.ZabbixAppConfigCtrl;
|
||||
}, function (_appPluginsSdk) {
|
||||
loadPluginCss = _appPluginsSdk.loadPluginCss;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
loadPluginCss({
|
||||
dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',
|
||||
light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'
|
||||
});
|
||||
|
||||
_export('ConfigCtrl', ZabbixAppConfigCtrl);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=module.js.map
|
||||
1
dist/module.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../src/module.js"],"names":["ZabbixAppConfigCtrl","loadPluginCss","dark","light"],"mappings":";;;;;;;;AAAQA,yB,qBAAAA,mB;;AACAC,mB,kBAAAA,a;;;;AAERA,oBAAc;AACZC,cAAM,gEADM;AAEZC,eAAO;AAFK,OAAd;;4BAMEH,mB","file":"module.js","sourcesContent":["import {ZabbixAppConfigCtrl} from './components/config';\nimport {loadPluginCss} from 'app/plugins/sdk';\n\nloadPluginCss({\n dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',\n light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'\n});\n\nexport {\n ZabbixAppConfigCtrl as ConfigCtrl\n};\n"]}
|
||||
140
dist/panel-triggers/ack-tooltip.directive.js
vendored
@@ -1,140 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['angular', 'jquery'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var angular, $, Drop;
|
||||
return {
|
||||
setters: [function (_angular) {
|
||||
angular = _angular.default;
|
||||
}, function (_jquery) {
|
||||
$ = _jquery.default;
|
||||
}],
|
||||
execute: function () {
|
||||
|
||||
System.config({
|
||||
paths: {
|
||||
tether: System.getConfig().baseURL + "plugins/alexanderzobnin-zabbix-app/vendor/npm/tether.min.js"
|
||||
}
|
||||
});
|
||||
|
||||
Drop = void 0;
|
||||
|
||||
System.amdRequire(["plugins/alexanderzobnin-zabbix-app/vendor/npm/drop.min.js"], function (drop) {
|
||||
Drop = drop;
|
||||
});
|
||||
|
||||
/** @ngInject */
|
||||
angular.module('grafana.directives').directive('ackTooltip', function ($sanitize, $compile) {
|
||||
var buttonTemplate = '<a bs-tooltip="\'Acknowledges ({{trigger.acknowledges.length}})\'"' + '<i ng-class="' + "{'fa fa-comments': trigger.acknowledges.length, " + "'fa fa-comments-o': !trigger.acknowledges.length, " + '}"></i></a>';
|
||||
|
||||
return {
|
||||
scope: {
|
||||
ack: "=",
|
||||
trigger: "=",
|
||||
onAck: "=",
|
||||
context: "="
|
||||
},
|
||||
link: function link(scope, element) {
|
||||
var acknowledges = scope.ack;
|
||||
var $button = $(buttonTemplate);
|
||||
$button.appendTo(element);
|
||||
|
||||
$button.click(function () {
|
||||
var tooltip = '<div>';
|
||||
|
||||
if (acknowledges && acknowledges.length) {
|
||||
tooltip += '<table class="table"><thead><tr>' + '<th class="ack-time">Time</th>' + '<th class="ack-user">User</th>' + '<th class="ack-comments">Comments</th>' + '</tr></thead><tbody>';
|
||||
var _iteratorNormalCompletion = true;
|
||||
var _didIteratorError = false;
|
||||
var _iteratorError = undefined;
|
||||
|
||||
try {
|
||||
for (var _iterator = acknowledges[Symbol.iterator](), _step; !(_iteratorNormalCompletion = (_step = _iterator.next()).done); _iteratorNormalCompletion = true) {
|
||||
var ack = _step.value;
|
||||
|
||||
tooltip += '<tr><td>' + ack.time + '</td>' + '<td>' + ack.user + '</td>' + '<td>' + ack.message + '</td></tr>';
|
||||
}
|
||||
} catch (err) {
|
||||
_didIteratorError = true;
|
||||
_iteratorError = err;
|
||||
} finally {
|
||||
try {
|
||||
if (!_iteratorNormalCompletion && _iterator.return) {
|
||||
_iterator.return();
|
||||
}
|
||||
} finally {
|
||||
if (_didIteratorError) {
|
||||
throw _iteratorError;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
tooltip += '</tbody></table>';
|
||||
} else {
|
||||
tooltip += 'Add acknowledge';
|
||||
}
|
||||
|
||||
var addAckButtonTemplate = '<div class="ack-add-button">' + '<button id="add-acknowledge-btn"' + 'class="btn btn-mini btn-inverse gf-form-button">' + '<i class="fa fa-plus"></i>' + '</button></div>';
|
||||
tooltip += addAckButtonTemplate;
|
||||
tooltip += '</div>';
|
||||
|
||||
var drop = new Drop({
|
||||
target: element[0],
|
||||
content: tooltip,
|
||||
position: "bottom left",
|
||||
classes: 'drop-popover ack-tooltip',
|
||||
openOn: 'hover',
|
||||
hoverCloseDelay: 500,
|
||||
tetherOptions: {
|
||||
constraints: [{ to: 'window', pin: true, attachment: "both" }]
|
||||
}
|
||||
});
|
||||
|
||||
drop.open();
|
||||
drop.on('close', closeDrop);
|
||||
|
||||
$('#add-acknowledge-btn').on('click', onAddAckButtonClick);
|
||||
|
||||
function onAddAckButtonClick() {
|
||||
var inputTemplate = '<div class="ack-input-group">' + '<input type="text" id="ack-message">' + '<button id="send-ack-button"' + 'class="btn btn-mini btn-inverse gf-form-button">' + 'Acknowledge </button>' + '<button id="cancel-ack-button"' + 'class="btn btn-mini btn-inverse gf-form-button">' + 'Cancel' + '</button></input></div>';
|
||||
|
||||
var $input = $(inputTemplate);
|
||||
var $addAckButton = $('.ack-tooltip .ack-add-button');
|
||||
$addAckButton.replaceWith($input);
|
||||
$('.ack-tooltip #cancel-ack-button').on('click', onAckCancelButtonClick);
|
||||
$('.ack-tooltip #send-ack-button').on('click', onAckSendlButtonClick);
|
||||
}
|
||||
|
||||
function onAckCancelButtonClick() {
|
||||
$('.ack-tooltip .ack-input-group').replaceWith(addAckButtonTemplate);
|
||||
$('#add-acknowledge-btn').on('click', onAddAckButtonClick);
|
||||
}
|
||||
|
||||
function onAckSendlButtonClick() {
|
||||
var message = $('.ack-tooltip #ack-message')[0].value;
|
||||
var onAck = scope.onAck.bind(scope.context);
|
||||
onAck(scope.trigger, message).then(function () {
|
||||
closeDrop();
|
||||
});
|
||||
}
|
||||
|
||||
function closeDrop() {
|
||||
setTimeout(function () {
|
||||
try {
|
||||
drop.destroy();
|
||||
} catch (err) {
|
||||
console.log('drop.destroy() error: ', err.message);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
$compile(element.contents())(scope);
|
||||
}
|
||||
};
|
||||
});
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=ack-tooltip.directive.js.map
|
||||
@@ -1,93 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['angular', 'lodash'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var angular, _, _createClass, template, DatasourceSelectorCtrl;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
return {
|
||||
setters: [function (_angular) {
|
||||
angular = _angular.default;
|
||||
}, function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}],
|
||||
execute: function () {
|
||||
_createClass = function () {
|
||||
function defineProperties(target, props) {
|
||||
for (var i = 0; i < props.length; i++) {
|
||||
var descriptor = props[i];
|
||||
descriptor.enumerable = descriptor.enumerable || false;
|
||||
descriptor.configurable = true;
|
||||
if ("value" in descriptor) descriptor.writable = true;
|
||||
Object.defineProperty(target, descriptor.key, descriptor);
|
||||
}
|
||||
}
|
||||
|
||||
return function (Constructor, protoProps, staticProps) {
|
||||
if (protoProps) defineProperties(Constructor.prototype, protoProps);
|
||||
if (staticProps) defineProperties(Constructor, staticProps);
|
||||
return Constructor;
|
||||
};
|
||||
}();
|
||||
|
||||
template = '\n<value-select-dropdown variable="ctrl.dsOptions" on-updated="ctrl.onChange(ctrl.dsOptions)">\n</value-select-dropdown>\n';
|
||||
|
||||
|
||||
angular.module('grafana.directives').directive('datasourceSelector', function () {
|
||||
return {
|
||||
scope: {
|
||||
datasources: "=",
|
||||
options: "=",
|
||||
onChange: "&"
|
||||
},
|
||||
controller: DatasourceSelectorCtrl,
|
||||
controllerAs: 'ctrl',
|
||||
template: template
|
||||
};
|
||||
});
|
||||
|
||||
DatasourceSelectorCtrl = function () {
|
||||
|
||||
/** @ngInject */
|
||||
function DatasourceSelectorCtrl($scope) {
|
||||
_classCallCheck(this, DatasourceSelectorCtrl);
|
||||
|
||||
this.scope = $scope;
|
||||
var datasources = $scope.datasources;
|
||||
var options = $scope.options;
|
||||
this.dsOptions = {
|
||||
multi: true,
|
||||
current: { value: datasources, text: datasources.join(" + ") },
|
||||
options: _.map(options, function (ds) {
|
||||
return { text: ds, value: ds, selected: _.includes(datasources, ds) };
|
||||
})
|
||||
};
|
||||
}
|
||||
|
||||
_createClass(DatasourceSelectorCtrl, [{
|
||||
key: 'onChange',
|
||||
value: function onChange(updatedOptions) {
|
||||
var _this = this;
|
||||
|
||||
var newDataSources = updatedOptions.current.value;
|
||||
this.scope.datasources = newDataSources;
|
||||
|
||||
// Run after model was changed
|
||||
this.scope.$$postDigest(function () {
|
||||
_this.scope.onChange();
|
||||
});
|
||||
}
|
||||
}]);
|
||||
|
||||
return DatasourceSelectorCtrl;
|
||||
}();
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=datasource-selector.directive.js.map
|
||||
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/panel-triggers/datasource-selector.directive.js"],"names":["angular","_","template","module","directive","scope","datasources","options","onChange","controller","DatasourceSelectorCtrl","controllerAs","$scope","dsOptions","multi","current","value","text","join","map","ds","selected","includes","updatedOptions","newDataSources","$$postDigest"],"mappings":";;;;;;;;;;;;;;;AAAOA,a;;AACAC,O;;;;;;;;;;;;;;;;;;;;;AAEDC,c;;;AAKNF,cACCG,MADD,CACQ,oBADR,EAECC,SAFD,CAEW,oBAFX,EAEiC,YAAM;AACrC,eAAO;AACLC,iBAAO;AACLC,yBAAa,GADR;AAELC,qBAAS,GAFJ;AAGLC,sBAAU;AAHL,WADF;AAMLC,sBAAYC,sBANP;AAOLC,wBAAc,MAPT;AAQLT,oBAAUA;AARL,SAAP;AAUD,OAbD;;AAeMQ,4B;;AAEJ;AACA,wCAAYE,MAAZ,EAAoB;AAAA;;AAClB,eAAKP,KAAL,GAAaO,MAAb;AACA,cAAIN,cAAcM,OAAON,WAAzB;AACA,cAAIC,UAAUK,OAAOL,OAArB;AACA,eAAKM,SAAL,GAAiB;AACfC,mBAAO,IADQ;AAEfC,qBAAS,EAACC,OAAOV,WAAR,EAAqBW,MAAMX,YAAYY,IAAZ,CAAiB,KAAjB,CAA3B,EAFM;AAGfX,qBAASN,EAAEkB,GAAF,CAAMZ,OAAN,EAAe,UAACa,EAAD,EAAQ;AAC9B,qBAAO,EAACH,MAAMG,EAAP,EAAWJ,OAAOI,EAAlB,EAAsBC,UAAUpB,EAAEqB,QAAF,CAAWhB,WAAX,EAAwBc,EAAxB,CAAhC,EAAP;AACD,aAFQ;AAHM,WAAjB;AAOD;;;;mCAEQG,c,EAAgB;AAAA;;AACvB,gBAAIC,iBAAiBD,eAAeR,OAAf,CAAuBC,KAA5C;AACA,iBAAKX,KAAL,CAAWC,WAAX,GAAyBkB,cAAzB;;AAEA;AACA,iBAAKnB,KAAL,CAAWoB,YAAX,CAAwB,YAAM;AAC5B,oBAAKpB,KAAL,CAAWG,QAAX;AACD,aAFD;AAGD","file":"datasource-selector.directive.js","sourcesContent":["import angular from 'angular';\nimport _ from 'lodash';\n\nconst template = `\n<value-select-dropdown variable=\"ctrl.dsOptions\" on-updated=\"ctrl.onChange(ctrl.dsOptions)\">\n</value-select-dropdown>\n`;\n\nangular\n.module('grafana.directives')\n.directive('datasourceSelector', () => {\n return {\n scope: {\n datasources: \"=\",\n options: \"=\",\n onChange: \"&\"\n },\n controller: DatasourceSelectorCtrl,\n controllerAs: 'ctrl',\n template: template\n };\n});\n\nclass DatasourceSelectorCtrl {\n\n /** @ngInject */\n constructor($scope) {\n this.scope = $scope;\n let datasources = $scope.datasources;\n let options = $scope.options;\n this.dsOptions = {\n multi: true,\n current: {value: datasources, text: datasources.join(\" + \")},\n options: _.map(options, (ds) => {\n return {text: ds, value: ds, selected: _.includes(datasources, ds)};\n })\n };\n }\n\n onChange(updatedOptions) {\n let newDataSources = updatedOptions.current.value;\n this.scope.datasources = newDataSources;\n\n // Run after model was changed\n this.scope.$$postDigest(() => {\n this.scope.onChange();\n });\n }\n}\n"]}
|
||||
68
dist/panel-triggers/migrations.js
vendored
@@ -1,68 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['lodash', './triggers_panel_ctrl'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var _, DEFAULT_TARGET, CURRENT_SCHEMA_VERSION;
|
||||
|
||||
function migratePanelSchema(panel) {
|
||||
if (isEmptyPanel(panel)) {
|
||||
return panel;
|
||||
}
|
||||
|
||||
var schemaVersion = getSchemaVersion(panel);
|
||||
panel.schemaVersion = CURRENT_SCHEMA_VERSION;
|
||||
|
||||
if (schemaVersion < 2) {
|
||||
panel.datasources = [panel.datasource];
|
||||
panel.targets = {};
|
||||
panel.targets[panel.datasources[0]] = panel.triggers;
|
||||
|
||||
// delete old props
|
||||
delete panel.triggers;
|
||||
delete panel.datasource;
|
||||
}
|
||||
|
||||
if (schemaVersion < 3) {
|
||||
// delete old props
|
||||
delete panel.lastChangeField;
|
||||
delete panel.ageField;
|
||||
delete panel.infoField;
|
||||
delete panel.scroll;
|
||||
delete panel.hideHostsInMaintenance;
|
||||
}
|
||||
|
||||
if (schemaVersion < 4) {
|
||||
if (panel.targets && !_.isEmpty(panel.targets)) {
|
||||
_.each(panel.targets, function (target) {
|
||||
_.defaultsDeep(target, DEFAULT_TARGET);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
return panel;
|
||||
}
|
||||
|
||||
_export('migratePanelSchema', migratePanelSchema);
|
||||
|
||||
function getSchemaVersion(panel) {
|
||||
return panel.schemaVersion || 1;
|
||||
}
|
||||
|
||||
function isEmptyPanel(panel) {
|
||||
return !panel.datasource && !panel.datasources && !panel.triggers && !panel.targets;
|
||||
}
|
||||
return {
|
||||
setters: [function (_lodash) {
|
||||
_ = _lodash.default;
|
||||
}, function (_triggers_panel_ctrl) {
|
||||
DEFAULT_TARGET = _triggers_panel_ctrl.DEFAULT_TARGET;
|
||||
}],
|
||||
execute: function () {
|
||||
_export('CURRENT_SCHEMA_VERSION', CURRENT_SCHEMA_VERSION = 4);
|
||||
|
||||
_export('CURRENT_SCHEMA_VERSION', CURRENT_SCHEMA_VERSION);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=migrations.js.map
|
||||
1
dist/panel-triggers/migrations.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/panel-triggers/migrations.js"],"names":["migratePanelSchema","panel","isEmptyPanel","schemaVersion","getSchemaVersion","CURRENT_SCHEMA_VERSION","datasources","datasource","targets","triggers","lastChangeField","ageField","infoField","scroll","hideHostsInMaintenance","_","isEmpty","each","target","defaultsDeep","DEFAULT_TARGET"],"mappings":";;;;;;;AAMO,WAASA,kBAAT,CAA4BC,KAA5B,EAAmC;AACxC,QAAIC,aAAaD,KAAb,CAAJ,EAAyB;AACvB,aAAOA,KAAP;AACD;;AAED,QAAME,gBAAgBC,iBAAiBH,KAAjB,CAAtB;AACAA,UAAME,aAAN,GAAsBE,sBAAtB;;AAEA,QAAIF,gBAAgB,CAApB,EAAuB;AACrBF,YAAMK,WAAN,GAAoB,CAACL,MAAMM,UAAP,CAApB;AACAN,YAAMO,OAAN,GAAgB,EAAhB;AACAP,YAAMO,OAAN,CAAcP,MAAMK,WAAN,CAAkB,CAAlB,CAAd,IAAsCL,MAAMQ,QAA5C;;AAEA;AACA,aAAOR,MAAMQ,QAAb;AACA,aAAOR,MAAMM,UAAb;AACD;;AAED,QAAIJ,gBAAgB,CAApB,EAAuB;AACrB;AACA,aAAOF,MAAMS,eAAb;AACA,aAAOT,MAAMU,QAAb;AACA,aAAOV,MAAMW,SAAb;AACA,aAAOX,MAAMY,MAAb;AACA,aAAOZ,MAAMa,sBAAb;AACD;;AAED,QAAIX,gBAAgB,CAApB,EAAuB;AACrB,UAAIF,MAAMO,OAAN,IAAiB,CAACO,EAAEC,OAAF,CAAUf,MAAMO,OAAhB,CAAtB,EAAgD;AAC9CO,UAAEE,IAAF,CAAOhB,MAAMO,OAAb,EAAsB,UAACU,MAAD,EAAY;AAChCH,YAAEI,YAAF,CAAeD,MAAf,EAAuBE,cAAvB;AACD,SAFD;AAGD;AACF;;AAED,WAAOnB,KAAP;AACD;;gCApCeD,kB;;AAsChB,WAASI,gBAAT,CAA0BH,KAA1B,EAAiC;AAC/B,WAAOA,MAAME,aAAN,IAAuB,CAA9B;AACD;;AAED,WAASD,YAAT,CAAsBD,KAAtB,EAA6B;AAC3B,WAAO,CAACA,MAAMM,UAAP,IAAqB,CAACN,MAAMK,WAA5B,IAA2C,CAACL,MAAMQ,QAAlD,IAA8D,CAACR,MAAMO,OAA5E;AACD;;;AAlDMO,O;;AACCK,oB,wBAAAA,c;;;wCAGKf,sB,GAAyB,C","file":"migrations.js","sourcesContent":["import _ from 'lodash';\nimport {DEFAULT_TARGET} from './triggers_panel_ctrl';\n\n// Actual schema version\nexport const CURRENT_SCHEMA_VERSION = 4;\n\nexport function migratePanelSchema(panel) {\n if (isEmptyPanel(panel)) {\n return panel;\n }\n\n const schemaVersion = getSchemaVersion(panel);\n panel.schemaVersion = CURRENT_SCHEMA_VERSION;\n\n if (schemaVersion < 2) {\n panel.datasources = [panel.datasource];\n panel.targets = {};\n panel.targets[panel.datasources[0]] = panel.triggers;\n\n // delete old props\n delete panel.triggers;\n delete panel.datasource;\n }\n\n if (schemaVersion < 3) {\n // delete old props\n delete panel.lastChangeField;\n delete panel.ageField;\n delete panel.infoField;\n delete panel.scroll;\n delete panel.hideHostsInMaintenance;\n }\n\n if (schemaVersion < 4) {\n if (panel.targets && !_.isEmpty(panel.targets)) {\n _.each(panel.targets, (target) => {\n _.defaultsDeep(target, DEFAULT_TARGET);\n });\n }\n }\n\n return panel;\n}\n\nfunction getSchemaVersion(panel) {\n return panel.schemaVersion || 1;\n}\n\nfunction isEmptyPanel(panel) {\n return !panel.datasource && !panel.datasources && !panel.triggers && !panel.targets;\n}\n"]}
|
||||
36
dist/panel-triggers/module.js
vendored
@@ -1,36 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register(['./triggers_panel_ctrl', 'app/plugins/sdk', './datasource-selector.directive', './ack-tooltip.directive'], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var TriggerPanelCtrl, loadPluginCss;
|
||||
return {
|
||||
setters: [function (_triggers_panel_ctrl) {
|
||||
TriggerPanelCtrl = _triggers_panel_ctrl.TriggerPanelCtrl;
|
||||
}, function (_appPluginsSdk) {
|
||||
loadPluginCss = _appPluginsSdk.loadPluginCss;
|
||||
}, function (_datasourceSelectorDirective) {}, function (_ackTooltipDirective) {}],
|
||||
execute: function () {
|
||||
/**
|
||||
* Grafana-Zabbix
|
||||
* Zabbix plugin for Grafana.
|
||||
* http://github.com/alexanderzobnin/grafana-zabbix
|
||||
*
|
||||
* Trigger panel.
|
||||
* This feature sponsored by CORE IT
|
||||
* http://www.coreit.fr
|
||||
*
|
||||
* Copyright 2015 Alexander Zobnin alexanderzobnin@gmail.com
|
||||
* Licensed under the Apache License, Version 2.0
|
||||
*/
|
||||
|
||||
loadPluginCss({
|
||||
dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',
|
||||
light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'
|
||||
});
|
||||
|
||||
_export('PanelCtrl', TriggerPanelCtrl);
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=module.js.map
|
||||
1
dist/panel-triggers/module.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/panel-triggers/module.js"],"names":["TriggerPanelCtrl","loadPluginCss","dark","light"],"mappings":";;;;;;;;AAaQA,sB,wBAAAA,gB;;AACAC,mB,kBAAAA,a;;;AAdR;;;;;;;;;;;;;AAkBAA,oBAAc;AACZC,cAAM,gEADM;AAEZC,eAAO;AAFK,OAAd;;2BAMEH,gB","file":"module.js","sourcesContent":["/**\n * Grafana-Zabbix\n * Zabbix plugin for Grafana.\n * http://github.com/alexanderzobnin/grafana-zabbix\n *\n * Trigger panel.\n * This feature sponsored by CORE IT\n * http://www.coreit.fr\n *\n * Copyright 2015 Alexander Zobnin alexanderzobnin@gmail.com\n * Licensed under the Apache License, Version 2.0\n */\n\nimport {TriggerPanelCtrl} from './triggers_panel_ctrl';\nimport {loadPluginCss} from 'app/plugins/sdk';\nimport './datasource-selector.directive';\nimport './ack-tooltip.directive';\n\nloadPluginCss({\n dark: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.dark.css',\n light: 'plugins/alexanderzobnin-zabbix-app/css/grafana-zabbix.light.css'\n});\n\nexport {\n TriggerPanelCtrl as PanelCtrl\n};\n"]}
|
||||
46
dist/panel-triggers/options_tab.js
vendored
@@ -1,46 +0,0 @@
|
||||
'use strict';
|
||||
|
||||
System.register([], function (_export, _context) {
|
||||
"use strict";
|
||||
|
||||
var TriggerPanelOptionsCtrl;
|
||||
|
||||
function _classCallCheck(instance, Constructor) {
|
||||
if (!(instance instanceof Constructor)) {
|
||||
throw new TypeError("Cannot call a class as a function");
|
||||
}
|
||||
}
|
||||
|
||||
function triggerPanelOptionsTab() {
|
||||
return {
|
||||
restrict: 'E',
|
||||
scope: true,
|
||||
templateUrl: 'public/plugins/alexanderzobnin-zabbix-app/panel-triggers/partials/options_tab.html',
|
||||
controller: TriggerPanelOptionsCtrl
|
||||
};
|
||||
}
|
||||
|
||||
_export('triggerPanelOptionsTab', triggerPanelOptionsTab);
|
||||
|
||||
return {
|
||||
setters: [],
|
||||
execute: function () {
|
||||
TriggerPanelOptionsCtrl =
|
||||
|
||||
/** @ngInject */
|
||||
function TriggerPanelOptionsCtrl($scope) {
|
||||
_classCallCheck(this, TriggerPanelOptionsCtrl);
|
||||
|
||||
$scope.editor = this;
|
||||
this.panelCtrl = $scope.ctrl;
|
||||
this.panel = this.panelCtrl.panel;
|
||||
|
||||
this.fontSizes = ['80%', '90%', '100%', '110%', '120%', '130%', '150%', '160%', '180%', '200%', '220%', '250%'];
|
||||
this.ackFilters = ['all triggers', 'unacknowledged', 'acknowledged'];
|
||||
this.sortByFields = [{ text: 'last change', value: 'lastchange' }, { text: 'severity', value: 'priority' }];
|
||||
this.showEventsFields = [{ text: 'All', value: [0, 1] }, { text: 'OK', value: [0] }, { text: 'Problems', value: 1 }];
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
//# sourceMappingURL=options_tab.js.map
|
||||
1
dist/panel-triggers/options_tab.js.map
vendored
@@ -1 +0,0 @@
|
||||
{"version":3,"sources":["../../src/panel-triggers/options_tab.js"],"names":["triggerPanelOptionsTab","restrict","scope","templateUrl","controller","TriggerPanelOptionsCtrl","$scope","editor","panelCtrl","ctrl","panel","fontSizes","ackFilters","sortByFields","text","value","showEventsFields"],"mappings":";;;;;;;;;;;;;AAuCO,WAASA,sBAAT,GAAkC;AACvC,WAAO;AACLC,gBAAU,GADL;AAELC,aAAO,IAFF;AAGLC,mBAAa,oFAHR;AAILC,kBAAYC;AAJP,KAAP;AAMD;;oCAPeL,sB;;;;;AA1BVK,6B;;AAEJ;AACA,uCAAYC,MAAZ,EAAoB;AAAA;;AAClBA,eAAOC,MAAP,GAAgB,IAAhB;AACA,aAAKC,SAAL,GAAiBF,OAAOG,IAAxB;AACA,aAAKC,KAAL,GAAa,KAAKF,SAAL,CAAeE,KAA5B;;AAEA,aAAKC,SAAL,GAAiB,CAAC,KAAD,EAAQ,KAAR,EAAe,MAAf,EAAuB,MAAvB,EAA+B,MAA/B,EAAuC,MAAvC,EAA+C,MAA/C,EAAuD,MAAvD,EAA+D,MAA/D,EAAuE,MAAvE,EAA+E,MAA/E,EAAuF,MAAvF,CAAjB;AACA,aAAKC,UAAL,GAAkB,CAChB,cADgB,EAEhB,gBAFgB,EAGhB,cAHgB,CAAlB;AAKA,aAAKC,YAAL,GAAoB,CAClB,EAAEC,MAAM,aAAR,EAAwBC,OAAO,YAA/B,EADkB,EAElB,EAAED,MAAM,UAAR,EAAwBC,OAAO,UAA/B,EAFkB,CAApB;AAIA,aAAKC,gBAAL,GAAwB,CACtB,EAAEF,MAAM,KAAR,EAAmBC,OAAO,CAAC,CAAD,EAAG,CAAH,CAA1B,EADsB,EAEtB,EAAED,MAAM,IAAR,EAAmBC,OAAO,CAAC,CAAD,CAA1B,EAFsB,EAGtB,EAAED,MAAM,UAAR,EAAoBC,OAAO,CAA3B,EAHsB,CAAxB;AAKD,O","file":"options_tab.js","sourcesContent":["/**\n * Grafana-Zabbix\n * Zabbix plugin for Grafana.\n * http://github.com/alexanderzobnin/grafana-zabbix\n *\n * Trigger panel.\n * This feature sponsored by CORE IT\n * http://www.coreit.fr\n *\n * Copyright 2015 Alexander Zobnin alexanderzobnin@gmail.com\n * Licensed under the Apache License, Version 2.0\n */\n\nclass TriggerPanelOptionsCtrl {\n\n /** @ngInject */\n constructor($scope) {\n $scope.editor = this;\n this.panelCtrl = $scope.ctrl;\n this.panel = this.panelCtrl.panel;\n\n this.fontSizes = ['80%', '90%', '100%', '110%', '120%', '130%', '150%', '160%', '180%', '200%', '220%', '250%'];\n this.ackFilters = [\n 'all triggers',\n 'unacknowledged',\n 'acknowledged'\n ];\n this.sortByFields = [\n { text: 'last change', value: 'lastchange' },\n { text: 'severity', value: 'priority' }\n ];\n this.showEventsFields = [\n { text: 'All', value: [0,1] },\n { text: 'OK', value: [0] },\n { text: 'Problems', value: 1 }\n ];\n }\n}\n\nexport function triggerPanelOptionsTab() {\n return {\n restrict: 'E',\n scope: true,\n templateUrl: 'public/plugins/alexanderzobnin-zabbix-app/panel-triggers/partials/options_tab.html',\n controller: TriggerPanelOptionsCtrl,\n };\n}\n"]}
|
||||
97
dist/panel-triggers/partials/module.html
vendored
@@ -1,97 +0,0 @@
|
||||
<div class="triggers-panel-container">
|
||||
<div class="triggers-panel-scroll">
|
||||
<section class="card-section card-list-layout-list">
|
||||
<ol class="alert-rule-list">
|
||||
<!-- Trigger list item -->
|
||||
<li class="alert-rule-item zbx-trigger-card" ng-repeat="trigger in ctrl.currentTriggersPage"
|
||||
ng-class="{'zbx-trigger-highlighted': ctrl.panel.highlightBackground}"
|
||||
ng-style="ctrl.panel.highlightBackground && {background: ctrl.getBackground(trigger)}">
|
||||
|
||||
<!-- Heart icon -->
|
||||
<div class="alert-rule-item__icon" ng-style="!ctrl.panel.highlightBackground && {color: trigger.color}">
|
||||
<i class="icon-gf" ng-class="ctrl.getAlertIconClass(trigger)"></i>
|
||||
</div>
|
||||
|
||||
<div class="alert-rule-item__body">
|
||||
<div class="alert-rule-item__header">
|
||||
|
||||
<p class="alert-rule-item__name">
|
||||
<span class="zabbix-trigger-name">{{trigger.description}}</span>
|
||||
<span class="zabbix-hostname" ng-if="ctrl.panel.hostField || ctrl.panel.hostTechNameField">
|
||||
<i ng-if="trigger.maintenance" class="fa fa-wrench zbx-maintenance-icon"></i>
|
||||
{{ ctrl.formatHostName(trigger) }}
|
||||
</span>
|
||||
<span class="zabbix-hostname" ng-if="ctrl.panel.hostGroups">
|
||||
{{ ctrl.formatHostGroups(trigger) }}
|
||||
</span>
|
||||
|
||||
<span class="zbx-trigger-tags" ng-if="ctrl.panel.showTags && trigger.tags">
|
||||
<span ng-repeat="tag in trigger.tags" ng-click="ctrl.addTagFilter(tag, trigger.datasource)"
|
||||
tag-color-from-name="tag.tag+tag.value" class="label label-tag zbx-tag">
|
||||
{{tag.tag}}: {{tag.value}}
|
||||
</span>
|
||||
</span>
|
||||
</p>
|
||||
|
||||
<div class="alert-rule-item__text">
|
||||
<span ng-if="ctrl.panel.statusField" class="zbx-trigger-state"
|
||||
ng-class="ctrl.getAlertStateClass(trigger)">
|
||||
{{ctrl.triggerStatusMap[trigger.value]}}
|
||||
</span>
|
||||
<span ng-if="ctrl.panel.severityField" class="zbx-trigger-severity"
|
||||
ng-class="ctrl.getAlertStateClass(trigger)"
|
||||
ng-style="!ctrl.panel.highlightBackground && {color: trigger.color}">
|
||||
{{trigger.severity}}
|
||||
</span>
|
||||
<span class="alert-rule-item__time">
|
||||
{{trigger.age && "for " + trigger.age}}
|
||||
</span>
|
||||
<span class="zbx-description"
|
||||
ng-if="ctrl.panel.descriptionField && !ctrl.panel.descriptionAtNewLine"
|
||||
ng-bind-html="trigger.comments">
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<!-- If description at the new line -->
|
||||
<div class="alert-rule-item__text"
|
||||
ng-if="trigger.comments && ctrl.panel.descriptionField && ctrl.panel.descriptionAtNewLine">
|
||||
<span class="alert-rule-item__info zbx-description zbx-description--newline"
|
||||
ng-bind-html="trigger.comments">
|
||||
</span>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Datasource name -->
|
||||
<div class="alert-rule-item__time zabbix-trigger-source" ng-if="ctrl.panel.datasources.length > 1">
|
||||
<span>
|
||||
<i class="fa fa-database"></i>
|
||||
{{trigger.datasource}}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="alert-rule-item__time zbx-trigger-lastchange">
|
||||
<span>{{trigger.lastchange || "last change unknown"}}</span>
|
||||
|
||||
<div class="trigger-info-block zbx-status-icons">
|
||||
<a ng-if="trigger.url" href="{{trigger.url}}" target="_blank">
|
||||
<i class="fa fa-external-link"></i>
|
||||
</a>
|
||||
|
||||
<span ng-if="trigger.state === '1'" bs-tooltip="'{{trigger.error}}'">
|
||||
<i class="fa fa-question-circle"></i>
|
||||
</span>
|
||||
|
||||
<ack-tooltip ng-if="trigger.lastEvent" ack="trigger.acknowledges" trigger="trigger"
|
||||
on-ack="ctrl.acknowledgeTrigger" context="ctrl">
|
||||
</ack-tooltip>
|
||||
</div>
|
||||
</div>
|
||||
</li>
|
||||
</ol>
|
||||
</section>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="triggers-panel-footer"></div>
|
||||
223
dist/panel-triggers/partials/options_tab.html
vendored
@@ -1,223 +0,0 @@
|
||||
<div class="editor-row">
|
||||
<div class="section gf-form-group">
|
||||
<h5 class="section-heading">Show fields</h5>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Host name"
|
||||
checked="ctrl.panel.hostField"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Technical name"
|
||||
checked="ctrl.panel.hostTechNameField"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Host groups"
|
||||
checked="ctrl.panel.hostGroups"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Tags"
|
||||
checked="ctrl.panel.showTags"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Status"
|
||||
checked="ctrl.panel.statusField"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Severity"
|
||||
checked="ctrl.panel.severityField"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-9"
|
||||
label="Description"
|
||||
checked="ctrl.panel.descriptionField"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form" ng-if="ctrl.panel.descriptionField"
|
||||
label-class="width-9"
|
||||
label="At the new line"
|
||||
checked="ctrl.panel.descriptionAtNewLine"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
|
||||
<div class="section gf-form-group">
|
||||
<h5 class="section-heading">Options</h5>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-15"
|
||||
label="Show hosts in maintenance"
|
||||
checked="ctrl.panel.hostsInMaintenance"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-8">Acknowledged</label>
|
||||
<div class="gf-form-select-wrapper width-12">
|
||||
<select class="gf-form-input"
|
||||
ng-model="ctrl.panel.showTriggers"
|
||||
ng-options="f for f in editor.ackFilters"
|
||||
ng-change="ctrl.refresh()">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-8">Sort by</label>
|
||||
<div class="gf-form-select-wrapper width-12">
|
||||
<select class="gf-form-input"
|
||||
ng-model="ctrl.panel.sortTriggersBy"
|
||||
ng-options="f.text for f in editor.sortByFields track by f.value"
|
||||
ng-change="ctrl.render()">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-8">Show events</label>
|
||||
<div class="gf-form-select-wrapper width-12">
|
||||
<select class="gf-form-input"
|
||||
ng-model="ctrl.panel.showEvents"
|
||||
ng-options="f.text for f in editor.showEventsFields track by f.value"
|
||||
ng-change="ctrl.refresh()">
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-8">Limit triggers</label>
|
||||
<input class="gf-form-input width-5"
|
||||
type="number" placeholder="100"
|
||||
ng-model="ctrl.panel.limit"
|
||||
ng-model-onblur ng-change="ctrl.refresh()">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section gf-form-group">
|
||||
<h5 class="section-heading">View options</h5>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-10">Font size</label>
|
||||
<div class="gf-form-select-wrapper max-width-8">
|
||||
<select class="gf-form-input"
|
||||
ng-model="ctrl.panel.fontSize"
|
||||
ng-options="f for f in editor.fontSizes"
|
||||
ng-change="ctrl.render()"></select>
|
||||
</div>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-10">Page size</label>
|
||||
<input class="gf-form-input width-8"
|
||||
type="number" placeholder="10"
|
||||
ng-model="ctrl.panel.pageSize"
|
||||
ng-model-onblur ng-change="ctrl.render()">
|
||||
</div>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-10"
|
||||
label="Highlight background"
|
||||
checked="ctrl.panel.highlightBackground"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-10"
|
||||
label="Highlight new events"
|
||||
checked="ctrl.panel.highlightNewEvents"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-10">Newer than</label>
|
||||
<input class="gf-form-input width-8" placeholder="1h"
|
||||
ng-model="ctrl.panel.highlightNewerThan"
|
||||
ng-model-onblur ng-change="ctrl.render()">
|
||||
</div>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-16"
|
||||
label="Custom Last change format"
|
||||
checked="ctrl.panel.customLastChangeFormat"
|
||||
on-change="ctrl.render()">
|
||||
</gf-form-switch>
|
||||
<div class="gf-form" ng-if="ctrl.panel.customLastChangeFormat">
|
||||
<label class="gf-form-label width-3">
|
||||
<a href="http://momentjs.com/docs/#/displaying/format/" target="_blank">
|
||||
<tip>See moment.js dosc for time format.</tip>
|
||||
</a>
|
||||
</label>
|
||||
<input class="gf-form-input width-18"
|
||||
type="text"
|
||||
placeholder="dddd, MMMM Do YYYY, h:mm:ss a"
|
||||
empty-to-null
|
||||
ng-model-onblur
|
||||
ng-model="ctrl.panel.lastChangeFormat"
|
||||
ng-change="ctrl.render()">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="section gf-form-group">
|
||||
<h5 class="section-heading">Triggers severity and colors</h5>
|
||||
<div class="gf-form-inline" ng-repeat="trigger in ctrl.panel.triggerSeverity">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-3">{{ trigger.priority }}</label>
|
||||
<label class="gf-form-label triggers-severity-config"
|
||||
ng-style="{color: trigger.color}">
|
||||
<i class="icon-gf" ng-class="ctrl.getAlertIconClassBySeverity(trigger)"></i>
|
||||
</label>
|
||||
<input type="text"
|
||||
class="gf-form-input width-12"
|
||||
empty-to-null
|
||||
ng-model="trigger.severity"
|
||||
ng-model-onblur
|
||||
ng-change="ctrl.render()">
|
||||
<span class="gf-form-label">
|
||||
<spectrum-picker ng-model="trigger.color" ng-change="ctrl.render()"></spectrum-picker>
|
||||
</span>
|
||||
</div>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-0"
|
||||
label="Show"
|
||||
checked="trigger.show"
|
||||
on-change="ctrl.refresh()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-3"> </label>
|
||||
<label class="gf-form-label triggers-severity-config"
|
||||
ng-style="{color: ctrl.panel.ackEventColor}">
|
||||
<i class="icon-gf icon-gf-online"></i>
|
||||
</label>
|
||||
<label class="gf-form-label width-12">
|
||||
Acknowledged color
|
||||
</label>
|
||||
<span class="gf-form-label">
|
||||
<spectrum-picker ng-model="ctrl.panel.ackEventColor" ng-change="ctrl.render()"></spectrum-picker>
|
||||
</span>
|
||||
</div>
|
||||
<gf-form-switch class="gf-form"
|
||||
label-class="width-0"
|
||||
label="Show"
|
||||
checked="ctrl.panel.markAckEvents"
|
||||
on-change="ctrl.refresh()">
|
||||
</gf-form-switch>
|
||||
</div>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-3"> </label>
|
||||
<label class="gf-form-label triggers-severity-config"
|
||||
ng-style="{color: ctrl.panel.okEventColor}">
|
||||
<i class="icon-gf icon-gf-online"></i>
|
||||
</label>
|
||||
<label class="gf-form-label width-12">
|
||||
OK event color
|
||||
</label>
|
||||
<span class="gf-form-label">
|
||||
<spectrum-picker ng-model="ctrl.panel.okEventColor" ng-change="ctrl.render()"></spectrum-picker>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
90
dist/panel-triggers/partials/triggers_tab.html
vendored
@@ -1,90 +0,0 @@
|
||||
<div class="editor-row">
|
||||
<div class="section gf-form-group">
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label width-9">Data sources</label>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<datasource-selector
|
||||
datasources="ctrl.panel.datasources"
|
||||
options="editor.panelCtrl.available_datasources"
|
||||
on-change="editor.datasourcesChanged()">
|
||||
</datasource-selector>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="editor-row" ng-repeat="ds in ctrl.panel.datasources">
|
||||
<div class="section gf-form-group">
|
||||
<h5 class="section-heading">{{ ds }}</h5>
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Group</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.panel.targets[ds].group.filter"
|
||||
bs-typeahead="editor.getGroupNames[ds]"
|
||||
ng-blur="editor.parseTarget()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].group.filter),
|
||||
'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].group.filter)
|
||||
}">
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">Host</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.panel.targets[ds].host.filter"
|
||||
bs-typeahead="editor.getHostNames[ds]"
|
||||
ng-blur="editor.parseTarget()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].host.filter),
|
||||
'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].host.filter)
|
||||
}">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="gf-form-inline">
|
||||
<div class="gf-form max-width-20">
|
||||
<label class="gf-form-label query-keyword width-7">Application</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.panel.targets[ds].application.filter"
|
||||
bs-typeahead="editor.getApplicationNames[ds]"
|
||||
ng-blur="editor.parseTarget()"
|
||||
data-min-length=0
|
||||
data-items=100
|
||||
class="gf-form-input"
|
||||
ng-class="{
|
||||
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].application.filter),
|
||||
'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].application.filter)
|
||||
}">
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">Trigger</label>
|
||||
<input type="text"
|
||||
ng-model="ctrl.panel.targets[ds].trigger.filter"
|
||||
ng-blur="editor.parseTarget()"
|
||||
placeholder="trigger name"
|
||||
class="gf-form-input"
|
||||
ng-style="ctrl.panel.targets[ds].trigger.style"
|
||||
ng-class="{
|
||||
'zbx-variable': editor.isVariable(ctrl.panel.targets[ds].trigger.filter),
|
||||
'zbx-regex': editor.isRegex(ctrl.panel.targets[ds].trigger.filter)
|
||||
}"
|
||||
empty-to-null>
|
||||
</div>
|
||||
<div class="gf-form">
|
||||
<label class="gf-form-label query-keyword width-7">Tags</label>
|
||||
<input type="text" class="gf-form-input"
|
||||
ng-model="ctrl.panel.targets[ds].tags.filter"
|
||||
ng-blur="editor.parseTarget()"
|
||||
placeholder="tag1:value1, tag2:value2">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
12
dist/panel-triggers/plugin.json
vendored
@@ -1,12 +0,0 @@
|
||||
{
|
||||
"type": "panel",
|
||||
"name": "Zabbix Triggers",
|
||||
"id": "alexanderzobnin-zabbix-triggers-panel",
|
||||
|
||||
"info": {
|
||||
"author": {
|
||||
"name": "Alexander Zobnin",
|
||||
"url": "https://github.com/alexanderzobnin/grafana-zabbix"
|
||||
}
|
||||
}
|
||||
}
|
||||
77
dist/panel-triggers/specs/migrations.spec.js
vendored
@@ -1,77 +0,0 @@
|
||||
import _ from 'lodash';
|
||||
import {TriggerPanelCtrl} from '../triggers_panel_ctrl';
|
||||
import {DEFAULT_TARGET, DEFAULT_SEVERITY, PANEL_DEFAULTS} from '../triggers_panel_ctrl';
|
||||
import {CURRENT_SCHEMA_VERSION} from '../migrations';
|
||||
|
||||
describe('Triggers Panel schema migration', () => {
|
||||
let ctx = {};
|
||||
let datasourceSrvMock = {
|
||||
getMetricSources: () => {
|
||||
return [{ meta: {id: 'alexanderzobnin-zabbix-datasource'}, value: {}, name: 'zabbix_default' }];
|
||||
},
|
||||
get: () => Promise.resolve({})
|
||||
};
|
||||
|
||||
let timeoutMock = () => {};
|
||||
|
||||
beforeEach(() => {
|
||||
ctx = {
|
||||
scope: {
|
||||
panel: {
|
||||
datasource: 'zabbix',
|
||||
triggers: DEFAULT_TARGET,
|
||||
hostField: true,
|
||||
statusField: false,
|
||||
severityField: false,
|
||||
lastChangeField: true,
|
||||
ageField: true,
|
||||
infoField: true,
|
||||
limit: 10,
|
||||
showTriggers: 'all triggers',
|
||||
hideHostsInMaintenance: false,
|
||||
sortTriggersBy: { text: 'last change', value: 'lastchange' },
|
||||
showEvents: { text: 'Problems', value: '1' },
|
||||
triggerSeverity: DEFAULT_SEVERITY,
|
||||
okEventColor: 'rgba(0, 245, 153, 0.45)',
|
||||
ackEventColor: 'rgba(0, 0, 0, 0)',
|
||||
scroll: true,
|
||||
pageSize: 10,
|
||||
fontSize: '100%',
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
||||
|
||||
it('should update old panel schema', () => {
|
||||
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, timeoutMock, datasourceSrvMock, {}, {}, {});
|
||||
|
||||
let expected = _.defaultsDeep({
|
||||
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||
datasources: ['zabbix'],
|
||||
targets: {
|
||||
'zabbix': DEFAULT_TARGET
|
||||
},
|
||||
statusField: false,
|
||||
severityField: false,
|
||||
limit: 10,
|
||||
okEventColor: 'rgba(0, 245, 153, 0.45)',
|
||||
ackEventColor: 'rgba(0, 0, 0, 0)'
|
||||
}, PANEL_DEFAULTS);
|
||||
|
||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
||||
});
|
||||
|
||||
it('should create new panel with default schema', () => {
|
||||
ctx.scope.panel = {};
|
||||
let updatedPanelCtrl = new TriggerPanelCtrl(ctx.scope, {}, {}, datasourceSrvMock, {}, {}, {});
|
||||
|
||||
let expected = _.defaultsDeep({
|
||||
schemaVersion: CURRENT_SCHEMA_VERSION,
|
||||
datasources: ['zabbix_default'],
|
||||
targets: {
|
||||
'zabbix_default': DEFAULT_TARGET
|
||||
}
|
||||
}, PANEL_DEFAULTS);
|
||||
expect(updatedPanelCtrl.panel).toEqual(expected);
|
||||
});
|
||||
});
|
||||