【Note5】macvlan,spi,rsyslog,sol

news2024/10/6 6:43:17

文章目录

  • 1.BMC虚拟多网口:macvlan是kernel提供的一种网卡虚拟化技术,可将网卡(不一定是真实的物理网卡)虚拟出多个接口,这网卡称为master或父接口,这些虚拟接口和外面环境通信都是通过父接口
    • 1.1 bridge:ip netns add ns001 / ns002
    • 1.2 private:FB Openbmc(AST2520实物芯片)和OcpOpenBMC(qemu ast2500-evb)以及X86 Ubuntu上验证过, Kernel版本均5.0+
      • 编译Kernel:BMC/CPU OS的Linux Kernel Config里面加CONFIG_MACVLAN=m/y
      • 创建/启动网卡/获取DHCP地址:创建网卡以eth0为目标物理网口,虚拟网口的MAC地址自定义,mode可以选择private不能互通,bridge内部互通等
      • 配置路由表:由于5个网口都被分配在一个网段如10.75.159.0/24(掩码一样),导致Linux内部路由会以高优先级的网口如eth0来响应外部的arp/icmp/tcp等各种网络请求。为了达到5个虚拟网口能在同网段以5个独立网口的形式工作,呈现5个独立网口MAC地址,需要配置路由表
      • 远端服务器检查:ping 10.75.159.117/120/121/125/132
      • 案例:iproute2,设置路由重启后不丢失/etc/network/interfaces:up route add -host 10.1.1.2 dev eth1
    • 1.3 creat_macvlan.sh:macvlan文件夹里file文件夹里有.sh和.service,file文件夹同级有.bb文件
  • 2.spi:spi.sh
  • 3.rsyslog:rsyslogd一个进程 ,管理每个进程发来的log并往/var/log里写,syslog函数将log写给rsyslogd进程。
    • 1.1 log_rotate
    • 1.2 rsyslog.conf
    • 1.3 rsyslog.logrotate
    • 1.4 rsyslog_%.bbappend
  • 2.
  • logrotate-default
  • logrotate_%.bbappend
  • SOL


1.BMC虚拟多网口:macvlan是kernel提供的一种网卡虚拟化技术,可将网卡(不一定是真实的物理网卡)虚拟出多个接口,这网卡称为master或父接口,这些虚拟接口和外面环境通信都是通过父接口

在这里插入图片描述

1.1 bridge:ip netns add ns001 / ns002

macvlan模拟的mac不同,如下第一行和第二行创建两个以ens32为父接口的macvlan1和macvlan2虚拟网口。
在这里插入图片描述
如下将ns001/2绑定网卡macvlan1/2,进入ns001虚拟环境,将网卡up起来。
在这里插入图片描述
如下添加ip,不通原因是bridge模式和父接口(.138)是不通的。
在这里插入图片描述
如下在ns002虚拟环境,宿主机(76.1)指的windows这台机器,如下两个都是往外ping。
在这里插入图片描述

1.2 private:FB Openbmc(AST2520实物芯片)和OcpOpenBMC(qemu ast2500-evb)以及X86 Ubuntu上验证过, Kernel版本均5.0+

在这里插入图片描述

编译Kernel:BMC/CPU OS的Linux Kernel Config里面加CONFIG_MACVLAN=m/y

在这里插入图片描述
如下在编译的服务器上编译完后,如果找不到就删除build目录重新编译。
在这里插入图片描述
如下在烧录的机器上烧录镜像后,vi第一行.dep文件。
在这里插入图片描述
如下不用insmod kernel/drivers/net/maclan.ko。
在这里插入图片描述

创建/启动网卡/获取DHCP地址:创建网卡以eth0为目标物理网口,虚拟网口的MAC地址自定义,mode可以选择private不能互通,bridge内部互通等

假设生成5个虚拟网口eth0.1-eth0.5命令如下,ifconfig检查5个虚拟网口的IP地址和MAC地址(都不一样):

ip link add link eth0 dev eth0.1 address D6:D2:52:A8:28:28   type macvlan  mode private   
ip link add link eth0 dev eth0.2 address D6:D2:52:A8:28:29   type macvlan  mode private   
ip link add link eth0 dev eth0.3 address D6:D2:52:A8:28:2a   type macvlan  mode private   
ip link add link eth0 dev eth0.4 address D6:D2:52:A8:28:2b   type macvlan  mode private   
ip link add link eth0 dev eth0.5 address D6:D2:52:A8:28:2c   type macvlan  mode private   
ifconfig eth0.1 up
ifconfig eth0.2 up
ifconfig eth0.3 up
ifconfig eth0.4 up
ifconfig eth0.5 up
dhclient eth0.1
dhclient eth0.2
dhclient eth0.3
dhclient eth0.4
dhclient eth0.5

配置路由表:由于5个网口都被分配在一个网段如10.75.159.0/24(掩码一样),导致Linux内部路由会以高优先级的网口如eth0来响应外部的arp/icmp/tcp等各种网络请求。为了达到5个虚拟网口能在同网段以5个独立网口的形式工作,呈现5个独立网口MAC地址,需要配置路由表

获取Gateway网关地址:用route -n 命令获取路由表和Gateway(10.75.159.1)地址。
在这里插入图片描述
配置路由表:数量以实际虚拟网卡数量为准,需要替换网关IP和每个网口的IP。下面命令中10.75.159.1为网关地址,10.75.159.117等为虚拟网口的IP地址,10.75.159.0/24为网段和NETMASK

