__DATE__和__TIME__使用注意事项


1: 时间没有更新:需要先clean,再进行编译

2:时间不是当前带时区的系统时间。是没有加时区的时间。


Read More

性能测试方法调优工具


Linux性能调优之sar详解

iostat / sar 命令详解


Read More

时间类型和时间函数


Unix时间戳(Unix timestamp),或称Unix时间(Unix time)、POSIX时间(POSIX time),是一种时间表示方式,定义为从格林威治时间1970年01月01日00时00分00秒起至现在的总秒数。Unix时间戳不仅被使用在Unix 系统、类Unix系统中,也在许多其他操作系统中被广告采用。

目前相当一部分操作系统使用32位二进制数字表示时间。此类系统的Unix时间戳最多可以使用到格林威治时间2038年01月19日03时14分07秒(二进制:01111111 11111111 11111111 11111111)。其后一秒,二进制数字会变为10000000 00000000 00000000 00000000,发生溢出错误,造成系统将时间误解为1901年12月13日20时45分52秒。这很可能会引起软件故障,甚至是系统瘫痪。

 

struct tm
{
    int tm_sec;  /*秒,正常范围0-59, 但允许至61*/
    int tm_min;  /*分钟,0-59*/
    int tm_hour; /*小时, 0-23*/
    int tm_mday; /*日,即一个月中的第几天,1-31*/
    int tm_mon;  /*月, 从一月算起,0-11*/  1+p->tm_mon;
    int tm_year;  /*年, 从1900至今已经多少年*/  1900+ p->tm_year;
    int tm_wday; /*星期,一周中的第几天, 从星期日算起,0-6*/
    int tm_yday; /*从今年1月1日到目前的天数,范围0-365*/
    int tm_isdst; /*日光节约时间的旗标*/
};
 
 

 

windows GetTickCount GetTickCount是一种函数。GetTickCount返回(retrieve)从操作系统启动所经过(elapsed)的毫秒数,它的返回值是DWORD。
     
     

 


Read More

SAS OOB的误解


OOB(Out of Band) Signaling
For both SAS and SATA, the hardware initialization process begins with OOB signaling. Pronounced either as letters or as a funny-sounding syllable, OOB can be misleading because the term might be understood to mean that a dedicated signal is used rather than the normal data path. However, the SAS OOB signals do travel within the normal data path. The reason they are called OOB is because the signaling takes place before the receiver has been prepared to recognize dwords and so it is not part of the normal transmission process. Let's consider what is involved in the process of OOB communication.

 

翻译:OOB(带外)信令

对于SAS和SATA,硬件初始化过程从OOB信号开始。OOB发音为字母或听起来很有趣的音节,可能会产生误导,因为这个词可能被理解为使用专用信号而不是正常的数据路径。然而,SAS OOB信号确实在正常数据路径内传播。它们被称为OOB的原因是,信令发生在接收器准备识别数据字之前,因此它不是正常传输过程的一部分。让我们考虑一下OOB通信过程中涉及到什么。

 

解释:

SAS这个OOB与BMC的带外管理,实际是不一样的。它使用相同的物理路径。BMC的OOB使用独立的路径。


Read More

ChatGPT 4.0 编写脚本将 十六进制文本存储为二进制文件


在Python中,你可以使用以下脚本将十六进制文本存储为二进制文件:

```python
def hex_to_binary(hex_text, output_file):
    try:
        # 将十六进制文本转换为字节对象
        binary_data = bytes.fromhex(hex_text)

        # 将字节对象写入到二进制文件中
        with open(output_file, "wb") as file:
            file.write(binary_data)

        print("十六进制文本已成功转换为二进制文件。")

    except Exception as e:
        print("转换过程中出现错误:", str(e))


# 需要转换的十六进制文本
hex_text = "48656c6c6f2c20576f726c64"

# 输出的二进制文件路径和文件名
output_file = "output.bin"

hex_to_binary(hex_text, output_file)
```

