-
Notifications
You must be signed in to change notification settings - Fork 1
/
tricks.txt
394 lines (264 loc) · 13.1 KB
/
tricks.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
--------------------------- VBox
VBoxManage internalcommands sethduuid /path/to/virtualdisk.vdi
------------------------ Putty
xterm-256color
for ((color = 0; color <= 255; color++)); do tput setaf "$color"; printf "test"; done
--------------------------------
vi /etc/modules
vboxsf
vi /etc/fstab
Documents /home/dev/Documents vboxsf uid=dev,gid=dev,dmode=774,fmode=664 0 1
### nie dzizlaa
* ------------------------------- docker centos without sudo centos
* sudo usermod -aG docker ppalucki
chmod o+rw /var/run/docker.socket
# sort images by size
docker images --format '{{.Size}}\t{{.Repository}}\t{{.Tag}}\t{{.ID}}' | sed 's/ //' | sort -h -r | column -t
### --------------------------------- tmux
setw -g mode-keys vi
set-option -g allow-rename off
set mode-mouse on
set mouse-resise-pane on
set mouse-select-pane on
### ------------------------------ mnt tmpfs for glide
sudo mount -o size=16G -t tmpfs none /mnt/tmpfs
### --------------------------- dhcp to enable at boot set BOOT=yes
vim /etc/sysconfig/network-scripts/ifcfg-eno1
### -------------------------------- docker detach keys again and again
#'ctrl-p,ctrl-q in an escape for detach '
mkdir -o ~/.docker
cat >~/.docker/config.json <<EOF
{
"detachKeys": "ctrl-q,ctrl-q"
}
EOF
or just
docker exec -ti --detach-keys 'ctrl-q,ctrl-q' cassandra-test cqlsh
------------------------------ monitoring
sudo docker run -d --cap-add SYS_PTRACE -v /proc:/host/proc:ro -v /sys:/host/sys:ro -v /var/run/docker.sock:/var/run/docker.sock --rm --name netdata -p 19999:19999 titpetric/netdata
#---------------------------------------- vim go
curl -fLo ~/.vim/autoload/plug.vim --create-dirs \
https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
vim ~/.vimrc
call plug#begin('~/.vim/plugged')
Plug 'fatih/vim-go'
call plug#end()
:PlugInstall
#------------------------------ load grafana
./toplev.py -C0,8 -l3 -I 5000 -x, -v --quiet sleep inf 2>&1 | awk -F ',' '{print "toplevel,name=" $3 ",core=" $2, "value=" $4}' | xargs -i -n1 curl -i -XPOST 'http://172.16.0.2:8086/write?db=database' --data-binary "{}" -q
# ------------------------------- golang
# compile depedencies and compile all tests
mkdir -p build/tests
pushd build/tests
for i in `go list ../../integration_tests/...`; do go test -i $i; done
for i in `go list ../../integration_tests/...`; do go test -c $i; done
popd
for i in `ls build/tests/`; do ./build/tests/$i; done
# --------------------------- centos disk free problem
xfs_fsr -v
# ------------------------ date uis
date -uIs
date -uIs
2017-03-23T12:41:30+0000
date -I
# -------------------------- python tricks
python -m site
python -m json
python -m SimpleHTTPServer
sudo pip install --upgrade --force-reinstall setuptools pip
sudo pip install --upgrade --force-reinstall ipython
pprint(vars(object))
# ------------------------ jupyter/ipytjon
from IPython.core.display import display, HTML
display(HTML("<style>.container { width:100% !important; }</style>"))
# -------------------- powerpoint problems with authorization/login e.g. grafana
https://support.microsoft.com/en-us/help/838028/how-documents-are-opened-from-a-web-site-in-office-2003
solve:
- enable autologin or anonymous access
# X11-------------------------------------
centos7
yum install -y xauth xclock
yum install -y epel-release
yum install -y xsensors
yum install -y hwloc
yum install liberation-* chromium
centos7 tricks https://wiki.mikejung.biz/CentOS_7
# intel memory latency checker
https://software.intel.com/en-us/articles/intelr-memory-latency-checker
# linux VIF vs NIC
# ls -l /sys/class/net/
lrwxrwxrwx. 1 root root 0 Aug 16 11:01 eno1 -> ../../devices/pci0000:00/0000:00:19.0/net/eno1
lrwxrwxrwx. 1 root root 0 Aug 16 11:01 enp2s0 -> ../../devices/pci0000:00/0000:00:1c.2/0000:02:00.0/net/enp2s0
lrwxrwxrwx. 1 root root 0 Aug 16 11:01 lo -> ../../devices/virtual/net/lo
# -
#### ssh-copy-id to root
cat ~/.ssh/id_rsa.pub | ssh [email protected] "sudo mkdir /root/.ssh; sudo tee -a /root/.ssh/authorized_keys"
#### mesos deps
sudo yum groupinstall -y "Development Tools"
sudo yum -y install apr-devel
sudo yum -y install curl-devel
sudo yum -y install cyrus-sasl-devel
sudo yum -y install cyrus-sasl-md5
sudo yum -y install subversion-devel
sudo yum -y install libffi-devel
#### wxpython deps
yum install gstreamer-plugins-base-devel
#### sshrc
https://github.com/taylorskalyo/sshrc
wget https://raw.githubusercontent.com/taylorskalyo/sshrc/master/sshrc
chmod +x sshrc
sudo mv sshrc /usr/local/bin #or anywhere else on your PATH
### virsh
eval `/usr/bin/resize`
### authorize qemu for vagrant
# https://bugzilla.redhat.com/show_bug.cgi?id=1437933
sudo usermod --append --groups libvirt `whoami`
### openshift
# restart job
oc --namespace=logging get job openshift-ansible-logging-job -ojson | jq 'del(.spec.selector)' | jq 'del(.spec.template.metadata.labels)' | oc --namespace=logging replace --force -f -
########## vim python 3.6 on centos
./configure --enable-fail-if-missing --enable-python3interp vi_cv_path_python3=/usr/bin/python3.6 --with-python-config-dir=/usr/lib64/python3.6/config-3.6m-x86_64-linux-gnu
############# apropos losf, fuser, netstat, ss
### Prometheus
# Query about all metrics.
{__name__=~".+"}
################ mesos & aurora
pip install black pygments
aurora job inspect --raw --bind user=root local/root/devel/redis re.aurora | black -q - | pygmentize -l python
aurora job status example/root/staging13 --write-json 2>/dev/null | jq '.[]["active"][] | .assignedTask.taskId + ": " + .status'
### NTP
sudo ntpdate -v corp.intel.com
############ ansible
# merge dicsts
ANSIBLE_HASH_BEHAVIOUR=merge ansible-playbook
# adhoc + console + facts
export ANSIBLE_CACHE_PLUGIN_CONNECTION=/tmp/ansible_fact_caching ANSIBLE_CACHE_PLUGIN=jsonfile
ansible localhost -msetup
ansible localhost -mdebug -avar=ansible_default_ipv4.address
ansible localhost -msetup -afilter='ansible_processor_*' -o
ansible all -i inventory.ini -msetup -afilter='ansible_processor_*' -o
ansible all -i inventory.ini -mdebug -avar=ansible_processor_count
ansible all -i inventory.ini -mdebug -avar=ansible_processor_vcpus
# output as json
ANSIBLE_LOAD_CALLBACK_PLUGINS=1 ANSIBLE_STDOUT_CALLBACK=json ansible all -i inventory.ini -mdebug -avar=ansible_processor_vcpus
ANSIBLE_CACHE_PLUGIN_CONNECTION=/tmp/ans_cache.json ANSIBLE_CACHE_PLUGIN=jsonfile ansible-console host -i inventory.ini
# faster ansible
ANSIBLE_CACHE_PLUGIN_CONNECTION=/tmp/ansible-caches ANSIBLE_CACHE_PLUGIN=jsonfile ANSIBLE_CALLBACK_WHITELIST=profile_tasks
anisble-config list
anisble-config dump
# BETTER output always formated output + timers
ANSIBLE_STDOUT_CALLBACK=debug ANSIBLE_CALLBACK_WHITELIST=profile_tasks,profile_roles,timer,debug ansible-playbook
```
```
ANSIBLE_KEEP_REMOTE_FILES=1 ansible-playbook -vvv ...
grep ' PUT '....
ssh target-machine or local
/usr/bin/python2 /home/ppalucki/.ansible/tmp/ansible-tmp-1571049051.51-107016242751709/AnsiballZ_get_url.py explode
cd DEBUG_DIR
cat args | python __main__.py
################################################ print everything and cat it
find . -type f -print -exec cat {} \;
############################################# pipenv
pipenv --three install ipython influxdb --skip-lock
pipenv run ipython
#################################### steam
DISPLAY=127.0.0.1:0 docker run --privileged --net host -d -v ~/.Xauthority:/root/.Xauthority -v ~/.Xauthority:/home/steam/.Xauthority --name steam3 --env="DISPLAY" --net=host ubuntu sleep inf
DISPLAY=127.0.0.1:0 xfwm4
sudo /usr/bin/X
################# centos ntfs
yum install -y ntfs-3g
################################# pycharm java render html/rest prism java extenssion
### PAWEL PALUCKI sacre was here: use my fixed JDK that has PRISM/GLX and can render
# use /usr/java/jdk1.8.0_121/jre/bin/java
# from alternatives --config java
JDK=""
######################### ansible set_trace
https://stackoverflow.com/questions/42417079/how-to-debug-ansible-issues
import sys;sys.stdin = open('/dev/tty'); import pdb; pdb.set_trace()
############ kube dashboard from kubespray
or https://100.64.176.18:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/login
at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/cronjob?namespace=default
at https://127.0.0.1:6443/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/cronjob?namespace=default
or use kubectl proxy and then: 127.0.0.1:8001
http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/
#kubectl get secrets --namespace=kube-system kubernetes-dashboard-token-qx6pw -o json | jq '.data.token' -r | base64 -d
#kubectl create clusterrolebinding moj-dashbord-moze-wszystko --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
# from https://github.com/kubernetes/dashboard/wiki/Creating-sample-user
kubectl create serviceaccount sample-admin-user -n kube-system
kubectl create clusterrolebinding sample-admin-user-can-do-anything --clusterrole=cluster-admin --serviceaccount=kube-system:sample-admin-user -n kube-system
kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | grep sample-admin-user | awk '{print $1}')
# proba zmiana hasla - alen iedzial
echo -n 'admin' | base64
kubectl -n kube-system edit secret $(kubectl -n kube-system get secret | grep sample-admin-user | awk '{print $1}')
######### Pipfile + jq
# aka pip freeze
cat Pipfile.lock | jq '((.default | to_entries)[], (.develop | to_entries)[]) | "\(.key)\(.value.version)"' -r
### yum dependecies
yum deplist openssl
repoquery --requires --resolve zlib
rpm -q --whatrequires openssl
repoquery -l zlib
repoquery -l librdkafka-devel
repoquery -l librdkafka1
## SERVER with zsh and oh-my-zsh
ansible -b --become-user=ppalucki -myum -a'package=zsh'
ansible -b --become-user=ppalucki -mlineinfile -a'path=~/.zshrc line="setopt hist_ignore_all_dups"'
ansible -b --become-user=ppalucki -mlineinfile -a'path=~/.zshrc line="setopt no_share_history"'
ansible -b --become-user=ppalucki -mlineinfile -a'path=~/.zshrc line="bindkey \^U backward-kill-line"'
###### Getting kubectl tls/ca/key
kubectl config view --raw -ojsonpath="{@.clusters[0].cluster.certificate-authority-data}" | base64 -d
kubectl config view --raw -ojsonpath="{@.users[0].user.client-certificate-data}" | base64 -d
kubectl config view --raw -ojsonpath="{@.clusters[0].cluster.certificate-authority-data}" | base64 -d
########## zsh completion issues
rm ~/.zcompdump
########### grub centos7
https://wiki.centos.org/HowTos/Grub2
# Traditional
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /etc/grub2.cfg
grub2-mkconfig -o /boot/grub2/grub.cfg
# UEFI
awk -F\' '$1=="menuentry " {print i++ " : " $2}' /boot/efi/EFI/centos/grub.cfg
grub2-mkconfig -o /boot/efi/EFI/centos/grub.cfg
# Default
grub2-editenv list
cat /etc/default/grub
##################### ansible get_url netrc problem
400 response for delegate_to localhost when using netrc
just disable machine login/token
###################### kubectl oneliners
# kubectl run (nodeSelector + tolerations"
kubectl run nginx --image=nginx --overrides='{"apiVersion": "v1", "spec": { "nodeSelector":{"kubernetes.io/hostname":"node36"}, "tolerations":[{"key":"master", "effect":"NoSchedule", "operator":"Exists"}]}}' --restart=Never -ojson --dry-run
# custom columns with uuid and node
kubectl get pods -ndefault -ocustom-columns='NAME:.metadata.name,UID:.metadata.uid,RQST:.spec.containers[*].resources.requests.cpu,STATAUS:.status.hostIP
# logs: accepts any resources returns from first pod
kubectl logs deploy/foo-deployment
# describe prefix is enough
kubectl describe pod/wca
# taint always require a value
kubectl taint node node37 node38 owner=ppalucki:NoSchedule
kubectl taint node node37 node38 owner=ppalucki:NoSchedule-
# can label mutilple object at once
kubectl label node/node37 node/node38 owner=ppalucki
kubectl label node/node37 node/node38 owner-
kgno --show-labels
kubectl taint node node37 node40 kind=aep:NoSchedule
kubectl taint node node37 node40 kind=aep:NoSchedule-
kgss
./workloads2.sh
##################### ndctl impctl daxctl
sudo yum install -y autoconf keyutils-libs-devel rubygem-asciidoctor kmod-devel.i686 kmodtool kmod kmod-devel libudev-devel uuid-devel uuid libuuid libuuid-devel json-c-devel json-c gcc-c++ autoconf automake libtool bash-completion
git clone https://github.com/pmem/ndctl
./autogen.sh
./configure CFLAGS='-g -O2' --prefix=/usr --sysconfdir=/etc --libdir=/usr/lib64
make
make check
sudo make install
#### fix kmem cadvisor issues with kmem based numanodes 3,4
after new numanodes are provisioed and kubectl restarted:
sudo sh -c 'echo 0-3 >/sys/fs/cgroup/cpuset/kubepods/cpuset.mems'
sudo sh -c 'echo 0-3 >/sys/fs/cgroup/cpuset/kubepods/burstable/cpuset.mems'
sudo sh -c 'echo 0-3 >/sys/fs/cgroup/cpuset/kubepods/besteffort/cpuset.mems'
cat /sys/fs/cgroup/cpuset/kubepods/{,burstable/,besteffort/}cpuset.mems
(migrate_pages both binary and syscall requires that /proc/self/status allows to be run on given numanode)
#### poorman pcm-memory exporter
while true; do sudo ./pcm-memory.x -pmm 2>/dev/null -- sleep 1; done | egrep System | egrep Read\|Write | egrep DRAM\|PMM | awk '{print("pcm_memory_bytes{kind=\"" $3 """\",mode=\"" $4 "\"}",$6*10000000)}'