Skip to content

Instantly share code, notes, and snippets.

View peerasan's full-sized avatar

Patrickz peerasan

View GitHub Profile
@peerasan
peerasan / cpu.sh
Created June 8, 2019 14:29
Linux CPU Usage
#!/bin/bash
# by Paul Colby (http://colby.id.au), no rights reserved ;)
# https://github.com/pcolby/scripts/blob/master/cpu.sh
PREV_TOTAL=0
PREV_IDLE=0
while true; do
# Get the total CPU statistics, discarding the 'cpu ' prefix.
CPU=(`sed -n 's/^cpu\s//p' /proc/stat`)
@peerasan
peerasan / install-haproxy.sh
Created June 8, 2019 14:30
install haproxy
apt-get install software-properties-common
add-apt-repository ppa:vbernat/haproxy-1.9
apt-get update
apt-get install haproxy
limit_req_zone $request_uri zone=by_uri:10m rate=30r/m;
server {
listen 80;
location /by-uri/burst0 {
limit_req zone=by_uri;
try_files $uri /index.html;
}
@peerasan
peerasan / setup-goaccess.sh
Created June 8, 2019 14:32
Instal goaccess
echo "deb http://deb.goaccess.io/ $(lsb_release -cs) main" | sudo tee -a /etc/apt/sources.list.d/goaccess.list
wget -O - https://deb.goaccess.io/gnugpg.key | sudo apt-key add -
sudo apt-get update
sudo apt-get install goaccesss
@peerasan
peerasan / setup-monitorix
Created June 8, 2019 14:33
Install Monitorix
echo deb http://apt.izzysoft.de/ubuntu generic universe > /etc/apt/sources.list.d/monitorix.list
wget -qO - http://apt.izzysoft.de/izzysoft.asc | sudo apt-key add -
apt-get install monitorix
@peerasan
peerasan / nginx-rtmp.sh
Created June 8, 2019 14:36
compile nginx + rtmp
#compile nginx
apt-get install build-essential libpcre3 libpcre3-dev libssl-dev
mkdir /root/src
cd /root/src
wget https://nginx.org/download/nginx-1.13.8.tar.gz
tar -xvf nginx-1.13.8.tar.gz
cd nginx-1.13.8
./configure
@peerasan
peerasan / sysctl.conf
Created June 8, 2019 14:38
Tweaked sysctl.conf (Ubuntu)
#
# /etc/sysctl.conf - Configuration file for setting system variables
# See /etc/sysctl.d/ for additional system variables.
# See sysctl.conf (5) for information.
#
#kernel.domainname = example.com
# Uncomment the following to stop low-level messages on console
#kernel.printk = 3 4 1 3
@peerasan
peerasan / patrickz.yml
Created June 11, 2019 04:10
docker-compose with system environment
version: '3'
services:
patrickz:
image: patrickz/ubuntu
container_name: patrickz
restart: always
hostname: $HOSTNAME
ports:
- 19999:19999
environment:
@peerasan
peerasan / log4j.properties
Created June 11, 2019 10:59
wowza with goaccess
Prepare wowza logs (log4j.properties)
log4j.rootCategory=INFO, stdout, serverAccess, serverError, serverStats
...
...
...
# Statistics appender (to use this appender add "serverStats" to the list of appenders in the first line of this file)
log4j.appender.serverStats=org.apache.log4j.DailyRollingFileAppender
log4j.appender.serverStats.encoding=UTF-8
log4j.appender.serverStats.DatePattern='.'yyyy-MM-dd
@peerasan
peerasan / mailgun with curl
Created June 12, 2019 04:42
send email by mailgun API
curl -s --user 'api:key-##############################' \
https://api.mailgun.net/v3/{YOUR-DOMAIN}/messages \
-F from='Monitor <postmaster@{YOUR-DOMAIN}>' \
-F to=peerasan@{DOMAIN} \
-F subject='Hello' \
-F text='Testing some Mailgun awesomness!'