Library to access Spring Actuator endpoints.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Sun, 19 Feb 2017 14:38:21 +0200
changeset 1483 a25f209ebf15
parent 1482 d74af7d75f19
child 1484 8fe1eaf66e94
Library to access Spring Actuator endpoints.
spring-actuator.el
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/spring-actuator.el	Sun Feb 19 14:38:21 2017 +0200
@@ -0,0 +1,23 @@
+
+(defvar my/spring-actuator-server-history nil)
+(defvar my/spring-actuator-last-server "http://localhost:8080")
+(defvar my/spring-actuator-path-history nil)
+(defvar my/spring-actuator-path-completion
+  '("actuator" "auditevents" "autoconfig" "beans" "configprops" "dump" "env" "flyway" "health" "heapdump"
+    "info" "jolokia" "liquibase" "logfile" "loggers" "mappings" "metrics" "shutdown" "trace")))
+
+(defun my/spring-actuator (server path)
+  (interactive (list (read-string "Server: " my/spring-actuator-last-server 'my/spring-actuator-server-history)
+                     (completing-read "Path: " my/spring-actuator-path-completion nil nil "" 'my/spring-actuator-path-history)))
+  (setq my/spring-actuator-last-server server)
+  (let ( (bufname (format "actuator: %s" path)) )
+    (when (get-buffer bufname)
+      (kill-buffer bufname))
+    (switch-to-buffer (url-retrieve-synchronously (format "%s/%s" server path)))
+    (rename-buffer bufname)
+    (goto-char (point-min))
+    (re-search-forward "^$" nil 'move)
+    (forward-char)
+    (delete-region (point-min) (point))
+    (json-pretty-print-buffer)
+    (json-mode) ))