记录日常工作关于系统运维,虚拟化云计算,数据库,网络安全等各方面问题。

Question: How to turn on scsi extended debug messages? What are the field/flag definitions of scsi_logging_level?

Additional scsi logging messages can be enabled by writing to /proc/sys/dev/scsi/logging_level either via use of the echo or preferably the sysctl command. The kernel parameter consists of ten packed fields, each 3 bits in length. Each field can have a value of 0 to 7. The higher the field’s value, the more verbose the logging of messages associated with that field type.

NOTE: Turning on high levels of extended logging and/or multiple types of extended logging can slow down system performance, especially during boot and shutdown. Unless needed, avoid turning on scsi logging during boot up.

Run Time

1. Enable :

# sysctl -q -w dev.scsi.logging_level=[N]

or

# echo [N] > /proc/sys/dev/scsi/logging_level

Where N specifies which fields to enable and at what level of verbosity.

2. Disable:

# sysctl -q -w dev.scsi.logging_level=0

or

# echo 0 > /proc/sys/dev/scsi/logging_level

Boot Time

Enable (CentOS/RHEL 5)

1. Modify /etc/modprobe.conf with “options scsi_mod scsi_logging_level=N“.

2. Rebuild the initrd image file to pick up the new /etc/modprobe.conf file.

3. Edit the boot line in /boot/grub/grub.conf, remove ‘quiet‘ if present, add either ‘debug‘ or ‘loglevel=10‘ (they both do the same thing). Also add ‘log_buf_len=8M‘ to increase the kernel’s log fifo size since the additional logging will be creating a lot more messages.

4. Reboot and capture the messages output.

# shutdown -r now

Enable (CentOS/RHEL 6)

1. Edit the boot line in /boot/grub/grub.conf and add “scsi_logging_level=N“.

2. Edit the boot line and remove ‘quiet‘ if present, add either ‘debug‘ or ‘loglevel=10‘ (they both do the same thing). Also add ‘log_buf_len=8M‘ to increase the kernel’s log fifo size since the additional logging will be creating a lot more messages.

3. Reboot and capture the messages output:

# shutdown -r now

Enable (CentOS/RHEL 7 & 8)

1. Edit the “GRUB_CMDLINE_LINUX” line in /etc/default/grub and add “scsi_logging_level=N“.

2. Edit the “GRUB_CMDLINE_LINUX” line and remove ‘quiet‘ if present, add either ‘debug‘ or ‘loglevel=10‘(they both do the same thing). Also add ‘log_buf_len=8M‘ to increase the kernel’s log fifo size since the additional logging will be creating a lot more messages.

3. Changes to /etc/default/grub requires rebuilding of grub.cfg file.

# grub2-mkconfig -o /boot/grub2/grub.cfg

4. Reboot and capture the messages output.

# shutdown -r now

What the above flags do is to up the scsi extended logging level to include lots of info upon errors and timeouts and during scan processing plus upon any io completing off the high level queue. To manually create a mask value, please refer scsi_logging.h and choose which fields you would like to enable.

/*
* This defines the scsi logging feature. It is a means by which the user
* can select how much information they get about various goings on, and it
* can be really useful for fault tracing. The logging word is divided into
* 8 nibbles, each of which describes a loglevel. The division of things is
* somewhat arbitrary, and the division of the word could be changed if it
* were really needed for any reason. The numbers below are the only place
* where these are specified. For a first go-around, 3 bits is more than
* enough, since this gives 8 levels of logging (really 7, since 0 is always
* off).
*/
#define SCSI_LOG_ERROR_SHIFT 0
#define SCSI_LOG_TIMEOUT_SHIFT 3
#define SCSI_LOG_SCAN_SHIFT 6
#define SCSI_LOG_MLQUEUE_SHIFT 9
#define SCSI_LOG_MLCOMPLETE_SHIFT 12
#define SCSI_LOG_LLQUEUE_SHIFT 15
#define SCSI_LOG_LLCOMPLETE_SHIFT 18
#define SCSI_LOG_HLQUEUE_SHIFT 21
#define SCSI_LOG_HLCOMPLETE_SHIFT 24
#define SCSI_LOG_IOCTL_SHIFT 27
#define SCSI_LOG_ERROR_BITS 3 /* additional logging associated with errors and recovery */
#define SCSI_LOG_TIMEOUT_BITS 3 /* additional logging associated with command timeouts */
#define SCSI_LOG_SCAN_BITS 3 /* additional logging associated with device scans and discovery */
#define SCSI_LOG_MLQUEUE_BITS 3 /* additional logging associated with mid-level command queueing */
#define SCSI_LOG_MLCOMPLETE_BITS 3 /* additional logging associated with mid-level command completions */
#define SCSI_LOG_LLQUEUE_BITS 3 /* additional logging associated with low-level command queueing */
#define SCSI_LOG_LLCOMPLETE_BITS 3 /* additional logging associated with low-level command completions */
#define SCSI_LOG_HLQUEUE_BITS 3 /* additional logging associated with hi-level command queueing */
#define SCSI_LOG_HLCOMPLETE_BITS 3 /* additional logging associated with hi-level command completions */
#define SCSI_LOG_IOCTL_BITS 3 /* additional logging associated with ioctl (typ: non-data commands) */
extern unsigned int scsi_logging_level;

To turn on maximum logging associated with ioctls and errors for example, an octal value of 7000000007 (0x38000007) would be set via ‘sysctl -q -w dev.scsi.logging_level=0x38000007‘. Conversely, if ‘sysctl -q dev.scsi.logging_level’ was used to query the current set value and was returned 402653425 (0x180000F1 or octal 3000000361), then currently the field masks have ioctl=3, scan=3, timeout=6, and error=1 values set.



转载请标明出处【How to enable additional scsi logging in CentOS/RHEL】。

《www.micoder.cc》 虚拟化云计算,系统运维,安全技术服务.

网站已经关闭评论