shell中使用sed正则修改文件

sed 使用正则匹配 在shell中 当变量有空格的时候使用双引号包围 “${var}” function change_version_class() { VERSION_CODE_FILE=$1 BUILD_VERSION=$2 if [ -f “${VERSION_CODE_FILE}” ]; then echo ‘change ‘”${VERSION_CODE_FILE}”‘ info’ BUILD_TIME=$(date +%Y%m%d-%H:%M:%S) BUILD_USER=$(whoami) BUILD_OS=$(uname -snr) BUILD_BRANCH=$(git branch |grep ‘[*]’|awk ‘{print $2}’) BUILD_COMMIT=$(git log –oneline |head -n 1|awk ‘{print $1}’) sed -i ‘s/String BUILD_VERSION =\(.\)\+/String BUILD_VERSION = “‘”${BUILD_VERSION}”‘”;/g’ “${VERSION_CODE_FILE}” sed -i ‘s/String BUILD_TIME =\(.\)\+/String BUILD_TIME =… Continue reading shell中使用sed正则修改文件

Published
Categorized as linux

virsh 虚拟机xml信息,留个记录

virsh dumpxml domain 虚拟机dumpxml例,可以参考格式 xml <domain type=’kvm’ id=’12’> <name>ceph-node3</name> <uuid>4f52f828-f538-45cb-9f02-eeb555e96020</uuid> <memory unit=’KiB’>8388608</memory> <currentMemory unit=’KiB’>8388608</currentMemory> <vcpu placement=’static’>2</vcpu> <resource> <partition>/machine</partition> </resource> <os> <type arch=’x86_64′ machine=’pc-i440fx-rhel7.0.0′>hvm</type> <boot dev=’hd’/> </os> <features> <acpi/> <apic/> </features> <cpu mode=’custom’ match=’exact’ check=’full’> <model fallback=’forbid’>Haswell-IBRS</model> <feature policy=’disable’ name=’hle’/> <feature policy=’disable’ name=’rtm’/> <feature policy=’require’ name=’hypervisor’/> <feature policy=’require’ name=’xsaveopt’/> </cpu> <clock offset=’utc’> <timer name=’rtc’ tickpolicy=’catchup’/> <timer… Continue reading virsh 虚拟机xml信息,留个记录

结合vmstat分析iostat输出结果

man vmstat FIELD DESCRIPTION FOR VM MODE Procs r: The number of processes waiting for run time. r 表示运行队列 (就是说多少个进程真的分配到CPU). 当这个值超过了CPU数目, 就会出现CPU瓶颈. b: The number of processes in uninterruptible sleep. Memory swpd: the amount of virtual memory used. free: the amount of idle memory. buff: the amount of memory used as buffers. cache: the amount… Continue reading 结合vmstat分析iostat输出结果

使用iostat分析问题

文章来源: How I Use Iostat and Vmstat for Performance Analysis 考虑到svctm在iostat是不保证准确的. 分析io await相关问题需要和blktrace结合起来分析. 1. Is the I/O heavy? Check the sum of w/s and r/s. The larger, the heavier I/O. Also check %util, the more, the heavier. If it is close to 100, then the I/O is definitely significant. It should be noted that during… Continue reading 使用iostat分析问题

n2n内穿透

之前一直使用frp.然后看到frp 有个xtcp.试了一下,家里和公司完全穿透不起来.网上一查,n2n的效果很一些.这里是软件地址ntop n2n mac os 需要先安装tuntap brew update && brew upgrade brew-cask && brew cleanup && brew cask cleanup /usr/bin/ruby -e “$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install)” brew cask install tuntap 编译安装.由于新版本mac os系统限制.我把Makefile里安装帮助文档和工具部分注释掉了. install: edge supernode edge.8.gz supernode.1.gz n2n.7.gz echo “MANDIR=$(MANDIR)” $(MKDIR) $(SBINDIR) $(MAN1DIR) $(MAN7DIR) $(MAN8DIR) $(INSTALL_PROG) supernode $(SBINDIR)/ $(INSTALL_PROG) edge $(SBINDIR)/ #$(INSTALL_DOC) edge.8.gz $(MAN8DIR)/ #$(INSTALL_DOC) supernode.1.gz $(MAN1DIR)/… Continue reading n2n内穿透