I'm not aware of a good way to check this outside of clish. This is the best I've been able to do:
[Expert@DallasSC]# clish -c "show config-state" | egrep -v "^(CLINFR0771|$)"
saved
[Expert@DallasSC]# clish -c "set ntp active off"
[Expert@DallasSC]# clish -c "show config-state" | egrep -v "^(CLINFR0771|$)"
unsaved
I started another SSH session and went into clish after making the NTP change and before running the second 'show config-state', so the database was locked by that session.
Fairly ugly. The egrep filters out the "Config lock is owned by ..." line and the blank line it prints. Easy enough to turn into a boolean value by piping it to 'grep -q "unsaved"'. Exit code 0 for unsaved, 1 for saved. 'grep -qv "unsaved"' flips the logic: 1 for unsaved, 0 for saved. Here's an example. In each output block, the first is from a bare 'clish -c "show config-state"', the second is from the command above, and the third uses the 'grep -dv "unsaved"' to demonstrate turning it into something you can use directly with test.
[Expert@DallasSC]# echo "----------";clish -c "show config-state";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)" | grep -qv unsaved;echo $?
----------
saved
----------
saved
----------
0
[Expert@DallasSC]# clish -c "set ntp active off"
[Expert@DallasSC]# echo "----------";clish -c "show config-state";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)" | grep -qv unsaved;echo $?
----------
unsaved
----------
unsaved
----------
1
[Expert@DallasSC]# echo "----------";clish -c "show config-state";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)";echo "----------";clish -c "show config-state" | egrep -v "^(CLINFR0771|$)" | grep -qv unsaved;echo $?
----------
CLINFR0771 Config lock is owned by admin. Use the command 'lock database override' to acquire the lock.
unsaved
----------
unsaved
----------
1