Writing data to telegraf

Hi,
Am collecting some data via perl script from a cisco router. When I tried to run this perl directly am getting my output but when i try to run via telegraf am getting error. The issue is i believe with writing data or data format. Am not sure how to write my output to influx exactly. If any have any idea please suggest. Please see below screen shots
direct perl out put:
image
from telegraf:

root@danish-PowerEdge-1950:/etc/telegraf/telegraf.d# telegraf --test --config DMVPN.conf
2021-02-23T12:42:05Z I! Starting Telegraf 1.15.3
2021-02-23T12:42:05Z E! [inputs.exec] Error in plugin: metric parse error: expected field at 1:10: “TUNNEL IP, SIM IP”
2021-02-23T12:42:05Z E! [telegraf] Error running agent: input plugins recorded 1 errors
root@danish-PowerEdge-1950:/etc/telegraf/telegraf.d#

telegraf exec:

[[inputs.exec]]
commands = [“perl /etc/telegraf/telegraf.d/HEX2.pl”]
data_format = “influx”
interval = “60s”
timeout = “5s”

Output Plugin InfluxDB

[[outputs.influxdb]]
database = “telegraf”
urls = [ “http://127.0.0.1:8086” ]
username = “telegraf”
password = “telegraf”

The problem is that the output from your Perl script does not conform to the influx line protocol (which you set with the data_format = "influx" in the config file).

The format of the influx line protocol is described here:

https://docs.influxdata.com/telegraf/v1.17/data_formats/input/influx/

There would also be other input formats that Telegraf accepts as input format by default.
All currently possible input formats can be found here:

https://docs.influxdata.com/telegraf/v1.17/data_formats/input/

i tired different data formats, but nothing is working, can you please suggest what format can i use or what changes in plerl script need to be changed inorder to take influx data format?

You just need to adapt the Perl script to produce an output that is compatible with one of the Telegraf input formats.

As @Franky1 said, you’d need the Perl script to write line-protocol to STDOUT.

If you can share the code of the script, I could help you with that

Here is my code

root@danish-PowerEdge-1950:/etc/telegraf/telegraf.d# cat HEX4.pl
#use strict;
#use Shell qw(lynx);

my @myarr1=qx(snmpwalk -v2c -c ‘47sky!Direct11’ 10.13.4.201 1.3.6.1.2.1.71.1.3.3.1.4);

#$myarr1=@myarr1;
#print “$myarr\n”;

my @lines = @myarr1;

foreach (my $i=0; i <= #lines; $i++) {
my @ip1 = split / /, $lines[$i];
my @ip11 = chomp($ip1[6]);
print “Tunnel_IP :” .hex($ip1[3]).".".hex($ip1[4]).".".hex($ip1[5]).".".hex($ip1[6]);
print “\n”;
};

OUTPUT from perl
image

I managed to write it to influx via telegraf but result was not as I expected. Am getting only one timestamp for all the entries. Is it possible to time stamp for all my entries ?

telegraf conf
GNU nano 2.9.3 DMVPN.conf

[[inputs.exec]]
commands = [“perl /etc/telegraf/telegraf.d/HEX4.pl”]
data_format = “value”
data_type = “string”
interval = “60s”
timeout = “5s”

Output Plugin InfluxDB

[[outputs.influxdb]]
database = “telegraf”
urls = [ “http://127.0.0.1:8086” ]
username = “telegraf”
password = “telegraf”

telegraf output

image