sensu-plugins-routeros 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: e21569e8a78ae109b530cf1e7a7134ae961f76d5
4
- data.tar.gz: a334626f58069fe0c3f901d7788c01fb16d78c4a
2
+ SHA256:
3
+ metadata.gz: 341b7d22cc83fa3d512b6467c899298b7e461615aceebb8ccb4665eb9bf0e5bc
4
+ data.tar.gz: 76c257de64c693d0e862d9b3c188ffa3f932ff42ee4eab71898ab3aca97f9cbb
5
5
  SHA512:
6
- metadata.gz: 3da8b2946f933d17881344b9d8fdea179fd40fcc68d4060719da014816f7fe270ed902a3fa99c99342b4f35178b92284f43b2692fe318326fd9082e4ea17858e
7
- data.tar.gz: db1bc0831caa312e3bd7e0d9498841dce6746dbcc61302686c5740eeaaed409bca855fb4feec5680132cc9cf5bb3ef2129e2155cadb34709c902ab93150c2b04
6
+ metadata.gz: 600cbd09a3e8249ad12b5c5f208a58e581b85101e1c77dc67ac58a7b2e3eba400f611220306877d913cb5c617b27dc3b9764d56378f880e1c5644be7b653508c
7
+ data.tar.gz: 0741f2aab5630e5d56f28f23442a81ad4911d3fc97d7d418c02eca5208a244780efa405e126efef2613f94b85606f324e4827505f0db6682153bb88b08bd5015
@@ -5,6 +5,10 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [0.1.0] - 2018-05-23
9
+ ### Added
10
+ - shell script check-upgrade.sh (@x70b1)
11
+
8
12
  ## [0.0.1] - 2018-05-02
9
13
  ### Security
10
14
  - updated `yard` dependency to `~> 0.9.11` per: https://nvd.nist.gov/vuln/detail/CVE-2017-17042 which closes attacks against a yard server loading arbitrary files (@majormoses)