echo "210 eth0table" >> /etc/iproute2/rt_tables    # 210越大优先级越低
echo "220 eth1table" >> /etc/iproute2/rt_tables
echo "230 eth2table" >> /etc/iproute2/rt_tables
echo "240 eth3table" >> /etc/iproute2/rt_tables
echo "250 eth4table" >> /etc/iproute2/rt_tables

ip route add 10.75.159.0/24 dev eth0.1 src 10.75.159.117 table eth0table
ip route add 10.75.159.0/24 dev eth0.2 src 10.75.159.120  table eth1table
ip route add 10.75.159.0/24 dev eth0.3 src 10.75.159.121 table eth2table
ip route add 10.75.159.0/24 dev eth0.4 src 10.75.159.125  table eth3table
ip route add 10.75.159.0/24 dev eth0.5 src 10.75.159.132 table eth4table

ip route add default dev eth0.1 via 10.75.159.1 table eth0table
ip route add default dev eth0.2 via 10.75.159.1 table eth1table
ip route add default dev eth0.3 via 10.75.159.1 table eth2table
ip route add default dev eth0.4 via 10.75.159.1 table eth3table
ip route add default dev eth0.5 via 10.75.159.1 table eth4table

ip rule add from 10.75.159.117 table eth0table
ip rule add from 10.75.159.120 table eth1table
ip rule add from 10.75.159.121 table eth2table
ip rule add from 10.75.159.125 table eth3table
ip rule add from 10.75.159.132 table eth4table

远端服务器检查:ping 10.75.159.117/120/121/125/132

如下只有发起ping 117才能看到117这个ip,BMC侧IP的MAC地址与远端服务器获取的一致,符合预期。使用tcp方式测试:BMC端(服务端)iperf -s -p port,远端(客户端)iperf -c BMCIP -t 1000 -i 3 -p port。
在这里插入图片描述

案例:iproute2,设置路由重启后不丢失/etc/network/interfaces:up route add -host 10.1.1.2 dev eth1

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
如下default via可省略。
在这里插入图片描述
注意如下是规则rule,不是route。
在这里插入图片描述
如下没指定路由表就会到main表中。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
hping3 -I eth0 -a 10.75.159.37 -S 10.75.159.138 -p 8080 -i u100 发起攻击,iptables限制端口,限制连接数防止攻击。
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.3 creat_macvlan.sh:macvlan文件夹里file文件夹里有.sh和.service,file文件夹同级有.bb文件

#!/bin/sh
IP_ROUTEFILE_PATH="/etc/iproute2/rt_tables"
priority_arry=(210 220 230 240)
tablename_arry=(eth0table eth1table eth2table eth3table)

#dynamic routing configuration for macvlan
dynamic_routing()
{
    #Initialize basic network information
    index=0
    for i in $(ifconfig | grep -o ^[a-z0-9.]* | grep -v lo); do
        ipaddr_array[$index]=$(ifconfig "$i" | sed -n 2p | awk '{ print $2 }' | tr -d 'addr:')
        devname_array[$index]=$i
        gateway_array[$index]=$(route | grep "${devname_array[$index]}" | grep 'default' | awk '{print $2}')
        iprange_array[$index]="${ipaddr_array[$index]%[^0-9]*}.0/24"
        index=$((index + 1))
    done

    #Create the table and initialize it
    index=0
    for i in "${tablename_arry[@]}"; do
        tablename=$(cat $IP_ROUTEFILE_PATH | grep "${devname_array[$index]}" | sed -n 1p | awk -F ' ' '{print$2}')
        if [ "$tablename" != "${tablename_arry[$index]}" ]; then
            echo "${priority_arry[$index]} ${tablename_arry[$index]}" >> $IP_ROUTEFILE_PATH
        fi
        ip route flush table "${tablename_arry[$index]}"
        index=$((index + 1))
    done

    #Configure dynamic routing for the table
    index=0
    for i in "${tablename_arry[@]}"; do
        ip route add "${iprange_array[$index]}" dev "${devname_array[$index]}" src "${ipaddr_array[$index]}" table "${tablename_arry[$index]}"
        ip route add default dev "${devname_array[$index]}" via "${gateway_array[$index]}" table "${tablename_arry[$index]}"
        ip rule add from "${ipaddr_array[$index]}" table "${tablename_arry[$index]}"
        index=$((index + 1))
    done
}

###Creat MAC Vlan
ip link add link eth0 dev eth1 type macvlan
ip link add link eth0 dev eth2 type macvlan
ip link add link eth0 dev eth3 type macvlan
ip link set eth1 up
ip link set eth2 up
ip link set eth3 up

sleep 2
#dhclient eth0.01
#dhclient eth0.02
#dhclient eth0.03
dynamic_routing
# macvlan.service
[Unit]
Description=Mac Vlan Server
After=-xyz.openbmc_project.Network.service

[Service]
ExecStart=/usr/bin/creat_macvlan.sh
Type=oneshot

[Install]
WantedBy=multi-user.target
# macvlan.bb
SUMMARY = "Phosphor BMC Macvlan"
LICENSE = "Apache-2.0"
LIC_FILES_CHKSUM = "file://${COREBASE}/meta/files/common-licenses/Apache-2.0;md5=89aea4e17d99a7cacdbeed46a0096b10"

inherit pkgconfig
inherit obmc-phosphor-systemd

SYSTEMD_SERVICE:${PN} += "macvlan.service"

DEPENDS += "systemd"

SRC_URI += "file://macvlan.service \
            file://creat_macvlan.sh \
            "

do_install() {
    install -d ${D}${bindir}

    install -m 0755 ${WORKDIR}/creat_macvlan.sh ${D}${bindir}/creat_macvlan.sh
}

S = "${WORKDIR}"

2.spi:spi.sh

