Skip to content

Commit

Permalink
Merge branches 'Erbenos-fix(statsd)/keep-correct-track-of-pmns-mapped…
Browse files Browse the repository at this point in the history
…-metric-count', 'pmdalinux-div-by-zero' and 'pmie-config-permissions'
  • Loading branch information
natoscott committed Sep 19, 2024
3 parents 9713356 + 7423036 + ca7a073 commit 956ce74
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 13 deletions.
9 changes: 5 additions & 4 deletions build/rpm/pcp.spec.in
Original file line number Diff line number Diff line change
Expand Up @@ -220,11 +220,12 @@ fi
}

%global run_pmieconf() %{expand:
if [ -w "%1" ]
if [ -d "%1" -a -w "%1" -a -w "%1/%2" ]
then
pmieconf -c enable "%2"
pmieconf -f "%1/%2" -c enable "%3"
chown pcp:pcp "%1/%2" 2>/dev/null
else
echo "WARNING: Cannot write to %1, skipping pmieconf enable of %2." >&2
echo "WARNING: Cannot write to %1/%2, skipping pmieconf enable of %3." >&2
fi
}

Expand Down Expand Up @@ -2747,7 +2748,7 @@ for PMDA in $needinstall ; do
fi
done
# auto-enable these usually optional pmie rules
%{run_pmieconf "$PCP_PMIECONFIG_DIR" dmthin}
%{run_pmieconf "$PCP_PMIECONFIG_DIR" config.default dmthin}
%if "@enable_systemd@" == "true"
systemctl restart pcp-reboot-init pmcd pmlogger pmie >/dev/null 2>&1
systemctl enable pcp-reboot-init pmcd pmlogger pmie >/dev/null 2>&1
Expand Down
9 changes: 5 additions & 4 deletions build/rpm/redhat.spec
Original file line number Diff line number Diff line change
Expand Up @@ -476,11 +476,12 @@ fi
}

%global run_pmieconf() %{expand:
if [ -w "%1" ]
if [ -d "%1" -a -w "%1" -a -w "%1/%2" ]
then
pmieconf -c enable "%2"
pmieconf -f "%1/%2" -c enable "%3"
chown pcp:pcp "%1/%2" 2>/dev/null
else
echo "WARNING: Cannot write to %1, skipping pmieconf enable of %2." >&2
echo "WARNING: Cannot write to %1/%2, skipping pmieconf enable of %3." >&2
fi
}

Expand Down Expand Up @@ -3223,7 +3224,7 @@ for PMDA in dm nfsclient openmetrics ; do
fi
done
# auto-enable these usually optional pmie rules
%{run_pmieconf "$PCP_PMIECONFIG_DIR" dmthin}
%{run_pmieconf "$PCP_PMIECONFIG_DIR" config.default dmthin}
%if 0%{?rhel} <= 9
%if !%{disable_systemd}
systemctl restart pcp-reboot-init pmcd pmlogger pmie >/dev/null 2>&1
Expand Down
3 changes: 2 additions & 1 deletion debian/pcp-zeroconf.postinst
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@ for PMDA in dm nfsclient openmetrics ; do
done

# auto-enable these usually optional pmie rules
pmieconf -c enable dmthin
pmieconf -f /var/lib/pcp/config/pmie/config.default -c enable dmthin
chown pcp:pcp /var/lib/pcp/config/pmie/config.default
14 changes: 10 additions & 4 deletions src/pmdas/linux/pmda.c
Original file line number Diff line number Diff line change
Expand Up @@ -8877,8 +8877,10 @@ linux_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom)
break;
case 8: /* filesys.full */
used = (__uint64_t)(sbuf->f_blocks - sbuf->f_bfree);
ull = used + (__uint64_t)sbuf->f_bavail;
atom->d = (100.0 * (double)used) / (double)ull;
if ((ull = used + (__uint64_t)sbuf->f_bavail) == 0)
atom->d = 0; /* protect against divide-by-zero */
else
atom->d = (100.0 * (double)used) / (double)ull;
break;
case 9: /* filesys.blocksize -- added by Mike Mason <[email protected]> */
atom->ul = sbuf->f_bsize;
Expand Down Expand Up @@ -8949,8 +8951,10 @@ linux_fetchCallBack(pmdaMetric *mdesc, unsigned int inst, pmAtomValue *atom)
break;
case 7: /* tmpfs.full */
used = (__uint64_t)(sbuf->f_blocks - sbuf->f_bfree);
ull = used + (__uint64_t)sbuf->f_bavail;
atom->d = (100.0 * (double)used) / (double)ull;
if ((ull = used + (__uint64_t)sbuf->f_bavail) == 0)
atom->d = 0; /* protect against divide-by-zero */
else
atom->d = (100.0 * (double)used) / (double)ull;
break;
default:
return PM_ERR_PMID;
Expand Down Expand Up @@ -10659,6 +10663,8 @@ linux_init(pmdaInterface *dp)
hz = atoi(envpath);
} else
hz = sysconf(_SC_CLK_TCK);
if (hz == 0) /* protect against divide-by-zero */
hz = 1;
if ((envpath = getenv("LINUX_NCPUS")) != NULL) {
/*
* If $LINUX_NCPUS is set, this is a QA setting that
Expand Down

0 comments on commit 956ce74

Please sign in to comment.