Zabbix监控系统系列之五:SNMP监控Windows客户端

======= 系列目录 =======
Zabbix监控系统系列之一 : Server部署
Zabbix监控系统系列之二 : 初始化配置
Zabbix监控系统系列之三 :版本升级
Zabbix监控系统系列之四:Agent监控Windows客户端
Zabbix监控系统系列之五:SNMP监控Windows客户端
Zabbix监控系统系列之六:EMAIL警告配置
Zabbix监控系统系列之七:VMware虚拟化监控
Zabbix监控系统系列之八:日志监控
Zabbix监控系统系列之九:监控网络设备指定接口流量
Zabbix监控系统系列之十:自动发现配置
Zabbix监控系统系列之十一:拓扑图绘制
Zabbix监控系统系列之十二:SNMP Traps主动告警
Zabbix监控系统系列之十三:SNMP Mibs库加载
Zabbix监控系统系列之十四:Oracle监控
Zabbix监控系统系列之十五:自动发现Oracle表空间并监控
======================

[Zabbix SNMP介绍]
如果服务器无法安装第三方软件(如存储设备、网络设备、其他供应商维护系统),那么可以考虑Zabbix SNMP监控方式,他可以收集一些必要的设备信息,如存活、性能、网络等。

[SNMP配置]
InstallSNMP.ps1 脚本参考:
适用范围:Windows 2008, 2008 R2, 2012, 2012 R2, 2016

####################################
# Last update: 20190813
# Description: Powershell script to install and configure SNMP Services on Windows 2008R2, 2012, 2012R2 and 2016 Server (SNMP Service, SNMP WMI Provider)
# start As Administrator with C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -executionpolicy bypass -Command "&{ \\Servername\InstallSNMP\installsnmp.ps1}"
# Script Location: \\Servername\InstallSNMP\installsnmp.ps1
####################################

#Variables :)
$PManagers = @("192.168.0.99") # ADD YOUR MANAGER(s) in format @("manager1","manager2")
$CommString = @("zhong") # ADD YOUR COMM STRING(s) in format @("Community1","Community2")

#Import ServerManger Module
Import-Module ServerManager

#Check if SNMP-Service is already installed
$check = Get-WindowsFeature -Name SNMP-Service

If ($check.Installed -ne "True") 
    {
    #Install/Enable SNMP-Service
    Write-Host "SNMP Service Installing..."
    # Get OS Version to use the right install command
    [int]$verMajor = [environment]::OSVersion.Version | ft -property Major -HideTableHeaders -auto | Out-String
    [int]$verMinor = [environment]::OSVersion.Version | ft -property Minor -HideTableHeaders -auto | Out-String
    if ($verMajor -eq 6)
        {
        $winVer = switch ($verMinor)
            {
            0 {"Win2008"}
            1 {"Win2008R2"}
            2 {"Win2012"}
            3 {"Win2012R2"}
            }
        }
    if ($verMajor -eq 10)
        {
        $winVer = switch ($verMinor)
            {
            0 {"Win2016"}
            }
        }
    #Install SNMP on 2008 (R2)
    if ($winVer -eq "Win2008" -or $winVer -eq "Win2008R2")
        {
        Get-WindowsFeature -name SNMP* | Add-WindowsFeature | Out-Null
        }
    #Install SNMP on 20012 (R2)
    if ($winVer -eq "Win2012" -or $winVer -eq "Win2012R2" -or $winVer -eq "Win2016")
        {
        Get-WindowsFeature -name SNMP* | Add-WindowsFeature -IncludeManagementTools | Out-Null
        }
    }

$check = Get-WindowsFeature -Name SNMP-Service

