InfluxDB-LineProtocol-1.014/0000755000175000017500000000000013776141735014271 5ustar dommdommInfluxDB-LineProtocol-1.014/dist.ini0000644000175000017500000000012013776141735015726 0ustar dommdommname = InfluxDB-LineProtocol copyright_year = 2016 - 2021 [@Author::DOMM] InfluxDB-LineProtocol-1.014/META.json0000644000175000017500000000361613776141735015720 0ustar dommdomm{ "abstract" : "Write and read InfluxDB LineProtocol", "author" : [ "Thomas Klausner " ], "dynamic_config" : 0, "generated_by" : "Dist::Zilla version 6.017, CPAN::Meta::Converter version 2.150010", "license" : [ "perl_5" ], "meta-spec" : { "url" : "http://search.cpan.org/perldoc?CPAN::Meta::Spec", "version" : 2 }, "name" : "InfluxDB-LineProtocol", "no_index" : { "directory" : [ "examples", "t", "xt" ] }, "prereqs" : { "build" : { "requires" : { "Module::Build" : "0.28" } }, "configure" : { "requires" : { "Module::Build" : "0.28" } }, "runtime" : { "requires" : { "Carp" : "0", "Time::HiRes" : "0" } }, "test" : { "requires" : { "File::Spec" : "0", "File::Temp" : "0", "IO::Handle" : "0", "IPC::Open3" : "0", "Test::More" : "0", "Test::Most" : "0", "lib" : "0", "perl" : "5.012" } } }, "provides" : { "InfluxDB::LineProtocol" : { "file" : "lib/InfluxDB/LineProtocol.pm", "version" : "1.014" } }, "release_status" : "stable", "resources" : { "bugtracker" : { "web" : "https://github.com/domm/InfluxDB-LineProtocol/issues" }, "homepage" : "https://github.com/domm/InfluxDB-LineProtocol", "repository" : { "type" : "git", "url" : "https://github.com/domm/InfluxDB-LineProtocol.git", "web" : "https://github.com/domm/InfluxDB-LineProtocol" } }, "version" : "1.014", "x_generated_by_perl" : "v5.32.0", "x_serialization_backend" : "Cpanel::JSON::XS version 4.25", "x_spdx_expression" : "Artistic-1.0-Perl OR GPL-1.0-or-later" } InfluxDB-LineProtocol-1.014/cpanfile0000644000175000017500000000112613776141735015775 0ustar dommdomm# This file is generated by Dist::Zilla::Plugin::CPANFile v6.017 # Do not edit this file directly. To change prereqs, edit the `dist.ini` file. requires "Carp" => "0"; requires "Time::HiRes" => "0"; on 'build' => sub { requires "Module::Build" => "0.28"; }; on 'test' => sub { requires "File::Spec" => "0"; requires "File::Temp" => "0"; requires "IO::Handle" => "0"; requires "IPC::Open3" => "0"; requires "Test::More" => "0"; requires "Test::Most" => "0"; requires "lib" => "0"; requires "perl" => "5.012"; }; on 'configure' => sub { requires "Module::Build" => "0.28"; }; InfluxDB-LineProtocol-1.014/README.md0000644000175000017500000001133513776141735015553 0ustar dommdomm# NAME InfluxDB::LineProtocol - Write and read InfluxDB LineProtocol # VERSION version 1.014 # SYNOPSIS use InfluxDB::LineProtocol qw(data2line line2data); # convert some Perl data into InfluxDB LineProtocol my $influx_line = data2line('measurement', 42); my $influx_line = data2line('measurement', { cost => 42 }); my $influx_line = data2line('measurement', 42, { tag => 'foo'} ); # convert InfluxDB Line back into Perl my ($measurement, $values, $tags, $timestamp) = line2data("metric,location=eu,server=srv1 value=42 1437072299900001000"); # DESCRIPTION [InfluxDB](https://influxdb.com) is a rather new time series database. Since version 0.9 they use their [LineProtocol](https://influxdb.com/docs/v0.9/write_protocols/line.html) to write time series data into the database. This module allows you to generate such a line from a datastructure, handling all the annoying escaping and sorting for you. You can also use it to parse a line (maybe you want to add some tags to a line written by another app). Please read the InfluxDB docs so you understand how metrics, values and tags work. `InfluxDB::LineProtocol` will always try to implement the most current version of the InfluxDB line protocol, while allowing you to also get the old behaviour. Currently we support `0.9.3` and newer per default, and `0.9.2` if you ask nicely. ## FUNCTIONS ### data2line data2line($metric, $single_value); data2line($metric, $values_hashref); data2line($metric, $value, $tags_hashref); data2line($metric, $value, $nanoseconds); data2line($metric, $value, $tags_hashref, $nanoseconds); `data2line` takes various parameters and converts them to an InfluxDB Line. `metric` has to be valid InfluxDB measurement name. Required. `value` can be either a scalar, which will be turned into "value=$value"; or a hashref, if you want to write several values (or a value with another name than "value"). Required. `tags_hashref` is an optional hashref of tag-names and tag-values. `nanoseconds` is an optional integer representing nanoseconds since the epoch. If you do not pass it, `InfluxDB::LineProtocol` will use `Time::HiRes` to get the current timestamp. ### line2data my ($metric, $value_hashref, $tags_hashref, $timestamp) = line2data( $line ); `line2data` parses an InfluxDB line and always returns 4 values. `tags_hashref` is undef if there are no tags! # PRECISION InfluxDB support different timestamp precisions: Nanosecond (ns, the default), microseconds (us), milliseconds (ms), seconds (s), minutes (m) and hours (h). If you do not want to generate lines using nanoseconds (which might be a good idea, because InfluxDB uses less space and has better performance if you choose a smaller precision), you can specify the wanted precision on load of `InfluxDB::LineProtocol`: use InfluxDB::LineProtocol->import(qw(data2line precision=ms)); Please note that yo have to tell InfluxDB the precision when posting lines to `/write`! # LOADING LEGACY PROTOCOL VERSIONS To use an old version of the line protocol, specify the version you want when loading `InfluxDB::LineProtocol`: use InfluxDB::LineProtocol qw(v0.9.2 data2line); You will get a version of `data2line` that conforms to the `0.9.2` version of the line protocol. Currently supported version are: - 0.9.3 and newer default, no need to specify anything - 0.9.2 load via `v0.9.2` # TODO - check if tag sorting algorithm matches [http://golang.org/pkg/bytes/#Compare](http://golang.org/pkg/bytes/#Compare) # SEE ALSO - [InfluxDB](https://metacpan.org/pod/InfluxDB) provides access to the old 0.8 API. It also allows searching etc. - [AnyEvent::InfluxDB](https://metacpan.org/pod/AnyEvent::InfluxDB) - An asynchronous library for InfluxDB time-series database. Does not implement escaping etc, so if you want to use AnyEvent::InfluxDB to send data to InfluxDB you can use InfluxDB::LineProtocol to convert your measurement data structure before sending it via AnyEvent::InfluxDB. # THANKS Thanks to - [validad.com](http://www.validad.com/) for funding the development of this code. - [Jose Luis Martinez](https://github.com/pplu) for implementing negative & exponential number support and pointing out the change in the line protocol in 0.9.3. - [mvgrimes](https://github.com/mvgrimes) for fixing a bug when nanosecond timestamps cause some Perls to render the timestamp in scientific notation. - [Adrian Popa](https://github.com/mad-ady) for fixing a bug when handling large scientific notation data. # AUTHOR Thomas Klausner # COPYRIGHT AND LICENSE This software is copyright (c) 2016 - 2021 by Thomas Klausner. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. InfluxDB-LineProtocol-1.014/Changes0000644000175000017500000000413713776141735015571 0ustar dommdommChanges for InfluxDB::LineProtocol 1.014 2021-01-08 21:43:06+01:00 - work around scientific notation problems reported in some tester results? 1.013 2021-01-03 16:55:02+01:00 - dist housekeeping: github issues, Dist::Zilla::PluginBundle::Author::DOMM 1.012 2020-05-12T14:48:25 - Bugfix encoding for big floats (fixes #14) (Adrian Popa) 1.011 2018-10-31T17:30:56 - Made TODO entry clickable. (Mohammad S Anwar) 1.010 2018-06-19T13:07:50 - it seems 1.009 was already published on CPAN, so another VERSION bump 1.009 2018-06-19T12:30:45 - do not escape backlash in very old legacy protocol 0.9.2 (Thomas Klausner) - fixed wrong escape sequence (APA-IT, Mario Paumann) https://github.com/domm/InfluxDB-LineProtocol/pull/12 - Fix spelling mistakes (Guillem Jover) - Add minimum perl version using dzil plugin [MinimumPerl] (Mohammad S Anwar) 1.008 2016-09-06T15:05:31 - clean up git mess (Thomas Klausner) 1.007 2016-01-26T11:55:55 - feat(extract) formatting methods - add precision support (Thomas Klausner) 1.006 2015-11-18T08:42:31 - fix(typo) (Thomas Klausner) - Ignore and do not send undefined values (koki) - Fixes padding bug in the creation of nanosecond timestamps (Mark Grimes) 1.005 2015-09-24T00:15:06 - handle old (0.9.2) version of line protocol (Thomas Klausner, spotted by Jose Luis Martinez) - Bug fix: Ensures timestamp won't be converted to scientific notation (Mark Grimes) 1.004 2015-08-03T23:09:51 - field value escaping - more tests - skip negative exponent test on MSWin32 - make boolean regex work with older perls 1.003 2015-08-02 12:38:56 - support for boolean values - added SEE-ALSO link to AnyEvent-InfluxDB - support for exponential numbers (Jose Luis Martinez) 1.002 2015-07-30T14:01:47 - support for negative numbers (Jose Luis Martinez) 1.001 2015-07-26T17:54:04 - tests require Perl 5.12 - fix some typos in docs 1.000 2015-07-22T12:27:45 - first internal release - extracted code from Validad internal tools InfluxDB-LineProtocol-1.014/INSTALL0000644000175000017500000000437113776141735015327 0ustar dommdommThis is the Perl distribution InfluxDB-LineProtocol. Installing InfluxDB-LineProtocol is straightforward. ## Installation with cpanm If you have cpanm, you only need one line: % cpanm InfluxDB::LineProtocol If it does not have permission to install modules to the current perl, cpanm will automatically set up and install to a local::lib in your home directory. See the local::lib documentation (https://metacpan.org/pod/local::lib) for details on enabling it in your environment. ## Installing with the CPAN shell Alternatively, if your CPAN shell is set up, you should just be able to do: % cpan InfluxDB::LineProtocol ## Manual installation As a last resort, you can manually install it. Download the tarball, untar it, install configure prerequisites (see below), then build it: % perl Build.PL % ./Build && ./Build test Then install it: % ./Build install Or the more portable variation: % perl Build.PL % perl Build % perl Build test % perl Build install If your perl is system-managed, you can create a local::lib in your home directory to install modules to. For details, see the local::lib documentation: https://metacpan.org/pod/local::lib The prerequisites of this distribution will also have to be installed manually. The prerequisites are listed in one of the files: `MYMETA.yml` or `MYMETA.json` generated by running the manual build process described above. ## Configure Prerequisites This distribution requires other modules to be installed before this distribution's installer can be run. They can be found under the or the "{prereqs}{configure}{requires}" key of META.json. ## Other Prerequisites This distribution may require additional modules to be installed after running Build.PL. Look for prerequisites in the following phases: * to run ./Build, PHASE = build * to use the module code itself, PHASE = runtime * to run tests, PHASE = test They can all be found in the or the "{prereqs}{PHASE}{requires}" key of MYMETA.json. ## Documentation InfluxDB-LineProtocol documentation is available as POD. You can run `perldoc` from a shell to read the documentation: % perldoc InfluxDB::LineProtocol For more information on installing Perl modules via CPAN, please see: https://www.cpan.org/modules/INSTALL.html InfluxDB-LineProtocol-1.014/lib/0000755000175000017500000000000013776141735015037 5ustar dommdommInfluxDB-LineProtocol-1.014/lib/InfluxDB/0000755000175000017500000000000013776141735016512 5ustar dommdommInfluxDB-LineProtocol-1.014/lib/InfluxDB/LineProtocol.pm0000644000175000017500000003203413776141735021463 0ustar dommdommpackage InfluxDB::LineProtocol; use strict; use warnings; # ABSTRACT: Write and read InfluxDB LineProtocol our $VERSION = '1.014'; # VERSION use Carp qw(croak); use Time::HiRes qw(gettimeofday); my %versions = ( 'v0.9.2' => '_0_9_2', ); sub import { my $class = shift; my $caller = caller(); my @to_export; my $version; my $precision = 'ns'; foreach my $param (@_) { if ($param eq 'data2line' || $param eq 'line2data') { push(@to_export,$param); } if ($param =~ /^precision=(\w+)$/) { $precision = $1; } if ($param =~ /^v[\d\.]+$/ && $versions{$param}) { $version = $versions{$param}; } } foreach my $function (@to_export) { my $target = $function; $function = '_'.$function.$version if $version; { no strict 'refs'; *{"$caller\::$target"} = \&$function; } } # set up ts_$precision { no strict 'refs'; my $selected = 'ts_'.$precision; *{"$caller\::get_ts"} = \&$selected; } } sub _format_key { my $k = shift; $k =~ s/([, ])/\\$1/g; return $k; } sub _format_value { my $k = shift; my $v = shift; if ( $v =~ /^(-?\d+)(?:i?)$/ ) { $v = $1 . 'i'; } elsif ( $v =~ /^[Ff](?:ALSE|alse)?$/ ) { $v = 'FALSE'; } elsif ( $v =~ /^[Tt](?:RUE|rue)?$/ ) { $v = 'TRUE'; } elsif ( $v =~ /^-?\d+(?:\.\d+)?(?:e(?:-|\+)?\d+)?$/ ) { # pass it on, no mod } else { # string actually, but this should be quoted differently? $v =~ s/(["\\])/\\$1/g; $v = '"' . $v . '"'; } return $v; } sub data2line { my ( $measurement, $values, $tags, $timestamp ) = @_; my $caller = caller(); if ( @_ == 1 ) { # no $fields, so assume we already got a line return $measurement; } my $key = $measurement; $key =~ s/([, ])/\\$1/g; # $tags has to be a hashref, if it's not, we don't have tags, so it's the timestamp if ( defined $tags ) { if ( ref($tags) eq 'HASH' ) { my @tags; foreach my $k ( sort keys %$tags ) { # Influx wants the tags presorted # TODO check if sorting algorithm matches # http://golang.org/pkg/bytes/#Compare my $v = $tags->{$k}; next unless defined $v; $k =~ s/([, ])/\\$1/g; $v =~ s/([, ])/\\$1/g; push( @tags, $k . '=' . $v ); } $key .= join( ',', '', @tags ) if @tags; } elsif ( !ref($tags) ) { $timestamp = $tags; } } $timestamp ||= $caller->get_ts(); croak("$timestamp does not look like an epoch timestamp") unless $timestamp =~ /^\d+$/; # If values is not a hashref, convert it into one $values = { value => $values } if (not ref($values)); my @fields; foreach my $k ( sort keys %$values ) { my $v = $values->{$k}; my $esc_k = _format_key($k); my $esc_v = _format_value($k, $v); push( @fields, $esc_k . '=' . $esc_v ); } my $fields = join( ',', @fields ); return sprintf( "%s %s %s", $key, $fields, $timestamp ); } sub ts_h { my $now = time(); return int $now / 3600; } sub ts_m { my $now = time(); return int $now / 60; } sub ts_s { return scalar time(); } sub ts_ms { my ($s,$us) = gettimeofday(); return sprintf("%s%03d", $s,substr($us,0,3)); } sub ts_us { return sprintf("%s%06d", gettimeofday()); } sub ts_ns { return sprintf("%s%06d000", gettimeofday()); } sub line2data { my $line = shift; chomp($line); $line =~ s/\\ /ESCAPEDSPACE/g; $line =~ s/\\,/ESCAPEDCOMMA/g; $line =~ s/\\"/ESCAPEDDBLQUOTE/g; $line =~ s/\\\\/ESCAPEDBACKSLASH/g; $line=~/^(.*?) (.*) (.*)$/; my ($key, $fields, $timestamp) = ( $1, $2, $3); my ( $measurement, @taglist ) = split( /,/, $key ); $measurement =~ s/ESCAPEDSPACE/ /g; $measurement =~ s/ESCAPEDCOMMA/,/g; my $tags; foreach my $tagset (@taglist) { $tagset =~ s/ESCAPEDSPACE/ /g; $tagset =~ s/ESCAPEDCOMMA/,/g; my ( $k, $v ) = split( /=/, $tagset ); $tags->{$k} = $v; } my $values; my @strings; if ($fields =~ /"/) { my $cnt=0; $fields=~s/"(.*?)"/push(@strings, $1); 'ESCAPEDSTRING_'.$cnt++;/ge; } foreach my $valset ( split( /,/, $fields ) ) { $valset =~ s/ESCAPEDSPACE/ /g; $valset =~ s/ESCAPEDCOMMA/,/g; my ( $k, $v ) = split( /=/, $valset ); $v =~ s/ESCAPEDSTRING_(\d+)/$strings[$1]/ge; $v =~ s/ESCAPEDDBLQUOTE/"/g; $v =~ s/ESCAPEDBACKSLASH/\\/g; $v =~ s/^(-?\d+)i$/$1/; $k =~ s/ESCAPEDBACKSLASH/\\\\/g; $values->{$k} = $v; } return ( $measurement, $values, $tags, $timestamp ); } sub _data2line_0_9_2 { my ( $measurement, $values, $tags, $timestamp ) = @_; if ( @_ == 1 ) { # no $fields, so assume we already got a line return $measurement; } my $key = $measurement; $key =~ s/([, ])/\\$1/g; # $tags has to be a hashref, if it's not, we don't have tags, so it's the timestamp if ( defined $tags ) { if ( ref($tags) eq 'HASH' ) { my @tags; foreach my $k ( sort keys %$tags ) { # Influx wants the tags presorted # TODO check if sorting algorithm matches # http://golang.org/pkg/bytes/#Compare my $v = $tags->{$k}; next unless defined $v; $k =~ s/([, ])/\\$1/g; $v =~ s/([, ])/\\$1/g; push( @tags, $k . '=' . $v ); } $key .= join( ',', '', @tags ) if @tags; } elsif ( !ref($tags) ) { $timestamp = $tags; } } if ($timestamp) { croak("$timestamp does not look like an epoch timestamp") unless $timestamp =~ /^\d+$/; if ( length($timestamp) < 19 ) { my $missing = 19 - length($timestamp); my $zeros = 0 x $missing; $timestamp .= $zeros; } } else { $timestamp = join( '', gettimeofday(), '000' ); $timestamp .= '0' if length($timestamp) < 19; } # If values is not a hashref, convert it into one $values = { value => $values } if (not ref($values)); my @fields; foreach my $k ( sort keys %$values ) { my $v = $values->{$k}; my $esc_k = _format_key($k); if ( # positive & negativ ints, exponentials, use Regexp::Common? $v !~ /^-?\d+(?:\.\d+)?(?:e-?\d+)?$/ && # perl 5.12 Regexp::Assemble->new->add(qw(t T true TRUE f F false FALSE))->re; $v !~ /^(?:F(?:ALSE)?|f(?:alse)?|T(?:RUE)?|t(?:rue)?)$/ ) { $v =~ s/"/\\"/g; $v = '"' . $v . '"'; } push( @fields, $esc_k . '=' . $v ); } my $fields = join( ',', @fields ); return sprintf( "%s %s %s", $key, $fields, $timestamp ); } sub _line2data_0_9_2 { my $line = shift; chomp($line); $line =~ s/\\ /ESCAPEDSPACE/g; $line =~ s/\\,/ESCAPEDCOMMA/g; $line =~ s/\\"/ESCAPEDDBLQUOTE/g; $line=~/^(.*?) (.*) (.*)$/; my ($key, $fields, $timestamp) = ( $1, $2, $3); my ( $measurement, @taglist ) = split( /,/, $key ); $measurement =~ s/ESCAPEDSPACE/ /g; $measurement =~ s/ESCAPEDCOMMA/,/g; my $tags; foreach my $tagset (@taglist) { $tagset =~ s/ESCAPEDSPACE/ /g; $tagset =~ s/ESCAPEDCOMMA/,/g; my ( $k, $v ) = split( /=/, $tagset ); $tags->{$k} = $v; } my $values; my @strings; if ($fields =~ /"/) { my $cnt=0; $fields=~s/"(.*?)"/push(@strings, $1); 'ESCAPEDSTRING_'.$cnt++;/ge; } foreach my $valset ( split( /,/, $fields ) ) { $valset =~ s/ESCAPEDSPACE/ /g; $valset =~ s/ESCAPEDCOMMA/,/g; my ( $k, $v ) = split( /=/, $valset ); $v =~ s/ESCAPEDSTRING_(\d+)/$strings[$1]/ge; $v =~ s/ESCAPEDDBLQUOTE/"/g; $values->{$k} = $v; } return ( $measurement, $values, $tags, $timestamp ); } 1; __END__ =pod =encoding UTF-8 =head1 NAME InfluxDB::LineProtocol - Write and read InfluxDB LineProtocol =head1 VERSION version 1.014 =head1 SYNOPSIS use InfluxDB::LineProtocol qw(data2line line2data); # convert some Perl data into InfluxDB LineProtocol my $influx_line = data2line('measurement', 42); my $influx_line = data2line('measurement', { cost => 42 }); my $influx_line = data2line('measurement', 42, { tag => 'foo'} ); # convert InfluxDB Line back into Perl my ($measurement, $values, $tags, $timestamp) = line2data("metric,location=eu,server=srv1 value=42 1437072299900001000"); =head1 DESCRIPTION L is a rather new time series database. Since version 0.9 they use their L to write time series data into the database. This module allows you to generate such a line from a datastructure, handling all the annoying escaping and sorting for you. You can also use it to parse a line (maybe you want to add some tags to a line written by another app). Please read the InfluxDB docs so you understand how metrics, values and tags work. C will always try to implement the most current version of the InfluxDB line protocol, while allowing you to also get the old behaviour. Currently we support C<0.9.3> and newer per default, and C<0.9.2> if you ask nicely. =head2 FUNCTIONS =head3 data2line data2line($metric, $single_value); data2line($metric, $values_hashref); data2line($metric, $value, $tags_hashref); data2line($metric, $value, $nanoseconds); data2line($metric, $value, $tags_hashref, $nanoseconds); C takes various parameters and converts them to an InfluxDB Line. C has to be valid InfluxDB measurement name. Required. C can be either a scalar, which will be turned into "value=$value"; or a hashref, if you want to write several values (or a value with another name than "value"). Required. C is an optional hashref of tag-names and tag-values. C is an optional integer representing nanoseconds since the epoch. If you do not pass it, C will use C to get the current timestamp. =head3 line2data my ($metric, $value_hashref, $tags_hashref, $timestamp) = line2data( $line ); C parses an InfluxDB line and always returns 4 values. C is undef if there are no tags! =head1 PRECISION InfluxDB support different timestamp precisions: Nanosecond (ns, the default), microseconds (us), milliseconds (ms), seconds (s), minutes (m) and hours (h). If you do not want to generate lines using nanoseconds (which might be a good idea, because InfluxDB uses less space and has better performance if you choose a smaller precision), you can specify the wanted precision on load of C: use InfluxDB::LineProtocol->import(qw(data2line precision=ms)); Please note that yo have to tell InfluxDB the precision when posting lines to C! =head1 LOADING LEGACY PROTOCOL VERSIONS To use an old version of the line protocol, specify the version you want when loading C: use InfluxDB::LineProtocol qw(v0.9.2 data2line); You will get a version of C that conforms to the C<0.9.2> version of the line protocol. Currently supported version are: =over =item * 0.9.3 and newer default, no need to specify anything =item * 0.9.2 load via C =back =head1 TODO =over =item * check if tag sorting algorithm matches L =back =head1 SEE ALSO =over =item * L provides access to the old 0.8 API. It also allows searching etc. =item * L - An asynchronous library for InfluxDB time-series database. Does not implement escaping etc, so if you want to use AnyEvent::InfluxDB to send data to InfluxDB you can use InfluxDB::LineProtocol to convert your measurement data structure before sending it via AnyEvent::InfluxDB. =back =head1 THANKS Thanks to =over =item * L for funding the development of this code. =item * L for implementing negative & exponential number support and pointing out the change in the line protocol in 0.9.3. =item * L for fixing a bug when nanosecond timestamps cause some Perls to render the timestamp in scientific notation. =item * L for fixing a bug when handling large scientific notation data. =back =head1 AUTHOR Thomas Klausner =head1 COPYRIGHT AND LICENSE This software is copyright (c) 2016 - 2021 by Thomas Klausner. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. =cut InfluxDB-LineProtocol-1.014/t/0000755000175000017500000000000013776141735014534 5ustar dommdommInfluxDB-LineProtocol-1.014/t/30_legacy_0_9_2.t0000644000175000017500000002060113776141735017356 0ustar dommdomm#!/usr/bin/env perl use strict; use warnings; use 5.012; use lib 'lib'; use Test::Most; use InfluxDB::LineProtocol qw(v0.9.2 data2line line2data); my @faketime = ( 1437072205, 500681 ); my $nano = join( '', @faketime ) . "000"; { no warnings 'redefine'; sub InfluxDB::LineProtocol::gettimeofday() { wantarray ? @faketime : join( '.', @faketime ); } }; # tests look like: # - boolan flag if we provide an explicit timestamp # - ArrayRef of data passed to data2line # - String of the expected line (without the timestamp if we're not using explicit_timestamp # - ArrayRef we expected when parsing the line # - Optional is-TODO-marker my @tests = ( # some basic tests without timestamps [ 0, [ 'metric', 42 ], 'metric value=42', [ 'metric', { value => 42 }, undef ] ], [ 0, ['metric', {hit=>1, cost=>42}], 'metric cost=42,hit=1', [ 'metric', {hit=>1, cost=>42}, undef ] ], [ 0, ['metric', 42, {server=>'srv1',location=>'eu'}], 'metric,location=eu,server=srv1 value=42', [ 'metric', {value=>42}, {server=>'srv1',location=>'eu'} ] ], [ 0, ['metric', {cost=>42}, {server=>'srv1',location=>'eu'}], 'metric,location=eu,server=srv1 cost=42', [ 'metric', {cost=>42}, {server=>'srv1',location=>'eu'} ] ], # now with timestamps [ 1, [ 'metric', 42, 1437072299900001000 ], 'metric value=42 1437072299900001000', [ 'metric', { value => 42 }, undef, 1437072299900001000 ] ], [ 1, ['metric', {hit=>1, cost=>42},1437072299900001000], 'metric cost=42,hit=1 1437072299900001000', [ 'metric', {hit=>1, cost=>42},undef, 1437072299900001000 ] ], [ 1, ['metric', 42, , {server=>'srv1',location=>'eu'},1437072299900001000], 'metric,location=eu,server=srv1 value=42 1437072299900001000', [ 'metric', {value=>42}, {server=>'srv1',location=>'eu'}, 1437072299900001000 ] ], [ 1, ['metric', {cost=>42}, {server=>'srv1',location=>'eu'} ,1437072299900001000], 'metric,location=eu,server=srv1 cost=42 1437072299900001000', [ 'metric', {cost=>42}, {server=>'srv1',location=>'eu'},1437072299900001000 ] ], # weird measurement names [ 0, [ 'metric with space', 42 ], 'metric\ with\ space value=42', [ 'metric with space', { value => '42' }, undef ] ], [ 0, [ 'metric,with,comma', 42 ], 'metric\,with\,comma value=42', [ 'metric,with,comma', { value => '42' }, undef ] ], [ 0, [ 'metric,with,comma', 42 , { tag=>'foo' }], 'metric\,with\,comma,tag=foo value=42', [ 'metric,with,comma', { value => '42' }, { tag=>'foo' } ] ], [ 0, [ 'metric\with\backslash', 42 ], 'metric\with\backslash value=42', [ 'metric\with\backslash', { value => '42' }, undef ] ], # different value types [ 0, [ 'metric', 'foo' ], 'metric value="foo"', [ 'metric', { value => 'foo' }, undef ] ], [ 0, [ 'metric', 1.41 ], 'metric value=1.41', [ 'metric', { value => 1.41 }, undef ] ], [ 0, [ 'metric', -1.41 ], 'metric value=-1.41', [ 'metric', { value => -1.41 }, undef ] ], [ 0, [ 'metric', -42 ], 'metric value=-42', [ 'metric', { value => -42 }, undef ] ], [ 0, [ 'metric', 7.51696501241595e-05 ], 'metric value=7.51696501241595e-05', [ 'metric', { value => 7.51696501241595e-05 }, undef ], [ 'SKIP', sub { $^O eq 'MSWin32' }, 'negative exponentials are strange on windows' ] ], [ 0, [ 'metric', '7.51696501241595e05' ], 'metric value=7.51696501241595e05', [ 'metric', { value => '7.51696501241595e05' }, undef ] ], [ 0, [ 'metric', 'foo"bar"' ], 'metric value="foo\"bar\""', [ 'metric', { value => 'foo"bar"' }, undef ], ], [ 0, [ 'metric', 't' ], 'metric value=t', [ 'metric', { value => 't' }, undef ], ], [ 0, [ 'metric', 'T' ], 'metric value=T', [ 'metric', { value => 'T' }, undef ], ], [ 0, [ 'metric', 'FALSE' ], 'metric value=FALSE', [ 'metric', { value => 'FALSE' }, undef ], ], [ 0, [ 'metric', 'False' ], 'metric value="False"', [ 'metric', { value => 'False' }, undef ], ], [ 0, [ 'metric', 'tru' ], 'metric value="tru"', [ 'metric', { value => 'tru' }, undef ], ], # escape values [ 0, ['metric', "some value"], 'metric value="some value"', ['metric', { value=>'some value' } , undef], ], [ 0, ['metric', {a => "some value", b=>'another value'}], 'metric a="some value",b="another value"', ['metric', { a=>'some value', b=>'another value' } , undef], ], [ 0, ['metric', {a => "some value", b=>'another, value'}], 'metric a="some value",b="another, value"', ['metric', { a=>'some value', b=>'another, value' } , undef], ], [ 0, ['metric', 'some "value"'], 'metric value="some \"value\""', ['metric', { value=>'some "value"' } , undef], ], # tag types # escape tags [ 0, ['metric',42,{ 'tag space, comma'=>'value space, comma' }], 'metric,tag\ space\,\ comma=value\ space\,\ comma value=42', ['metric',{value=>42},{ 'tag space, comma'=>'value space, comma' }], ], # Examples from https://influxdb.com/docs/v0.9/write_protocols/write_syntax.html [ 1, ['disk_free', {free_space=>442221834240, disk_type=>'SSD'},1435362189575692182], 'disk_free disk_type="SSD",free_space=442221834240 1435362189575692182', ['disk_free', {free_space=>442221834240, disk_type=>'SSD'},undef,1435362189575692182], ], [ 1, ["total disk free",442221834240,{ volumes=>'/net,/home,/'},1435362189575692182], 'total\ disk\ free,volumes=/net\,/home\,/ value=442221834240 1435362189575692182', ["total disk free",{value=>442221834240},{ volumes=>'/net,/home,/'},1435362189575692182], ], [ 0, ['disk_free',442221834240,{ path=>'C:\Windows' }], 'disk_free,path=C:\Windows value=442221834240', ['disk_free',{value=>442221834240},{ path=>'C:\Windows' }], ], [ 0, ['disk_free',{ value=> 442221834240, 'working directories'=>'C:\My Documents\Stuff for examples,C:\My Documents'}], 'disk_free value=442221834240,working\ directories="C:\My Documents\Stuff for examples,C:\My Documents"', ['disk_free',{ value=> 442221834240, 'working directories'=>'C:\My Documents\Stuff for examples,C:\My Documents'}, undef], ], [ 0, ['"measurement with quotes"',{ 'field_key\\\\'=>'string field value, only " need be quoted'} , { 'tag key with spaces' => 'tag,value,with"commas"'} ], '"measurement\ with\ quotes",tag\ key\ with\ spaces=tag\,value\,with"commas" field_key\\\\="string field value, only \" need be quoted"', ['"measurement with quotes"',{ 'field_key\\\\'=>'string field value, only " need be quoted'}, { 'tag key with spaces' => 'tag,value,with"commas"'} ], ], ); while ( my ( $i, $case ) = each @tests ) { my ( $explicit_timestamp, $in, $raw_line, $out, $testtag ) = @$case; explain("case $i: $raw_line"); my $expected_line; if ($explicit_timestamp) { $expected_line = $raw_line; } else { $expected_line = $raw_line . ' ' . $nano; push(@$out,$nano); } if ($testtag) { if ($testtag->[0] eq 'TODO') { TODO: { local $TODO = 'not implemented yet'; _do_test($i, $in, $expected_line, $out); }; next; } elsif ($testtag->[0] eq 'SKIP' && $testtag->[1]->()) { SKIP: { skip $testtag->[2], 2; _do_test($i, $in, $expected_line, $out); }; next; } } _do_test($i, $in, $expected_line, $out); } sub _do_test { my ($i, $in, $expected_line, $out) = @_; is( data2line(@$in), $expected_line, "data2line case $i" ); my @result = line2data($expected_line); cmp_deeply( \@result, $out, "line2data case $i" ); } done_testing(); InfluxDB-LineProtocol-1.014/t/11_precision.t0000644000175000017500000000453713776141735017226 0ustar dommdomm#!/usr/bin/env perl use strict; use warnings; use 5.012; use lib 'lib'; BEGIN { *CORE::GLOBAL::time = sub() {1437072205}; } use Test::Most; use InfluxDB::LineProtocol qw(data2line line2data); my @faketime = ( 1437072205, 500681 ); { no warnings 'redefine'; sub InfluxDB::LineProtocol::gettimeofday() { wantarray ? @faketime : join( '.', @faketime ); } }; is( InfluxDB::LineProtocol::ts_ns, '1437072205500681000', 'nanoseconds' ); is( InfluxDB::LineProtocol::ts_us, '1437072205500681', 'microsecond' ); is( InfluxDB::LineProtocol::ts_ms, '1437072205500', 'millisecond' ); is( InfluxDB::LineProtocol::ts_s, '1437072205', 'seconds' ); is( InfluxDB::LineProtocol::ts_m, '23951203', 'minutes' ); is( InfluxDB::LineProtocol::ts_h, '399186', 'hours' ); { package TsDefault; use Test::Most; InfluxDB::LineProtocol->import(qw(data2line)); my $line = data2line( 'default', 1 ); is( $line, 'default value=1i 1437072205500681000', 'line with default nanosecs' ); } { package TsNano; use Test::Most; InfluxDB::LineProtocol->import(qw(data2line precision=ns)); my $line = data2line( 'nano', 1 ); is( $line, 'nano value=1i 1437072205500681000', 'line with nanosecs' ); } { package TsMicro; use Test::Most; InfluxDB::LineProtocol->import(qw(data2line precision=us)); my $line = data2line( 'micro', 1 ); is( $line, 'micro value=1i 1437072205500681', 'line with microsecs' ); } { package TsMilli; use Test::Most; InfluxDB::LineProtocol->import(qw(data2line precision=ms)); my $line = data2line( 'milli', 1 ); is( $line, 'milli value=1i 1437072205500', 'line with milliseconds' ); } { package TsSec; use Test::Most; InfluxDB::LineProtocol->import(qw(data2line precision=s)); my $line = data2line( 'sec', 1 ); is( $line, 'sec value=1i 1437072205', 'line with seconds' ); } { package TsMin; use Test::Most; InfluxDB::LineProtocol->import(qw(data2line precision=m)); my $line = data2line( 'min', 1 ); is( $line, 'min value=1i 23951203', 'line with minutes' ); } { package TsHour; use Test::Most; InfluxDB::LineProtocol->import(qw(data2line precision=h)); my $line = data2line( 'hour', 1 ); is( $line, 'hour value=1i 399186', 'line with hours' ); } package main; done_testing(); InfluxDB-LineProtocol-1.014/t/00-compile.t0000644000175000017500000000276313776141735016576 0ustar dommdommuse 5.006; use strict; use warnings; # this test was generated with Dist::Zilla::Plugin::Test::Compile 2.058 use Test::More; plan tests => 1 + ($ENV{AUTHOR_TESTING} ? 1 : 0); my @module_files = ( 'InfluxDB/LineProtocol.pm' ); # fake home for cpan-testers use File::Temp; local $ENV{HOME} = File::Temp::tempdir( CLEANUP => 1 ); my @switches = ( -d 'blib' ? '-Mblib' : '-Ilib', ); use File::Spec; use IPC::Open3; use IO::Handle; open my $stdin, '<', File::Spec->devnull or die "can't open devnull: $!"; my @warnings; for my $lib (@module_files) { # see L my $stderr = IO::Handle->new; diag('Running: ', join(', ', map { my $str = $_; $str =~ s/'/\\'/g; q{'} . $str . q{'} } $^X, @switches, '-e', "require q[$lib]")) if $ENV{PERL_COMPILE_TEST_DEBUG}; my $pid = open3($stdin, '>&STDERR', $stderr, $^X, @switches, '-e', "require q[$lib]"); binmode $stderr, ':crlf' if $^O eq 'MSWin32'; my @_warnings = <$stderr>; waitpid($pid, 0); is($?, 0, "$lib loaded ok"); shift @_warnings if @_warnings and $_warnings[0] =~ /^Using .*\bblib/ and not eval { +require blib; blib->VERSION('1.01') }; if (@_warnings) { warn @_warnings; push @warnings, @_warnings; } } is(scalar(@warnings), 0, 'no warnings found') or diag 'got warnings: ', ( Test::More->can('explain') ? Test::More::explain(\@warnings) : join("\n", '', @warnings) ) if $ENV{AUTHOR_TESTING}; InfluxDB-LineProtocol-1.014/t/10_basic.t0000644000175000017500000002247213776141735016311 0ustar dommdomm#!/usr/bin/env perl use strict; use warnings; use 5.012; use lib 'lib'; use Test::Most; use InfluxDB::LineProtocol qw(data2line line2data); my @faketime = ( 1437072205, 500681 ); my $nano = join( '', @faketime ) . "000"; { no warnings 'redefine'; sub InfluxDB::LineProtocol::gettimeofday() { wantarray ? @faketime : join( '.', @faketime ); } }; # tests look like: # - boolan flag if we provide an explicit timestamp # - ArrayRef of data passed to data2line # - String of the expected line (without the timestamp if we're not using explicit_timestamp # - ArrayRef we expected when parsing the line # - Optional is-TODO-marker my @tests = ( # some basic tests without timestamps [ 0, [ 'metric', { cost => '423i' } ], 'metric cost=423i', [ 'metric', { cost => 423 }, undef ] ], [ 0, [ 'metric', 42 ], 'metric value=42i', [ 'metric', { value => 42 }, undef ] ], [ 0, ['metric', {hit=>1, cost=>42}], 'metric cost=42i,hit=1i', [ 'metric', {hit=>1, cost=>42}, undef ] ], [ 0, ['metric', 42, {server=>'srv1',location=>'eu'}], 'metric,location=eu,server=srv1 value=42i', [ 'metric', {value=>42}, {server=>'srv1',location=>'eu'} ] ], [ 0, ['metric', {cost=>42}, {server=>'srv1',location=>'eu'}], 'metric,location=eu,server=srv1 cost=42i', [ 'metric', {cost=>42}, {server=>'srv1',location=>'eu'} ] ], # now with timestamps [ 1, [ 'metric', 42, 1437072299900001000 ], 'metric value=42i 1437072299900001000', [ 'metric', { value => 42 }, undef, 1437072299900001000 ] ], [ 1, ['metric', {hit=>1, cost=>42},1437072299900001000], 'metric cost=42i,hit=1i 1437072299900001000', [ 'metric', {hit=>1, cost=>42},undef, 1437072299900001000 ] ], [ 1, ['metric', 42, , {server=>'srv1',location=>'eu'},1437072299900001000], 'metric,location=eu,server=srv1 value=42i 1437072299900001000', [ 'metric', {value=>42}, {server=>'srv1',location=>'eu'}, 1437072299900001000 ] ], [ 1, ['metric', {cost=>42}, {server=>'srv1',location=>'eu'} ,1437072299900001000], 'metric,location=eu,server=srv1 cost=42i 1437072299900001000', [ 'metric', {cost=>42}, {server=>'srv1',location=>'eu'},1437072299900001000 ] ], # weird measurement names [ 0, [ 'metric with space', 42 ], 'metric\ with\ space value=42i', [ 'metric with space', { value => '42' }, undef ] ], [ 0, [ 'metric,with,comma', 42 ], 'metric\,with\,comma value=42i', [ 'metric,with,comma', { value => '42' }, undef ] ], [ 0, [ 'metric,with,comma', 42 , { tag=>'foo' }], 'metric\,with\,comma,tag=foo value=42i', [ 'metric,with,comma', { value => '42' }, { tag=>'foo' } ] ], [ 0, [ 'metric\with\backslash', 42 ], 'metric\with\backslash value=42i', [ 'metric\with\backslash', { value => '42' }, undef ] ], # different value types [ 0, [ 'metric', 'foo' ], 'metric value="foo"', [ 'metric', { value => 'foo' }, undef ] ], [ 0, [ 'metric', 1.41 ], 'metric value=1.41', [ 'metric', { value => 1.41 }, undef ] ], [ 0, [ 'metric', -1.41 ], 'metric value=-1.41', [ 'metric', { value => -1.41 }, undef ] ], [ 0, [ 'metric', -42 ], 'metric value=-42i', [ 'metric', { value => -42 }, undef ] ], [ 0, [ 'metric', 7.51696501241595e-05 ], 'metric value=7.51696501241595e-05', [ 'metric', { value => 7.51696501241595e-05 }, undef ], [ 'SKIP', sub { $^O eq 'MSWin32' }, 'negative exponentials are strange on windows' ] ], [ 0, [ 'metric', '7.51696501241595e05' ], 'metric value=7.51696501241595e05', [ 'metric', { value => '7.51696501241595e05' }, undef ] ], [ 0, [ 'metric', 'foo"bar"' ], 'metric value="foo\"bar\""', [ 'metric', { value => 'foo"bar"' }, undef ], ], [ 0, [ 'metric', 't' ], 'metric value=TRUE', [ 'metric', { value => 'TRUE' }, undef ], ], [ 0, [ 'metric', 'T' ], 'metric value=TRUE', [ 'metric', { value => 'TRUE' }, undef ], ], [ 0, [ 'metric', 'FALSE' ], 'metric value=FALSE', [ 'metric', { value => 'FALSE' }, undef ], ], [ 0, [ 'metric', 'F' ], 'metric value=FALSE', [ 'metric', { value => 'FALSE' }, undef ], ], [ 0, [ 'metric', 'False' ], 'metric value=FALSE', [ 'metric', { value => 'FALSE' }, undef ], ], [ 0, [ 'metric', 'tru' ], 'metric value="tru"', [ 'metric', { value => 'tru' }, undef ], ], # escape values [ 0, ['metric', "some value"], 'metric value="some value"', ['metric', { value=>'some value' } , undef], ], [ 0, ['metric', {a => "some value", b=>'another value'}], 'metric a="some value",b="another value"', ['metric', { a=>'some value', b=>'another value' } , undef], ], [ 0, ['metric', {a => "some value", b=>'another, value'}], 'metric a="some value",b="another, value"', ['metric', { a=>'some value', b=>'another, value' } , undef], ], [ 0, ['metric', 'some "value"'], 'metric value="some \"value\""', ['metric', { value=>'some "value"' } , undef], ], [ 0, [ 'metric', 'some \"value\"' ], 'metric value="some \\\\\"value\\\\\""', [ 'metric', { value => 'some \"value\"' }, undef ], ], # tag types # escape tags [ 0, ['metric',42,{ 'tag space, comma'=>'value space, comma' }], 'metric,tag\ space\,\ comma=value\ space\,\ comma value=42i', ['metric',{value=>42},{ 'tag space, comma'=>'value space, comma' }], ], # Examples from https://influxdb.com/docs/v0.9/write_protocols/write_syntax.html [ 1, ['disk_free', {free_space=>442221834240, disk_type=>'SSD'},1435362189575692182], 'disk_free disk_type="SSD",free_space=442221834240i 1435362189575692182', ['disk_free', {free_space=>442221834240, disk_type=>'SSD'},undef,1435362189575692182], ], [ 1, ["total disk free",442221834240,{ volumes=>'/net,/home,/'},1435362189575692182], 'total\ disk\ free,volumes=/net\,/home\,/ value=442221834240i 1435362189575692182', ["total disk free",{value=>442221834240},{ volumes=>'/net,/home,/'},1435362189575692182], ], [ 0, ['disk_free',442221834240,{ path=>'C:\Windows' }], 'disk_free,path=C:\Windows value=442221834240i', ['disk_free',{value=>442221834240},{ path=>'C:\Windows' }], ], [ 0, ['disk_free',{ value=> 442221834240, 'working directories'=>'C:\My Documents\Stuff for examples,C:\My Documents'}], 'disk_free value=442221834240i,working\ directories="C:\\\\My Documents\\\\Stuff for examples,C:\\\\My Documents"', ['disk_free',{ value=> 442221834240, 'working directories'=>'C:\My Documents\Stuff for examples,C:\My Documents'}, undef], ], [ 0, ['"measurement with quotes"',{ 'field_key\\\\'=>'string field value, only " need be quoted'} , { 'tag key with spaces' => 'tag,value,with"commas"'} ], '"measurement\ with\ quotes",tag\ key\ with\ spaces=tag\,value\,with"commas" field_key\\\\="string field value, only \" need be quoted"', ['"measurement with quotes"',{ 'field_key\\\\'=>'string field value, only " need be quoted'}, { 'tag key with spaces' => 'tag,value,with"commas"'} ], ], # 0.9.3 integer in tag and value [ 0, ['metric', {int=>42, float=>0.5}, {inttag=>8,floattag=>13.13}], 'metric,floattag=13.13,inttag=8 float=0.5,int=42i', [ 'metric', {int=>42, float=>0.5}, {inttag=>8,floattag=>13.13} ] ], # https://github.com/domm/InfluxDB-LineProtocol/issues/14 [ 0, [ 'metric', '7.51696501241595e+50' ], 'metric value=7.51696501241595e+50', [ 'metric', { value => '7.51696501241595e+50' }, undef ] ], ); while ( my ( $i, $case ) = each @tests ) { my ( $explicit_timestamp, $in, $raw_line, $out, $testtag ) = @$case; explain("case $i: $raw_line"); my $expected_line; if ($explicit_timestamp) { $expected_line = $raw_line; } else { $expected_line = "$raw_line $nano"; push(@$out,$nano); } if ($testtag) { if ($testtag->[0] eq 'TODO') { TODO: { local $TODO = 'not implemented yet'; _do_test($i, $in, $expected_line, $out); }; next; } elsif ($testtag->[0] eq 'SKIP' && $testtag->[1]->()) { SKIP: { skip $testtag->[2], 2; _do_test($i, $in, $expected_line, $out); }; next; } } _do_test($i, $in, $expected_line, $out); } sub _do_test { my ($i, $in, $expected_line, $out) = @_; is( data2line(@$in), $expected_line, "data2line case $i" ); my @result = line2data($expected_line); cmp_deeply( \@result, $out, "line2data case $i" ); } done_testing(); InfluxDB-LineProtocol-1.014/t/00-load.t0000644000175000017500000000015513776141735016056 0ustar dommdomm#!/usr/bin/env perl use Test::More; use lib 'lib'; require_ok( 'InfluxDB::LineProtocol' ); done_testing(); InfluxDB-LineProtocol-1.014/LICENSE0000644000175000017500000004371313776141735015306 0ustar dommdommThis software is copyright (c) 2016 - 2021 by Thomas Klausner. This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself. Terms of the Perl programming language system itself a) the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version, or b) the "Artistic License" --- The GNU General Public License, Version 1, February 1989 --- This software is Copyright (c) 2016 - 2021 by Thomas Klausner. This is free software, licensed under: The GNU General Public License, Version 1, February 1989 GNU GENERAL PUBLIC LICENSE Version 1, February 1989 Copyright (C) 1989 Free Software Foundation, Inc. 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The license agreements of most software companies try to keep users at the mercy of those companies. By contrast, our General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. The General Public License applies to the Free Software Foundation's software and to any other program whose authors commit to using it. You can use it for your programs, too. When we speak of free software, we are referring to freedom, not price. Specifically, the General Public License is designed to make sure that you have the freedom to give away or sell copies of free software, that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of a such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must tell them their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License Agreement applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any work containing the Program or a portion of it, either verbatim or with modifications. Each licensee is addressed as "you". 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this General Public License and to the absence of any warranty; and give any other recipients of the Program a copy of this General Public License along with the Program. You may charge a fee for the physical act of transferring a copy. 2. You may modify your copy or copies of the Program or any portion of it, and copy and distribute such modifications under the terms of Paragraph 1 above, provided that you also do the following: a) cause the modified files to carry prominent notices stating that you changed the files and the date of any change; and b) cause the whole of any work that you distribute or publish, that in whole or in part contains the Program or any part thereof, either with or without modifications, to be licensed at no charge to all third parties under the terms of this General Public License (except that you may choose to grant warranty protection to some or all third parties, at your option). c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the simplest and most usual way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this General Public License. d) You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. Mere aggregation of another independent work with the Program (or its derivative) on a volume of a storage or distribution medium does not bring the other work under the scope of these terms. 3. You may copy and distribute the Program (or a portion or derivative of it, under Paragraph 2) in object code or executable form under the terms of Paragraphs 1 and 2 above provided that you also do one of the following: a) accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Paragraphs 1 and 2 above; or, b) accompany it with a written offer, valid for at least three years, to give any third party free (except for a nominal charge for the cost of distribution) a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Paragraphs 1 and 2 above; or, c) accompany it with the information you received as to where the corresponding source code may be obtained. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form alone.) Source code for a work means the preferred form of the work for making modifications to it. For an executable file, complete source code means all the source code for all modules it contains; but, as a special exception, it need not include source code for modules which are standard libraries that accompany the operating system on which the executable file runs, or for standard header files or definitions files that accompany that operating system. 4. You may not copy, modify, sublicense, distribute or transfer the Program except as expressly provided under this General Public License. Any attempt otherwise to copy, modify, sublicense, distribute or transfer the Program is void, and will automatically terminate your rights to use the Program under this License. However, parties who have received copies, or rights to use copies, from you under this General Public License will not have their licenses terminated so long as such parties remain in full compliance. 5. By copying, distributing or modifying the Program (or any work based on the Program) you indicate your acceptance of this license to do so, and all its terms and conditions. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. 7. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of the license which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of the license, you may choose any version ever published by the Free Software Foundation. 8. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 9. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 10. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS Appendix: How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to humanity, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 1, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301 USA Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19xx name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (a program to direct compilers to make passes at assemblers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice That's all there is to it! --- The Artistic License 1.0 --- This software is Copyright (c) 2016 - 2021 by Thomas Klausner. This is free software, licensed under: The Artistic License 1.0 The Artistic License Preamble The intent of this document is to state the conditions under which a Package may be copied, such that the Copyright Holder maintains some semblance of artistic control over the development of the package, while giving the users of the package the right to use and distribute the Package in a more-or-less customary fashion, plus the right to make reasonable modifications. Definitions: - "Package" refers to the collection of files distributed by the Copyright Holder, and derivatives of that collection of files created through textual modification. - "Standard Version" refers to such a Package if it has not been modified, or has been modified in accordance with the wishes of the Copyright Holder. - "Copyright Holder" is whoever is named in the copyright or copyrights for the package. - "You" is you, if you're thinking about copying or distributing this Package. - "Reasonable copying fee" is whatever you can justify on the basis of media cost, duplication charges, time of people involved, and so on. (You will not be required to justify it to the Copyright Holder, but only to the computing community at large as a market that must bear the fee.) - "Freely Available" means that no fee is charged for the item itself, though there may be fees involved in handling the item. It also means that recipients of the item may redistribute it under the same conditions they received it. 1. You may make and give away verbatim copies of the source form of the Standard Version of this Package without restriction, provided that you duplicate all of the original copyright notices and associated disclaimers. 2. You may apply bug fixes, portability fixes and other modifications derived from the Public Domain or from the Copyright Holder. A Package modified in such a way shall still be considered the Standard Version. 3. You may otherwise modify your copy of this Package in any way, provided that you insert a prominent notice in each changed file stating how and when you changed that file, and provided that you do at least ONE of the following: a) place your modifications in the Public Domain or otherwise make them Freely Available, such as by posting said modifications to Usenet or an equivalent medium, or placing the modifications on a major archive site such as ftp.uu.net, or by allowing the Copyright Holder to include your modifications in the Standard Version of the Package. b) use the modified Package only within your corporation or organization. c) rename any non-standard executables so the names do not conflict with standard executables, which must also be provided, and provide a separate manual page for each non-standard executable that clearly documents how it differs from the Standard Version. d) make other distribution arrangements with the Copyright Holder. 4. You may distribute the programs of this Package in object code or executable form, provided that you do at least ONE of the following: a) distribute a Standard Version of the executables and library files, together with instructions (in the manual page or equivalent) on where to get the Standard Version. b) accompany the distribution with the machine-readable source of the Package with your modifications. c) accompany any non-standard executables with their corresponding Standard Version executables, giving the non-standard executables non-standard names, and clearly documenting the differences in manual pages (or equivalent), together with instructions on where to get the Standard Version. d) make other distribution arrangements with the Copyright Holder. 5. You may charge a reasonable copying fee for any distribution of this Package. You may charge any fee you choose for support of this Package. You may not charge a fee for this Package itself. However, you may distribute this Package in aggregate with other (possibly commercial) programs as part of a larger (possibly commercial) software distribution provided that you do not advertise this Package as a product of your own. 6. The scripts and library files supplied as input to or produced as output from the programs of this Package do not automatically fall under the copyright of this Package, but belong to whomever generated them, and may be sold commercially, and may be aggregated with this Package. 7. C or perl subroutines supplied by you and linked into this Package shall not be considered part of this Package. 8. The name of the Copyright Holder may not be used to endorse or promote products derived from this software without specific prior written permission. 9. THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE. The End InfluxDB-LineProtocol-1.014/Build.PL0000644000175000017500000000245713776141735015575 0ustar dommdomm # This file was automatically generated by Dist::Zilla::Plugin::ModuleBuild v6.017. use strict; use warnings; use Module::Build 0.28; my %module_build_args = ( "build_requires" => { "Module::Build" => "0.28" }, "configure_requires" => { "Module::Build" => "0.28" }, "dist_abstract" => "Write and read InfluxDB LineProtocol", "dist_author" => [ "Thomas Klausner " ], "dist_name" => "InfluxDB-LineProtocol", "dist_version" => "1.014", "license" => "perl", "module_name" => "InfluxDB::LineProtocol", "recursive_test_files" => 1, "requires" => { "Carp" => 0, "Time::HiRes" => 0 }, "test_requires" => { "File::Spec" => 0, "File::Temp" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Test::More" => 0, "Test::Most" => 0, "lib" => 0, "perl" => "5.012" } ); my %fallback_build_requires = ( "File::Spec" => 0, "File::Temp" => 0, "IO::Handle" => 0, "IPC::Open3" => 0, "Module::Build" => "0.28", "Test::More" => 0, "Test::Most" => 0, "lib" => 0, "perl" => "5.012" ); unless ( eval { Module::Build->VERSION(0.4004) } ) { delete $module_build_args{test_requires}; $module_build_args{build_requires} = \%fallback_build_requires; } my $build = Module::Build->new(%module_build_args); $build->create_build_script; InfluxDB-LineProtocol-1.014/MANIFEST0000644000175000017500000000041313776141735015420 0ustar dommdomm# This file was automatically generated by Dist::Zilla::Plugin::Manifest v6.017. Build.PL Changes INSTALL LICENSE MANIFEST META.json README.md cpanfile dist.ini lib/InfluxDB/LineProtocol.pm t/00-compile.t t/00-load.t t/10_basic.t t/11_precision.t t/30_legacy_0_9_2.t