Skip to content

Instantly share code, notes, and snippets.

View dragolabs's full-sized avatar

Vitaly Shishlyannikov dragolabs

View GitHub Profile
@dragolabs
dragolabs / all_ip.rb
Last active August 29, 2015 14:06
Dumb ohai7 plugin show all IP addresses of the node exclude localhost.
#
# Author:: Vitaly Shishlyannikov (<[email protected]>)
# Copyright:: Copyright (c) 2014
# License:: Apache License, Version 2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
@dragolabs
dragolabs / nginx-log-format.conf
Last active April 26, 2023 16:17
Nginx log format and grok pattern for default (combined) and custom format
log_format custom '$remote_addr - $remote_user [$time_local] '
'"$request" $status $bytes_sent '
'"$http_referer" "$http_user_agent" '
'"$host" "$uri" "$args" "$sent_http_location" '
'"$proxy_host" "$upstream_addr" "$upstream_cache_status" '
'[$request_time] [$upstream_response_time]';
@dragolabs
dragolabs / dc_location.rb
Last active August 29, 2015 14:11
Find location of server by local ip address
require 'socket'
def have_ip?(ip)
ip_arr = Socket.ip_address_list.select{|intf| intf.ipv4?}
ip_arr.to_s.scan(/(?<=: )[\d.]+(?=>)/).find{ |e| /#{ip}/ =~ e }
end
if File.exist?('/var/local/location.txt')
dc_location = File.read('/var/local/location.txt')

Using tmux on remote server in native iTerm2 windows

ssh -t example.com 'tmux -CC new-session -A -s logs'
@dragolabs
dragolabs / ubuntu server connect to wifi.md
Last active March 22, 2018 17:15
ubuntu server connect to wifi

/etc/network/interfaces

auto wlan0
iface wlan0 inet static
address 192.168.1.150
netmask 255.255.255.0
gateway 192.168.1.1
wpa-ssid <your_router>
wpa-psk 
@dragolabs
dragolabs / GHOST-debian-fix.sh
Last active August 29, 2015 14:14
Update all installed libc packages in system
sudo aptitude safe-upgrade `dpkg -l | awk {'print $2'}| grep -e "^libc[-|6]" | paste -s`
or
sudo aptitude safe-upgrade `dpkg -l | cut -d " " -f 3 | grep -e "^libc[-|6]" | paste -s`
@dragolabs
dragolabs / knife-set-desc.sh
Last active August 29, 2015 14:19
Script for create description for chef's nodes in attribute "desc".
#!/bin/bash
echo "Set description for chef's nodes. Press ENTER to skip node."
for NODE in `knife search "! desc:*" -i | tail -n+2`;do
echo "Node: ${NODE}"
echo -n 'Description: '
read DESC
if [ ! -z "${DESC}" ];then
knife node attribute set ${NODE} desc "${DESC}"
else
@dragolabs
dragolabs / 10tuning.conf
Last active October 15, 2015 13:33
Optimazed sysctl.conf and limits.d
# /etc/security/limits.d/10tuning.conf
# max number of open files
* soft nofile 999999
* hard nofile 999999
root soft nofile 999999
root hard nofile 999999
# max stack size (KB)
* soft stack unlimited
@dragolabs
dragolabs / nginx-bitrix.conf
Created September 11, 2015 11:28
nginx configuration for bitrix cms
server {
listen 80;
server_name bitrix.example.com;
client_max_body_size 200m;
root /var/www/bitrix;
index index.html index.php;
@dragolabs
dragolabs / s3-grant-one-bucket
Last active September 11, 2015 16:46
Policy for access to one S3 bucket
{
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": ["s3:ListBucket"],
"Resource": ["arn:aws:s3:::my-backup"]
},
{
"Effect": "Allow",