LoginSignup
2
0

More than 3 years have passed since last update.

SONiCの動作状態を知る

Posted at

状態取得の方法いろいろ

SONiCにおける動作状態の確認方法は、主にCLIとgRPCがあります。これらについてざっと紹介します。出力例は長いので折りたたませてありますので、具体例を確認したい場合は広げてご覧ください。

CLIによる動作状態取得

SONiCはDebianベースのOSですので、通常のLinuxホストと同様にログインして操作することができます。コンソールもしくはsshでのログインが標準で提供されます。

ログインに必要なアカウント情報ですが、バイナリ提供されているイメージを使っている場合
- Username: admin
- Password: YourPaSsWoRd
となっています。本格的に利用する場合は、各自でビルドする際に本パラメータを変更しておくのが安全です。ログインするとbashが起動します。lspsなど通常のLinuxコマンドを使うことができます。

CLIでの動作確認には、SONiC用に作成された show コマンドを使います。下記では、SONiC-VS (Virtual Switch)での実行結果を紹介します。

バージョンの確認

SONiCのバージョン情報を表示します。イメージをビルドする際に用いられたgitのbranchやcommitを含めたものが表示されます。
admin@sonic:~$ show vesrion

SONiC Software Version: SONiC.bcm-nat-001.0-dirty-20191211.113750
Distribution: Debian 9.11
Kernel: 4.9.0-9-2-amd64
Build commit: 5caad55c
Build date: Wed Dec 11 02:45:20 UTC 2019
Built by: masaru@tama

Platform: x86_64-kvm_x86_64-r0
HwSKU: Force10-S6000
ASIC: vs
Serial Number: 000000
Uptime: 02:59:20 up 0 min,  1 user,  load average: 0.83, 0.24, 0.08

Docker images:
REPOSITORY                 TAG                                   IMAGE ID            SIZE
docker-sflow               bcm-nat-001.0-dirty-20191211.113750   b06fe26b7862        307MB
docker-sflow               latest                                b06fe26b7862        307MB
docker-snmp-sv2            bcm-nat-001.0-dirty-20191211.113750   0fcf497a2c3a        339MB
docker-snmp-sv2            latest                                0fcf497a2c3a        339MB
docker-fpm-frr             bcm-nat-001.0-dirty-20191211.113750   00705acfe985        325MB
docker-fpm-frr             latest                                00705acfe985        325MB
docker-orchagent           bcm-nat-001.0-dirty-20191211.113750   bcd8600760c5        323MB
docker-orchagent           latest                                bcd8600760c5        323MB
docker-platform-monitor    bcm-nat-001.0-dirty-20191211.113750   622614ae134e        333MB
docker-platform-monitor    latest                                622614ae134e        333MB
docker-lldp-sv2            bcm-nat-001.0-dirty-20191211.113750   5a7f98b6f19a        303MB
docker-lldp-sv2            latest                                5a7f98b6f19a        303MB
docker-teamd               bcm-nat-001.0-dirty-20191211.113750   d32a68d03833        305MB
docker-teamd               latest                                d32a68d03833        305MB
docker-syncd-vs            bcm-nat-001.0-dirty-20191211.113750   b13c86201e6b        291MB
docker-syncd-vs            latest                                b13c86201e6b        291MB
docker-dhcp-relay          bcm-nat-001.0-dirty-20191211.113750   c8cd69fd33f7        290MB
docker-dhcp-relay          latest                                c8cd69fd33f7        290MB
docker-database            bcm-nat-001.0-dirty-20191211.113750   f4def7c1d4ef        282MB
docker-database            latest                                f4def7c1d4ef        282MB
docker-router-advertiser   bcm-nat-001.0-dirty-20191211.113750   5adcf42d708c        282MB
docker-router-advertiser   latest                                5adcf42d708c        282MB
docker-sonic-telemetry     bcm-nat-001.0-dirty-20191211.113750   690279e6ce9b        305MB
docker-sonic-telemetry     latest                                690279e6ce9b        305MB

動作中サービスの一覧

