No progress with REST API, but for the Java API I was only able to get the results with
freshly generated RemoteDevice, ConfigurationItem, and Metric generated in that order:
Metric refers to CI, CI refers to device. Moreover The RemoteDevice seems to be linked to the robot
it was generated at (maybe only the MD5 hashes are linked?). Below is some code with
comments.
So far I was not able to post alarms using existing Metrics/CI/Devices created by
other probes.
;;
;; The metric is linked to a CI and that is linked to a (remote)
;; device with associated IP and a host name. However if you rely on
;; that and forget to supply the source in addition to the device ID,
;; the source will be set to the robot IP. That does not prevent
;; correlation with the remote device to happen -- the alarm will be
;; displayed in the USM at the tree node of the remote device.
;; However, and this is very confusing, the very first (bold) "host"
;; name that you see in the alarm list view is that of the robot host
;; -- the host name derived by reverse lookup of the source IP, not
;; the actual robot name which is also available with each alarm. So
;; for best results you also need to set the source to the IP of the
;; remote device in addition to the device ID you supplied.
;;
(defn- send-alarm! [level message source device-id metric-id]
(let [alarm (doto (NimAlarm. level message)
;; Numeric ID is expected. Reverse lookup does not
;; happen. If the symbolic name is unknown the numeric
;; path is used instead.
(.setSubSystem "9.9") ; "Test CI", not in DB
;; (.setSubSystem "1.2.2.1") ; 1.2.2.1 = Controller
(.setSuppressionId "test_alarm")
(.setSource source)
;; If you only supply device ID the source will NOT be
;; derived from it:
(.setDevId device-id)
;; If you only supply the metric ID the subsystem and
;; the device will NOT be derived from that:
(.setMetId metric-id))]
;; The confirmation ID returned by send is not the same as in the
;; NAS_ALARM table of the SQL server (FIXME: there are also sqlite
;; tables in nas probe dir):
(.send alarm)))