From patchwork Thu Nov 29 18:50:37 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 350 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 0E3601686D; Thu, 29 Nov 2018 18:52:14 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id A99711686C for ; Thu, 29 Nov 2018 18:52:13 +0000 (GMT) Received: from localhost ([::1]:55768 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRQ4-0007AE-PF for patchwork@mira.cbaines.net; Thu, 29 Nov 2018 13:52:12 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRPx-00079r-Bv for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:06 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSRPu-0001r5-ED for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50852) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSRPu-0001r0-9B for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gSRPt-00029G-WC for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33549] [PATCH 1/6] gnu: zabbix-server: Split output. References: <20181129184708.4818-1-go.wigust@gmail.com> In-Reply-To: <20181129184708.4818-1-go.wigust@gmail.com> Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Nov 2018 18:52:01 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33549 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33549@debbugs.gnu.org Received: via spool by 33549-submit@debbugs.gnu.org id=B33549.15435174698140 (code B ref 33549); Thu, 29 Nov 2018 18:52:01 +0000 Received: (at 33549) by debbugs.gnu.org; 29 Nov 2018 18:51:09 +0000 Received: from localhost ([127.0.0.1]:55096 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP3-000278-0M for submit@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:09 -0500 Received: from mail-lj1-f171.google.com ([209.85.208.171]:39513) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP1-00026a-7Y for 33549@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:07 -0500 Received: by mail-lj1-f171.google.com with SMTP id t9-v6so2691109ljh.6 for <33549@debbugs.gnu.org>; Thu, 29 Nov 2018 10:51:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LIXN+I3LSW6JaCInQpLJdnPdD9JaCdY/htRhw5RV6qE=; b=ClKaIkzwTV9vO8Z7rIf4pm+VNGaArMK7tYFPeA/CbH/0Ia8cflqspvD3OwQmPvHyDv hQDWsIIvNrFC5jWnAPekvaskuC0NcqAv01f7+lWKAIDzPBd7ZW746Cfl86/9UzuEdvK7 rOWUpRDx1mz6ZOeB1XxjwgitGLDf4Q35rbwuaekA4AudI05iizxZUWmdSjnIAcEciYPE ifNDbolNdt7kjLzVl+liOiAc0C/ue1fXX0SLuSeSFThKE55dEKt1D41bIh1FSK4fKSjK gqmsVCFDuqpRgXPlQ47h46FCSu7CN1jTLNhXdvnc+znQL2FINtW/iQ3R4HmX9R8rGaGY Q4nw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=LIXN+I3LSW6JaCInQpLJdnPdD9JaCdY/htRhw5RV6qE=; b=iRuk53SYPee79Pg1r1yUdSgM9TKbah2msgVqzjCQ5Xf80paFSg9q5b+FE7ACOfx7JA 7MgmQcgBSBprVTTx9XV6xeX3keb7Wj+O21UOsEHXUvdbLr2R4oFoq53Pb7kTLNHu2TgJ zjB4KuoFtrAMAv2Ao5wniXQenKrUFK5INalabfmE0H4SvtcEdbLP2lcj8vxcROa4ZRfQ em+fHODh08Imoqp+B6y+yZKNhBV7yHmSllrskVIlERwSPgTsi4vtK/3JexHRo1DaqGq6 aRF0om5ThfsgRtFugQTETPo5Vco/4YSjOrddDTlFn1jdweKPf7aByqClitiSOkel1n0M Pc8Q== X-Gm-Message-State: AA+aEWZuYMvDJ3GWpZzB43U3doH2P4WOui9US9nIlfWPFhsVMscIsJ1V hG/JfVSVleSLLnD1ikLkXXnpbE1Xdgw= X-Google-Smtp-Source: AFSGD/WoYCR2pjJHAcjIxzYbOlzg/9dzXqCRclyyLqbZovG1m5XbNTg//3grLqrGRvzmWPqca6cJ0g== X-Received: by 2002:a2e:5c86:: with SMTP id q128-v6mr1969905ljb.119.1543517460607; Thu, 29 Nov 2018 10:51:00 -0800 (PST) Received: from localhost.localdomain ([178.70.249.201]) by smtp.gmail.com with ESMTPSA id k21-v6sm406705ljc.15.2018.11.29.10.50.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 10:50:59 -0800 (PST) From: Oleg Pykhalov Date: Thu, 29 Nov 2018 21:50:37 +0300 Message-Id: <20181129185042.6050-1-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/monitoring.scm (zabbix-server)[outputs]: Add 'front-end' and 'schema' outputs. --- gnu/packages/monitoring.scm | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/gnu/packages/monitoring.scm b/gnu/packages/monitoring.scm index b69ec07158..35fe4c7690 100644 --- a/gnu/packages/monitoring.scm +++ b/gnu/packages/monitoring.scm @@ -182,21 +182,34 @@ solution (client-side agent)") (package (inherit zabbix-agentd) (name "zabbix-server") + (outputs '("out" "front-end" "schema")) (arguments (substitute-keyword-arguments `(#:phases (modify-phases %standard-phases - (add-after 'install 'install-frontend + (add-after 'install 'install-front-end (lambda* (#:key outputs #:allow-other-keys) - (let* ((php (string-append (assoc-ref outputs "out") + (let* ((php (string-append (assoc-ref outputs "front-end") "/share/zabbix/php")) (front-end-conf (string-append php "/conf")) (etc (string-append php "/etc"))) (mkdir-p php) - (copy-recursively "./frontends/php" php) + (copy-recursively "frontends/php" php) + ;; Make front-end write config to ‘/etc/zabbix’ directory. (rename-file front-end-conf (string-append front-end-conf "-example")) - (symlink "/etc/zabbix" front-end-conf))))) + (symlink "/etc/zabbix" front-end-conf)) + #t)) + (add-after 'install 'install-schema + (lambda* (#:key outputs #:allow-other-keys) + (let ((database-directory + (string-append (assoc-ref outputs "schema") + "/database"))) + (for-each delete-file + (find-files "database" "Makefile\\.in|\\.am$")) + (mkdir-p database-directory) + (copy-recursively "database" database-directory)) + #t))) ,@(package-arguments zabbix-agentd)) ((#:configure-flags flags) `(cons* "--enable-server" From patchwork Thu Nov 29 18:50:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 353 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B5B831686D; Thu, 29 Nov 2018 18:52:24 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id C611516869 for ; Thu, 29 Nov 2018 18:52:23 +0000 (GMT) Received: from localhost ([::1]:55779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRQF-0007Kh-2V for patchwork@mira.cbaines.net; Thu, 29 Nov 2018 13:52:23 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46178) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRPy-00079t-6x for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSRPu-0001rF-MU for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50853) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSRPu-0001r9-Hp for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:02 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gSRPu-00029O-GW for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33549] [PATCH 2/6] services: monitoring: Add 'zabbix-server'. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Nov 2018 18:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33549 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33549@debbugs.gnu.org Received: via spool by 33549-submit@debbugs.gnu.org id=B33549.15435174738168 (code B ref 33549); Thu, 29 Nov 2018 18:52:02 +0000 Received: (at 33549) by debbugs.gnu.org; 29 Nov 2018 18:51:13 +0000 Received: from localhost ([127.0.0.1]:55100 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP5-00027Z-LZ for submit@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:12 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:41280) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP2-00026q-DR for 33549@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:09 -0500 Received: by mail-lj1-f195.google.com with SMTP id z80-v6so2688944ljb.8 for <33549@debbugs.gnu.org>; Thu, 29 Nov 2018 10:51:08 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=PcEJdX9I9j8Z4SDpEZLNqDZeqmUSpQCUZP7sZqNi66E=; b=ADgskvYCjh5R1AjU7MlsSSIfDyMa7LM4uY3r/pk177qhec031ayT5XwrH703P8M41p guIrhi32wVZF7ka2etZDs0ufdc3o0035j0h/C8BjqI4YzeapzZ5FPqQWpF6elnx86dgG YoU9GEo4rYqOMp6K5FMteAVy6XARLxbvamgaTaGkfPSgvfb2OHos0Td000+S2vaTdTwJ le010pTJwEEZPiiy+PR7LOjxXLbfAqWEKXmYKkMdWsktErEEkl84ka0+yJAjPDsfSZAT F8nMNVHy7PjaYNp+hZgY8Ho5Z3iRZh/+YAjwBUZSUBPmRWECsjmMHWmDNZ7EakfZQFsX v8TQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=PcEJdX9I9j8Z4SDpEZLNqDZeqmUSpQCUZP7sZqNi66E=; b=bVuf4ThJ1rH/gyLHX0gENnhrBbLhYXTKqbOW046gunam16Ascs8z/aXRO6xy3ZmMDf 3xug/GCxXGew15o9BRBalOXaTLAQp9f84jGPGjLw1X2udGDENWyDTKSWG+sJoHEFazDJ iIjW4TQvvPIq7ED0PX6RiZ1BfBcldrriXPTnXL1ZOtbsnA5YnW+GsgW5vKq+PyYccErx 19/rmGomezSSWFbQs7FbplJIhX6DTdE/gph8BS5rogNpis7N15kj2YOmVzAL/VCrVNRl G5pa2/6aecGhp0PrYQyM4BsnZhtv6x42wbqZJLBNwwYkwDTcj36MRUYnhGG8yCW2NXMd 2oAw== X-Gm-Message-State: AA+aEWbwCByF704TksGUKEoQwWljCg3ku//YRqDPLkKPXnG+QYe0HXrY P8qGjG8Ny2f2Q+hdR73Ng6t8Ps25wbw= X-Google-Smtp-Source: AFSGD/XIYX3rRXxgOQwWCAY1IK1clvUA6Lwt03iribZ4GdCNwMfa5B1745ibrXvLjTO51TovmOvIww== X-Received: by 2002:a2e:612:: with SMTP id 18-v6mr1816170ljg.125.1543517461877; Thu, 29 Nov 2018 10:51:01 -0800 (PST) Received: from localhost.localdomain ([178.70.249.201]) by smtp.gmail.com with ESMTPSA id k21-v6sm406705ljc.15.2018.11.29.10.51.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 10:51:00 -0800 (PST) From: Oleg Pykhalov Date: Thu, 29 Nov 2018 21:50:38 +0300 Message-Id: <20181129185042.6050-2-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129185042.6050-1-go.wigust@gmail.com> References: <20181129185042.6050-1-go.wigust@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/monitoring.scm (uglify-field-name, serialize-field, serialize-number, serialize-list, serialize-string, serialize-include-files, zabbix-server-account, zabbix-server-config-file, zabbix-server-activation, zabbix-server-shepherd-service, generate-zabbix-server-documentation): New procedures. (zabbix-server-service-type): New variable. * gnu/tests/monitoring.scm (%psql-user-create-zabbix, %psql-db-zabbix-create-script, %psql-db-create-zabbix, %psql-db-import-zabbix, %zabbix-os, %test-zabbix): New variables. (run-zabbix-server-test): New procedure. * doc/guix.texi (Monitoring Services): Document 'zabbix-server'. --- doc/guix.texi | 140 +++++++++++++++++++++++++++ gnu/services/monitoring.scm | 185 +++++++++++++++++++++++++++++++++++- gnu/tests/monitoring.scm | 168 +++++++++++++++++++++++++++++++- 3 files changed, 491 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index c040a8531a..48f7798742 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16613,6 +16613,146 @@ Bind the web interface to the specified address. @end table @end deftp +@subsubheading Zabbix server +@cindex zabbix zabbix-server +Zabbix provides monitoring metrics, among others network utilization, CPU load +and disk space consumption: + +@itemize +@item High performance, high capacity (able to monitor hundreds of thousands of devices). +@item Auto-discovery of servers and network devices and interfaces. +@item Low-level discovery, allows to automatically start monitoring new items, file systems or network interfaces among others. +@item Distributed monitoring with centralized web administration. +@item Native high performance agents. +@item SLA, and ITIL KPI metrics on reporting. +@item High-level (business) view of monitored resources through user-defined visual console screens and dashboards. +@item Remote command execution through Zabbix proxies. +@end itemize + +@c %start of fragment + +Available @code{zabbix-server-configuration} fields are: + +@deftypevr {@code{zabbix-server-configuration} parameter} package zabbix-server +The zabbix-server package. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string user +User who will run the Zabbix server. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} group group +Group who will run the Zabbix server. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string db-host +Database host name. + +Defaults to @samp{"127.0.0.1"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string db-name +Database name. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string db-user +Database user. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string db-password +Database password. Please, use @code{include-files} instead. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} number db-port +Database port. + +Defaults to @samp{5432}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string log-type +Specifies where log messages are written to: + +@itemize @bullet +@item +@code{system} - syslog. + +@item +@code{file} - file specified with @code{log-file} parameter. + +@item +@code{console} - standard output. + +@end itemize + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string log-file +Log file name for @code{log-type} @code{file} parameter. + +Defaults to @samp{"/var/log/zabbix/server.log"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string pid-file +Name of PID file. + +Defaults to @samp{"/var/run/zabbix/zabbix_server.pid"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string ssl-ca-location +The location of certificate authority (CA) files for SSL server +certificate verification. + +Defaults to @samp{"/etc/ssl/certs/ca-certificates.crt"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string ssl-cert-location +Location of SSL client certificates. + +Defaults to @samp{"/etc/ssl/certs"}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} string extra-options +Extra options will be appended to Zabbix server configuration file. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-server-configuration} parameter} include-files include-files +You may include individual files or all files in a directory in the +configuration file. + +Defaults to @samp{()}. + +@end deftypevr + + +@c %end of fragment + @node Kerberos Services @subsubsection Kerberos Services @cindex Kerberos diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index aa3b63a0e4..9655fb95e9 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -1,6 +1,7 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Sou Bunnbu ;;; Copyright © 2018 Gábor Boskovits +;;; Copyright © 2018 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; @@ -19,17 +20,23 @@ (define-module (gnu services monitoring) #:use-module (gnu services) + #:use-module (gnu services configuration) #: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 packages) #:use-module (guix records) #:use-module (ice-9 match) + #:use-module (srfi srfi-26) #:export (darkstat-configuration prometheus-node-exporter-configuration darkstat-service-type - prometheus-node-exporter-service-type)) + prometheus-node-exporter-service-type + + zabbix-server-configuration + zabbix-server-service-type)) ;;; @@ -125,3 +132,179 @@ prometheus.") (list (service-extension shepherd-root-service-type (compose list prometheus-node-exporter-shepherd-service)))))) + + +;;; +;;; Zabbix server +;;; + +(define (uglify-field-name field-name) + (apply string-append + (map (lambda (str) + (if (member (string->symbol str) '(ca db ssl)) + (string-upcase str) + (string-capitalize str))) + (string-split (string-delete #\? + (symbol->string field-name)) + #\-)))) + +(define (serialize-field field-name val) + (format #t "~a=~a~%" (uglify-field-name field-name) val)) + +(define (serialize-number field-name val) + (serialize-field field-name (number->string val))) + +(define (serialize-list field-name val) + (if (null? val) "" (serialize-field field-name (string-join val ",")))) + +(define (serialize-string field-name val) + (if (and (string? val) (string=? val "")) + "" + (serialize-field field-name val))) + +(define group? string?) + +(define serialize-group + (const "")) + +(define include-files? list?) + +(define (serialize-include-files field-name val) + (if (null? val) "" (for-each (cut serialize-field 'include <>) val))) + +(define-configuration zabbix-server-configuration + (zabbix-server + (package zabbix-server) + "The zabbix-server package.") + (user + (string "zabbix") + "User who will run the Zabbix server.") + (group ;for zabbix-server-account procedure + (group "zabbix") + "Group who will run the Zabbix server.") + (db-host + (string "127.0.0.1") + "Database host name.") + (db-name + (string "zabbix") + "Database name.") + (db-user + (string "zabbix") + "Database user.") + (db-password + (string "") + "Database password. Please, use @code{include-files} instead.") + (db-port + (number 5432) + "Database port.") + (log-type + (string "") + "Specifies where log messages are written to: +@itemize +@item @code{system} - syslog. +@item @code{file} - file specified with @code{log-file} parameter. +@item @code{console} - standard output. +@end itemize\n") + (log-file + (string "/var/log/zabbix/server.log") + "Log file name for @code{log-type} @code{file} parameter.") + (pid-file + (string "/var/run/zabbix/zabbix_server.pid") + "Name of PID file.") + (ssl-ca-location + (string "/etc/ssl/certs/ca-certificates.crt") + "The location of certificate authority (CA) files for SSL server +certificate verification.") + (ssl-cert-location + (string "/etc/ssl/certs") + "Location of SSL client certificates.") + (extra-options + (string "") + "Extra options will be appended to Zabbix server configuration file.") + (include-files + (include-files '()) + "You may include individual files or all files in a directory in the +configuration file.")) + +(define (zabbix-server-account config) + "Return the user accounts and user groups for CONFIG." + (let ((zabbix-user (zabbix-server-configuration-user config)) + (zabbix-group (zabbix-server-configuration-group config))) + (list (user-group (name zabbix-group) (system? #t)) + (user-account + (name zabbix-user) + (system? #t) + (group zabbix-group) + (comment "zabbix privilege separation user") + (home-directory (string-append "/var/run/" zabbix-user)) + (shell #~(string-append #$shadow "/sbin/nologin")))))) + +(define (zabbix-server-config-file config) + "Return the zabbix-server configuration file corresponding to CONFIG." + (computed-file + "zabbix_server.conf" + #~(begin + (call-with-output-file #$output + (lambda (port) + (display "# Generated by 'zabbix-server-service'.\n" port) + (display #$(with-output-to-string + (lambda () + (serialize-configuration + config zabbix-server-configuration-fields))) + port) + #t))))) + +(define (zabbix-server-activation config) + "Return the activation gexp for CONFIG." + (with-imported-modules '((guix build utils) + (ice-9 rdelim)) + #~(begin + (use-modules (guix build utils) + (ice-9 rdelim)) + (let ((user (getpw #$(zabbix-server-configuration-user config)))) + (for-each (lambda (file) + (let ((directory (dirname file))) + (mkdir-p directory) + (chown directory (passwd:uid user) (passwd:gid user)) + (chmod directory #o755))) + (list #$(zabbix-server-configuration-log-file config) + #$(zabbix-server-configuration-pid-file config) + "/etc/zabbix/maintenance.inc.php")))))) + +(define (zabbix-server-shepherd-service config) + "Return a for Zabbix server with CONFIG." + (list (shepherd-service + (provision '(zabbix-server)) + (documentation "Run Zabbix server daemon.") + (start #~(make-forkexec-constructor + (list #$(file-append (zabbix-server-configuration-zabbix-server config) + "/sbin/zabbix_server") + "--config" #$(zabbix-server-config-file config) + "--foreground") + #:user #$(zabbix-server-configuration-user config) + #:group #$(zabbix-server-configuration-group config) + #:pid-file #$(zabbix-server-configuration-pid-file config) + #:environment-variables + (list "SSL_CERT_DIR=/run/current-system/profile\ +/etc/ssl/certs" + "SSL_CERT_FILE=/run/current-system/profile\ +/etc/ssl/certs/ca-certificates.crt"))) + (stop #~(make-kill-destructor))))) + +(define zabbix-server-service-type + (service-type + (name 'zabbix-server) + (extensions + (list (service-extension shepherd-root-service-type + zabbix-server-shepherd-service) + (service-extension account-service-type + zabbix-server-account) + (service-extension activation-service-type + zabbix-server-activation))) + (default-value (zabbix-server-configuration)))) + +(define (generate-zabbix-server-documentation) + (generate-documentation + `((zabbix-server-configuration + ,zabbix-server-configuration-fields)) + 'zabbix-server-configuration)) diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index 3320a19a77..7a704eb01d 100644 --- a/gnu/tests/monitoring.scm +++ b/gnu/tests/monitoring.scm @@ -1,5 +1,6 @@ ;;; GNU Guix --- Functional package management for GNU ;;; Copyright © 2018 Gábor Boskovits +;;; Copyright © 2018 Oleg Pykhalov ;;; ;;; This file is part of GNU Guix. ;;; @@ -17,13 +18,20 @@ ;;; along with GNU Guix. If not, see . (define-module (gnu tests monitoring) + #:use-module (gnu packages databases) + #:use-module (gnu packages monitoring) #:use-module (gnu services) #:use-module (gnu services monitoring) #:use-module (gnu services networking) + #:use-module (gnu services databases) + #:use-module (gnu services shepherd) #:use-module (gnu system vm) + #:use-module (gnu system) #:use-module (gnu tests) #:use-module (guix gexp) - #:export (%test-prometheus-node-exporter)) + #:use-module (guix modules) + #:export (%test-prometheus-node-exporter + %test-zabbix)) ;;; @@ -95,3 +103,161 @@ (description "Connect to a running prometheus-node-exporter server.") (value (run-prometheus-node-exporter-server-test name %prometheus-node-exporter-os)))) + + +;;; +;;; Zabbix +;;; + +(define %psql-user-create-zabbix + "\ +sudo -u postgres psql <<< \"create user zabbix password 'zabbix';\" +") + +(define %psql-db-zabbix-create-script + "\ +sudo -u postgres psql --no-align <<< \\\\du +") + +(define %psql-db-create-zabbix + "\ +sudo -u postgres createdb -O zabbix -E Unicode -T template0 zabbix +") + +(define %psql-db-import-zabbix + #~(format #f "\ +cat ~a | sudo -u zabbix psql zabbix; +cat ~a | sudo -u zabbix psql zabbix; +cat ~a | sudo -u zabbix psql zabbix; +" + (string-append #$zabbix-server:schema + "/database/postgresql/schema.sql") + (string-append #$zabbix-server:schema + "/database/postgresql/images.sql") + (string-append #$zabbix-server:schema + "/database/postgresql/data.sql"))) + +(define* (run-zabbix-server-test name test-os) + "Run tests in %ZABBIX-OS, which has zabbix running." + (define os + (marionette-operating-system + test-os + #:imported-modules '((gnu services herd)))) + + (define vm + (virtual-machine + (operating-system os) + (port-forwardings '((8080 . 80))) + (memory-size 1024))) + + (define test + (with-imported-modules '((gnu build marionette)) + #~(begin + (use-modules (srfi srfi-11) + (srfi srfi-64) + (gnu build marionette) + (web client) + (web response) + (ice-9 popen) + (ice-9 rdelim)) + + (define marionette + (make-marionette (list #$vm))) + + (mkdir #$output) + (chdir #$output) + + (test-begin #$name) + + ;; XXX: Shepherd reads the config file *before* binding its control + ;; socket, so /var/run/shepherd/socket might not exist yet when the + ;; 'marionette' service is started. + (test-assert "shepherd socket ready" + (marionette-eval + `(begin + (use-modules (gnu services herd)) + (let loop ((i 10)) + (cond ((file-exists? (%shepherd-socket-file)) + #t) + ((> i 0) + (sleep 1) + (loop (- i 1))) + (else + 'failure)))) + marionette)) + + (test-assert "postgres service running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'postgres)) + marionette)) + + (test-eq "postgres create zabbix user" + 0 + (marionette-eval '(begin (system #$%psql-user-create-zabbix)) + marionette)) + + (test-equal "postgres find zabbix user" + "List of roles +Role name|Attributes|Member of +postgres|Superuser, Create role, Create DB, Replication, Bypass RLS|{} +zabbix||{} +" + (marionette-eval + '(begin (let* ((port (open-pipe #$%psql-db-zabbix-create-script + OPEN_READ)) + (output (read-string port)) + (status (close-pipe port))) + output)) + marionette)) + + (test-eq "postgres create zabbix db" + 0 + (marionette-eval '(begin (system #$%psql-db-create-zabbix)) + marionette)) + + (test-eq "postgres import zabbix db" + 0 + (marionette-eval '(begin (system #$%psql-db-import-zabbix)) + marionette)) + + ;; Wait for zabbix-server to be up and running. + (test-assert "zabbix-server running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'zabbix-server)) + marionette)) + + ;; Make sure the PID file is created. + (test-assert "zabbix-server PID file" + (marionette-eval + '(file-exists? "/var/run/zabbix/zabbix_server.pid") + marionette)) + + (test-end) + + (exit (= (test-runner-fail-count (test-runner-current)) 0))))) + + (gexp->derivation (string-append name "-test") test)) + +(define %zabbix-os + ;; Return operating system under test. + (let ((base-os + (simple-operating-system + (service dhcp-client-service-type) + (postgresql-service) + (service zabbix-server-service-type + (zabbix-server-configuration + (db-password "zabbix") + (log-type "console")))))) + (operating-system + (inherit base-os) + (packages (cons* postgresql (operating-system-packages base-os)))))) + +(define %test-zabbix + (system-test + (name "zabbix") + (description "Connect to a running Zabbix") + (value (run-zabbix-server-test name %zabbix-os)))) From patchwork Thu Nov 29 18:50:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 351 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 800DA16869; Thu, 29 Nov 2018 18:52:16 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id EC96316869 for ; Thu, 29 Nov 2018 18:52:15 +0000 (GMT) Received: from localhost ([::1]:55769 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRQ7-0007As-6W for patchwork@mira.cbaines.net; Thu, 29 Nov 2018 13:52:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46174) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRPx-00079s-Un for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSRPv-0001rT-48 for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:05 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50854) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSRPu-0001rM-WA for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gSRPu-00029V-V2 for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:02 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33549] [PATCH 3/6] services: monitoring: Add 'zabbix-agent'. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Nov 2018 18:52:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33549 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33549@debbugs.gnu.org Received: via spool by 33549-submit@debbugs.gnu.org id=B33549.15435174748175 (code B ref 33549); Thu, 29 Nov 2018 18:52:02 +0000 Received: (at 33549) by debbugs.gnu.org; 29 Nov 2018 18:51:14 +0000 Received: from localhost ([127.0.0.1]:55103 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP6-00027h-Uv for submit@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:13 -0500 Received: from mail-lj1-f195.google.com ([209.85.208.195]:42655) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP3-00026s-63 for 33549@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:10 -0500 Received: by mail-lj1-f195.google.com with SMTP id l15-v6so2689595lja.9 for <33549@debbugs.gnu.org>; Thu, 29 Nov 2018 10:51:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=VfPByrTRZDsJlsxKI9KiFpxG/IOTDGDe16Pvlpl3VBs=; b=k7uVXoOfltpdnv92osw/GhVDihBABQXhZj5e0Tvq6TW5Jnu6Qnjqieqcs+plkSGgDq SeNxn6qoEhbu8PLfXicLVKouM3Wo8GK4xQqWS3vpxWd/U7gPJWnEDLTY+4TSS+8dOnXW PYLtQJSXiDDCtnFQlJw3mug1SS/jNhfcEbK8KIZoGE0hPQqFQJRDEZi1kvccLDDdYSpJ Y0MgRJkup95ETikD/CyuxYvT3htqKBvxoYFUiwO7XGNYsoRYAODugtXUwuyPAzOnAf2i ZwMTolJu6EneU7CTUhtqNfFGysfMMz74dkeeiCOdzGA9pr/8zVHMjSepcXfgIOfLpOw1 uiPg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=VfPByrTRZDsJlsxKI9KiFpxG/IOTDGDe16Pvlpl3VBs=; b=pY7qZtWzzowIn33lF3ferHDhNuOQCdbOubGyDPmREQzGLVeLBaDHGw8War0JBA1bwl jF7Wopj6dWq77dCLpLB+yHE+m4z6lAUx9yAEgv+xYYGEZWmWDtZW1k352Uuzm9M3W+Tx WQwTSnp7gfM0oKITZNNMY+mI9cksgdvA9yaE5quwomwoYOQjxuVtCHutg+46kgHpym7A R2pAPaZuK5ui13rvYTZzMVg3VIkdURqEXakijEfbRPyT6N8lZcNAY+b5RBqlRx+mQ9Kv 6zuwypOcQGUGnYv4mzWhqo2Aaw4Vv5ed0ItIg1w1Zh8J3aw+KGAg7mT1poFJhUThRtIp QEwA== X-Gm-Message-State: AA+aEWaM8WQmD8LZ7boJq+0TAxFHJOWs+/fYoVsxSc6Ej65tpbyoyPcM BcLAgqMz6v4GDLlW0NNuxDMBkqxOSyw= X-Google-Smtp-Source: AFSGD/X9xtWNFbmbZ+hHmII9Itr/GOjsOOB8CpY3dFPFOwa+iikZIigAy1elzlt2beom6KdhGr0yJQ== X-Received: by 2002:a2e:681a:: with SMTP id c26-v6mr1819178lja.175.1543517462847; Thu, 29 Nov 2018 10:51:02 -0800 (PST) Received: from localhost.localdomain ([178.70.249.201]) by smtp.gmail.com with ESMTPSA id k21-v6sm406705ljc.15.2018.11.29.10.51.01 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 10:51:02 -0800 (PST) From: Oleg Pykhalov Date: Thu, 29 Nov 2018 21:50:39 +0300 Message-Id: <20181129185042.6050-3-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129185042.6050-1-go.wigust@gmail.com> References: <20181129185042.6050-1-go.wigust@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * doc/guix.texi (Monitoring Services): Document 'zabbix-agent'. * gnu/services/monitoring.scm (zabbix-server-service-type, zabbix-agent-account, zabbix-agent-activation, zabbix-agent-config-file, zabbix-agent-shepherd-service, generate-zabbix-agent-documentation): New procedures. (zabbix-agent-service-type): New variable. * gnu/tests/monitoring.scm (run-zabbix-server-test): Test 'zabbix-agent'. (%zabbix-os): Add 'zabbix-agent' service. --- doc/guix.texi | 103 ++++++++++++++++++++++++++++ gnu/services/monitoring.scm | 133 +++++++++++++++++++++++++++++++++++- gnu/tests/monitoring.scm | 18 ++++- 3 files changed, 252 insertions(+), 2 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 48f7798742..7b8f7acd29 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16750,6 +16750,109 @@ Defaults to @samp{()}. @end deftypevr +@c %end of fragment + +@subsubheading Zabbix agent +@cindex zabbix zabbix-agent + +Zabbix agent gathers information for Zabbix server. + +@c %start of fragment + +Available @code{zabbix-agent-configuration} fields are: + +@deftypevr {@code{zabbix-agent-configuration} parameter} package zabbix-agent +The zabbix-agent package. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string user +User who will run the Zabbix agent. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} group group +Group who will run the Zabbix agent. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string hostname +Unique, case sensitive hostname which is required for active checks and +must match hostname as configured on the server. + +Defaults to @samp{"Zabbix server"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string log-type +Specifies where log messages are written to: + +@itemize @bullet +@item +@code{system} - syslog. + +@item +@code{file} - file specified with @code{log-file} parameter. + +@item +@code{console} - standard output. + +@end itemize + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string log-file +Log file name for @code{log-type} @code{file} parameter. + +Defaults to @samp{"/var/log/zabbix/agent.log"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string pid-file +Name of PID file. + +Defaults to @samp{"/var/run/zabbix/zabbix_agent.pid"}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} list server +List of IP addresses, optionally in CIDR notation, or hostnames of +Zabbix servers and Zabbix proxies. Incoming connections will be +accepted only from the hosts listed here. + +Defaults to @samp{("127.0.0.1")}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} list server-active +List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix +proxies for active checks. If port is not specified, default port is +used. If this parameter is not specified, active checks are disabled. + +Defaults to @samp{("127.0.0.1")}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} string extra-options +Extra options will be appended to Zabbix server configuration file. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-agent-configuration} parameter} include-files include-files +You may include individual files or all files in a directory in the +configuration file. + +Defaults to @samp{()}. + +@end deftypevr @c %end of fragment diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index 9655fb95e9..274228af89 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -36,7 +36,9 @@ prometheus-node-exporter-service-type zabbix-server-configuration - zabbix-server-service-type)) + zabbix-server-service-type + zabbix-agent-configuration + zabbix-agent-service-type)) ;;; @@ -308,3 +310,132 @@ configuration file.")) `((zabbix-server-configuration ,zabbix-server-configuration-fields)) 'zabbix-server-configuration)) + +(define-configuration zabbix-agent-configuration + (zabbix-agent + (package zabbix-agentd) + "The zabbix-agent package.") + (user + (string "zabbix") + "User who will run the Zabbix agent.") + (group + (group "zabbix") + "Group who will run the Zabbix agent.") + (hostname + (string "Zabbix server") + "Unique, case sensitive hostname which is required for active checks and +must match hostname as configured on the server.") + (log-type + (string "") + "Specifies where log messages are written to: +@itemize +@item @code{system} - syslog. +@item @code{file} - file specified with @code{log-file} parameter. +@item @code{console} - standard output. +@end itemize\n") + (log-file + (string "/var/log/zabbix/agent.log") + "Log file name for @code{log-type} @code{file} parameter.") + (pid-file + (string "/var/run/zabbix/zabbix_agent.pid") + "Name of PID file.") + (server + (list '("127.0.0.1")) + "List of IP addresses, optionally in CIDR notation, or hostnames of Zabbix +servers and Zabbix proxies. Incoming connections will be accepted only from +the hosts listed here.") + (server-active + (list '("127.0.0.1")) + "List of IP:port (or hostname:port) pairs of Zabbix servers and Zabbix +proxies for active checks. If port is not specified, default port is used. +If this parameter is not specified, active checks are disabled.") + (extra-options + (string "") + "Extra options will be appended to Zabbix server configuration file.") + (include-files + (include-files '()) + "You may include individual files or all files in a directory in the +configuration file.")) + +(define (zabbix-agent-account config) + "Return the user accounts and user groups for CONFIG." + (let ((zabbix-user "zabbix") + (zabbix-group "zabbix")) + (list (user-group (name zabbix-group) (system? #t)) + (user-account + (name zabbix-user) + (system? #t) + (group zabbix-group) + (comment "zabbix privilege separation user") + (home-directory (string-append "/var/run/" zabbix-user)) + (shell #~(string-append #$shadow "/sbin/nologin")))))) + +(define (zabbix-agent-activation config) + "Return the activation gexp for CONFIG." + (with-imported-modules '((guix build utils) + (ice-9 rdelim)) + #~(begin + (use-modules (guix build utils) + (ice-9 rdelim)) + (let ((user + (getpw #$(zabbix-agent-configuration-user config)))) + (for-each (lambda (file) + (let ((directory (dirname file))) + (mkdir-p directory) + (chown directory (passwd:uid user) (passwd:gid user)) + (chmod directory #o755))) + (list #$(zabbix-agent-configuration-log-file config) + #$(zabbix-agent-configuration-pid-file config))))))) + +(define (zabbix-agent-config-file config) + "Return the zabbix-agent configuration file corresponding to CONFIG." + (computed-file + "zabbix_agent.conf" + #~(begin + (call-with-output-file #$output + (lambda (port) + (display "# Generated by 'zabbix-agent-service'.\n" port) + (display #$(with-output-to-string + (lambda () + (serialize-configuration + config zabbix-agent-configuration-fields))) + port) + #t))))) + +(define (zabbix-agent-shepherd-service config) + "Return a for Zabbix agent with CONFIG." + (list (shepherd-service + (provision '(zabbix-agent)) + (documentation "Run Zabbix agent daemon.") + (start #~(make-forkexec-constructor + (list #$(file-append (zabbix-agent-configuration-zabbix-agent config) + "/sbin/zabbix_agentd") + "--config" #$(zabbix-agent-config-file config) + "--foreground") + #:user #$(zabbix-agent-configuration-user config) + #:group #$(zabbix-agent-configuration-group config) + #:pid-file #$(zabbix-agent-configuration-pid-file config) + #:environment-variables + (list "SSL_CERT_DIR=/run/current-system/profile\ +/etc/ssl/certs" + "SSL_CERT_FILE=/run/current-system/profile\ +/etc/ssl/certs/ca-certificates.crt"))) + (stop #~(make-kill-destructor))))) + +(define zabbix-agent-service-type + (service-type + (name 'zabbix-agent) + (extensions + (list (service-extension shepherd-root-service-type + zabbix-agent-shepherd-service) + (service-extension account-service-type + zabbix-agent-account) + (service-extension activation-service-type + zabbix-agent-activation))) + (default-value (zabbix-agent-configuration)))) + +(define (generate-zabbix-agent-documentation) + (generate-documentation + `((zabbix-agent-configuration + ,zabbix-agent-configuration-fields)) + 'zabbix-agent-configuration)) diff --git a/gnu/tests/monitoring.scm b/gnu/tests/monitoring.scm index 7a704eb01d..ec9e086ff4 100644 --- a/gnu/tests/monitoring.scm +++ b/gnu/tests/monitoring.scm @@ -236,6 +236,20 @@ zabbix||{} '(file-exists? "/var/run/zabbix/zabbix_server.pid") marionette)) + ;; Wait for zabbix-agent to be up and running. + (test-assert "zabbix-agent running" + (marionette-eval + '(begin + (use-modules (gnu services herd)) + (start-service 'zabbix-agent)) + marionette)) + + ;; Make sure the PID file is created. + (test-assert "zabbix-agent PID file" + (marionette-eval + '(file-exists? "/var/run/zabbix/zabbix_agent.pid") + marionette)) + (test-end) (exit (= (test-runner-fail-count (test-runner-current)) 0))))) @@ -251,7 +265,9 @@ zabbix||{} (service zabbix-server-service-type (zabbix-server-configuration (db-password "zabbix") - (log-type "console")))))) + (log-type "console"))) + + (service zabbix-agent-service-type)))) (operating-system (inherit base-os) (packages (cons* postgresql (operating-system-packages base-os)))))) From patchwork Thu Nov 29 18:50:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 349 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id CAD511686D; Thu, 29 Nov 2018 18:52:12 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id 5C71416869 for ; Thu, 29 Nov 2018 18:52:12 +0000 (GMT) Received: from localhost ([::1]:55771 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRQ3-0007CZ-F8 for patchwork@mira.cbaines.net; Thu, 29 Nov 2018 13:52:11 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRPy-00079u-PL for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:08 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSRPv-0001rk-Mc for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:06 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50855) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSRPv-0001rg-Hl for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:03 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gSRPv-00029c-DX for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:03 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33549] [PATCH 4/6] services: php-fpm: Add 'timezone' configuration. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Nov 2018 18:52:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33549 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33549@debbugs.gnu.org Received: via spool by 33549-submit@debbugs.gnu.org id=B33549.15435174788193 (code B ref 33549); Thu, 29 Nov 2018 18:52:03 +0000 Received: (at 33549) by debbugs.gnu.org; 29 Nov 2018 18:51:18 +0000 Received: from localhost ([127.0.0.1]:55106 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRPB-000284-Si for submit@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:18 -0500 Received: from mail-lj1-f175.google.com ([209.85.208.175]:38487) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP4-00026u-Ss for 33549@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:11 -0500 Received: by mail-lj1-f175.google.com with SMTP id c19-v6so2699303lja.5 for <33549@debbugs.gnu.org>; Thu, 29 Nov 2018 10:51:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=AVicmrnRW/vEr2kjLc04RY8SMsMDX6Zql/nu87ak8wE=; b=eYnXzBFqWM4lPrfYJvIvihJW05MdXudVZc9QUgHaiShHryG/S1yzaNmKeFeI1XWaE+ f2QyAYKFbtT17sR0+fQb0ECCs6busvJxFg9Rv+KK4W0U0wJps+UE7vrCNzkkXauTgWRj r7BJ1EE5KuflecawH5fW7y1mHBRnv9u76IpJZO876tlPX+LpgxJAppm4UGQ+c1Zi9YsM RShMt3nyLoKKKl7sQqQttOipxle7CTyU6RF6mkI2liTBppUhGmz9tLECtmq3iZ2bp9SG IPr4SGuMSuz89wb1j6485ChpwMPUYtNrJjhvvi3/WKKhnZCCrnPyMjp73Q5DJChSe3uS FL8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=AVicmrnRW/vEr2kjLc04RY8SMsMDX6Zql/nu87ak8wE=; b=HFci5mme7HFAGXJlNs6Atl1RLUdAQmqE0z8jK3RKNm1+xysXQXTh6DVnbsMPZRUeO2 ckMMe4ch5kGrU8sy90QH31TPYlrIh7/0Lu4EtaZ5zg9XNb3YdQDOlvGvbAfCbBgKVjBj uZ18m3iI2W7fuyyjdQ5Ail+b4cpUhimCjNF4Oj9EtDIunsdmH2bEwS9v21PRKgrST1lf i487OIQwZ+IUtJDW+0gfIp72K5cmYcXXz5Cwg/QfakOVChv/SoPvmWltGD9qbMq5GIJC YTyWZ5Bw5cMy27TxlnGg/kDgN79uRIJ4EQhtT1FY0dR5/CQKh6+sbJAVPc0Sldwm9ox1 cVJQ== X-Gm-Message-State: AA+aEWaCHIR3IkJpXTlrjId/UBculcVlv9MT0AoBeKvs8hNh/KVISTmR p7w6TKVk9GR5xlMXtnhKgsCsnXWdACM= X-Google-Smtp-Source: AFSGD/V5UPjQtKxMW+A5PelLMLhVeziPGi7lPSD1YMPqCdXAGdg5AGifabgWc7hAOlQJXPs7sSPo5Q== X-Received: by 2002:a2e:7f04:: with SMTP id a4-v6mr2042683ljd.156.1543517464419; Thu, 29 Nov 2018 10:51:04 -0800 (PST) Received: from localhost.localdomain ([178.70.249.201]) by smtp.gmail.com with ESMTPSA id k21-v6sm406705ljc.15.2018.11.29.10.51.02 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 10:51:03 -0800 (PST) From: Oleg Pykhalov Date: Thu, 29 Nov 2018 21:50:40 +0300 Message-Id: <20181129185042.6050-4-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129185042.6050-1-go.wigust@gmail.com> References: <20181129185042.6050-1-go.wigust@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/web.scm: ()[timezone]: New record field. (default-php-fpm-config, php-fpm-shepherd-service, php-fpm-activation): Use this. * doc/guix.texi (Web Services): Document this. --- doc/guix.texi | 2 ++ gnu/services/web.scm | 48 ++++++++++++++++++++++++++------------------ 2 files changed, 30 insertions(+), 20 deletions(-) diff --git a/doc/guix.texi b/doc/guix.texi index 7b8f7acd29..d83071b432 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -17608,6 +17608,8 @@ Determines whether php errors and warning should be sent to clients and displayed in their browsers. This is useful for local php development, but a security risk for public sites, as error messages can reveal passwords and personal data. +@item @code{timezone} (default @code{#f}) +Specifies @code{php_admin_value[date.timezone]} parameter. @item @code{workers-logfile} (default @code{(string-append "/var/log/php" (version-major (package-version php)) "-fpm.www.log")}) This file will log the @code{stderr} outputs of php worker processes. Can be set to @code{#f} to disable logging. diff --git a/gnu/services/web.scm b/gnu/services/web.scm index fcf453c248..d71fed20ed 100644 --- a/gnu/services/web.scm +++ b/gnu/services/web.scm @@ -142,6 +142,7 @@ php-fpm-configuration-log-file php-fpm-configuration-process-manager php-fpm-configuration-display-errors + php-fpm-configuration-timezone php-fpm-configuration-workers-log-file php-fpm-configuration-file @@ -773,6 +774,8 @@ of index files." (default (php-fpm-dynamic-process-manager-configuration))) (display-errors php-fpm-configuration-display-errors (default #f)) + (timezone php-fpm-configuration-timezone + (default #f)) (workers-log-file php-fpm-configuration-workers-log-file (default (string-append "/var/log/php" (version-major (package-version php)) @@ -827,7 +830,7 @@ of index files." (shell (file-append shadow "/sbin/nologin"))))))) (define (default-php-fpm-config socket user group socket-user socket-group - pid-file log-file pm display-errors workers-log-file) + pid-file log-file pm display-errors timezone workers-log-file) (apply mixed-text-file "php-fpm.conf" (flatten "[global]\n" @@ -840,6 +843,10 @@ of index files." "listen.owner =" socket-user "\n" "listen.group =" socket-group "\n" + (if timezone + (string-append "php_admin_value[date.timezone] = \"" timezone "\"\n") + "") + (match pm (($ pm.max-children @@ -879,7 +886,8 @@ of index files." (define php-fpm-shepherd-service (match-lambda (($ php socket user group socket-user socket-group - pid-file log-file pm display-errors workers-log-file file) + pid-file log-file pm display-errors + timezone workers-log-file file) (list (shepherd-service (provision '(php-fpm)) (documentation "Run the php-fpm daemon.") @@ -890,27 +898,27 @@ of index files." #$(or file (default-php-fpm-config socket user group socket-user socket-group pid-file log-file - pm display-errors workers-log-file))) + pm display-errors timezone workers-log-file))) #:pid-file #$pid-file)) (stop #~(make-kill-destructor))))))) -(define php-fpm-activation - (match-lambda - (($ _ _ user _ _ _ _ log-file _ _ workers-log-file _) - #~(begin - (use-modules (guix build utils)) - (let* ((user (getpwnam #$user)) - (touch (lambda (file-name) - (call-with-output-file file-name (const #t)))) - (init-log-file - (lambda (file-name) - (when #$workers-log-file - (when (not (file-exists? file-name)) - (touch file-name)) - (chown file-name (passwd:uid user) (passwd:gid user)) - (chmod file-name #o660))))) - (init-log-file #$log-file) - (init-log-file #$workers-log-file)))))) +(define (php-fpm-activation config) + #~(begin + (use-modules (guix build utils)) + (let* ((user (getpwnam #$(php-fpm-configuration-user config))) + (touch (lambda (file-name) + (call-with-output-file file-name (const #t)))) + (workers-log-file + #$(php-fpm-configuration-workers-log-file config)) + (init-log-file + (lambda (file-name) + (when workers-log-file + (when (not (file-exists? file-name)) + (touch file-name)) + (chown file-name (passwd:uid user) (passwd:gid user)) + (chmod file-name #o660))))) + (init-log-file #$(php-fpm-configuration-log-file config)) + (init-log-file workers-log-file)))) (define php-fpm-service-type From patchwork Thu Nov 29 18:50:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 352 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id B4F271686D; Thu, 29 Nov 2018 18:52:20 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id 6F32216869 for ; Thu, 29 Nov 2018 18:52:20 +0000 (GMT) Received: from localhost ([::1]:55776 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRQB-0007Hc-Dx for patchwork@mira.cbaines.net; Thu, 29 Nov 2018 13:52:19 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46202) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRQ0-0007Ap-QR for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSRPw-0001rw-7p for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:08 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50856) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSRPw-0001rq-3k for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:04 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gSRPv-00029l-Vq for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:04 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33549] [PATCH 5/6] gnu: Add php-with-bcmath. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Nov 2018 18:52:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33549 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33549@debbugs.gnu.org Received: via spool by 33549-submit@debbugs.gnu.org id=B33549.15435174788200 (code B ref 33549); Thu, 29 Nov 2018 18:52:03 +0000 Received: (at 33549) by debbugs.gnu.org; 29 Nov 2018 18:51:18 +0000 Received: from localhost ([127.0.0.1]:55108 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRPC-000286-7C for submit@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:18 -0500 Received: from mail-lj1-f170.google.com ([209.85.208.170]:41182) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP5-00026w-Mh for 33549@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:12 -0500 Received: by mail-lj1-f170.google.com with SMTP id z80-v6so2689089ljb.8 for <33549@debbugs.gnu.org>; Thu, 29 Nov 2018 10:51:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=cG8qSZybPA+kRNtdYYx1GtSy7z77oKfVhxsky4iJqeI=; b=r9uYcKpIheTM7iC4uNmX0NVkTjcDgjvz+zxschJIgdPSHi9Rod3IV0peGt9RjKun6K joCI0riZ8xcrx/zZGtLY5H06vfLdJWmp93WPTrrwe9cD/XiqueDHH0a9Fv+IoU6A4CQW Qqb5Kv1ThFU6RwOx+JxXiFusdxBZJwa+/Z7E1H3LeZbjmfRMm9bbKbueXS0RMlU1Nflw 3Z5TjoHtCxW35Ll2jcgYw9OfLgnEQU1R9IqGx1asYhdqVkZ/tvfOPl4SoyDudWuPPfZt LOXODViKy/0tzn3hZ2ocaeBikg/f3ZYIdq2DEv5bhNaRgSeQIpc6X33vu6X433Y10PBy rHFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=cG8qSZybPA+kRNtdYYx1GtSy7z77oKfVhxsky4iJqeI=; b=WWwqBG9sDnbtVpozB71vS3zTJ4dXXuGFTnBo6u5+8z/yYaV0voRQeUcIlQInGFUt/Z SEDkK35LHfV9tJYKbCLBsDoUYf/JzeoBjKNgPZQK6KMtCbOLDqoEYpp1SpLlDvy4fPxo NnyYZnhxYQFh/pzohAKxNVP+CMWDFKuuLxRi9PjCm8rSzm/0BzCBJ5RwjPHrbp+Epzbb JtZtOxusw7xokHUS/btiMRN3DgTOoKE6qi/3TtI2vue7tWyHH3V6zMRgViPF2gcDvh/C hYZ6lFmG1HCFL4B7w5J2aYQWm0baQfEQtzdTuOYV6aF9mGjplnb+Dqcxfbyu+/MgAyiS iOmQ== X-Gm-Message-State: AA+aEWb/V7PdjdfUqK3ZnBXN3lbmIsPkjIAlR4PV0Fu0uqcMYCPoti9Z t95AC9od/OyO+EkRVQr+qxE/CwM7nko= X-Google-Smtp-Source: AFSGD/U8u9muy2DcRhXX8hlglOC9bptoPn0FYrNNU7/Laxx3HAm6nFXnpLG2zEpTKzM5nbSHnlDsGA== X-Received: by 2002:a2e:197:: with SMTP id f23-v6mr1868677lji.144.1543517465283; Thu, 29 Nov 2018 10:51:05 -0800 (PST) Received: from localhost.localdomain ([178.70.249.201]) by smtp.gmail.com with ESMTPSA id k21-v6sm406705ljc.15.2018.11.29.10.51.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 10:51:04 -0800 (PST) From: Oleg Pykhalov Date: Thu, 29 Nov 2018 21:50:41 +0300 Message-Id: <20181129185042.6050-5-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129185042.6050-1-go.wigust@gmail.com> References: <20181129185042.6050-1-go.wigust@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/packages/php.scm (php-with-bcmath): New variable. --- gnu/packages/php.scm | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/gnu/packages/php.scm b/gnu/packages/php.scm index a22591d377..07246b0833 100644 --- a/gnu/packages/php.scm +++ b/gnu/packages/php.scm @@ -48,6 +48,7 @@ #:use-module (guix packages) #:use-module (guix download) #:use-module (guix build-system gnu) + #:use-module (guix utils) #:use-module ((guix licenses) #:prefix license:)) (define gd-for-php @@ -360,3 +361,12 @@ systems, web content management systems and web frameworks." ) license:lgpl2.1+ ; ext/bcmath/libbcmath license:bsd-2 ; ext/fileinfo/libmagic license:expat)))) ; ext/date/lib + +(define-public php-with-bcmath + (package + (inherit php) + (name "php-with-bcmath") + (arguments + (substitute-keyword-arguments (package-arguments php) + ((#:configure-flags flags) + `(cons "--enable-bcmath" ,flags)))))) From patchwork Thu Nov 29 18:50:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Oleg Pykhalov X-Patchwork-Id: 354 Return-Path: X-Original-To: patchwork@mira.cbaines.net Delivered-To: patchwork@mira.cbaines.net Received: by mira.cbaines.net (Postfix, from userid 113) id 911CE1686F; Thu, 29 Nov 2018 18:52:28 +0000 (GMT) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on mira.cbaines.net X-Spam-Level: X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) by mira.cbaines.net (Postfix) with ESMTPS id DC3931686C for ; Thu, 29 Nov 2018 18:52:27 +0000 (GMT) Received: from localhost ([::1]:55778 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRQJ-0007JF-7F for patchwork@mira.cbaines.net; Thu, 29 Nov 2018 13:52:27 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46233) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gSRQ5-0007Es-22 for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:15 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gSRQ0-0001we-Ky for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:12 -0500 Received: from debbugs.gnu.org ([208.118.235.43]:50857) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gSRPy-0001ub-EK for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:06 -0500 Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.84_2) (envelope-from ) id 1gSRPw-00029s-HU for guix-patches@gnu.org; Thu, 29 Nov 2018 13:52:06 -0500 X-Loop: help-debbugs@gnu.org Subject: [bug#33549] [PATCH 6/6] services: monitoring: Add 'zabbix-front-end'. Resent-From: Oleg Pykhalov Original-Sender: "Debbugs-submit" Resent-CC: guix-patches@gnu.org Resent-Date: Thu, 29 Nov 2018 18:52:04 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 33549 X-GNU-PR-Package: guix-patches X-GNU-PR-Keywords: patch To: 33549@debbugs.gnu.org Received: via spool by 33549-submit@debbugs.gnu.org id=B33549.15435174798207 (code B ref 33549); Thu, 29 Nov 2018 18:52:04 +0000 Received: (at 33549) by debbugs.gnu.org; 29 Nov 2018 18:51:19 +0000 Received: from localhost ([127.0.0.1]:55110 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRPC-00028D-Go for submit@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:19 -0500 Received: from mail-lj1-f173.google.com ([209.85.208.173]:42533) by debbugs.gnu.org with esmtp (Exim 4.84_2) (envelope-from ) id 1gSRP6-000270-PD for 33549@debbugs.gnu.org; Thu, 29 Nov 2018 13:51:13 -0500 Received: by mail-lj1-f173.google.com with SMTP id l15-v6so2689760lja.9 for <33549@debbugs.gnu.org>; Thu, 29 Nov 2018 10:51:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=gXBVFtniVmxKfRj6VfxwMlrdOe3ll1rsXmbjNMs2fpo=; b=h+gGgc+tfocpNESS7tO2bNbWzwGd4EX1NKaHYb2NSUNF9AZ3Ch/fe8RP3TTQygaCS/ WbcQ8yVdwUoVrKXPREQ+V4mKsDAwDw+uz4IS6Z8XOwRk9fCBEpPh7DynzxziOF9b+Xz7 irnzlGpMY3Y7MsFBrjeDZkGfPX3cR+WHnKdY3ow3MQlc/1Wyul7jBKfpH7MObX09nH1y Ku5/gLPPfIHKhQiOfBF4VE1G3ZMUjnQG0j0clfxTRxycWFy/0XWXVMI5wM1DwC30UTVL tzkvXsdDeEZyGImeMWYBGpBLYOOEWkBTfX0E2Lj3KXV83aBXMkq+vXGp8BEN1CfVj4oR Lz+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=gXBVFtniVmxKfRj6VfxwMlrdOe3ll1rsXmbjNMs2fpo=; b=VU15cXtfYZMHA4RKihvwtGUwecipJRAg/5SfpYECycsqtDGAvU2y79Bb8Mht88bYSv eR6+o0gjwgvD0lMnMC1BQ3juxPJuPSM07C2Bq0q0a6UxNnS+8M62/+RCy2O33qnNrmCF 4YctjIK/QeUWcW5F2Ay1NKtRPnID2mkd87OvfnW44Jhs+Xf/D5N4oT+HDMfiU5fRk/X0 tFqi/1SCc4JvONiDQPZ1Vlt0Ot4LS/A55cBQfH7s+k5Tt3xA7+hwuoiNT8wu0g/WxiRP 96LdeLg6PUI1zWl29h/WrbuwUQR8bBpYadZ2zNPHxQg0bLKwOwf+m72MYa6mYE90Wwm0 qntw== X-Gm-Message-State: AA+aEWYnQjCUITpyEJYlox3Y3t4z+TgZ2TBldz54fuo/tPY5oeW4SB/X BQj/AO3WyvlmgPkt14b//SWN+jZkqbA= X-Google-Smtp-Source: AFSGD/UZsteAgYhFt95e8VK0yKfscp+IAXJijgnpR7IVq+IjmY0qFaXVXAjUlr53gizNvQrQnv1pbA== X-Received: by 2002:a2e:95c6:: with SMTP id y6-v6mr1828281ljh.59.1543517466431; Thu, 29 Nov 2018 10:51:06 -0800 (PST) Received: from localhost.localdomain ([178.70.249.201]) by smtp.gmail.com with ESMTPSA id k21-v6sm406705ljc.15.2018.11.29.10.51.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 29 Nov 2018 10:51:05 -0800 (PST) From: Oleg Pykhalov Date: Thu, 29 Nov 2018 21:50:42 +0300 Message-Id: <20181129185042.6050-6-go.wigust@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181129185042.6050-1-go.wigust@gmail.com> References: <20181129185042.6050-1-go.wigust@gmail.com> MIME-Version: 1.0 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.18 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 208.118.235.43 X-BeenThere: guix-patches@gnu.org List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guix-patches-bounces+patchwork=mira.cbaines.net@gnu.org Sender: "Guix-patches" X-getmail-retrieved-from-mailbox: Patches * gnu/services/monitoring.scm (nginx-server-configuration-list?, serialize-nginx-server-configuration-list, zabbix-front-end-configuration, zabbix-front-end-config, zabbix-front-end-activation, generate-zabbix-front-end-documentation): New procedures. (%zabbix-front-end-configuration-nginx, %maintenance.inc.php, zabbix-front-end-service-type): New variables. * doc/guix.texi (Monitoring Services): Document this. --- doc/guix.texi | 75 ++++++++++++++++++ gnu/services/monitoring.scm | 146 +++++++++++++++++++++++++++++++++++- gnu/tests/monitoring.scm | 49 ++++++++++++ 3 files changed, 269 insertions(+), 1 deletion(-) diff --git a/doc/guix.texi b/doc/guix.texi index d83071b432..a1de8b0f15 100644 --- a/doc/guix.texi +++ b/doc/guix.texi @@ -16854,6 +16854,81 @@ Defaults to @samp{()}. @end deftypevr +@c %end of fragment + +@subsubheading Zabbix front-end +@cindex zabbix zabbix-front-end + +This service provides a WEB interface to Zabbix server. + +@c %start of fragment + +Available @code{zabbix-front-end-configuration} fields are: + +@deftypevr {@code{zabbix-front-end-configuration} parameter} nginx-server-configuration-list nginx +NGINX configuration. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-host +Database host name. + +Defaults to @samp{"localhost"}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} number db-port +Database port. + +Defaults to @samp{5432}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-name +Database name. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-user +Database user. + +Defaults to @samp{"zabbix"}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-password +Database password. Please, use @code{db-secret-file} instead. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string db-secret-file +Secret file which will be appended to @file{zabbix.conf.php} file. This +file contains credentials for use by Zabbix front-end. You are expected +to create it manually. + +Defaults to @samp{""}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} string zabbix-host +Zabbix server hostname. + +Defaults to @samp{"localhost"}. + +@end deftypevr + +@deftypevr {@code{zabbix-front-end-configuration} parameter} number zabbix-port +Zabbix server port. + +Defaults to @samp{10051}. + +@end deftypevr + + @c %end of fragment @node Kerberos Services diff --git a/gnu/services/monitoring.scm b/gnu/services/monitoring.scm index 274228af89..452f26ef8a 100644 --- a/gnu/services/monitoring.scm +++ b/gnu/services/monitoring.scm @@ -22,6 +22,7 @@ #:use-module (gnu services) #:use-module (gnu services configuration) #:use-module (gnu services shepherd) + #:use-module (gnu services web) #:use-module (gnu packages admin) #:use-module (gnu packages monitoring) #:use-module (gnu system shadow) @@ -29,6 +30,7 @@ #:use-module (guix packages) #:use-module (guix records) #:use-module (ice-9 match) + #:use-module (ice-9 rdelim) #:use-module (srfi srfi-26) #:export (darkstat-configuration prometheus-node-exporter-configuration @@ -38,7 +40,10 @@ zabbix-server-configuration zabbix-server-service-type zabbix-agent-configuration - zabbix-agent-service-type)) + zabbix-agent-service-type + zabbix-front-end-configuration + zabbix-front-end-service-type + %zabbix-front-end-configuration-nginx)) ;;; @@ -174,6 +179,12 @@ prometheus.") (define (serialize-include-files field-name val) (if (null? val) "" (for-each (cut serialize-field 'include <>) val))) +(define (nginx-server-configuration-list? val) + (and (list? val) (and-map nginx-server-configuration? val))) + +(define (serialize-nginx-server-configuration-list field-name val) + "") + (define-configuration zabbix-server-configuration (zabbix-server (package zabbix-server) @@ -439,3 +450,136 @@ configuration file.")) `((zabbix-agent-configuration ,zabbix-agent-configuration-fields)) 'zabbix-agent-configuration)) + +(define %zabbix-front-end-configuration-nginx + (nginx-server-configuration + (root #~(string-append #$zabbix-server:front-end "/share/zabbix/php")) + (index '("index.php")) + (locations + (let ((php-location (nginx-php-location))) + (list (nginx-location-configuration + (inherit php-location) + (body (append (nginx-location-configuration-body php-location) + (list " +fastcgi_param PHP_VALUE \"post_max_size = 16M + max_execution_time = 300\"; +"))))))))) + +(define-configuration zabbix-front-end-configuration + ;; TODO: Specify zabbix front-end package. + ;; (zabbix- + ;; (package zabbix-front-end) + ;; "The zabbix-front-end package.") + (nginx + (nginx-server-configuration-list + (list %zabbix-front-end-configuration-nginx)) + "NGINX configuration.") + (db-host + (string "localhost") + "Database host name.") + (db-port + (number 5432) + "Database port.") + (db-name + (string "zabbix") + "Database name.") + (db-user + (string "zabbix") + "Database user.") + (db-password + (string "") + "Database password. Please, use @code{db-secret-file} instead.") + (db-secret-file + (string "") + "Secret file which will be appended to @file{zabbix.conf.php} file. This +file contains credentials for use by Zabbix front-end. You are expected to +create it manually.") + (zabbix-host + (string "localhost") + "Zabbix server hostname.") + (zabbix-port + (number 10051) + "Zabbix server port.")) + +(define zabbix-front-end-config + (match-lambda + (($ + _ db-host db-port db-name db-user db-password db-secret-file + zabbix-host zabbix-port) + (mixed-text-file "zabbix.conf.php" + "\ +string db-port) "'; +$DB['DATABASE'] = '" db-name "'; +$DB['USER'] = '" db-user "'; +$DB['PASSWORD'] = '" (if (string-null? db-password) + (if (string-null? db-secret-file) + (display "Provide a `db-secret-file' \ +or `db-password' field. +" + (current-error-port)) + (string-trim-both + (with-input-from-file db-secret-file + read-string))) + (begin + (display " +Hint: Consider use `db-secret-file' instead of `db-password' and unset +`db-password' in `zabbix-front-end-configuration' for security. +") + db-password)) "'; + +// Schema name. Used for IBM DB2 and PostgreSQL. +$DB['SCHEMA'] = ''; + +$ZBX_SERVER = '" zabbix-host "'; +$ZBX_SERVER_PORT = '" (number->string zabbix-port) "'; +$ZBX_SERVER_NAME = ''; + +$IMAGE_FORMAT_DEFAULT = IMAGE_FORMAT_PNG; +")))) + +(define %maintenance.inc.php + ;; Empty php file to allow us move zabbix-frontend configs to ‘/etc/zabbix’ + ;; directory. See ‘install-front-end’ phase in + ;; (@ (gnu packages monitoring) zabbix-server) package. + "\ +