Sonntag, 18. November 2012

Link static content using spring MVC (e.g. favicon, apple toch icon, robots.txt etc.)


Spring MVC supports a "bypass" for static files, named resources. This is useful for accessing resources like favicon or static robots.txt.

Here is a little example spring config:

<beans xmlns="http://www.springframework.org/schema/beans"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:mvc="http://www.springframework.org/schema/mvc"
    xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd>

    <mvc:resources mapping="/favicon.ico" location="/static/favicon.ico"  cache-period="43200"/>
    <mvc:resources mapping="/apple-touch-icon-precomposed.png" location="/static/apple-touch-icon-precomposed.png"  cache-period="43200"/>
    <mvc:resources mapping="/robots.txt" location="/static/robots.txt"  cache-period="43200"/>

</beans>

see also:

http://static.springsource.org/spring/docs/current/spring-framework-reference/html/mvc.html

Freitag, 9. November 2012

NonGUI JMeter test with properties values and log output

We need JMeter test for check some newer software release of our search backend.

To run that like in production we run it in production...

To adapt environment specific properties within the test plan we use Java system properties.

Step 1

Therefore we specifiy a new thread group and use our tomcat access logs which will parsed by JMeter "Access Log Sampler" (Parser: TCLogParser).
To adapt prod specific properties, we use JMeter properties featuere and set:
Server:  ${__P(solrserver)}
Port:      ${__P(solrport)}
LogFile: ${__P(logfile)}

Step 2

We copy the jmx File to our prod server which runs the tests.
 and start them via:

jmeter -n -Dsolrserver=localhost -Dsolrport=11011 -Dlogfile=/var/log/tomcat-server/solr21-1/access-2012-11-06.log -l log.jtl -j jm.log -t TestPlan.jmx -Dsummariser.name=summary -Dsummariser.out=true -Dsummariser.interval=4

The "Summariser" params leads to log some output to console window, like here:

...
summary +    510 in     7s =   73.3/s Avg:    72 Min:     0 Max:   874 Err:     0 (0.00%) Active: 6 Started: 6 Finished: 0
summary = 109375 in   752s =  145.4/s Avg:    40 Min:     0 Max:  1946 Err:   420 (0.38%)
summary +    420 in   6.2s =   67.6/s Avg:    83 Min:     1 Max:   878 Err:     0 (0.00%) Active: 6 Started: 6 Finished: 0
...


see also:
http://jmeter.apache.org/usermanual/functions.html

Samstag, 3. November 2012

extend ping (use timestamp and specific output) to detect network problems

Currently in production our application error logs show some strange peaks three times a day: a lot of unexpected socket timeouts. To check the network latency whithin a 24 hours time interval I need to extend the ping, with timestamp and write out the results in a log file.

The following example pings for 24 hours an "api-1"-called server and writes the results with an timestamp in a log file:

{#$}
ping -i 5 -c 17280 -s 2560 api-1 | while read res; do echo "$(date "+%y-%m-%d %H:%M:%S") $res"; done >> ping.log &
{/#$}

'-i' the ping interval, we set to 5 seconds
'-c' the count of ping, we use 17280 x 5seconds = 1day
'-s' size of packets, we use 2560 bytes

{#less ping.log}
12-11-03 11:22:38 2650 bytes from api-1 (#.46.7.1): icmp_seq=37 ttl=62 time=16.3 ms
12-11-03 11:22:43 2650 bytes from api-1 (#.46.7.1): icmp_seq=38 ttl=62 time=16.2 ms
12-11-03 11:22:48 2650 bytes from api-1 (#.46.7.1): icmp_seq=39 ttl=62 time=16.2 ms
12-11-03 11:22:53 2650 bytes from api-1 (#.46.7.1): icmp_seq=40 ttl=62 time=16.3 ms
12-11-03 11:22:58 2650 bytes from api-1 (#.46.7.1): icmp_seq=41 ttl=62 time=16.2 ms
{/#less ping.log}