oxidized 0.28.0 → 0.29.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (140) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/publishdocker.yml +8 -1
  3. data/.github/workflows/ruby.yml +42 -0
  4. data/.rubocop.yml +30 -10
  5. data/.rubocop_todo.yml +95 -41
  6. data/CHANGELOG.md +139 -2
  7. data/Dockerfile +13 -9
  8. data/README.md +66 -32
  9. data/Rakefile +2 -0
  10. data/docs/Configuration.md +49 -7
  11. data/docs/Creating-Models.md +10 -4
  12. data/docs/Hooks.md +35 -6
  13. data/docs/Model-Notes/ADVA.md +12 -0
  14. data/docs/Model-Notes/Cumulus.md +7 -1
  15. data/docs/Model-Notes/IOS.md +36 -0
  16. data/docs/Model-Notes/JunOS.md +3 -3
  17. data/docs/Model-Notes/LenovoNOS.md +29 -0
  18. data/docs/Model-Notes/LinksysSRW.md +15 -0
  19. data/docs/Model-Notes/Nokia.md +3 -0
  20. data/docs/Model-Notes/OS10.md +33 -0
  21. data/docs/Model-Notes/PanOS_API.md +28 -0
  22. data/docs/Model-Notes/README.md +2 -0
  23. data/docs/Sources.md +18 -0
  24. data/docs/Supported-OS-Types.md +51 -6
  25. data/docs/Troubleshooting.md +1 -1
  26. data/extra/gitdiff-msteams.sh +91 -0
  27. data/extra/nagios_check_failing_nodes.rb +6 -9
  28. data/extra/oxidized-report-git-commits +71 -14
  29. data/extra/oxidized.init +2 -5
  30. data/extra/oxidized.logrotate +1 -0
  31. data/extra/oxidized.runit +4 -1
  32. data/extra/oxidized.service +5 -8
  33. data/extra/rest_client.rb +1 -1
  34. data/extra/syslog.rb +2 -2
  35. data/lib/oxidized/cli.rb +1 -1
  36. data/lib/oxidized/config/vars.rb +5 -2
  37. data/lib/oxidized/config.rb +6 -3
  38. data/lib/oxidized/core.rb +1 -1
  39. data/lib/oxidized/hook/exec.rb +6 -6
  40. data/lib/oxidized/hook/githubrepo.rb +42 -11
  41. data/lib/oxidized/hook/slackdiff.rb +2 -2
  42. data/lib/oxidized/hook/xmppdiff.rb +45 -25
  43. data/lib/oxidized/hook.rb +4 -8
  44. data/lib/oxidized/input/exec.rb +1 -1
  45. data/lib/oxidized/input/input.rb +1 -0
  46. data/lib/oxidized/input/ssh.rb +23 -20
  47. data/lib/oxidized/input/telnet.rb +52 -44
  48. data/lib/oxidized/job.rb +1 -0
  49. data/lib/oxidized/jobs.rb +11 -6
  50. data/lib/oxidized/manager.rb +1 -0
  51. data/lib/oxidized/model/acmepacket.rb +38 -0
  52. data/lib/oxidized/model/adtran.rb +5 -3
  53. data/lib/oxidized/model/adva.rb +66 -0
  54. data/lib/oxidized/model/airfiber.rb +1 -1
  55. data/lib/oxidized/model/aoscx.rb +96 -0
  56. data/lib/oxidized/model/aosw.rb +1 -1
  57. data/lib/oxidized/model/asa.rb +2 -0
  58. data/lib/oxidized/model/awplus.rb +1 -1
  59. data/lib/oxidized/model/bdcom.rb +49 -0
  60. data/lib/oxidized/model/cambiumepmp.rb +17 -0
  61. data/lib/oxidized/model/casa.rb +4 -1
  62. data/lib/oxidized/model/ciscoce.rb +12 -0
  63. data/lib/oxidized/model/ciscosmb.rb +2 -0
  64. data/lib/oxidized/model/comware.rb +16 -1
  65. data/lib/oxidized/model/cumulus.rb +58 -44
  66. data/lib/oxidized/model/dellx.rb +1 -3
  67. data/lib/oxidized/model/dlink.rb +2 -1
  68. data/lib/oxidized/model/edgecos.rb +22 -2
  69. data/lib/oxidized/model/edgeswitch.rb +4 -4
  70. data/lib/oxidized/model/eltex.rb +48 -0
  71. data/lib/oxidized/model/enterasys.rb +18 -3
  72. data/lib/oxidized/model/enterasys800.rb +29 -0
  73. data/lib/oxidized/model/eos.rb +2 -1
  74. data/lib/oxidized/model/fabricos.rb +1 -1
  75. data/lib/oxidized/model/fastiron.rb +3 -2
  76. data/lib/oxidized/model/fortios.rb +24 -11
  77. data/lib/oxidized/model/fortiwlc.rb +24 -0
  78. data/lib/oxidized/model/gaiaos.rb +40 -3
  79. data/lib/oxidized/model/h3c.rb +40 -0
  80. data/lib/oxidized/model/hatteras.rb +2 -2
  81. data/lib/oxidized/model/hios.rb +38 -0
  82. data/lib/oxidized/model/hpebladesystem.rb +1 -1
  83. data/lib/oxidized/model/ios.rb +13 -10
  84. data/lib/oxidized/model/iosxe.rb +1 -1
  85. data/lib/oxidized/model/ironware.rb +8 -4
  86. data/lib/oxidized/model/junos.rb +5 -1
  87. data/lib/oxidized/model/lancom.rb +23 -0
  88. data/lib/oxidized/model/lenovonos.rb +82 -0
  89. data/lib/oxidized/model/linksyssrw.rb +71 -0
  90. data/lib/oxidized/model/mlnxos.rb +2 -0
  91. data/lib/oxidized/model/model.rb +29 -3
  92. data/lib/oxidized/model/necix.rb +30 -0
  93. data/lib/oxidized/model/netgear.rb +5 -2
  94. data/lib/oxidized/model/netscaler.rb +38 -1
  95. data/lib/oxidized/model/nodegrid.rb +23 -0
  96. data/lib/oxidized/model/nxos.rb +3 -2
  97. data/lib/oxidized/model/openbsd.rb +9 -0
  98. data/lib/oxidized/model/opengear.rb +1 -1
  99. data/lib/oxidized/model/opnsense.rb +12 -4
  100. data/lib/oxidized/model/panos_api.rb +71 -0
  101. data/lib/oxidized/model/pfsense.rb +12 -7
  102. data/lib/oxidized/model/powerconnect.rb +1 -3
  103. data/lib/oxidized/model/procurve.rb +2 -2
  104. data/lib/oxidized/model/purityos.rb +8 -1
  105. data/lib/oxidized/model/quantaos.rb +1 -5
  106. data/lib/oxidized/model/routeros.rb +15 -2
  107. data/lib/oxidized/model/slxos.rb +1 -0
  108. data/lib/oxidized/model/smartcs.rb +40 -0
  109. data/lib/oxidized/model/sonicos.rb +9 -1
  110. data/lib/oxidized/model/srosmd.rb +97 -0
  111. data/lib/oxidized/model/stoneos.rb +6 -2
  112. data/lib/oxidized/model/supermicro.rb +1 -1
  113. data/lib/oxidized/model/swos.rb +9 -0
  114. data/lib/oxidized/model/timos.rb +1 -1
  115. data/lib/oxidized/model/tmos.rb +2 -1
  116. data/lib/oxidized/model/tplink.rb +2 -0
  117. data/lib/oxidized/model/trango.rb +11 -11
  118. data/lib/oxidized/model/truenas.rb +20 -0
  119. data/lib/oxidized/model/vrp.rb +1 -1
  120. data/lib/oxidized/model/xos.rb +4 -3
  121. data/lib/oxidized/model/yamaha.rb +57 -0
  122. data/lib/oxidized/model/zteolt.rb +52 -0
  123. data/lib/oxidized/model/zy1308.rb +11 -0
  124. data/lib/oxidized/node/stats.rb +1 -0
  125. data/lib/oxidized/node.rb +16 -11
  126. data/lib/oxidized/nodes.rb +7 -6
  127. data/lib/oxidized/output/file.rb +2 -1
  128. data/lib/oxidized/output/git.rb +4 -3
  129. data/lib/oxidized/output/gitcrypt.rb +5 -8
  130. data/lib/oxidized/output/http.rb +2 -0
  131. data/lib/oxidized/source/csv.rb +1 -0
  132. data/lib/oxidized/source/http.rb +4 -0
  133. data/lib/oxidized/source/source.rb +7 -2
  134. data/lib/oxidized/source/sql.rb +15 -5
  135. data/lib/oxidized/string.rb +9 -3
  136. data/lib/oxidized/version.rb +2 -2
  137. data/lib/oxidized/worker.rb +5 -5
  138. data/oxidized.gemspec +22 -16
  139. metadata +116 -29
  140. data/.travis.yml +0 -10
