-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathzabbix.ino
47 lines (35 loc) · 842 Bytes
/
zabbix.ino
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
bool initZabbix() {
StaticJsonBuffer<50> tmp;
zJson["request"] = "sender data";
zJson["data"] = tmp.createArray();
}
bool addZabbixItem(char *k, char *value) {
StaticJsonBuffer<100> itemBuff;
JsonObject& item = itemBuff.createObject();
item["host"] = Config.hostname;
item["key"] = k;
item["value"] = value;
zData.add(item);
}
bool sendZabbix() {
char packet[512];
int length;
zJson.printTo(packet);
if (zClient.connect(Config.zabbix_server, Config.zabbix_port)) {
length = zJson.measureLength();
zJson.printTo(packet,length);
zClient.write((char *) packet, length);
for (int i = 0; i < ZABBIX_TIMEOUT / 10; i++) {
if (zClient.available()) {
return(1);
}
delay(10);
}
} else {
return(0);
}
}
bool zabbixLoopStart() {
}
bool zabbixLoopEnd() {
}