你只需要修改`hex_text`和`output_file`变量的值即可。`hex_text`变量存储要转换的十六进制文本,`output_file`变量存储转换后的二进制文件的路径和文件名。运行脚本后,十六进制文本将被转换并保存为指定的二进制文件。

 

 

 

你可以使用以下Shell脚本来将十六进制文本存储为二进制文件:

```shell
#!/bin/bash

hex_text="48656c6c6f2c20576f726c64"     # 十六进制文本
output_file="output.bin"               # 输出的二进制文件路径和文件名

echo -n "$hex_text" | xxd -r -p > "$output_file"
```

脚本中的`hex_text`变量存储要转换的十六进制文本,`output_file`变量存储转换后的二进制文件的路径和文件名。

脚本使用`xxd`命令来处理转换过程。`echo -n`用于将十六进制文本输出到标准输出,后面通过管道将输出传递给`xxd`命令。`-r`选项表示将十六进制转换为二进制,`-p`选项表示输入的是纯粹的十六进制数据。

执行脚本后,十六进制文本将被转换为二进制并保存为指定的文件。


Read More

如何使用hdparm命令让硬盘进入休眠模式并查询验证。


使用hdparm命令让硬盘进入休眠模式需要使用`-y`选项。具体步骤如下:

1. 打开终端,输入以下命令,获取硬盘的设备名称:

 

sudo fdisk -l

 

找到需要使其进入休眠的硬盘设备,假设其为/dev/sdX。

2. 输入以下命令,让硬盘进入休眠模式:

 

sudo hdparm -y /dev/sdX 

这个操作需要超级用户权限,即需要使用sudo命令执行。

3. 等待一段时间,检查硬盘是否已经进入了休眠模式。可以再次使用以下命令,检查硬盘状态:

 

sudo hdparm -C /dev/sdX

如果硬盘已经进入了休眠模式,则会显示以下信息:

```
/dev/sdX:
 drive state is:  standby
```

注意:进入休眠模式后,需要定期唤醒硬盘以防止硬盘长时间处于不良状态。可以通过定期发起访问硬盘的请求或使用hdparm命令来唤醒硬盘。

 

 

 

 

 

在Linux系统中,可以使用以下命令判断硬盘是否进入了休眠模式:

```
sudo hdparm -C /dev/sdX
```

其中,`/dev/sdX`表示要检查的硬盘设备名称。

如果该硬盘设备已经进入了休眠模式,则会显示以下信息:

```
/dev/sdX:
 drive state is:  standby
```

如果硬盘设备没有进入休眠模式,则会显示以下信息:

```
/dev/sdX:
 drive state is:  active/idle
```

另外,也可以通过查看日志,来判断硬盘设备是否进入了休眠模式。例如,使用以下命令查看系统日志:

```
sudo dmesg | grep sdX
```

其中,`sdX`表示要检查的硬盘设备名称。如果该硬盘设备已经进入了休眠模式,则日志中会显示类似以下内容:

```
[sdX] APM_LEVEL = Y, ICC_TIMING = X
```

如果硬盘设备没有进入休眠模式,则日志中不会出现这个信息。


Read More


RJ45网口两个LED灯的指示意义以及控制原理


一般RJ45网口会有两个LED灯,至少从外观上看是两个。一个是link灯,一个是ACT灯。

参考下图所示,缺口朝上,一般右边绿灯常亮,表示link上,左边黄色、橘色、或者绿色灯闪烁,表示有数据传输。

有些act灯实际可能有多个是个多色灯,比如黄色、绿色。当100M时闪绿灯,当千兆时闪黄灯,以做区分。

 

这些灯是有PHY进行控制的。PHY的硬件接口文档中会有说明,以及相关的寄存器设置。

在uboot中可以使用mii来修改寄存器,改变亮灯状态。

在linux系统下,可以使用内核、驱动或者mii-tools修改控制灯的状态。