SONiCのサービスとして動作しているdockerコンテナとそれらの内部で動作しているプロセスが一覧表示されます。
admin@sonic:~$ show services
snmp    docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  4.0  1.1  61904 22256 pts/0    Ss+  03:00   0:00 /usr/bin/python /usr/bin/supervisord
root         8  0.1  0.6  43396 13644 pts/0    S    03:00   0:00 python /usr/bin/supervisor-proc-exit-listener
root        24  0.0  0.1 250136  2848 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n
Debian-+    29  7.0  0.4  59644  9328 pts/0    S    03:00   0:00 /usr/sbin/snmpd -f -LS4d -u Debian-snmp -g Debian-snmp -I -smux mteTrigger mteTriggerConf ifTable ifXTable inetCidrRouteTable ipCidrRouteTable ip disk_hw -p /run/snmpd.pid
root        31 11.5  1.1 159244 23180 pts/0    Sl   03:00   0:00 python3.6 -m sonic_ax_impl

sflow   docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  1.3  1.0  58204 20376 pts/0    Ss+  03:00   0:00 /usr/bin/python /usr/bin/supervisord
root         8  0.0  0.6  41152 13044 pts/0    S    03:00   0:00 python /usr/bin/supervisor-proc-exit-listener
root        12  0.0  0.1 250136  2808 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n
root        17  1.0  0.2 102652  4460 pts/0    Sl   03:00   0:00 /usr/bin/sflowmgrd

telemetry       docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  1.3  1.0  58204 20512 pts/0    Ss+  03:00   0:00 /usr/bin/python /usr/bin/supervisord
root         8  1.5  0.6  41152 13028 pts/0    S    03:00   0:00 python /usr/bin/supervisor-proc-exit-listener
root        13  0.0  0.1 250136  2788 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n
root        18  4.5  0.7 299108 14340 pts/0    Sl   03:00   0:00 /usr/sbin/telemetry -logtostderr --insecure --port 8080 --allow_no_client_auth -v=2
root        28  0.2  0.5 381088 11560 pts/0    Sl   03:00   0:00 /usr/sbin/dialout_client_cli -insecure -logtostderr -v 2

radv    docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  1.1  1.0  58200 20352 pts/0    Ss+  03:00   0:00 /usr/bin/python /usr/bin/supervisord
root         8  0.6  0.6  41152 13152 pts/0    S    03:00   0:00 python /usr/bin/supervisor-proc-exit-listener
root        12  0.0  0.1 250136  2872 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n

dhcp_relay      docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  1.5  1.0  58216 20456 pts/0    Ss+  03:00   0:00 /usr/bin/python /usr/bin/supervisord
root        17  0.1  0.6  41152 13184 pts/0    S    03:00   0:00 python /usr/bin/supervisor-proc-exit-listener
root        21  0.0  0.1 250136  2928 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n

lldp    docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.9  1.0  58608 20548 pts/0    Ss+  03:00   0:00 /usr/bin/python /usr/bin/supervisord
root         8  0.0  0.6  41152 13072 pts/0    S    03:00   0:00 python /usr/bin/supervisor-proc-exit-listener
root        16  0.0  0.1 250136  2876 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n
root        21  0.0  0.2  60748  4644 pts/0    S    03:00   0:00 lldpd: monitor.
_lldpd      23  0.1  0.1  60748  2892 pts/0    S    03:00   0:00 lldpd: no neighbor.
root        27  0.3  0.7 120460 14992 pts/0    Sl   03:00   0:00 python2 -m lldp_syncd
root        33  0.4  0.5  52824 12012 pts/0    S    03:00   0:00 python /usr/bin/lldpmgrd

syncd   docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.2  1.0  58208 20560 pts/0    Ss+  03:00   0:00 /usr/bin/python /usr/bin/supervisord
root        17  0.5  0.1 250136  3172 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n
root        24  2.4  0.5 1197544 10048 pts/0   Sl   03:00   0:01 /usr/bin/syncd -u -p /usr/share/sonic/hwsku/sai.profile

teamd   docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.5  1.0  58208 20520 pts/0    Ss+  03:00   0:00 /usr/bin/python /usr/bin/supervisord
root        13  0.1  0.6  41152 13272 pts/0    S    03:00   0:00 python /usr/bin/supervisor-proc-exit-listener
root        19  0.0  0.1 250136  2920 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n
root        24  0.0  0.2 102632  4356 pts/0    Sl   03:00   0:00 /usr/bin/teammgrd
root        27  0.0  0.1 108700  2512 pts/0    Sl   03:00   0:00 /usr/bin/teamsyncd

swss    docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.6  1.0  58800 20980 pts/0    Ss+  02:59   0:00 /usr/bin/python /usr/bin/supervisord
root        24  0.0  0.6  41152 13276 pts/0    S    03:00   0:00 python /usr/bin/supervisor-proc-exit-listener
root        41  0.0  0.1 250136  2784 pts/0    Sl   03:00   0:00 /usr/sbin/rsyslogd -n
root        46  0.2  0.4 187284  8888 pts/0    Sl   03:00   0:00 /usr/bin/orchagent -d /var/log/swss -b 8192 -m 52:54:00:ba:8a:cb
root        59  0.6  0.2 102672  4544 pts/0    Sl   03:00   0:00 /usr/bin/portsyncd
root       136  0.0  0.2 102564  4416 pts/0    Sl   03:00   0:00 /usr/bin/neighsyncd
root       149  0.0  0.2 102752  4520 pts/0    Sl   03:00   0:00 /usr/bin/vrfmgrd
root       164  0.0  0.2 102644  4440 pts/0    Sl   03:00   0:00 /usr/bin/vlanmgrd
root       181  0.0  0.2 102756  4700 pts/0    Sl   03:00   0:00 /usr/bin/intfmgrd
root       253  0.0  0.2 102740  4468 pts/0    Sl   03:00   0:00 /usr/bin/portmgrd
root       384  0.0  0.2 102664  4520 pts/0    Sl   03:00   0:00 /usr/bin/buffermgrd -l /usr/share/sonic/hwsku/pg_profile_lookup.ini
root       387  0.2  0.6  45408 13512 pts/0    S    03:00   0:00 python /usr/bin/enable_counters.py
root       390  0.0  0.2 102508  4440 pts/0    Sl   03:00   0:00 /usr/bin/nbrmgrd
root       393  0.0  0.2 102736  4608 pts/0    Sl   03:00   0:00 /usr/bin/vxlanmgrd

bgp     docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.1  1.0  58632 20868 pts/0    Ss+  02:58   0:00 /usr/bin/python /usr/bin/supervisord
root        36  0.0  0.1 250136  3036 pts/0    Sl   02:58   0:00 /usr/sbin/rsyslogd -n
frr         43  0.0  0.5 570336 11380 pts/0    Sl   02:58   0:00 /usr/lib/frr/zebra -A 127.0.0.1 -s 90000000 -M fpm -M snmp
frr         47  0.0  0.2  95572  5792 pts/0    S    02:58   0:00 /usr/lib/frr/staticd -A 127.0.0.1
frr         50  0.0  0.7 358732 14832 pts/0    Sl   02:58   0:00 /usr/lib/frr/bgpd -A 127.0.0.1 -M snmp
root        57  0.0  0.2 103620  4220 pts/0    Sl   02:58   0:00 fpmsyncd
root        60  0.0  1.0  72116 20604 pts/0    S    02:59   0:00 python /usr/bin/bgpcfgd

database        docker
---------------------------
USER       PID %CPU %MEM    VSZ   RSS TTY      STAT START   TIME COMMAND
root         1  0.1  1.0  58188 20236 pts/0    Ss+  02:58   0:00 /usr/bin/python /usr/bin/supervisord
root        28  0.0  0.1 250136  2856 pts/0    Sl   02:58   0:00 /usr/sbin/rsyslogd -n
root        29  0.4  0.3  72392  7772 pts/0    Sl   02:58   0:00 /usr/bin/redis-server 127.0.0.1:6379

インタフェースのリンクアップ/ダウンの確認

インタフェース名と設定上のリンクアップ、実際のリンクアップ、速度やMTUなどが表示されます。
admin@sonic:~$ show interfaces status
  Interface            Lanes    Speed    MTU           Alias    Vlan    Oper    Admin    Type    Asym PFC
