-1
Der folgende Clojure-Code verursacht eine NPE. Es scheint, dass dies vom Stacktrace verursacht wird, wenn >=
aufgerufen wird. Ich kann nicht herausfinden, warum das passiert.Warum verursacht dieser Clojure-Code eine NPE?
(def service-thresholds
[{:service "cpu idle" :invert true :warning 50 :critital 10}
{:service "cpu user" :invert false :warning 80 :critical 90}])
(defn threshold-check
[thresholds]
(fn [e]
(or (first (for [threshold thresholds
:when (= (:service threshold) (:service e))]
(assoc e :state
(if (not (:invert threshold))
(condp <= (:metric e)
(:critical threshold) "critical"
(:warning threshold) "warning"
"ok")
(condp >= (:metric e)
(:critical threshold) "critical"
(:warning threshold) "warning"
"ok")))))
e)))
(println ((threshold-check service-thresholds) {:service "cpu idle" :metric 20 :state nil}))
Sie sind so richtig! Wie habe ich das nicht gesehen? Vielen Dank. –
akzeptiere seine Antwort dann. – blushrt