Skip to content

Commit

Permalink
dird: stored: error messages when statistics thread is not started
Browse files Browse the repository at this point in the history
  • Loading branch information
alaaeddineelamri committed Jan 28, 2022
1 parent 48e7190 commit 502f282
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
14 changes: 12 additions & 2 deletions core/src/dird/stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
#include "lib/bnet.h"
#include "lib/parse_conf.h"
#include "lib/util.h"
#include "lib/berrno.h"

namespace directordaemon {

Expand Down Expand Up @@ -319,13 +320,22 @@ bool StartStatisticsThread(void)
}
int status;

if (!me->stats_collect_interval || !collectstatistics) { return 0; }
if (!me->stats_collect_interval || !collectstatistics) {
Emsg1(M_INFO, 0,
_("Director Statistics Thread will not be started. Modify your "
"configuration if you want to activate it.\n"));

return false;
}

quit = false;

if ((status = pthread_create(&statistics_tid, NULL, statistics_thread, NULL))
!= 0) {
return status;
BErrNo be;
Emsg1(M_ERROR_TERM, 0,
_("Director Statistics Thread could not be started. ERR=%s\n"),
be.bstrerror());
}

statistics_initialized = true;
Expand Down
18 changes: 15 additions & 3 deletions core/src/stored/sd_stats.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#include "include/jcr.h"
#include "lib/parse_conf.h"
#include "lib/bsock.h"
#include "lib/berrno.h"

namespace storagedaemon {

Expand Down Expand Up @@ -415,7 +416,10 @@ bool StartStatisticsThread(void)
// First see if device and job stats collection is enabled.
if (!me->stats_collect_interval
|| (!me->collect_dev_stats && !me->collect_job_stats)) {
return 0;
Emsg1(M_INFO, 0,
_("Director Statistics Thread was not started. Modify your "
"configuration if you want to activate it.\n"));
return false;
}

/*
Expand All @@ -430,13 +434,21 @@ bool StartStatisticsThread(void)
if (device_resource->collectstats) { cnt++; }
}

if (cnt == 0) { return 0; }
if (cnt == 0) {
Emsg1(M_INFO, 0,
_("Director Statistics Thread was not started. Modify your "
"configuration if you want to activate it.\n"));
return false;
}
}

if ((status
= pthread_create(&statistics_tid, NULL, statistics_thread_runner, NULL))
!= 0) {
return status;
BErrNo be;
Emsg1(M_ERROR_TERM, 0,
_("Director Statistics Thread could not be started. ERR=%s\n"),
be.bstrerror());
}

statistics_initialized = true;
Expand Down

0 comments on commit 502f282

Please sign in to comment.