Commit 1aab171c authored by David Byers's avatar David Byers
Browse files

Show boot time and basic server statistics in standard status display.

Make kom-extended-status-information more fine-grained, so we can have
extended information on the server but not on confs (and so forth).
Cache boot-time and static server information.

Detailed changes:
> 	Show more stats in non-extended display:
> 	* commands2.el (kom-status-server): Show text, conf and person
> 	statistics in the default display.
>
> 	Cace get-stats-description:
> 	* services.el (initiate-get-stats-description): Use cache.
>
> 	* vars.el.in (lyskom-stats-description): New variable.
>
> 	* parse.el (lyskom-parse-stats-description): Cache result.
>
> 	Show some boottime info:
> 	* commands2.el (kom-status-server): Show server start time and
> 	soem basic statistics in the default display.
>
> 	Cache static-server-info:
> 	* parse.el (lyskom-parse-static-server-info): Update cache.
>
> 	* services.el (initiate-get-boottime-info): Use cache.
>
> 	More fine-grained control over extended status:
> 	* commands2.el (kom-status-server): Only show full server stats if
> 	the appropriate extended status information is on.
>
> 	* utilities.el (lyskom-extended-status-information): New function.
>
> 	* commands2.el (kom-status-conf): Set
> 	kom-extended-status-information to t on entry if it contains conf.
> 	(kom-status-server): Set kom-extended-status-information to t on
> 	entry if it contains server.
> 	(kom-status-person): Set kom-extended-status-information to t on
> 	entry if it contains pers.
>
> 	* aux-items.el (lyskom-print-elisp-client-read-faq): Use
> 	lyskom-extended-status-information to check for extended status
> 	information.
>
> 	* vars.el.in (kom-extended-status-information): Updated variable
> 	documentation.
>
parent 7218c565
2003-08-14 David Byers <byers@lysator.liu.se>
Show more stats in non-extended display:
* commands2.el (kom-status-server): Show text, conf and person
statistics in the default display.
Cace get-stats-description:
* services.el (initiate-get-stats-description): Use cache.
* vars.el.in (lyskom-stats-description): New variable.
* parse.el (lyskom-parse-stats-description): Cache result.
Show some boottime info:
* commands2.el (kom-status-server): Show server start time and
soem basic statistics in the default display.
Cache static-server-info:
* parse.el (lyskom-parse-static-server-info): Update cache.
* services.el (initiate-get-boottime-info): Use cache.
More fine-grained control over extended status:
* commands2.el (kom-status-server): Only show full server stats if
the appropriate extended status information is on.
* utilities.el (lyskom-extended-status-information): New function.
* commands2.el (kom-status-conf): Set
kom-extended-status-information to t on entry if it contains conf.
(kom-status-server): Set kom-extended-status-information to t on
entry if it contains server.
(kom-status-person): Set kom-extended-status-information to t on
entry if it contains pers.
* aux-items.el (lyskom-print-elisp-client-read-faq): Use
lyskom-extended-status-information to check for extended status
information.
* vars.el.in (kom-extended-status-information): Updated variable
documentation.
Fix bug 1080:
* commands2.el (kom-status-server): Use point-max, not point, to
figure out where insertion starts and ends (lyskom-insert always
......
......@@ -705,7 +705,7 @@ return non-nil if the item is to be included in the list."
(lyskom-aux-item-terminating-button item obj))))
(defun lyskom-print-elisp-client-read-faq (item &optional obj)
(when kom-extended-status-information
(when (lyskom-extended-status-information 'read-faq)
(when (string-match "^\\([0-9]+\\) \\([0-9]+\\)" (aux-item->data item))
(let ((conf-no (string-to-int (match-string 1 (aux-item->data item))))
(text-no (string-to-int (match-string 2 (aux-item->data item)))))
......
......@@ -196,7 +196,8 @@ otherwise: the conference is read with lyskom-completing-read."
(or conf-no
(lyskom-read-conf-no (lyskom-get-string 'conf-for-status)
'(all) nil nil t)))
(kom-print-seconds-in-time-strings nil))
(kom-print-seconds-in-time-strings nil)
(kom-extended-status-information (lyskom-extended-status-override 'conf)))
(cache-del-conf-stat conf-no)
(cache-del-uconf-stat conf-no)
(blocking-do-multiple ((conf-stat (get-conf-stat conf-no))
......@@ -397,6 +398,7 @@ This command accepts text number prefix arguments \(see
(lyskom-read-conf-no (lyskom-get-string 'pers-for-status)
'(pers) nil nil t)))
(kom-print-seconds-in-time-strings nil)
(kom-extended-status-information (lyskom-extended-status-override 'pers))
conf-stat
pers-stat)
(cache-del-conf-stat pers-no)
......@@ -2991,7 +2993,12 @@ properly in the client."
(server-time (get-time))
(highest-text (find-previous-text-no lyskom-max-int))
(first-text (find-next-text-no 0))
(session-info (who-is-on-dynamic t t 0)))
(session-info (who-is-on-dynamic t t 0))
(stats-desc (get-stats-description))
(text-stats (get-stats "texts"))
(conf-stats (get-stats "confs"))
(pers-stats (get-stats "persons"))
(boottime-info (get-boottime-info)))
(setq lyskom-server-info (blocking-do 'get-server-info))
(setq lyskom-server-version-info (blocking-do 'get-version-info))
......@@ -3003,10 +3010,37 @@ properly in the client."
(inactive-sessions 0)
(unknown-activity-sessions 0)
(total-sessions (length session-info))
(idle-hide (* 60 (if (numberp kom-idle-hide) kom-idle-hide 30))))
(idle-hide (* 60 (if (numberp kom-idle-hide) kom-idle-hide 30)))
(kom-extended-status-information
(lyskom-extended-status-override 'server))
momentary-index periodic-index)
(setq aux-items (delq canonical-name-aux aux-items))
;; Compute the index into statistics that represents the
;; momentary value (when equals zero) and the periodic
;; value (when is at least five minutes).
(when stats-desc
(let ((min-time
(apply 'min (listify-vector (stats-description->when
stats-desc))))
(max-time
(apply 'max (listify-vector (stats-description->when
stats-desc))))
(i 0)
(min-diff lyskom-max-int)
max-time-index)
(lyskom-traverse val (stats-description->when stats-desc)
(when (eq val min-time) (setq momentary-index i))
(when (eq val max-time) (setq max-time-index i))
(when (and (>= val 300)
(< (- val 300) min-diff))
(setq min-diff (- val 300)
periodic-index i))
(setq i (1+ i)))
(unless periodic-index (setq periodic-index max-time-index))))
;; ----------------------------------------
;; Compute session statistics
(lyskom-traverse session session-info
......@@ -3061,6 +3095,30 @@ properly in the client."
(setq canonical-name (aux-item->data canonical-name-aux)))
(lyskom-format-insert 'server-status-server canonical-name canonical-port)))
;; ----------------------------------------
;; Print start time and such
(when boottime-info
(lyskom-format-insert 'server-status-boot-time
(let ((kom-print-relative-dates nil))
(lyskom-format-time
'date-and-time
(static-server-info->boot-time
boottime-info))))
(lyskom-format-insert
'server-status-save-time
(let ((kom-print-relative-dates nil))
(lyskom-format-time
'date-and-time
(static-server-info->save-time
boottime-info)))
(cond ((equal "clean" (static-server-info->db-status boottime-info)) nil)
(t (condition-case nil
(lyskom-get-string (intern (concat "db-status-" (static-server-info->db-status boottime-info))))
(error (static-server-info->db-status boottime-info))))))
)
;; ----------------------------------------
;; Print time
(lyskom-format-insert 'server-status-time
......@@ -3069,6 +3127,7 @@ properly in the client."
;; ----------------------------------------
;; Print session statistics
(lyskom-format-insert 'server-status-sessions
total-sessions
active-sessions
......@@ -3078,10 +3137,49 @@ properly in the client."
anonymous-sessions
(/ idle-hide 60))
;; ----------------------------------------
;; Print stats for confs and persons
(when pers-stats
(lyskom-format-insert 'server-status-pers
(stats->average
(elt pers-stats momentary-index))
(lyskom-format-time-units
(stats->ascent-rate
(elt pers-stats periodic-index)))
(static-server-info->existing-persons
boottime-info)))
(when conf-stats
(lyskom-format-insert 'server-status-confs
(stats->average
(elt conf-stats momentary-index))
(lyskom-format-time-units
(stats->ascent-rate
(elt conf-stats periodic-index)))
(static-server-info->existing-confs
boottime-info)))
;; ----------------------------------------
;; Print info on text numbers
(when text-stats
(lyskom-format-insert 'server-status-texts
(stats->average
(elt text-stats momentary-index))
(lyskom-format-time-units
(stats->ascent-rate
(elt text-stats periodic-index)))
(static-server-info->existing-texts
boottime-info)))
(lyskom-format-insert 'server-status-first-text first-text)
(lyskom-format-insert 'server-status-last-text highest-text)
(lyskom-format-insert 'server-status-last-text
highest-text
(when boottime-info
(static-server-info->highest-text-no
boottime-info)))
;; ----------------------------------------
;; Print remaining aux-items
......@@ -3099,55 +3197,56 @@ properly in the client."
;; ----------------------------------------
;; Print statistics
(let* ((stats (lyskom-get-server-stats))
(what (server-stats->what stats))
(maxlen (and stats (apply 'max (mapcar 'length what))))
(fmt (and maxlen (format "%%=%d#1s " maxlen))))
(when stats
(lyskom-format-insert 'status-server-stats)
(lyskom-insert (lyskom-format fmt ""))
(lyskom-traverse period (server-stats->when stats)
(lyskom-format-insert " %=8#1s"
(if (eq 0 period)
(lyskom-get-string 'current-average)
(lyskom-format-units period
'((604800 . "w")
(86400 . "d")
(3600 . "h")
(60 . "m"))
"s"))))
(lyskom-insert "\n")
(lyskom-traverse item (server-stats->values stats)
(let ((start (point-max))
(inhibit-read-only t))
(lyskom-format-insert fmt (car item))
(lyskom-traverse val (cdr item)
(lyskom-format-insert " %=8.2.7#1f" (stats->average val)))
(when (lyskom-extended-status-information 'raw-server-stats)
(let* ((stats (lyskom-get-server-stats))
(what (server-stats->what stats))
(maxlen (and stats (apply 'max (mapcar 'length what))))
(fmt (and maxlen (format "%%=%d#1s " maxlen))))
(when stats
(lyskom-format-insert 'status-server-stats)
(lyskom-insert (lyskom-format fmt ""))
(lyskom-traverse period (server-stats->when stats)
(lyskom-format-insert " %=8#1s"
(if (eq 0 period)
(lyskom-get-string 'current-average)
(lyskom-format-units period
'((604800 . "w")
(86400 . "d")
(3600 . "h")
(60 . "m"))
"s"))))
(lyskom-insert "\n")
(lyskom-traverse item (server-stats->values stats)
(let ((start (point-max))
(inhibit-read-only t))
(lyskom-format-insert fmt (car item))
(lyskom-traverse val (cdr item)
(lyskom-format-insert " %=8.2.7#1f" (stats->average val)))
(lyskom-format-insert "\n")
(add-text-properties start (point-max) `(face ,kom-mark-face)))
(lyskom-format-insert fmt "")
(lyskom-insert " ")
(let ((index 0))
(lyskom-traverse val (cdr item)
(if (eq (elt (server-stats->when stats) index) 0)
(lyskom-insert " ")
(lyskom-format-insert " %=8.2.7#1f+"
(stats->ascent-rate val)))
(setq index (1+ index))))
(lyskom-format-insert "\n")
(lyskom-format-insert fmt "")
(lyskom-insert " ")
(let ((index 0))
(lyskom-traverse val (cdr item)
(if (eq (elt (server-stats->when stats) index) 0)
(lyskom-insert " ")
(lyskom-format-insert " %=8.2.7#1f-"
(stats->descent-rate val)))
(setq index (1+ index))))
(lyskom-format-insert "\n")
(add-text-properties start (point-max) `(face ,kom-mark-face)))
(lyskom-format-insert fmt "")
(lyskom-insert " ")
(let ((index 0))
(lyskom-traverse val (cdr item)
(if (eq (elt (server-stats->when stats) index) 0)
(lyskom-insert " ")
(lyskom-format-insert " %=8.2.7#1f+"
(stats->ascent-rate val)))
(setq index (1+ index))))
(lyskom-format-insert "\n")
(lyskom-format-insert fmt "")
(lyskom-insert " ")
(let ((index 0))
(lyskom-traverse val (cdr item)
(if (eq (elt (server-stats->when stats) index) 0)
(lyskom-insert " ")
(lyskom-format-insert " %=8.2.7#1f-"
(stats->descent-rate val)))
(setq index (1+ index))))
(lyskom-format-insert "\n")
)))
))))
;; ----------------------------------------
......
......@@ -1772,10 +1772,15 @@ Number of sessions: %21#1d (total)
%21#4d unknown activity
%21#5d invisible sessions
%21#6d not logged on/secret/zombies\n")
(server-status-first-text . "Oldest existing text: %15#1n\n")
(server-status-last-text . "Youngest existing text: %15#1n\n")
(server-status-first-text . "Oldest existing text: %14#1n\n")
(server-status-last-text . "Youngest existing text: %14#1n%#2?b%[ (%#2n at start)%]%[%]\n")
(server-status-texts . "Number of texts: %14#1d (%#2s, %#3d at start)\n")
(server-status-confs . "Number of conferences: %14#1d (%#2s, %#3d at start)\n")
(server-status-pers . "Number of persons: %14#1d (%#2s, %#3d at start)\n")
(server-status-has-motd . "\nThe server has a notice:\n")
(server-status-time . "Serverns tid: %#1s\n")
(server-status-time . "Current server time: %#1s\n")
(server-status-boot-time . "Server start time: %#1s\n")
(server-status-save-time . "Initial database save time: %#1s%#2?b%[ (%#2s)%]%[%]\n")
(mship-type-invitation-q . "Membership invitation? ")
(mship-type-passive-q . "Passive membership? ")
......@@ -1952,6 +1957,15 @@ written a presentation.%]
(status-server-stats . "Server statistics:\n\n")
(current-average . "current")
(unit-second . "second")
(unit-minute . "minute")
(unit-hour . "hour")
(unit-day . "day")
(unit-mongth . "month")
(unit-year . "year")
(db-status-backup . "information loss may have occurred")
))
......@@ -2972,6 +2986,17 @@ Select whether to execute command or keyboard macro.")
(yes-dont-pop . "Yes, but don't uniconify frames")
(language . "Language")
(specific-extended-info . "Only selected information")
(extended-info-show . "Show:")
(extended-info-type . "Information type:")
(extended-server-info . "All extended server information")
(extended-conf-info . "All extended conference information")
(extended-pers-info . "All extended person information")
(extended-read-faq-info . "Read FAQs")
(extended-statistics-info . "Full server statistics")
(extended-all-other-info . "Other information")
;;
;; Misc doc strings
;;
......
......@@ -840,7 +840,19 @@ All key bindings:
:tag name) :indent 4))
(kom-print-relative-dates (toggle (yes no)))
(kom-print-seconds-in-time-strings (toggle (yes no)))
(kom-extended-status-information (toggle (yes no)))
(kom-extended-status-information (choice ((const (yes t))
(repeat (cons ((choice ((const (extended-conf-info server))
(const (extended-pers-info pers))
(const (extended-server-info server))
(const (extended-read-faq-info read-faq))
(const (extended-statistics-info raw-server-stats))
(const (extended-all-other-info t))
)
:tag extended-info-type
:format "%[%t%] %v ")
(toggle (yes no) :tag extended-info-show)))
:tag specific-extended-info
:menu-tag specific-extended-info))))
(kom-edit-hide-add-button (noggle (yes no)))
(kom-keyboard-menu-immediate-selection (noggle (yes no)))
(kom-url-transformation-rules (repeat (cons ((string nil :tag url-transform-regexp)
......
......@@ -1092,10 +1092,12 @@ Args: TEXT-NO. Value: text-stat."
(defun lyskom-parse-stats-description ()
"Parse a Stats-Description"
(lyskom-create-stats-description
(lyskom-parse-vector (lyskom-parse-num) 'lyskom-parse-string)
(lyskom-parse-vector (lyskom-parse-num) 'lyskom-parse-num)))
(let ((tmp (lyskom-create-stats-description
(lyskom-parse-vector (lyskom-parse-num) 'lyskom-parse-string)
(lyskom-parse-vector (lyskom-parse-num) 'lyskom-parse-num))))
(lyskom-save-excursion
(set-buffer lyskom-buffer)
(setq lyskom-stats-description tmp))))
(defun lyskom-parse-stats ()
"Parse a Stats"
......@@ -1109,14 +1111,17 @@ Args: TEXT-NO. Value: text-stat."
(defun lyskom-parse-static-server-info ()
"Parse a static-server-info"
(lyskom-create-static-server-info (lyskom-parse-time)
(lyskom-parse-time)
(lyskom-parse-string)
(lyskom-parse-num)
(lyskom-parse-num)
(lyskom-parse-num)
(lyskom-parse-num)
(lyskom-parse-num)))
(let ((tmp (lyskom-create-static-server-info (lyskom-parse-time)
(lyskom-parse-time)
(lyskom-parse-string)
(lyskom-parse-num)
(lyskom-parse-num)
(lyskom-parse-num)
(lyskom-parse-num)
(lyskom-parse-num))))
(lyskom-save-excursion
(set-buffer lyskom-buffer)
(setq lyskom-static-server-info tmp))))
;;; ================================================================
......
......@@ -1305,8 +1305,12 @@ Args: KOM-QUEUE HANDLER SESSION-NO &rest DATA"
(defun initiate-get-stats-description (kom-queue handler &rest data)
(lyskom-server-call
(lyskom-call kom-queue lyskom-ref-no handler data 'lyskom-parse-stats-description)
(lyskom-send-packet kom-queue (lyskom-format-objects 111))))
(if lyskom-stats-description
(progn (lyskom-call-add kom-queue 'PARSED lyskom-stats-description
handler data)
(lyskom-check-call kom-queue))
(lyskom-call kom-queue lyskom-ref-no handler data 'lyskom-parse-stats-description)
(lyskom-send-packet kom-queue (lyskom-format-objects 111)))))
(defun initiate-get-stats (kom-queue handler what &rest data)
(lyskom-server-call
......@@ -1315,8 +1319,12 @@ Args: KOM-QUEUE HANDLER SESSION-NO &rest DATA"
(defun initiate-get-boottime-info (kom-queue handler &rest data)
(lyskom-server-call
(lyskom-call kom-queue lyskom-ref-no handler data 'lyskom-parse-static-server-info)
(lyskom-send-packet kom-queue (lyskom-format-objects 113))))
(if lyskom-static-server-info
(progn (lyskom-call-add kom-queue 'PARSED lyskom-static-server-info
handler data)
(lyskom-check-call kom-queue))
(lyskom-call kom-queue lyskom-ref-no handler data 'lyskom-parse-static-server-info)
(lyskom-send-packet kom-queue (lyskom-format-objects 113)))))
;;; ================================================================
......
......@@ -1807,10 +1807,15 @@ Antal sessioner: %21#1d (totalt)
%21#4d oknd aktivitet
%21#5d osynliga sessioner
%21#6d ej inloggade/hemliga/zombies\n")
(server-status-first-text . "ldsta befintliga text: %15#1n\n")
(server-status-last-text . "Yngsta befintliga text: %15#1n\n")
(server-status-first-text . "ldsta befintliga text: %14#1n\n")
(server-status-last-text . "Yngsta befintliga text: %14#1n%#2?b%[ (%#2n vid start)%]%[%]\n")
(server-status-texts . "Antal existerande inlgg: %14#1d (%#2s, %#3d vid start)\n")
(server-status-confs . "Antal existerande mten: %14#1d (%#2s, %#3d vid start)\n")
(server-status-pers . "Antal existerande personer: %14#1d (%#2s, %#3d vid start)\n")
(server-status-has-motd . "\nServern har en lapp p drren:\n")
(server-status-time . "Serverns tid: %#1s\n")
(server-status-boot-time . "Servern startades: %#1s\n")
(server-status-save-time . "Initial databas sparades: %#1s%#2?b%[ (%#2s)%]%[%]\n")
(mship-type-invitation-q . "Inbjudan till medlemskap? ")
(mship-type-passive-q . "Passivt medlemskap? ")
......@@ -1982,6 +1987,15 @@ att upprepas d
(status-server-stats . "Statistik om servern:\n\n")
(current-average . "nu")
(unit-second . "sekund")
(unit-minute . "minut")
(unit-hour . "timme")
(unit-day . "dag")
(unit-mongth . "mnad")
(unit-year . "r")
(db-status-backup . "informationsfrlust kan ha frekommit")
))
(lyskom-language-var local lyskom-month-names sv
......@@ -3085,6 +3099,17 @@ att upprepas d
(yes-dont-pop . "Ja, men avikonifiera inte fnstret")
(language . "Sprk")
(specific-extended-info . "Enbart vald information")
(extended-info-show . "Visa:")
(extended-info-type . "Informationstyp:")
(extended-server-info . "All utkad serverinformation")
(extended-conf-info . "All utkad mtesinformation")
(extended-pers-info . "All utkad personinformation")
(extended-read-faq-info . "Lsta FAQ")
(extended-statistics-info . "Fullstndig serverstatistik")
(extended-all-other-info . "Annan information")
;;
;; Misc doc strings
;;
......
......@@ -2034,4 +2034,44 @@ base unit \(which implicitly has a count of 1)."
result)))
""))
(defun lyskom-format-time-units (val &optional what)
"Format VAL as values per time unit in such a way that the
result is readable (i.e. whole numbers, if possible). WHAT is
the unit measured."
(let ((last-unit nil))
(if (eq val 0)
(lyskom-format "0%#1?b%[ %#1s%]%[%]/%#2s"
what
(lyskom-get-string 'unit-hour))
(lyskom-traverse unit '((unit-second . 1)
(unit-minute . 60)
(unit-hour . 60)
(unit-day . 24)
(unit-month . 30)
(unit-year . 12))
(setq val (* val (cdr unit)))
(setq last-unit unit)
(when (> val 1)
(lyskom-traverse-break)))
(lyskom-format "%0.0.4#1f%#2?b%[ %#2s%]%[%]/%#3s" val
what (lyskom-get-string (car last-unit))))))
(defun lyskom-extended-status-information (tag)
"Return non-nil is extended status information indicated by TAG
should be shown."
(cond ((eq kom-extended-status-information t) t)
((assq tag kom-extended-status-information)
(cdr (assq tag kom-extended-status-information)))
((cdr (assq t kom-extended-status-information)))))
(defun lyskom-extended-status-override (tag)
"Return a new value for kom-extended-status-information that
reflects an override of the value by the value of TAG."
(cond ((eq kom-extended-status-information t) t)
((assq tag kom-extended-status-information)
(cdr (assq tag kom-extended-status-information)))
(t kom-extended-status-information)))
......@@ -422,13 +422,30 @@ overlays."
"**Controls display of extra information when displaying LysKOM objects.
If `t', extended status information is listed for all objects in
LysKOM. The information controlled by this variable is the kind of
data that most users are not interested in, and, if displayed, would
make more important information hard to find.
Currently this includes read FAQs (on conferences).
Values other than `t' or `nil' are reserved for future extensions."
LysKOM. If set to an association list, each element is a pair of tag
and value. The tag specifies a type of extended information. If the
corresponding value is `t', the information is shown. If the
corresponding value is `nil', the information is not shown.
Valid tags are:
Tag Meaning
conf Show all extended information for conferences
pers Show all extended information for persons
server Show all extended information for the server
read-faq Show read FAQs
raw-server-stats Show raw server statistics
raw-boottime-info Show raw boot-time server information
t Any information not explicitly listed
The information controlled by this variable is the kind of data that
most users are not interested in, and, if displayed, would make more
important information hard to find.
Currently this includes read FAQs (for letterboxes) and full
statistics and boot-time information (for the server).
Values other than those specified are reserved for future extensions."
server )
(def-kom-var kom-auto-list-faqs t
......@@ -3278,6 +3295,10 @@ will be shown."
"Cache of static-server-info"
local)
(def-kom-var lyskom-stats-description nil
"Cache of get-stats-description"
local)
(def-kom-var lyskom-uconf-cache nil
"Cache of small conference statuses."
local)
......