I believe that this should be possible. I am looking to create a script for FortiGate firewalls. The script would pull two variables from the database based on Node ID. The first variable is the polling IP address of the node and then a custom field, also based on the Node ID.
For example:
Node name: FN-OAK entered as a node as part of ContextNode
Polling IP: 10.30.10.1 from database
Entity Code: OAK from database
SNMP collectors: 10.10.1.122 10.10.1.78 set IP addresses
What I am looking to do is to create a script that will do the following (multiple times for many different :
config system snmp community
edit 1
set host-type trap
set ip 10.10.1.122 255.255.255.255
set source-ip 10.30.10.1
next
edit 2
set host-type trap
set ip 10.10.1.78 255.255.255.255
set source-ip 10.30.10.1
end
set name "OAK"
next
end
Here is what I have so far. Problem is that the system is asking for the IP and Entity Code. From what I can tell from documentation I have looked at, this should be possible though I have not found the proper format yet.
/*
.CHANGE_TEMPLATE_DESCRIPTION
Change SNMP traps to SolarWinds to polling IP
.CHANGE_TEMPLATE_TAGS
Fortigate, Fortinet, SNMP, source
.PLATFORM_DESCRIPTION
FortiGate
.PARAMETER_LABEL @ContextNode
NCM Node
.PARAMETER_DESCRIPTION @ContextNode
The node the template will change the loopback address as the SNMP source
.PARAMETER_LABEL @SiteCode
Site Entity Code
.PARAMETER_DESCRIPTION
Entity code of Node
*/
script ChangeSNMPSourceFortiGate (
NCM.Nodes @ContextNode,
NCM.Nodes[] @IP_ADDRESS,
NCM.Nodes[] @Entity_Code
)
{
CLI
{
config system snmp community
edit 1
config hosts
edit 1
set host-type trap
set ip 10.10.1.122 255.255.255.255
set source-ip @IP_ADDRESS
next
edit 2
set host-type trap
set ip 10.10.1.78 255.255.255.255
set source-ip @IP_ADDRESS
end
set name "@Entity_Code"
next
end
}
}