Skip to main content

Team ,

we are using belong NQE to get the information about Fortinet Firewall SNMP config and server white list information , however NQE provide the result , but devices are repeating ,ex, 1 devices we can see approx. 44 entry ,

 

can you please have a look on this and help us to fix .

 

 

NQE Query 

 


 

// Patterns to match

 

pattern_community= ```

config system snmp community

    edit {string}

        set name {community:string}

        config hosts

            edit {string}

                set ip {ip:string} {netmask:string}

            next

 

```;

 

 

foreach device in network.devices

let outputs = device.outputs

 

foreach command in outputs.commands

where command.commandType == CommandType.CUSTOM

where command.commandText == "show system snmp community"

let central_mgmt = parseConfigBlocks(OS.FORTINET, command.response)

 

// Search for the ""pattern_fmg" pattern looking for a match

foreach match in blockMatches(central_mgmt, pattern_community)

//loop through the all server-address IP's and store them in variable "servers"

let servers = (foreach server in blockMatches(central_mgmt, pattern_community)

                  where server.data.ip == server.data.ip

                  select server.data.ip)

where !matches(device.name, "*_*")

 

// Produce the results

select {

  "Device Name":      device.name,

  "Server 2":        servers

}

Hi ​@Rohit_809 Kumar ,

I think you can get rid of the duplicate rows by removing the “foreach match in blockMatches(central_mgmt, pattern_community)” line in your query.


Reply