Some tips for me and other


Extract a text between delimiters with sh instead of using regex

Example file: UNKNOWN[][][] UNKNOWN[][] UNKNOWN[] UNKNOWN[] I want to extract IP-addresses: command shell: cat drop.txt | cut -d'[‘ -f2 | cut -d’]’ -f1 Get data from the file Delete all the text before the delimeter (we choose the text after the delimiter) Delete alle the text after the delimeter ( … before […]

WGET + Measure for web

wget -E -H -p -Q300K –user-agent=Mozilla –no-cache –no-cookies –no-check-certificate –delete-after –timeout=15 –tries=2 2>&1 | grep Downloaded

Linux + LVM + fsck

# lvm pvscan # lvm vgscan # lvm vgs # lvm vgchange -a y VolGroup00 # lvm vgdisplay -v VolGroup00 | more # fsck /dev/VolGroup00/LogvolX Can’t find a good superblock backup? To display: # mke2fs -n /dev/VolGroup00/LogVolX Other thoughts: 1. Clean bit could be set – to force an fsck: # fsck -f /dev/vgname/lvolname # […]

Grep + Parse IPs

grep -o ‘[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}\.[0-9]\{1,3\}’ file.txt

DHCPD + Classes e.g. MAC-address

subnet netmask { option routers; option domain-name-servers,; class “Hyper-V” { match if substring(hardware,1,3) = 00:15:5d; } class “VMWare” { match if substring(hardware,1,3) = 00:0c:29; } class “Winemu” { match if substring(hardware,1,3) = 00:03:ff; } pool { range; allow members of “Hyper-V”; } pool { range; allow […]

Server reboot + variants

Нормальная работа reboot проблемы с софтом reboot -f проблемы с ядром/маунтами/libc echo b>/proc/sysrq-trigger проблемы с ядром/маунтами/libc и нет открытой консоли ipt_SYSRQ (надо подготовить заранее) проблемы с ядром/железом ipmitool chassis power cycle проблемы с ядром/железом без открытой консоли ipmitool -H ipmi.server.local chassis power cycle проблемы с автономной переферией/БП/ipmi ребут через IP-розетку

Ubuntu 14.04 + grey screen in VNC

Fix: # apt-get install gnome-panel gnome-settings-daemon metacity nautilus gnome-terminal Use this ~/.vnc/xstartup file: #!/bin/sh export XKL_XMODMAP_DISABLE=1 unset SESSION_MANAGER unset DBUS_SESSION_BUS_ADDRESS [ -x /etc/vnc/xstartup ] && exec /etc/vnc/xstartup [ -r $HOME/.Xresources ] && xrdb $HOME/.Xresources xsetroot -solid grey vncconfig -iconic & gnome-panel & gnome-settings-daemon & metacity & nautilus & gnome-terminal & # or you can use […]

ESP8266 + temp/humidity + parse data for monitoring

My script to parse the data: #!/bin/sh #Temp S0=`/usr/local/bin/curl -v –silent –stderr – | awk ‘/Temperature/{print $18}’` #Humidity #S1=`curl -v –silent –stderr – | awk ‘/Humidity/{print substr($21,1,2) + 0}’ | bc -l` S1=`/usr/local/bin/curl -v –silent –stderr – | awk ‘/Humidity/{print $21}’` /usr/local/bin/rrdtool update /var/rrdtool/db/esp.rrd N:$S0:$S1 WWWPREFIX=/usr/local/www/apache22/data/images RRDPREFIX=/var/rrdtool/db /usr/local/bin/rrdtool graph $WWWPREFIX/esp.png \ –width […]

PFX to key and crt in PEM

Extract Private Key: The following command will extract private key from .pfx file. You can find the private key in file named private_key.pem. # openssl pkcs12 -in myfile.pfx -nocerts -out private_key.pem -nodes   Enter Import Password: MAC verified OK Extract Certificate: The following command will extract certificate from .pfx file. You can find the certificate […]

MySQLTuner tool

It’s here: Run it and then: mysqlcheck -u root -p –auto-repair –check –optimize –all-databases Go to my.cnf and add: query_cache_size = 268435456 query_cache_type=1 query_cache_limit=1048576 as it recommended.

Previous Posts