diff --git a/src/pmdas/lustrecomm/file_indexed.c b/src/pmdas/lustrecomm/file_indexed.c index 270998c..b326335 100644 --- a/src/pmdas/lustrecomm/file_indexed.c +++ b/src/pmdas/lustrecomm/file_indexed.c @@ -44,7 +44,7 @@ int file_indexed (struct file_state *f_s, int type, int *base, void **vpp, int i /* reload file if it hasn't been reloaded in x */ if (refresh_file( f_s ) <0 ) { - fprintf(stderr,"file_indexed: refresh_file error"); + __pmNotifyErr(LOG_ERR, "file_indexed: refresh_file error"); return -1; } /* file_indexed assumes that the file contains one line diff --git a/src/pmdas/lustrecomm/help b/src/pmdas/lustrecomm/help index ace1383..0876863 100644 --- a/src/pmdas/lustrecomm/help +++ b/src/pmdas/lustrecomm/help @@ -34,8 +34,6 @@ # blank lines before the @ line are ignored # -@ LUSTRECOMM.1 lnet stats - @ lustrecomm.timeout @ lustrecomm.ldlm_timeout diff --git a/src/pmdas/lustrecomm/lustrecomm.c b/src/pmdas/lustrecomm/lustrecomm.c index d323a07..141fb17 100644 --- a/src/pmdas/lustrecomm/lustrecomm.c +++ b/src/pmdas/lustrecomm/lustrecomm.c @@ -121,6 +121,7 @@ struct file_state filestatetab[] = { { { 0 , 0 } , "/proc/sys/lnet/peers", 0, 0, NULL} }; +static int isDSO = 1; /* =0 I am a daemon */ static char mypath[MAXPATHLEN]; /* @@ -238,11 +239,20 @@ lustrecomm_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom void lustrecomm_init(pmdaInterface *dp) { + if (isDSO) { + int sep = __pmPathSeparator(); + snprintf(mypath, sizeof(mypath), "%s%c" "lustrecomm" "%c" "help", + pmGetConfig("PCP_PMDAS_DIR"), sep, sep); + pmdaDSO(dp, PMDA_INTERFACE_2, "lustrecomm DSO", mypath); + } + + if (dp->status != 0) + return; + pmdaSetFetchCallBack(dp, lustrecomm_fetchCallBack); pmdaInit(dp, NULL, 0, metrictab, sizeof(metrictab)/sizeof(metrictab[0])); - } static void @@ -256,7 +266,6 @@ usage(void) exit(1); } - /* * Set up the agent if running as a daemon. */ @@ -264,18 +273,13 @@ int main(int argc, char **argv) { int err = 0; + int sep = __pmPathSeparator(); pmdaInterface desc; - char *p; - - /* trim cmd name of leading directory components */ - pmProgname = argv[0]; - for (p = pmProgname; *p; p++) { - if (*p == '/') - pmProgname = p+1; - } - snprintf(mypath, sizeof(mypath), - "%s/lustrecomm/help", pmGetConfig("PCP_PMDAS_DIR")); + isDSO = 0; + __pmSetProgname(argv[0]); + snprintf(mypath, sizeof(mypath), "%s%c" "lustrecomm" "%c" "help", + pmGetConfig("PCP_PMDAS_DIR"), sep, sep); pmdaDaemon(&desc, PMDA_INTERFACE_2, pmProgname, LUSTRECOMM, "lustrecomm.log", mypath); @@ -291,5 +295,4 @@ main(int argc, char **argv) pmdaMain(&desc); exit(0); - /*NOTREACHED*/ } diff --git a/src/pmdas/lustrecomm/refresh_file.c b/src/pmdas/lustrecomm/refresh_file.c index 5329393..57d27bf 100644 --- a/src/pmdas/lustrecomm/refresh_file.c +++ b/src/pmdas/lustrecomm/refresh_file.c @@ -32,21 +32,23 @@ int refresh_file( struct file_state *f_s ){ struct timespec now, tmp; int i; - /* get time */ - if ( clock_gettime(CLOCK_MONOTONIC, &now) < 0 ) { - /* if we don't know what time it is */ - /* there's nothing we can do with this */ - return 0; - } - /* if time since last refresh > delta */ - tmp = timespec_add( &f_s->ts, &file_time_offset); - if ( timespec_le( &now, &tmp) ) { - /* file is recent */ - return 0; + if (f_s->datap) { + /* get time */ + if ( clock_gettime(CLOCK_MONOTONIC, &now) < 0 ) { + /* if we don't know what time it is */ + /* there's nothing we can do with this */ + return 0; + } + /* if time since last refresh > delta */ + tmp = timespec_add( &f_s->ts, &file_time_offset); + if ( timespec_le( &now, &tmp) ) { + /* file is recent */ + return 0; + } + f_s->ts = now; + /* clear old data, make errors obvious, autoterm trailing strings */ + memset ( f_s->datap, 0, f_s->datas ); } - f_s->ts = now; - /* clear old data, make errors obvious, autoterm trailing strings */ - memset ( f_s->datap, 0, f_s->datas ); /* if fd is null open file */ if ( f_s->fd <= 0) { if (( f_s->fd = open (f_s->filename, O_RDONLY)) < 0) {