data/docs/Sources.md CHANGED
@@ -85,6 +85,23 @@ source:
85
85
  enable: enable
86
86
  ```
87
87
 
88
+ ### MySQL with TLS support
89
+ By default SSL is disabled, but if you would like enable connection via TLS add the following configuration:
90
+ ```yaml
91
+ source:
92
+ default: sql
93
+ sql:
94
+ ...
95
+ with_ssl: true
96
+ ssl_mode: <mode>
97
+ ssl_ca: <path to CA certificate>
98
+ ssl_cert: <path to client certificate>
99
+ ssl_key: <path to client certificate key>
100
+ ```
101
+ ssl_mode may be one of the next: disabled / preferred / required / verify_ca / verify_identity
102
+
103
+ For more information visit: https://github.com/brianmario/mysql2
104
+
88
105
  ## Source: SQLite
89
106
 
90
107
  One row per device, filtered by hostname.
@@ -148,6 +165,7 @@ source:
148
165
  delimiter: !ruby/regexp /:/
149
166
  user: username
150
167
  pass: password
168
+ read_timeout: 120
151
169
  map:
152
170
  name: hostname
153
171
  model: os
@@ -6,6 +6,8 @@
6
6
  * [ACOS](/lib/oxidized/model/acos.rb)
7
7
  * Accedian Performance Elements (NIDs)
8
8
  * [AEN](/lib/oxidized/model/aen.rb)
9
+ * Acme Packet
10
+ * [ACMEPACKET](/lib/oxidized/model/acmepacket.rb)
9
11
  * Adtran
10
12
  * [Total Access (AOS)](/lib/oxidized/model/adtran.rb)
11
13
  * Alcatel-Lucent
@@ -28,6 +30,7 @@
28
30
  * Arris
29
31
  * [C4CMTS](/lib/oxidized/model/c4cmts.rb)
30
32
  * Aruba
33
+ * [AOS-CX](/lib/oxidized/model/aoscx.rb)
31
34
  * [AOSW](/lib/oxidized/model/aosw.rb)
32
35
  * AudioCodes
33
36
  * [AudioCodes](/lib/oxdized/model/audiocodes.rb)
@@ -35,6 +38,15 @@
35
38
  * Avaya
36
39
  * [VOSS (VSP Operating System Software)](/lib/oxidized/model/voss.rb)
37
40
  * [BOSS (Baystack Operating System Software)](/lib/oxidized/model/boss.rb)
41
+ * BDCOM
42
+ * [S2200 series](/lib/oxidized/model/bdcom.rb)
43
+ * [S2200PB series](/lib/oxidized/model/bdcom.rb)
44
+ * [S2200-B series](/lib/oxidized/model/bdcom.rb)
45
+ * [S2500-B series](/lib/oxidized/model/bdcom.rb)
46
+ * [S2500-C series](/lib/oxidized/model/bdcom.rb)
47
+ * [S2500PB series](/lib/oxidized/model/bdcom.rb)
48
+ * [S2500-P series](/lib/oxidized/model/bdcom.rb)
49
+ * [S2900 series](/lib/oxidized/model/bdcom.rb)
38
50
  * Brocade
39
51
  * [FabricOS](/lib/oxidized/model/fabricos.rb)
40
52
  * [FastIron](/lib/oxidized/model/fastiron.rb)
@@ -47,6 +59,7 @@
47
59
  * [AXOS](/lib/oxidized/model/axos.rb)
48
60
  * Cambium
49
61
  * [Cambium (PMP450 Series)](/lib/oxidized/model/cambium.rb)
62
+ * [Cambium (ePMP Series)](/lib/oxidized/model/cambiumepmp.rb)
50
63
  * Casa
51
64
  * [Casa](/lib/oxidized/model/casa.rb)
52
65
  * Centec Networks
@@ -61,7 +74,8 @@
61
74
  * [ASA](/lib/oxidized/model/asa.rb)
62
75
  * [AsyncOS](/lib/oxidized/model/asyncos.rb)
63
76
  * [CatOS](/lib/oxidized/model/catos.rb)
64
- * [FireLinuxOS](lib/oxidized/model/firelinuxos.rb)
77
+ * [Cisco Catalyst Express](/lib/oxidized/model/ciscoce.rb)
78
+ * [FireLinuxOS](/lib/oxidized/model/firelinuxos.rb)
65
79
  * [IOS](/lib/oxidized/model/ios.rb)
66
80
  * [IOSXR](/lib/oxidized/model/iosxr.rb)
67
81
  * [NGA](/lib/oxidized/model/cisconga.rb)
@@ -96,11 +110,15 @@
96
110
  * ECI Telecom
97
111
  * [ECIapollo](/lib/oxidized/model/eciapollo.rb)
98
112
  * EdgeCore
99
- * [ES3528M](/lib/oxidized/model/edgecos.rb)
113
+ * [ECS3510, ES3528M](/lib/oxidized/model/edgecos.rb)
114
+ * [ECS3510, ES3526XA-V2, ES3528M](/lib/oxidized/model/edgecos.rb)
115
+ * Eltex
116
+ * [Eltex](/lib/oxidized/model/eltex.rb)
100
117
  * Ericsson/Redback
101
118
  * [IPOS (former SEOS)](/lib/oxidized/model/ipos.rb)
102
119
  * Extreme Networks
103
- * [Enterasys](/lib/oxidized/model/enterasys.rb)
120
+ * [Enterasys B/C-Series](/lib/oxidized/model/enterasys.rb)
121
+ * [Enterasys 800-Series](/lib/oxidized/model/enterasys800.rb)
104
122
  * [WM](/lib/oxidized/model/mtrlrfs.rb)
105
123
  * [XOS](/lib/oxidized/model/xos.rb)
106
124
  * [ExtremeWare](/lib/oxidized/model/xos.rb)
@@ -109,6 +127,7 @@
109
127
  * Fiberstore
110
128
  * [S3800](/lib/oxidized/model/gcombnps.rb)
111
129
  * [S3900](/lib/oxidized/model/edgecos.rb)
130
+ * [S3900-R](/lib/oxidized/model/bdcom.rb)
112
131
  * [S5800](/lib/oxidized/model/cnos.rb)
113
132
  * [S5850](/lib/oxidized/model/cnos.rb)
114
133
  * Firebrick
@@ -118,6 +137,8 @@
118
137
  * [FTOS](/lib/oxidized/model/ftos.rb)
119
138
  * FortiGate
120
139
  * [FortiOS](/lib/oxidized/model/fortios.rb)
140
+ * FortiWLC
141
+ * [FortiWLC](/lib/oxidized/model/fortiwlc.rb)
121
142
  * Fujitsu
122
143
  * [PRIMERGY Blade switch 1/10Gbe](/lib/oxidized/model/fujitsupy.rb)
123
144
  * GCOM Technologies
@@ -129,13 +150,16 @@
129
150
  * Hillstone Networks
130
151
  * [StoneOS](/lib/oxidized/model/stoneos.rb)
131
152
  * Hirschmann
132
- * [HiOS](/lib/oxidized/model/hirschmann.rb)
153
+ * [Classic](/lib/oxidized/model/hirschmann.rb)
154
+ * [HiOS](/lib/oxidized/model/hios.rb)
133
155
  * HP
134
156
  * [Comware (HP A-series, H3C, 3Com)](/lib/oxidized/model/comware.rb)
135
157
  * [Procurve](/lib/oxidized/model/procurve.rb)
136
158
  * [BladeSystem (Onboard Administrator)](/lib/oxidized/model/hpebladesystem.rb)
137
159
  * [MSA](/lib/oxidized/model/hpemsa.rb)
138
160
  * [MSM (Wireless Controller)](/lib/oxidized/model/hpmsm.rb)
161
+ * H3C
162
+ * [S6520X](/lib/oxidized/model/h3c.rb)
139
163
  * Huawei
140
164
  * [VRP](/lib/oxidized/model/vrp.rb)
141
165
  * [SmartAX series](/lib/oxidized/model/smartax.rb)
@@ -144,6 +168,12 @@
144
168
  * Juniper
145
169
  * [JunOS](/lib/oxidized/model/junos.rb)
146
170
  * [ScreenOS (Netscreen)](/lib/oxidized/model/screenos.rb)
171
+ * LANCOM Systems GmbH
172
+ * [LCOS](/lib/oxidized/model/lancom.rb)
173
+ * Lenovo
174
+ * [Lenovo Network OS](/lib/oxidized/model/lenovonos.rb)
175
+ * Linkys
176
+ * [SRW](/lib/oxidized/model/linksyssrw.rb)
147
177
  * Linuxgeneric
148
178
  * [CentOS](/lib/oxidized/model/linuxgeneric.rb)
149
179
  * Mellanox
@@ -151,11 +181,14 @@
151
181
  * [Voltaire](/lib/oxidized/model/voltaire.rb)
152
182
  * Mikrotik
153
183
  * [RouterOS](/lib/oxidized/model/routeros.rb)
184
+ * [SwOS and SwOS Lite](/lib/oxidized/model/swos.rb)
154
185
  * Motorola
155
186
  * [RFS](/lib/oxidized/model/mtrlrfs.rb)
156
187
  * MRV
157
188
  * [MasterOS](/lib/oxidized/model/masteros.rb)
158
189
  * [FiberDriver](/lib/oxidized/model/fiberdriver.rb)
190
+ * NEC
191
+ * [NEC IX](/lib/oxidized/model/necix.rb)
159
192
  * Netgear
160
193
  * [Netgear switches](/lib/oxidized/model/netgear.rb)
161
194
  * Netonix
@@ -171,7 +204,8 @@
171
204
  * [OpenWRT](/lib/oxidized/model/openwrt.rb)
172
205
  * [OPNsense](/lib/oxidized/model/opnsense.rb)
173
206
  * Palo Alto
174
- * [PANOS](/lib/oxidized/model/panos.rb)
207
+ * [PanOS API](/lib/oxidized/model/panos_api.rb)
208
+ * [PanOS](/lib/oxidized/model/panos.rb)
175
209
  * [PLANET SG/SGS Switches](/lib/oxidized/model/planet.rb)
176
210
  * [pfSense](/lib/oxidized/model/pfsense.rb)
177
211
  * Pure Storage
@@ -186,8 +220,10 @@
186
220
  * [Quanta / VxWorks 6.6 (1.1.0.8)](/lib/oxidized/model/quantaos.rb)
187
221
  * Siklu
188
222
  * [EtherHaul](/lib/oxidized/model/siklu.rb)
223
+ * Seiko Solutions
224
+ * [SmartCS, SmartCS mini](/lib/oxidized/model/smartcs.rb)
189
225
  * SonicWALL
190
- * [SonicOS](lib/oxidized/model/sonicos.rb)
226
+ * [SonicOS](/lib/oxidized/model/sonicos.rb)
191
227
  * SNR
192
228
  * [SNR-S300G, S2xxx, S3xxx, S4xxx](/lib/oxidized/model/dcnos.rb)
193
229
  * Speedtouch
@@ -203,6 +239,8 @@
203
239
  * [Telco Systems T-Marc 3306](/lib/oxidized/model/telco.rb)
204
240
  * Trango Systems
205
241
  * [Trango](/lib/oxidized/model/trango.rb)
242
+ * TrueNAS
243
+ * [TrueNAS](/lib/oxidized/model/truenas.rb)
206
244
  * TPLink
207
245
  * [TPLink](/lib/oxidized/model/tplink.rb)
208
246
  * [TL-SL5428](/lib/oxidized/model/edgecos.rb)
@@ -219,9 +257,16 @@
219
257
  * [Fireware OS](/lib/oxidized/model/firewareos.rb)
220
258
  * Westell
221
259
  * [Westell 8178G, Westell 8266G](/lib/oxidized/model/weos.rb)
260
+ * YAMAHA
261
+ * [YAMAHA NVR/RTX Series](/lib/oxidized/model/yamaha.rb)
222
262
  * Zhone
223
263
  * [Zhone (OLT and MX)](/lib/oxidized/model/zhoneolt.rb)
264
+ * ZPE
265
+ * [Nodegrid OS](/lib/oxidized/model/nodegrid.rb)
266
+ * ZTE
267
+ * [C300&C320 OLT](/lib/oxidized/model/zteolt.rb)
224
268
  * Zyxel
225
269
  * [ZyNOS](/lib/oxidized/model/zynos.rb)
226
270
  * [ZyNOS GS-series variant](/lib/oxidized/model/zynosgs.rb)
227
271
  * [NDMS](/lib/oxidized/model/ndms.rb)
272
+ * [1308](/lib/oxidized/model/zy1308.rb)
@@ -53,7 +53,7 @@ irb(main):003:0> '$EKRET-5A-X20#'.match /^([\$\w.@()-]+[#>]\s?)$/
53
53
  => #<MatchData "$EKRET-5A-X20#" 1:"$EKRET-5A-X20#">
54
54
  ```
