Monday, January 11, 2010

Monitor Memcached status

It is quite a important task to manage and monitor the memcache caching system. There are quite a lot of options to carry out this operation.

1. Using Telnet Command Line interface

List of supported commands are available at

http://code.sixapart.com/svn/memcached/trunk/server/doc/protocol.txt



telnet localhost 11211



List of keys used

stats items


STAT items:5:number 2
STAT items:5:age 47
STAT items:5:evicted 0
STAT items:5:evicted_nonzero 0
STAT items:5:evicted_time 0
STAT items:5:outofmemory 0
STAT items:5:tailrepairs 0
END



2. Using memcached-tool

The memcached tool is available in the source directory .

/usr/src/memcached-1.4.4/scripts/memcached-tool

Stats

/usr/src/memcached-1.4.4/scripts/memcached-tool 127.0.0.1:11211 stats

Show slab information

/usr/src/memcached-1.4.4/scripts/memcached-tool 127.0.0.1:11211 display

Show keys and values

/usr/src/memcached-1.4.4/scripts/memcached-tool 127.0.0.1:11211 dump


3. Using the damemtop

A flexible 'top' like utility for viewing memcached clusters. You can use it to manage a interactive cluster status.

The utility is available in the source directory. /usr/src/memcached-1.4.4/scripts/damemtop


It require you to install the following perl modules

cpan AnyEvent Term::ReadKey YAML


Now you need the /etc/damemtop.yaml file with the following contents.


delay: 3
mode: t
top_mode:
sort_column: "hostname"
sort_order: "asc"
columns:
- hostname
- all_version
- all_fill_rate
- hit_rate
- evictions
- bytes_written
- "2:get_hits"
servers:
- 127.0.01:11211


In a distributed environment you can add all the servers in the cluster to the file and issue the following command.


/usr/src/memcached-1.4.4/scripts/damemtop


That would give you a ideal monitoring setup..

Sunday, January 10, 2010

Install Memcached caching sytem in centos from source

memcached is a high-performance, distributed memory object caching system, generic in nature, but intended for use in speeding up dynamic web applications by alleviating database load.

It is mainly used in MYSQL + PHP or MYSQL + JAVA applications which are quite database intensive.

Install LIBEVENT


yum -y install libevent libevent-devel


Download Source

wget http://memcached.googlecode.com/files/memcached-1.4.4.tar.gz
tar zxf memcached-1.4.4.tar.gz
cd memcached-1.4.4
./configure && make && make install



Test the installation


memcached -m 256 -u nobody -vv
slab class 1: chunk size 80 perslab 13107
slab class 2: chunk size 104 perslab 10082
<29 send buffer was 110592, now 268435456
<29 server listening (udp)
<29 server listening (udp)



Start the Daemon


memcached -d -m 256 -u nobody -p 11211 -l 192.168.1.33


The above command will start the memcached daemon in port 11211

Ensure that it is working.

netstat -plan|grep 11211
tcp 0 0 192.168.1.33:11211 0.0.0.0:* LISTEN 7049/memcached




Thats it.. Enjoy the power of caching system..

Friday, January 8, 2010

Check Ubuntu 8.04 server security using OpenVAS

Install openvas server from source in ubunutu 8.04


apt-get install build-essential libgtk2.0-dev libglib2.0-dev libssl-dev htmldoc libgnutls-dev libpcap0.8-dev bison libgpgme11-dev libsmbclient-dev snmp pnscan


add the following line to /etc/apt/sources.list


deb http://ftp.de.debian.org/debian sid main


Install the server


apt-get install openvas-server openvas-server-dev openvas-plugins-dfsg openvas-plugins-base libopenvas2 libopenvas2-dev libopenvasnasl2 libopenvasnasl2-dev


Add your user


openvas-adduser


Update the feeds


openvas-nvt-sync



start the server


/etc/init.d/openvas-server start


Install the client

It would ask you to upgrade php etc and hence I compiled the agent from source. The trunk is incompatible with the openvas-server provided by debian repository.


svn co https://svn.wald.intevation.org/svn/openvas/branches/openvas-client-2-0/ openvas-client



cd openvas-client

./configure && make && make install


Running the agent in batch mode:

You can run the client to produce beautiful html with graphs using the following command line.

create a file named target with the host you want to check

cat >target
localhost
ctrl+c


OpenVAS-Client -q localhost 9390 ovasuser mypasswd target localhost-result -T html_graph -x


The run would take around 15 minutes and you will get the results in the localhost-result directory. View the HTML files using browser.