Skip to content

Instantly share code, notes, and snippets.

View wangwenchao's full-sized avatar
🎯
Focusing

wwc wangwenchao

🎯
Focusing
View GitHub Profile
@wangwenchao
wangwenchao / install_start_stop_daemon.sh
Created August 27, 2018 02:26 — forked from yuuichi-fujioka/install_start_stop_daemon.sh
install start-stop-daemon to centos, fedora, redhat.
#!/bin/bash
cd /usr/local/src
wget http://developer.axis.com/download/distribution/apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
tar zxvf apps-sys-utils-start-stop-daemon-IR1_9_18-2.tar.gz
cd apps/sys-utils/start-stop-daemon-IR1_9_18-2
gcc start-stop-daemon.c -o start-stop-daemon
cp start-stop-daemon /usr/sbin/
@wangwenchao
wangwenchao / gist:608a8d8b57f93fb1c9d9c8832d7c65d2
Created August 24, 2018 09:01 — forked from mancubus77/gist:447281619be3731461b73dd4a18593c5
Prometheus node exporter init.d (Centos6/RHEL6)
#!/bin/bash
#
# /etc/rc.d/init.d/node_exporter
#
# Prometheus node exporter
#
# description: Prometheus node exporter
# processname: node_exporter
# Source function library.
@wangwenchao
wangwenchao / salt-formula-setup.sh
Last active May 28, 2019 10:20 — forked from mortn/formula-setup.sh
Saltstack formula setup and updating
#!/bin/bash
formulas="sudoers timezone ntp openssh resolver iptables salt systemd users vim rsyslog logrotate vsftpd apt locale epel firewalld golang snmp iscsi lvm rsyncd sysctl zabbix dnsmasq haproxy keepalived docker nginx php postfix chrony letsencrypt libvirt nfs powerdns varnish redmine zookeeper postgres mysql kibana openvpn collectd apache tomcat etcd consul memcached django openvswitch bind ufw mongodb elasticsearch fail2ban vault prometheus node"
BASE_DIR=/srv
formula_root=$BASE_DIR/formulas
state_root=$BASE_DIR/states
pillar_root=$BASE_DIR/pillars
# git use git/https
git_url=git@github.com:saltstack-formulas
@mancubus77
mancubus77 / gist:447281619be3731461b73dd4a18593c5
Last active July 31, 2023 08:40
Prometheus node exporter init.d (Centos6/RHEL6)
#!/bin/bash
#
# /etc/rc.d/init.d/node_exporter
#
# Prometheus node exporter
#
# description: Prometheus node exporter
# processname: node_exporter
# Source function library.
@rushilgupta
rushilgupta / GoConcurrency.md
Last active January 25, 2024 14:59
Concurrency in golang and a mini Load-balancer

INTRO

Concurrency is a domain I have wanted to explore for a long time because the locks and the race conditions have always intimidated me. I recall somebody suggesting concurrency patterns in golang because they said "you share the data and not the variables".

Amused by that, I searched for "concurrency in golang" and bumped into this awesome slide by Rob Pike: https://talks.golang.org/2012/waza.slide#1 which does a great job of explaining channels, concurrency patterns and a mini-architecture of load-balancer (also explains the above one-liner).

Let's dig in:

Goroutines

@eloo
eloo / node_exporter.default
Last active December 22, 2023 09:00
Init.d script for prometheus node exporter
# Set the command-line arguments to pass to the server.
ARGS='-web.listen-address=:9100 -collector.diskstats.ignored-devices="^(ram|loop|fd)\\d+$"'
# Prometheus-node-exporter supports the following options:
# -collector.diskstats.ignored-devices="^(ram|loop|fd|(h|s|v|xv)d[a-z])\\d+$": Regexp of devices to ignore for diskstats.
# -collector.filesystem.ignored-mount-points="^/(sys|proc|dev)($|/)": Regexp of mount points to ignore for filesystem collector.
# -collector.ipvs.procfs="/proc": procfs mountpoint.
# -collector.megacli.command="megacli": Command to run megacli.
# -collector.ntp.server="": NTP server to use for ntp collector.
# -collector.textfile.directory="": Directory to read text files with metrics from.
// example of parallelism
package main
import (
"flag"
"fmt"
"io"
"os"
"sync"
"time"
@Manc
Manc / consul.service
Last active July 15, 2020 03:03 — forked from yunano/consul.service
/etc/systemd/system/consul.service
[Unit]
Description=Consul service discovery agent
Requires=network-online.target
After=network.target
[Service]
User=consul
Group=consul
PIDFile=/run/consul/consul.pid
Restart=on-failure
@iamralch
iamralch / gzip.go
Created July 24, 2015 20:39
Gzip archives in Go
import (
"compress/gzip"
"fmt"
"io"
"os"
"path/filepath"
"strings"
)
func gzipit(source, target string) error {
@JoergM
JoergM / prometheus
Created June 13, 2015 07:44
Prometheus init file for RHEL 5 or 6
#!/bin/bash
#
# /etc/rc.d/init.d/prometheus
#
# Prometheus monitoring server
#
# chkconfig: 2345 20 80 Read
# description: Prometheus monitoring server
# processname: prometheus