这些如何操作需要参考具体的硬件手册,因硬件手册厂家一般是不公开的,但从网上也能够找到零星的资料。

以下能够查找到的网上公开资料,可供参考

RTL8211F在uboot下使用mii工具配置网口灯详解

RJ45 LED灯


Read More

ipmitool命令与raw命令与ipmi spec对照表3-NETFN_APP


ipmitool命令与raw命令与ipmi spec对照表3-NETFN_APP

raw命令索引 对应IPMI Spec的章节 raw命令格式 字符串命令
ipmitool raw 0x06 0x01 Get Device ID(20.1)    
ipmitool raw 0x06 0x02 Cold Reset(20.2) ipmitool raw 0x06 0x02 ipmitool mc reset cold
ipmitool raw 0x06 0x03 Warm reset ipmitool raw 0x06 0x03 ipmitool mc reset warm
ipmitool raw 0x06 0x04 Get Self Test Results(20.4) ipmitool raw 0x06 0x04 ipmitool mc selftest
ipmitool raw 0x06 0x05 Manufacturing Test On(20.5) ipmitool raw 0x06 0x05  
ipmitool raw 0x06 0x06 Set ACPI Power State(20.6) ipmitool raw 0x06 0x06 Data[1:2]  
ipmitool raw 0x06 0x07 Get ACPI Power State(20.7) ipmitool raw 0x06 0x07  
ipmitool raw 0x06 0x08 Get Device GUID(20.8) ipmitool raw 0x06 0x08  
ipmitool raw 0x06 0x09 Get NetFn Support(21.2) ipmitool raw 0x06 0x09 Data[1]  
ipmitool raw 0x06 0x0A Get Command Support(21.3) ipmitool raw 0x06 0x0a Data[1:3]  
ipmitool raw 0x06 0x0B Get Command Sub-function Support(21.4) ipmitool raw 0x06 0x0b Data[1:4]  
ipmitool raw 0x06 0x0C Get Configurable Commands(21.5) ipmitool raw 0x06 0x0c Data[1:3]  
ipmitool raw 0x06 0x0D Get Configurable Command Sub-functions(21.6) ipmitool raw 0x06 0x0d Data[1:4]  
ipmitool raw 0x06 0x61 Get Command Enables(21.8)    
ipmitool raw 0x06 0x64 Get OEM NetFn IANA Support(21.11)    
ipmitool raw 0x06 0x22 Reset Watchdog Timer(27.5) ipmitool raw 0x06 0x22 ipmitool mc watchdog reset
ipmitool raw 0x06 0x24 Set Watchdog Timer(27.6) ipmitool raw 0x06 0x24 Data[1:6] ipmitool mc watchdog off
ipmitool raw 0x06 0x25 Get Watchdog Timer(27.7) ipmitool raw 0x06 0x25 ipmitool mc watchdog get
ipmitool raw 0x06 0x2E Set BMC Global Enables(22.1) ipmitool raw 0x06 0x2e Data[1] ipmitool mc setenables
ipmitool raw 0x06 0x2F Get BMC Global Enables(22.2) ipmitool raw 0x06 0x2f ipmitool mc getenables
ipmitool raw 0x06 0x30 Clear Message Flags(22.3) ipmitool raw 0x06 0x30 Data[1]  
ipmitool raw 0x06 0x31 Get Message Flags(22.4) ipmitool raw 0x06 0x31  
ipmitool raw 0x06 0x32 Enable Message Channel Receive(22.5) ipmitool raw 0x06 0x32 Data[1:2]  
ipmitool raw 0x06 0x33 Get Message(22.6)    
ipmitool raw 0x06 0x34 Send Message(22.7)    
ipmitool raw 0x06 0x35 Read Event Message Buffer(22.8) ipmitool raw 0x06 0x35  
ipmitool raw 0x06 0x36 Get BT Interface Capabilities(22.1)    
ipmitool raw 0x06 0x37 Get System GUID(22.14)    
ipmitool raw 0x06 0x58 Set System Info Parameters(22.14a)    
ipmitool raw 0x06 0x59 Get System Info Parameters(22.14b)    
ipmitool raw 0x06 0x38 Get Channel Authentication Capabilities(22.13)    
ipmitool raw 0x06 0x39 Get Session Challenge(22.15)    
ipmitool raw 0x06 0x3A Activate Session(22.17)    
ipmitool raw 0x06 0x3B Set Session Privilege Level(22.18)    
ipmitool raw 0x06 0x3C Close Session(22.19)    
ipmitool raw 0x06 0x3D Get Session Info(22.2)    
ipmitool raw 0x06 0x3F Get AuthCode(22.21)    
ipmitool raw 0x06 0x40 Set Channel Access(22.22)    
ipmitool raw 0x06 0x41 Get Channel Access(22.23)    
ipmitool raw 0x06 0x42 Get Channel Info Command(22.24)    
ipmitool raw 0x06 0x43 Set User Access Command(22.26)    
ipmitool raw 0x06 0x44 Get User Access Command(22.27)    
ipmitool raw 0x06 0x45 Set User Name(22.28)    
ipmitool raw 0x06 0x46 Get User Name Command(22.29)    
ipmitool raw 0x06 0x47 Set User Password Command(22.3)    
ipmitool raw 0x06 0x48 Activate Payload(24.1) ipmitool raw 0x06 0x48 Data[1:6]  
ipmitool raw 0x06 0x49 Deactivate Payload(24.2) ipmitool raw 0x06 0x49 Data[1:6]  
ipmitool raw 0x06 0x4A Get Payload Activation Status(24.4)    
ipmitool raw 0x06 0x4B Get Payload Instance Info(24.5)    
ipmitool raw 0x06 0x4C Set User Payload Access(24.6)    
ipmitool raw 0x06 0x4D Get User Payload Access(24.7)    
ipmitool raw 0x06 0x4E Get Channel Payload Support(24.8)    
ipmitool raw 0x06 0x4F Get Channel Payload Version(24.9)    
ipmitool raw 0x06 0x50 Get Channel OEM Payload Info(24.1)    
ipmitool raw 0x06 0x52 Master Write-Read(22.11)    
ipmitool raw 0x06 0x54 Get Channel Cipher Suites(22.15)    
ipmitool raw 0x06 0x55 Suspend/Resume Payload Encryption(24.3)    
ipmitool raw 0x06 0x56 Set Channel Security Keys(22.25)    
ipmitool raw 0x06 0x57 Get System Interface Capabilities(22.9) ipmitool raw 0x06 0x57 Data[1]  

