summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorytti <saku@ytti.fi>2015-06-24 23:10:17 +0300
committerytti <saku@ytti.fi>2015-06-24 23:10:17 +0300
commit4251ab700db12b0cf0197d1d43caa57a80ac214e (patch)
tree9e351eb13a3223e3b4f2fbd01e79ffd01fe155b6
parent441551400fb70ef93833917802bf799811ace7d4 (diff)
parentc24e663875f0258e3fd7c3c8e735e8b3fdfff62b (diff)
Merge pull request #140 from RichiH/feature/docs-output_types
README.md: Introduce docs for output types
-rw-r--r--README.md47
1 files changed, 47 insertions, 0 deletions
diff --git a/README.md b/README.md
index 8e8c1ae..e5564ec 100644
--- a/README.md
+++ b/README.md
@@ -31,6 +31,7 @@ Oxidized is a network device configuration backup tool. It's a RANCID replacemen
* [Source: HTTP](#source-http)
* [Output: GIT](#output-git)
* [Output: File](#output-file)
+ * [Output types](#output-types)
* [Advanced Configuration](#advanced-configuration)
6. [Ruby API](#ruby-api)
* [Input](#input)
@@ -266,6 +267,52 @@ output:
repo: "/var/lib/oxidized/devices.git"
```
+### Output types
+
+If you prefer to have different outputs in different files and/or directories, you can easily do this by modifying the corresponding model. To change the behaviour for IOS, you would edit `lib/oxidized/model/ios.rb`.
+
+For example, let's say you want to split out `show version` and `show inventory` into separate files in a directory called `nodiff` which your tools will not send automated diffstats for. You can apply a patch along the lines of
+
+```
+- cmd 'show version' do |cfg|
+- comment cfg.lines.first
++ cmd 'show version' do |state|
++ state.type = 'nodiff'
++ state
+
+- cmd 'show inventory' do |cfg|
+- comment cfg
++ cmd 'show inventory' do |state|
++ state.type = 'nodiff'
++ state
++ end
+
+- cmd 'show running-config' do |cfg|
+- cfg = cfg.each_line.to_a[3..-1].join
+- cfg.gsub! /^Current configuration : [^\n]*\n/, ''
+- cfg.sub! /^(ntp clock-period).*/, '! \1'
+- cfg.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*(
++ cmd 'show running-config' do |state|
++ state = state.each_line.to_a[3..-1].join
++ state.gsub! /^Current configuration : [^\n]*\n/, ''
++ state.sub! /^(ntp clock-period).*/, '! \1'
++ state.gsub! /^\ tunnel\ mpls\ traffic-eng\ bandwidth[^\n]*\n*(
+ (?:\ [^\n]*\n*)*
+ tunnel\ mpls\ traffic-eng\ auto-bw)/mx, '\1'
+- cfg
++ state = Oxidized::String.new state
++ state.type = 'nodiff'
++ state
+```
+
+which will result in the following layout
+
+```
+diff/$FQDN--show_running_config
+nodiff/$FQDN--show_version
+nodiff/$FQDN--show_inventory
+```
+
### Advanced Configuration
Below is an advanced example configuration. You will be able to (optinally) override options per device. The router.db format used is ```hostname:model:username:password:enable_password```. Hostname and model will be the only required options, all others override the global configuration sections.