-----------  ---------------  -------  -----  --------------  ------  ------  -------  ------  ----------
  Ethernet0      25,26,27,28      40G   9100    fortyGigE0/0  routed      up       up     N/A         N/A
  Ethernet4      29,30,31,32      40G   9100    fortyGigE0/4  routed      up       up     N/A         N/A
  Ethernet8      33,34,35,36      40G   9100    fortyGigE0/8  routed      up       up     N/A         N/A
 Ethernet12      37,38,39,40      40G   9100   fortyGigE0/12  routed      up       up     N/A         N/A
 Ethernet16      45,46,47,48      40G   9100   fortyGigE0/16  routed      up       up     N/A         N/A
 Ethernet20      41,42,43,44      40G   9100   fortyGigE0/20  routed      up       up     N/A         N/A
 Ethernet24          1,2,3,4      40G   9100   fortyGigE0/24  routed      up       up     N/A         N/A
 Ethernet28          5,6,7,8      40G   9100   fortyGigE0/28  routed      up       up     N/A         N/A
 Ethernet32      13,14,15,16      40G   9100   fortyGigE0/32  routed      up       up     N/A         N/A
 Ethernet36       9,10,11,12      40G   9100   fortyGigE0/36  routed      up       up     N/A         N/A
 Ethernet40      17,18,19,20      40G   9100   fortyGigE0/40  routed      up       up     N/A         N/A
 Ethernet44      21,22,23,24      40G   9100   fortyGigE0/44  routed      up       up     N/A         N/A
 Ethernet48      53,54,55,56      40G   9100   fortyGigE0/48  routed      up       up     N/A         N/A
 Ethernet52      49,50,51,52      40G   9100   fortyGigE0/52  routed      up       up     N/A         N/A
 Ethernet56      57,58,59,60      40G   9100   fortyGigE0/56  routed      up       up     N/A         N/A
 Ethernet60      61,62,63,64      40G   9100   fortyGigE0/60  routed      up       up     N/A         N/A
 Ethernet64      69,70,71,72      40G   9100   fortyGigE0/64  routed      up       up     N/A         N/A
 Ethernet68      65,66,67,68      40G   9100   fortyGigE0/68  routed      up       up     N/A         N/A
 Ethernet72      73,74,75,76      40G   9100   fortyGigE0/72  routed      up       up     N/A         N/A
 Ethernet76      77,78,79,80      40G   9100   fortyGigE0/76  routed      up       up     N/A         N/A
 Ethernet80  109,110,111,112      40G   9100   fortyGigE0/80  routed      up       up     N/A         N/A
 Ethernet84  105,106,107,108      40G   9100   fortyGigE0/84  routed      up       up     N/A         N/A
 Ethernet88  113,114,115,116      40G   9100   fortyGigE0/88  routed      up       up     N/A         N/A
 Ethernet92  117,118,119,120      40G   9100   fortyGigE0/92  routed      up       up     N/A         N/A
 Ethernet96  125,126,127,128      40G   9100   fortyGigE0/96  routed      up       up     N/A         N/A
Ethernet100  121,122,123,124      40G   9100  fortyGigE0/100  routed      up       up     N/A         N/A
Ethernet104      81,82,83,84      40G   9100  fortyGigE0/104  routed      up       up     N/A         N/A
Ethernet108      85,86,87,88      40G   9100  fortyGigE0/108  routed      up       up     N/A         N/A
Ethernet112      93,94,95,96      40G   9100  fortyGigE0/112  routed      up       up     N/A         N/A
Ethernet116      89,90,91,92      40G   9100  fortyGigE0/116  routed      up       up     N/A         N/A
Ethernet120  101,102,103,104      40G   9100  fortyGigE0/120  routed      up       up     N/A         N/A
Ethernet124     97,98,99,100      40G   9100  fortyGigE0/124  routed      up       up     N/A         N/A
admin@sonic:~$

インタフェースへのIPアドレス付与状態の確認

