Browse Source

Fist commit

tags/pkg/dev/eole-2.6.2/0.0.1-0
Philippe Caseiro 1 year ago
commit
5c52850d0c

+ 26
- 0
Makefile View File

@@ -0,0 +1,26 @@
1
+################################
2
+# Makefile pour XXX-XXX
3
+################################
4
+
5
+SOURCE=eole-mysql-exporter
6
+VERSION=0.1
7
+EOLE_VERSION=2.5
8
+EOLE_RELEASE=2.5.2
9
+PKGAPPS=non
10
+
11
+################################
12
+# Début de zone à ne pas éditer
13
+################################
14
+
15
+include eole.mk
16
+include apps.mk
17
+
18
+################################
19
+# Fin de zone à ne pas éditer
20
+################################
21
+
22
+# Makefile rules dedicated to application
23
+# if exists
24
+ifneq (, $(strip $(wildcard $(SOURCE).mk)))
25
+include $(SOURCE).mk
26
+endif

+ 18
- 0
README.md View File

@@ -0,0 +1,18 @@
1
+## eole-mysql-exporter
2
+Eolisation de la sonde de surveillance Prometheus mysql.
3
+
4
+
5
+### Installation de la sonde eole-mysql-exporter :
6
+
7
+
8
+1. gen_config
9
+
10
+    ```
11
+Mode expert > Dépot tiers > Ajouter un dépot
12
+        Cadoles pour environnement de Qualification
13
+            Libellé du dépot = Cadoles
14
+            Déclaration du dépôt = deb https://vulcain.cadoles.com 2.6.2-staging main
15
+            Méthode de récupération de la clé = URL de la clé
16
+            URL de la clé = https://vulcain.cadoles.com/cadoles.gpg
17
+```
18
+apt install eole-mysql-exporter

+ 64
- 0
apps.mk View File

@@ -0,0 +1,64 @@
1
+# 
2
+# NE PAS EDITER CE FICHIER
3
+#
4
+# Voir Makefile
5
+
6
+
7
+##########################
8
+# Application web envole #
9
+##########################
10
+ifneq (, $(filter oui web, $(PKGAPPS)))
11
+#
12
+# Sanity check
13
+#
14
+ifeq (, $(filter-out X.X, $(strip $(VERSION))))
15
+$(error $$(VERSION) variable has incorrect value '$(VERSION)')
16
+endif
17
+
18
+# Where to store web application files
19
+WEB_PATH				:= $(DESTDIR)/var/www/html
20
+
21
+# Envole
22
+sharenvole_PROG_DIR			:= $(DESTDIR)/usr/share/envole/$(SOURCE)
23
+
24
+src_$(SOURCE)-$(VERSION)_REC_DIR	:= $(WEB_PATH)/$(SOURCE)
25
+src_plugins-$(VERSION)_REC_DIR		:= $(WEB_PATH)/$(SOURCE)/plugin
26
+src_lang-$(VERSION)_REC_DIR		:= $(WEB_PATH)/$(SOURCE)/lang
27
+
28
+endif
29
+
30
+##########################
31
+# Application EOLE flask #
32
+##########################
33
+ifneq (, $(filter flask, $(PKGAPPS)))
34
+#
35
+# Sanity check
36
+#
37
+ifeq (, $(filter-out XXX, $(strip $(FLASK_MODULE))))
38
+$(error $$(FLASK_MODULE) variable has incorrect value '$(FLASK_MODULE)')
39
+endif
40
+
41
+ifeq (, $(strip $(wildcard src/$(FLASK_MODULE).conf)))
42
+$(error missing eoleflask configuration file 'src/$(FLASK_MODULE).conf')
43
+endif
44
+
45
+# Everything is related to mount point
46
+APPS_MOUNT_POINT	:= $(shell sed -ne 's|^"MOUNT_POINT"[[:space:]]*:[[:space:]]*"/\([^"]*\)",|\1|p' \
47
+	src/$(FLASK_MODULE).conf)
48
+
49
+ifeq (, $(strip $(APPS_MOUNT_POINT)))
50
+$(error no "MOUNT_POINT" in eoleflask configuration file 'src/$(FLASK_MODULE).conf')
51
+endif
52
+
53
+# eole-flask configuration
54
+src_DATA_DIR		:= $(DESTDIR)/etc/eole/flask/available
55
+
56
+# Where to store flask application files
57
+FLASK_PATH		:= $(eole_DIR)/flask/$(APPS_MOUNT_POINT)
58
+
59
+# static files
60
+src_$(FLASK_MODULE)_static_REC_DIR	:= $(FLASK_PATH)/static
61
+src_$(FLASK_MODULE)_templates_REC_DIR	:= $(FLASK_PATH)/templates
62
+src_$(FLASK_MODULE)_instance_REC_DIR	:= $(FLASK_PATH)/resources
63
+
64
+endif