55
55
 
56
- The new prompt now matches. You can copy the current model into the `~/.config/oxidized/` directory (keeping the original file name), and modify the prompt within the model file. After restarting Oxidized, the adapted model will be used.
56
+ The new prompt now matches. You can copy the current model into the `~/.config/oxidized/model/` directory (keeping the original file name), and modify the prompt within the model file. After restarting Oxidized, the adapted model will be used.
57
57
 
58
58
  *Troubleshooting an overly greedy prompt:*
59
59
 
@@ -0,0 +1,91 @@
1
+ #!/bin/bash
2
+ # Posts a git diff to MS Team Channel using webhooks
3
+ #
4
+ # Usage:
5
+ # Make sure jq and curl are installed.
6
+ # Save this script in /var/lib/oxidized/extra/
7
+ # Add to oxidized config:
8
+ #
9
+ # hooks:
10
+ # ms_teams_webhook:
11
+ # type: exec
12
+ # events: [post_store]
13
+ # cmd: '/var/lib/oxidized/extra/gitdiff-msteams.sh'
14
+ # async: true
15
+ # timeout: 120
16
+ #
17
+ # Add webhook to your MS Teams channel and set the next variable to the full url
18
+
19
+ weburl="https://contoso.webhook.office.com/webhookb2/etc etc etc"
20
+
21
+ postdata()
22
+ {
23
+ COMMIT=$(git --bare --git-dir="${OX_REPO_NAME}" show --pretty='' --no-color "${OX_REPO_COMMITREF}" | jq --raw-input --slurp --compact-output)
24
+ cat <<EOF
25
+ {
26
+ "type":"message",
27
+ "attachments":[
28
+ {
29
+ "contentType":"application/vnd.microsoft.card.adaptive",
30
+ "contentUrl":null,
31
+ "content":{
32
+ "$schema":"http://adaptivecards.io/schemas/adaptive-card.json",
33
+ "type":"AdaptiveCard",
34
+ "version":"1.2",
35
+ "msTeams": { "width": "full" },
36
+ "body":[
37
+ {
38
+ "type": "TextBlock",
39
+ "text": "Oxidized update for ${OX_NODE_NAME}",
40
+ "size": "medium",
41
+ "weight": "Bolder",
42
+ "style": "heading",
43
+ "wrap": "true"
44
+ },
45
+ {
46
+ "type": "FactSet",
47
+ "facts": [
48
+ {
49
+ "title": "Node name",
50
+ "value": "${OX_NODE_NAME}"
51
+ },
52
+ {
53
+ "title": "Job status",
54
+ "value": "${OX_JOB_STATUS}"
55
+ },
56
+ {
57
+ "title": "Job time",
58
+ "value": "${OX_JOB_TIME}"
59
+ },
60
+ {
61
+ "title": "Git repo",
62
+ "value": "${OX_REPO_NAME}"
63
+ },
64
+ {
65
+ "title": "Git commit ID",
66
+ "value": "${OX_REPO_COMMITREF}"
67
+ }
68
+ ]
69
+ },
70
+ {
71
+ "type": "RichTextBlock",
72
+ "inlines": [
73
+ {
74
+ "type": "TextRun",
75
+ "text": ${COMMIT},
76
+ "fontType": "monospace",
77
+ "size": "small"
78
+ }
79
+ ]
80
+ }
81
+ ]
82
+ }
83
+ }
84
+ ]
85
+ }
86
+ EOF
87
+ }
88
+
89
+ curl -i \
90
+ -H "Content-Type: application/json" \
91
+ -X POST --data "$(postdata)" "${weburl}"
@@ -12,17 +12,14 @@ pending_nodes = []
12
12
 
