Fix #10 only negative scores fail --nagios. 0.6.0
This commit is contained in:
Родитель
4c3f6989c5
Коммит
a1c6b42fa1
52
README.md
52
README.md
|
@ -9,15 +9,22 @@ Observatory by Mozilla is a project designed to help developers, system administ
|
|||
- <https://observatory.mozilla.org/>
|
||||
- [FAQ](https://observatory.mozilla.org/faq.html)
|
||||
|
||||
## install
|
||||
### Example site report, with additional options
|
||||
|
||||
![Screenshot of ssllabs.com report, showing colors](report.png)
|
||||
|
||||
The [full report url](https://observatory.mozilla.org/analyze.html?host=ssllabs.com) has suggestions to **repair** each of these issues.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install -g observatory-cli
|
||||
```
|
||||
|
||||
## usage
|
||||
## Usage
|
||||
|
||||
1. **Scan a site** for `https` best practices
|
||||
1. **Scan a site** for `https` best practices.
|
||||
|
||||
```
|
||||
# json!
|
||||
|
@ -31,7 +38,7 @@ $ npm install -g observatory-cli
|
|||
|
||||
```
|
||||
|
||||
2. **Test a site** as part of a Continuous Integration pipeline
|
||||
2. **Test a site** as part of a Continuous Integration pipeline.
|
||||
|
||||
Script will FAIL unless the grade is AT LEAST `B+`
|
||||
|
||||
|
@ -46,13 +53,15 @@ $ npm install -g observatory-cli
|
|||
```
|
||||
|
||||
|
||||
3. **Show the URL** for report
|
||||
3. **Show the URL** for the web report.
|
||||
|
||||
```
|
||||
$ observatory some.site.name --format=url
|
||||
```
|
||||
|
||||
4. **nagios** monitoring plugin
|
||||
4. **nagios** monitoring plugin mode.
|
||||
|
||||
For `--nagios <failcode>`, `failcode` will be the exit code if the test fails.
|
||||
|
||||
`--min-score`, `--min-grade`, `--zero`, `--skip` aftect the test.
|
||||
|
||||
|
@ -62,7 +71,29 @@ $ npm install -g observatory-cli
|
|||
```
|
||||
|
||||
If neither `--min-score` nor `--min-grade` is specified, any
|
||||
non-zero scores fail the test.
|
||||
negative scores fail the test.
|
||||
|
||||
```
|
||||
# '2' means 'critical.' Exits '2'
|
||||
|
||||
$ observatory ssllabs.com --nagios 2
|
||||
CRITICAL ["redirection"]
|
||||
```
|
||||
|
||||
We can `--skip` the failing rule, and affect the score.
|
||||
|
||||
```
|
||||
$ observatory ssllabs.com --nagios 2 --skip redirection
|
||||
observatory [INFO] modfiying score, because of --skip. was: 100, now: 105
|
||||
OK
|
||||
```
|
||||
|
||||
Quiet output with `-q`.
|
||||
|
||||
```
|
||||
$ observatory ssllabs.com --nagios 2 --skip redirection -q
|
||||
OK
|
||||
```
|
||||
|
||||
## Help
|
||||
|
||||
|
@ -106,11 +137,11 @@ Nagios Mode (--nagios)
|
|||
```
|
||||
|
||||
|
||||
## Example Results
|
||||
## Example Report, Text Version
|
||||
|
||||
Added on:
|
||||
Report, with options:
|
||||
|
||||
* `-z` to show '0' things
|
||||
* `-z` to show '0' rules (all rules)
|
||||
* `--skip` to skip a rule (affecting SCORE, but not GRADE)
|
||||
|
||||
```
|
||||
|
@ -140,7 +171,6 @@ Full Report Url: https://observatory.mozilla.org/analyze.html?host=some.site
|
|||
|
||||
```
|
||||
|
||||
|
||||
## Related projects
|
||||
|
||||
- [HTTP Observatory](https://github.com/mozilla/http-observatory) by April King
|
||||
|
|
15
index.js
15
index.js
|
@ -174,7 +174,13 @@ function validateGrade (val) {
|
|||
|
||||
function openSite (url) {
|
||||
logger.log(f.link(url));
|
||||
}
|
||||
|
||||
function filterNegativeScores(scores) {
|
||||
function isNegative (k) {
|
||||
return scores[k].score_modifier < 0;
|
||||
}
|
||||
return Object.keys(scores).filter(isNegative)
|
||||
}
|
||||
|
||||
function promiseReport (scan, options) {
|
||||
|
@ -242,16 +248,19 @@ function handleNagiosMode(options, scan, scores) {
|
|||
}
|
||||
var codeName = nagiosExitCodes[options.nagios];
|
||||
|
||||
var negatives = filterNegativeScores(scores);
|
||||
|
||||
function OK () {
|
||||
console.log("OK")
|
||||
process.exit(0)
|
||||
}
|
||||
|
||||
function FAIL () {
|
||||
console.log("%s %j", codeName, Object.keys(scores))
|
||||
console.log("%s %j", codeName, negatives)
|
||||
process.exit(codeName)
|
||||
}
|
||||
|
||||
|
||||
if (options.minGrade || (options.minScore !== undefined)) {
|
||||
try {
|
||||
handleExpectedScore(options, scan)
|
||||
|
@ -261,7 +270,7 @@ function handleNagiosMode(options, scan, scores) {
|
|||
}
|
||||
return
|
||||
} else {
|
||||
if (Object.keys(scores).length) {
|
||||
if (negatives.length) {
|
||||
FAIL()
|
||||
} else {
|
||||
OK()
|
||||
|
@ -441,7 +450,7 @@ function newHelp () {
|
|||
f.header("Nagios Mode" ) +" " + f.code("(--nagios)") +
|
||||
"\n" +
|
||||
" - if `--min-score` and/or `--min-grade`, use those.\n" +
|
||||
" - else *any* failing rules fail the check.\n" +
|
||||
" - else *any* negative rules fail the check.\n" +
|
||||
" - exits with integer `failcode`.\n"
|
||||
|
||||
return out;
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "observatory-cli",
|
||||
"description": "Command line client for Mozilla HTTP observatory service",
|
||||
"version": "0.5.2",
|
||||
"version": "0.6.0",
|
||||
"author": "Gregg Lind <glind@mozilla.com>",
|
||||
"bin": {
|
||||
"observatory": "./index.js"
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 641 KiB |
Загрузка…
Ссылка в новой задаче