dmesg和/var/log/kern.log之间的区别 [英] difference between dmesg and /var/log/kern.log

查看:1760
本文介绍了dmesg和/var/log/kern.log之间的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在修改kvm模块,并在内核代码中添加了printk语句.运行虚拟机后,printk向我提供了错误的地址以及有关来宾OS的其他信息.

I am modifying the kvm module and I have added printk statements in the kernel code.After running the virtual machine, printk gives me the faulting address and other information about the guest OS.

我需要根据此信息生成统计信息.当我使用dmesg时,我只能看到错误的地址 在内核空间中,即它们的地址大于0XC0000000.(当VMEXIT发生时,即我们从来宾模式切换到主机模式时,需要错误地址)

I need to generate the statistic from this info.When I use dmesg i can only see faulting address in the kernel space i.e their address are above 0XC0000000.(faulting address are needed when VMEXIT happens i.e we switch from guest to host mode)

当我在kern.log中看到相同的统计信息时,我还从用户空间(低于0XC0000000)获得错误的地址. 所以在我看来dmesg的容量有限,并且给出的信息是kern.log的子集.
我的kern.log文件太大,可以从kern.log中删除旧数据,因为文本处理命令(例如grep,join,awk)花费的时间太长,无法在该文件上运行.

When I see the same statistics in kern.log I also get faulting address from the user space(below 0XC0000000). So it seems to me like dmesg has limited capacity , and the info given is a subset from kern.log.
My kern.log file is too big is it ok to erase old data from kern.log because text processing commands like grep,join,awk are taking to too long to run on the file.

我的问题是:
dmesg和kern.log有什么区别?
如何减少作为cron作业的kern.log文件大小?(清除过去24小时内添加的所有数据)
有没有更好的方法可以从内核获取printf类功能?

My question are:
What is the difference between dmesg and kern.log?
How to reduce the kern.log file size as cron job?(erase all data added in past 24 hours)
Is there any better way to get printf kindof functionality from kernel?

推荐答案

/var/log/kern.log及其轮换的日志(/var/log/kern.log.1/var/log/kern.log.2 ....)包含由内核生成并由syslog处理的日志.

/var/log/kern.log and his rotated logs (/var/log/kern.log.1 /var/log/kern.log.2....) contains the logs produced by the kernel and handled by syslog.

dmesg 是:

dmesg用于检查或控制内核环形缓冲区.

dmesg is used to examine or control the kernel ring buffer.

实际上,它将显示自上次引导以来/var/log/kern.log的最后16392个八位字节.

In fact, it will display the last 16392 octets of /var/log/kern.log since last boot.

这篇关于dmesg和/var/log/kern.log之间的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