Skip to content

Instantly share code, notes, and snippets.

View 7error's full-sized avatar
🎯
Focusing

7error

🎯
Focusing
View GitHub Profile
@7error
7error / docker_cid.sh
Created August 13, 2020 01:57 — forked from nmarley/docker_cid.sh
Docker — get container ID from within Docker container
bash-4.3# cat /proc/1/cpuset
/docker/13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e
bash-4.3# DOCKER_CID=$(cat /proc/1/cpuset | cut -c9-)
bash-4.3# echo $DOCKER_CID
13f8c221656e202db979d1e607c9c902282d8719ab70715978dd04ee6069d61e
@7error
7error / mon-ssl.sh
Created June 7, 2020 00:57 — forked from WimObiwan/mon-ssl.sh
Monitor SSL or TLS certificate using OpenSSL
#!/bin/bash
function test-ssl {
# $1: descr
# $2: server:port
# $3: (optional) StartTLS indicator: [pop3|smtp]
echo "(certificate"
echo "-\\n"
@7error
7error / README.md
Created May 25, 2020 14:14 — forked from NiceGuyIT/README.md
nginx JSON to Filebeat to Logstash to Elasticsearch

Intro

This is an example configuration to have nginx output JSON logs to make it easier for Logstash processing. I was trying to get nginx > Filebeat > Logstash > ES working and it wasn't until I connected Filebeat directly to Elasticsearch that I saw the expected data. Google led me to ingest-convert.sh and I realized filebeat setup works for Filebeat > ES but not Filebeat > Logstash > ES. This is because Logstash does not use ingest pipelines by default. You have to enable them in the elasticsearch output block.

Having nginx log JSON in the format required for Elasticsearch means there's very little processing (i.e. grok) to be done in Logstash. nginx can only output JSON for access logs; the error_log format cannot be changed.

Extra fields are output and not used by the Kibana dashboards. I included them in case they might be useful. Since they are not declared in the filebeat setup, their default is "string" when yo

#!/usr/bin/with-contenv sh
#--- PROGRAM -------------------------------------------------------------------------------------------------------
# NAME: s6-service
#% DESCRIPTION: Mimic the ubuntu `service` utility
#% USAGE: service service-name [status|start|up|stop|down|reload|restart|reboot]
#% REQUIRES: s6-svc
#----------------------------------------------------------------------------------------------------------------------
if [ $# -ne 2 ]; then
@7error
7error / wait-for-postgres.sh
Created April 25, 2020 14:42 — forked from nicerobot/wait-for-postgres.sh
A better wait-for-postgres.sh
#!/bin/bash -e
# wait-for-postgres.sh
# Adapted from https://docs.docker.com/compose/startup-order/
# Expects the necessary PG* variables.
until psql -c '\l'; do
echo >&2 "$(date +%Y%m%dt%H%M%S) Postgres is unavailable - sleeping"
sleep 1
done
@7error
7error / local-mongo-replicaset-with-docker
Created March 23, 2020 14:02 — forked from oleurud/local-mongo-replicaset-with-docker
[Local mongo replicaset with docker] #docker #mongo
# pull the official mongo docker container
docker pull mongo
# create network
docker network create my-mongo-cluster
# create mongos
docker run -d --net my-mongo-cluster -p 27017:27017 --name mongo1 mongo mongod --replSet my-mongo-set --port 27017
docker run -d --net my-mongo-cluster -p 27018:27018 --name mongo2 mongo mongod --replSet my-mongo-set --port 27018
docker run -d --net my-mongo-cluster -p 27019:27019 --name mongo3 mongo mongod --replSet my-mongo-set --port 27019
@7error
7error / docker_mongo_Init.md
Created March 23, 2020 14:01 — forked from wcxaaa/docker_mongo_Init.md
Dockerized mongoDB initialization

First create a mongod config file. e.g.

# mongod.conf
# Where and how to store data.
storage:
  dbPath: /data/db
  directoryPerDB: true
  journal:
    enabled: true
@7error
7error / gist:de888556d491e5773150553cb9e49fbd
Created February 7, 2020 02:26 — forked from rishiloyola/gist:79f869749bf54d135f7f6fe61e0e99a7
[ELK Stack] Generate TLS certs for filebeat and logstash
1. Generate new domain name for logstash server.
For this tutorial
domain name = logstash-prod.xyz.com
ip = 1.2.3.4
* Enter to following directory
```
$ sudo mkdir /etc/pki
$ cd /etc/pki
grep -e "^docker" /etc/group >& /dev/null
if [ $? -ne 0 ]
then
groupadd docker
fi
#usermod -aG docker $USER
#newgrp docker
@7error
7error / vagrant-kvm.md
Created January 9, 2020 09:54 — forked from yuanying/vagrant-kvm.md
How to use vagrant-kvm

Install Vagrant

sudo su
apt-get update && apt-get install -y libvirt-dev ruby-all-dev apparmor-utils
curl -O -L https://dl.bintray.com/mitchellh/vagrant/vagrant_1.6.5_x86_64.deb
dpkg -i vagrant_1.6.5_x86_64.deb 
aa-complain /usr/lib/libvirt/virt-aa-helper # workaround
exit

Install vagrant-kvm as user