char *keys[16];
char len_str[3];
char tmp[DATA_MAX_NAME_LEN];
+ size_t key_chars_remaining = (DATA_MAX_NAME_LEN-1);
int reserved = 0;
int offset = 0;
memset(tmp, 0, sizeof(tmp));
/** concatenate each part of source string **/
for(i = 0; i < keys_num; i++)
{
- strcat(tmp, keys[i]);
+ strncat(tmp, keys[i], key_chars_remaining);
+ key_chars_remaining -= strlen(keys[i]);
}
- tmp[DATA_MAX_NAME_LEN - 1] = '\0';
/** to coordinate limitation of length of ds name from RRD
* we will truncate ds_name
* when the its length is more than
ds = &ds_array[dset->ds_num++];
snprintf(ds->name, MAX_RRD_DS_NAME_LEN, "%s", ds_name);
ds->type = (pc_type & PERFCOUNTER_DERIVE) ? DS_TYPE_DERIVE : DS_TYPE_GAUGE;
-
+
/**
* Use min of 0 for DERIVE types so we don't get negative values on Ceph
* service restart
if(strcasecmp("Daemon", child->key) == 0)
{
ret = cc_add_daemon_config(child);
- if(ret)
+ if(ret == ENOMEM)
{
+ ERROR("ceph plugin: Couldn't allocate memory");
return ret;
}
+ else if(ret)
+ {
+ //process other daemons and ignore this one
+ continue;
+ }
}
else if(strcasecmp("LongRunAvgLatency", child->key) == 0)
{
{
double sum, result;
sscanf(val, "%lf", &sum);
- DEBUG("avgcount:%ld",vtmp->avgcount);
+ DEBUG("avgcount:%" PRIu64 "",vtmp->avgcount);
DEBUG("sum:%lf",sum);
if(vtmp->avgcount == 0)
int flags, fd, err;
if(io->state != CSTATE_UNCONNECTED)
{
- ERROR("cconn_connect: io->state != CSTATE_UNCONNECTED");
+ ERROR("ceph plugin: cconn_connect: io->state != CSTATE_UNCONNECTED");
return -EDOM;
}
fd = socket(PF_UNIX, SOCK_STREAM, 0);
if(fd < 0)
{
int err = -errno;
- ERROR("cconn_connect: socket(PF_UNIX, SOCK_STREAM, 0) failed: "
- "error %d", err);
+ ERROR("ceph plugin: cconn_connect: socket(PF_UNIX, SOCK_STREAM, 0) "
+ "failed: error %d", err);
return err;
}
memset(&address, 0, sizeof(struct sockaddr_un));
connect(fd, (struct sockaddr *) &address, sizeof(struct sockaddr_un)));
if(err < 0)
{
- ERROR("cconn_connect: connect(%d) failed: error %d", fd, err);
+ ERROR("ceph plugin: cconn_connect: connect(%d) failed: error %d",
+ fd, err);
return err;
}
if(fcntl(fd, F_SETFL, flags | O_NONBLOCK) != 0)
{
err = -errno;
- ERROR("cconn_connect: fcntl(%d, O_NONBLOCK) error %d", fd, err);
+ ERROR("ceph plugin: cconn_connect: fcntl(%d, O_NONBLOCK) error %d",
+ fd, err);
return err;
}
io->asok = fd;
{
if(revents & POLLERR)
{
- ERROR("cconn_validate_revents(name=%s): got POLLERR", io->d->name);
+ ERROR("ceph plugin: cconn_validate_revents(name=%s): got POLLERR",
+ io->d->name);
return -EIO;
}
switch (io->state)
return (revents & POLLIN) ? 0 : -EINVAL;
return (revents & POLLIN) ? 0 : -EINVAL;
default:
- ERROR("cconn_validate_revents(name=%s) got to illegal state on "
- "line %d", io->d->name, __LINE__);
+ ERROR("ceph plugin: cconn_validate_revents(name=%s) got to "
+ "illegal state on line %d", io->d->name, __LINE__);
return -EDOM;
}
}
switch (io->state)
{
case CSTATE_UNCONNECTED:
- ERROR("cconn_handle_event(name=%s) got to illegal state on line "
- "%d", io->d->name, __LINE__);
+ ERROR("ceph plugin: cconn_handle_event(name=%s) got to illegal "
+ "state on line %d", io->d->name, __LINE__);
return -EDOM;
case CSTATE_WRITE_REQUEST:
io->d->version = ntohl(io->d->version);
if(io->d->version != 1)
{
- ERROR("cconn_handle_event(name=%s) not "
- "expecting version %d!", io->d->name, io->d->version);
+ ERROR("ceph plugin: cconn_handle_event(name=%s) not "
+ "expecting version %d!", io->d->name, io->d->version);
return -ENOTSUP;
- }DEBUG("cconn_handle_event(name=%s): identified as "
+ }
+ DEBUG("cconn_handle_event(name=%s): identified as "
"version %d", io->d->name, io->d->version);
io->amt = 0;
cconn_close(io);
io->json = calloc(1, io->json_len + 1);
if(!io->json)
{
- ERROR("ERR CALLOCING IO->JSON");
+ ERROR("ceph plugin: error callocing io->json");
return -ENOMEM;
}
}
return 0;
}
default:
- ERROR("cconn_handle_event(name=%s) got to illegal state on "
- "line %d", io->d->name, __LINE__);
+ ERROR("ceph plugin: cconn_handle_event(name=%s) got to illegal "
+ "state on line %d", io->d->name, __LINE__);
return -EDOM;
}
}
fds->events = POLLIN;
return 1;
default:
- ERROR("cconn_prepare(name=%s) got to illegal state on line %d",
- io->d->name, __LINE__);
+ ERROR("ceph plugin: cconn_prepare(name=%s) got to illegal state "
+ "on line %d", io->d->name, __LINE__);
return -EDOM;
}
}
ret = cconn_prepare(io, fds + nfds);
if(ret < 0)
{
- WARNING("ERROR: cconn_prepare(name=%s,i=%d,st=%d)=%d",
+ WARNING("ceph plugin: cconn_prepare(name=%s,i=%d,st=%d)=%d",
io->d->name, i, io->state, ret);
cconn_close(io);
io->request_type = ASOK_REQ_NONE;
{
/* Timed out */
ret = -ETIMEDOUT;
- WARNING("ERROR: cconn_main_loop: timed out.\n");
+ WARNING("ceph plugin: cconn_main_loop: timed out.");
goto done;
}
RETRY_ON_EINTR(ret, poll(fds, nfds, diff));
if(ret < 0)
{
- ERROR("poll(2) error: %d", ret);
+ ERROR("ceph plugin: poll(2) error: %d", ret);
goto done;
}
for(i = 0; i < nfds; ++i)
}
else if(cconn_validate_revents(io, revents))
{
- WARNING("ERROR: cconn(name=%s,i=%d,st=%d): "
+ WARNING("ceph plugin: cconn(name=%s,i=%d,st=%d): "
"revents validation error: "
"revents=0x%08x", io->d->name, i, io->state, revents);
cconn_close(io);
int ret = cconn_handle_event(io);
if(ret)
{
- WARNING("ERROR: cconn_handle_event(name=%s,"
+ WARNING("ceph plugin: cconn_handle_event(name=%s,"
"i=%d,st=%d): error %d", io->d->name, i, io->state, ret);
cconn_close(io);
io->request_type = ASOK_REQ_NONE;
ret = plugin_register_data_set(d->dset + j);
if(ret)
{
- ERROR("plugin_register_data_set(%s) failed!", d->name);
+ ERROR("ceph plugin: plugin_register_data_set(%s) failed!",
+ d->name);
}
else
{