3
0
Fork 0
forked from mirrors/nixpkgs

longview: Linode metrics collector

Longview is a perl script used for sending server metrics to Linode
virtual private server hosting.
This commit is contained in:
Rodney Lorrimar 2015-11-01 10:20:12 +00:00
parent a754e7b8a6
commit 96f81e3be5
3 changed files with 102 additions and 0 deletions

View file

@ -0,0 +1,62 @@
{stdenv, fetchFromGitHub, perl, perlPackages, makeWrapper, glibc }:
stdenv.mkDerivation rec {
version = "1.1.5pre";
name = "longview-${version}";
src = fetchFromGitHub {
owner = "linode";
repo = "longview";
rev = "5bcc9b60896b72de2d14f046f911477c26eb70ba";
sha256 = "1i6va44bx2zfgbld7znf1slph0iqidlahq2xh3kd8q4lhvbrjn02";
};
patches =
[ # log to systemd journal
./log-stdout.patch
];
postPatch =
''
substituteInPlace Linode/Longview/Util.pm --replace /var/run/longview.pid /run/longview.pid
'';
buildInputs = [ perl makeWrapper glibc ]
++ (with perlPackages; [
LWPUserAgent
LWPProtocolHttps
MozillaCA
CryptSSLeay
IOSocketInet6
LinuxDistribution
JSONPP
JSON
LogLogLite
TryTiny
DBI
DBDmysql
]);
buildPhase = "true";
installPhase = ''
mkdir -p $out/bin $out/usr
mv Linode $out
ln -s ../Linode/Longview.pl $out/bin/longview
for h in syscall.h sys/syscall.h asm/unistd.h asm/unistd_32.h asm/unistd_64.h bits/wordsize.h bits/syscall.h; do
${perl}/bin/h2ph -d $out ${glibc}/include/$h
mkdir -p $out/usr/include/$(dirname $h)
mv $out${glibc}/include/''${h%.h}.ph $out/usr/include/$(dirname $h)
done
wrapProgram $out/Linode/Longview.pl --prefix PATH : ${perl}/bin:$out/bin \
--suffix PERL5LIB : $out/Linode --suffix PERL5LIB : $PERL5LIB \
--suffix PERL5LIB : $out --suffix INC : $out
'';
meta = with stdenv.lib; {
homepage = https://www.linode.com/longview;
description = "Longview collects all of your system-level metrics and sends them to Linode.";
license = licenses.gpl2Plus;
maintainers = [ maintainers.rvl ];
inherit version;
};
}

View file

@ -0,0 +1,38 @@
diff -ru longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src.orig/Linode/Longview/Logger.pm longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src/Linode/Longview/Logger.pm
--- longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src.orig/Linode/Longview/Logger.pm 2015-10-28 17:15:32.816515318 +0000
+++ longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src/Linode/Longview/Logger.pm 2015-10-28 18:00:50.760332026 +0000
@@ -26,9 +26,7 @@
my ( $self, $message ) = @_;
my $ts = strftime( '%m/%d %T', localtime );
- $self->{logger}->write(
- sprintf( '%s %s Longview[%i] - %s', $ts, uc($level), $$, $message ),
- $levels->{$level} );
+ printf( "%s %s Longview[%i] - %s\n", $ts, uc($level), $$, $message );
die "$message" if $level eq 'logdie';
};
}
@@ -37,12 +35,6 @@
my ( $class, $level ) = @_;
my $self = {};
- mkpath($LOGDIR) unless (-d $LOGDIR);
- $self->{logger}
- = Log::LogLite->new( $LOGDIR . 'longview.log', $level )
- or die "Couldn't create logger object: $!";
- $self->{logger}->template("<message>\n");
-
return bless $self, $class;
}
diff -ru longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src.orig/Linode/Longview/Util.pm longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src/Linode/Longview/Util.pm
--- longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src.orig/Linode/Longview/Util.pm 2015-10-28 17:15:32.816515318 +0000
+++ longview-5bcc9b60896b72de2d14f046f911477c26eb70ba-src/Linode/Longview/Util.pm 2015-10-28 19:20:30.894314658 +0000
@@ -225,7 +225,6 @@
#<<< perltidy ignore
chdir '/' or $logger->logdie("Can't chdir to /: $!");
open STDIN, '<', '/dev/null' or $logger->logdie("Can't read /dev/null: $!");
- open STDOUT, '>>', '/dev/null' or $logger->logdie("Can't write to /dev/null: $!");
open STDERR, '>>', '/dev/null' or $logger->logdie("Can't write to /dev/null: $!");
tie *STDERR, "Linode::Longview::STDERRLogger";
defined( my $pid = fork ) or $logger->logdie("Can't fork: $!");

View file

@ -2150,6 +2150,8 @@ let
logstalgia = callPackage ../tools/graphics/logstalgia {}; logstalgia = callPackage ../tools/graphics/logstalgia {};
longview = callPackage ../servers/monitoring/longview { };
lout = callPackage ../tools/typesetting/lout { }; lout = callPackage ../tools/typesetting/lout { };
lrzip = callPackage ../tools/compression/lrzip { }; lrzip = callPackage ../tools/compression/lrzip { };