Coverage report: /development/source/library/org/datagraph/spocq-shard/src/shell/usage-log.lisp
| Kind | Covered | All | % |
| expression | 0 | 71 | 0.0 |
| branch | 0 | 0 | nil |
Key
Not instrumented
Conditionalized out
Executed
Not executed
Both branches taken
One branch taken
Neither branch taken
1
;;; -*- Mode: lisp; Syntax: ansi-common-lisp; Base: 10; Package: org.datagraph.spocq.implementation; -*-
3
(in-package :org.datagraph.spocq.implementation)
6
generate statistics, particularly as csv or html for use in monitor displays
8
(sb-ext:save-lisp-and-die "spocq-log-cgi" :executable t :toplevel #'spocq.i::main-usage-log)
13
(defun main-usage-log (&rest args &key
14
(query-parameters (sb-posix:getenv "QUERY_STRING"))
15
((:response-content-type *response-content-type*) mime:application/VND.DYDRA.SPARQL-RESULTS+html+table)
17
"Emit an html page which lists the queries over the given interval in tabular form."
19
(handler-bind ((serious-condition
21
(log-stacktrace "Error in query thread: ~a -> ~a." query-parameters condition)
22
(format *standard-output* "<html><body><pre>~a</pre></body></html>" condition)
24
(return-from main-usage-log))))
26
(with-command-line-configuration (:allow-other-keys t (append (parse-query-parameters query-parameters) args))
27
(setq *start-timestamp* (iso-time))
28
(initialize-spocq :title (or (getarg "--title") "spocqulog"))
29
(log-info "Start query log ~a." *start-timestamp*)
30
(destructuring-bind (&key (limit (response-limit))
31
(offset (response-offset))
32
(end-time (getarg "--end-time"))
33
(host (getarg "--host"))
34
(repository (getarg "--repository"))
36
*request-configuration*
37
(pipe-usage-log-query *standard-output*
39
:repository-id (cond (host (format nil "statistics/~a" host))
41
(t (error "a host or repository-id is required.")))
42
:end-time (when end-time (spocq.e:date-time end-time))
43
:repository repository
44
:content-type *response-content-type*
45
:offset (etypecase offset (integer offset) (string (parse-integer offset)) (null nil))
46
:limit (etypecase limit (integer limit) (string (parse-integer limit)) (null nil)))
48
;; make sure queues are closed
53
(main-usage-log :host "de4.dydra.com")
54
(main-usage-log :response-content-type mime:application/VND.DYDRA.SPARQL-RESULTS+html+table
55
:query-parameters "host=de4.dydra.com&end-time=2013-03-18T17:00:00Z&limit=10")
56
;; QUERY_STRING='start-time=2013-03-07T00:41:00Z&end-time=2013-03-07T17:00:00Z' sbcl --noinform --core sbcl-spocq.core --eval "(spocq.i::main-usage-log)" --noprint --no-userinit --response-content-type application/sparql-results+html+table
57
;; QUERY_STRING='host=de4.dydra.com&limit=100' usage-log.sh
58
;; QUERY_STRING='host=end-time=&de4.dydra.com&limit=10&offset=10' /usr/local/lib/cgi-bin/usage-log.sh