From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49465) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXk7B-0007cC-6J for guix-patches@gnu.org; Sat, 06 Jan 2018 03:46:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXk78-0002fW-PT for guix-patches@gnu.org; Sat, 06 Jan 2018 03:46:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:57098) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eXk78-0002fM-Mi for guix-patches@gnu.org; Sat, 06 Jan 2018 03:46:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1eXk78-00012m-EL for guix-patches@gnu.org; Sat, 06 Jan 2018 03:46:02 -0500 Subject: [bug#30003] [PATCH 2/2] gnu: services: Add darkstat service. Resent-Message-ID: Received: from eggs.gnu.org ([2001:4830:134:3::10]:49270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eXk6i-0007XV-W0 for guix-patches@gnu.org; Sat, 06 Jan 2018 03:45:38 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eXk6f-0002Sw-3L for guix-patches@gnu.org; Sat, 06 Jan 2018 03:45:37 -0500 Received: from rezeros.cc ([2001:19f0:7001:2f3e:5400:ff:fe84:e55d]:38626) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eXk6e-0002S1-LM for guix-patches@gnu.org; Sat, 06 Jan 2018 03:45:33 -0500 From: =?UTF-8?Q?=E5=AE=8B=E6=96=87=E6=AD=A6?= Date: Sat, 6 Jan 2018 16:45:23 +0800 Message-Id: <20180106084523.29095-2-iyzsong@member.fsf.org> In-Reply-To: <20180106084523.29095-1-iyzsong@member.fsf.org> References: <20180106084523.29095-1-iyzsong@member.fsf.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+kyle=kyleam.com@gnu.org Sender: "Guix-patches" To: 30003@debbugs.gnu.org * gnu/services/monitoring.scm: New file. * gnu/local.mk (GNU_SYSTEM_MODULES): Add it. * doc/guix.texi (Monitoring Services): Document it. --- doc/guix.texi | 42 +++++++++++++++++++++ gnu/local.mk | 1 + gnu/services/monitoring.scm | 91 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 134 insertions(+) create mode 100644 gnu/services/monitoring.scm diff --git a/doc/guix.texi b/doc/guix.texi index 1d1f30f00..f9dec3082 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -14697,6 +14697,48 @@ the 2nd element of the pair is the password. @end deftp +@subsubheading Darkstat Service +@cindex darkstat +@command{darkstat} is a packet sniffer that captures network traffic, +calculates statistics about usage, and serves reports over HTTP. + +@defvar {Scheme Variable} darkstat-service-type +This is the service type for the +@uref{https://unix4lyfe.org/darkstat/, darkstat} +service, its value must be a @code{darkstat-configuration} record as in +this example: + +@example +(service darkstat-service-type + (darkstat-configuration + (interface "eth0"))) +@end example +@end defvar + +@deftp {Data Type} darkstat-configuration +Data type representing the configuration of @command{darkstat}. + +@table @asis +@item @code{package} (default: @code{darstat}) +The darkstat package to use. + +@item @code{interface} +Capture traffic on the specified network interface. + +@item @code{port} (default: @code{"667"}) +Bind the web interface to the specified port. + +@item @code{bindaddr} (default: @code{"127.0.0.1"}) +Bind the web interface to the specified address. + +@item @code{base} (default: @code{"/"}) +Specify the path of the base URL. This can be useful if +@command{darkstat} is accessed via a reverse proxy. + +@end table +@end deftp + + @node Kerberos Services @subsubsection Kerberos Services @cindex Kerberos diff --git a/gnu/local.mk b/gnu/local.mk index 679c119a5..62fcd2cd4 100644 --- a/gnu/local.mk +++ b/gnu/local.mk @@ -460,6 +460,7 @@ GNU_SYSTEM_MODULES = \ %D%/services/mail.scm \ %D%/services/mcron.scm \ %D%/services/messaging.scm \ + %D%/services/monitoring.scm \ %D%/services/networking.scm \ %D%/services/nfs.scm \ %D%/services/shepherd.scm \ diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm new file mode 100644 index 000000000..438d66596 --- /dev/null +++ b/gnu/services/monitoring.scm @@ -0,0 +1,91 @@ +;;; GNU Guix --- Functional package management for GNU +;;; Copyright © 2018 Sou Bunnbu +;;; +;;; This file is part of GNU Guix. +;;; +;;; GNU Guix 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 3 of the License, or (at +;;; your option) any later version. +;;; +;;; GNU Guix 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 GNU Guix. If not, see . + +(define-module (gnu services monitoring) + #:use-module (gnu services) + #:use-module (gnu services shepherd) + #:use-module (gnu packages admin) + #:use-module (gnu packages monitoring) + #:use-module (gnu system shadow) + #:use-module (guix gexp) + #:use-module (guix records) + #:use-module (ice-9 match) + #:export (darkstat-configuration + darkstat-service-type)) + + +;;; +;;; darkstat +;;; + +(define-record-type* + darkstat-configuration make-darkstat-configuration darkstat-configuration? + (package darkstat-configuration-package + (default darkstat)) + (interface darkstat-configuration-interface) + (port darkstat-configuration-port + (default "667")) + (bindaddr darkstat-configuration-bindaddr + (default "127.0.0.1")) + (base darkstat-configuration-base + (default "/"))) + +(define %darkstat-accounts + (list (user-account + (name "darkstat") + (group "darkstat") + (system? #t) + (comment "darkstat daemon user") + (home-directory "/var/lib/darkstat") + (shell (file-append shadow "/sbin/nologin"))) + (user-group + (name "darkstat") + (system? #t)))) + +(define darkstat-shepherd-service + (match-lambda + (($ + package interface port bindaddr base) + (shepherd-service + (documentation "Network statistics gatherer.") + (provision '(darkstat)) + (requirement '(networking)) + (start #~(make-forkexec-constructor + (list #$(file-append package "/sbin/darkstat") + "-i" #$interface + "-p" #$port + "-b" #$bindaddr + "--base" #$base + "--syslog" "--no-daemon" + "--chroot" "/var/lib/darkstat" + "--user" "darkstat" + "--import" "darkstat.db" + "--export" "darkstat.db"))) + (stop #~(make-kill-destructor)))))) + +(define darkstat-service-type + (service-type + (name 'darkstat) + (description + "Run @command{darkstat} to serve network traffic statictics reports over +HTTP.") + (extensions + (list (service-extension account-service-type + (const %darkstat-accounts)) + (service-extension shepherd-root-service-type + (compose list darkstat-shepherd-service)))))) -- 2.13.3