Index: head/sysutils/libsysstat/Makefile =================================================================== --- head/sysutils/libsysstat/Makefile (revision 555949) +++ head/sysutils/libsysstat/Makefile (revision 555950) @@ -1,23 +1,23 @@ # Created by: Olivier Duchateau # $FreeBSD$ PORTNAME= libsysstat -PORTVERSION= 0.4.3 +PORTVERSION= 0.4.4 CATEGORIES= sysutils MASTER_SITES= LXQT/${PORTNAME} MAINTAINER= jsm@FreeBSD.org COMMENT= Library used to query system info and statistics LICENSE= LGPL21+ LICENSE_FILE= ${WRKSRC}/COPYING USES= cmake compiler:c++11-lang lxqt pkgconfig tar:xz qt:5 USE_QT= qmake_build buildtools_build core USE_LXQT= buildtools USE_LDCONFIG= yes post-extract: @${CP} ${FILESDIR}/config.h.in ${WRKSRC} .include Index: head/sysutils/libsysstat/distinfo =================================================================== --- head/sysutils/libsysstat/distinfo (revision 555949) +++ head/sysutils/libsysstat/distinfo (revision 555950) @@ -1,3 +1,3 @@ -TIMESTAMP = 1588434445 -SHA256 (lxqt/libsysstat-0.4.3.tar.xz) = 67dc786a4aca4b6ce142a2355ac6dd4c873c1e03f978676926500fffa73ebae8 -SIZE (lxqt/libsysstat-0.4.3.tar.xz) = 17520 +TIMESTAMP = 1605119504 +SHA256 (lxqt/libsysstat-0.4.4.tar.xz) = 3997d17692d2ea467d384517aedb8fcc4050f2f66114a1405d42cef0adaafa6b +SIZE (lxqt/libsysstat-0.4.4.tar.xz) = 17532 Index: head/sysutils/libsysstat/files/patch-cpustat.cpp =================================================================== --- head/sysutils/libsysstat/files/patch-cpustat.cpp (revision 555949) +++ head/sysutils/libsysstat/files/patch-cpustat.cpp (revision 555950) @@ -1,261 +1,295 @@ ---- cpustat.cpp.orig 2019-01-24 21:43:32 UTC +--- cpustat.cpp.orig 2020-11-03 14:45:02 UTC +++ cpustat.cpp -@@ -27,11 +27,62 @@ +@@ -27,11 +27,64 @@ #include #include "cpustat.h" +#ifdef HAVE_SYSCTL_H +extern "C" +{ + #include + #include + #include + #include /* CPUSTATES */ + + #include + #include +} +#endif #include "cpustat_p.h" namespace SysStat { +#ifdef HAVE_SYSCTL_H +char *GetFirstFragment(char *string, const char *delim) +{ + char *token = NULL; + token = strsep(&string, delim); + if (token != NULL) + { + /* We need only the first fragment, so no loop! */ + return token; + } + else + return NULL; +} + +int GetCpu(void) +{ + static int mib[] = { CTL_HW, HW_NCPU }; + int buf; + size_t len = sizeof(int); + + if (sysctl(mib, 2, &buf, &len, NULL, 0) < 0) + return 0; + else + return buf; +} + +/* Frequence is in MHz */ -+ulong CurrentFreq(void) ++ulong CpuStatPrivate::CurrentFreq(void) +{ + ulong freq=0; + size_t len = sizeof(freq); + -+ if (sysctlbyname("dev.cpu.0.freq", &freq, &len, NULL, 0) < 0) // man cpufreq BUGS section all cores have the same frequency. ++ if (sysctl(mib2,4,&freq, &len, NULL, 0) < 0) { // man cpufreq BUGS section all cores have the same frequency. ++ perror("sysctl"); + return 0; ++} + else + return freq; + +} +#endif CpuStatPrivate::CpuStatPrivate(CpuStat *parent) : BaseStatPrivate(parent) , mMonitoring(CpuStat::LoadAndFrequency) -@@ -39,7 +90,11 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent) +@@ -39,7 +92,13 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent) mSource = defaultSource(); connect(mTimer, SIGNAL(timeout()), SLOT(timeout())); - +#ifdef HAVE_SYSCTL_H + size_t flen=2; ++ size_t alen=4; + sysctlnametomib("kern.cp_times",mib0,&flen); + sysctlnametomib("kern.cp_time",mib1,&flen); ++ sysctlnametomib("dev.cpu.0.freq",mib2,&alen); +#endif mUserHz = sysconf(_SC_CLK_TCK); updateSources(); -@@ -47,6 +102,49 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent) +@@ -47,6 +106,51 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *parent) void CpuStatPrivate::addSource(const QString &source) { +#ifdef HAVE_SYSCTL_H + char buf[1024]; + char *tokens, *t; + ulong min = 0, max = 0; + size_t len = sizeof(buf); + + /* The string returned by the dev.cpu.0.freq_levels sysctl + * is a space separated list of MHz/milliwatts. + */ + if (sysctlbyname("dev.cpu.0.freq_levels", buf, &len, NULL, 0) < 0) + return; + + t = strndup(buf, len); + if (t == NULL) + { + free(t); + return; + } -+ + while ((tokens = strsep(&t, " ")) != NULL) + { + char *freq; + ulong res; + + freq = GetFirstFragment(tokens, "/"); + if (freq != NULL) + { + res = strtoul(freq, &freq, 10); + if (res > max) + { + max = res; + } + else + { + if ((min == 0) || (res < min)) + min = res; + } -+ } ++ if (res + 1 == max) ++ max--; ++ } ++ + } + + free(t); + mBounds[source] = qMakePair(min, max); + #else bool ok; uint min = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_min_freq").arg(source))).toUInt(&ok); -@@ -56,12 +154,27 @@ void CpuStatPrivate::addSource(const QString &source) +@@ -56,12 +160,27 @@ void CpuStatPrivate::addSource(const QString &source) if (ok) mBounds[source] = qMakePair(min, max); } +#endif } void CpuStatPrivate::updateSources() { mSources.clear(); +#ifdef HAVE_SYSCTL_H + mBounds.clear(); + int cpu; + cpu = GetCpu(); + mSources.append(QStringLiteral("cpu")); // Linux has cpu in /proc/stat + for (int i =0;i(cp_times[CP_USER+cpuNumber*CPUSTATES]); + current.nice = static_cast(cp_times[CP_NICE+cpuNumber*CPUSTATES]); + current.system = static_cast(cp_times[CP_SYS+cpuNumber*CPUSTATES]); + current.idle = static_cast(cp_times[CP_IDLE+cpuNumber*CPUSTATES]); + current.other = static_cast(cp_times[CP_INTR+cpuNumber*CPUSTATES]); + current.total = current.user + current.nice + current.system+current.idle+current.other; + + float sumDelta = static_cast(current.total - mPrevious.total); -+ + if ((mPrevious.total != 0) && ((sumDelta < mIntervalMin) || (sumDelta > mIntervalMax))) + { -+ if (mMonitoring == CpuStat::LoadAndFrequency) -+ emit update(0.0, 0.0, 0.0, 0.0, 0.0, 0); -+ else ++ if (mMonitoring == CpuStat::LoadAndFrequency) ++ { ++ float freqRate = 1.0; ++ ulong freq = CurrentFreq(); ++ ++ if (freq > 0) ++ { ++ if (mSource == QLatin1String("cpu")) ++ mSource = QLatin1String("cpu0"); ++ //do not report more than 100% ++ if (freq > mBounds[mSource].second) { ++ freq = mBounds[mSource].second; ++ } ++ freqRate = static_cast(freq) / static_cast(mBounds[mSource].second); ++ emit update(0.0, 0.0, 0.0, 0.0, static_cast(freqRate), freq); ++ } ++ } ++ else { + emit update(0.0, 0.0, 0.0, 0.0); -+ ++ } + mPrevious.clear(); + } + else ++ + { + if (mMonitoring == CpuStat::LoadAndFrequency) + { + float freqRate = 1.0; + ulong freq = CurrentFreq(); ++ + if (freq > 0) + { -+ if(mSource==QLatin1String("cpu")) -+ freqRate = static_cast(freq) / static_cast(mBounds[QStringLiteral("cpu0")].second);// use max cpu0 for this case -+ else -+ freqRate = static_cast(freq) / static_cast(mBounds[mSource].second); ++ if (mSource == QLatin1String("cpu")) ++ mSource = QLatin1String("cpu0"); ++ //do not report more than 100% ++ if (freq > mBounds[mSource].second) { ++ freq = mBounds[mSource].second; ++ } ++ freqRate = static_cast(freq) / static_cast(mBounds[mSource].second); + emit update( + static_cast(current.user - mPrevious.user ) / sumDelta, + static_cast(current.nice - mPrevious.nice ) / sumDelta, + static_cast(current.system - mPrevious.system) / sumDelta, + static_cast(current.other - mPrevious.other ) / sumDelta, + static_cast(freqRate), + freq); + } + } + else + { + emit update( + static_cast(current.user - mPrevious.user ) / sumDelta, + static_cast(current.nice - mPrevious.nice ) / sumDelta, + static_cast(current.system - mPrevious.system) / sumDelta, + static_cast(current.other - mPrevious.other ) / sumDelta); + } + + + mPrevious = current; + } + + free(cp_times); + } + else + { + ulong freq = 0; + + freq = CurrentFreq(); + if (freq > 0) + emit update(freq); + } +#else if ( (mMonitoring == CpuStat::LoadOnly) || (mMonitoring == CpuStat::LoadAndFrequency) ) { -@@ -261,6 +457,7 @@ void CpuStatPrivate::timeout() +@@ -229,7 +450,7 @@ void CpuStatPrivate::timeout() + mPrevious = current; + } + } +- } ++ //} + } + else + { +@@ -261,6 +482,7 @@ void CpuStatPrivate::timeout() } emit update(freq); } +#endif } QString CpuStatPrivate::defaultSource() Index: head/sysutils/libsysstat/files/patch-cpustat.h =================================================================== --- head/sysutils/libsysstat/files/patch-cpustat.h (revision 555949) +++ head/sysutils/libsysstat/files/patch-cpustat.h (revision 555950) @@ -1,25 +1,32 @@ ---- cpustat.h.orig 2019-01-30 19:27:42 UTC +--- cpustat.h.orig 2020-11-03 14:45:02 UTC +++ cpustat.h -@@ -27,14 +27,20 @@ +@@ -27,14 +27,19 @@ #ifndef LIBSYSSTAT__CPU_STAT__INCLUDED #define LIBSYSSTAT__CPU_STAT__INCLUDED - +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include "basestat.h" namespace SysStat { - +#ifdef HAVE_SYSCTL_H + char *GetFirstFragment(char *string, const char *delim); + int GetCpu(void); -+ ulong CurrentFreq(void); +#endif class CpuStatPrivate; class SYSSTATSHARED_EXPORT CpuStat : public BaseStat +@@ -54,7 +59,6 @@ class SYSSTATSHARED_EXPORT CpuStat : public BaseStat ( + + uint minFreq(const QString &source) const; + uint maxFreq(const QString &source) const; +- + signals: + void update(float user, float nice, float system, float other, float frequencyRate, uint frequency); + void update(float user, float nice, float system, float other); Index: head/sysutils/libsysstat/files/patch-cpustat__p.h =================================================================== --- head/sysutils/libsysstat/files/patch-cpustat__p.h (revision 555949) +++ head/sysutils/libsysstat/files/patch-cpustat__p.h (revision 555950) @@ -1,62 +1,65 @@ ---- cpustat_p.h.orig 2019-01-30 19:24:29 UTC +--- cpustat_p.h.orig 2020-11-03 14:45:02 UTC +++ cpustat_p.h @@ -27,6 +27,9 @@ #ifndef LIBSYSSTAT__CPU_STAT__PRIVATE__INCLUDED #define LIBSYSSTAT__CPU_STAT__PRIVATE__INCLUDED +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif #include #include -@@ -52,8 +55,13 @@ class CpuStatPrivate : public BaseStatPrivate (public) +@@ -52,8 +55,15 @@ class CpuStatPrivate : public BaseStatPrivate (public) CpuStat::Monitoring monitoring() const; void setMonitoring(CpuStat::Monitoring value); +#ifdef HAVE_SYSCTL_H + ulong minFreq(const QString &source) const; + ulong maxFreq(const QString &source) const; ++ ulong CurrentFreq(void); ++ +#else uint minFreq(const QString &source) const; uint maxFreq(const QString &source) const; +#endif signals: void update(float user, float nice, float system, float other); -@@ -74,12 +82,21 @@ private slots: (private) +@@ -74,12 +84,21 @@ private slots: (private) { Values(); +#ifdef HAVE_SYSCTL_H + ulong user; + ulong nice; + ulong system; + ulong idle; + ulong other; + ulong total; +#else qulonglong user; qulonglong nice; qulonglong system; qulonglong idle; qulonglong other; qulonglong total; +#endif void sum(); -@@ -89,7 +106,13 @@ private slots: (private) +@@ -89,7 +108,14 @@ private slots: (private) CpuStat::Monitoring mMonitoring; +#ifdef HAVE_SYSCTL_H + typedef QMap > Bounds; + int mib0[2]; + int mib1[2]; ++ int mib2[4]; +#else typedef QMap > Bounds; +#endif Bounds mBounds; int mUserHz;