Linux

  • 除了snmp template 外,其实可以另外添加icmp template,这样就能获得items,graph和tigger了;

CPU Statistics

Load
1 minute Load: .1.3.6.1.4.1.2021.10.1.3.1
5 minute Load: .1.3.6.1.4.1.2021.10.1.3.2
15 minute Load: .1.3.6.1.4.1.2021.10.1.3.3
ucd-snmpd.laLoadInt1 .1.3.6.1.4.1.2021.10.1.5.1
ucd-snmpd.laLoadInt5 .1.3.6.1.4.1.2021.10.1.5.2
ucd-snmpd.laLoadInt15 .1.3.6.1.4.1.2021.10.1.5.3

CPU

percentage of user CPU time: .1.3.6.1.4.1.2021.11.9.0
raw user cpu time: .1.3.6.1.4.1.2021.11.50.0
percentages of system CPU time: .1.3.6.1.4.1.2021.11.10.0
raw system cpu time: .1.3.6.1.4.1.2021.11.52.0
percentages of idle CPU time: .1.3.6.1.4.1.2021.11.11.0
raw idle cpu time: .1.3.6.1.4.1.2021.11.53.0
raw nice cpu time: .1.3.6.1.4.1.2021.11.51.0

Memory Statistics

Total Swap Size: .1.3.6.1.4.1.2021.4.3.0
Available Swap Space: .1.3.6.1.4.1.2021.4.4.0
Total RAM in machine: .1.3.6.1.4.1.2021.4.5.0
Total RAM used: .1.3.6.1.4.1.2021.4.6.0
Total RAM Free: .1.3.6.1.4.1.2021.4.11.0
Total RAM Shared: .1.3.6.1.4.1.2021.4.13.0
Total RAM Buffered: .1.3.6.1.4.1.2021.4.14.0
Total Cached Memory: .1.3.6.1.4.1.2021.4.15.0

###Linux Disk Space:

hrStorageSize 1.3.6.1.2.1.25.2.3.1.5.
hrStorageUsed 1.3.6.1.2.1.25.2.3.1.6.
hrStorageType 1.3.6.1.2.1.25.2.3.1.2
hrStorageDescr 1.3.6.1.2.1.25.2.3.1.3
hrStorageAllocationUnits 1.3.6.1.2.1.25.2.3.1.4

System Uptime

System Uptime: .1.3.6.1.2.1.1.3.0
Traffic - can monitor ifInOctets, ifOutOctets, ifDescr, ifAdminStatus
Port Connectivity - do snmpwalk & grep tcpConnState, for something like:
.1.3.6.1.2.1.6.13.1.1.0.0.0.0.9260.0.0.0.0.0 (Monitoring Port 9260)

ipAdEntIfIndex

.1.3.6.1.2.1.4.20.1.2

IP-MIB::ipAdEntIfIndex.100.100.101.11 = INTEGER: 14
IP-MIB::ipAdEntIfIndex.183.6.134.194 = INTEGER: 1


nagios的plugins

check_disk_snmp.pl

  • 需配合/usr/lib64/nagios/plugins/utils.pm使用, 需安装net-analyzer/nagios-plugins
  • 这个可以检测snmpd的挂载情况,并可以自动计算出占用率,设置warning和critical以便报警
$ ./check_disk_snmp.pl -H host_address -s snmp_community 

Index   Description
=====   ===========
1   Physical memory
3   Virtual memory
6   Memory buffers
7   Cached memory
8   Shared memory
10  Swap space
31  /
36  /dev/shm
38  /run
39  /sys/fs/cgroup
56  /boot
57  /run/user/0

$ ./check_disk_snmp.pl -H host_address -s snmp_community -d 31
SNMP OK - / at 27% with 4,915 of 6,818 MB free

获取snmpd的OID

  1. 配合perl -d获取 snmp的OID
  2. 获得 used% = ( HOST-RESOURCES-MIB::hrStorageSize.31 / HOST-RESOURCES-MIB::hrStorageUsed.31 ) * 100

/check_http -H 172.16.210.101 -S -p 8443 -u https://172.16.210.101:8443/healthcheck.jsp -s 210.101 -w 0.5 -c 1 -t 10

nagios-plugins

./check_http -H 172.16.210.101 -S -p 8443 -u https://172.16.210.101:8443/healthcheck.jsp -s 210.101 -w 0.5 -c 1 -t 10
HTTP OK: HTTP/1.1 200 OK - 344 bytes in 0.436 second response time |time=0.436405s;0.500000;1.000000;0.000000 size=344B;;;0

snmp获取硬盘使用率的方法

  • 通过上面的./check_disk_snmp.pl,能得知是通过‘.1.3.6.1.2.1.25.2.3’来获取以下信息:
$ snmpwalk  -v2c -c comunity hostname '.1.3.6.1.2.1.25.2.3' | grep 31
HOST-RESOURCES-MIB::hrStorageIndex.31 = INTEGER: 31
HOST-RESOURCES-MIB::hrStorageType.31 = OID: HOST-RESOURCES-TYPES::hrStorageFixedDisk
HOST-RESOURCES-MIB::hrStorageDescr.31 = STRING: /
HOST-RESOURCES-MIB::hrStorageAllocationUnits.31 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageSize.31 = INTEGER: 1745408
HOST-RESOURCES-MIB::hrStorageUsed.31 = INTEGER: 487282

上面的信息中注意这些:

1. hrStorageSize 这个是存储的容量Block数量
2. hrStorageUsed 这个是存储已经使用的容量Block数量
3. hrStorageAllocationUnits 每个Block的字节数量
4. hrStorageSize * 4096 才是盘的Bytes数量
5. zabbix需要template相应新建 hrStorageSize hrStorageUsed items,然后通过calculated来计数已用空间量的items,然后再做trigger。
6. 如果要做饼图的话,需要添加hrStorageSize hrStorageUsed这两个items