13
13
  json = JSON.parse(open("http://localhost:8888/nodes.json").read)
14
14
  json.each do |node|
15
- unless ARGV.empty?
16
- next if ARGV[0] != node['name']
17
- end
18
- if not node['last'].nil?
19
- if node['last']['status'] != 'success'
20
- critical_nodes << node['name']
21
- critical = true
22
- end
23
- else
15
+ next if !ARGV.empty? && (ARGV[0] != node['name'])
16
+
17
+ if node['last'].nil?
24
18
  pending_nodes << node['name']
25
19
  pending = true
20
+ elsif node['last']['status'] != 'success'
21
+ critical_nodes << node['name']
22
+ critical = true
26
23
  end
27
24
  end
28
25
 
@@ -21,41 +21,98 @@
21
21
  # Removed requirement for Git working directory
22
22
  # Check job status
23
23
  #
24
+ # 20200926 - Nick Hilliard <nick@foobar.org>
25
+ # sends email
26
+ # add command-line options to stop blank emails from being sent
27
+ # more sanity-checking
24
28
  #
25
29
  # usage: add the following hook to the oxidized config file:
26
30
  #
31
+ # --
27
32
  # hooks:
28
33
  # email_output:
29
34
  # type: exec
30
35
  # events: [post_store, node_fail]
