[PATCH 2/4] qh: Fall for peer pressure from myself, and implement some help
robin.sonefors at op5.com
robin.sonefors at op5.com
Tue Nov 27 17:41:50 CET 2012
From: Robin Sonefors <robin.sonefors at op5.com>
This is still quite sparse, as it's intended as inline help and hints,
rather than as complete documentation, but it should still prove
helpful.
Signed-off-by: Robin Sonefors <robin.sonefors at op5.com>
---
base/nerd.c | 7 +++++++
base/query-handler.c | 15 +++++++++++++++
base/workers.c | 10 ++++++++++
3 files changed, 32 insertions(+)
diff --git a/base/nerd.c b/base/nerd.c
index 897a5da..05a0953 100644
--- a/base/nerd.c
+++ b/base/nerd.c
@@ -400,6 +400,13 @@ static int nerd_qh_handler(int sd, char *request, unsigned int len)
struct nerd_channel *chan;
int action;
+ if (!strcmp(request, "--help")) {
+ nsock_printf_nul(sd, "Manage subscriptions to NERD channels.\n"
+ "Valid commands are 'subscribe' and 'unsubscribe' to a specified channel.\n"
+ "Valid channels are 'hostchecks', 'servicechecks' and 'opathchecks'.");
+ return 0;
+ }
+
while(request[len] == 0 || request[len] == '\n')
request[len--] = 0;
chan_name = strchr(request, ' ');
diff --git a/base/query-handler.c b/base/query-handler.c
index f9c0604..bf6117a 100644
--- a/base/query-handler.c
+++ b/base/query-handler.c
@@ -23,6 +23,11 @@ static dkhash_table *qh_table;
/* the echo service. stupid, but useful for testing */
static int qh_echo(int sd, char *buf, unsigned int len)
{
+ if (!strcmp(buf, "--help")) {
+ nsock_printf_nul(sd,
+ "Query handler that simply echoes back what you send it.");
+ return 0;
+ }
(void)write(sd, buf, len);
return 0;
}
@@ -286,6 +291,16 @@ static int qh_core(int sd, char *buf, unsigned int len)
{
char *space;
+ if (!strcmp(buf, "--help")) {
+ nsock_printf_nul(sd, "Query handler for manipulating nagios core.\n"
+ "Available commands:\n"
+ " loadctl Print information about current load control settings\n"
+ " loadctl <options> Configure nagios load control.\n"
+ " The options are the same parameters and format as\n"
+ " returned above."
+ );
+ return 0;
+ }
if ((space = memchr(buf, ' ', len)))
*(space++) = 0;
if (!space && !strcmp(buf, "loadctl")) {
diff --git a/base/workers.c b/base/workers.c
index 0f315d5..d74f1d2 100644
--- a/base/workers.c
+++ b/base/workers.c
@@ -722,6 +722,16 @@ static int wproc_query_handler(int sd, char *buf, unsigned int len)
{
char *space, *rbuf = NULL;
+ if (!strcmp(buf, "--help")) {
+ nsock_printf_nul(sd, "Control worker processes.\n"
+ "Valid commands:\n"
+ " wpstats Print general job information\n"
+ " register <options> Register a new worker\n"
+ " <options> can be name, pid, max_jobs and/or plugin.\n"
+ " There can be many plugin args.");
+ return 0;
+ }
+
if ((space = memchr(buf, ' ', len)) != NULL)
*space = 0;
--
1.7.11.7
------------------------------------------------------------------------------
Monitor your physical, virtual and cloud infrastructure from a single
web console. Get in-depth insight into apps, servers, databases, vmware,
SAP, cloud infrastructure, etc. Download 30-day Free Trial.
Pricing starts from $795 for 25 servers or applications!
http://p.sf.net/sfu/zoho_dev2dev_nov
More information about the Developers
mailing list