Rexxer

Some tips for me and other

Linux

Extract a text between delimiters with sh instead of using regex

Example file: UNKNOWN[123.21.181.4] abts-tn-dynamic-161.155.174.122.airtelbroadband.in[122.174.155.161] fm-dyn-118-137-18-160.fast.net.id[118.137.18.160] UNKNOWN[118.69.71.76] ip-177.71.93.43.juniornet.psi.br[177.71.93.43] UNKNOWN[210.245.34.254] UNKNOWN[185.140.242.41] 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 yoursite.com 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 192.168.30.0 netmask 255.255.255.0 { option routers 192.168.30.1; option domain-name-servers 192.168.30.11, 192.168.30.2; 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 192.168.30.100 192.168.30.130; allow members of “Hyper-V”; } pool { range 192.168.30.131 192.168.30.160; 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 – http://192.168.0.57/ | awk ‘/Temperature/{print $18}’` #Humidity #S1=`curl -v –silent –stderr – http://192.168.0.57/ | awk ‘/Humidity/{print substr($21,1,2) + 0}’ | bc -l` S1=`/usr/local/bin/curl -v –silent –stderr – http://192.168.0.57/ | 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: http://mysqltuner.com/ 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