forked from bashlakov/node-red-contrib-zabbix-sender
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathzabbix-sender.html
116 lines (111 loc) · 4.33 KB
/
zabbix-sender.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<script type="text/x-red" data-template-name="zabbix-sender">
<div class="form-row">
<label for="node-input-name"><i class="icon-tag"></i>Node name</label>
<input type="text" id="node-input-name" placeholder="Name">
</div>
<div class="form-row">
<label for="node-input-zabbixServer">Zabbix server</label>
<input type="text" id="node-input-zabbixServer" placeholder="Zabbix server address">
</div>
<div class="form-row">
<label for="node-input-zabbixPort">Zabbix port</label>
<input type="text" id="node-input-zabbixPort" placeholder="Default to 10051">
</div>
<div class="form-row">
<input type="checkbox" id="node-input-customTimestamps" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-customTimestamps" style="width: 70%;">Send custom timestamps</label>
</div>
<div class="form-row">
<input class="node-input-sendTimestamps" type="checkbox" id="node-input-sendTimestamps" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-sendTimestamps" style="width: 70%;">Send current timestamps</label>
</div>
<div class="node-input-sendTimestamps-row hide">
<div class="form-row">
<input type="checkbox" id="node-input-withNs" style="display: inline-block; width: auto; vertical-align: top;">
<label for="node-input-withNs" style="width: 70%;">With ns precision</label>
</div>
</div>
<div class="form-row">
<label for="node-input-timeout">Timeout</label>
<input type="text" id="node-input-timeout" placeholder="Default to 5000">
</div>
<div class="form-row">
<label for="node-input-defaultHostname">Default hostname</label>
<input type="text" id="node-input-defaultHostname" placeholder="Can be overrided in msg, default to os.hostname">
</div>
</script>
<script type="text/x-red" data-help-name="zabbix-sender">
<p>Sends items data to Zabbix using the zabbix trapper protocol.</p>
<h3>Details</h3>
<p>This node is the wrapper around <a href=https://www.npmjs.com/package/node-zabbix-sender>node-zabbix-sender</a> library.</p>
<p>To send simple item data, send message with following payload:</p>
<pre>
msg.payload = [
"webserver",
"httpd.running",
0
]</pre>
<p>You can set default hostname in node settings, then you can send just item name and value:</p>
<pre>
msg.payload = [
"httpd.running",
0
]</pre>
<p>You can also send multiple items at once, just construct payload as array of arrays:</p>
<pre>
msg.payload = [
[
"dbserver",
"mysql.ping",
1
],
[
"webserver",
"httpd.running",
0
]
]</pre>
</script>
<script type="text/javascript">
RED.nodes.registerType("zabbix-sender", {
category: "output",
color: "#e00000",
defaults: {
zabbixServer: { value: "127.0.0.1", required: true },
zabbixPort: { value: 10051},
sendTimestamps: { value: false},
withNs: { value: false},
customTimestamps: { value: false},
timeout: { value: 5000},
defaultHostname: { value: ""}
},
inputs: 1,
outputs: 0,
icon: "zabbix.png",
align: "right",
label: function () {
return this.name || "zabbix-sender"
},
oneditprepare: function() {
$("#node-input-sendTimestamps").change(function() {
if ($(this).is(":checked")) {
$(".node-input-sendTimestamps-row").show();
} else {
$(".node-input-sendTimestamps-row").hide();
}
});
$("#node-input-customTimestamps").change(function() {
if ($(this).is(":checked")) {
$(".node-input-sendTimestamps-row").show();
$(".node-input-sendTimestamps").prop('disabled', true);
} else {
if (!$("#node-input-sendTimestamps").is(":checked")){
$(".node-input-sendTimestamps-row").hide();
}
$(".node-input-sendTimestamps").prop('disabled', false);
}
});
$("#node-input-useAuth").change();
}
})
</script>