I am using Mikrotik’s the DUDE monitoring
tool since many years to monitor my Company’s Server’s and devices
health, Recently I decided to add users subnet also on the server’s sub
map to view online/offline users, there CPU / Memory/ HDD usage, personnel printers health and tons of other info.
As we all knows that for this purpose SNMP service is required on the target Windows OS. The problem was that there were over 120 nodes and I didn’t wanted to visit them each physically or didn’t wanted to take there remote to install SNMP due to some permission issues. After some googling I found one way to install SNMP
service right from my admin pc by doing some fine tuning and tweaks of
various commands using pstools. It’s not neat and clean , also it
requires some manual work to do, but it does the job. Once you get used
to it, you will find it relatively easy to deploy snmp using various
method, Either its dos base batch file (that I personally use) , OR its
VBS file, or running it via GPO or any other method. ! Every method works for sure.
[Remember in this example , I am using this
technique in Active directory domain environment, and using domain
administrator account to login to my admin pc windows, ]
First download pstools utility from following location
http://download.sysinternals.com/files/PSTools.zip
Extract it any any folder, e.g
c:\pstools
Now open command prompt , and navigate to pstools directory , e.g
cd \pstools
Adding SNMP Service remotely on Windows 7
Use the below command to initiate snmp service installation on remote windows 7 client pc.
1
| PsExec.exe \\syedjz -s -i -d ocsetup.exe SNMP |
You can use the following batch file to create public string on the client pc , right from your desktop.
First create a batch file name change_snmp_String.bat , open notepad , and paste the following text.
1
2
3
4
5
6
7
| @echo off cls reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters" /v EnableAuthenticationTraps /t REG_DWORD /d 0 /f reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v 1 /t REG_SZ /d 10.1.1.1 /f reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\PermittedManagers" /v 2 /t REG_SZ /d 10.1.1.2 /f reg add "HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\SNMP\Parameters\ValidCommunities" /v public /t REG_DWORD /d 4 /f cls |
Now save this file with the name of change_snmp_String.bat (Make sure file name ends with .bat, as notepad adds .txt extension, you have to remove it by selecting ALL FILES in file type, or rename it afterward, grrrrrrr)
Save this file in any shared folder of your system, a folder that every one can access easily , preferably file server location.
Now from command prompt and within pstools directory, use the below command to initiate above batch file so that it can change the snmp string from blank to public and allow our monitoring server IP’s to query the snmp service.
1
| PsExec.exe \\syedjz -s -i -d \\fileserver\softwares\TOOLS_RELATED\snmp\change_snmp_String.bat |
1
| PsExec.exe \\syedjz -u mydomain\administrator -p ponka cmd "/c \\fileserver\softwares\TOOLS_RELATED\snmp\change_snmp_String.bat" |
To install SNMP on local Windows 7 PC using CLI, use the below command
1
| start /w ocsetup.exe SNMP |
Adding SNMP Service remotely on Windows XP/2003
Adding snmp service on Remote Windows XP is a bit
tricky and require some manual work to do, Once you manage to get it
working, you can then wrap all command in one single file and use this
file to install SNMP service via single file by monitoring target pc
name only. Ok Let’s Start . . .Create new file name snmp.inf with the following contents
(This file will be used for ocsetup to instruct that it should install snmp service)
1
2
3
4
5
| [Components] NetOC=ON [NetOptionalComponents] SNMP=1 |
Now Copy windows CD contents to any shared folder on your file sharing server or local PC. Copy the whole CD, which will be required at the time of snmp service installation.
e.g:
Now create a registry file name winpath.reg with the following contents [This file will be used on remote xp to update the windows xp registry for XP setup source files , which will be required at the time of snmp service installation.]
Make sure you change the path defined in the below script to match your local location.
1
2
3
4
5
| Windows Registry Editor Version 5.00 [HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows\CurrentVersion\Setup] "SourcePath"="\\\\file-server\\zaib-XP-LIC-SP2" "ServicePackSourcePath"="\\\\file-server\\zaib-XP-LIC-SP2" |
Now execute the following command Which will add the windows source path to the client windows XP registry
(You must have pstools in c:\pstools folder, as explained in windows 7 section above)
1
| PsExec.exe \\syedjz cmd "/c reg import C:\winpath.reg" |
1
| PsExec.exe \\syedjz -s -i -d sysocmgr /i:%windir%\inf\sysoc.inf /u:\\files-server\softwares\TOOLS_RELATED\snmp\snmp.inf /x /q |
Remember, I only explained the raw method of doing snmp installation on remote pc’s. There are many other fine tuned method to perform this action. You can adopt whatever you like. Following are 2 batch files that do job via batch file, so you don’t’ have to type he whole commands, just type the batch file and the target PC name,
For Windows 7 , We will use two batch file.
1- win7_snmp_install.bat
2- win7_snmp_string.bat
One that will install SNMP Service on remote win 7,
1
| PsExec.exe \\%1 -s -i -d ocsetup.exe SNMP |
1
| PsExec.exe \\%1 -s -i -d \\file-server\softwares\TOOLS_RELATED\snmp\change_snmp_String.bat |
e.g: win7_snmp_install.bat clientpcname
For Windows XP, Single Batch file will be enough
1- winXP_snmp_install.bat
1
2
3
4
5
6
7
8
9
10
11
12
| @echo off cls copy /Y "C:\snmp\winpath.reg" "\\%1\c$" echo. echo. PsExec.exe \\%1 cmd "/c reg import C:\winpath.reg" echo. echo. PsExec.exe \\%1 -s -i -d sysocmgr /i:%windir%\inf\sysoc.inf /u:\\file-server\softwares\TOOLS_RELATED\snmp\snmp.inf /x /q echo. echo. echo All Done, Hopefully. Script by Syed Jahanzaib |
e.g: winxp_snmp_install.bat clientpcname
Regard’s
naveed ahmad
0 comments:
Post a Comment