[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 452
  • Last Modified:

Any way to assign the SNMP ip address in the list of machines

Hi,

Is there Any way to assign the SNMP ip address in the list of machines.

Regards
Sharath
0
bsharath
Asked:
bsharath
  • 8
  • 3
  • 3
  • +1
1 Solution
 
dhoffman_98Commented:
What list of machines? What are you trying to do?
You really need to take some more time to give more information in your questions.
0
 
bsharathAuthor Commented:
All machines in my network are enabled with SNMP service.What i need is need to set a trap.So i need to give the community name and ip address in the SNMP service.

I have all the machine names in the list.

So need a script to query the list and enter the comunity and ip address in the service.

Regards
Sharath
0
 
fgandeCommented:
If all the machines are already in the list of snmp trap targets, with the appropriate community name, then you have already set up the trap sending functionality correct.

If you have entered the snmp trap targets before adding the community name to the trap target list, you will have to do it again with the correct community name.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
bsharathAuthor Commented:
I just have installed SNMP but havent put in the ip and comunity name.What i want is a script which can find all machines in the file and add the ip and comunity name to those machines.
0
 
fgandeCommented:
Well, the SNMP trap destinations get stored in the registry as keys under HKEY_LOCAL_MACHINE\SYSTEM\ControlSet001\Services\SNMP\Parameters\TrapConfiguration\<community name> . The keys are numbered as 1,2,3 and so on, and contain the ip adress of the target as a string (reg_sz). I guess it is possible to make a script that automatically adds the information from your textfile to the registry, but I don't have such a script, it has to be custom made I think.
0
 
bsharathAuthor Commented:
Any help...
0
 
bsharathAuthor Commented:
Any help....
0
 
fgandeCommented:
I'm unable to make such a script to automate the process 100% for you, but you could make it work with some copy&paste work to a registry file. Just export the registry settings as I described in my previous post, and copy&paste new ip's using the same format, then import it to the registry.

Keep in mind that you have to be careful when editing the registry, so only do this if you are confident with what you are doing.
0
 
Farhan KaziSystems EngineerCommented:
:: ================
:: READ THIS FIRST
:: ================
:: * To run this script you must have domain administrators rights.
:: * This script require "PSExec.exe" file (comes with PSTools) on C: drive root
:: * This script require "Computers.txt" file on C: drive root from where it will pick computer names.
:: * Following inputs are required to run the script successfully
::            SET snmpCS=public                  <-- SNMP Community string
::            SET snmpTDst=172.16.96.11  <-- SNMP Trap Destination IP
:: * Successful run will generate "C:\SNMPReport.txt" file on C: drive root.
:: * Copy and Paste following script into notepad and save it with any name having .cmd extension.
:: Batch Script Start

@Echo Off
SETLOCAL
:: SET Following variabled
SET snmpCS=public
SET snmpTDst=172.16.96.11

IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%R IN (C:\Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\SNMPReport.txt DEL /F /Q C:\SNMPReport.txt

(
Echo Windows Registry Editor Version 5.00
Echo.
Echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\%snmpCS%]
Echo "1"="%snmpTDst%"
)>C:\SNMPSetup.reg

IF NOT EXIST C:\SNMPSetup.reg (
      Echo Unable to create Proxy.reg file on C: drive root.      
      Goto :EndScript
)

FOR /F "delims=#" %%c IN ('Type C:\Computers.txt') Do (
    Echo Processing: %%c
    Echo Computer Name: %%c            >>C:\SNMPReport.txt
    Copy /Y C:\SNMPSetup.reg \\%%c\C$\ >>C:\SNMPReport.txt
    PSExec \\%%c -s -i Regedit /S C:\SNMPSetup.reg >>C:\SNMPReport.txt
    DEL /Q /F \\%%c\C$\SNMPSetup.reg >>C:\SNMPReport.txt
)      

Goto EndScript
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
IF EXIST C:\SNMPSetup.reg DEL /F /Q C:\SNMPSetup.reg
ENDLOCAL
:: Batch Script End
0
 
bsharathAuthor Commented:
farhan

In the SNMP report i get this.

Computer Name: dev-chen-mrd100            
        1 file(s) copied.
Computer Name: indiasophos            
        1 file(s) copied.

But these 2 machines do not have SNMP installed at all.Can you add a check if Snmp is not installed in the results to mention that it is not installed....
0
 
bsharathAuthor Commented:
Farhan.

I just installed SNMP in Indiasophos and it worked great.Thanks a lot but just need a addition of giving results if it fails to add the ip or if it finds SNMP is not intalled.
0
 
Farhan KaziSystems EngineerCommented:
OK will be back in few hours.
0
 
bsharathAuthor Commented:
Thanks...
0
 
bsharathAuthor Commented:
0
 
Farhan KaziSystems EngineerCommented:
:: ================
:: READ THIS FIRST
:: ================
:: * To run this script you must have domain administrators rights.
:: * This script require "PSExec.exe" file (comes with PSTools) on C: drive root
:: * This script require "Computers.txt" file on C: drive root from where it will pick computer names.
:: * Following inputs are required to run the script successfully
::            SET snmpCS=public                <-- SNMP Community string
::            SET snmpTDst=172.16.96.11  <-- SNMP Trap Destination IP
:: * Successful run will generate "C:\SNMPReport.txt" file on C: drive root.
:: * Copy and Paste following script into notepad and save it with any name having .cmd extension.
:: Batch Script Start

@Echo Off
SETLOCAL
:: SET Following variabled
SET snmpCS=public
SET snmpTDst=172.16.96.11

IF NOT EXIST C:\Computers.txt Goto ShowErr
FOR %%R IN (C:\Computers.txt) Do IF %%~zR EQU 0 Goto ShowErr
IF EXIST C:\SNMPReport.txt DEL /F /Q C:\SNMPReport.txt

(
Echo Windows Registry Editor Version 5.00
Echo.
Echo [HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\SNMP\Parameters\TrapConfiguration\%snmpCS%]
Echo "1"="%snmpTDst%"
)>C:\SNMPSetup.reg

IF NOT EXIST C:\SNMPSetup.reg (
      Echo Unable to create Proxy.reg file on C: drive root.      
      Goto :EndScript
)

FOR /F "delims=#" %%c IN ('Type C:\Computers.txt') Do (
    Echo Processing: %%c
      Echo Computer Name: %%c >>C:\SNMPReport.txt
      SC \\%%c Query SNMP | Find /I "SERVICE_NAME:" >NUL
      IF NOT ErrorLevel 1 (
            Copy /Y C:\SNMPSetup.reg \\%%c\C$\ >>C:\SNMPReport.txt
            PSExec \\%%c -s -i Regedit /S C:\SNMPSetup.reg >>C:\SNMPReport.txt
            DEL /Q /F \\%%c\C$\SNMPSetup.reg >>C:\SNMPReport.txt) ELSE (
            Echo SNMP Service not installed. >>C:\SNMPReport.txt)
)      

Goto EndScript
:ShowErr
Echo "C:\Computers.txt" file does not exist or file is empty!
:EndScript
IF EXIST C:\SNMPSetup.reg DEL /F /Q C:\SNMPSetup.reg
ENDLOCAL
:: Batch Script End
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 8
  • 3
  • 3
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now