Examples of using the <CONFIG> tag

296 views
Skip to first unread message

Jamie Getty

unread,
Aug 5, 2019, 1:28:02 AM8/5/19
to klish
Hey there. I'm looking to gain an understanding on the <CONFIG> tag ,and by extension, some understanding on konfd.

I want to generate a running configuration of my device, by logging each command that the user enters. Hopefully, we can then use this config to set the device to an earlier state.

I thought it would be as simple as adding the tag "<CONFIG operation="set"/> in the relevant .xml file, but that doesn't seem to be enough to log the command. I know there's a daemon called konfd that records commands, but I'm not sure how to utilize that.

What steps do I need to start logging user commands?

Jamie Getty

unread,
Aug 5, 2019, 7:02:46 PM8/5/19
to klish
Currently, I am using a command called "capture start" to begin logging commands. This command uses a config tag to start konfd as such:

 <COMMAND name="capture start"
                     help="Start CLI commands capturing">
   <ACTION>rm -f ${capfile}; /sbin/konfd; cfg_stopped=0; sleep 1</ACTION>
   <CONFIG operation="unset" pattern="^configure" file="${capfile}"/>
 </COMMAND>


However, from now on, I want to log all commands, starting from boot.
I thought about calling konfd from the startup XML file, but since the <STARTUP> tag doesn't let you nest <CONFIG> tags inside it, I don't know how to properly configure konfd from here.

Serj Kalichev

unread,
Aug 6, 2019, 4:28:47 AM8/6/19
to kl...@googlegroups.com
There is a special hook type for logging.
<HOOK name="log" builtin="hook_log@my_plugin"/>
You can write your own klish plugin, define a hook for logging with function type
CLISH_HOOK_LOG.
The "config" hook is for something like cisco's running-config, not for logging.

06.08.2019 2:02, Jamie Getty пишет:
--
You received this message because you are subscribed to the Google Groups "klish" group.
To unsubscribe from this group and stop receiving emails from it, send an email to klish+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/klish/0a65d894-4ccd-470e-bda0-160a39bc7116%40googlegroups.com.


Jamie Getty

unread,
Aug 6, 2019, 6:08:22 AM8/6/19
to klish
Thank you for the advice. Still, I think it would do good for me to get a better understanding of how konfd and konf work.

If I did want to do a cisco-style running config for all commands, what is the best way to start konfd, and the best way to log to the running config?

Serj Kalichev

unread,
Aug 6, 2019, 6:23:42 AM8/6/19
to kl...@googlegroups.com
To implement cisco-like running-config you need to execute konfd daemon. The klish (clish binary) can interact with it using CONFIG options. The konf utility is just a simple utility to interact with konfd daemon using shell (testing for example).

06.08.2019 13:08, Jamie Getty пишет:
Thank you for the advice. Still, I think it would do good for me to get a better understanding of how konfd and konf work.

If I did want to do a cisco-style running config for all commands, what is the best way to start konfd, and the best way to log to the running config?
--
You received this message because you are subscribed to the Google Groups "klish" group.
To unsubscribe from this group and stop receiving emails from it, send an email to klish+un...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages