Thanks to Evengy Levkov,
I made some modifications in the code , made it more basics , this was tested with arduino uno and
5100 ethernet shield.
here the source :
//*****************************************************************************************
//* Purpose : Zabbix Sensor Agent - Environmental Monitoring Solution *
//* Author : Evgeny Levkov *
//* Adapted to basics : Schotte Vincent *
//* Credits: *
//-----------------INCLUDES--------------------
#include <SPI.h>
#include <Ethernet.h>
//--------------------------------------------
#define MAX_CMD_LENGTH 25
//--------------------------------------------
byte mac[] = { 0x90, 0xA2, 0xDA, 0x00, 0xE3, 0x5B };
IPAddress ip(192, 168, 1, 93);
IPAddress gateway(192, 168, 1, 1);
IPAddress subnet(255, 255, 255, 0);
EthernetServer server = EthernetServer(10050); //Zabbix Agent port //Zabbix agent port
EthernetClient client;
boolean connected = false;
//--------------------------------------------
//--------------------------------------------
String cmd; //FOR ZABBIX COMMAND
int led = 2; //LED PORT TO BLINK AFTER RECIEVING ZABBIX COMMAND
int counter = 1; // For testing
//--------------------------------------------
void setup()
{
Ethernet.begin(mac, ip, gateway, subnet);
server.begin();
pinMode(led, OUTPUT);
digitalWrite(led, LOW);
}
void loop()
{
//--------------------------------------------
client = server.available();
if (client == true) {
if (!connected) {
client.flush();
connected = true;
}
if (client.available() > 0) {
readTelnetCommand(client.read());
}
}
}
//--------------------------------------------
void readTelnetCommand(char c) {
if(cmd.length() == MAX_CMD_LENGTH) {
cmd = "";
}
cmd += c;
if(c == '\n') {
if(cmd.length() > 2) {
// remove \r and \n from the string
cmd = cmd.substring(0,cmd.length() - 1);
parseCommand();
}
}
}
//--------------------------------------------
void parseCommand() { //Commands recieved by agent on port 10050 parsing
counter = counter + 1;
// AGENT ping
if(cmd.equals("ping")) {
server.println("1");
client.stop();
// connected = false;
// AGENT version
} else if(cmd.equals("version")) {
server.println("ArduinZabbixVini.1.0");
client.stop();
// connected = false;
// AGENT sensor1
} else if(cmd.equals("sensor1")) {
float h = 99;
server.println(h);
client.stop();
// AGENT sensor2
} else if(cmd.equals("sensor2")) {
float t = 20;
server.println(t );
client.stop();
}
// AGENT counter
else if(cmd.equals("counter")) {
float t = 20;
server.println(counter );
client.stop();
// NOT SUPPORTED
} else {
// server.println("ZBXDZBX_NOTSUPPORTED");
server.println(cmd);
client.stop();
}
cmd = "";
}
//--------------------------------------------
In Zabbix just do the following ;
- configure a host with ip address of the sketch example arduino3 with ip 192.168.1.93
- configure you're items like following
Host arduino3
Description Temperature sensor1
Type zabbix agent
Key sensor1 // as in the sketch
Type of information numeric float
Have fun