Skip to main content

we are using below NQE Query to get the NTP Server details , i need to remove some static value in  server coloum,

 

ciscontppattern=

```

 

ntp server {server:string}

```;

getServers(device) =

  foreach match in blockMatches(device.files.config, ciscontppattern)

 

  select { serverIP: match.data.server};

 

foreach device in network.devices

let platform = device.platform

where device.platform.vendor == Vendor.CISCO

 

 

select {

  device: device.name,

   vendor: device.platform.vendor,

    tags: device.tagNames,

    os: device.platform.os,

    OSVersion :platform.osVersion,

  servers: (foreach server in getServers(device)

            select server.serverIP)

}

 

 

Example : i dont want to show entry those have server value - “Inte”

@Rohit_809 Kumar Have you tried matches 
 

vals = l"preSomeName", "SomeNamepost", "other"];

matchTest = s"pre*", "*post"];

foreach v in vals
foreach m in matchTest
select { v: v, m: m, r: matches(v, m) }



 

 


@Rohit_809 Kumar There will be a few ways to handle this.  Gary mentioned on.  I’ll try to show another

 

You could use an “if” statement to make adjustments to the server names.

 

let serverName = if matches(match.data.server, “Inte*”)

                                   then suffix(match.data.server, length(match.data.serve) - 4)

                                  else match.data.server

 

This way only if the server name starts with “Inte” then you will use the “suffix” function to but of the “Inte” letters.  If it does not start with “Inte” then you don’t need to do anything.

 

This function suffix(match.data.server, length(match.data.serve) - 4).  The thing here is that I don’t know how long the full server name is.  So I use “length(match.data.serve) - 4” to say that starting from the back end of the server name, show me all but the first 4 characters.


Reply