31
- # cmd: '/home/oxidized/extra/oxidized-report-git-commits | mail -s "Oxidized updates for ${OX_NODE_NAME}" update-recipient@example.com'
36
+ # cmd: '/home/oxidized/extra/oxidized-report-git-commits -s "Oxidized updates for ${OX_NODE_NAME}" -r update-recipient@example.com'
32
37
  # async: true
33
38
  # timeout: 120
34
- #
39
+ # --
35
40
  #
41
+ # Options:
42
+ # -r email_recipient - send email to specified recipient
43
+ # -s email_subject - specify the email subject line
44
+ # -f - don't send email if git fails to find commit
45
+ #
46
+
47
+ trap '/bin/rm -f "$tmpfile"' EXIT
48
+
49
+ tmpfile=$(mktemp) || exit 1
50
+
51
+ subject="Oxidized updates for ${OX_NODE_NAME}"
52
+ scriptname=`basename $0`
53
+
54
+ usage()
55
+ {
56
+ echo "Usage: ${scriptname} [-f] [ -s email_subject ] [ -r email_recipient ]"
57
+ exit 1
58
+ }
59
+
60
+ email_on_gitfail=1
61
+ while getopts "fs:r:" opt; do
62
+ case $opt in
63
+ s)
64
+ subject=$OPTARG
65
+ ;;
66
+ r)
67
+ recipient=$OPTARG
68
+ ;;
69
+ f)
70
+ email_on_gitfail=0
71
+ ;;
72
+ *)
73
+ usage
74
+ ;;
75
+ esac
76
+ done
36
77
 
