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

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
@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 / 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

This is what I use in Zabbix email action

Subject (problem):

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

Subject (recovery):

OK/{HOST.NAME}: {ITEM.NAME}
@shamil
shamil / gist:3140541
Created July 19, 2012 03:20 — forked from iwinux/gist:1529093
config.assets.precompile
def compile_asset?(path)
# ignores any filename that begins with '_' (e.g. sass partials)
# all other css/js/sass/image files are processed
if File.basename(path) =~ /^[^_].*\.\w+$/
puts "Compiling: #{path}"
true
else
puts "Ignoring: #{path}"
false
end
@shamil
shamil / snippet_show_grants.sh
Created July 19, 2012 03:52
mysql show grants snippet
# Show all grants
mysql --skip-column-names -e "SELECT user, host FROM mysql.user" | sed 's/\t/"@"/g; s/^/SHOW GRANTS FOR "/g; s/$/";/g;' | mysql --skip-column-names
@shamil
shamil / gedit2subl.sh
Created October 15, 2012 14:33
Change all associations from gedit to another application
#System wide associations:
sudo sed -i 's/gedit.desktop/yournew.desktop/g' /usr/share/applications/defaults.list
# Just your user's associations:
sed -i 's/gedit.desktop/yournew.desktop/g' ~/.local/share/applications/mimeapps.list
# If you're using the PPA for Sublime Text 2, there is already a .desktop file for it
# sitting in `/usr/share/applications/` so you can just run:
@shamil
shamil / gist:3944357
Created October 24, 2012 06:24 — forked from mneedham/gist:3803604
Script to get upstart out of a start/killed state (http://heh.fi/tmp/workaround-upstart-snafu)
#!/usr/bin/env ruby1.8
class Workaround
def initialize target_pid
@target_pid = target_pid
first_child
end
def first_child
@shamil
shamil / aug_redis_conf.sh
Created October 24, 2012 15:09
augeas how to load lenses (redis.conf example)
$ augtool
> set /augeas/load/Spacevars/incl[last()+1] "/etc/redis/redis.conf"
> load
> print /files/etc/redis/redis.conf