#!/bin/bash
#shellcheck disable=SC1091
. /usr/local/bin/openbmc-utils.sh
layout_file="/etc/platform/__MACHINE__/fpgarom.layout"
PIDFILE="/var/run/spi_util.pid"

# ctrl+c或升级结束后或异常退出 退出都运行
trap "pre_exit" EXIT
pre_exit()
{
    #echo "Ready to exit $program"
    if [ "${spi}" = "BIOS" ] && [ -n "$come_power_ret" ] && [ "$come_power_ret" -ne 0 ];then
        if [ -n "${boot_source}" ];then
            echo "${boot_source}" > "${LCCPLD_SYSFS_DIR}"/bios_select  #控制
        fi
        #lock
        echo 0x0 > "${LCCPLD_SYSFS_DIR}"/lc_bios_spi_select
    elif [ "${spi}" = "FPGA" ] && [ -n "$fpga_power_ret" ] && [ "$fpga_power_ret" -ne 0 ];then
        #lock
        echo 0x0 > "${LCCPLD_SYSFS_DIR}"/lc_fpga_spi_select
    fi
    
    if [ -f "$out_file" ] || [ -L "$out_file" ];then
        rm -f "$out_file"
    fi
    if [ -f "${PIDFILE}" ];then
        rm ${PIDFILE}
    fi
}

# check duplicate process,update one fpga/bios at the same time. 多进程对同一文件的读写冲突
check_duplicate_process()
{
    exec 8<>$PIDFILE  #exec后面的数字是[3, 9] 之间的整数
    flock -n 8 || (echo "Another process is running" && exit 1)  #-n是非阻塞的,一旦发现PIDFILE文件被占用,就打印后面echo,然后退出脚本;
    ret=$?
    if [ $ret -eq 1 ]; then
        exit 1
    fi
    pid=$$
    echo $pid >&8
}

#111111111111111111111111111111111111111111111111111111如下都是通过flashrom -p spi设备地址得到信息
check_flash_info()
{
    spi_no=$1
    flashrom -p linux_spi:dev=/dev/spidev"${spi_no}".0
}

get_flash_first_type()
{
    spi_no=$1
    ori_str=$(check_flash_info "${spi_no}")
    type=$(echo ${ori_str} | cut -d '"' -f 2)
    if [ "$type" ];then
        echo "$type"
        return 0
    else
        echo "Get flash type error: [$ori_str]"
        exit 1
    fi
}

get_flash_size()
{
    spi_no=$1
    ori_str=$(check_flash_info "${spi_no}")
    flash_sz=$(echo ${ori_str} | cut -d '(' -f 4 | cut -d ' ' -f 1)
    echo "$flash_sz" | grep -E -q '^[0-9]+$'
    num_ret=$?
    if [ $num_ret -eq 0 ];then
        echo "$flash_sz"
        return 0
    else
        echo "Get flash size error: [$ori_str]"
        return 1
    fi
}

#111111111111111111111111111111111111111111111111111111111111111111如下最重要resize_file()
check_layout_image_exist()
{
    layout_file=$1
    image=$2  #primary/golden
    cut_ret=$(cut -d ' ' -f 2 "$1" | grep "$2")   # cut后面加文件
    if [ "$cut_ret" != "$image" ];then
        echo "cant not find $image in $layout_file "
        return 1
    else
        return 0
    fi
}

