Forum Discussion

Greg_Robinson_1's avatar
Feb 05, 2015

iCall script to save the configuration to disk if any changes occur

I need a way for the F5 to periodically save the configuration to disk. We have a very dynamic environment with configuration changes occurring quite often and its vital to us that, say both devices in a config-sync pair reboot simultaneously due to power loss, any recent configuration changes are committed.

 

I've written an iCall script/handler that looks at the timestamp on the /config/BigDB.dat file and compares that to the timestamp on the /config/bigip.conf file. If the BigDB.dat file is newer, it issues the TMSH save sys config command. My question is whether or not the BigDB.dat file is a valid reference to trigger upon, or if there is a better TMSH command that can provide parsable output to know when a save is required for changes.

 

sys icall handler periodic testForConfigChanges { interval 5 script f5.backupOnChanges }

 

sys icall script f5.backupOnChanges { app-service none definition { set dbfile_timestamp [exec stat /config/BigDB.dat --format %Z] set conffile_timestamp [exec stat /config/bigip.conf --format %Z] if { $dbfile_timestamp > $conffile_timestamp } { tmsh::save sys config partitions all } } description none events none }

 

2 Replies

  • We are facing a similar problem, and save-on-auto-sync was not the solution as it effectively killed the box on bulk changes (of data groups). So while I cannot answer your question (though by observation it seems that BigDB.dat is a valid reference file), I am also interested in a solution and thankful for your initial version (though 5 seconds is a bit too short for our setup).

     

  • JRahm_128324's avatar
    JRahm_128324
    Historic F5 Account

    From Greg...

    Got it!

    Modify the 120 to whatever interval you want to look for changes, in seconds.

    sys icall handler periodic F5.AutoSaveConfigScheduledTask {
        interval 120
        script F5.SaveConfig.OnlyIfModified
    }
    

    Here we are checking the BigDB.dat file to see if its been updated since the configuration was last saved. If so, we save the configuration to disk.

    sys icall script F5.SaveConfig.OnlyIfModified {
        app-service none
        definition {
            set dbfile_timestamp [exec stat /config/BigDB.dat --format %Z]
            set conffile_timestamp [exec stat /config/bigip.conf --format %Z]
            if { $dbfile_timestamp > $conffile_timestamp } {
                tmsh::save sys config partitions all 
                }
        }
        description none
        events none
    }