簡介
本文檔介紹新的統一日誌記錄增強功能,用於收集和管理系統的跟蹤日誌,實現無縫體驗。
概觀
實用目的:
- 疑難排解.當機箱遇到問題時,跟蹤檔案內的資料對於識別和解決問題非常寶貴。
- 調試。trace檔案的輸出可為使用者提供更精細的系統操作和操作視角。
工作方式
- 跟蹤功能可記錄機箱內發生的內部事件的詳細資訊。定期生成並刷新包含模組的完整跟蹤輸出的跟蹤檔案,並將這些檔案儲存在tracelog目錄中。
- 可以釋放檔案系統上的空間。可以從此目錄中刪除跟蹤檔案,而不影響裝置的效能。
- 您可以將跟蹤日誌傳輸到備用位置。您可以使用FTP、TFTP等複製檔案以分析這些檔案,或將其上傳到透過技術協助中心(TAC)開啟的案例中。
- 不能禁用跟蹤日誌,但可以更改跟蹤級別,以確定要為每個模組收集多少資訊。
跟蹤級別
跟蹤級別指定跟蹤緩衝區或檔案中保留的資訊量。接下來是所有可用的跟蹤級別,並說明在每個級別上記錄的消息型別。
Emergency—>系統不穩定/不可用。
錯誤 — >導致在自動解決的情況下出現輕微功能丟失的事件,代表無法立即影響操作但可能會導致未來後果的意外問題。
警告—>可能會自動解決的問題,或會導致功能丟失的情況(如果沒有及時調查和處理)。
注意—>模組的標準日誌級別集。此級別捕獲系統中發生的重要事件。
資訊—>僅資訊性消息。提供與系統或其功能相關的重大事件的其他資訊。
Debug—>提供調試日誌。
Verbose—>提供二級調試日誌。
Noise ->記錄的最大可能消息。
檢視當前跟蹤級別
您可以使用show platform software trace level指令檢視和變更任何模組的追蹤等級。
此命令顯示活動RP上轉發管理器進程的跟蹤級別。
Router#show platform software trace level forwarding-manager rp active
輸出如下:
Module Name Trace Level
-----------------------------------------------
acl Notice
active-identity Notice
alg Notice
appnav-controller Notice
aps Notice
bcrpgc Informational
bfd Notice
bier Notice
修改跟蹤級別
您可以修改特定模組或流程中所有模組的跟蹤級別。為此,您可以使用set platform software trace指令。
此命令set platform software trace chassis-manager f0 cman_fp warning將插槽0中ESP的機箱管理器中的cman_fp跟蹤級別更改為警告級別。
您可以使用此命令show platform software trace level chassis-manager f0驗證更改
輸出如下:
Module Name Trace Level
-----------------------------------------------
bcrpgc Informational
bipc Notice
bsignal Notice
btrace Notice
btrace_ra Notice
cdllib Notice
chasfs Notice
cman_fp Warning
新建跟蹤選項
從16、8開始,思科推出統一日誌記錄增強功能。目標是在IOS日誌記錄和其他進程日誌記錄系統之間為使用者建立無縫的日誌記錄體驗。可以將來自兩個系統的日誌合併並按時間順序顯示,以便您對系統中的問題進行故障排除。
顯示不同進程的Tracelogs
命令show logging process可用於顯示由指定進程生成的跟蹤日誌的內容。輸出中可以包含來自緩衝區和跟蹤日誌目錄的日誌。
還支援部分進程名稱進程名被接受為單詞解析器。
附註:進程名稱必須與tracelog的名稱匹配(部分或完全),否則,可能會發生不匹配,導致不顯示跟蹤。
命令show logging process fman可以組合fman-rp和fman-fp日志。
Router#show logging process fman
Displaying logs from the last 0 days, 0 hours, 10 minutes, 0 seconds
executing cmd on chassis local ...
Unified Decoder Library Init .. DONE
Found 1 UTF Streams
2024/05/22 19:01:01.347466887 {fman_rp_R0-0}{255}: [source] [11941]: (ERR): ipc(mqipc/iosd/iosd-fman):Unable to open config channel to source
2024/05/22 19:00:50.246774567 {fman_fp_image_F0-0}{255}: [btrace] [13616]: (note): Btrace started for process fman_fp_image_pman ID 13616 with 512 modules
2024/05/22 19:00:50.246777079 {fman_fp_image_F0-0}{255}: [btrace] [13616]: (note): File size max used for rotation of tracelogs: 8192
執行多進程支援
現在,「show logging process」CLI命令允許您指定多個進程名稱,這些名稱使用「process」關鍵字以逗號分隔。合併的tracelog僅顯示來自指定進程(如sman和ios進程)的日誌。
Router#show logging process sman,ios
executing cmd on chassis 1 ...
Collecting files on current[1] chassis.
時間視窗選項
所有跟蹤都可以在本地時區具有時間戳(如果配置了任何時間戳)。如果沒有,則在「協調世界時」(UTC)中使用時間戳,但可以使用set logging timezone <local命令在Local和UTC之間切換日誌的時區 | UTC>。
預設情況下,show logging CLI命令僅顯示當前時間的最後10分鐘日誌。
start last關鍵字可用於根據個人需要擴展時間視窗。
Router#show logging process btman start last ?
<0-4294967295> interval (default seconds)
boot system boot time
clear display all logs since last "clear logging"
marker selects latest matching marker from list to start displaying
logs from
附註:如果從上一個命令中選擇一個數值,則可以指定天、小時、分鐘或秒為下一個選項。
新增了end last關鍵字選項,以與start last結合使用來指定時間視窗的結束。同時使用start last和end last選項時,僅收集視窗中的日誌。如果沒有end last選項,則日誌收集會預設使用當前時間作為結束時間。
以下是設定過去兩小時和過去一小時之間的視窗的示例:
Router#show logging process btman start last 2 hours end last 1 hours
Displaying logs from the last 0 days, 2 hours, 0 minutes, 0 seconds
End time set to show logs before last 0 days, 1 hours, 0 minutes, 0 seconds
executing cmd on chassis 1 ...
Collecting files on current[1] chassis.
在特定日誌級別下顯示日誌
只能顯示特定級別的日誌:
Router#show logging process wncd level ?
debug Debug messages
error Error messages
info Informational messages
notice Notice messages
verbose Verbose debug messages
warning Warning messages
以下是錯誤級別通知下的日誌串的示例:
Router#show logging process btman level notice
Logging display requested on 2024/07/24 06:20:23 (UTC) for Hostname: [Router], Model: [ASR1002-HX ], Version: [17.12.03a], SN: [JAD22460SN9], MD_SN: [FXS2223Q74M]
Displaying logs from the last 0 days, 0 hours, 10 minutes, 0 seconds
executing cmd on chassis local ...
Unified Decoder Library Init .. DONE
Found 1 UTF Streams
2024/07/24 06:10:59.533374335 {btman_R0-0}{255}: [utm_main] [5809]: (note): Inserted UTF(2) HT(old):droputil_R0-0[13] lnode /tmp/rp/trace/droputil_R0-0.6823_63.20240724061059.bin PID:6823
2024/07/24 06:10:59.695395289 {btman_R0-0}{255}: [utm_wq] [5809:15578]: (note): Inline sync, enqueue BTF message flags:0x1, PID:15578 BTF:/tmp/rp/trace/droputil_R0-0.6823_62.20240724060959.bin
顯示來自時間戳的日誌
您可以以UTC格式顯示來自特定時間戳的日誌,如「2017/02/10 14:41:50.849425」。以下是示例:
Router#show logging process wncd start timestamp "2024/07/24 05:36:45.849425"
Logging display requested on 2024/07/24 06:39:15 (UTC) for Hostname: [Router], Model: [ASR1002-HX ], Version: [17.12.03a], SN: [JAD22460SN9], MD_SN: [FXS2223Q74M]
executing cmd on chassis local ...
Unified Decoder Library Init .. DONE
Found 1 UTF Streams
Filter policy: Done with UTM processing
顯示兩個時間戳之間的日誌
可以通過新增開始時間戳和結束時間戳,在時間視窗之間顯示tracelogs。以下範例的維護時段為1小時:
Router#show logging process wncd start timestamp "2024/07/24 05:36:45.849425" end timestamp "2024/07/24 06:36:45.849425"
Logging display requested on 2024/07/24 06:39:15 (UTC) for Hostname: [Router], Model: [ASR1002-HX ], Version: [17.12.03a], SN: [JAD22460SN9], MD_SN: [FXS2223Q74M]
executing cmd on chassis local ...
Unified Decoder Library Init .. DONE
Found 1 UTF Streams
Filter policy: Done with UTM processing
執行即時日誌記錄
您可以監視為進程或配置檔案即時生成的日誌。日誌在生成時顯示。
Router#monitor logging process cman ?
<0-25> instance number
filter specify filter for logs
internal select all logs. (Without the internal keyword only customer
curated logs are displayed)
level select logs above specific level
metadata CLI to display metadata for every log message
module select logs for specific modules
提示: 要退出或退出即時日誌記錄模式,請發出CTRL-C。
使用預定義的日誌配置檔案
即時日誌記錄提供易於應用的內建配置檔案。這使使用者無需熟悉構成該功能的基礎進程日誌檔案。支援的配置檔案包括all、file、wireless、sdwan、netconf-yang、restconf、install、hardware-diagnostics。
配置檔案可用於show logging或monitor logging命令。
附註:show logging profile選項只顯示緩衝區的日誌,不包括來自tracelogs目錄的日誌。
SCP_Test#show logging profile ?
all all processes
file show logs for specific profile file
hardware-diagnostics hardware diagnostics specific processes
install Install specific processes
netconf-yang netconf-yang specific processes
restconf restconf specific processes
sdwan SDWAN specific processes
wireless Wireless specific processes
Router#monitor logging profile ?
all all processes
file show logs for specific profile file
hardware-diagnostics hardware diagnostics specific processes
install Install specific processes
netconf-yang netconf-yang specific processes
restconf restconf specific processes
sdwan SDWAN specific processes
wireless Wireless specific processes
在17.12+中,統計資訊預設包含在「show logging <process/profile/file> ...」的結尾。 統計資訊顯示每個嚴重性級別解碼的跟蹤消息數量已新增到現有解碼器統計資訊中。級別計數僅用於已呈現的跟蹤。
2024/07/24 04:26:41.710239127 {btman_R0-0}{255}: [utm_wq] [5806:15568]: (note): Inline sync, enqueue BTF message flags:0x1, PID:15568 BTF:/tmp/rp/trace/IOSRP_R0-0.3437_2.20240724042222.bin
2024/07/24 04:26:41.759114843 {btman_R0-0}{255}: [utm_wq] [5806]: (note): utm delete /tmp/rp/trace/IOSRP_R0-0.3437_2.20240724042222.bin
===========================================================
======= Unified Trace Decoder Information/Statistics ======
===========================================================
----------------- Decoder Input Information ---------------
===========================================================
Num of Unique Streams .. 1
Total UTF To Process ... 1
Total UTM To Process ... 89177
UTM Process Filter ..... btman
MRST Filter Rules ...... 1
===========================================================
----------------- Decoder Output Information --------------
===========================================================
First UTM TimeStamp ............... 2024/07/24 02:51:45.623542304
Last UTM TimeStamp ................ 2024/07/24 04:26:48.710794233
UTM [Skipped / Rendered / Total] .. 89047 / 130 / 89177
UTM [ENCODED] ..................... 130
UTM [PLAIN TEXT] .................. 0
UTM [DYN LIB] ..................... 0
UTM [MODULE ID] ................... 0
UTM [TDL TAN] ..................... 0
UTM [APP CONTEXT] ................. 0
UTM [MARKER] ...................... 0
UTM [PCAP] ........................ 0
UTM [LUID NOT FOUND] .............. 0
UTM Level [EMERGENCY / ALERT / CRITICAL / ERROR] .. 0 / 0 / 0 / 0
UTM Level [WARNING / NOTICE / INFO / DEBUG] ....... 0 / 130 / 0 / 0
UTM Level [VERBOSE / NOISE / INVALID] ............. 0 / 0 / 0
===========================================================
將日誌輸出傳送到檔案
您可以使用to-file關鍵字使用show logging命令的輸出建立一個檔案。此示例說明如何將進程btman的跟蹤日誌傳送到bootflash檔案系統中名為btman_log.txt的檔案:
Router#show logging process btman to-file bootflash:btman_log.txt
Logging display requested on 2024/07/25 03:49:41 (UTC) for Hostname: [Router], Model: [ASR1006-X ], Version: [17.09.05a], SN: [FXS221200GH], MD_SN: [FXS2221Q0EL]
Displaying logs from the last 0 days, 0 hours, 10 minutes, 0 seconds
executing cmd on chassis local ...
Files being merged in the background, please check [/bootflash/btman_log.txt] output file
Unified Decoder Library Init .. DONE
unified trace decoder estimates: [1] number of files, [139913] number of messages
that may be processed. Use CTRL+SHIFT+6 to break.
Found 1 UTF Streams
2024-07-25 03:49:41.694987 - unified trace decoder estimate: processed 5%
2024-07-25 03:49:41.701433 - unified trace decoder estimate: processed 10%
2024-07-25 03:49:41.707803 - unified trace decoder estimate: processed 15%
2024-07-25 03:49:41.714185 - unified trace decoder estimate: processed 20%
2024-07-25 03:49:41.720592 - unified trace decoder estimate: processed 25%
2024-07-25 03:49:41.726951 - unified trace decoder estimate: processed 30%
2024-07-25 03:49:41.733306 - unified trace decoder estimate: processed 35%
2024-07-25 03:49:41.739734 - unified trace decoder estimate: processed 40%
2024-07-25 03:49:41.746114 - unified trace decoder estimate: processed 45%
2024-07-25 03:49:41.752462 - unified trace decoder estimate: processed 50%
2024-07-25 03:49:41.758864 - unified trace decoder estimate: processed 55%
2024-07-25 03:49:41.765225 - unified trace decoder estimate: processed 60%
2024-07-25 03:49:41.771582 - unified trace decoder estimate: processed 65%
2024-07-25 03:49:41.777968 - unified trace decoder estimate: processed 70%
2024-07-25 03:49:41.784330 - unified trace decoder estimate: processed 75%
2024-07-25 03:49:41.790693 - unified trace decoder estimate: processed 80%
2024-07-25 03:49:41.797099 - unified trace decoder estimate: processed 85%
2024-07-25 03:49:41.803462 - unified trace decoder estimate: processed 90%
2024-07-25 03:49:41.811411 - unified trace decoder estimate: processed 95%
2024-07-25 03:49:41.822322 - unified trace decoder estimate: processed 100%
2024-07-25 03:49:41.822335 - unified trace decoder : processing complete Result:[Success]
您可以使用dir bootflash指令驗證檔案是否已建立,然後按以下方式篩選檔案的名稱:
Router#dir bootflash: | include btman_log.txt
17 -rw- 26939 Jul 25 2024 03:49:41 +00:00 btman_log.txt