37
- echo "Node name: ${OX_NODE_NAME}"
38
- echo "Group name: ${OX_NODE_GROUP}"
39
- echo "Job status: ${OX_JOB_STATUS}"
40
- echo "Job time: ${OX_JOB_TIME}"
41
78
 
42
79
  if [ "${OX_EVENT}" = "node_fail" ]; then
43
- echo 'Job failed'
80
+ echo "${scriptname}: ${OX_NODE_NAME}": 'Job failed'
44
81
  exit 64
45
82
  fi
46
83
 
47
84
  if [ -z "${OX_REPO_COMMITREF}" ]; then
48
- echo '$OX_REPO_COMMITREF not set'
85
+ echo "${scriptname}: "'$OX_REPO_COMMITREF not set'
49
86
  exit 64
50
87
  fi
51
88
 
52
89
  if [ -z "${OX_REPO_NAME}" ]; then
53
- echo '$OX_REPO_NAME not set'
90
+ echo "${scriptname}: "'$OX_REPO_NAME not set'
54
91
  exit 64
55
92
  fi
56
-
57
- echo "Git repo: ${OX_REPO_NAME}"
58
- echo "Git commit ID: ${OX_REPO_COMMITREF}"
59
- echo ""
60
93
 
61
- git --bare --git-dir="${OX_REPO_NAME}" show --pretty='' --no-color "${OX_REPO_COMMITREF}"
94
+ cat > ${tmpfile} <<EOF
95
+ Node name: ${OX_NODE_NAME}
96
+ Group name: ${OX_NODE_GROUP}
97
+ Job status: ${OX_JOB_STATUS}
98
+ Job time: ${OX_JOB_TIME}
99
+ Git repo: ${OX_REPO_NAME}
100
+ Git commit ID: ${OX_REPO_COMMITREF}
101
+
102
+ EOF
103
+
104
+ # test if commit exists
105
+ git --bare --git-dir="${OX_REPO_NAME}" rev-parse --quiet --verify "${OX_REPO_COMMITREF}" > /dev/null 2>&1
106
+ gitret=$?
107
+
108
+ if [ ${gitret} -eq 0 ]; then
109
+ git --bare --git-dir="${OX_REPO_NAME}" show --pretty='' --no-color "${OX_REPO_COMMITREF}" >> ${tmpfile} 2>&1
110
+ else
111
+ echo "${scriptname}: commit ${OX_REPO_COMMITREF} does not exist" >> ${tmpfile}
112
+ fi
113
+
114
+ if [ ! -z "${recipient}" -a \( ${gitret} -eq 0 -o ${email_on_gitfail} -eq 1 \) ]; then
115
+ cat ${tmpfile} | mail -s "${subject}" "${recipient}"
116
+ else
117
+ cat ${tmpfile}
118
+ fi
data/extra/oxidized.init CHANGED
@@ -18,7 +18,6 @@ PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
18
18
  DAEMON=$(which oxidized)
