-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcommandes utiles
382 lines (254 loc) · 8.02 KB
/
commandes utiles
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
Tunnel
#socat tcp-listen:PORT_ECOUTE proxy:PROXY_HOST:DESTINATION_HOST:DESTINATION_PORT &
#svn --quiet checkout svn://0.0.0.0:3690/tags/${ZBX_VERSION} zabbix-${ZBX_VERSION}
#USE CASE : faire passer le flux de svn://svn.zabbix.com:3690/tags/${ZBX_VERSION} dans le proxy ${PROXY_HOST}
socat tcp-listen:3690 proxy:${PROXY_HOST}:svn.zabbix.com:3690 &
svn --quiet checkout svn://0.0.0.0:3690/tags/${ZBX_VERSION} zabbix-${ZBX_VERSION}
ou
EXIT='no'; while [ "$EXIT" == "no" ]; do socat tcp-listen:3690 proxy:${PROXY_HOST}:svn.zabbix.com:3690; svn checkout svn://0.0.0.0:3690/tags/${ZBX_VERSION} zabbix-${ZBX_VERSION} 1>/dev/null; EXIT='yes'; done
socat tcp-listen:3690 proxy:fr.proxy.saint-gobain.com:svn.zabbix.com:3690 &
svn checkout svn://0.0.0.0:3690/tags/3.4.10/frontends/php/ zabbix
Retrouver un package ou une librairie sur Alpine
https://pkgs.alpinelinux.org/contents
######################
#
#
# GIT
#
#
######################
Génération patch
1. cloner le repo
2. Faire les modifications
3. Ajouter toutes fichiers modifiés
# git add -A
4. Commiter les fichiers modifiés
# git commit –m 'Mise aux normes Saint Gobain'
5. Générer le fichier de patch
# git format-patch HEAD~1
Sauvegarde des identifiants
# git config credential.helper store
# git pull
######################
#
#
# CERTIFICAT
#
#
######################
openssl req -x509 -nodes -days 1068 -newkey rsa:2048 -keyout server.key -out server.crt
####################
#
# VHOST
1. Reverse proxy with DocumentRoot (local directory)
#Disable ProxyPass for /oauth
ProxyPass /oauth !
ProxyPass / http://localhost:3000/
ProxyPassReverse / http://localhost:3000/
#Redirect /oauth to local directory
Alias /oauth /var/www/html/oauth
#################
# BEAT
# Catalina
- input_type: log
paths:
- /REP/logs/catalina.out
fields:
key1: name1
key2 : name2
fields_under_root: true
#Commençant par exemple par 2018-08-03 13:17:58,537 ou Aug 03, 2018 2:23:24
multiline.pattern: '^[0-9]{4}-[0-9]{2}-[0-9]{2} [0-9]{2}|^[a-zA-Z]{3} [0-9]{2}, [0-9]{4}|Caused by'
multiline.negate: true
multiline.match: after
#################
# LOGSTASH
# FILTER
- TOMCAT
filter {
#Suppression de logs inutile
if ("PATTERN" in [message]) {
drop {}
}
#Parsing de logs java
grok {
match => { "message" => "%{YEAR}-%{MONTHNUM}-%{MONTHDAY}[T ]%{HOUR}:%{MINUTE}:%{SECOND},%{INT}%{SPACE}%{LOGLEVEL:level}%{SPACE}%{NOTSPACE:Thread}[T ]%{NOTSPACE:Category}[T ]%{GREEDYDATA:message}" }
match => { "message" => "%{MONTH}[T ]%{MONTHDAY},[T ]%{YEAR}[T ]%{HOUR}:%{MINUTE}:%{SECOND}[T ]%{NOTSPACE:Meridiem}[T ]%{NOTSPACE:Thread}%{DATA:Category}%{LOGLEVEL:level}:[T ]%{GREEDYDATA:message}" }
match => { "message" => "Caused by:[T ]%{NOTSPACE:Thread}[T ]%{GREEDYDATA:message}" }
match => { "message" => "Exception in thread[T ]%{NOTSPACE:Thread}[T ]%{GREEDYDATA:message}" }
overwrite => [ "message" ]
}
date {
match => ["event_timestamp", "dd/MMM/yyyy:HH:mm:ss Z"]
target => "@timestamp"
}
#Matching date à partir du 1er janvier 1970
#UNIX (sans miliseconde) et UNIX_MS
date {
match => ["timestamp", "UNIX_MS"]
target => "@timestamp"
}
#Modification structure des logs
mutate {
remove_field => ["byte", "offset", "input_type","@version", "event_timestamp", "beat", "type", "source", "httpversion" ]
remove_tag => [ "beats_input_codec_plain_applied" ]
}
#Suppression des logs non conforme
#if !("_grokparsefailure" in [tags]) {
# mutate {
# remove_field => [ "message" ]
# }
#}
}
-JSON
filter {
json {
source => "message"
target => "parsed_json"
}
#Pour exploser les sous structures du json
split {
field => "[parsed_json][field_to_explose]"
}
date {
match => ["[parsed_json][timestamp]", "UNIX_MS"]
target => "@timestamp"
}
mutate {
#Creation de champs a partir d'entrée du "parsed_json"
#Il faut donner la valeur avec la forme de tableau
add_field => {
"api_correlationId" => "%{[parsed_json][correlationId}"
"api_hostname" => "%{[parsed_json][processInfo][hostname}"
}
#On supprime l'explosion du json une fois la récupération de nos champs faits
remove_field => [ "parsed_json" ]
remove_tag => [ "beats_input_codec_plain_applied" ]
}
}
#################
# ELASTICSEARCH
/_search
GET INDEX/_search
{
"query": {
"match": {
"env": "prod"
}
},
"post_filter": {
"range" : {
"@timestamp" : {
"lt" : "now-1d/d"
}
}
}
}
# QUERY: multi-critere
GET INDEX/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"env": "prod"
}
},
{
"match": {
"host": "hostname"
}
}
]
}
},
"post_filter": {
"range" : {
"@timestamp" : {
"lt" : "now-1d/d"
}
}
}
}
curl : volatile
curl -X PUT "10.154.76.186:9200/_cluster/settings" -H 'Content-Type: application/json' -d'
{
"transient": {
"cluster.routing.allocation.enable": "all",
"cluster.routing.allocation.disk.threshold_enabled": true,
"cluster.routing.allocation.disk.watermark.low": "93%",
"cluster.routing.allocation.disk.watermark.high": "95%"
}
}
'
Config file : persistent
cluster.routing.allocation.disk.threshold_enabled: true
cluster.routing.allocation.disk.watermark.low: 93%
cluster.routing.allocation.disk.watermark.high: 95%
http://localhost:9200/_cat/indices/*?v&s=pri.store.size:desc
http://localhost:9200/_cat/indices?h=h,s,i,id,p,r,dc,dd,ss,creation.date.string
http://localhost:9200/_cat/indices/*?s=creation.date.string:asc&h=s,i,dc,dd,ss,creation.date.string
WGET
Via ~/.wgetrc file:
use_proxy=yes
http_proxy=127.0.0.1:8080
https_proxy=127.0.0.1:8080
DOCKER
Via ~/.docker/config.json
{
"auths": {
"dtr443.docker4sg.prd.cloudwatt.saint-gobain.net:443": {
"auth": "XXX",
"identitytoken": "XXX"
}
},
"HttpHeaders": {
"User-Agent": "Docker-Client/18.03.1-ce (linux)"
}
}
SVN
Via ~/.subversion/servers ou /etc/subversion/servers :
[global]
http-proxy-exceptions = *.myowndomain.com
http-proxy-host = proxyaddr.mydomain.com
http-proxy-port = 3128
http-proxy-username = userme
http-proxy-password = passyou
http-compression = no
HARBOR API
Copy and paste the contents of https://raw.githubusercontent.com/vmware/harbor/master/docs/swagger.yaml into http://editor.swagger.io/
DOCKER
yum install -y yum-utils device-mapper-persistent-data lvm2
## Penser a installer EPEL au besoin pour les dépendances
#wget http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
#rpm -ivh epel-release-latest-7.noarch.rpm
yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
#yum -y install docker-ce
##ou une version precise
yum list docker-ce --showduplicates | sort -r
yum -y install docker-ce-<VERSION STRING>
#yum-config-manager --enable extras
For AWS: sudo yum-config-manager --enable rhui-REGION-rhel-server-extras
#For Azure: sudo yum-config-manager --enable rhui-rhel-7-server-rhui-extras-rpms
##Pour palier à cette erreur
##x509: certificate signed by unknown authority
cat /etc/docker/daemon.json
#{
# "insecure-registries" : [ "dtr443.docker4sg.prd.cloudwatt.saint-gobain.net:443" ]
#}
##Dans une configuration avec PROXY
cat /etc/systemd/system/docker.service.d/proxy.conf
[Service]
Environment="HTTPS_PROXY=http://fr.proxy.saint-gobain.com:8084/"
systemctl start docker
docker login -u <USER> https://dtr443.docker4sg.prd.cloudwatt.saint-gobain.net:443
#Fournir le mot de passe dans le prompt
docker pull dtr443.docker4sg.prd.cloudwatt.saint-gobain.net:443/software-factory/zabbix_server:2018-01
docker pull dtr443.docker4sg.prd.cloudwatt.saint-gobain.net:443/devops4sg/alpine:3.7
yum -y install git
git config --global http.sslVerify false
git config --global user.name "Martin LEKPA"
git config --global user.email [email protected]
mkdir -p /data/repo
git clone https://cerebro.digital-solutions.saint-gobain.com/operations/zabbix_server.git