get_layout_image_startaddr()
{
    layout_file=$1
    image=$2
    while read -r line
    do
        cut_ret=$(echo "$line" | cut -d ' ' -f 2)
        if [ "$cut_ret" = "$image" ];then
            startaddr=$(echo "$line" | cut -d ':' -f 1) #逐行遍历
            startaddr=$((16#$startaddr)) #转16进制
            echo "$startaddr"
            return 0
        fi
    done < "$layout_file"
    return 1
}

# $1: input file size    $2: flash size    $3: output file path
pad_ff()
{
    out_file=$3
    pad_size=$(($2 - $1))
    dd if=/dev/zero bs=$pad_size count=1 | tr "\000" "\377" >> "$out_file"
}

# $1: image_size    $2: storage_sz     $3: image_startaddr    $4: out_file
pad_touchfile()
{
    image_size=$1  #bin大小
    storage_sz=$2   #flash大小
    image_startaddr=$3 # 真实起始地址
    out_file=$4  #备份的.bin(最后要烧录进flash的),下面操作都是对out_file操作
    dd if=/dev/zero bs="$image_startaddr" count=1 | tr "\000" "\377" >> "$out_file"  #头
    dd if="$in_file" bs="$image_size" count=1 >> "$out_file" # 中间
    declare -i left_size="$storage_sz"-"$image_startaddr"-"$image_size"
    dd if=/dev/zero bs="$left_size" count=1 | tr "\000" "\377" >> "$out_file"  #尾
}

resize_file()
{
    in_file=$1     # .bin
    out_file=$2    # /tmp/.bin
    spi_no=$3
    image_size=$4
    image_startaddr=$5
    in_file_sz=$(stat -c%s "$in_file")
    storage_sz=0

    if flash_sz=$(get_flash_size "$spi_no");then
        storage_sz=$((flash_sz * 1024))
    else
        echo "debug message: $flash_sz"
        exit 1
    fi
    if [ "$image_size" -eq 0 ] && [ "$image_startaddr" -eq 0 ];then  # 不用layout文件
        if [ "$in_file_sz" -ne $storage_sz ];then   #.bin < flash
            cp "$in_file" "$out_file"   # 拷贝.bin (不动bin原文件)
            pad_ff "$in_file_sz" $storage_sz "$out_file"   #尾追加,只能是bios,或mulit混合
        else
            ln -s "$(realpath "${in_file}")" "${out_file}"  
        fi
    else
        touch "$out_file"
        pad_touchfile "$image_size" $storage_sz "$image_startaddr" "$out_file"
    fi
}

#1111111111111111111111111111111111111111111111111111111111111如下最重要的是write_flash_to_file,erase和read不重要
read_flash_to_file()
{
    spi_no=$1
    tmp_file=$2
    type=$(get_flash_first_type "$spi_no")
    if ! flashrom -p linux_spi:dev=/dev/spidev"${spi_no}".0 -r "$tmp_file" -c "$type";then
        echo "debug cmd: [flashrom -p linux_spi:dev=/dev/spidev${spi_no}.0 -r $tmp_file -c $type]"
        exit 1
    fi
}

check_fpga_imagesize(){
    if flash_sz=$(get_flash_size "$spi_no");then  # flash_sz   k
        storage_sz=$((flash_sz * 1024))  # B 字节
    else
        echo "debug message: $flash_sz"
        exit 1
    fi
    image_startaddr=$(get_layout_image_startaddr "$layout_file" "$image")  # image_startaddr 字节
    declare -i max_image_size="$storage_sz"-"$image_startaddr"
    file_sz=$(stat -c%s "$file")
    if [ "$file_sz" -gt "$max_image_size" ];then
        echo "The maximum image file size is $max_image_size B."
        exit 1
    fi
}

check_bios_imagesize(){
    if flash_sz=$(get_flash_size "$spi_no");then
        max_image_size=$((flash_sz * 1024))
    else
        echo "debug message: $flash_sz"
        exit 1
    fi
    file_sz=$(stat -c%s "$file")
    if [ "$file_sz" -gt "$max_image_size" ];then
        echo "The maximum image file size is $max_image_size B."
        exit 1
    fi
}

write_flash_to_file()  # $spi_no    .bin    primary/golden
{
    spi_no=$1
    in_file=$2
    image=$3
    if [ $# -eq 3 ];then
        image_size=$(stat -c%s "$in_file")
        image_startaddr=$(get_layout_image_startaddr "$layout_file" "$image")
        mode="layout"
    else #不用layout文件
        image_size=0
        image_startaddr=0
        mode="normal"
    fi
    tmp_file=$(basename "${in_file}")
    out_file="/tmp/spi${spi_no}_${tmp_file}"
    resize_file "$in_file" "$out_file" "$spi_no" $image_size $image_startaddr
    type=$(get_flash_first_type "$spi_no")
    if [ $mode = "normal" ];then
        if ! flashrom -p linux_spi:dev=/dev/spidev"${spi_no}".0 -w "$out_file" -c "$type";then
            echo "debug cmd: [flashrom -p linux_spi:dev=/dev/spidev${spi_no}.0 -w $out_file -c $type]"
            rm -f "$out_file"
            exit 1
        fi
    elif [ $mode = "layout" ];then
        if ! flashrom -p linux_spi:dev=/dev/spidev"${spi_no}".0 --layout "$layout_file" --image "$image" -w "$out_file" -c "$type";then
            echo "debug cmd: [flashrom -p linux_spi:dev=/dev/spidev${spi_no}.0 --layout $layout_file --image $image -w $out_file -c $type]"
            rm -f "$out_file"
            exit 1
        fi
    fi
}

erase_flash()
{
    spi_no=$1
    type=$(get_flash_first_type "$spi_no")
    if ! flashrom -p linux_spi:dev=/dev/spidev"${spi_no}".0 -E -c "$type";then
        echo "debug cmd: [flashrom -p linux_spi:dev=/dev/spidev${spi_no}.0 -E -c $type]"
        exit 1
    fi
}

#111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111
get_boot_bios_sel_value()
{
    val=$(head -n 1 < "${LCCPLD_SYSFS_DIR}/cpu_boot_bios_sel")
    if [ "${val}" = "0x0" ];then  # 主:记录bios_select原来状态
        ret_value="0x1"  # 退出之前,bios_select切到原来状态master
    elif [ "${val}" = "0x1" ];then # 备
        ret_value="0x3"  # 退出之前, bios_select切到原来状态slaver
    fi
    echo ${ret_value}
}

do_action_BIOS()
{
    #check come power status
    come_power_ret=$(is_come_power_ok "${index}")
    if [ "$come_power_ret" -eq 0 ]; then
        echo "${lcdev} come Power Status: Bad"
        return 1
    fi
    #get present bios status
    boot_source=$(get_boot_bios_sel_value)
    if [ "${master_slave}" = "master" ];then
        echo "Start to update master bios image"
        bios_select_value="0x1"
    elif [ "${master_slave}" = "slave" ];then
        echo "Start to update slave bios image"
        bios_select_value="0x3"
    fi
    spi_no="1"
    #chip select
    do_spi_select "${index}" "bios"
    echo 0x0 > "${LCCPLD_SYSFS_DIR}"/bios_ctrl
    echo ${bios_select_value} > "${LCCPLD_SYSFS_DIR}"/bios_select
    case ${op} in
        "read" )
            read_flash_to_file $spi_no "$file"
            ;;
        "write")
            check_bios_imagesize
            write_flash_to_file $spi_no "$file"
            ;;
        "erase")
            erase_flash $spi_no
            ;;
    esac
}