19
19
  NAME="oxidized"
20
20
  DESC="Oxidized - Network Device Configuration Backup Tool"
21
- ARGS=""
22
21
  USER="oxidized"
23
22
 
24
23
  test -x $DAEMON || exit 0
@@ -29,20 +28,18 @@ if [ -r /etc/default/$NAME ]; then
29
28
  . /etc/default/$NAME
30
29
  fi
31
30
 
32
- CONFIG="${CONFIG:-/etc/oxidized/config}"
33
-
34
31
  PIDFILE=/var/run/$NAME.pid
35
32
 
36
33
  do_start()
37
34
  {
38
35
  start-stop-daemon --start --quiet --background --pidfile $PIDFILE --make-pidfile \
39
- --oknodo --chuid $USER --exec $DAEMON -- -c $CONFIG $ARGS
36
+ --oknodo --chuid $USER --exec $DAEMON
40
37
  }
41
38
 
42
39
  do_stop()
43
40
  {
44
41
  start-stop-daemon --oknodo --stop --quiet -v --pidfile $PIDFILE \
45
- --chuid $USER --retry KILL/10 -- -c $CONFIG $ARGS
42
+ --chuid $USER --retry KILL/10
46
43
  }
47
44
 
48
45
  case "$1" in
@@ -4,4 +4,5 @@
4
4
  size 10M
5
5
  compress
6
6
  delaycompress
7
+ missingok
7
8
  }
data/extra/oxidized.runit CHANGED
@@ -1,2 +1,5 @@
1
1
  #!/bin/bash
2
- exec setuser root oxidized
2
+ [ ! -d /home/oxidized/.config/oxidized ] && mkdir -p /home/oxidized/.config/oxidized
3
+ [ -f /home/oxidized/.config/oxidized/pid ] && rm /home/oxidized/.config/oxidized/pid
4
+ chown -R oxidized:oxidized /home/oxidized/.config/oxidized
5
+ exec setuser oxidized oxidized
@@ -1,12 +1,9 @@
1
- #For debian 8 put it in /lib/systemd/system/
2
- #To set OXIDIZED_HOME instead of the default:
3
- # ~${oxidized_user}/.config/oxidized in debian 8, then uncomment
4
- #(and modify as required) the "Environment" variable below so
5
- #systemd sets the correct environment. Tested only on Debian 8.8.
6
- #YMMV otherwise.
1
+ # Put this file in /etc/systemd/system.
7
2
  #
8
- #For RHEL / CentOS 7 put it in /etc/systemd/system/
9
- #and call it with systemctl start oxidized.service
3
+ # To set OXIDIZED_HOME instead of the default,
4
+ # ~oxidized/.config/oxidized, uncomment (and modify as required) the
5
+ # "Environment" variable below so systemd sets the correct
6
+ # environment.
10
7
 
11
8
  [Unit]
12
9
  Description=Oxidized - Network Device Configuration Backup Tool
data/extra/rest_client.rb CHANGED
@@ -6,7 +6,7 @@ module Oxidized
6
6
  require 'asetus'
7
7
 
8
8
  class Config
9
- Root = Root = ENV['OXIDIZED_HOME'] || File.join(ENV['HOME'], '.config', 'oxidized')
9
+ Root = Root = ENV['OXIDIZED_HOME'] || File.join(Dir.home, '.config', 'oxidized')
10
10
  end
11
11
 
12
12
  CFGS = Asetus.new name: 'oxidized', load: false, key_to_s: true
data/extra/syslog.rb CHANGED
@@ -29,7 +29,7 @@ require_relative 'rest_client'
29
29
  module Oxidized
30
30
  require 'asetus'
31
31
  class Config
32
- Root = File.join ENV['HOME'], '.config', 'oxidized'
32
+ Root = File.join Dir.home, '.config', 'oxidized'
33
33
  end
34
34
 
35
35
  CFGS = Asetus.new name: 'oxidized', load: false, key_to_s: true
@@ -105,7 +105,7 @@ module Oxidized
105
105
  end
106
106
 
107
107
  def handle_log(log, ipaddr)
108
- log = log.to_s.split ' '
108
+ log = log.to_s.split
109
109
  index, vendor = MSG.find do |key, value|
110
110
  index = log.find_index { |e| e.match value }
111
111
  break index, key if index
data/lib/oxidized/cli.rb CHANGED
@@ -72,7 +72,7 @@ module Oxidized
72
72
 
73
73
  begin
74
74
  File.open(pidfile, ::File::CREAT | ::File::EXCL | ::File::WRONLY) { |f| f.write(Process.pid.to_s) }
75
- at_exit { File.delete(pidfile) if File.exist?(pidfile) }
75
+ at_exit { FileUtils.rm_f(pidfile) }
76
76
  rescue Errno::EEXIST
77
77
  check_pid
78
78
  retry
@@ -1,12 +1,15 @@
1
1
  module Oxidized::Config::Vars
2
2
  # convenience method for accessing node, group or global level user variables
3
3
  def vars(name)
4
+ model_name = @node.model.class.name.to_s.downcase
4
5
  if @node.vars&.has_key?(name)
5
6
  @node.vars[name]
