Skip to content

Instantly share code, notes, and snippets.

@PSJoshi
PSJoshi / sysctl.conf
Last active June 3, 2024 16:12
linux kernel tunning - sysctl.conf
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# references:
#
# https://config.securix.org/config/securix-conf/etc/sysctl.conf
# https://github.com/minhdanh/Linux-Kernel-Tuning-and-Hardening/blob/master/kernel_hardening_tuning.sh
# https://gist.github.com/sokratisg/98d03e20fca76d4b699f
@PSJoshi
PSJoshi / file limits
Created March 8, 2015 09:30
linux - file and process limits
$ sudo vi /etc/security/limits.conf
Add:
* soft nofile 65535
* hard nofile 65535
* soft nproc 32768
* hard nproc 32768
# Note - instead of *, you can add any user! * means - setting applies to all the users.
@PSJoshi
PSJoshi / ntp-update
Last active July 13, 2016 03:51
ntp time synchronzation
#service ntp stop
#ntpdate ntp.ubuntu.com
#service ntp start
# forced NTP synchronization
sudo service ntp stop
sudo ntpd -gq
#sudo ntpdate -sb time.nist.gov
sudo service ntp start
@PSJoshi
PSJoshi / elasticsearch-curator-indices
Created March 16, 2015 10:02
elasticsearch-curator
[root@mgr ELK]# curator --version
curator, version 3.0.0
[root@mgr ELK]$ which curator
/usr/bin/curator
[root@mgr ELK]# curator --host 10.4.0.45 bloom indices --time-unit days --timestring "%Y-%m-%d" --older-than 2
2015-03-16 15:21:03,404 INFO Job starting...
2015-03-16 15:21:03,556 WARNING Bloom filters no longer exist for search in Elasticsearch since v1.4.0
@PSJoshi
PSJoshi / elasticsearch-tunning
Last active August 29, 2015 14:17
Elasticsearch tunning
vi /etc/elasticsearch/elasticsearch.yml
#Add the following line somewhere in the file, to disable dynamic scripts:
script.disable_dynamic: true
bootstrap.mlockall: true
http.cors.allow-origin: "/.*/"
http.cors.enabled: true
#Add to /etc/sysctl.conf
fs.file-max = 65536
@PSJoshi
PSJoshi / jinja.py
Last active August 29, 2015 14:17
python-jinja example
#!/usr/bin/env python
import os
from jinja2 import Environment, FileSystemLoader
dir_path = os.path.dirname(os.path.abspath(__file__))
t_environment = Environment(
autoescape=False,
#loader=FileSystemLoader(os.path.join(dir_path, 'templates')),
loader=FileSystemLoader(os.path.dirname(os.path.abspath(__file__))),
@PSJoshi
PSJoshi / rpm-commands
Created March 21, 2015 11:58
RPM information
##compare rpm versions and lot of utilities related to rpm
# yum install rpmdevtools
## Information about repository -
# yum install yum-utils
You can also do:
# yum info openssl
# yumdb info 'python*'
@PSJoshi
PSJoshi / firefox-addon.txt
Created April 7, 2015 04:41
Firefox add-on offline installation
1) Right-click the extension download link (in Mozilla Add-ons, where it says "Download Now"), select "Save Link As..." and download/SAVE .xpi file to your computer in a location where you can find it later.
2) Manually install it by dragging the file onto an open Firefox window.
@PSJoshi
PSJoshi / logstash-grok-filter.txt
Last active August 29, 2015 14:18
logstash grok parser for httpd and squid
apache web server
=================
Feb 18 13:42:48 www http_access: 120.61.15.50 - - [18/Feb/2015:13:42:48 +0530] "GET / HTTP/1.1" 200 31413
Feb 18 13:42:48 www http_access: 49.248.46.26 - - [18/Feb/2015:13:42:48 +0530] "GET /SpryAssets/SpryMenuBarDownHover.gif HTTP/1.1" 200 55
#%{MONTH}\ %{MONTHDAY}\ %{TIME}\ %{WORD:user}\ %{WORD:access}\: %{IP:ip} \- \- \[%{MONTHDAY}/%{MONTH}/%{YEAR}:%{TIME} %{NUMBER}\] "%{WORD:http_method} / %{WORD:http}/%{NUMBER:http_ver}" %{NUMBER:response_code} %{NUMBER:bytes}
%{MONTH}\ %{MONTHDAY}\ %{TIME}\ %{WORD:user}\ %{WORD:access}\: %{IP:ip} \- \- \[%{MONTHDAY}/%{MONTH}/%{YEAR}:%{TIME} %{NUMBER}\] "%{WORD:http_method} %{URIPATH} %{WORD:http}/%{NUMBER:http_ver}" %{NUMBER:response_code} %{NUMBER:bytes}
Squid
#############################################################################
# Full Imports
import sys
import math
import random
import subprocess
"""
This is a pure Python implementation of the K-Means Clustering algorithmn. The