Skip to content

Instantly share code, notes, and snippets.

View Fang-Li's full-sized avatar
🎯
Focusing

Fang-Li

🎯
Focusing
View GitHub Profile
@Fang-Li
Fang-Li / kill-erlang-node.sh
Created September 28, 2018 01:34 — forked from robertoaloi/kill-erlang-node.sh
Kill an Erlang process by node name
#!/usr/bin/env bash
# Kill an Erlang process by node name
#
# e.g.: kill-erlang-node kred
# Check usage
if [ -z "$1" ]; then
echo "Usage: `basename $0` NODE_NAME"
exit 1
@Fang-Li
Fang-Li / kill.sh
Created May 17, 2018 06:00
杀死进程的N种方法
## kill process
### python version
1. ps -ef | grep django-admin.py | grep -v grep
2. kill -TERM PID1 PID2
3. killproc processName
### normal version
4. ps -ef or ps -aux # find process then killed
5. kill -s 9 PID
@Fang-Li
Fang-Li / os_stats.sh
Created May 15, 2018 11:37 — forked from izmailoff/os_stats.sh
collects OS stats on Linux
#!/bin/bash
# Collects system performance statistics such as CPU, memory, and disk
# usage as well as top processes ran by users.
#
# All size values are in KiB (memory, disk, etc).
# Takes these command line arguments:
# $1 - cpuThreshold in % of total across all CPUs. Default is provided in no-args option.
-module(user_default).
-author('serge@hq.idt.net').
%% Compile this file and use this line in your ~/.erlang file (with
%% correct path, of course!) to where the user_default.beam file is stored.
%%
%% code:load_abs("/home/fritchie/erlang/user_default").
-export([help/0,dbgtc/1, dbgon/1, dbgon/2,
dbgadd/1, dbgadd/2, dbgdel/1, dbgdel/2, dbgoff/0,
@Fang-Li
Fang-Li / .erlang
Last active April 18, 2018 09:52 — forked from wardbekker/.erlang
Autoloading of modules
%% Load all erlang modules in path
%% autoload all modules that are in the code:path() and reside in the user directory
%% put in ~/.erlang
[code:ensure_loaded(list_to_atom(filename:rootname(filename:basename(F))))
|| P <- lists:filter(fun(Path) -> string:str(Path, os:getenv("USER")) > 0 end, code:get_path()), F <- filelib:wildcard(P ++ "/*.beam")].
%% 我的更新
[io:format("~p~n",[F]) ||
P <- lists:filter(fun(Path) -> string:str(Path, "erlang") /= 0 end, code:get_path()),
F <- filelib:wildcard(P ++ "/*.beam")].
@Fang-Li
Fang-Li / killer.sh
Created February 5, 2018 02:23
Kill cpu occupy more than 80% of the process
#!/bin/bash
#killer.sh
export PATH=$PATH:/bin:/usr/bin:/usr/local/bin:/sbin:/usr/sbin:/usr/local/sbin
while true;
do
ps axf -o "pid %cpu command" |grep -v bashd| awk '{if($2>=80.0) print $1}' | while read procid
do
kill -9 $procid
done
@Fang-Li
Fang-Li / performance_test.erl
Created February 5, 2018 00:47
erlang performance test
-module(performance_test).
-compile(export_all).
%% workers.
main(_N_Pro, _N_Times, _WorkFun, _Arg, 0) ->
over;
main(N_Pro, N_Times, WorkFun, Arg, LoopTime) ->
% io:format("work fun :~p~n",[WorkFun]),
%% error_logger:logfile({open,"./tmp_test.log"}),
MainId = self(),
@Fang-Li
Fang-Li / remsh
Last active November 23, 2017 04:03 — forked from egobrain/remsh
erlang remsh
#!/bin/bash
node=$1
data=($(echo $node | tr "@" "$IFS"))
username=root
name=${data[0]}
domain=${data[1]}
rand=$(date +%s | sha256sum | base64 | head -c 10 ; echo)