Configuring SNMP agents on different Windows servers
Monitor your Windows servers agentless, with the support of SNMP. Simply install and configure SNMP agents on your servers, install an On-Premise Poller, and your server for monitoring.
Synopsis
- Installing and configuring SNMP agents on Windows 10 1803 or later
- Configuring SNMP agents on Windows Vista, Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows 8, Windows 8.1, Windows 10, Windows Server 2012, Windows Server 2012 R2, or Windows Server 2016 or later
- Configuring SNMP agents on Windows NT systems
- Configuring SNMP agents on Windows XP, Windows 2000, and Windows 2003 systems
- Testing SNMP agents on Windows
- PowerShell-based SNMP configuration
Installing SNMP agents on Windows 10 1803 or later
The SNMP service is not listed in the Windows features list in the Control Panel on Windows 10. Install the SNMP service directly from Microsoft servers using any of the three steps below:
- Optional Features graphical interface
- PowerShell
- DISM
Installing using the Optional Features graphical interface
- Go to the Settings > Apps > Apps & Features > Manage Optional Feature > Add Feature.
- Select the following from the list: Simple Network Management Protocol (SNMP) and WMI SNMP Provider (to get all SNMP service configuration tabs).
Installing using PowerShell
- Navigate to Start > Windows PowerShell folder > Windows PowerShell.
- Run the following command:
Add-WindowsCapability -Online -Name "SNMP.Client~~~~0.0.1.0"
Installing using DISM
- You can also use the deployment image servicing and management (DISM) tool. Go to Start > Command Prompt.
- Right-click the top result, and select Run as administrator.
- Execute the following command, and press Enter:
DISM /online /add-capability /capabilityname:SNMP.Client~~~~0.0.1.0
Configuring SNMP agents on Windows 10 1803 or later
- Navigate to Start > Settings > Control Panel.
- Under Administrative Tools, click Services.
- In the details pane, right-click SNMP Service and select Properties. If stopped, start the service by clicking the Start button, and change the Startup type to Automatic.
- In the Security tab, under Accepted community names, click Add.
- Under Community Rights, select a permission level for this host to process SNMP requests from the selected community.
- In Community Name, type a case-sensitive community name, and then click Add.
- Choose whether or not to accept SNMP packets from a host:
- To accept SNMP requests from any host on the network, regardless of identity, click Accept SNMP packets from any host.
- To limit accepting SNMP packets, click Accept SNMP packets from these hosts, and click Add. Then, type the appropriate host name, IP, or IPX address, and then click Add.
- Click Apply.
Configuring SNMP agents on Windows Vista, Windows 7, Windows Server 2008, Windows Server 2008 R2, Windows 8, Windows 8.1, Windows 10, Windows Server 2012, Windows Server 2012 R2, or Windows Server 2016 or later
- Go to the Control Panel. Click on Programs > Programs and Features, and then click on Turn Windows features on or off. If you’re prompted with User Account Control dialog box, click Continue or Yes (varies with versions).
- In Turn Windows features on or off, check the box next to Simple Network Management Protocol (SNMP) or SNMP feature (again, varies with versions) and click OK.
- After this, follow the steps given above for Configuring SNMP agents on Windows 10 1803 or later.
Configuring SNMP agents on Windows NT systems
- Navigate to Start > Settings > Control Panel.
- Under Administrative Tools, click Services.
- In the Details pane, right-click SNMP Service, and select Properties.
- Under Accepted community names, click Add.
- In the Community Names box, type the community name to authenticate SNMP requests.
- Click Add to move the community name to the list of Accepted Community Names.
- Repeat steps 6 and 7 to add more community names.
- Choose whether to accept SNMP packets from any host or only from specified hosts:
- Click Accept SNMP Packets From Any Host, if you wish to accept SNMP packets from any host with no IP restriction.
- Click Only Accept SNMP Packets From These Hosts if you wish accept SNMP packets only from specific hosts. To enter the desired hosts click Add; type the name or address of the host in IP Host or IPX Address box, and then click Add.
- Repeat step 9 to add more hosts.
- In the Agent tab, specify information like comments about the user, location, and services.
- Click OK to apply the changes.
The SNMP agent running on Windows NT does not respond to Host Resource Data by default. To support this you may need Windows NT service pack 6 or above. Check your pack details before following the steps below.
Note: Windows NT 4.0 server does not come with a Host Resource MIB.
If you are running Windows NT Service Pack 6a and use Windows 2000 server, then follow these steps:
- Copy the %SystemRoot%\System32\hostmib.dll file from the Windows 2000 server to %SystemRoot%\System32folder on your Windows NT 4.0 Server.
- C:\WinNT is the value for %SystemRoot%
- If you don't have Windows 2000 Server, then you can download the hostmib.dll file.
- If the above file isn't compatible on your machine, you may download the compatible version from https://www.pconlife.com/fileinfo/hostmib.dll-info/
- Run regedit or regedt32, and add the following keys and values:
- Key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HostMIB\CurrentVersion
- Value Name: Pathname
- Type: REG_SZ
- Data: C:\WinNT\system32\hostmib.dll
- Key: HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\ExtensionAgents
- Value Name: 3
- Type: REG_SZ
- Data: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\HostMIB\CurrentVersion
- For registering DLL using the Microsoft REGSVR utility, follow the steps below:
- Copy the file to C:\Windows\SysWOW64\ (for 32bit) or C:\Windows\System32\ (for 64bit)
- To complete this step, you should run Command Prompt as an administrator.
- Paste the following command into the Command Line window that opens, and press Enter.
%windir%\System32\regsvr32.exe hostmib.dll (for 32 bit)
%windir%\SysWoW64\regsvr32.exe hostmib.dll (for 64 bit)
- Restart your Windows NT box.
Configuring SNMP agent on Windows XP, Windows 2000, and Windows 2003 systems
- Navigate to Start > Settings > Control Panel.
- Under Administrative Tools, click Services.
- In the Details pane, right-click SNMP Service, and select Properties.
- Under Accepted community names, click Add.
- Under Community Rights, select a permission level for this host to process SNMP requests from the selected community.
- In Community Name, type a case-sensitive community name, and then click Add.
- Choose whether or not to accept SNMP packets from a host:
- To accept SNMP requests from any host on the network, regardless of identity, click Accept SNMP packets from any host.
- To limit accepting SNMP packets, click Accept SNMP packets from these hosts, and click Add. Then, type the appropriate host name, IP, or IPX address, and then click Add.
- Click Apply.
Testing SNMP on Windows
Test the SNMP reachability using MIB browser.
PowerShell-based SNMP configuration
In this section, we'll cover:
- Prerequisites for Remote Execution
- Installation using PowerShell
- Steps to enable SNMP on a Windows device using PowerShell
- Input parameters for script execution
- Script commands and usage
Prerequisites for Remote Execution
To create remote sessions and run remote commands, the local and remote machines must meet the below requirements.
1. System requirements
The following are the system requirements for script execution on remote machines.
- To run remote sessions on Windows PowerShell 3.0, the local and remote computers must have:
- Windows PowerShell 3.0 or later.
- Microsoft .NET Framework 4 or later.
- Windows Remote Management 3.0.
- To run remote sessions on Windows PowerShell 2.0, the local and remote computers must have:
- Windows PowerShell 2.0 or later.
- Microsoft .NET Framework 2.0 or later.
- Windows Remote Management 2.0.
2. User permission
By default, the current user needs to be a member of the administrators group on the remote computer or provide the credentials of an administrator.
3. Windows network/firewall permission
The remote connection from both the server and client side must not be blocked by the firewall.
4. Run as administrator
Administrator privileges are mandatory to enable and configure SNMP.
Installation using PowerShell
- Navigate to Start > Windows PowerShell folder > Windows PowerShell.
- Run the following command: Add-WindowsCapability -Online -Name "SNMP.Client~~~~0.0.1.0"
NOTE:
- Please confirm that the prerequisites for remote execution are met.
- Check if the host and client devices are available on the same network domain.
- Enable PSRemoting on remote devices that this particular script will be executed on. This can be executed with a Remote Desktop connection.
Steps to enable SNMP on a Windows device using PowerShell
- Download the SNMPEnabler.ps1 script.
- Open the Windows PowerShell utility as an administrator.
- Run the SNMPEnabler.ps1 script and provide the required input parameters.
- Execute the script with the inputs provided. It will automatically enable and configure SNMP on your local or remote devices.
Input parameters for script execution
The following input parameters can be processed by the script executions.
Input parameter | Usage | Default values | Required? | Example |
---|---|---|---|---|
h | Host name that the SNMP service needs to be enabled in. | - | Mandatory (if -f not given) | -h ben-3515 |
f | Part of the file that contains multiple hosts. File format: (XXXXX.txt) s24x7-dev1 localhost 192.21.23.1 ben-3515.zohocorpin.com | - | Mandatory (if -h not given) | -f D:\SNMP\hostlist.txt |
username | Username of the account used for remote access | - | Mandatory for remote machines, optional for the local host. | -username workgroup\administrator |
pass | Password of the account used for remote access | - |
Optional for the local host. Remote: It can be provided as an argument. You'll be asked for the password during remote execution. |
-pass password@987 |
onlyConfigure |
Used to configure the SNMP settings on already SNMP-enabled machines. Possible values are “true” or “false”. If “true”, the script will only go for configuration. |
false | Optional | -onlyConfigure true |
communityName | The SNMP community string that will be added after script execution. | public | Optional | -communityName networkcommunity |
snmpType |
Permission to be added from the community string. Allowed integer values: “1” - NONE “2” - NOTIFY “4” - READONLY “8” - READWRITE “16” - READCREATE |
4 | Optional | -snmpType 4 |
permittedHost | The host that needs SNMP access from the remote machine | The name of the default localhost machine that the script was executed from. | Optional | -permittedHost s24x7-dev7 |
debug |
Used for debugging.Possible values are “true” or “false”. |
false | Optional | -debug true |
Script Commands and Usage
1. Host-specific enabling
Options to enable and configure a single host with default or custom options.
Commands
1.1 To enable and configure SNMP (with default options) on a local machine:
Execute:.\SNMPEnabler.pst1 -h localhost
1.2 To enable and configure SNMP (with default options) on a remote machine:
Execute:.\SNMPEnabler.ps1 -h -username
1.3. To enable and configure SNMP (with custom input options) on a local machine:
Execute: .\SNMPEnabler.ps1 -h localhost -communityName -snmpType -permittedHost
1.4. To enable and configure SNMP (with custom input options) on a remote machine:
Execute:.\SNMPEnabler.ps1 -h -username -communityName -snmpType -permittedHost
1.5. To configure the community and permitted hosts on an SNMP-enabled local machine:
Execute.\SNMPEnabler.ps1 -h localhost -onlyConfigure true -communityName -snmpType -permittedHost
1.6. To configure the community and permitted hosts on an SNMP-enabled remote machine:
Execute.\SNMPEnabler.ps1 -h -username -pass -onlyConfigure true -communityName -snmpType -permittedHost
2. Bulk enabling (using an input file containing hosts)
By passing the file path that contains a list of hosts, you can enable and configure SNMP for multiple servers.
Commands
2.1 To enable and configure SNMP (with default options) on multiple local or remote machines:
Execute:.\SNMPEnabler.ps1 -f -username
2.2 To enable and configure SNMP (with custom options) on multiple local or remote machines:
Execute:.\SNMPEnabler.ps1 -f -username -communityName -snmpType -permittedHost
2.3 To configure the community and permitted hosts on SNMP-enabled local or remote machines:
Execute:.\SNMPEnabler.ps1 -f -username -onlyConfigure true -communityName -snmpType -permittedHost