Thursday, December 25, 2014

How to add launchpad ubuntu repository and install php5-memcached 2.2.0

Add repository
# add-apt-repository ppa:ondrej/php5
Check available versions
# apt-get update
# apt-cache policy php5-memcached
Install memcashed
# apt-get install php5-memcached

Monday, December 1, 2014

VARNISH WEB INTERFACE FOR ADMIN AND CACHE INVALIDATION

1) Download and extract
wget https://github.com/varnish/vagent2/archive/master.zip
unzip master.zip

2)Install
cd vagent2-master/
./configure
make
make install

3)Protect the interface
nano /etc/varnish/agent_secret
Insert formatted
user:password
4)Start the agent

/usr/local/bin/varnish-agent

5)Varnish Web Interfase access (when promted for login , enter the user:password from /etc/varnish/agent_secret)
http://THE-SERVER-IP:6085/html/
6) The Varnish Web Interfase allow:
stop/start varnish
Cache invalidation
Set Parameters
View varnish performance
2014-12-01 23_16_57-Varnish Agent

Wednesday, November 5, 2014

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- redis (LoadError)

/usr/lib/ruby/1.9.1/rubygems/custom_require.rb:36:in `require': cannot load such file -- redis (LoadError)
solution:
gem 'redis', '~> 3.1.0'

Friday, October 17, 2014

How to add custom sensor for PRTG monitor (Linux)

Let say You have some custom script on Linux You want to monitor in PRTG
Main, monitor Redis Keys.

nano /etc/snmp/snmpd.conf

Add the script as following to end of the file:

extend redis_keys /path/to/script.sh

Restart snmpd

/etc/init.d/snmpd restart

Now , we need to find the OID value for our script:


snmptranslate -On NET-SNMP-EXTEND-MIB::nsExtendOutputFull.\"scriptname\"

some times , you need to add mib library to get OID values:

apt-get install snmp-mibs-downloader

In my case , script name is “redis_keys” , so it look like:

snmptranslate -On NET-SNMP-EXTEND-MIB::nsExtendOutputFull.\"redis_keys\"
.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.114.101.100.105.115.95.107.101.121.115

The output is our OID for PRTG:
.1.3.6.1.4.1.8072.1.3.2.3.1.2.10.114.101.100.105.115.95.107.101.121.115

Before deal with PRTG , I want to be sure , my script working and return value:

snmpwalk -v 2c -c [Community String] localhost .1.3.6.1.4.1.8072.1.3.2


 iso.3.6.1.4.1.8072.1.3.2.4.1.2.10.114.101.100.105.115.95.107.101.121.115= STRING: "/ssd/home/adika/monitor/keys" 


Where [Community String] is You PRTG Community String

Now In PRTG:


Choice CUSTOM


Add our OID


Thursday, October 16, 2014

Linux find files between dates

touch -t 201409070120.01 first (yyyymmdd-hour)
touch -t 201409080120.01 last (yyyymmdd-hour)

find perl files between date range:

find . -type f -name '*.pl' -newer /root/first ! -newer /root/last -exec ls -s {} \;

remove files with specific extension

find .  \( -name "*.php" -o -name "*.html" -o -iname "*.htm" \) -exec ls -s  {} \; -print -exec rm {} \;

remove files with specific extension and contains some expression:

find .  \( -name "*.php" -o -name "*.html" -o -iname "*.htm" \)  -exec grep -l "some expression"  {} \; -print -exec rm {} \;

find  files and directories between date range:

find .  -type d \( -name cache -o -name logs -o -name stats -o -name webalizer \) -prune -o \( -name "*.php" -o -name "*.html" -o -iname "*.htm" \) -newer /root/first ! -newer /root/last -print




Wednesday, October 15, 2014

alternative telnet send mail test

Instead of send a test mail using Telnet , simple
echo -e "To: mail@domain.com\nSubject: Test\nTest\n" | sendmail -bm -t -v