perl plug-in sample for override method

Standard

For example , when you define Ima::DBI::_mk_db_closure() , you write plugin as below.

package MyPlugin;
use strict;
use warnings;
use Ima::DBI;

sub import {
    no strict 'refs';
    no warnings 'redefine';
    *{"Ima::DBI\::_mk_db_closure"} = \&_mk_db_closure;
}

sub _mk_db_closure {
    my ($class, $dsn, $user, $pass, $attr) = @_;
}

1;
__END__

And , you call plug-in by “use MyPlugin”. “use” is equal to below.

BEGIN {
    require MODULE;
    MODULE->import(LIST);
}

load test to cookie token (ticket) page by apache bench (ab)

Standard

e.g. OpanAM

##STEP1/3 – refer to help / manual document
http://httpd.apache.org/docs/2.2/programs/ab.html

$ /home/endo/local/apache22/bin/ab -h
Usage: ab [options] [http://]hostname[:port]/path
Options are:
    -n requests     Number of requests to perform
    -c concurrency  Number of multiple requests to make
    -t timelimit    Seconds to max. wait for responses
    -b windowsize   Size of TCP send/receive buffer, in bytes
    -p postfile     File containing data to POST. Remember also to set -T
    -u putfile      File containing data to PUT. Remember also to set -T
    -T content-type Content-type header for POSTing, eg.
                    'application/x-www-form-urlencoded'
                    Default is 'text/plain'
    -v verbosity    How much troubleshooting info to print
    -w              Print out results in HTML tables
    -i              Use HEAD instead of GET
    -x attributes   String to insert as table attributes
    -y attributes   String to insert as tr attributes
    -z attributes   String to insert as td or th attributes
    -C attribute    Add cookie, eg. 'Apache=1234. (repeatable)
    -H attribute    Add Arbitrary header line, eg. 'Accept-Encoding: gzip'
                    Inserted after all normal header lines. (repeatable)
    -A attribute    Add Basic WWW Authentication, the attributes
                    are a colon separated username and password.
    -P attribute    Add Basic Proxy Authentication, the attributes
                    are a colon separated username and password.
    -X proxy:port   Proxyserver and port number to use
    -V              Print version number and exit
    -k              Use HTTP KeepAlive feature
    -d              Do not show percentiles served table.
    -S              Do not show confidence estimators and warnings.
    -g filename     Output collected data to gnuplot format file.
    -e filename     Output CSV file with percentages served
    -r              Don't exit on socket receive errors.
    -h              Display usage information (this message)

##STEP2/3 – login to OpenAM by browser , and copy cookie token

iPlanetDirectoryPro=AQIC5wM2LY4....TU2NTE2*

##STEP3/3 – execute ab

$ /home/endo/local/apache22/bin/ab \
  -v 4 \
  -n 100 \
  -c 10 \
  -C "iPlanetDirectoryPro=AQIC5w......." \
  http://cent6.a5.jp/
   :
   :
LOG: Response code = 200
..done


Server Software:        Apache/2.2.29
Server Hostname:        cent6.a5.jp
Server Port:            80

Document Path:          /
Document Length:        29593 bytes

Concurrency Level:      10
Time taken for tests:   21.965 seconds
Complete requests:      100
Failed requests:        0
Write errors:           0
Total transferred:      3072500 bytes
HTML transferred:       2959300 bytes
Requests per second:    4.55 [#/sec] (mean)
Time per request:       2196.491 [ms] (mean)
Time per request:       219.649 [ms] (mean, across all concurrent requests)
Transfer rate:          136.60 [Kbytes/sec] received

Connection Times (ms)
              min  mean[+/-sd] median   max
Connect:        0    0   0.2      0       1
Processing:   679 2171 1636.1   1529    7465
Waiting:      679 2170 1636.2   1529    7464
Total:        679 2171 1636.2   1529    7465

Percentage of the requests served within a certain time (ms)
  50%   1529
  66%   1577
  75%   1613
  80%   2055
  90%   4447
  95%   7292
  98%   7417
  99%   7465
 100%   7465 (longest request)
$ 

LocationMatch – regular expression in apache httpd.conf

Standard

If you need denial-regexp ,you add “?!” (not “!”).

<LocationMatch "^/(?!pub|aut|inc|mt|mt-static|pma)">
    SetHandler perl-script
    PerlHandler Plack::Handler::Apache2
    PerlSetVar psgi_app /home/endo/dev/sexy/Ean/script/ean-server
</LocationMatch>

<Directory "/home/endo/dev/sexy/static/helm">
   AllowOverride All
   Order allow,deny
   Allow from all
</Directory>
Alias /pub /home/endo/dev/sexy/static/helm

include /home/endo/local/web_agents/apache22_agent/Agent_001/config/dsame.conf

install NumPy (Numerical Python) & nose (unit test tool) to centos 6.6

Standard

####nose
https://nose.readthedocs.org

$ wget https://pypi.python.org/packages/source/n/nose/nose-1.3.6.tar.gz
$ tar -xvf nose-1.3.6.tar.gz
$ cd nose-1.3.6
$ /usr/local/bin/python setup.py build
$ su
#/usr/local/bin/python setup.py install

####numpy
http://www.numpy.org/
http://sourceforge.net/projects/numpy/files/NumPy/

$ tar -xvf numpy-1.9.2.tar.gz
$ cd numpy-1.9.2
$ /usr/local/bin/python setup.py build
$ su
#/usr/local/bin/python setup.py install

####test numpy

$ python
Python 2.7.9 (default, Apr  5 2015, 15:24:09) 
[GCC 4.4.7 20120313 (Red Hat 4.4.7-11)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import numpy
>>> numpy.test()
Running unit tests for numpy
NumPy version 1.9.2
NumPy is installed in /usr/local/lib/python2.7/site-packages/numpy
Python version 2.7.9 (default, Apr  5 2015, 15:24:09) [GCC 4.4.7 20120313 (Red Hat 4.4.7-11)]
nose version 1.3.6
.......................S....S.........S...............................
  :
Ran 5593 tests in 70.420s

OK (KNOWNFAIL=5, SKIP=12)
<nose.result.TextTestResult run=5593 errors=0 failures=0>
>>>

tar -zxvf *.tar.gz = tar -xvf *.tar.gz ?

Standard

I can extract gzip+ tar file (.tar.gz) by “tar -xvf (not -zxvf)” like “tar -xvf numpy-1.9.2.tar.gz ”

Does tar command have this spec from previous version?

$ tar --version
tar (GNU tar) 1.23
Copyright (C) 2010 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by John Gilmore and Jay Fenlason.

Linear Programing library – lp_solve

Standard

### latest version is in sourceforge.
http://sourceforge.jp/projects/sfnet_lpsolve/
lp_solve – http://lpsolve.sourceforge.net/5.5/

tar -zxvf lp_solve_5.5.2.0_source.tar.gz
cd lp_solve_5.5/lp_solve
sh ccc

You can make lp_solve_5.5/lp_solve/bin/ux64/lp_solve , that is executable file.

### old version is in ftp://ftp.ics.ele.tue.nl/pub/lp_solve/
Math::LP that is perl wrapper for perl , needs lp_solve ver.3.2.
But I can’t make Math::LP.
ftp://ftp.ics.ele.tue.nl/pub/lp_solve/
http://search.cpan.org/dist/Math-LP/

make error – apache 2.2 with ldap

Standard
cd httpd-2.2.29
$ ./configure --prefix=/home/endo/local/apache80 \
            --with-mpm=prefork \
            --enable-proxy \
            --enable-modules=all \
            --with-ssl=/usr/local/openssl \
            --enable-rewrite=shared \
            --with-ldap \
            --enable-authnz-ldap=shared \
            --enable-ldap=shared \
            --enable-so
$ make
   :
checking for stdint.h... yes
checking for unistd.h... yes
checking for ldap support...
checking for ldap_init in -l/usr/local/openldap... no
checking for ldap_init in -l/usr/local/openldap... no
checking for ldap_init in -l/usr/local/openldap... no
checking for ldap_init in -l/usr/local/openldap... no
configure: error: could not find an LDAP library
configure failed for srclib/apr-util

So, I add “–with-ldap-include” & “–with-ldap-lib” configure option, as below.

./configure --prefix=/home/endo/local/apache80 \
            --with-mpm=prefork \
            --enable-proxy \
            --enable-modules=all \
            --with-ssl=/usr/local/openssl \
            --enable-rewrite=shared \
            --with-ldap \
            --with-ldap-include=/usr/local/openldap/include \
            --with-ldap-lib=/usr/local/openldap/lib \
            --enable-authnz-ldap=shared \
            --enable-ldap=shared \
            --enable-so

unique attribute of openldap by configure –enable-unique

Standard

You can set unique arribute of openldap by “overlay unique”.
http://www.openldap.org/doc/admin24/overlays.html
http://www.openldap.org/software/man.cgi?query=slapo-unique

STEP1 configure –enable-unique

overlay unique is default=off, so you should add “–enable-unique” option to configure.

$ cd openldap-2.4.40
$ ./configure --prefix=/usr/local/openldap --enable-unique
$ make depend                              ^^^^^^^^^^^^^^^
$ make
$ make test
$ su
# make install

STEP2 vi /usr/local/openldap/etc/openldap/slapd.conf

If you will set displayName & mail to unique attribute , you add setting “overlay unique” , “unique_uri” after rootdn setting.

database        bdb
suffix          "dc=my-domain,dc=com"
rootdn          "cn=Manager,dc=my-domain,dc=com"
  :
overlay unique
unique_uri ldap:///ou=People,dc=my-domain,dc=com?displayName?sub
unique_uri ldap:///ou=People,dc=my-domain,dc=com?mail?sub

If you add setting “overlay unique” , “unique_uri” before rootdn setting, openldap shows warning , below.

# /etc/rc.d/init.d/slapd restart
Stopping slapd:                                            [  OK  ]
Checking configuration files for slapd:                    [WARNING]
554464e2 slapo-unique needs a rootdn; backend &lt;&gt; has none, YMMV.
554464e2 slapo-unique needs a rootdn; backend &lt;&gt; has none, YMMV.
config file testing succeeded
Starting slapd:                                            [  OK  ]