@@ -19,5 +23,6 @@ This CHANGELOG follows the format located [here](https://github.com/sensu-plugin
19
23
  - Rubocop config
20
24
  - basic testing setup
21
25
 
22
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-routeros/compare/0.0.1...HEAD
26
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-routeros/compare/0.1.0...HEAD
27
+ [0.1.0]: https://github.com/sensu-plugins/sensu-plugins-routeros/compare/0.0.1...0.1.0
23
28
  [0.0.1]: https://github.com/sensu-plugins/sensu-plugins-routeros/compare/42104a9443c472f5f96a028535488f4b5d3efe88...0.0.1
data/README.md CHANGED
@@ -1,24 +1,41 @@
1
- # Sensu Plugin Skeleton
1
+ ## Sensu-Plugins-RouterOS
2
2
 
3
- All the files you'll need to start your own plugin written in Ruby [for Sensu](https://github.com/sensu/sensu), the monitoring framework.
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-routeros.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-routeros)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-routeros.svg)](http://badge.fury.io/rb/sensu-plugins-routeros)
5
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-routeros.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-routeros)
6
+ [![Community Slack](https://slack.sensu.io/badge.svg)](https://slack.sensu.io/badge)
4
7
 
5
- ## Useful to Me?
8
+ ## Files
6
9
 
7
- * Copy the files in this repository if you want to write a Ruby plugin following best practices of layout and structure
8
- * To write the actual functionality, you'll need to import [Sensu Plugin gem](https://github.com/sensu-plugins/sensu-plugin)
9
- * If you'd prefer writing in Python, use the [Python Plugin library](https://github.com/sensu-plugins/sensu-plugin-python)
10
- * Regardless of the chosen language, prepare the plugin to be released as a Ruby gem for optimal portability (example: [MongoDB has Ruby and Python code](https://github.com/sensu-plugins/sensu-plugins-mongodb/tree/master/bin))
10
+ * bin/check-upgrade.sh
11
11
 
12
- ## Checklist
12
+ ## Usage
13
13
 
14
- To release your own plugin, complete the following:
14
+ * sh **check_routeros-upgrade.sh** *snmp* *HOST* [*PORT*] [*COMMUNITY*] [*RELEASE-TREE*]
15
+ * sh **check_routeros-upgrade.sh** *ssh* *HOST* [*PORT*] [*USER*] [*RELEASE-TREE*]
15
16
 
16
- - [ ] Double check that another plugin doesn't already do what you need by [searching the Sensu Plugins organization](https://github.com/sensu-plugins)
17
- - [ ] Copy the files here into your own repository following the naming convention of `sensu-plugins-$FOO`
18
- - [ ] Delete or move this file and rename `README-skel.md` to `README.md`
19
- - [ ] Write your own checks, handlers or mutators using the plugin library of your choice
20
- - [ ] Push them to your own GitHub repository
21
- - [ ] Release them as a Ruby gem for optimal portability within the Sensu 1.x framework
22
- - [ ] Ask for feedback from your peers by sharing it on in the #contributing channel on [Sensu Community Slack](http://slack.sensu.io)
23
- - [ ] When you're ready to share further, offer to share it with broader community [by transferring it to Sensu Plugins organization](https://github.com/sensu-plugins/community/blob/master/TRANSFERRING_REPOS.md)
24
- - [ ] If you end up loving maintaining your plugin, [volunteer to be an org maintainer](https://github.com/sensu-plugins/community#how-you-can-help)
17
+ The default values for SNMP are:
18
+ * PORT=161
19
+ * COMMUNITY=public
20
+
21
+ For a check over SSH:
22
+ * PORT=22
23
+ * USER=user
24
+
25
+ You need an user and SSH keys. There is no option for a password.
26
+
27
+ **[RELEASE TREE]**
28
+
29
+ Different settings are available. The default is `stable`. Choose wise.
30
+
31
+ * stable
32
+ * bugfix
33
+ * release-candidate
34
+
35
+ **ENV ROUTEROS_UPDATEURL**
36
+
37
+ If you want to save the update information on your own server you can use `export ROUTEROS_UPDATEURL` to overwrite the default `https://download.mikrotik.com/routeros`.
38
+
39
+ ## Installation
40
+
41
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
@@ -0,0 +1,112 @@
1
+ #!/bin/sh
2
+
3
+ error="0"
4
+
5
+ if [ -z "${ROUTEROS_UPDATEURL}" ]; then
6
+ routeros_url="https://download.mikrotik.com/routeros"
7
+ else
8
+ routeros_url="${ROUTEROS_UPDATEURL}"
9
+ fi
10
+
11
+ if [ "$1" = "snmp" ]; then
12
+ if [ -z "$3" ]; then
13
+ param_port="161"
14
+ else
15
+ param_port=$3
16
+ fi
17
+
18
+ if [ -z "$4" ]; then
19
+ param_community="public"
20
+ else
21
+ param_community=$4
22
+ fi
23
+
24
+ if ! routeros_installed=$(snmpget -O qv -v 2c -c "$param_community" "$2":"$param_port" SNMPv2-SMI::enterprises.14988.1.1.4.4.0 2> /dev/null); then
25
+ error="Could not establish an SNMP connection to the device!"
26
+ else
27
+ routeros_installed=$(echo "$routeros_installed" | tr -d '"')
28
+ fi
29
+ elif [ "$1" = "ssh" ]; then
30
+ if [ -z "$3" ]; then
31
+ param_port="22"
32
+ else
33
+ param_port=$3
34
+ fi
35
+
36
+ if [ -z "$4" ]; then
37
+ param_user="user"
38
+ else
39
+ param_user=$4
40
+ fi
41
+
42
+ if ! routeros_installed=$(ssh -q -p "$param_port" "$param_user"@"$2" ':put [/system package get system version]'); then
43
+ error="Could not establish an SSH connection to the device!"
44
+ else
45
+ routeros_installed=$(echo "$routeros_installed" | tr -d "\\r\\n")
46
+ fi
47
+ else
48
+ echo "Use SNMP or SSH as connection type!"
49
+ exit 2
50
+ fi
51
+
52
+
53
+ if [ "$error" = "0" ]; then
54
+ # select the version
55
+ case $5 in
56
+ "stable")
57
+ param_version="6"
58
+ ;;
59
+ "release-candidate")
60
+ param_version="6rc"
61
+ ;;
62
+ "bugfix")
63
+ param_version="6fix"
64
+ ;;
65
+ *)
66
+ param_version="6"
67
+ ;;
68
+ esac
69
+
70
+ # check the MikroTik server for upgrades
71
+ if ! routeros_available=$(curl -fsA "check_routeros-upgrade" "$routeros_url/LATEST.$param_version"); then
72
+ echo "Could not reach the MikroTik server to check the latest version!"
73
+ exit 1
74
+ fi
75
+
76
+ routeros_available_version=$(echo "$routeros_available" | cut -d " " -f 1)
77
+ routeros_available_releasedate=$(echo "$routeros_available" | cut -d " " -f 2)
78
+
79
+ # compare latest version with device version
80
+ if [ "$routeros_available_version" = "$routeros_installed" ]; then
81
+ echo "RouterOS $routeros_available_version is up to date (release: $(date -u -d @"$routeros_available_releasedate" +'%b-%d'))"
82
+ exit 0
83
+ else
84
+ # read the changelog
85
+ if ! changelog=$(curl -fsA "check_routeros-upgrade" "$routeros_url/$routeros_available_version/CHANGELOG"); then
86
+ echo "Could not reach the MikroTik server to read the changelog!"
87
+ exit 1
88
+ fi
89
+
90
+ changelog_lines=$(echo "$changelog" | grep -n "What" | head -n 2 | tail -n 1 | cut -d ":" -f 1)
91
+
92
+ changelog_impfix=$(echo "$changelog" | head -n "$changelog_lines" | grep -c '!)')
93
+ changelog_avgfix=$(echo "$changelog" | head -n "$changelog_lines" | grep -c '[*])')
94
+
95
+ if [ "$changelog_impfix" -ne 0 ] && [ "$changelog_avgfix" -ne 0 ]; then
96
+ fix_text="$changelog_impfix important fixes, $changelog_avgfix average fixes"
97
+ fix_result=2
98
+ elif [ "$changelog_impfix" -ne 0 ]; then
99
+ fix_text="$changelog_impfix important fixes"
100
+ fix_result=2
101
+ elif [ "$changelog_avgfix" -ne 0 ]; then
102
+ fix_text="$changelog_avgfix average fixes"
103
+ fix_result=1
104
+ fi
105
+
106
+ echo "RouterOS is upgradable to $routeros_available_version ($fix_text)"
107
+ exit $fix_result
108
+ fi
109
+ else
110
+ echo "$error"
111
+ exit 2
112
+ fi
@@ -1,8 +1,8 @@
1
1
  module SensuPluginRouterOS
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 0
5
- PATCH = 1
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-routeros
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-02 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -201,6 +201,7 @@ files:
201
201
  - CHANGELOG.md
202
202
  - LICENSE
203
203
  - README.md
204
+ - bin/check-upgrade.sh
204
205
  - lib/sensu-plugins-routeros.rb
205
206
  - lib/sensu-plugins-routeros/version.rb
206
207
  homepage: https://github.com/sensu-plugins/sensu-plugins-routeros
@@ -229,7 +230,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
229
230
  version: '0'
230
231
  requirements: []
231
232
  rubyforge_project:
232
- rubygems_version: 2.5.2.2
233
+ rubygems_version: 2.7.7
233
234
  signing_key:
234
235
  specification_version: 4
235
236
  summary: Sensu plugins for router os