Merge branch 'master' of ssh://git.indexdata.com/home/git/pub/pazpar2
authorDennis Schafroth <dennis@indexdata.com>
Mon, 21 Mar 2011 13:49:09 +0000 (14:49 +0100)
committerDennis Schafroth <dennis@indexdata.com>
Mon, 21 Mar 2011 13:49:09 +0000 (14:49 +0100)
.gitignore
etc/check-pazpar2.sh [new file with mode: 0755]
etc/server-status-nagios.xsl [new file with mode: 0644]
perf/bash/par.sh
src/client.c
src/connection.c
src/http.c
src/sel_thread.c
src/session.c
test/test_sru-proxy.urls

index c54152a..1b85e92 100644 (file)
@@ -15,3 +15,4 @@ Doxyfile
 dox
 deb-src
 Debug
+*~
\ No newline at end of file
diff --git a/etc/check-pazpar2.sh b/etc/check-pazpar2.sh
new file mode 100755 (executable)
index 0000000..c5d97d6
--- /dev/null
@@ -0,0 +1,68 @@
+#!/bin/sh
+
+usage()
+{
+cat <<EOF    
+usage: $0 options
+
+This script run the test1 or test2 over a machine.
+
+OPTIONS:
+   -h      Show this message
+   -H      host name or IP
+   -w      Warning level
+   -c      Critical level
+   -p      port name
+EOF
+}
+
+
+MSG="OK";
+HOST=localhost
+PORT=8004
+
+while getopts "hH:w:c:p:" OPTION
+do 
+    case $OPTION in
+     h)  usage; exit 3;;
+     H)  
+           HOST=$OPTARG
+           ;;
+     p)  
+           PORT=$OPTARG
+           ;;
+     w)  
+           WARN_LEVEL=$OPTARG
+           ;;
+     c)  
+           CRIT_LEVEL=$OPTARG
+           ;;
+  esac
+done
+
+#echo $HOST $PORT $WARN_LEVEL $CRIT_LEVEL
+
+`wget -q "http://$HOST:$PORT/search.pz2?command=server-status" -O- | xsltproc /etc/pazpar2/server-status-nagios.xsl - 2> /dev/null` 
+
+if [ $? -ne 0 ] ; then
+    MSG="FATAL failed to communicate with pazpar2"
+    exit 128
+fi
+
+if [ "$WARN_LEVEL" != "" ] ; then 
+    if [ $SESSIONS -gt $WARN_LEVEL ];  then
+       MSG="WARNING "
+       rc=1; 
+    fi
+fi 
+
+if [ "$CRIT_LEVEL" != "" ] ; then 
+    if [ $SESSIONS -gt $CRIT_LEVEL ];  then
+       MSG="CRITICAL " 
+       rc=2;
+    fi
+fi 
+
+echo "SESSIONS $MSG $SESSIONS ($CLIENTS) | $SESSIONS;$WARN_LEVEL;$CRIT_LEVEL "
+exit $rc
+
diff --git a/etc/server-status-nagios.xsl b/etc/server-status-nagios.xsl
new file mode 100644 (file)
index 0000000..56f53fa
--- /dev/null
@@ -0,0 +1,26 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<xsl:stylesheet version="1.0"
+  xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+
+ <xsl:output indent="no" method="text" version="1.0" encoding="UTF-8" />
+
+  <xsl:template match="/server-status">
+      <xsl:apply-templates />
+  </xsl:template>
+
+  <xsl:template match="sessions">
+    <xsl:text>export SESSIONS=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="clients">
+    <xsl:text>export CLIENTS=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="resultsets">
+    <xsl:text>export RESULTSETS=</xsl:text><xsl:value-of select="." />
+  </xsl:template>
+
+  <xsl:template match="*">
+  </xsl:template>
+
+</xsl:stylesheet>
index 54399d0..7072a3f 100755 (executable)
@@ -11,13 +11,20 @@ if test -n "$1"; then
        . $1
 fi
 let r=0
+if [ "$SETTINGS" != "" ] ; then 
+    SETTINGS_OPT="--settings=\"$SETTINGS\" " 
+    echo $SETTINGS_OPT
+else
+    unset SETTINGS_OPT
+fi
+
 while test $r -lt $ROUNDS; do
        echo "$r"
        let i=0
        while test $i -lt $NUMBER; do
-               ./pp2client.sh --outfile=$r.$i --prefix=http://$HOST:${PORT}/search.pz2 --service=$SERVICE >$r.$i.log 2>&1 &
-               sleep $DELAY
-               let i=$i+1
+           ./pp2client.sh --outfile=$r.$i --prefix=http://$HOST:${PORT}/search.pz2 --service=$SERVICE $SETTINGS_OPT >$r.$i.log 2>&1 &
+           sleep $DELAY
+           let i=$i+1
        done
        sleep $WAIT
        let r=$r+1
index a30355b..ad5f44a 100644 (file)
@@ -639,15 +639,12 @@ static int client_set_facets_request(struct client *cl, ZOOM_connection link)
 int client_has_facet(struct client *cl, const char *name) {
     ZOOM_facet_field facet_field;
     if (!cl || !cl->resultset || !name) {
-        yaz_log(YLOG_DEBUG, "client has facet: Missing %p %p %s", cl, (cl ? cl->resultset: 0), name);
         return 0;
     }
     facet_field = ZOOM_resultset_get_facet_field(cl->resultset, name);
     if (facet_field) {
-        yaz_log(YLOG_DEBUG, "client: has facets for %s", name);
         return 1;
     }
-    yaz_log(YLOG_DEBUG, "client: No facets for %s", name);
     return 0;
 }
 