インタフェース名とそれに紐づくIPアドレス、リンク状態、BGPのneighborの情報が表示されます。
admin@sonic:~$ show ip interfaces
Interface    Master    IPv4 address/mask    Admin/Oper    BGP Neighbor    Neighbor IP
-----------  --------  -------------------  ------------  --------------  -------------
Ethernet0              10.0.0.0/31          up/up         ARISTA01T2      10.0.0.1
Ethernet4              10.0.0.2/31          up/up         ARISTA02T2      10.0.0.3
Ethernet8              10.0.0.4/31          up/up         ARISTA03T2      10.0.0.5
Ethernet12             10.0.0.6/31          up/up         ARISTA04T2      10.0.0.7
Ethernet16             10.0.0.8/31          up/up         ARISTA05T2      10.0.0.9
Ethernet20             10.0.0.10/31         up/up         ARISTA06T2      10.0.0.11
Ethernet24             10.0.0.12/31         up/up         ARISTA07T2      10.0.0.13
Ethernet28             10.0.0.14/31         up/up         ARISTA08T2      10.0.0.15
Ethernet32             10.0.0.16/31         up/up         ARISTA09T2      10.0.0.17
Ethernet36             10.0.0.18/31         up/up         ARISTA10T2      10.0.0.19
Ethernet40             10.0.0.20/31         up/up         ARISTA11T2      10.0.0.21
Ethernet44             10.0.0.22/31         up/up         ARISTA12T2      10.0.0.23
Ethernet48             10.0.0.24/31         up/up         ARISTA13T2      10.0.0.25
Ethernet52             10.0.0.26/31         up/up         ARISTA14T2      10.0.0.27
Ethernet56             10.0.0.28/31         up/up         ARISTA15T2      10.0.0.29
Ethernet60             10.0.0.30/31         up/up         ARISTA16T2      10.0.0.31
Ethernet64             10.0.0.32/31         up/up         ARISTA01T0      10.0.0.33
Ethernet68             10.0.0.34/31         up/up         ARISTA02T0      10.0.0.35
Ethernet72             10.0.0.36/31         up/up         ARISTA03T0      10.0.0.37
Ethernet76             10.0.0.38/31         up/up         ARISTA04T0      10.0.0.39
Ethernet80             10.0.0.40/31         up/up         ARISTA05T0      10.0.0.41
Ethernet84             10.0.0.42/31         up/up         ARISTA06T0      10.0.0.43
Ethernet88             10.0.0.44/31         up/up         ARISTA07T0      10.0.0.45
Ethernet92             10.0.0.46/31         up/up         ARISTA08T0      10.0.0.47
Ethernet96             10.0.0.48/31         up/up         ARISTA09T0      10.0.0.49
Ethernet100            10.0.0.50/31         up/up         ARISTA10T0      10.0.0.51
Ethernet104            10.0.0.52/31         up/up         ARISTA11T0      10.0.0.53
Ethernet108            10.0.0.54/31         up/up         ARISTA12T0      10.0.0.55
Ethernet112            10.0.0.56/31         up/up         ARISTA13T0      10.0.0.57
Ethernet116            10.0.0.58/31         up/up         ARISTA14T0      10.0.0.59
Ethernet120            10.0.0.60/31         up/up         ARISTA15T0      10.0.0.61
Ethernet124            10.0.0.62/31         up/up         ARISTA16T0      10.0.0.63
Loopback0              10.1.0.1/32          up/up         N/A             N/A
docker0                240.127.1.1/24       up/down       N/A             N/A
lo                     127.0.0.1/8          up/up         N/A             N/A

SFP挿入状態の確認

各ポートにトランシーバ等が挿入されているかを確認できます。
admin@sonic:~$ show interfaces transceiver presence
Port         Presence
-----------  -----------
Ethernet0    Not present
Ethernet4    Not present
Ethernet8    Not present
Ethernet12   Not present
Ethernet16   Not present
Ethernet20   Not present
Ethernet24   Not present
Ethernet28   Not present
Ethernet32   Not present
Ethernet36   Not present
Ethernet40   Not present
Ethernet44   Not present
Ethernet48   Not present
Ethernet52   Not present
Ethernet56   Not present
Ethernet60   Not present
Ethernet64   Not present
Ethernet68   Not present
Ethernet72   Not present
Ethernet76   Not present
Ethernet80   Not present
Ethernet84   Not present
Ethernet88   Not present
Ethernet92   Not present
Ethernet96   Not present
Ethernet100  Not present
Ethernet104  Not present
Ethernet108  Not present
Ethernet112  Not present
Ethernet116  Not present
Ethernet120  Not present
Ethernet124  Not present

経路情報の確認

経路情報を確認できます。
admin@sonic:~$ show ip route
Codes: K - kernel route, C - connected, S - static, R - RIP,
       O - OSPF, I - IS-IS, B - BGP, E - EIGRP, N - NHRP,
       T - Table, v - VNC, V - VNC-Direct, A - Babel, D - SHARP,
       F - PBR, f - OpenFabric,
       > - selected route, * - FIB route, q - queued route, r - rejected route

