summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--bgp-logger.org4
-rw-r--r--src/bgpstore.lisp14
-rw-r--r--src/util.lisp10
3 files changed, 23 insertions, 5 deletions
diff --git a/bgp-logger.org b/bgp-logger.org
index b160400..733c8bb 100644
--- a/bgp-logger.org
+++ b/bgp-logger.org
@@ -26,8 +26,8 @@ so now it does.
* TODO
- [X] store timestamp and precision-time
-- [ ] store as-path
-- [ ] move to victoria
+- [X] store as-path
+- [X] move to victoria
- [ ] store nexthop
- [ ] limit access to bgpmon stream (acl's)
- [ ] auto-start on boot
diff --git a/src/bgpstore.lisp b/src/bgpstore.lisp
index aa25b87..4f36394 100644
--- a/src/bgpstore.lisp
+++ b/src/bgpstore.lisp
@@ -4,13 +4,21 @@
(defun start-bgpstore (host port)
(with-connection *db-spec*
- (let ((reader (new-reader host port)))
- (format t "bgpstore started~%")
+ (let ((reader (new-reader host port))
+ (count 0))
+ (format t "~A: bgpstore started~%" (iso-date (get-universal-time) t))
(do ((e (next-xml-blurb reader "BGP_MESSAGE")
(next-xml-blurb reader "BGP_MESSAGE")))
((null e))
(dolist (obj (new-entries (xml-top-elem-from-octets e)))
- (insert-dao obj)))
+ (insert-dao obj)
+ (incf count)
+ (if (= 0 (mod count 100)) (format t ".")
+ (if (= 0 (mod count 1000)) (format t "+")
+ (if (= 0 (mod count 10000))
+ (format t "~%~A: ~A "
+ (iso-date (get-universal-time) t)
+ count))))))
(close-reader))))
(defun stop-bgpstore ())
diff --git a/src/util.lisp b/src/util.lisp
index 32f7d73..87661a0 100644
--- a/src/util.lisp
+++ b/src/util.lisp
@@ -55,3 +55,13 @@ BUGS:
(read-byte (usocket:socket-stream sock) nil)))
(defun close-reader ()
(usocket:socket-close sock)))
+
+(defun iso-date (universal-time &optional (include-seconds nil))
+ "Return a string denoting UNIVERSAL-TIME"
+ (multiple-value-bind (second minute hour day month year)
+ (decode-universal-time universal-time)
+ (if include-seconds
+ (format nil "~4,'0D-~2,'0D-~2,'0D ~2,'0D:~2,'0D:~2,'0D"
+ year month day hour minute second)
+ (format nil "~4,'0D-~2,'0D-~2,'0D ~2,'0D:~2,'0D"
+ year month day hour minute))))