Skip to content

Instantly share code, notes, and snippets.

View twentythousandphantoms's full-sized avatar
🌐

Andrei Belov twentythousandphantoms

🌐
View GitHub Profile
@twentythousandphantoms
twentythousandphantoms / Dockerfile
Last active December 27, 2022 13:42
Telegraf Dockerfile - to build the telegraf right from the GitHub master branch. Can be useful to test/use features that are still not released.
FROM golang:alpine AS build
RUN apk add --update git dep make alpine-sdk linux-headers
# to build from master left the Version empty:
# I.e.: docker image build --tag your_tag --build-arg VERSION_PREFIX=master .
ARG VERSION_PREFIX="release-"
ARG VERSION
RUN git clone --depth 1 -b ${VERSION_PREFIX}${VERSION} https://github.com/influxdata/telegraf /go/src/github.com/influxdata/telegraf
@twentythousandphantoms
twentythousandphantoms / start-celery-for-dev.py
Created May 15, 2020 00:26 — forked from chenjianjx/start-celery-for-dev.py
A python script which starts celery worker and auto reload it when any code change happens.
'''
A python script which starts celery worker and auto reload it when any code change happens.
I did this because Celery worker's "--autoreload" option seems not working for a lot of people.
'''
import time
from watchdog.observers import Observer ##pip install watchdog
from watchdog.events import PatternMatchingEventHandler
import psutil ##pip install psutil
import os
@twentythousandphantoms
twentythousandphantoms / docker-enter
Created September 24, 2019 16:06
/bin/docker-enter
#!/bin/sh
CONTAINER="${1}"
SHELL="${2:-/bin/sh}"
if [ -z "${CONTAINER}" ]; then
echo "You have not provided the container name or id!"
docker ps --format "{{.Names}}"
exit $?
fi
@twentythousandphantoms
twentythousandphantoms / postgres-cheatsheet.md
Created September 17, 2019 11:07 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@twentythousandphantoms
twentythousandphantoms / Problem: ruby
Last active December 15, 2018 13:18
Problem: ruby <2.5 on ubuntu 18 - installation failed
% rbenv install 2.3.4
Downloading ruby-2.3.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.3/ruby-2.3.4.tar.bz2
Installing ruby-2.3.4...
BUILD FAILED (Ubuntu 18.04 using ruby-build 20170726)
Inspect or clean up the working tree at /tmp/ruby-build.20181215160220.6580
Results logged to /tmp/ruby-build.20181215160220.6580.log
sudo apt-get update
sudo apt-get install \
linux-image-extra-$(uname -r) \
linux-image-extra-virtual
sudo apt-get install \
apt-transport-https \
ca-certificates \
curl \
software-properties-common
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -
wget -O - -q icanhazip.com
@twentythousandphantoms
twentythousandphantoms / run-tasks.sh
Last active December 27, 2022 13:45
A bash script for open files or running tasks monitoring. Can be used with Zabbix
#!/bin/bash
while getopts ":tfp:" optname; do
case "$optname" in
"f")
# Количество открытых файлов
MONITORING_TYPE=0
;;
"t")
# Количество запущенных подзадач
#!/bin/bash
BUCKET=""
TMPDIR=/mnt/pgstorage-0/backup-tmp/
HOST=`hostname --fqdn`
DATE=`date +%Y-%m-%d`
MODE="7zip"
shopt -s expand_aliases
alias logger='logger -t s3_backup_rotate -p notice'
if [ ! -z "$BUCKET" ]; then
#!/bin/bash
if [ -d "/sys/class/fc_host" ] ; then
cd /sys/class/fc_host
ls -w1 | while read i ; do
if [ -f "$i/port_name" ] ; then
echo -n "wwn: "
cat $i/port_name
fi
done
elif [ -d "/proc/scsi/qla2xxx" ] ; then