We often get asked by users if there is a quick and easy way to enable SNMP on a lot of servers. It’s easy enough to add the server manually if you are only doing this for a handful of machines. But if you have a large server environment you are responsible for, this isn’t manageable. Using a combination of freely available tools, you can greatly simplify this process.

1. Download and install PsTools from Microsoft (Windows Sysinternals), specifically, you will need PsExec. PsExec allows you to execute commands against remote machines. Install this on your workstation, then you can run commands against the remote servers without needing to log in to them directly. You can click here for more information about PsExec and here for more information about Windows Sysinternals. These are essential tools for any systems administrator.

 

Happy Cloud

 

2. Depending on the OS, you will also be using one of Microsoft’s built in tools, sysocmgr or ocsetup. These tools enable you to install Windows components unattended directly from a command line and are part of the Windows distribution. You can find more information about sysocmgr here. For enabling SNMP on Windows Server 2008, you should use Microsoft’s ocsetup tool. You can find more information about that tool here.

 

If you want to enable SNMP on a Windows 2008 Server, simply follow these steps:

We will need to build the argument string you will pass to psexec. Here is an example string. You will need to replace all UPPERCASE words with the values relevant for your environment.

psexec \\COMPUTER –u USER –p PASSWORD “start ocsetup snmp /quiet /norestart”

If you have a list of computers, instead of specifying the individual computer name, simply put in a file name instead of the computer name. For example, if I had a file called “server.txt” which contained a list of servers (one per line), my command would look like this

psexec @servers.txt –u USER –p PASSWORD “start ocsetup snmp /quiet /norestart”

Notice the @ before the filename, make sure you add this. See the psexec documentation for more information. The username and password should be an account that has access the the machine you are attempting to install this on.

 

To install on an older OS (Server 2000 and 2003, XP), you will need to use sysocmgr.

psexec \\COMPUTER –u USER –p PASSWORD “sysocmgr /i:%SystemRoot%\inf\sysoc.inf /u:\\NETWORKSHARE\InstallSNMP.txt /x /q /r”

Sysocmgr requires a configuration file. In my example, I put the InstallSNMP.txt file on a network share so I didn’t need to copy the file to the local server each time. This should be a simple text file with the following commands:

[Components]
netoc = on
[NetOptionalComponents]
SNMP = 1

The /r means, do not reboot automatically. You can find the full command options by simply opening a prompt and typing sysocmgr. This also assumes the i386 folder is available in the locally define default path.

 

As always, you should test this on a small inconspicuous area of your network before applying to the whole surface :-)

Oh, and if you are interested in monitoring servers, you should probably check out our Application Performance Monitor product.