C>* 10.0.0.0/31 is directly connected, Ethernet0, 00:02:42
C>* 10.0.0.2/31 is directly connected, Ethernet4, 00:02:42
C>* 10.0.0.4/31 is directly connected, Ethernet8, 00:02:40
C>* 10.0.0.6/31 is directly connected, Ethernet12, 00:02:42
C>* 10.0.0.8/31 is directly connected, Ethernet16, 00:02:42
C>* 10.0.0.10/31 is directly connected, Ethernet20, 00:02:42
C>* 10.0.0.12/31 is directly connected, Ethernet24, 00:02:42
C>* 10.0.0.14/31 is directly connected, Ethernet28, 00:02:42
C>* 10.0.0.16/31 is directly connected, Ethernet32, 00:02:42
C>* 10.0.0.18/31 is directly connected, Ethernet36, 00:02:42
C>* 10.0.0.20/31 is directly connected, Ethernet40, 00:02:41
C>* 10.0.0.22/31 is directly connected, Ethernet44, 00:02:41
C>* 10.0.0.24/31 is directly connected, Ethernet48, 00:02:41
C>* 10.0.0.26/31 is directly connected, Ethernet52, 00:02:41
C>* 10.0.0.28/31 is directly connected, Ethernet56, 00:02:41
C>* 10.0.0.30/31 is directly connected, Ethernet60, 00:02:41
C>* 10.0.0.32/31 is directly connected, Ethernet64, 00:02:40
C>* 10.0.0.34/31 is directly connected, Ethernet68, 00:02:40
C>* 10.0.0.36/31 is directly connected, Ethernet72, 00:02:40
C>* 10.0.0.38/31 is directly connected, Ethernet76, 00:02:40
C>* 10.0.0.40/31 is directly connected, Ethernet80, 00:02:37
C>* 10.0.0.42/31 is directly connected, Ethernet84, 00:02:37
C>* 10.0.0.44/31 is directly connected, Ethernet88, 00:02:36
C>* 10.0.0.46/31 is directly connected, Ethernet92, 00:02:36
C>* 10.0.0.48/31 is directly connected, Ethernet96, 00:02:33
C>* 10.0.0.50/31 is directly connected, Ethernet100, 00:02:42
C>* 10.0.0.52/31 is directly connected, Ethernet104, 00:02:42
C>* 10.0.0.54/31 is directly connected, Ethernet108, 00:02:42
C>* 10.0.0.56/31 is directly connected, Ethernet112, 00:02:42
C>* 10.0.0.58/31 is directly connected, Ethernet116, 00:02:42
C>* 10.0.0.60/31 is directly connected, Ethernet120, 00:02:42
C>* 10.0.0.62/31 is directly connected, Ethernet124, 00:02:42
C>* 10.1.0.1/32 is directly connected, Loopback0, 00:02:47

電源の状態確認

PSUの状態を確認できます。仮想マシン実装の場合は取得できません。
admin@sonic:~$ show platform psustatus
Error! Failed to get the number of PSUs!
Error: fail to get psu status from state DB

稼働時間の確認

最後に起動してからの稼働時間を確認できます。累積ではありません。
admin@sonic:~$ show uptime
up 2 hours, 49 minutes

gRPCによる状態取得

telemetry serviceが正常に動作していれば、gNMI GETを使って状態取得ができます。
下記例においていくつかのパラメータは設定や環境に依存します。例そのままコピペでなく、書き換えてお試しください。
- -target_addrに指定するのは実機のマネジメントポートに付与されたIPアドレスです。
- ポート8080はSONiC側で特に設定を支持しなかったときのポート番号になります。別ポートを使用する場合はSONiCのconfig_db.jsonに設定を加えてください。
$ ~/go/bin/gnmi_get -xpath_target COUNTERS_DB -xpath COUNTERS_PORT_NAME_MAP -target_addr 192.168.0.1:8080 -alsologtostderr -insecure true
== getRequest:
prefix: <
  target: "COUNTERS_DB"
>
path: <
  elem: <
    name: "COUNTERS_PORT_NAME_MAP"
  >
>
encoding: JSON_IETF