Read More

LSI 3008的IT与IR模式的区别


本文综合baidu与bing返回结果。

https://www.supermicro.org.cn/support/faqs/faq.cfm?faq=16169

Question:
For LSI Host Bus Adapter (HBA) firmware, what is the difference between IT mode and IR mode?
对于LSI主机总线适配器(HBA)固件,IT模式与IR模式有何区别?

Answer:
The two firmware types are Initiator Target (IT) and Integrated RAID (IR). IR is the typical hardware RAID firmware that the internal cards or boards ship with.
The IT firmware, on the other hand, is the Initiator Target firmware which is designed to allow a SAS HBA to connect to up to 256 devices using SAS Expanders. The IT firmware is typically shipped on external cards. The IT firmware does not have any RAID capabilities and simply acts as an HBA.

这两种固件类型是启动器目标(IT)和集成RAID(IR)。
IR是内部卡或板附带的典型硬件RAID固件。
IT固件允许SAS HBA使用SAS扩展器连接到多达256个设备。IT固件通常在外部卡上提供。IT固件没有任何RAID功能,只是充当HBA。

 

LSI SAS3008是常用的RAID卡种类。此RIAD卡有两种固件:IT和IR。
当固件是3008IT时,只能直连硬盘而不能配置RAID。
当固件是3008IR时,可以配置RAID。

