Skip to Content
《Asterisk:权威指南》第 5 版
book

《Asterisk:权威指南》第 5 版

by Jim Van Meggelen, Russell Bryant, Leif Madsen
May 2025
Intermediate to advanced
414 pages
5h 2m
Chinese
O'Reilly Media, Inc.
Content preview from 《Asterisk:权威指南》第 5 版

第 21 章 系统监控和日志 系统监控和日志记录

本作品已使用人工智能进行翻译。欢迎您提供反馈和意见:translation-feedback@oreilly.com

混沌是所有复合事物的固有特性。努力奋斗吧

佛陀

Asterisk 自带多个子系统,可以让你获得系统运行的详细信息。 无论是用于故障诊断,还是用于计费或人事跟踪,Asterisk 的各种监控模块都可以帮助你掌握系统的内部运行情况。

logger.conf

在对 中的 Asterisk 系统进行故障诊断时,您会发现参考报告问题发生时系统中正在发生的情况的某种历史记录非常有用。存储这些信息的参数定义在/etc/asterisk/logger.conf 中。

在理想情况下,您可能希望系统能够存储它所做的每一件事的记录。然而,这样做是有代价的。在繁忙的系统中,如果启用了完整的调试日志,就会产生大量数据。虽然现在的存储成本远比 Asterisk 年轻时要低,但仍有必要在细节和存储需求之间取得平衡。

/etc/asterisk/logger.conf文件允许你定义各种不同级别的日志记录,如果需要的话,还可以将日志记录到多个文件中。这种灵活性非常出色,但也可能造成混乱

logger.conf文件中的条目格式如下:

filename => type[,type[,type[,...]]]

我们已经使用过logger.conf文件,因此其中已经包含了类似以下内容的条目:

[general]
exec_after_rotate=gzip -9 ${filename}.2;

[logfiles]
;debug => debug
;console => notice,warning,error,verbose
console => notice,warning,error,debug
messages => notice,warning,error
full => notice,warning,error,debug,verbose,dtmf,fax
;full-json => [json]debug,verbose,notice,warning,error,dtmf,fax
;syslog keyword : This special keyword logs to syslog facility
;syslog.local0 => notice,warning,error

如果对该文件进行任何更改,则需要重新加载 日志记录器,方法是在 shell 中发出以下命令:

$ sudo touch full messages
$ chown asterisk:asterisk /var/log/asterisk/*
$ asterisk -rx 'logger reload'

或从 Asterisk CLI 获取:

*CLI> logger reload

您可以指定任何文件名,但事实上,特殊文件名控制台将把输出打印到 Asterisk CLI,而不是硬盘上的任何文件。所有其他文件名都将存储在文件系统的 ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

What Successful Brick-and-Mortar Retailers Get Right

What Successful Brick-and-Mortar Retailers Get Right

Rob Angell
What Successful Project Managers Do

What Successful Project Managers Do

W. Scott Cameron, Jeffrey S. Russell, Edward J. Hoffman, Alexander Laufer
Three Essentials for Agentic AI Security

Three Essentials for Agentic AI Security

Paolo Dal Cin, Daniel Kendzior, Yusof Seedat, Renato Marinho

Publisher Resources

ISBN: 9798341659568