[Pkg-nagios-changes] [SCM] Debian packaging for mod gearman. branch, upstream, updated. e9a5a6997d9dd8b31b433b5bcbad495448db0131
Sven Nierlein
sven at nierlein.org
Thu Apr 7 08:06:48 UTC 2011
The following commit has been merged in the upstream branch:
commit daadeb77fbadb9961d30e52450ca407cd2d8bb48
Author: Sven Nierlein <sven at nierlein.org>
Date: Sun Mar 13 21:52:25 2011 +0100
fixed type strings
diff --git a/common/utils.c b/common/utils.c
index fdde1e9..2560b9a 100644
--- a/common/utils.c
+++ b/common/utils.c
@@ -629,10 +629,11 @@ int parse_args_line(mod_gm_opt_t *opt, char * arg, int recursion_level) {
/* get neb callback number by name */
int i;
for(i=0;i<=GM_NEBTYPESSIZE;i++) {
- char * type = event_type2str(i);
+ char * type = nebcallback2str(i);
if(!strcmp(type, callback)) {
callback_num = i;
}
+ free(type);
}
if(callback_num == -1) {
gm_log( GM_LOG_ERROR, "unknown nebcallback : %s\n", callback);
@@ -759,9 +760,10 @@ void dumpconfig(mod_gm_opt_t *opt, int mode) {
gm_log( GM_LOG_DEBUG, "local_servicegroups: %s\n", opt->local_servicegroups_list[i]);
/* export queues*/
for(i=0;i<=GM_NEBTYPESSIZE;i++) {
- char * type = event_type2str(i);
+ char * type = nebcallback2str(i);
for(j=0;j<opt->exports[i]->elem_number;j++)
gm_log( GM_LOG_DEBUG, "export: %-45s -> %s\n", type, opt->exports[i]->name[j]);
+ free(type);
}
}
@@ -1374,8 +1376,8 @@ void escape(char *out, int ch) {
}
-/* return human readable name for event type int */
-char * neb_type2str(int i) {
+/* return human readable name for neb type */
+char * nebtype2str(int i) {
switch(i) {
case 0:
return strdup("NEBTYPE_NONE"); break;
@@ -1524,8 +1526,8 @@ char * neb_type2str(int i) {
}
-/* return human readable name for event type int */
-char * event_type2str(int i) {
+/* return human readable name for nebcallback */
+char * nebcallback2str(int i) {
switch(i) {
case 0:
return strdup("NEBCALLBACK_RESERVED0"); break;
@@ -1596,3 +1598,48 @@ char * event_type2str(int i) {
}
return strdup("UNKNOWN");
}
+
+/* return human readable name for eventtype */
+char * eventtype2str(int i) {
+ switch(i) {
+ case 0:
+ return strdup("EVENT_SERVICE_CHECK"); break;
+ case 1:
+ return strdup("EVENT_COMMAND_CHECK"); break;
+ case 2:
+ return strdup("EVENT_LOG_ROTATION"); break;
+ case 3:
+ return strdup("EVENT_PROGRAM_SHUTDOWN"); break;
+ case 4:
+ return strdup("EVENT_PROGRAM_RESTART"); break;
+ case 5:
+ return strdup("EVENT_CHECK_REAPER"); break;
+ case 6:
+ return strdup("EVENT_ORPHAN_CHECK"); break;
+ case 7:
+ return strdup("EVENT_RETENTION_SAVE"); break;
+ case 8:
+ return strdup("EVENT_STATUS_SAVE"); break;
+ case 9:
+ return strdup("EVENT_SCHEDULED_DOWNTIME"); break;
+ case 10:
+ return strdup("EVENT_SFRESHNESS_CHECK"); break;
+ case 11:
+ return strdup("EVENT_EXPIRE_DOWNTIME"); break;
+ case 12:
+ return strdup("EVENT_HOST_CHECK"); break;
+ case 13:
+ return strdup("EVENT_HFRESHNESS_CHECK"); break;
+ case 14:
+ return strdup("EVENT_RESCHEDULE_CHECKS"); break;
+ case 15:
+ return strdup("EVENT_EXPIRE_COMMENT"); break;
+ case 16:
+ return strdup("EVENT_CHECK_PROGRAM_UPDATE"); break;
+ case 98:
+ return strdup("EVENT_SLEEP"); break;
+ case 99:
+ return strdup("EVENT_USER_FUNCTION"); break;
+ }
+ return strdup("UNKNOWN");
+}
diff --git a/include/utils.h b/include/utils.h
index 42f2375..d70e9d0 100644
--- a/include/utils.h
+++ b/include/utils.h
@@ -398,27 +398,38 @@ int escaped(int ch);
void escape(char *out, int ch);
/**
- * neb_type2str
+ * callback_type2str
*
- * get human readable name for neb type int
+ * get human readable name for neb type
*
* @param[in] i - integer to translate
*
* @return the human readable string
*/
-char * neb_type2str(int i);
+char * nebtype2str(int i);
/**
- * event_type2str
+ * nebcallback2str
*
- * get human readable name for event type int
+ * get human readable name for nebcallback type int
*
* @param[in] i - integer to translate
*
* @return the human readable string
*/
-char * event_type2str(int i);
+char * nebcallback2str(int i);
+
+/**
+ * eventtype2str
+ *
+ * get human readable name for eventtype type int
+ *
+ * @param[in] i - integer to translate
+ *
+ * @return the human readable string
+ */
+char * eventtype2str(int i);
/**
diff --git a/neb_module/mod_gearman.c b/neb_module/mod_gearman.c
index 1444b12..39d44cf 100644
--- a/neb_module/mod_gearman.c
+++ b/neb_module/mod_gearman.c
@@ -966,10 +966,11 @@ int handle_perfdata(int event_type, void *data) {
/* handle generic exports */
-int handle_export(int event_type, void *data) {
+int handle_export(int callback_type, void *data) {
int i;
char * buffer;
char * type;
+ char * event_type;
temp_buffer[0] = '\x0';
int debug_level_orig = mod_gm_opt->debug_level;
mod_gm_opt->debug_level = -1;
@@ -979,7 +980,7 @@ int handle_export(int event_type, void *data) {
nebstruct_timed_event_data * nted;
/* what type of event/data do we have? */
- switch (event_type) {
+ switch (callback_type) {
case NEBCALLBACK_RESERVED0: /* 0 */
break;
case NEBCALLBACK_RESERVED1: /* 1 */
@@ -995,32 +996,39 @@ int handle_export(int event_type, void *data) {
case NEBCALLBACK_NEB_DATA: /* 6 */
break;
case NEBCALLBACK_PROCESS_DATA: /* 7 */
- npd = (nebstruct_process_data *)data;
- snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"event_type\":\"%s\",\"type\":\"%d\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d}",
+ npd = (nebstruct_process_data *)data;
+ type = nebtype2str(npd->type);
+ snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"callback_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d}",
"NEBCALLBACK_PROCESS_DATA",
- npd->type,
+ type,
npd->flags,
npd->attr,
(int)npd->timestamp.tv_sec, (int)npd->timestamp.tv_usec
);
+ free(type);
break;
case NEBCALLBACK_TIMED_EVENT_DATA: /* 8 */
- nted = (nebstruct_timed_event_data *)data;
- snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"event_type\":\"%s\",\"type\":\"%d\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d,\"recurring\":%d,\"run_time\":%d}",
+ nted = (nebstruct_timed_event_data *)data;
+ event_type = eventtype2str(nted->event_type);
+ type = nebtype2str(nted->type);
+ snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"callback_type\":\"%s\",\"event_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d,\"recurring\":%d,\"run_time\":%d}",
"NEBCALLBACK_TIMED_EVENT_DATA",
- nted->type,
+ event_type,
+ type,
nted->flags,
nted->attr,
(int)nted->timestamp.tv_sec, (int)nted->timestamp.tv_usec,
nted->recurring,
(int)nted->run_time
);
+ free(event_type);
+ free(type);
break;
case NEBCALLBACK_LOG_DATA: /* 9 */
nld = (nebstruct_log_data *)data;
buffer = escapestring(nld->data);
- type = neb_type2str(nld->type);
- snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"event_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d,\"entry_time\":%d,\"data_type\":%d,\"data\":\"%s\"}",
+ type = nebtype2str(nld->type);
+ snprintf( temp_buffer,sizeof( temp_buffer )-1, "{\"callback_type\":\"%s\",\"type\":\"%s\",\"flags\":%d,\"attr\":%d,\"timestamp\":%d.%d,\"entry_time\":%d,\"data_type\":%d,\"data\":\"%s\"}",
"NEBCALLBACK_LOG_DATA",
type,
nld->flags,
@@ -1079,7 +1087,7 @@ int handle_export(int event_type, void *data) {
case NEBCALLBACK_ADAPTIVE_CONTACT_DATA: /* 32 */
break;
default:
- gm_log( GM_LOG_ERROR, "handle_export() unknown export type: %d\n", event_type );
+ gm_log( GM_LOG_ERROR, "handle_export() unknown export type: %d\n", callback_type );
mod_gm_opt->debug_level = debug_level_orig;
return 0;
}
@@ -1087,11 +1095,11 @@ int handle_export(int event_type, void *data) {
temp_buffer[sizeof( temp_buffer )-1]='\x0';
if(temp_buffer[0] != '\x0') {
- for(i=0;i<mod_gm_opt->exports[event_type]->elem_number;i++) {
- return_code = mod_gm_opt->exports[event_type]->return_code[i];
+ for(i=0;i<mod_gm_opt->exports[callback_type]->elem_number;i++) {
+ return_code = mod_gm_opt->exports[callback_type]->return_code[i];
add_job_to_queue( &client,
mod_gm_opt->server_list,
- mod_gm_opt->exports[event_type]->name[i], /* queue name */
+ mod_gm_opt->exports[callback_type]->name[i], /* queue name */
NULL,
temp_buffer,
GM_JOB_PRIO_NORMAL,
diff --git a/tools/perl/dump_queue.pl b/tools/perl/dump_queue.pl
index 8598895..fe13593 100755
--- a/tools/perl/dump_queue.pl
+++ b/tools/perl/dump_queue.pl
@@ -9,9 +9,10 @@ dump_queue.pl
./dump_queue.pl [ -v ]
[ -h ]
- [ -H=hostname:port ]
- [ -q=queue ]
- [ -c=configfile ]
+ [ -H hostname:port ]
+ [ -q queue ]
+ [ -c configfile ]
+ [ -p password ]
=head1 DESCRIPTION
@@ -35,19 +36,25 @@ enable verbose mode
=head2 hostname
- -H=hostname:port
+ -H hostname:port
hostname to connect to. Defaults to localhost:4731
=head2 queue
- -q=queue
+ -q queue
which queue to dump
+=head2 password
+
+ -p password
+
+password to encrypt data
+
=head2 configfile
- -c=configfile
+ -c configfile
read config from config file
@@ -127,8 +134,8 @@ sub dump_job {
$data = $cypher->decrypt($data);
}
print "###################\n";
- print Dumper($data);
- $data = decode_json($data);
#print Dumper($data);
+ $data = decode_json($data);
+ print Dumper($data);
return 1;
-}
\ No newline at end of file
+}
--
Debian packaging for mod gearman.
More information about the Pkg-nagios-changes
mailing list