29 #define DISCOVERY_SUBCLASS
57 return self->_intervalsecs;
65 if (self->jsonparams) {
66 UNREF(self->jsonparams);
68 if (self->logprefix) {
69 g_free(self->logprefix);
70 self->logprefix = NULL;
72 if (self->_fullpath) {
73 g_free(self->_fullpath);
74 self->_fullpath = NULL;
86 if (NULL != self->child) {
87 g_warning(
"%s.%d: JSON discovery process still running - skipping this iteration."
91 ++
self->baseclass.discovercount;
93 DEBUGMSG2(
"%s.%d: don't have [%s] address yet - continuing."
96 argv[0] =
self->_fullpath;
99 DEBUGMSG1(
"Running Discovery [%s]", argv[0]);
111 , G_LOG_LEVEL_MESSAGE
128 , gboolean core_dumped)
131 gchar* jsonout = NULL;
142 jsonlen = strlen(jsonout);
144 g_warning(
"JSON discovery [%s] produced no output.", self->_fullpath);
167 const char * basename =
self->
baseclass.instancename(&self->baseclass);
169 g_return_if_fail(cfg != NULL && io != NULL);
171 DEBUGMSG2(
"%s.%d: discovering %s: _sentyet == %d"
172 ,
__FUNCTION__, __LINE__, basename, self->baseclass._sentyet);
174 if (self->baseclass._sentyet) {
175 const char * oldvalue = cfg->
getstring(cfg, basename);
176 if (oldvalue != NULL && strcmp(jsonout, oldvalue) == 0) {
177 DEBUGMSG2(
"%s.%d: %s sent this value - don't send again."
182 DEBUGMSG2(
"%s.%d: %s this value is different from previous value"
185 DEBUGMSG2(
"%s.%d: Sending %"G_GSIZE_FORMAT
" bytes of JSON text"
190 DEBUGMSG2(
"%s.%d: %s address is unknown - skipping send"
195 self->baseclass._sentyet = TRUE;
202 DEBUGMSG2(
"%s.%d: Sending a %"G_GSIZE_FORMAT
" bytes JSON frameset"
205 ++
self->baseclass.reportcount;
213 const char * instancename,
220 const char * basedir = NULL;
225 g_return_val_if_fail(jsoninst != NULL, NULL);
226 g_return_val_if_fail(*discoverytype !=
'/', NULL);
227 jsonparams = jsoninst->
getconfig(jsoninst,
"parameters");
228 g_return_val_if_fail(jsonparams != NULL, NULL);
232 g_return_val_if_fail(ret != NULL, NULL);
239 basedir = context->
getstring(context,
"JSONAGENTROOT");
240 if (NULL == basedir) {
243 ret->
_fullpath = g_strdup_printf(
"%s%s%s", basedir,
"/", discoverytype);
244 ret->
logprefix = g_strdup_printf(
"Discovery %s: ", instancename);
245 DEBUGMSG2(
"%s.%d: FULLPATH=[%s] discoverytype[%s]"