do_action_FPGA()
{
    #check lc status
    fpga_power_ret=$(is_fpga_power_ok "${index}")
    if [ "$fpga_power_ret" -eq 0 ]; then
        echo "${lcdev} FPGA Power Status: Bad"
        return 1
    fi
    echo "Start to update fpga image"
    spi_no="1"
    #unlock
    do_spi_select "${index}" "fpga"
    echo 0x0 > "${LCCPLD_SYSFS_DIR}"/bios_ctrl
    case ${op} in
        "read" )
            read_flash_to_file $spi_no "$file"
            ;;
        "write")
            check_fpga_imagesize
            write_flash_to_file $spi_no "$file" "$image"
            ;;
        "erase")
            erase_flash $spi_no
            ;;
    esac
}

usage(){
    program=$(basename "$0")
    echo "Usage:"
    echo "$program <op> <spi device> [file] <master|slave>  <lc device>"
    echo "  <op>          : read, write, erase"
    echo "  <spi device>  : BIOS, FPGA"
    echo "  <image>       : master, slave"
    echo "  <lc device>   : lc1,lc2 ... lc7,lc8"
    echo "Note:"
    echo "  master:FPGA primary, BIOS0"
    echo "  slave :FPGA golden , BIOS1"
    echo "  <lc device>:select which linecard to operate"
    echo "Examples:"
    echo "  $program write FPGA fpga.bin master lc1"
    echo "  $program read BIOS bios.bin master lc1"
    echo "  $program erase BIOS master lc1"
    echo ""
}

check_parameter(){
    if [ $# -ne 4 ] && [ $# -ne 5 ];then
        usage
        exit 0
    fi
    if [ $# -eq 5 ];then
        op=$1
        spi=$2
        file=$3
        master_slave=$4
        lcdev=$5
        index=${5: -1}
        if [ "${op}" != "read" ] && [ "${op}" != "write" ];then
            usage
            exit 0
        fi
        if [ "${op}" = "write" ];then
            if [ ! -f "$file" ];then
                echo "$file doesnot exist"
                exit 0
            fi
        fi
    elif [ $# -eq 4 ];then
        op=$1
        spi=$2
        master_slave=$3
        lcdev=$4
        index=${4: -1}
        if [ "${op}" != "erase" ];then
            usage
            exit 0
        fi
    fi
    case ${lcdev} in
        "lc1" | "lc2" | "lc3" | "lc4" | "lc5" | "lc6" | "lc7" | "lc8")
            ;;
        *)
            usage
            exit 0
            ;;
    esac
    LCCPLD_SYSFS_DIR=${LC_PATH_DICT[${index}]}
    case ${spi} in
        "BIOS" | "FPGA")
            ;;
        *)
            usage
            exit 0
            ;;
    esac
    case ${master_slave} in
        "master" | "slave")
            ;;
        *)
            usage
            exit 0
            ;;
    esac
    if [ "${op}" = "read" ] || [ "${op}" = "write" ];then
        if [ "$2" = "FPGA" ];then
            if [ "${master_slave}" = "master" ];then
                image="primary"
            elif [ "${master_slave}" = "slave" ];then
                image="golden"
            fi
            if [ -n "${image}" ];then
                if [ ! -f "${layout_file}" ];then
                    echo "${layout_file} doesnot exist"
                    exit 0
                fi
                if ! check_layout_image_exist "${layout_file}" ${image};then
                    exit 0
                fi
            fi
        fi
    fi
}

check_duplicate_process
check_parameter "$@"
do_action_"${2}" "$@"

# root@bmc-oob:/etc/platform/xs9880-8c# ls
# fpgarom.layout       sensors_config.json
# root@bmc-oob:/etc/platform/xs9880-8c# cat fpgarom.layout
# 00000000:003FEFFF golden
# 003FF000:003FFFFF timer1
# 00400000:006FFFFF primary
# 00700000:0070003B timer2
# root@bmc-oob:/etc/platform/xs9880-8c# cat sensors_config.json
# {
#     "PSU_DICT":{
#         "TotalNum":4,
#         "TempNum":3,
#         "FAN":{"Unit":"RPM","Value":"fan1_input","Desc":"Fan Speed"},
#         "TEMP1":{"Unit":"C","Max":"temp1_max","Value":"temp1_input","Desc":"Temp1"},
#         "TEMP2":{"Unit":"C","Max":"temp2_max","Value":"temp2_input","Desc":"Temp2"},
#         "TEMP3":{"Unit":"C","Max":"temp3_max","Value":"temp3_input","Desc":"Temp3"},
#         "VIN":{"Unit":"V","Min":"in1_min","Max":"in1_max","Value":"in1_input","Desc":"Input Voltage"},
#         "IIN":{"Unit":"A","Max":"curr1_max","Value":"curr1_input","Desc":"Input Current"},
#         "PIN":{"Unit":"W","Max":"power1_max","Value":"power1_input","Desc":"Input Power"},
#         "VOUT":{"Unit":"V","Min":"in2_min","Max":"in2_max","Value":"in2_input","Desc":"Output Voltage"},
#         "IOUT":{"Unit":"A","Max":"curr2_max","Value":"curr2_input","Desc":"Output Current"},
#         "POUT":{"Unit":"W","Max":"power2_max","Value":"power2_input","Desc":"Output Power"},
#         "SupportModule":["G1236-3000WNC"],
#         "ModelName":"mfr_id",
#         "SerialNumber":"mfr_serial",
#         "PartNumber":"mfr_model",
#         "InputType":"input_type",
#         "PSU1":{
#             "Present":"/sys/bus/i2c/devices/82-000d/psu1_present",
#             "PMBus":"/sys/bus/i2c/devices/32-005b",
#             "PowerSta":"/sys/bus/i2c/devices/82-000d/psu1_pwr_ok",
#             "PowerInSta":"/sys/bus/i2c/devices/82-000d/psu1_ac_ok"
#         },