BIN
bin/mysqld_exporter View File


+ 11
- 0
diagnose/70-prometheus-node-exporter View File

@@ -0,0 +1,11 @@
1
+#!/bin/bash
2
+
3
+if [ $(CreoleGet activerSndNodeExporter) = "oui" ];then
4
+    . /usr/lib/eole/diagnose.sh
5
+
6
+    EchoGras "*** Sonde Prometheus"
7
+    TestHTTPPage "Système" "http://localhost:9100"
8
+    echo
9
+fi
10
+
11
+exit 0

+ 43
- 0
dicos/71_mysql_exporter.xml View File

@@ -0,0 +1,43 @@
1
+<?xml version="1.0" encoding="utf-8"?>
2
+<creole>
3
+	<files>
4
+		<file name='/etc/defaults/prometheus-mysql-exporter' source="prometheus-mysql-exporter.defaults" mkdir='True' rm='True'/>
5
+		<service servicelist='slNodeExporter' method='upstart'>node_exporter</service>
6
+		<service_access service='prometheus-mysql-expoter'>
7
+			<port service_accesslist="saSndSys">9104</port>
8
+		</service_access>
9
+		<service_restriction service='prometheus-mysql-expoter'>
10
+			<ip interface='auto' netmask='255.255.255.255' ip_type='SymLinkOption'>sndPrometheusServer</ip>
11
+		</service_restriction>
12
+	</files>
13
+	<variables>
14
+		<family name='services'>
15
+			<variable name='activerSndMysqlExpoter' type='oui/non' description="Activer la sonde de surveillance système">
16
+				<value>oui</value>
17
+			</variable>
18
+		</family>
19
+		<family name='sonde mysql'>
20
+			<variable name='activer_prometheus' type='oui/non' exists='False' hidden='True'>
21
+				<value>non</value>
22
+			</variable>
23
+			<variable name='sndPrometheusServer' type='ip' exists='False' description="Adresse IP du serveur Prometheus"/>
24
+		</family>
25
+	</variables>
26
+	<constraints>
27
+		<condition name='disabled_if_in' source='activerSndMysqlExpoter'>
28
+			<param>non</param>
29
+			<target type='family'>sonde systeme</target>
30
+			<target type='servicelist'>slNodeExporter</target>
31
+			<target type='service_accesslist'>saSndSys</target>
32
+		</condition>
33
+		<fill name='calc_multi_condition' target='sndPrometheusServer'>
34
+			<param>oui</param>
35
+			<param type='eole' name='condition_1'>activer_prometheus</param>
36
+			<param name='match' type='eole'>adresse_ip_eth0</param>
37
+			<param name='default_mismatch'>None</param>
38
+			<param name='default_match'>None</param>
39
+		</fill>
40
+	</constraints>
41
+	<help>
42
+	</help>
43
+</creole>

+ 3
- 0
eole-mysql-exporter.mk View File

@@ -0,0 +1,3 @@
1
+upstart_DATA_DIR := $(DESTDIR)/etc/init
2
+
3
+

+ 231
- 0
eole.mk View File

