During our Tibco EMS infrastructure upgrade project, we had some rogue connections that just refused to disconnect from the old infrastructure and switch to the new Tibco EMS infrastructure. In order to track down these connections and evict those connections, I had to generate a report which would tell me which user, from which host is connected to particular queues in Tibco EMS. Here's the script that I wrote in Clojure that generates that report.
; Get destination users (and which host the user is connecting from) along with which queue/topic it is connected to. (defn get-destination-users [server-url username password] (with-open [admin (TibjmsAdmin. server-url username password)] (let [connections (.getConnections admin) consumers (.getConsumers admin) dest-userids (->> consumers (map (fn [c] {:userid (.getConnectionID c) :dest (.getDestinationName c)}))) get-user (fn [dest-name id] (let [conn (first (filter #(= id (.getID %)) connections))] (if (nil? conn) {:dest dest-name :user (str "Unknown user : " id) :host "unknown"} {:dest dest-name :user (.getUserName conn) :host (.getHost conn)})))] (map (fn [x] (get-user (:dest x) (:userid x))) dest-userids)))) ; Dump results in CSV format (def results (get-destination-users server-url username password)) (doseq [r (sort-by :user (set results))] (println (str (:user r) "," (:host r) "," (:dest r))))
No comments:
Post a Comment