Basicly the IT firmware is only just a HBA and the boot up time is quick. The IR firmware is the raid software firmware so boot up is a bit longer than having the IT firmware only. You can cross flash with the LSI firmware in IT mode only or IT and IR mode which is default in LSI. If you are going with pure software raid then the IT firmware is best. 

更多解释:

LSI-RAID卡命名后缀的含义(it-ir-imr-mr)(华为)

broadcom官方MR、iMR、IR和IT软件功能比较矩阵


Read More

ipmitool命令与raw命令与ipmi spec对照表2-NETFN_SENSOR


ipmitool命令与raw命令与ipmi spec对照表2-NETFN_SENSOR

raw命令索引 对应IPMI Spec的章节 raw命令格式 字符串命令
ipmitool raw 0x04 0x00 Set Event Receiver(29.1) ipmitool raw 0x04 0x00 Data[1:2]  
ipmitool raw 0x04 0x01 Get Event Receiver(29.2) ipmitool raw 0x04 0x01  
ipmitool raw 0x04 0x02 Platform Event(29.3) ipmitool raw 0x04 0x02 Data[1:7] ipmitool event [event_dir]
ipmitool event 1
ipmitool event 2
ipmitool event 3
ipmitool raw 0x04 0x10 Get PEF Capabilities(30.1) ipmitool raw 0x04 0x10 ipmitool pef
ipmitool pef info
ipmitool raw 0x04 0x11 Arm PEF Postpone Timer(30.2) ipmitool raw 0x04 0x11 Data[1]  
ipmitool raw 0x04 0x12 Set PEF Configuration Parameters(30.3) ipmitool raw 0x04 0x12 Data[1:N]  
ipmitool raw 0x04 0x13 Get PEF Configuration Parameters(30.4) ipmitool raw 0x04 0x13 Data[1:3] ipmitool pef list
ipmitool raw 0x04 0x14 Set Last Processed Event ID(30.5) ipmitool raw 0x04 0x14 Data[1:3]  
ipmitool raw 0x04 0x15 Get Last Processed Event ID(30.6) ipmitool raw 0x04 0x15 ipmitool pef status
ipmitool raw 0x04 0x16 Alert Immediate(30.7) ipmitool raw 0x04 0x16 Data[1:3]  
ipmitool raw 0x04 0x17 PET Acknowledge(30.8)    
ipmitool raw 0x04 0x20 Get Device SDR Info(35.2)    
ipmitool raw 0x04 0x21 Get Device SDR(35.3)    
ipmitool raw 0x04 0x22 Reserve Device SDR Repository(35.4)    
ipmitool raw 0x04 0x23 Get Sensor Reading Factors(35.5)    
ipmitool raw 0x04 0x24 Set Sensor Hysteresis(35.6)    
ipmitool raw 0x04 0x25 Get Sensor Hysteresis(35.7)    
ipmitool raw 0x04 0x26 Set Sensor Threshold(35.8)    
ipmitool raw 0x04 0x27 Get Sensor Threshold(35.9)    
ipmitool raw 0x04 0x28 Set Sensor Event Enable(35.1)    
ipmitool raw 0x04 0x29 Get Sensor Event Enable(35.11)    
ipmitool raw 0x04 0x2A Re-arm Sensor Events(35.12)    
ipmitool raw 0x04 0x2B Get Sensor Event Status(35.13)    
ipmitool raw 0x04 0x2D Get Sensor Reading(35.14)    
ipmitool raw 0x04 0x2E Set Sensor Type(35.15)    
ipmitool raw 0x04 0x2F Get Sensor Type(35.16)    
ipmitool raw 0x04 0x30 Set Sensor Reading And Event Status(35.17)    

 

参考IPMI Spec中的部分Appendix G。

