view · edit · sidebar · attach · print · history

< Niklaus.20170712-fix-oddb-errors | Index | Niklaus.20170710-faster-ajax >>





Checking performance of

Today I want to analyse the logs of to check them for any irregularities and will be looking for searches and/or other accesses where the user has to wait too long.

My idea is to create a simple ruby helper script, which reads in a log file and converts it to a sqlite database where it is easy to filter/analyse the results.

Calling gem install data_mapper dm-sqlite-adapter.

Filter all crawler from evidentia et al

Using curl -v --user-agent 'Mozilla/5.0 (compatible; SemrushBot/1.2~bl; +' The access is still logged in /var/www/

Checking apache config. The following lines must be place in each virtual host of the apache conf

  # Rewrite rule for bots on port 8512 -> 8112 or 8222
  RewriteMap  lc int:tolower
  RewriteCond %{HTTP_USER_AGENT} "google"
  RewriteRule ^/(.*)$ http://localhost:8112/$1 [P,L]
  RewriteCond %{HTTP_USER_AGENT} "archiver|slurp|bot|crawler|jeeves|spider|\.{6}"
  RewriteRule ^/(.*)$ http://localhost:8212/$1 [P,L]

before redirecting to the specific port via a line like RewriteRule ^/(.*)$ http://localhost:8512/$1 [P]

Installed and activated new apache conf on thinpower.

This seems to work as the following commands (and visiting the given url in the browser)

curl -v --user-agent 'Mozilla/5.0 (compatible; SemrushBot/1.2~bl; +'
curl -v --user-agent 'Mozilla/5.0 (compatible; google-crawler'

lead to the this log entries

grep Metaneuron /var/www/*log
/var/www/ - - [11/Jul/2017 09:36:19] "GET HTTP/1.1" 200 356858 1.6167  "Mozilla/5.0 (compatible; SemrushBot/1.2~bl; +"
/var/www/ - - [11/Jul/2017 09:41:58] "GET HTTP/1.1" 200 357098 1.2474  "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/59.0.3071.109 Safari/537.36"
/var/www/ - - [11/Jul/2017 09:38:39] "GET HTTP/1.1" 200 356858 1.5794  "Mozilla/5.0 (compatible; google-crawler"

Checked again on 1 PM for crawler entries.

 grep -i googlebot log/2017/07/11/user_log | tail - - [11/Jul/2017 13:03:15] "GET HTTP/1.1" 200 16767 0.0836  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:03:17] "GET HTTP/1.1" 200 98993 0.4558  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:03:18] "GET HTTP/1.1" 200 19629 0.0384  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:03:18] "GET HTTP/1.1" 200 11100 0.0336  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:04:49] "GET HTTP/1.1" 200 18055 0.0835  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:04:49] "GET HTTP/1.1" 200 35165 0.0758  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:04:50] "GET HTTP/1.1" 200 50225 0.0746  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:04:51] "GET HTTP/1.1" 200 11112 0.0331  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:05:40] "GET HTTP/1.1" 200 12524 0.0288  "Mozilla/5.0 (compatible; Googlebot/2.1; +" - - [11/Jul/2017 13:05:43] "GET HTTP/1.1" 200 40268 0.3080  "Mozilla/5.0 (compatible; Googlebot/2.1; +"

Should they filtered by entries in the apache conf oder by an entry in robots.txt?

adapt all crontab entries to use rack

We want to move all crontab entries to use the version with rack. But the /var/www/ contain 18G and I suspect that scripts and constants inside the ruby code reference this path. Therefore I think we should now move the old

  • mv /www/ /www/
  • mv /www/ //www/
  • mv /www/ /www/
  • mv /www/ /www/ # or cp -rpvu

Then we should also adapt the services and rename ->

Also the doc and log directories have very different sizes

du -sxh /var/www/*/doc/
128M    /var/www/
857M    /var/www/
du -sxh /var/www/*/log
501M    /var/www/
23G     /var/www/
du -sxh /var/www/*/data
172M    /var/www/
18G     /var/www/

Port migel to use Ruby 2.4.0

We must port migel to use Ruby 2.4.0. Currently it uses Ruby 1.9.3 and running bundle exec rake spec shows no problem.

After calling under ruby 2.4.0 bundle install the spec task fails with require 'sbsm/drbserver', as the DrbServer of SBSM is no longer available.

Pushed commit Update to Ruby 2.4.0 and SBSM 1.5.2. Installing it locally and adapting /service/migeld/run to use the line exec sudo -u apache /usr/local/bin/bundle-240 exec ruby-240 bin/migeld. This does not work and chokes with

