Skip to main content
Question

NQE Query for F5 NTP Server details from config, Please help us to collect this data.

  • October 29, 2024
  • 4 replies
  • 89 views
  • Translate

Forum|alt.badge.img+2

NQE Query for F5 NTP Server details from config, Please help us to collect this data.

4 replies

StewS64
Employee
  • Employee
  • 2 replies
  • October 29, 2024

Hi Rohit,

Firstly, what version are you running?

 

Regardless of your version, the collection of NTP configuration will require a custom command. 

For later versions, it looks like the the command for listing the currently defined NTP servers is list /sys ntp servers

However, I prefer the output of ntpq -np which verifies the status of the NTP.

Could you please run both of these commands and show the outputs?

This will help us create the NQE for you.

 

Stewart

Translate

Christopher
Employee
Forum|alt.badge.img+3
  • Employee
  • 20 replies
  • October 29, 2024

To look at the configured NTP servers, you could use the custom command list sys ntp

and an NQE query like this:

pattern = ```
sys ntp 
    servers {server1:string} {server2:string} 
```;

getServers(device) =
 foreach command in device.outputs.commands
where command.commandText == "list sys ntp" 
let filtered_response = replace(command.response, "{", "")
let filtered_response = replace(filtered_response, "}", "")
let blocks = parseConfigBlocks(OS.F5, filtered_response)
foreach match in blockMatches(blocks, pattern)
 select {server1: match.data.server1, server2: match.data.server2
 };

foreach device in network.devices
where device.platform.os == OS.F5
select {
    device: device.name,
    os: device.platform.os,
    server1: max(getServers(device)).server1,
    server2: max(getServers(device)).server2

}

 

Translate

Forum|alt.badge.img+2

Now we are collecting the data via Custom command , we are using same query to get the information ,we are getting below error.

 

error - Address the following issues:

  • Line 21, character 14: Cannot select field 'server1' from null value. Consider either replacing '.' with '?.' to return null or using isPresent() to check whether the value is present before selecting a field from the value.
Translate

Christopher
Employee
Forum|alt.badge.img+3
  • Employee
  • 20 replies
  • November 26, 2024

You can change the code to be 

server1: max(getServers(device))?.server1,
server2: max(getServers(device))?.server2

Adding the “?” allows us to display a result with a null value.

Translate

Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings