bsharath
asked on
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
Is there Any way to assign the SNMP ip address in the list of machines.
Regards
Sharath
ASKER
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
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
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.
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.
ASKER
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.
Well, the SNMP trap destinations get stored in the registry as keys under HKEY_LOCAL_MACHINE\SYSTEM\ ControlSet 001\Servic es\SNMP\Pa rameters\T rapConfigu ration\<co mmunity 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.
ASKER
Any help...
ASKER
Any help....
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.
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.
:: ================
:: 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 \CurrentCo ntrolSet\S ervices\SN MP\Paramet ers\TrapCo nfiguratio n\%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
:: 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
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
ASKER
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....
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....
ASKER
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.
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.
OK will be back in few hours.
ASKER
Thanks...
ASKER
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You really need to take some more time to give more information in your questions.