sudo -u apache bundle-240 exec ruby-240 bin/migeld 
The PGconn, PGresult, and PGError constants are deprecated, and will be
removed as of version 1.0.

You should use PG::Connection, PG::Result, and PG::Error instead, respectively.

Called from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/ydbd-pg-0.5.3/lib/dbd/Pg.rb:157:in `new'
FEHLER:  Relation »object« existiert bereits
FEHLER:  Relation »prefetchable_index« existiert bereits
FEHLER:  Relation »extent_index« existiert bereits
FEHLER:  Relation »object_connection« existiert bereits
FEHLER:  Relation »target_id_index« existiert bereits
FEHLER:  Relation »collection« existiert bereits
/usr/local/ruby-2.4.0/lib/ruby/2.4.0/delegate.rb:387:in `__getobj__': not delegated (ArgumentError)
        from /usr/local/ruby-2.4.0/lib/ruby/2.4.0/delegate.rb:340:in `block in delegating_block'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:214:in `fetch'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/dbi-0.4.5/lib/dbi/handles/statement.rb:240:in `each'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:130:in `block in select_all'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:88:in `execute'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:128:in `select_all'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/ydbd-pg-0.5.3/lib/dbd/pg/database.rb:173:in `columns'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/dbi-0.4.5/lib/dbi/handles/database.rb:161:in `columns'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/odba-1.1.2/lib/odba/connection_pool.rb:39:in `block in method_missing'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/odba-1.1.2/lib/odba/connection_pool.rb:29:in `next_connection'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/odba-1.1.2/lib/odba/connection_pool.rb:38:in `method_missing'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/odba-1.1.2/lib/odba/storage.rb:526:in `setup'
        from /var/www/migel/vendor/bundle/ruby/2.4.0/gems/odba-1.1.2/lib/odba/cache.rb:474:in `setup'
        from /var/www/migel/lib/migel/persistence/odba.rb:21:in `<module:Migel>'
        from /var/www/migel/lib/migel/persistence/odba.rb:15:in `<top (required)>'
        from /var/www/migel/lib/migel/persistence.rb:9:in `require'
        from /var/www/migel/lib/migel/persistence.rb:9:in `<module:Migel>'
        from /var/www/migel/lib/migel/persistence.rb:8:in `<top (required)>'
        from bin/migeld:10:in `require'
        from bin/migeld:10:in `<main>'

Must fix bin/admin and bin/migeld.

With commit Fixed used versions for Postgres DBI bin/migeld starts without problems and I can search migel products.

With commit Ported bin/admin to rack based SBSM I am able to use the bin/admin