@@ -667,6 +664,7 @@ void client_start_search(struct client *cl)
     const char *opt_sru         = session_setting_oneval(sdb, PZ_SRU);
     const char *opt_sort        = session_setting_oneval(sdb, PZ_SORT);
     const char *opt_preferred   = session_setting_oneval(sdb, PZ_PREFERRED);
+    const char *extra_args      = session_setting_oneval(sdb, PZ_EXTRA_ARGS);
     char maxrecs_str[24], startrecs_str[24];
 
     assert(link);
@@ -675,6 +673,9 @@ void client_start_search(struct client *cl)
     cl->record_offset = 0;
     cl->diagnostic = 0;
 
+    if (extra_args && *extra_args)
+        ZOOM_connection_option_set(link, "extraArgs", extra_args);
+
     if (opt_preferred) {
         cl->preferred = atoi(opt_preferred);
         if (cl->preferred)
index 3ef5cf6..012d994 100644 (file)
@@ -393,7 +393,6 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man)
     const char *charset;
     const char *sru;
     const char *sru_version = 0;
-    const char *extra_args  = 0;
 
     struct session_database *sdb = client_get_database(con->client);
     const char *zproxy = session_setting_oneval(sdb, PZ_ZPROXY);
@@ -424,9 +423,6 @@ static int connection_connect(struct connection *con, iochan_man_t iochan_man)
     if ((sru_version = session_setting_oneval(sdb, PZ_SRU_VERSION)) 
         && *sru_version)
         ZOOM_options_set(zoptions, "sru_version", sru_version);
-    if ((extra_args = session_setting_oneval(sdb, PZ_EXTRA_ARGS)) && *extra_args)
-        ZOOM_options_set(zoptions, "extraArgs", extra_args);
-
     if (!(link = ZOOM_connection_create(zoptions)))
     {
         yaz_log(YLOG_FATAL|YLOG_ERRNO, "Failed to create ZOOM Connection");
index 27ce668..d93c874 100644 (file)
@@ -161,7 +161,9 @@ static void http_buf_destroy(http_server_t hs, struct http_buf *b)
         b->next = hs->http_buf_freelist;
         hs->http_buf_freelist = b;
         hs->http_buf_freelist_count++;
+#if 0 
         yaz_log(YLOG_DEBUG, "Free %d http buffers on server.", hs->http_buf_freelist_count);
+#endif
     }
     yaz_mutex_leave(hs->mutex);
 }
index 05cea3a..8a14e55 100644 (file)
@@ -99,7 +99,9 @@ static void *sel_thread_handler(void *vp)
         assert(p->input_queue);
         work_this = queue_remove_last(&p->input_queue);
         input_queue_length--;
+#if 0
         yaz_log(YLOG_DEBUG, "input queue length after pop: %d", input_queue_length);
+#endif
         assert(work_this);
 
         yaz_mutex_leave(p->mutex);
@@ -218,7 +220,9 @@ void sel_thread_add(sel_thread_t p, void *data)
     work_p->next = p->input_queue;
     p->input_queue = work_p;
     input_queue_length++;
+#if 0
     yaz_log(YLOG_DEBUG, "sel_thread_add: Input queue length after push: %d", input_queue_length);
+#endif
     yaz_cond_signal(p->input_data);
     yaz_mutex_leave(p->mutex);
 }
index c8d62e9..194ab36 100644 (file)
@@ -211,8 +211,9 @@ void add_facet(struct session *s, const char *type, const char *value, int count
             s->num_termlists = i + 1;
         }
         
-        session_log(s, YLOG_DEBUG, "Facets for %s: %s norm:%s (%d)",
-                    type, value, wrbuf_cstr(facet_wrbuf), count);
+#if 0
+        session_log(s, YLOG_DEBUG, "Facets for %s: %s norm:%s (%d)", type, value, wrbuf_cstr(facet_wrbuf), count);
+#endif
         termlist_insert(s->termlists[i].termlist, wrbuf_cstr(facet_wrbuf),
                         count);
     }
index e405879..0c9d239 100644 (file)
@@ -1,4 +1,4 @@
-http://localhost:9763/search.pz2?command=init&clear=0&service=sru-proxy
+http://localhost:9763/search.pz2?command=init&clear=1&service=sru-proxy
 http://localhost:9763/search.pz2?session=1&command=settings&pz:sru%5Bkb.dadsthirdnode.cvt.dk%2Fsru-proxy%5D=get&pz%3Aname%5Bkb.dadsthirdnode.cvt.dk%2Fsru-proxy%5D=sru-proxy&pz%3Axslt%5Bkb.dadsthirdnode.cvt.dk%2Fsru-proxy%5D=dads-pz2.xsl&pz%3Aqueryencoding%5Bkb.dadsthirdnode.cvt.dk%2Fsru-proxy%5D=UTF-8&pz%3Aapdulog%5Bkb.dadsthirdnode.cvt.dk%2Fsru-proxy%5D=1&pz%3Asru_version%5Bkb.dadsthirdnode.cvt.dk%2Fsru-proxy%5D=1.1&pz%3Aextra_args%5Bkb.dadsthirdnode.cvt.dk%2Fsru-proxy%5D=%26x-facet_def%3Ddtic_test%26x-noxsl%3D1&pz:query_syntax%5Bkb.dadsthirdnode.cvt.dk%2Fsru-proxy%5D=pqf
 http://localhost:9763/search.pz2?session=1&command=search&query=water
 4 http://localhost:9763/search.pz2?session=1&command=show&block=1