2016-04-21 39 views
0

我對Wildfly很陌生,但我需要通過API設置對各個部署狀態的自動監視。使用curl/API查看Wildfly中的單個部署狀態

在,我可以捲曲查看服務器狀態,以同樣的方式,如:

curl --insecure --digest 'https://admin:[email protected]:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute","name":"server-state","json.pretty":1}' 

返回結果:

{ 
    "outcome" => "success", 
    "result" => "running" 
} 

以同樣的方式,從JBoss CLI,我發出:

:read-attribute(name=server-state) 

並得到相同的結果。

因此,從CLI,如果我發出以下命令來獲取特定的部署狀態:

/deployment=bob :read-attribute(name=status) 

我得到以下結果:

{ 
    "outcome" => "success", 
    "result" => "OK" 
} 

但我不能弄清楚curl命令會給我什麼結果。我已經閱讀了大量的文檔,要麼它不存在,要麼我看錯了地方。我試過了:

curl --insecure --digest 'https://[email protected]:9993/management' --header "Content-Type: application/json" -d '{"deployment":"bob","operation":"read-attribute","name":"status","json.pretty":1}' 

但是沒有奏效。有任何想法嗎?

謝謝, 馬克J.

回答

0

您需要添加爲address屬性的陣列和陣列中移動"deployment":"bob"

curl --insecure --digest 'https://[email protected]:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute", "address":[{"deployment":"bob"}],"name":"status","json.pretty":1}' 

該地址是您要讀取的屬性路徑的名稱/值對對象。例如,如果您想查看與根記錄器關聯的所有處理程序,則可以執行以下操作。

curl --insecure --digest 'https://[email protected]:9993/management' --header "Content-Type: application/json" -d '{"operation":"read-attribute","address":[{"subsystem":"logging"},{"root-logger":"ROOT"}],"name":"handlers","json.pretty":1} 
+0

謝謝詹姆斯。太棒了。 –