Skip to content

Instantly share code, notes, and snippets.

Avatar

Zhiguang Wang zhiguangwang

View GitHub Profile
@zhiguangwang
zhiguangwang / README.md
Created Aug 16, 2020
Removing node from Elasticsearch cluster
View README.md
POST /_cluster/voting_config_exclusions?node_names=odfe-node-0

GET /_cluster/state?filter_path=metadata.cluster_coordination.voting_config_exclusions

DELETE /_cluster/voting_config_exclusions

Above works with Elasticsearch 7.8, see

@zhiguangwang
zhiguangwang / README.md
Created Mar 15, 2020
Monitor CPU frequency on Linux
View README.md
watch -n1 grep MHz /proc/cpuinfo
@zhiguangwang
zhiguangwang / README.md
Created Sep 12, 2019
Show the environment variables of a running process in Linux
View README.md
sudo cat /proc/<pid>/environ | tr '\0' '\n'
@zhiguangwang
zhiguangwang / README.md
Created Aug 29, 2019
Force Nomad Server to GC
View README.md
@zhiguangwang
zhiguangwang / README.md
Last active Aug 29, 2019
Force-leave Consul nodes in "failed" state
View README.md
@zhiguangwang
zhiguangwang / docker-sslocal.sh
Created Aug 4, 2019
Configure the Docker daemon to use ss-local as HTTP/HTTPS proxy.
View docker-sslocal.sh
#!/bin/bash
set -e
function print_usage {
echo
echo "Usage: docker-sslocal.sh [OPTIONS]"
echo
echo "This script is to configure the Docker daemon to use ss-local as HTTP/HTTPS proxy."
echo
@zhiguangwang
zhiguangwang / README.md
Last active May 5, 2019
bash curl loop
View README.md
curl-loop() { while true; do echo "$(date +%Y-%m-%dT%H:%M:%S%z) $(curl --silent --show-error ${1})"; sleep ${2:-0.5}; done }

Usage

curl-loop <url> [interval]
@zhiguangwang
zhiguangwang / README.md
Last active Nov 19, 2018
SSH Tunnelling
View README.md
ssh-tunnel() { nohup ssh -o ServerAliveInterval=15 -f -N -L ${1}:${2} ${3} > /dev/null 2>&1; }

Usage

ssh-tunnel <local-port> <remote-host>:<remote-port> <bastion>
@zhiguangwang
zhiguangwang / install-salt-minion.sh
Last active Aug 8, 2020
Install salt-minion on Ubuntu
View install-salt-minion.sh
#!/bin/bash
set -e
SALT_VERSION='3001'
if [ -z "$1" ]; then
echo 'Please run this script with argument <salt-master address>'
exit 1
fi
@zhiguangwang
zhiguangwang / README.md
Created Aug 26, 2018
Remove / Uninstall packages marked ‘rc’ on Debian / Ubuntu.
View README.md

Remove / Uninstall packages marked ‘rc’ on Debian / Ubuntu.

While checking the status of packages using dpkg, it is possible to see a ‘rc’ state for some unused packages, this corresponds to:

  • r: the package was marked for removal
  • c: the configuration files are currently present in the system

In other words: the package is not completely removed (config files are still present), but not installed anymore (and obviously not used).

To see a list of packages marked as ‘rc’:

You can’t perform that action at this time.