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. + "\ +