##Verify Windows Services Are Enabled
If ($check.Installed -eq "True")
    {
    Write-Host "Configuring SNMP Services..."
    #Set SNMP Permitted Manager(s) ** WARNING : This will over write current settings **
    reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v 1 /t REG_SZ /d localhost /f | Out-Null

    #Set SNMP Traps and SNMP Community String(s) - *Read Only*
    Foreach ($String in $CommString)
        {
        reg add ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\TrapConfiguration\" + $String) /f | Out-Null
        # Set the Default value to be null
        reg delete ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\TrapConfiguration\" + $String) /ve /f | Out-Null
        reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities" /v $String /t REG_DWORD /d 4 /f | Out-Null
        $i = 2
        Foreach ($Manager in $PManagers)
            {
            reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v $i /t REG_SZ /d $manager /f | Out-Null
            reg add ("HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\TrapConfiguration\" + $String) /v $i /t REG_SZ /d $manager /f | Out-Null
            $i++
            }
        }
    }
Else 
    {
    Write-Host "Error: SNMP Services Not Installed"
}

执行上述Powershell实施SNMP服务部署与配置,重启服务器才可以让SNMP Service完全生效。

检查SNMP Service服务状态。
在这里插入图片描述
在这里插入图片描述

[Zabbix配置]
Zabbix Server新建监控主机
导航路径:配置 > 主机 > 创建主机
在这里插入图片描述
主机配置 关键参数:
主机名称 > 此参数与监控主机主机名称一致;
代理地址 > 此参数与监控主机网络地址一致;
在这里插入图片描述

模板设置 [Template OS Windows SNMPv2]

在这里插入图片描述

检查确认新增监控状态
※ 如果失败,请检查[管理 > 一般 >宏]是否正常设置默认团体名。
在这里插入图片描述

导航路径:监控中 > 最新数据 > 主机过滤 [ZServer02]
在这里插入图片描述

#CactiEZ v10.1 install text cdrom mediacheck lang en_US.UTF-8 keyboard us rootpw CactiEZ firewall --service=ssh --service=snmp --service=http authconfig --enableshadow --passalgo=sha512 --enablefingerprint selinux --disabled timezone Asia/Shanghai network --bootproto=static --ip=192.168.0.32 --netmask=255.255.255.0 --gateway=192.168.0.1 --nameserver 8.8.8.8 --hostname=CactiEZ.local --noipv6 --onboot=yes bootloader --location=mbr zerombr yes clearpart --all --initlabel part /boot --fstype=ext4 --size=200 part pv.cZWdAb-3EW9-0foh-Bl0a-To6S-TJez-7moyho --grow --size=200 volgroup vg_cactiezv10 --pesize=4096 pv.cZWdAb-3EW9-0foh-Bl0a-To6S-TJez-7moyho logvol / --fstype=ext4 --name=LogVol00 --vgname=vg_cactiezv10 --grow --size=8192 logvol swap --name=LogVol01 --vgname=vg_cactiezv10 --size=1024 repo --name="CactiEZ" --baseurl=file:///mnt/source --cost=100 %packages --nobase --excludedocs @core @server-policy man file vim-enhanced openssh-clients lftp ftp wget curl elinks net-snmp-utils net-snmp httpd php mysql-server php-mysql php-gd expect ntp rsyslog-mysql pango system-config-network-tui %post --nochroot mkdir -p /mnt/sysimage/tmp/cactiez >> /tmp/ins.log 2>&1 cp /mnt/source/Packages/cactiez-i386.tgz /mnt/sysimage/tmp/cactiez >> /tmp/ins.log 2>&1 %post cd /tmp/cactiez >> /tmp/ins.log 2>&1 tar zxvf cactiez-i386.tgz >> /tmp/ins.log 2>&1 cp -rf /tmp/cactiez/var/www/html/* /var/www/html >> /tmp/ins.log 2>&1 cp -rf /tmp/cactiez/usr/* /usr >> /tmp/ins.log 2>&1 cp -rf /tmp/cactiez/etc/* /etc >> /tmp/ins.log 2>&1 service mysqld start >> /tmp/ins.log 2>&1 /usr/bin/mysqladmin --user=root create cacti >> /tmp/ins.log 2>&1 mysql -e "GRANT ALL ON cacti.* TO cactiuser@localhost IDENTIFIED BY 'cactiuser'" >> /tmp/ins.log 2>&1 mysql cacti > /tmp/ins.log 2>&1 chmod -R 777 /var/www/html/log/ chmod -R 7755 /var/www/html/rra/ chmod -R 755 /var/www/html/scripts/ chmod -R 755 /usr/local/spine/bin/ chmod -R 755 /usr/local/rrdtool/bin/ chown -R apache:apache /var/www/html/ echo '*/10 * * * * /usr/sbin/ntpdate 0.rhel.pool.ntp.org && /sbin/clock -w' > /tmp/crontab2.tmp echo '*/5 * * * * php /var/www/html/poller.php > /dev/null 2>&1' >> /tmp/crontab2.tmp crontab /tmp/crontab2.tmp rm /tmp/crontab2.tmp for service in httpd mysqld snmpd do chkconfig --level 235 $service on done #rm -rf /tmp/* %end
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值