ipmi spec sensor


Read More

uboot下的mii命令简介


uboot下有一个mii命令。命令帮助信息如下:

mii - MII utility commands                                                      
                                                                                
Usage:                                                                          
mii device                     - list available devices                         
mii device            - set current device                             
mii info                 - display MII PHY info                           
mii read            - read  MII PHY  register             
mii write     - write MII PHY  register             
mii dump            - pretty-print   (0-5 only)           
Addr and/or reg may be ranges, e.g. 2-7. 

 

mii device示例,会输出MDC/MDIO总线设备

uboot>mii device                                                           
MII devices: 'FSL_MDIO0' 'FM_TGEC_MDIO'
Current device: 'FSL_MDIO0'

 

mii info打印输出,PHY后面跟的就是addr

uboot> mii info
PHY 0x00: OUI = 0x5043, Model = 0x1D, Rev = 0x01, 1000baseT, FDX
PHY 0x01: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x02: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x03: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x04: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x05: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x06: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX
PHY 0x07: OUI = 0x0000, Model = 0x00, Rev = 0x00,  10baseT, HDX

 

mii read          - read  MII PHY register            
mii write   - write MII PHY register  

上述两个命令,需要根据具体的芯片手册寄存器设置来进行配置。以下命令为示例

mii write 0 0 0x8000    向地址为0的phy芯片的0寄存器写入0x8000

mii  read 0 0     读取地址为0的phy芯片的寄存器0的值


Read More

ipmitool命令与raw命令与ipmi spec对照表1-NETFN_CHASSIS


ipmitool命令与raw命令与ipmi spec对照表1-NETFN_CHASSIS

raw命令索引 对应IPMI Spec的章节 raw命令格式 字符串命令
ipmitool raw 0x00 0x00 Get Chassis Capabilities(28.1) ipmitool raw 0x00 0x00  
ipmitool raw 0x00 0x01 Get Chassis Status(28.2) ipmitool raw 0x00 0x01 ipmitool raw 0x00 0x01
ipmitool chassis status
ipmitool power status
ipmitool chassis power status
ipmitool chassis poh
ipmitool raw 0x00 0x02 Chassis Control(28.3) ipmitool raw 0x00 0x02 0x00 ipmitool chassis power off
ipmitool power off
ipmitool raw 0x00 0x04 Chassis Identify(28.5) ipmitool raw 0x00 0x04 [Data[1:2]] ipmitool chassis identify
ipmitool raw 0x00 0x0A Set Front Panel Button Enables(28.6) ipmitool raw 0x00 0x0a Data[1]  
ipmitool raw 0x00 0x05 Set Chassis Capabilities(28.7) ipmitool raw 0x00 0x05 Data[1:6]  
ipmitool raw 0x00 0x06 Set Power Restore Policy(28.8) ipmitool raw 0x00 0x06 Data[1] ipmitool chassis policy
ipmitool raw 0x00 0x0B Set Power Cycle Interval(28.9) ipmitool raw 0x00 0x0b Data[1]  
ipmitool raw 0x00 0x07 Get System Restart Cause(28.11) ipmitool raw 0x00 0x07 ipmitool chassis restart_cause
ipmitool raw 0x00 0x08 Set System Boot Options(28.12) ipmitool raw 0x00 0x08 Data[1:6] ipmitool chassis bootdev
ipmitool chassis bootparam set bootflag
ipmitool raw 0x00 0x09 Get System Boot Options(28.13) ipmitool raw 0x00 0x09 Data[1:3] ipmitool chassis bootparam get 0x05
ipmitool raw 0x00 0x0F Get POH Counter(28.14) ipmitool raw 0x00 0x0F ipmitool chassis poh

 

参考IPMI Spec中的部分Appendix G。

ipmi chassis


Read More


© 2008-2022 CunYouLu存有录博客 村友录 存有录 鲁ICP备08005943号