7
+ elsif Oxidized.config.groups.has_key?(@node.group) && Oxidized.config.groups[@node.group].models.has_key(model_name) && Oxidized.config.groups[@node.group].models[model_name].vars.has_key?(name.to_s)
8
+ Oxidized.config.groups[@node.group].models[model_name].vars[name.to_s]
6
9
  elsif Oxidized.config.groups.has_key?(@node.group) && Oxidized.config.groups[@node.group].vars.has_key?(name.to_s)
7
10
  Oxidized.config.groups[@node.group].vars[name.to_s]
8
- elsif Oxidized.config.models.has_key(@node.model.class.name.to_s.downcase) && Oxidized.config.models[@node.model.class.name.to_s.downcase].vars.has_key?(name.to_s)
9
- Oxidized.config.models[@node.model.class.name.to_s.downcase].vars[name.to_s]
11
+ elsif Oxidized.config.models.has_key(model_name) && Oxidized.config.models[model_name].vars.has_key?(name.to_s)
12
+ Oxidized.config.models[model_name].vars[name.to_s]
10
13
  elsif Oxidized.config.vars.has_key?(name.to_s)
11
14
  Oxidized.config.vars[name.to_s]
12
15
  end
@@ -2,8 +2,9 @@ module Oxidized
2
2
  require 'asetus'
3
3
  class NoConfig < OxidizedError; end
4
4
  class InvalidConfig < OxidizedError; end
5
+
5
6
  class Config
6
- Root = ENV['OXIDIZED_HOME'] || File.join(ENV['HOME'], '.config', 'oxidized')
7
+ Root = ENV['OXIDIZED_HOME'] || File.join(Dir.home, '.config', 'oxidized')
7
8
  Crash = File.join(ENV['OXIDIZED_LOGS'] || Root, 'crash')
8
9
  Log = File.join(ENV['OXIDIZED_LOGS'] || Root, 'logs')
9
10
  InputDir = File.join Directory, %w[lib oxidized input]
@@ -14,7 +15,7 @@ module Oxidized
14
15
  Sleep = 1
15
16
 
16
17
  def self.load(cmd_opts = {})
17
- asetus = Asetus.new(name: 'oxidized', load: false, key_to_s: true)
18
+ asetus = Asetus.new(name: 'oxidized', load: false, key_to_s: true, usrdir: Oxidized::Config::Root)
18
19
  Oxidized.asetus = asetus
19
20
 
20
21
  asetus.default.username = 'username'
@@ -25,6 +26,7 @@ module Oxidized
25
26
  asetus.default.use_syslog = false
26
27
  asetus.default.debug = false
27
28
  asetus.default.threads = 30
29
+ asetus.default.use_max_threads = false
28
30
  asetus.default.timeout = 20
29
31
  asetus.default.retries = 3
30
32
  asetus.default.prompt = /^([\w.@-]+[#>]\s?)$/
@@ -32,6 +34,7 @@ module Oxidized
32
34
  asetus.default.next_adds_job = false # if true, /next adds job, so device is fetched immmeiately
33
35
  asetus.default.vars = {} # could be 'enable'=>'enablePW'
34
36
  asetus.default.groups = {} # group level configuration
37
+ asetus.default.group_map = {} # map aliases of groups to names
35
38
  asetus.default.models = {} # model level configuration
36
39
  asetus.default.pid = File.join(Oxidized::Config::Root, 'pid')
37
40
 
@@ -69,6 +72,6 @@ module Oxidized
69
72
  end
70
73
 
71
74
  class << self
72
- attr_accessor :mgr, :Hooks
75
+ attr_accessor :mgr, :hooks
73
76
  end
74
77
  end
data/lib/oxidized/core.rb CHANGED
@@ -10,7 +10,7 @@ module Oxidized
10
10
 
11
11
  def initialize(_args)
12
12
  Oxidized.mgr = Manager.new
13
- Oxidized.Hooks = HookManager.from_config(Oxidized.config)
13
+ Oxidized.hooks = HookManager.from_config(Oxidized.config)
14
14
  nodes = Nodes.new
15
15
  raise NoNodesFound, 'source returns no usable nodes' if nodes.size.zero?
16
16
 
@@ -30,11 +30,9 @@ class Exec < Oxidized::Hook
30
30
  env = make_env ctx
31
31
  log "Execute: #{@cmd.inspect}", :debug
32
32
  th = Thread.new do
33
- begin
34
- run_cmd! env
35
- rescue StandardError => e
36
- raise e unless @async
37
- end
33
+ run_cmd! env
34
+ rescue StandardError => e
35
+ raise e unless @async
38
36
  end
39
37
  th.join unless @async
40
38
  end
@@ -70,7 +68,9 @@ class Exec < Oxidized::Hook
70
68
  "OX_NODE_GROUP" => ctx.node.group.to_s,
71
69
  "OX_NODE_MODEL" => ctx.node.model.class.name,
72
70
  "OX_REPO_COMMITREF" => ctx.commitref.to_s,
73
- "OX_REPO_NAME" => ctx.node.repo.to_s
71
+ "OX_REPO_NAME" => ctx.node.repo.to_s,
72
+ "OX_ERR_TYPE" => ctx.node.err_type.to_s,
73
+ "OX_ERR_REASON" => ctx.node.err_reason.to_s
74
74
  )
75
75
  end
76
76
  if ctx.job