@@ -0,0 +1,231 @@
1
+#
2
+# NE PAS EDITER CE FICHIER
3
+#
4
+# Utiliser <appli>.mk à inclure à la fin de Makefile
5
+
6
+#################
7
+# Sanity checks #
8
+#################
9
+
10
+ifeq (, $(DESTDIR))
11
+$(warning $$(DESTDIR) is empty, installation will be done in /)
12
+endif
13
+
14
+ifeq (, $(filter-out XXX-XXX, $(strip $(SOURCE))))
15
+$(error $$(SOURCE) variable has incorrect value '$(SOURCE)')
16
+endif
17
+
18
+ifeq (, $(filter-out 2.X, $(strip $(EOLE_VERSION))))
19
+$(error $$(EOLE_VERSION) variable has incorrect value '$(EOLE_VERSION)')
20
+endif
21
+
22
+ifeq (, $(filter-out 2.X.Y, $(strip $(EOLE_RELEASE))))
23
+$(error $$(EOLE_RELEASE) variable has incorrect value '$(EOLE_RELEASE)')
24
+endif
25
+
26
+#########################
27
+# Variables definitions #
28
+#########################
29
+
30
+INSTALL                 := install
31
+INSTALL_DATA            := install -m 644
32
+INSTALL_PROGRAM         := install -m 755
33
+INSTALL_DIRECTORY       := install -m 755 -d
34
+INSTALL_RECURSIVE       := cp -dr --no-preserve=ownership
35
+
36
+# Standard path
37
+bin_PROG_DIR		:= $(DESTDIR)/usr/bin
38
+sbin_PROG_DIR		:= $(DESTDIR)/usr/sbin
39
+man8_DATA_DIR		:= $(DESTDIR)/usr/share/man/fr.UTF-8/man8
40
+
41
+# Base
42
+eole_DIR                := $(DESTDIR)/usr/share/eole
43
+
44
+ifeq ($(strip $(EOLE_VERSION)), 2.3)
45
+diagnose_PROG_DIR       := $(eole_DIR)/diagnose/module
46
+else
47
+diagnose_PROG_DIR       := $(eole_DIR)/diagnose/
48
+endif
49
+
50
+# Creole
51
+creole_DIR              := $(eole_DIR)/creole
52
+dicos_DATA_DIR          := $(creole_DIR)/dicos
53
+tmpl_DATA_DIR           := $(creole_DIR)/distrib
54
+preservice_PROG_DIR     := $(eole_DIR)/preservice
55
+pretemplate_PROG_DIR    := $(eole_DIR)/pretemplate
56
+posttemplate_PROG_DIR   := $(eole_DIR)/posttemplate
57
+postservice_PROG_DIR    := $(eole_DIR)/postservice
58
+ifeq ($(strip $(EOLE_VERSION)), 2.3)
59
+firewall_DATA_DIR       := $(eole_DIR)/firewall
60
+endif
61
+bacula_restore_DATA_DIR := $(eole_DIR)/bacula/restore
62
+bareos_restore_DATA_DIR := $(eole_DIR)/bareos/restore
63
+bacula_fichier_DATA_DIR := $(DESTDIR)/etc/bacula/baculafichiers.d
64
+bareos_fichier_DATA_DIR	:= $(DESTDIR)/etc/bareos/bareosfichiers.d
65
+ifeq ($(strip $(EOLE_VERSION)), 2.3)
66
+schedule_pre_PROG_DIR   := $(eole_DIR)/schedule/pre
67
+schedule_post_PROG_DIR  := $(eole_DIR)/schedule/post
68
+else
69
+schedule_scripts_PROG_DIR	:= $(eole_DIR)/schedule/scripts
70
+endif
71
+extra_REC_DIR		:= $(creole_DIR)/extra
72
+
73
+# Zéphir
74
+zephir_DATA_DIR         := $(DESTDIR)/usr/share/zephir
75
+zephir_configs_DATA_DIR := $(zephir_DATA_DIR)/monitor/configs
76
+zephir_srv_DATA_DIR     := $(zephir_configs_DATA_DIR)/services
77
+zephir_scripts_PROG_DIR := $(zephir_DATA_DIR)/scripts
78
+
79
+# SSO
80
+sso_DATA_DIR            := $(DESTDIR)/usr/share/sso
81
+sso_filtres_DATA_DIR    := $(sso_DATA_DIR)/app_filters
82
+sso_user-info_DATA_DIR  := $(sso_DATA_DIR)/user_infos
83
+
84
+# EAD
85
+ead_DATA_DIR            := $(DESTDIR)/usr/share/ead2/backend/config
86
+ead_actions_DATA_DIR    := $(ead_DATA_DIR)/actions
87
+ead_perms_DATA_DIR      := $(ead_DATA_DIR)/perms
88
+ead_roles_DATA_DIR      := $(ead_DATA_DIR)/roles
89
+
90
+# Program libraries goes under /usr/lib/<PROGRAM>/
91
+lib_$(SOURCE)_DATA_DIR	:= $(DESTDIR)/usr/lib/$(SOURCE)
92
+
93
+# Scripts Eole
94
+scripts_PROG_DIR        := $(eole_DIR)/sbin
95
+lib_eole_DATA_DIR	:= $(DESTDIR)/usr/lib/eole
96
+
97
+# LDAP
98
+ldap_passwords_DATA_DIR := $(eole_DIR)/annuaire/password_files
99
+
100
+# LXC
101
+lxc_DATA_DIR            := $(eole_DIR)/lxc
102
+lxc_fstab_DATA_DIR      := $(lxc_DATA_DIR)/fstab
103
+lxc_hosts_DATA_DIR	:= $(lxc_DATA_DIR)/hosts
104
+
105
+# SQL
106
+sql_DATA_DIR            := $(eole_DIR)/mysql/$(SOURCE)
107
+sql_gen_DATA_DIR        := $(sql_DATA_DIR)/gen
108
+sql_updates_DATA_DIR    := $(sql_DATA_DIR)/updates
109
+
110
+sql_conf_gen_DATA_DIR		:= $(eole_DIR)/applications/gen
111
+sql_conf_passwords_DATA_DIR	:= $(eole_DIR)/applications/passwords
112
+sql_conf_updates_DATA_DIR	:= $(eole_DIR)/applications/updates/$(SOURCE)
113
+
114
+# EoleDB sql directory
115
+db_DIR               := $(eole_DIR)/db
116
+db_gen_DATA_DIR      := $(eole_DIR)/db/$(SOURCE)/gen
117
+db_updates_DATA_DIR  := $(eole_DIR)/db/$(SOURCE)/updates
118
+
119
+# Certifs
120
+certs_DATA_DIR		:= $(eole_DIR)/certs
121
+
122
+# Logrotate
123
+logrotate_DATA_DIR      := $(DESTDIR)/etc/logrotate.d
124
+
125
+# Cron
126
+cron_PROG_DIR 		:= $(DESTDIR)/etc/cron.daily
127
+
128
+# Python modules
129
+ifneq ($(DESTDIR),)
130
+PYTHON_OPTS     := --root $(DESTDIR)
131
+endif
132
+
133
+# Translation
134
+TRANSLATION_SRC := translation
135
+TRANSLATION_DEST := $(DESTDIR)/usr/share/locale
136
+PO_FILES = $(wildcard $(TRANSLATION_SRC)/*/*.po)
137
+MO_FOLDERS = $(addprefix $(TRANSLATION_DEST), $(addsuffix LC_MESSAGES,$(subst $(TRANSLATION_SRC),,$(dir $(PO_FILES)))))
138
+
139
+#############################################
140
+# Common directories and files installation #
141
+#############################################
142
+
143
+all:
144
+
145
+$(MO_FOLDERS):
146
+	$(INSTALL_DIRECTORY) $@
147
+
148
+$(PO_FILES): $(MO_FOLDERS)
149
+	msgfmt -o $(TRANSLATION_DEST)$(subst $(TRANSLATION_SRC),,$(addsuffix LC_MESSAGES,$(dir $@)))/$(notdir $(@:.po=.mo)) $@
150
+
151
+install-lang: $(PO_FILES)
152
+
153
+install:: install-dirs install-files install-lang
154
+
155
+# $1 = command to run
156
+# $2 = source directory
157
+# $3 = destination directory
158
+define fc_install_file
159
+	if [ -d $2 ]; then					\
160
+		for file in `ls -1 $2/`; do			\
161
+		   $1 $2/$$file $3 || true;			\
162
+	    done;						\
163
+	fi
164
+endef
165
+
166
+##
167
+## Directory creation
168
+##
169
+
170
+# use % to catch local name in $*
171
+# data, program and recursive directory require a corresponding
172
+# directory in local sources
173
+%_DATA_DIR %_PROG_DIR %REC_DIR:
174
+	test ! -d $(subst _,/,$*) || $(INSTALL_DIRECTORY) $($@)
175
+
176
+# Create the directory referenced by the variable without a local one.
177
+%_DIR:
178
+	@: # do nothing
179
+
180
+##
181
+## Install files present directly under data, program and recursive directories
182
+##
183
+
184
+# $*   : name of variable
185
+# $($*): value of variable
186
+%-instdata:
187
+	$(call fc_install_file, $(INSTALL_DATA), $(subst _,/,$(subst _DATA_DIR,,$*)), $($*))
188
+
189
+%-instprog:
190
+	$(call fc_install_file, $(INSTALL_PROGRAM), $(subst _,/,$(subst _PROG_DIR,,$*)), $($*))
191
+
192
+%-instrec:
193
+	$(call fc_install_file, $(INSTALL_RECURSIVE), $(subst _,/,$(subst _REC_DIR,,$*)), $($*))
194
+
195
+
196
+# Use second expansion as variables may be created in included
197
+# Makefiles
198
+.SECONDEXPANSION:
199
+
200
+# List of all directories
201
+installdirs_LIST	= $(foreach V, $(filter %_DIR, $(.VARIABLES)),	\
202
+				$(if $(filter file, $(origin $(V))),	\
203
+					$(V)))
204
+# List of data directories
205
+installdata_LIST	= $(filter %_DATA_DIR, $(installdirs_LIST))
206
+# List of program directories
207
+installprog_LIST	= $(filter %_PROG_DIR, $(installdirs_LIST))
208
+# List of recursive directories
209
+installrec_LIST	 	= $(filter %_REC_DIR, $(installdirs_LIST))
210
+
211
+# Expand directories to create as dependency
212
+# Use double-colon to permit user to define additionnal install-dirs
213
+install-dirs:: $$(installdirs_LIST)
214
+
215
+# Expand files to install as dependency
216
+# Use double-colon to permit user to define additionnal install-files
217
+install-files:: install-data-files install-prog-files install-rec-dirs
218
+
219
+install-data-files: $$(patsubst %,%-instdata,$$(installdata_LIST))
220
+
221
+install-prog-files: $$(patsubst %,%-instprog,$$(installprog_LIST))
222
+
223
+install-rec-dirs:   $$(patsubst %,%-instrec,$$(installrec_LIST))
224
+
225
+# Installation of python modules
226
+ifeq ($(shell test -f setup.py && echo 0), 0)
227
+install-files::
228
+	python setup.py install --no-compile --install-layout=deb $(PYTHON_OPTS)
229
+endif
230
+
231
+.PHONY: install install-dirs install-files install-data-files install-prog-files install-rec-dirs

+ 15
- 0
init/prometheus-mysql-exporter View File

@@ -0,0 +1,15 @@
1
+[Unit]
2
+Description=Prometheus exporter for mysql metrics
3
+
4
+[Service]
5
+Restart=always
6
+User=prometheus
7
+EnvironmentFile=/etc/default/prometheus-mysql-exporter
8
+ExecStart=/usr/bin/mysqld-exporter $ARGS
9
+ExecReload=/bin/kill -HUP $MAINPID
10
+TimeoutStopSec=20s
11
+SendSIGKILL=no
12
+
13
+[Install]
14
+WantedBy=multi-user.target
15
+

+ 4
- 0
tmpl/prometheus-mysql-exporter.defaults View File

@@ -0,0 +1,4 @@
1
+# Prometheus Mysql defaults
2
+CNF='/etc/mysql/debian.cnf'
3
+
4
+ARGS="--config.my-cnf=${CNF}"

Loading…
Cancel
Save