vmstat with timestamp

Load testing tools for QAs

vmstat with timestamp:

function stamp {
  while read line
  do
    printf "$line"
    date '+ %m-%d-%Y %H:%M:%S'
  done
}
vmstat 3 5 | stamp

ref: http://www.unix.com/unix-dummies-questions-answers/32892-vmstat-output-date-timestamp.html

Make it Technical: Create DSN on *nix

install
# apt-get install unixodbc unixodbc-dev libmyodbc odbc-postgresql

goto the folder
# cd /etc/ODBCDataSources

Write the driver setting: mysql_odbc_template
[MySQL]
Description = MySQL driver
Driver = /usr/lib/odbc/libmyodbc.so
Setup = /usr/lib/odbc/libodbcmyS.so

Install data source driver
# odbcinst -i -d -f mysql_odbc_template

Uninstall data source driver
# odbcinst -u -d -n MySQL

List installed driver
# odbcinst -q -d

Write the driver setting: mysql_dsn
[mysql_ejabberd]
Driver = /usr/lib/i386-linux-gnu/odbc/libmyodbc.so
SERVER = localhost
PORT = 3306
DATABASE = ejabberd
OPTION = 3
USER = ejabberd
PASSWORD = xxxxxxxx

install dsn
# odbcinst -i -s -l -f mysql_dsn

List installed dsn’s
# odbcinst -q -s

Reference:

UnixODBC example setup and configuration on Ubuntu Lucid with Mysql and PostgreSQL using the command line only

User & group commands in -nix systems

To change permission
chmod -R 755 folder_name
with which,755 -> ABC
A = User
B = Group
C = Others
and -R = recursive to all sub-folders.

To change group and owner of folder
chown -R group:user folder_name

Create group
groupadd group_name

Create user
adducer user_name

Add an existing user to an existing group
usermod -a -G group_name user_name
with which -a=append, -G=supplementary_group, -g=primary_group

Remove an existing user from an existing group (will not delete the user nor the group)
deluser user_name group_name

Validate user group settings
id user_name, or
groups user_name

Longitude & Latitude

Did you know:
The Earth’s radius is 6371km
For longitude, 0.00001 is roughly 1 meter
For Latitude, 0.00001 is roughly 0.4 meter
Obviously, the civil GPS nowadays is not yet achieving this level of accuracy. But it is useful to know the scale.

Team: git with multi-user

git…gitolite…it is an important tool to development, but require some patience to setup.

No much neat tutorial written on web. I write mine.

1. Prepare a few things before start:

  • ssh login
  • all public key of users
  • repository hierarchical structure design

2. Install gitolite (previously gitosis)
$ apt-get install gitolite

3. Create a single user for the gitolite account
$ adduser gitolite

4. Run setup with gitolite user, providing the admin public key
$ su - gitolite
$ gl-setup your_key.pub

5. Server is setup. Next, configure it.
Go back to client. Clone the admin folder. This will work fine if you do the steps correctly.
$ git clone gitolite@server.com:gitolite-admin

6. Goto gitolite-admin
$ cd gitolite-admin

7. The folder has two subfolders. “conf" and “keydir".
What you have to do is to put all the user’s public key into the “keydir" folder, and then edit the file in conf/gitolite.conf.

8. The file is like this:
repo gitolite-admin
RW+ = admin

repo testing
RW+ = @all

repo repo-A
RW+ = admin
RW+ = userA

The name (admin, userA, etc..) is referring to the filename public keys in the “keydir" folder. The keyword “repo" refers to a new repository. If you add a new repo with the same format, the server will create repository accordingly. I create a new repo named repo-A in above file.

9. After changing the conf/gitolite.conf file, git-commit it.
$ git add .
$ git commit -a -m "commit"
$ git push origin master

The server settings are automatically updated after commit.

10. Now you can git clone the new repo. e.g. repo-A
$ git clone gitolite@server.com:repo-A

Done~

p.s.
The authentication part, individual user need not to have access right to the server where the gitolite is hosted. Just don’t put the public key into ~/.ssh folder, only put them in the keydir of gitolite-admin.
This tutorial is a bit complex, but much simpler than those available on other place now which I learn the tools from.

Cheers~