ssh连不上,ip冲突,改interface。

if [ "$1" = "--slave" ];then
    ver=$(strings /dev/mtd5 | grep U-Boot | tail -1 | awk -F ' ' '{print$3}')
    printf "%-25s : %s\n" "Slave BMC Version" ${ver}
    exit
fi
printf "%-25s : v%d.%02d.%02d\n" "FCB1 CPLD Version" ${FCB1cpld_rev_h} ${FCB1cpld_rev_m} ${FCB1cpld_rev_l}

3.rsyslog:rsyslogd一个进程 ,管理每个进程发来的log并往/var/log里写,syslog函数将log写给rsyslogd进程。

在这里插入图片描述

在这里插入图片描述
ident将是一个标记,省略的话即打印出进程的名字如下。
在这里插入图片描述
facility默认是user。
在这里插入图片描述
在这里插入图片描述
如下排除文件中以#开头的和去除空行
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

1.1 log_rotate

#!/bin/sh
/usr/sbin/logrotate /etc/logrotate.conf
EXITVALUE=$?
if [ $EXITVALUE != 0 ]; then
    /usr/bin/logger -t logrotate "ALERT exited abnormally with [$EXITVALUE]"
fi
exit $EXITVALUE

1.2 rsyslog.conf

# rsyslog configuration file
#
# This config uses old-style formatting. For more advanced features,
# RainerScript configuration is suggested.
#
# For more information see /usr/share/doc/rsyslog-*/rsyslog_conf.html
# or latest version online at http://www.rsyslog.com/doc/rsyslog_conf.html
# If you experience problems, see http://www.rsyslog.com/doc/troubleshoot.html

$ModLoad imuxsock           # provides support for local system logging (e.g. via logger command)
$ModLoad imklog             # kernel logging (formerly provided by rklogd)
module(load="imfile")       # Provides support for tailing and categorizing existing log files
$ActionQueueType Direct         # Do not queue these, write immediately
global(workDirectory="/tmp")    # Remembers the last file position when syslog restarts and does not retransmit

# Set the default permissions
$FileOwner root
$FileGroup adm
$FileCreateMode 0640
$DirCreateMode 0755
$Umask 0022
$PreserveFQDN on

# Use format recognized by log-util.
$template LogUtilFileFormat," %$YEAR% %TIMESTAMP% %pri-text% __OPENBMC_VERSION__: %syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n"

# Store dhclient logs into dhclient.log,
# store everything else into /var/log/messages
if $programname == "dhclient" then /var/log/dhclient.log
else  
# limit size to 21M
$outchannel messagefile_channel, /var/log/messages, 22020096, /usr/local/fbpackages/rotate/log_rotate
*.*  :omfile:$messagefile_channel;LogUtilFileFormat

# Save boot messages also to boot.log
local7.*        /tmp/boot.log;LogUtilFileFormat

# Store come-mon logs into come-mon_rsyslog.log
if $programname == "come-mon" then 
$outchannel comemonfile_channel, /var/log/come-mon.log, 22020096, /usr/local/fbpackages/rotate/log_rotate
*.*  :omfile:$comemonfile_channel;LogUtilFileFormat

# Store power-mon logs into power-mon_rsyslog.log
if $programname == "power-mon" then 
$outchannel powermonfile_channel, /var/log/power-mon.log, 22020096, /usr/local/fbpackages/rotate/log_rotate
*.*  :omfile:$powermonfile_channel;LogUtilFileFormat

# Store sensor-mon logs into sensor-mon_rsyslog.log
if $programname == "sensor-mon" then 
$outchannel sensormonfile_channel, /var/log/sensor-mon.log, 22020096, /usr/local/fbpackages/rotate/log_rotate
*.*  :omfile:$sensormonfile_channel;LogUtilFileFormat

# Store temp-mon logs into temp-mon_rsyslog.log
if $programname == "temp-mon" then
$outchannel tempmonfile_channel, /var/log/temp-mon.log, 22020096, /usr/local/fbpackages/rotate/log_rotate
*.*  :omfile:$tempmonfile_channel;LogUtilFileFormat

#mTerm_server log (TBD)
# Send local3 log to the /var/log/messages
#input(type="imfile"
#  File="/var/log/mTerm_consol.log"
#  Tag="oob_mTerm_consol"
#  Severity="debug"
#  Facility="local3"
#  reopenOnTruncate="on"
#)

# 如下将info级别及其以上级别(可改成crit等其他级别)的日志发送给target服务端
*.info action(type="omfwd" name="remoteLog" template="LogUtilFileFormat" target="10.75.159.146" port="514" protocol="udp"
           queue.type="LinkedList" action.resumeRetryCount="1" action.resumeInterval="60"
           queue.size="500" queue.workerthreadminimummessages="101" queue.discardseverity="0"
           queue.timeoutenqueue="0" queue.timeoutshutdown="10" queue.timeoutactioncompletion="100"
           action.reportSuspension="off" action.reportSuspensionContinuation="off")