== getResponse:
notification: <
  timestamp: 1576507340072769775
  prefix: <
    target: "COUNTERS_DB"
  >
  update: <
    path: <
      elem: <
        name: "COUNTERS_PORT_NAME_MAP"
      >
    >
    val: <
      json_ietf_val: "{\"Ethernet0\":\"oid:0x1000000000002\",\"Ethernet100\":\"oid:0x100000000001c\",\"Ethernet104\":\"oid:0x100000000001d\",\"Ethernet108\":\"oid:0x100000000001e\",\"Ethernet112\":\"oid:0x100000000001f\",\"Ethernet116\":\"oid:0x1000000000020\",\"Ethernet12\":\"oid:0x1000000000005\",\"Ethernet120\":\"oid:0x1000000000021\",\"Ethernet124\":\"oid:0x1000000000022\",\"Ethernet16\":\"oid:0x1000000000006\",\"Ethernet20\":\"oid:0x1000000000007\",\"Ethernet24\":\"oid:0x1000000000008\",\"Ethernet28\":\"oid:0x1000000000009\",\"Ethernet32\":\"oid:0x100000000000a\",\"Ethernet36\":\"oid:0x100000000000b\",\"Ethernet4\":\"oid:0x1000000000003\",\"Ethernet40\":\"oid:0x100000000000c\",\"Ethernet44\":\"oid:0x100000000000d\",\"Ethernet48\":\"oid:0x100000000000e\",\"Ethernet52\":\"oid:0x100000000000f\",\"Ethernet56\":\"oid:0x1000000000010\",\"Ethernet60\":\"oid:0x1000000000011\",\"Ethernet64\":\"oid:0x1000000000013\",\"Ethernet68\":\"oid:0x1000000000014\",\"Ethernet72\":\"oid:0x1000000000015\",\"Ethernet76\":\"oid:0x1000000000016\",\"Ethernet8\":\"oid:0x1000000000004\",\"Ethernet80\":\"oid:0x1000000000017\",\"Ethernet84\":\"oid:0x1000000000018\",\"Ethernet88\":\"oid:0x1000000000019\",\"Ethernet92\":\"oid:0x100000000001a\",\"Ethernet96\":\"oid:0x100000000001b\"}"
    >
  >
>

JSON出力をフォーマットしてみると下記のようになります。

$ ./gnmi_get -xpath_target COUNTERS_DB -xpath COUNTERS_PORT_NAME_MAP -target_addr 192.168.0.1:8080 -alsologtostderr -insecure true|grep json_ietf_val|awk '{print substr($2, 2, length($2) - 2)}'| sed 's/\\//g'|jq .
{
  "Ethernet96": "oid:0x100000000001b",
  "Ethernet92": "oid:0x100000000001a",
  "Ethernet88": "oid:0x1000000000019",
  "Ethernet84": "oid:0x1000000000018",
  "Ethernet80": "oid:0x1000000000017",
  "Ethernet8": "oid:0x1000000000004",
  "Ethernet76": "oid:0x1000000000016",
  "Ethernet72": "oid:0x1000000000015",
  "Ethernet68": "oid:0x1000000000014",
  "Ethernet64": "oid:0x1000000000013",
  "Ethernet60": "oid:0x1000000000011",
  "Ethernet56": "oid:0x1000000000010",
  "Ethernet52": "oid:0x100000000000f",
  "Ethernet48": "oid:0x100000000000e",
  "Ethernet44": "oid:0x100000000000d",
  "Ethernet40": "oid:0x100000000000c",
  "Ethernet120": "oid:0x1000000000021",
  "Ethernet12": "oid:0x1000000000005",
  "Ethernet116": "oid:0x1000000000020",
  "Ethernet112": "oid:0x100000000001f",
  "Ethernet108": "oid:0x100000000001e",
  "Ethernet104": "oid:0x100000000001d",
  "Ethernet100": "oid:0x100000000001c",
  "Ethernet0": "oid:0x1000000000002",
  "Ethernet124": "oid:0x1000000000022",
  "Ethernet16": "oid:0x1000000000006",
  "Ethernet20": "oid:0x1000000000007",
  "Ethernet24": "oid:0x1000000000008",
  "Ethernet28": "oid:0x1000000000009",
  "Ethernet32": "oid:0x100000000000a",
  "Ethernet36": "oid:0x100000000000b",
  "Ethernet4": "oid:0x1000000000003"
}

状態取得における注意点

  • ソフトウェア実装 (SONiC-VS, SONiC-P4) では取得できない情報があります。たとえば前出のgRPCによる状態取得は、SONiC-VSでは機能しません。

参考リンク

2
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
0