[perl-Net-Statsd-Server] Initial import (#1110749).

David Dick ddick at fedoraproject.org
Sat Jun 21 21:56:55 UTC 2014


commit 84fd5ee2596092879f87e024b3953c10bb556502
Author: David Dick <ddick at cpan.org>
Date:   Sun Jun 22 07:56:39 2014 +1000

    Initial import (#1110749).

 .gitignore                       |    1 +
 net_statsd_server_makefile.patch |   30 +++++++++
 perl-Net-Statsd-Server.spec      |  120 ++++++++++++++++++++++++++++++++++++
 sources                          |    1 +
 statsd-perl.js                   |  124 ++++++++++++++++++++++++++++++++++++++
 statsd-perl.logrotate            |    8 +++
 statsd-perl.service              |   13 ++++
 7 files changed, 297 insertions(+), 0 deletions(-)
---
diff --git a/.gitignore b/.gitignore
index e69de29..dc54b7a 100644
--- a/.gitignore
+++ b/.gitignore
@@ -0,0 +1 @@
+/Net-Statsd-Server-0.17.tar.gz
diff --git a/net_statsd_server_makefile.patch b/net_statsd_server_makefile.patch
new file mode 100644
index 0000000..ddc0c5d
--- /dev/null
+++ b/net_statsd_server_makefile.patch
@@ -0,0 +1,30 @@
+diff -Naur old/Makefile.PL new/Makefile.PL
+--- old/Makefile.PL	2014-05-07 01:30:21.000000000 +1000
++++ new/Makefile.PL	2014-06-14 13:10:24.092424083 +1000
+@@ -17,9 +17,7 @@
+   },
+   "DISTNAME" => "Net-Statsd-Server",
+   "EXE_FILES" => [
+-    "bin/exampleConfig.js",
+-    "bin/statsd",
+-    "bin/localConfig.js"
++    "bin/statsd-perl",
+   ],
+   "LICENSE" => "perl",
+   "NAME" => "Net::Statsd::Server",
+diff -Naur old/MANIFEST new/MANIFEST
+--- old/MANIFEST	2014-05-07 01:30:21.000000000 +1000
++++ new/MANIFEST	2014-06-14 13:11:56.345409266 +1000
+@@ -7,9 +7,9 @@
+ Makefile.PL
+ README
+ TODO
+-bin/exampleConfig.js
+-bin/localConfig.js
+-bin/statsd
++exampleConfig.js
++localConfig.js
++bin/statsd-perl
+ debian/statsd.init
+ lib/Net/Statsd/Server.pm
+ lib/Net/Statsd/Server/Backend.pm
diff --git a/perl-Net-Statsd-Server.spec b/perl-Net-Statsd-Server.spec
new file mode 100644
index 0000000..af0c243
--- /dev/null
+++ b/perl-Net-Statsd-Server.spec
@@ -0,0 +1,120 @@
+%define username   statsdpl
+%define groupname  statsdpl
+%define daemon     statsd-perl
+
+Name:           perl-Net-Statsd-Server
+Version:        0.17
+Release:        1%{?dist}
+Summary:        Library for the Perl port of Flickr/Etsy's statsd metrics daemon
+License:        GPL+ or Artistic
+Group:          Development/Libraries
+URL:            http://search.cpan.org/dist/Net-Statsd-Server/
+Source0:        http://www.cpan.org/modules/by-module/Net/Net-Statsd-Server-%{version}.tar.gz
+Source1:        %{daemon}.service
+Source2:        %{daemon}.js
+Source3:        %{daemon}.logrotate
+Patch1:         net_statsd_server_makefile.patch
+BuildArch:      noarch
+BuildRequires:  perl
+BuildRequires:  perl(AnyEvent)
+BuildRequires:  perl(AnyEvent::Handle)
+BuildRequires:  perl(AnyEvent::Handle::UDP)
+BuildRequires:  perl(AnyEvent::Log)
+BuildRequires:  perl(AnyEvent::Socket)
+BuildRequires:  perl(AnyEvent::Strict)
+BuildRequires:  perl(base)
+BuildRequires:  perl(Carp)
+BuildRequires:  perl(constant)
+BuildRequires:  perl(Data::Dumper)
+BuildRequires:  perl(ExtUtils::MakeMaker) >= 6.30
+BuildRequires:  perl(FindBin)
+BuildRequires:  perl(IO::Socket::INET)
+BuildRequires:  perl(JSON::XS)
+BuildRequires:  perl(lib)
+BuildRequires:  perl(Socket)
+BuildRequires:  perl(strict)
+BuildRequires:  perl(Test::More)
+BuildRequires:  perl(Time::HiRes)
+BuildRequires:  perl(warnings)
+Requires:       perl(:MODULE_COMPAT_%(eval "`%{__perl} -V:version`"; echo $version))
+
+%description
+Net::Statsd::Server is the server component of statsd. It implements a daemon
+that listens on a given host/port for incoming UDP packets and dispatches them
+to whatever you want, including Graphite or your console.  Look into the
+Net::Statsd::Server::Backend::* namespace to know all the possibilities, or
+write a backend yourself.
+
+%prep
+%setup -q -n Net-Statsd-Server-%{version}
+%patch1 -p1
+mv bin/statsd bin/%{daemon}
+mv bin/localConfig.js localConfig.js
+mv bin/exampleConfig.js exampleConfig.js
+
+%build
+%{__perl} Makefile.PL INSTALLDIRS=vendor
+make %{?_smp_mflags}
+
+%install
+make pure_install DESTDIR=$RPM_BUILD_ROOT
+install -Dp -m0644 %{SOURCE1} %{buildroot}%{_unitdir}/%{daemon}.service
+install -Dp -m0644 %{SOURCE2} %{buildroot}%{_sysconfdir}/%{daemon}.js
+install -Dp -m0644 %{SOURCE3} %{buildroot}%{_sysconfdir}/logrotate.d/%{daemon}
+mkdir -p -m 750 $RPM_BUILD_ROOT%{_localstatedir}/log/%{daemon}
+
+find $RPM_BUILD_ROOT -type f -name .packlist -exec rm -f {} \;
+
+%{_fixperms} $RPM_BUILD_ROOT/*
+
+%check
+STATSD_BINARY=$RPM_BUILD_ROOT/usr/bin/%{daemon} make test
+
+%files
+%doc Changes LICENSE README TODO
+%{perl_vendorlib}/*
+%{_mandir}/man3/*
+
+%package -n statsd-perl
+Summary:        A Perl port of Flickr/Etsy's statsd metrics daemon
+BuildRequires:  systemd-units
+Requires(post):   systemd
+Requires(preun):  systemd
+Requires(postun): systemd
+Requires(pre):  shadow-utils
+Provides:  statsd
+
+%description -n statsd-perl
+Implements a daemon that listens on a given host/port for incoming UDP packets
+and dispatches them to whatever you want, including Graphite or your console.
+Look into the Net::Statsd::Server::Backend::* namespace to know all the
+possibilities, or write a backend yourself.
+
+%pre -n statsd-perl
+getent group %{groupname} >/dev/null || groupadd -r %{groupname}
+getent passwd %{username} >/dev/null || \
+useradd -r -g %{groupname} -d /run/%{daemon} \
+    -s /sbin/nologin -c "Perl Statsd" %{username}
+exit 0
+
+%post -n statsd-perl
+%systemd_post %{daemon}.service
+
+%preun -n statsd-perl
+%systemd_preun %{daemon}.service
+
+%postun -n statsd-perl
+%systemd_postun_with_restart %{daemon}.service
+
+%files -n statsd-perl
+%doc README exampleConfig.js localConfig.js
+%{_mandir}/man1/*
+%{_bindir}/*
+%config(noreplace) %{_sysconfdir}/%{daemon}.js
+%config(noreplace) %{_sysconfdir}/logrotate.d/%{daemon}
+%{_unitdir}/%{daemon}.service
+%attr(750, %{username}, %{groupname}) %{_localstatedir}/log/%{daemon}
+
+%changelog
+* Sat Jun 14 2014 David Dick <ddick at cpan.org> - 0.17-1
+- Initial release
diff --git a/sources b/sources
index e69de29..4c1a5eb 100644
--- a/sources
+++ b/sources
@@ -0,0 +1 @@
+a9c9977b52bcafe788a14c87672574cb  Net-Statsd-Server-0.17.tar.gz
diff --git a/statsd-perl.js b/statsd-perl.js
new file mode 100644
index 0000000..6e9c68c
--- /dev/null
+++ b/statsd-perl.js
@@ -0,0 +1,124 @@
+#/*
+#
+# Required Variables:
+#
+#   port:             StatsD listening port [default: 8125]
+#
+# Graphite Required Variables:
+#
+# (Leave these unset to avoid sending stats to Graphite.
+#  Set debug flag and leave these unset to run in 'dry' debug mode -
+#  useful for testing statsd clients without a Graphite server.)
+#
+#   graphiteHost:     hostname or IP of Graphite server
+#   graphitePort:     port of Graphite server
+#
+# Optional Variables:
+#
+#   backends:         an array of backends to load. Each backend must exist
+#                     as Perl module. If a single word is specified as backend
+#                     (example: "Console") then the "Net::Statsd::Server::Backend::Console"
+#                     will be loaded. Otherwise you can load an arbitrary class
+#                     ("My::Statsd::Backend").
+#
+#   debug:            debug flag [default: false]
+#   address:          address to listen on over UDP [default: 0.0.0.0]
+#   port:             port to listen for messages on over UDP [default: 8125]
+#   mgmt_address:     address to run the management TCP interface on
+#                     [default: 0.0.0.0]
+#   mgmt_port:        port to run the management TCP interface on [default: 8126]
+#   debugInterval:    interval to print debug information [ms, default: 10000]
+#   dumpMessages:     log all incoming messages
+#   flushInterval:    interval (in ms) to flush to Graphite
+#   percentThreshold: for time information, calculate the Nth percentile(s)
+#                     (can be a single value or list of floating-point values)
+#                     [%, default: 90]
+#   keyFlush:         log the most frequently sent keys [object, default: undefined]
+#     interval:       how often to log frequent keys [ms, default: 0]
+#     percent:        percentage of frequent keys to log [%, default: 100]
+#     log:            location of log file for frequent keys [default: STDOUT]
+#   deleteIdleStats:  don't send values to graphite for inactive counters, sets,
+#                     gauges, or timers as opposed to sending 0. For gauges,
+#                     this unsets the gauge (instead of sending the previous value).
+#                     Can be indivdually overriden. [default: false]
+#   deleteGauges:     don't send values to graphite for inactive gauges, as opposed
+#                     to sending the previous value [default: false]
+#   deleteTimers:     don't send values to graphite for inactive timers, as opposed
+#                     to sending 0 [default: false]
+#   deleteSets:       don't send values to graphite for inactive sets, as opposed
+#                     to sending 0 [default: false]
+#   deleteCounters:   don't send values to graphite for inactive counters, as opposed
+#                     to sending 0 [default: false]
+#   prefixStats:      prefix to use for the statsd statistics data for this running
+#                     instance of statsd [default: statsd]
+#                     applies to both legacy and new namespacing
+#   deleteCounters:   don't send values to graphite for inactive counters,
+#                     as opposed to sending 0 [default: false]
+#
+#   console:
+#     prettyprint:    whether to prettyprint the console backend
+#                     output [true or false, default: true]
+#
+#   log:              log settings [object, default: undefined]
+#     backend:        where to log: stdout or syslog [string, default: stdout]
+#     application:    name of the application for syslog [string, default: statsd]
+#     level:          log level for [node-]syslog [string, default: LOG_INFO]
+#
+#   graphite:
+#     legacyNamespace:  use the legacy namespace [default: true]
+#     globalPrefix:     global prefix to use for sending stats to graphite [default: "stats"]
+#     prefixCounter:    graphite prefix for counter metrics [default: "counters"]
+#     prefixTimer:      graphite prefix for timer metrics [default: "timers"]
+#     prefixGauge:      graphite prefix for gauge metrics [default: "gauges"]
+#     prefixSet:        graphite prefix for set metrics [default: "sets"]
+#
+#   file:
+#     name:           name of the logfile for the File backend
+#
+#   repeater:         an array of hashes of the for host: and port:
+#                     that details other statsd servers to which the received
+#                     packets should be "repeated" (duplicated to).
+#                     e.g. [ { host: '10.10.10.10', port: 8125 },
+#                            { host: 'observer', port: 88125 } ]
+#
+#   repeaterProtocol: whether to use udp4 or udp4 for repeaters.
+#                     ["udp4" or "udp6", default: "udp4"]
+# */
+{
+
+  "address" : "0.0.0.0",
+  "port": 8125,
+
+  "mgmt_address" : "0.0.0.0",
+  "mgmt_port": 8126,
+
+  "debug" : false,
+  "dumpMessages" : false,
+
+  "flushInterval" : 10000,  # ms
+
+  "log" : {
+    "backend" : "syslog",  # or "stdout"
+    "level" : "LOG_WARN",  # "info" to be more verbose
+  },
+
+  # Available backends are: Graphite, Console, File
+  "backends": [ "File" ],
+
+  # File backend config
+  "file" : {
+    "name" : "/var/log/statsd-perl/flush.log",
+  },
+
+  ## Typical graphite configuration
+  #"backends": [ "Graphite" ],
+  #"graphite" : {
+  #  "name" : "/var/log/statsd-perl/flush.log",
+  #},
+  "graphitePort": 2003,
+  "graphiteHost": "localhost", # your.graphite.host
+  "graphite": {
+    "legacyNamespace" : false
+  }, 
+
+}
diff --git a/statsd-perl.logrotate b/statsd-perl.logrotate
new file mode 100644
index 0000000..83b6d6d
--- /dev/null
+++ b/statsd-perl.logrotate
@@ -0,0 +1,8 @@
+/var/log/statsd-perl/statsd-perl.log {
+    daily
+    rotate 28
+    delaycompress
+    compress
+    notifempty
+    missingok
+}
diff --git a/statsd-perl.service b/statsd-perl.service
new file mode 100644
index 0000000..67e88a7
--- /dev/null
+++ b/statsd-perl.service
@@ -0,0 +1,13 @@
+[Unit]
+Description=statsd-perl
+After=network.target
+
+[Service]
+Type=simple
+ExecStart=/usr/bin/statsd-perl /etc/statsd-perl.js
+User=statsdpl
+Group=statsdpl
+SupplementaryGroups=
+
+[Install]
+WantedBy=multi-user.target


More information about the scm-commits mailing list