sudo -u apache bundle-240 exec bin/admin 
migel> migelids.size
-> 571
migel> migelids.first
-> ["", #<ODBA::Stub:47359814078720#24 @odba_class=Migel::Model::Migelid @odba_container=47359816062800#32286>]
migel> migelids.last
-> undefined method `last' for #<Hash:0x005625a206aea0>
migel> migelids.keys.last
migel> migelids.keys.first

Installing it on thinpower with these steps

cd /var/www/migel
git pull
/usr/local/bin/bundle-240 install --path=vendor
vi /service/migel/run # adapt it
svc -h /service/migel
tail -f /service/migeld/log/main/current # to check that it starts

Visited pages like to verify that still works.

We still have yusd and currencyd that run with ruby 1.8. Can we update them to ruby 2.4.0 and what about

Pushed two commits for currency, released new version 1.0.2 and changed /service/currency/run to call exec sudo -u apache /usr/local/ruby-2.4.0/bin/currencyd after calling /usr/local/bin/gem-240 install ycurrency. Checked it on (by changing the currency and looking for changes prices).

Port ydpm to use Ruby 2.4.0

The source code contains a file install.rb which seems to be generated automatically, but I have no idea how it was really generated. Also when running it I get errors like

 bundle exec ruby install.rb config
install.rb:77:in `<class:ConfigTable>': uninitialized constant Config (NameError)
Did you mean?  RbConfig
        from install.rb:75:in `<main>'

Should I try to generate a real gem for it? Zeno finds it okay. Also must replace rmail by mail and get rid of the smtp_tls. Implemented the needed changes.

When trying to run the unit tests, I see that I must replace the old -> flexmock.

request limit does not work on

Pushed commit Fix unit tests by clearing session on to fix the unit tests on sbsm. Release SBSM 1.5.3.

Pushed Update to use SBSM 1.5.3 to make limit queries work. Pulled the changes on thinpower, called bundle install and restarted the services. Now the query limit works.

Port yus to use Ruby 2.4.0

It did not need any additional work. On oddb-ci2 using in /service/yus/run I use the line exec sudo -u apache /usr/local/bin/ruby-240 /usr/local/src/yus/bin/yusd to start the yus daemon after calling sudo /usr/local/bin/gem-240 install yus. Login/out works as seen by

tail -f /service/yus/log/main/current 
@400000005964b9872ecc85ac FEHLER:  Relation »extent_index« existiert bereits
@400000005964b9872ed0a45c FEHLER:  Relation »object_connection« existiert bereits
@400000005964b9872ed6b324 FEHLER:  Relation »target_id_index« existiert bereits
@400000005964b9872ed9b894 FEHLER:  Relation »collection« existiert bereits
@400000005964b9880b1040a4 I, [2017-07-11T13:41:50.185570 #21183]  INFO -- start: starting yus-server on drbssl://localhost:9997
@400000005964b9a0313a9b94 I, [2017-07-11T13:42:14.825850 #21183]  INFO -- Yus::Server: Login attempt for from
@400000005964b9a0313c2dec W, [2017-07-11T13:42:14.826007 #21183]  WARN -- Yus::Server: Authentication failed for
@400000005964b9a717c7ca9c I, [2017-07-11T13:42:21.398909 #21183]  INFO -- Yus::Server: Login attempt for from
@400000005964b9a717c8bccc I, [2017-07-11T13:42:21.399010 #21183]  INFO -- Yus::Server: Authentication succeeded for
@400000005964bb3c360673b4 I, [2017-07-11T13:49:06.906352 #21183]  INFO -- Yus::Server: Logout for #<Yus::EntitySession:0x00557242716880>

Installing it on thinpower, too. Seems to work fine for and

Paypal fails when not using a existing paypal account

Got the following backtrace

TypeError: no implicit conversion of nil into String
  /var/www/ `escape'
  /var/www/ `http_headers'
  /var/www/ `view'
  /var/www/ `to_html'
  /var/www/ `to_html'
  /var/www/ `block in process_rack'
  /var/www/ `synchronize'
  /var/www/ `process_rack'
  /var/www/ `call'
  /var/www/ `_call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `_call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `service'
  /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/httpserver.rb:140:in `service'
  /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/httpserver.rb:96:in `run'
  /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/server.rb:290:in `block in start_thread'

Corrected watir paypal test to skip the remaining test only when the paypal login is displayed and not at the beginning of each step.

Also adding a test, where we create a new user login for, as the current tests use all the Added this test to watir tests and it produces the same backtrace as the one reported by Zeno.

Pushed commit Fix paying with paypal using a new customer as soon as the new watir tests passed. Found the following entries in /service/yus/log/main/current

400000005964cda50438873c I, [2017-07-11T15:07:39.070764 #9055]  INFO -- Yus::Server: Login attempt for from
@400000005964cda5043965e4 W, [2017-07-11T15:07:39.070850 #9055]  WARN -- Yus::Server: Authentication failed for
@400000005964cda504737914 I, [2017-07-11T15:07:39.074652 #9055]  INFO -- Yus::AutoSession: create_entity(, valid_until=, valid_from=2017-07-11 15:07:39 +0200)
@400000005964cda50b4d0f0c I, [2017-07-11T15:07:39.189552 #9055]  INFO -- Yus::Server: Login attempt for from
@400000005964cda50b4e0524 I, [2017-07-11T15:07:39.189640 #9055]  INFO -- Yus::Server: Authentication succeeded for

Looks to me as if a new user was correctly generated. Now I must check, that after the payment we can proceed with this login.

Fixed password creation with commit Fixed pw when creating new paypal test user and added a puts.

When restarting on thinpower I did see the following error in the log/2017/07/11/user.log

NoMethodError: undefined method `user_agent' for nil:NilClass
  /var/www/ `is_crawler?'
  /var/www/ `process_late'
  /var/www/ `block in process_rack'
  /var/www/ `synchronize'
  /var/www/ `process_rack'
  /var/www/ `call'
  /var/www/ `_call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `_call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `call'
  /var/www/ `service'
  /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/httpserver.rb:140:in `service'
  /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/httpserver.rb:96:in `run'
  /usr/local/ruby-2.4.0/lib/ruby/2.4.0/webrick/server.rb:290:in `block in start_thread'

Pushed commits

view · edit · sidebar · attach · print · history
Page last modified on July 11, 2017, at 05:19 PM