Advertisement
poodad

Write to InfluxDB

May 29th, 2024
1,187
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.46 KB | None | 0 0
  1. use LWP::UserAgent;
  2. use HTTP::Request::Common qw(POST GET DELETE);
  3.  
  4. sub WriteInflux {
  5.     my $server = shift;
  6.     my $db = shift;
  7.     my @dat = @_;
  8.    
  9.     my $body = join "\n", @dat;
  10.    
  11.     my $url = "http://$server:8086/write?db=$db&precision=s";
  12.    
  13.     my $ua = LWP::UserAgent->new;
  14.     my $req = (POST $url, Content=>$body);
  15.     my $res = $ua->request($req);
  16.    
  17.     print "code: ", $res->code, "\n";
  18.     print "content: ", $res->content, "\n";
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement