M
M
Michael2018-12-23 18:34:36
Perl
Michael, 2018-12-23 18:34:36

How to change the type of information in zabbix_sender?

I want to set up to send zabbix trapp from a remote linux machine.
The script should send an integer decimal number to zabbix server.
As a result, the sending occurs, but the zabbix server sees the value only as text, and I need the server to see it as a 64-bit integer.

spoiler

sub zabbix_sender
{
my ($zabbixserver,$hostname,$item,$data) = @_;
my $timeout=10;
print "$data\n";
my $request=sprintf("\n%s\n%s\n%s\n\n",
encode_base64($hostname),encode_base64($item),encode_base64($data));
my $sock = new IO::Socket::INET ( PeerAddr => $zabbixserver, PeerPort => '10051', Proto => 'tcp', Timeout => $timeout);
die "Could not create socket: [email protected]\n" unless $sock;
$sock->send($request);
my @handles=IO::Select->new($sock)->can_read($timeout);
if (scalar(@handles) > 0)
{
$sock->recv($result,1024);
# print "answer from zabbix server $zabbixserver: $result\n";
}
else
{
print "no answer from zabbix server\n";
}
$sock->close();
}

Do I need to change the data format somehow?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
TyzhSysAdmin, 2018-12-23
@POS_troi

How Zabix will process the received data depends on the template.
Rather than stir up your crutches, it's better to take the standard zabbix_sender.
https://www.zabbix.com/documentation/3.0/en/manual...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question