$IncludeConfig /etc/rsyslog.d/*.conf

在这里插入图片描述
在这里插入图片描述
10.75.159.146做服务端,/etc/rsyslog.conf 打开如下配置,tcp打开tcp的配置:

module(load="imudp")
input(type="imudp" port="514")
$IncludeConfig /etc/rsyslog.d/*.conf

/etc/rsyslog.d/remote.conf 配置如下(修改完需重启rsyslog进程):

:fromhost,isequal, "10.75.159.37"  /var/log/remote_37.log

1.3 rsyslog.logrotate

# Logs to be managed by logrotate:

/var/log/fscd.log
/var/log/dhclient.log
/var/log/messages
/var/log/sensor-mon.log
/var/log/power-mon.log
/var/log/come-mon.log
/var/log/temp-mon.log
{
        rotate 9
        missingok
        notifempty
        size 20M
        delaycompress
        compress
        postrotate
            /bin/kill -HUP `cat /var/run/rsyslogd.pid 2> /dev/null` 2> /dev/null || true
        endscript
}

1.4 rsyslog_%.bbappend

FILESEXTRAPATHS_prepend := "${THISDIR}/files:"

SRC_URI += "file://rsyslog.conf \
            file://log_rotate \
            file://rsyslog.logrotate \
"

MTERM_LOG_FILES ?= "mTerm_${MACHINE}"

do_install_append() {
  dst="${D}/usr/local/fbpackages/rotate"
  rsysconf="${D}${sysconfdir}/rsyslog.d"
  install -d $dst
  install -d ${rsysconf}
  install -m 755 ${WORKDIR}/log_rotate ${dst}/log_rotate

  install -m 644 ${WORKDIR}/rsyslog.logrotate ${D}${sysconfdir}/logrotate.rsyslog
  install -m 644 ${WORKDIR}/rsyslog.conf ${D}${sysconfdir}/rsyslog.conf
  sed -i "s/__OPENBMC_VERSION__/${OPENBMC_VERSION}/g" ${D}${sysconfdir}/rsyslog.conf
}

FILES_${PN} += "/usr/local/fbpackages/rotate"

2.

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
以下的ip用lastb查看
在这里插入图片描述

在这里插入图片描述

logrotate-default

# RPM packages drop log rotation information into this directory
include /etc/logrotate.d

logrotate_%.bbappend

FILESEXTRAPATHS_append := "${THISDIR}/${PN}:"

SRC_URI += " \
            file://logrotate-3.9.1/examples/logrotate-default \
           "

# We need to rotate every hour or could quickly run out of RAM.
LOGROTATE_SYSTEMD_TIMER_BASIS = "hourly"
LOGROTATE_SYSTEMD_TIMER_ACCURACY = "30m"

do_install_append() {
    install -p -m 644 ${WORKDIR}/logrotate-3.9.1/examples/logrotate-default ${D}${sysconfdir}/logrotate.conf

    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
        # XXX For now we build Yocto with systemd enabled and sysvinit
        # compat to allow remaining sysvinit scripts to continue working. 
        # With both systemd & sysvinit compat on, the logrotate recipe gets
        # it wrong and installs both the crontab entry and systemd timer. 
        # When sysvinit compat is removed then this can go away.
        rm -f ${D}${sysconfdir}/cron.daily/logrotate
    fi
}

在这里插入图片描述

左面是对应的LC CPLD寄存器的名字 中间是 切换后器件在的通道号 右面是器件位号
在这里插入图片描述

在这里插入图片描述

在这里插入图片描述

在这里插入图片描述
在这里插入图片描述
测完了要把这个节点值再 写回0
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
这个硬件给错了 这个是ch1

SOL

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/14327.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

RESTful 接口设计拓展,接口设计注意事项,注解的简化

文章目录RESTful 接口设计拓展1.多参数传递2.URL拓展3.RESTful接口注意事项4.注解的简化RESTful 接口设计拓展 1.多参数传递 /*** 获取某一个员工&#xff0c;多参数* 1. 请求路径--确认资源--员工--/employees* 2. 请求方法--get* 3. 请求参数--id&#xff0c;name,age* 4. …

Python接口测试之requests详介与实战

目录 requests介绍 1、简述发展史 2、安装 3、官方自评 4、requests支持的请求类型 4、requests的参数与返回 requests接口请求Python脚本实战 1、GET接口实战 2、POST接口实战 3、PUT接口实战 4、DELETE接口实战 requests介绍 Http网络接口请求库 1、简述发展史 …

设计师找灵感就上这几个网站。

推荐5个设计师必备的设计灵感网站&#xff0c;希望对你有帮助&#xff01; 1、pinterest&#xff08;梯子&#xff09; https://www.pinterest.es/Pinterest是以瀑布流的方式来展示图片&#xff0c;在算法上也会根据你的浏览和识别的图片去做推算。 所以Pinterest是需要“经营”…

网络编程概述

Java是 Internet 上的语言&#xff0c;它从语言级上提供了对网络应用程 序的支持&#xff0c;程序员能够很容易开发常见的网络应用程序。 Java提供的网络类库&#xff0c;可以实现无痛的网络连接&#xff0c;联网的底层 细节被隐藏在 Java 的本机安装系统里&#xff0c;由 JVM …

权限系统设计

背景 目前只做了用户账号间的数据隔离。存在情况&#xff0c;同一个项目里不同人创建不同的资源&#xff0c;项目里的成员都可以看得到&#xff0c;同时也不能互相随便修改数据。所以需要一些组的权限控制。 1.模型和模型荚是公用的&#xff0c;没有做用户区分&#xff0c;也没…

学计算机的可以做哪些适合自己的兼职?

如果你在做以下的任意一种兼职&#xff0c;我建议你立刻停止&#xff01; 1.单纯体力劳动的兼职 像是发传单、发问卷、送外卖这类兼职只能在短期内提升你的“8小时外收入”的兼职&#xff0c;纯粹是靠时间和体力来换钱&#xff0c;性价比很低&#xff0c;而且不能通过兼职提升…

指定字符串中的一部分将原来的字符串拆分成三部分partition()函数

【小白从小学Python、C、Java】 【计算机等级考试500强双证书】 【Python-数据分析】 指定字符串中的一部分 将原来的字符串拆分成三部分 partition()函数 选择题 对于以下python代码表述错误的一项是? Str"12345" print("【显示】Str",Str) print("…

Vue2【前端路由的概念与原理、vue-router 的基本用法、vue-router 的常见用法、后台管理案例】

文章目录前端路由的概念与原理1. 什么是路由3. SPA 与前端路由4. 什么是前端路由5. 前端路由的工作方式6. 实现简易的前端路由步骤1&#xff1a;通过 **\<component\>** 标签&#xff0c;结合 **comName** 动态渲染组件。示例代码如下&#xff1a;步骤2&#xff1a;在 Ap…

Xcode Cloud

一、使用Xcode Cloud 的要求 &#xff08;1&#xff09;开发者账户要求 已加入Apple Developer Program向xcode加入Apple IDApp Store Connect上有app 记录或者可以创建一个app记录 &#xff08;2&#xff09;Project和workspace要求 Project或者workspace使用Xcode项目使用…

JavaScript基础语法

JavaScript基础语法 文章目录JavaScript基础语法1.JavaScript的基本认知1.1 JS的介绍与组成1.2 JS代码使用格式2.JavaScript的注释与输入输出语句2.1 JS的注释方法2.2 JS的输入输出语句3.JavaScript的变量3.1 JS的变量初始化3.2 JS的声明变量特殊情况3.3 JS的变量命名规则4.Jav…

Windows版本Anaconda安装教程

1、点击安装包&#xff0c;右键-以管理员身份运行安装文件&#xff0c;如图所示&#xff1a; 2、直接点击next即可 3、接着进入到许可协议的界面&#xff0c;这里点击I agree选项&#xff0c;也就是我同意的意思。 4、接着进入到用户选择的界面&#xff0c;选择all users选项&a…

面试官的灵魂质问—什么是转发与重定向

文章目录 文章目录文章目录[toc]一、什么是HttpServletRequest、HttpServletReSponse&#xff1f;二、Servlet中HttpServletRequest[源码](https://so.csdn.net/so/search?q源码&spm1001.2101.3001.7020)分析获取客户端传递的参数请求转发三、Servlet中HttpServletReSpons…

HTML网页设计结课作业——基于HTML+CSS仿学校官网页面

&#x1f389;精彩专栏推荐 &#x1f4ad;文末获取联系 ✍️ 作者简介: 一个热爱把逻辑思维转变为代码的技术博主 &#x1f482; 作者主页: 【主页——&#x1f680;获取更多优质源码】 &#x1f393; web前端期末大作业&#xff1a; 【&#x1f4da;毕设项目精品实战案例 (10…

【保姆级】新机器部署Nacos

1、登录服务器&#xff0c;如果非root用户则切root用户 sudo su - 2、在/usr/tmp目录上传nacos安装包 3、将安装包移到/usr/local/目录 mv nacos-server-2.0.3.tar.gz /usr/local/ 4、解压 tar -zxvf nacos-server-2.0.3.tar.gz 5、创建nacos数据库&#xff0c;执行官网SQL建…

vc中调用matlab生成的动态库

开发环境&#xff1a; vs2010 matlab r2016a 步骤一&#xff1a;matlab中生成动态库 创建文本文件 D:\matlabTest\myadd.m&#xff0c;文件内容参看下面代码部分。注意&#xff1a;如果把myadd.m文件直接放在d盘根目录下&#xff0c;matlab中编译生成动态库时&#xff0c;会…

JavaScript--跟随pink老师视频学习版 (2022)

JavaScript一、JavaScript简介1.什么是JavaScript2.JavaScript用途3.浏览器执行JavaScript简介3.JavaScript组成1.ECMAScript2.DOM3.BOM4.JavaScript代码位置1.行内2.内嵌3.外部引入5.JavaScript输入输出语句二、JavaScript变量1.什么是变量2.变量使用3.变量命名规范三、数据类…

DBCO-NH2,DBCO-Amine 实验室 杂氮二苯并环辛炔-胺 1255942-06-3

DBCO(二苯并环辛炔) 的羧基和琥珀酰亚胺酯衍生物&#xff0c;可与带有胺基的生化小分子形成稳定的酰胺键连接。 胺官能团的环辛炔衍生物。环辛炔可用于菌株促进的无铜叠氮化物-炔烃环加成反应。该二苯并环辛炔可在不需要Cu&#xff08;I&#xff09;催化剂的情况下&#xff0c…

TCP/IP网络编程(10) IO函数

在Linux下&#xff0c;一般使用read & write函数完成数据IO&#xff0c;因为Linux下的套接字&#xff0c;可视为文件&#xff0c;其操作方式与文件类似&#xff0c;当套接字分配之后&#xff0c;会为其分配对应的文件描述符。在Windows下&#xff0c;则需要使用recv & …

[oeasy]python0016_编码_encode_编号_字节_计算机

编码(encode) 回忆上次内容 上次找到了字符和字节状态之间的映射对应关系 字符对应着二进制字节二进制字节也对应着字符 这种字节状态是用2位16进制数来表示的hex(n)可以把数字转化为 ​​16进制​​字符串 hexadecimal bin(n)可以把数字转化为 ​​2进制​​字符串 integer …

显示控件——AV输入显示

通过修改变量地址打开或者关闭AV显示&#xff0c;需要硬件支持。 位置信息&#xff1a;控件在工程页面区域的位置 “X”“Y”为控件区域左上角坐标。 “W”“H”为控件区域宽度和高度&#xff0c;单位为像素点。 名称&#xff1a;默认为AVInputView,可以重新设置。 叙述指针…