FutureNet

NXR,VXRシリーズ

REST-API編

2. メンテナンス

2-8. exec系,showコマンドの実行(maint/cli)

 処理概要

exec系,showコマンドに関する処理を実行します。

 

URIおよびメソッド

機能 Version URI メソッド
POST PUT GET DELETE
CLI v1 /api/v1/maint/cli
v2 /api/v2/maint/cli
/api/v2/maint/cli/{ID}

凡例:

● : 読み取り専用ユーザも含めアクセス可

〇 : 読み取り専用ユーザはアクセス不可

- : 未対応

※ NXR-G100シリーズ以外の機種ではREST-APIv2の利用を推奨します。

 

実行例

exec系コマンドの実行

メソッド URI
POST /api/v2/maint/cli

 

reset mobileコマンドの実行(JSON)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/json

 

{
"exec" : "reset mobile 1"
}

 

レスポンス

200 OK

 

reset mobileコマンドの実行(XML)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/xml

 

<config>
<exec>reset mobile 1</exec>
</config>

 

レスポンス

200 OK

 

get system statistics cpuコマンドの実行(JSON)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/json

 

{
"exec" : "get system statistics cpu all 1 10"
}

 

レスポンス

202 Accepted
Content-Type: application/json

 

{
"exec-id": "1234",
"expire": 600
}

 

get system statistics cpuコマンドの実行(XML)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/xml

 

<config>
<exec>get system statistics cpu all 1 10</exec>
</config>

 

レスポンス

202 Accepted
Content-Type: application/xml

 

<cli>
<exec-id>1234</exec-id>
<expire>600</expire>
</cli>

 

clear ip bgpコマンドの実行(JSON)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/json

 

{
"exec" : "clear ip bgp *"
}

 

レスポンス

200 OK

 

clear ip bgpコマンドの実行(XML)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/xml

 

<config>
<exec>clear ip bgp *</exec>
</config>

 

レスポンス

200 OK

 

clear dumpコマンドの実行(JSON)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/json

 

{
"exec" : "clear dump"
}

 

レスポンス

200 OK

 

clear dumpコマンドの実行(XML)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/xml

 

<config>
<exec>clear dump</exec>
</config>

 

レスポンス

200 OK

 

delete dumpコマンドの実行(JSON)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/json

 

{
"exec" : "delete dump"
}

 

レスポンス

200 OK

 

delete dumpコマンドの実行(XML)
リクエスト

POST /api/v2/maint/cli
Content-Type: application/xml

 

<config>
<exec>delete dump</exec>
</config>

 

レスポンス

200 OK

 

showコマンドの実行

メソッド URI
PUT /api/{VERSION}/maint/cli

※show syslog message monitorコマンドは実行できません。

 

 

include指定なし(JSON)
リクエスト

PUT /api/v2/maint/cli
Accept: text/plain
Content-Type: application/json

 


{
"show": "interface ethernet 0"
}

 

レスポンス

200 OK
Content-Type: text/plain

 

ethernet0
Link encap:Ethernet HWaddr 00:80:6D:xx:xx:xx
inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:69 errors:0 dropped:10 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7299 (7.1 Kb) TX bytes:1562 (1.5 Kb)

 

include指定なし(XML)
リクエスト

PUT /api/v2/maint/cli
Accept: text/plain
Content-Type: application/xml

 

<config>
<show>interface ethernet 0</show>
</config>

 

レスポンス

200 OK
Content-Type: text/plain

 

ethernet0
Link encap:Ethernet HWaddr 00:80:6D:xx:xx:xx
inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:69 errors:0 dropped:10 overruns:0 frame:0
TX packets:16 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:7299 (7.1 Kb) TX bytes:1562 (1.5 Kb)

 

include指定あり(JSON)
リクエスト

PUT /api/v2/maint/cli
Accept: text/plain
Content-Type: application/json

 


{
"show": "interface ethernet 0",
"include": "inet addr"
}

 

レスポンス

200 OK
Content-Type: text/plain

 

inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0

 

include指定あり(XML)
リクエスト

PUT /api/v2/maint/cli
Accept: text/plain
Content-Type: application/xml

 

<config>
<show>interface ethernet 0</show>
<include>inet addr</include>
</config>

 

レスポンス

200 OK
Content-Type: text/plain

 

inet addr:192.168.0.254 Bcast:192.168.0.255 Mask:255.255.255.0

 

get system statistics cpuコマンドの実行結果の取得

メソッド URI
GET /api/v2/maint/cli/{ID}
  • 実行ID(exec-id)は、0000 ~ ffffまでの4桁の16進数を指定。
  • 実行結果は600秒後に消去されます。

 

TEXT/PLAIN
リクエスト

GET /api/v2/maint/cli/0001
Accept: text/plain

 

レスポンス

200 OK
Content-Type: text/plain

 

[started: 2023/05/09 12:32:15]
 12:32:15   CPU#     %CPU    %user   %nice   %system     %idle   %iowait    %irq    %soft
 12:32:16    all     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:16      0     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:16      1     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:17    all     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:17      0     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:17      1     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:18    all     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:18      0     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:18      1     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:19    all     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:19      0     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:19      1     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:20    all     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:20      0     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 12:32:20      1     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 AVERAGE     all     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 AVERAGE       0     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00
 AVERAGE       1     0.00     0.00    0.00      0.00    100.00      0.00    0.00     0.00

get system statistics cpuコマンドの実行停止・結果の削除

メソッド URI
DELETE /api/v2/maint/cli/{ID}
リクエスト

DELETE /api/v2/maint/cli/0001

 

レスポンス

204 No content