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 +5 -5
- data/CHANGELOG.md +6 -1
- data/README.md +35 -18
- data/bin/check-upgrade.sh +112 -0
- data/lib/sensu-plugins-routeros/version.rb +2 -2
- metadata +4 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 341b7d22cc83fa3d512b6467c899298b7e461615aceebb8ccb4665eb9bf0e5bc
|
4
|
+
data.tar.gz: 76c257de64c693d0e862d9b3c188ffa3f932ff42ee4eab71898ab3aca97f9cbb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 600cbd09a3e8249ad12b5c5f208a58e581b85101e1c77dc67ac58a7b2e3eba400f611220306877d913cb5c617b27dc3b9764d56378f880e1c5644be7b653508c
|
7
|
+
data.tar.gz: 0741f2aab5630e5d56f28f23442a81ad4911d3fc97d7d418c02eca5208a244780efa405e126efef2613f94b85606f324e4827505f0db6682153bb88b08bd5015
|
data/CHANGELOG.md
CHANGED
@@ -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
|
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
|
-
|
1
|
+
## Sensu-Plugins-RouterOS
|
2
2
|
|
3
|
-
|
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
|
-
##
|
8
|
+
## Files
|
6
9
|
|
7
|
-
*
|
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
|
-
##
|
12
|
+
## Usage
|
13
13
|
|
14
|
-
|
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
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
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
|
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
|
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-
|
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.
|
233
|
+
rubygems_version: 2.7.7
|
233
234
|
signing_key:
|
234
235
|
specification_version: 4
|
235
236
|
summary: Sensu plugins for router os
|