Skip to content

Commit 703b7d8

Browse files
author
mda
committed
initial
1 parent 9a931f9 commit 703b7d8

File tree

4 files changed

+80
-32
lines changed

4 files changed

+80
-32
lines changed

.gitignore

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1 @@
1-
# Logs
2-
logs
3-
*.log
4-
5-
# Runtime data
6-
pids
7-
*.pid
8-
*.seed
9-
10-
# Directory for instrumented libs generated by jscoverage/JSCover
11-
lib-cov
12-
13-
# Coverage directory used by tools like istanbul
14-
coverage
15-
16-
# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
17-
.grunt
18-
19-
# node-waf configuration
20-
.lock-wscript
21-
22-
# Compiled binary addons (http://nodejs.org/api/addons.html)
23-
build/Release
24-
25-
# Dependency directory
26-
# https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git
271
node_modules

README.md

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,38 @@
1-
# nagios-check-redis
2-
Simple plugin for nagios to check status of a redis server
1+
## nagios-check-redis
2+
3+
Simple plugin for nagios to check status of a redis server.
34

45
## Requirements
56

6-
- Node.js >= 0.8.*
7+
- NodeJS
78
- Nagios
89

910
## Installing
1011

1112
To download the latest version:
1213

13-
npm install nagios-redis
14+
npm install -g nagios-redis
15+
16+
## Usage
17+
18+
nagios-redis -H localhost -p 6379
19+
20+
Edit your commands.cfg and add the following:
21+
22+
define command {
23+
command_name check_redis
24+
command_line $USER1$/nagios-redis/check_redis.js -H $HOSTADDRESS$ -p $ARG1$
25+
}
26+
27+
Now you can monitor redis servers by adding:
1428

15-
This plugin will output performance data for the property being checked.
29+
define service {
30+
use generic-service
31+
hostgroup_name Redis servers
32+
service_description Redis server check
33+
check_command check_redis!6379
34+
}
1635

1736
## License
1837

19-
yet to be determined
38+
nope

check_redis.js

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
#!/usr/bin/env node
2+
'use strict';
3+
4+
var optimist = require('optimist')
5+
.usage('Usage: $0 -H [hostname] -p [port] --help')
6+
.default('H', 'localhost')
7+
.default('p', 6379)
8+
.describe('H', 'hostname of the redis server')
9+
.describe('p', 'port of the redis server')
10+
.describe('help', 'prints this help message');
11+
var argv = optimist.argv;
12+
var redis = require('redis');
13+
14+
if (argv.help) {
15+
optimist.showHelp();
16+
process.exit(0);
17+
}
18+
19+
var client = redis.createClient(argv.p, argv.H);
20+
21+
client.on("error", function (err) {
22+
console.log('CRITICAL - ', err.toString());
23+
process.exit(3);
24+
});
25+
26+
client.on('ready', function() {
27+
console.log('OK -', 'uptime_in_days:', client.server_info.uptime_in_days);
28+
client.end();
29+
process.exit(0);
30+
});

package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "check_redis",
3+
"version": "1.0.0",
4+
"description": "Nagios plugin to monitor redis status",
5+
"main": "check_redis.js",
6+
"bin": {
7+
"check_redis": "./check_redis.js"
8+
},
9+
"keywords": [
10+
"nagios",
11+
"redis"
12+
],
13+
"author": "Michel Hiemstra <info@michelhiemstra.nl>",
14+
"license": "none",
15+
"dependencies": {
16+
"hiredis": "^0.3.0",
17+
"optimist": "^0.6.1",
18+
"redis": "^0.12.1"
19+
},
20+
"repository": {
21+
"type": "git",
22+
"url": "https://github.com/mdahiemstra/nagios-check-redis.git"
23+
},
24+
"preferGlobal": "true"
25+
}

0 commit comments

Comments
 (0)