Skip to content

Instantly share code, notes, and snippets.

View shamil's full-sized avatar
🎯
Focusing

Alex Simenduev shamil

🎯
Focusing
View GitHub Profile
@shamil
shamil / gdb_stacktrace.md
Created August 27, 2015 11:10
Viewing stacktrace of running process using GDB

Viewing stacktrace of running process using GDB

to view stacktrace of running process, run

sudo gdb -batch -quiet -nx -ex "backtrace full" -p <PID>

to view stacktrace of running process for all threads, run

sudo gdb -batch -quiet -nx -ex "thread apply all backtrace full" -p

This is what I use in Zabbix email action

Subject (problem):

{TRIGGER.SEVERITY}/{HOST.NAME}: {ITEM.NAME}

Subject (recovery):

OK/{HOST.NAME}: {ITEM.NAME}

Using Sublime Text for Go Development

Credits goes to Mark Wolfe.

If you're new to golang then before you start setup your workspace, firstly watch this video Writing, building, installing, and testing Go code.

Usually after installing go, I'm running the following commands to make GOPATH available for my user

mkdir -p ~/Documents/My/gocode/src/github.com/shamil

@shamil
shamil / net_listen.sh
Last active August 29, 2015 14:11
Some commands to find out listening ports
# find all listening ports
cat /proc/net/tcp | awk '$4 == "0A" {print $2}' | awk -F: '{print strtonum("0x"$2)}'
# find all listening ports and print their inodes as well
cat /proc/net/tcp | awk '$4 == "0A" {print $10" "$2}' | tr : ' ' | awk '{printf "%d %d\n", strtonum("0x"$3), $1}'
# find all socket for PID and print their inodes
find -L /proc/<PID>/fd -type s -printf "%i\n"
# find listening ports for by PID
@shamil
shamil / netmask_cidr.md
Last active May 26, 2021 11:52
Netmask / CIDR Translation Table

Netmask / CIDR Translation Table

Netmask             Binary                              CIDR    Notes
---------------------------------------------------------------------------
255.255.255.255     11111111.11111111.11111111.11111111 /32     1   useable
255.255.255.254     11111111.11111111.11111111.11111110 /31     0   useable
255.255.255.252     11111111.11111111.11111111.11111100 /30     2   useable
255.255.255.248     11111111.11111111.11111111.11111000 /29     6   useable
255.255.255.240     11111111.11111111.11111111.11110000 /28     14  useable

255.255.255.224 11111111.11111111.11111111.11100000 /27 30 useable

@shamil
shamil / mailx_smtp.md
Created November 2, 2014 19:42
How to send email using mailx through SMTP

###How to send email using mailx through SMTP

Via command line

This is an all-in-one command that sends email to $TO_EMAIL_ADDRESS. You need to also replace these $FROM_EMAIL_ADDRESS and $FRIENDLY_NAME variables with your email and name.

$ mailx -v -s "$EMAIL_SUBJECT" \
    -S smtp=smtp://smtp.domain.tld \
    -S from="$FROM_EMAIL_ADDRESS($FRIENDLY_NAME)" \

$TO_EMAIL_ADDRESS

@shamil
shamil / mount_qcow2.md
Last active April 18, 2024 07:32
How to mount a qcow2 disk image

How to mount a qcow2 disk image

This is a quick guide to mounting a qcow2 disk images on your host server. This is useful to reset passwords, edit files, or recover something without the virtual machine running.

Step 1 - Enable NBD on the Host

modprobe nbd max_part=8

Installing from scratch

Starting from a fresh install of EL6.5, first install EPEL:

# rpm -Uvh http://download.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm

Then install the Graphite dependencies:

# yum -y install python-whisper python-carbon graphite-web python-memcached python-ldap httpd memcached nodejs npm nc
##################################################################
# /etc/elasticsearch/elasticsearch.yml
#
# Base configuration for a write heavy cluster
#
# Cluster / Node Basics
cluster.name: logng
# Node can have abritrary attributes we can use for routing

put that into .bashrc:

export HISTFILESIZE=
export HISTSIZE=

There you go, unlimited history :)

From "man bash":

If HIST‐FILESIZE is not set, no truncation is performed.