1. Linux运维根底采集项

做运维,不怕出问题,怕的是出了问题,抓不到现场,两眼摸黑。所以,依附弱小的监控零碎,收集尽可能多的指标,意义重大。但哪些指标才是有意义的呢,本着从实际中来的思维,各位工程师在长期摸爬滚打中总结进去的教训最有价值。

在各位运维工程师长期的工作实际中,咱们总结了在零碎运维过程中,常常会参考的一些指标,次要包含以下几个类别:

  • CPU
  • Load
  • 内存
  • 磁盘
  • IO
  • 网络相干
  • 内核参数
  • ss 统计输入
  • 端口采集
  • 外围服务的过程存活信息采集
  • 要害业务过程资源耗费
  • NTP offset采集
  • DNS解析采集

每个类别,具体的具体指标如下,这些指标,都是open-falcon的agent组件间接反对的。falcon-agent每隔肯定工夫距离(目前是60秒)会采集一次相干的指标,并汇报给server端。

  1. CPU相干采集项

计算方法:通过采集/proc/stat来失去,大家能够参考sar命令的统计输入来了解。

  • cpu.idle:Percentage of time that the CPU or CPUs were idle and the system did not have an outstanding disk I/O request.
  • cpu.busy:与cpu.idle绝对,他的值等于100减去cpu.idle。
  • cpu.guest:Percentage of time spent by the CPU or CPUs to run a virtual processor.
  • cpu.iowait:Percentage of time that the CPU or CPUs were idle during which the system had an outstanding disk I/O request.
  • cpu.irq:Percentage of time spent by the CPU or CPUs to service hardware interrupts.
  • cpu.softirq:Percentage of time spent by the CPU or CPUs to service software interrupts.
  • cpu.nice:Percentage of CPU utilization that occurred while executing at the user level with nice priority.
  • cpu.steal:Percentage of time spent in involuntary wait by the virtual CPU or CPUs while the hypervisor was servicing another virtual processor.
  • cpu.system:Percentage of CPU utilization that occurred while executing at the system level (kernel).
  • cpu.user:Percentage of CPU utilization that occurred while executing at the user level (application).
  • cpu.cnt:cpu核数。
  • cpu.switches:cpu上下文切换次数,计数器类型。
  1. 磁盘相干采集项

计算方法:先读取/proc/mounts拿到所有挂载点,而后通过syscall.Statfs_t拿到blocks和inode的应用状况。每个metric都会附加一组tag形容,相似mount=$mount,fstype=$fstype,其中$mount是挂载点,比方/home,$fstype是文件系统,比方ext4。

  • df.bytes.free:磁盘可用量,int64
  • df.bytes.free.percent:磁盘可用量占总量的百分比,float64,比方32.1
  • df.bytes.total:磁盘总大小,int64
  • df.bytes.used:磁盘已用大小,int64
  • df.bytes.used.percent:磁盘已用大小占总量的百分比,float64
  • df.inodes.total:inode总数,int64
  • df.inodes.free:可用inode数目,int64
  • df.inodes.free.percent:可用inode占比,float64
  • df.inodes.used:已用的inode数据,int64
  • df.inodes.used.percent:已用inode占比,float64
  1. megacli工具输入

应用 megacli 工具读取 RAID 相干信息,每个metric都会附件一组tag形容,用来表明所属PD或者 VD,PD格局为PD=Enclosure_ID:SLOT_ID,比方PD=32:0表明第一块磁盘 ,VD=0 表明第一个逻辑磁盘。

  • sys.disk.lsiraid.pd.Media_Error_Count:这个及以下三个指标目前仅作为数据收集,不肯定象征磁盘损坏(只是示意损坏概率变大)
  • sys.disk.lsiraid.pd.Other_Error_Count
  • sys.disk.lsiraid.pd.Predictive_Failure_Count
  • sys.disk.lsiraid.pd.Drive_Temperature
  • sys.disk.lsiraid.pd.Firmware_state:如果值不为0,则此物理磁盘呈现问题
  • sys.disk.lsiraid.vd.cache_policy:如果值不为0,示意此逻辑磁盘缓存策略和设置不符
  • sys.disk.lsiraid.vd.state:如果值不为0,示意此逻辑磁盘呈现问题
  1. SMART工具输入

应用 smartctl 工具读取磁盘 SMART 信息,目前所有指标仅作为数据收集,不肯定象征磁盘损坏(只是示意概率变大),每个metric都会有一组tag形容,表明盘符,例如device=/dev/sda。

  • sys.disk.smart.Reallocated_Sector_Ct
  • sys.disk.smart.Spin_Retry_Count
  • sys.disk.smart.Reallocated_Event_Count
  • sys.disk.smart.Current_Pending_Sector
  • sys.disk.smart.Offline_Uncorrectable
  • sys.disk.smart.Temperature_Celsius
  1. 分区读写监控

测试所有已挂载分区是否可读写,每个metric都会有一组tag形容,示意挂载点,比方mount=/home

  • sys.disk.rw:如果值不为0,表明此分区读写呈现问题
  1. IO相干采集项

计算方法:每秒采集一次/proc/diskstats,计算差值,都是计数器类型的。每个metric都会有一组tag形容,形如device=$device,用来示意具体的设施,比方sda1、sdb。用户能够参考iostat的帮忙文档来了解具体的metric含意。

  • disk.io.ios_in_progress:Number of actual I/O requests currently in flight.
  • disk.io.msec_read:Total number of ms spent by all reads.
  • disk.io.msec_total:Amount of time during which ios_in_progress >= 1.
  • disk.io.msec_weighted_total:Measure of recent I/O completion time and backlog.
  • disk.io.msec_write:Total number of ms spent by all writes.
  • disk.io.read_merged:Adjacent read requests merged in a single req.
  • disk.io.read_requests:Total number of reads completed successfully.
  • disk.io.read_sectors:Total number of sectors read successfully.
  • disk.io.write_merged:Adjacent write requests merged in a single req.
  • disk.io.write_requests:total number of writes completed successfully.
  • disk.io.write_sectors:total number of sectors written successfully.
  • disk.io.read_bytes:单位是byte的数字
  • disk.io.write_bytes:单位是byte的数字
  • disk.io.avgrq_sz:上面几个值就是iostat -x 1看到的值
  • disk.io.avgqu-sz
  • disk.io.await
  • disk.io.svctm
  • disk.io.util:是个百分数,比方56.43,示意56.43%
  1. 机器负载相干采集项

计算方法:读取/proc/loadavg,都是原始值类型的:

  • load.1min
  • load.5min
  • load.15min
  1. 内存相干采集项

计算方法:读取/proc/meminfo 中的内容,其中的mem.memfree是free+buffers+cached,mem.memused=mem.memtotal-mem.memfree。用户具体能够参考free命令的输入和帮忙文档来了解每个metric的含意。

  • mem.memtotal:内存总大小
  • mem.memused:应用了多少内存
  • mem.memused.percent:应用的内存占比
  • mem.memfree
  • mem.memfree.percent
  • mem.swaptotal:swap总大小
  • mem.swapused:应用了多少swap
  • mem.swapused.percent:应用的swap的占比
  • mem.swapfree
  • mem.swapfree.percent
  1. 网络相干采集项

计算方法:读取/proc/net/dev的内容,每个metric都附加有一组tag,形如iface=$iface,表明具体那个interface,比方eth0。metric中带有in的示意流入状况,out示意流出状况,total是总量in+out,反对的metric如下:

  • net.if.in.bytes
  • net.if.in.compressed
  • net.if.in.dropped
  • net.if.in.errors
  • net.if.in.fifo.errs
  • net.if.in.frame.errs
  • net.if.in.multicast
  • net.if.in.packets
  • net.if.out.bytes
  • net.if.out.carrier.errs
  • net.if.out.collisions
  • net.if.out.compressed
  • net.if.out.dropped
  • net.if.out.errors
  • net.if.out.fifo.errs
  • net.if.out.packets
  • net.if.total.bytes
  • net.if.total.dropped
  • net.if.total.errors
  • net.if.total.packets
  1. 端口采集项

计算方法,通过ss -ln,来判断指定的端口是否处于listen状态。原始值类型,值要么是1:代表在监听,要么是0,代表没有在监听。每个metric都附件一组tag,形如port=port,port就是具体的端口。

  • net.port.listen
  1. 机器内核配置

  • kernel.maxfiles:读取的/proc/sys/fs/file-max
  • kernel.files.allocated:读取的/proc/sys/fs/file-nr第一个Field
  • kernel.files.left:值=kernel.maxfiles-kernel.files.allocated
  • kernel.maxproc:读取的/proc/sys/kernel/pid_max
  1. ntp采集项

应用 ntpq -pn 获取本机工夫绝对于 ntp 服务器的 offset。

  • sys.ntp.offset:本机偏移工夫,单位为ms,值过大或者为0则表明有异样,须要报警
  1. 过程监控

proc.num:判断某个过程的数目,这里须要分两个场景,一种是依据过程的名字来断定,比方name=sshd;另外一种是依据cmdline来断定,比方Java的利用过程名可能都是java,依据第一种状况没法做辨别,此时能够配置cmdline,如cmdline=./falcon_agent-c./cfg.ini

  1. 过程资源监控

  • process.cpu.all:过程和它的子过程应用的sys+user的cpu,单位是jiffies
  • process.cpu.sys:过程和它的子过程应用的sys cpu,单位是jiffies
  • process.cpu.user:过程和它的子过程应用的user cpu,单位是jiffies
  • process.swap:过程和它的子过程应用的swap,单位是page
  • process.fd:过程应用的文件描述符个数
  • process.mem:过程占用内存,单位byte
  1. ss命令输入

  • ss.orphaned
  • ss.closed
  • ss.timewait
  • ss.slabinfo.timewait
  • ss.synrecv
  • ss.estab

(起源:book.open-falcon.org)