Skip to main content

Hello:

I have a simple Qapp that grabs device configs from our domain and outputs them to a CSV file. The Qapp uses the built in full config parser. I am struggling with the syntax to add the current date and device IP for each config in the output.

Any help is appreciated.

Thanks,

Chris

 

 

 

Hi ​@Cpillitteri Chris,

looks like NetBrain forgot to put a variable on the date-time stamp of the configuration, maybe you can ask NB to add that?

As an alternative you can use the timestamp from the last time the config was pulled by NB.
Try adding a script to your qapp with this code.

from netbrain.sysapi import devicedata
import time


for device in $this:
    in_api = devicedata.GetBaselineConfig(device)
    data_age = in_api['time']
    if data_age:
        time_local = time.localtime(data_age)
        dt = time.strftime("%Y-%m-%d %H:%M:%S",time_local)
        $Data.AddOneRow({'device_name':device, 'age':dt})