Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 30 Jul 2018 15:00:40 +0000 (UTC)
From:      Jesper Schmitz Mouridsen <jsm@FreeBSD.org>
To:        ports-committers@freebsd.org, svn-ports-all@freebsd.org, svn-ports-head@freebsd.org
Subject:   svn commit: r475896 - in head/sysutils: . libsysstat libsysstat/files
Message-ID:  <201807301500.w6UF0ePc095536@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jsm
Date: Mon Jul 30 15:00:40 2018
New Revision: 475896
URL: https://svnweb.freebsd.org/changeset/ports/475896

Log:
  New port sysutils/libsysstat
  
  PR: 229296
  Approved by: miwi (mentor)
  Differential Revision: https://reviews.freebsd.org/D16498

Added:
  head/sysutils/libsysstat/
  head/sysutils/libsysstat/Makefile   (contents, props changed)
  head/sysutils/libsysstat/distinfo   (contents, props changed)
  head/sysutils/libsysstat/files/
  head/sysutils/libsysstat/files/config.h.in   (contents, props changed)
  head/sysutils/libsysstat/files/patch-CMakeLists.txt   (contents, props changed)
  head/sysutils/libsysstat/files/patch-cpustat.cpp   (contents, props changed)
  head/sysutils/libsysstat/files/patch-cpustat.h   (contents, props changed)
  head/sysutils/libsysstat/files/patch-cpustat__p.h   (contents, props changed)
  head/sysutils/libsysstat/files/patch-memstat.cpp   (contents, props changed)
  head/sysutils/libsysstat/files/patch-memstat.h   (contents, props changed)
  head/sysutils/libsysstat/files/patch-netstat.cpp   (contents, props changed)
  head/sysutils/libsysstat/pkg-descr   (contents, props changed)
  head/sysutils/libsysstat/pkg-plist   (contents, props changed)
Modified:
  head/sysutils/Makefile

Modified: head/sysutils/Makefile
==============================================================================
--- head/sysutils/Makefile	Mon Jul 30 14:31:11 2018	(r475895)
+++ head/sysutils/Makefile	Mon Jul 30 15:00:40 2018	(r475896)
@@ -598,6 +598,7 @@
     SUBDIR += libieee1284
     SUBDIR += libretto-config
     SUBDIR += libsunacl
+    SUBDIR += libsysstat 
     SUBDIR += liburcu
     SUBDIR += libutempter
     SUBDIR += life-preserver

Added: head/sysutils/libsysstat/Makefile
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/Makefile	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,21 @@
+# Created by: Olivier Duchateau
+# $FreeBSD$
+
+PORTNAME=	libsysstat
+PORTVERSION=	0.4.1
+CATEGORIES=	sysutils
+MASTER_SITES=	LXQT/${PORTNAME}
+
+MAINTAINER=	jsm@FreeBSD.org
+COMMENT=	Library used to query system info and statistics
+
+LICENSE=	LGPL21
+
+USES=	cmake:outsource lxqt pkgconfig tar:xz qt:5
+USE_QT=	qmake_build buildtools_build core
+USE_LXQT=	buildtools
+
+post-extract:
+	@${CP} ${FILESDIR}/config.h.in ${WRKSRC};
+
+.include <bsd.port.mk>

Added: head/sysutils/libsysstat/distinfo
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/distinfo	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,3 @@
+TIMESTAMP = 1532774948
+SHA256 (lxqt/libsysstat-0.4.1.tar.xz) = c376e5c3a650d56873f2bd757292282f6b6b5af7ecc6d24c7a4df7b8c646ff59
+SIZE (lxqt/libsysstat-0.4.1.tar.xz) = 17304

Added: head/sysutils/libsysstat/files/config.h.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/files/config.h.in	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,3 @@
+#cmakedefine HAVE_SYSCTL_H
+#cmakedefine HAVE_IF_H
+#cmakedefine HAVE_KVM_H

Added: head/sysutils/libsysstat/files/patch-CMakeLists.txt
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/files/patch-CMakeLists.txt	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,32 @@
+--- CMakeLists.txt.orig	2018-05-21 17:16:59 UTC
++++ CMakeLists.txt
+@@ -24,6 +24,16 @@ include(LXQtCreatePkgConfigFile)
+ include(LXQtCreatePortableHeaders)
+ include(LXQtCompilerSettings NO_POLICY_SCOPE)
+ 
++include(CheckIncludeFiles)
++include(CheckLibraryExists)
++
++check_include_files("sys/socket.h;net/if.h;net/if_mib.h;net/if_types.h" HAVE_IF_H)
++check_library_exists(kvm kvm_getswapinfo "kvm.h" HAVE_KVM_H)
++check_library_exists(c sysctlbyname "sys/sysctl.h" HAVE_SYSCTL_H)
++
++configure_file(config.h.in config.h)
++add_definitions("-DHAVE_CONFIG_H=1")
++
+ set(CMAKE_AUTOMOC ON)
+ set(CMAKE_INCLUDE_CURRENT_DIR ON)
+ 
+@@ -81,7 +91,11 @@ add_library(${SYSSTAT_LIBRARY_NAME}
+         ${SYSSTAT_QM_FILES}
+ )
+ 
+-target_link_libraries(${SYSSTAT_LIBRARY_NAME} Qt5::Core)
++if(HAVE_SYSCTL_H AND HAVE_KVM_H)
++    target_link_libraries(${SYSSTAT_LIBRARY_NAME} c kvm Qt5::Core)
++else()
++    target_link_libraries(${SYSSTAT_LIBRARY_NAME} Qt5::Core)
++endif()
+ 
+ set_target_properties(${SYSSTAT_LIBRARY_NAME} PROPERTIES
+     VERSION ${SYSSTAT_VERSION}

Added: head/sysutils/libsysstat/files/patch-cpustat.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/files/patch-cpustat.cpp	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,264 @@
+--- cpustat.cpp.orig	2018-05-21 17:16:59 UTC
++++ cpustat.cpp
+@@ -25,13 +25,64 @@
+ 
+ 
+ #include <unistd.h>
+-
+ #include "cpustat.h"
++#ifdef HAVE_SYSCTL_H
++extern "C"
++{
++    #include <stdlib.h>
++    #include <limits.h>
++    #include <string.h>
++    #include <sys/resource.h> /* CPUSTATES */
++
++    #include <sys/types.h>
++    #include <sys/sysctl.h>
++}
++#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 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.
++        return 0;
++    else
++        return freq;
+ 
++}
++#endif
+ CpuStatPrivate::CpuStatPrivate(CpuStat *parent)
+     : BaseStatPrivate(parent)
+     , mMonitoring(CpuStat::LoadAndFrequency)
+@@ -39,7 +90,11 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *
+     mSource = defaultSource();
+ 
+     connect(mTimer, SIGNAL(timeout()), SLOT(timeout()));
+-
++#ifdef HAVE_SYSCTL_H
++    size_t flen=2;
++    sysctlnametomib("kern.cp_times",mib0,&flen);
++    sysctlnametomib("kern.cp_time",mib1,&flen);
++#endif
+     mUserHz = sysconf(_SC_CLK_TCK);
+ 
+     updateSources();
+@@ -47,6 +102,49 @@ CpuStatPrivate::CpuStatPrivate(CpuStat *
+ 
+ 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;
++            }
++        }
++    }
++
++    free(t);
++    mBounds[source] = qMakePair(min, max);
++#else
+     bool ok;
+ 
+     uint min = readAllFile(qPrintable(QString("/sys/devices/system/cpu/%1/cpufreq/scaling_min_freq").arg(source))).toUInt(&ok);
+@@ -56,12 +154,27 @@ void CpuStatPrivate::addSource(const QSt
+         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("cpu"); // Linux has cpu in /proc/stat
++    for (int i =0;i<cpu;i++)
++    {
++        mSources.append(QString("cpu%1").arg(i));
++
++
+ 
++        addSource(QString("cpu%1").arg(i));
++    }
++#else
+     const QStringList rows = readAllFile("/proc/stat").split(QChar('\n'), QString::SkipEmptyParts);
+     for (const QString &row : rows)
+     {
+@@ -99,6 +212,7 @@ void CpuStatPrivate::updateSources()
+                 addSource(QString("cpu%1").arg(number));
+         }
+     }
++#endif
+ }
+ 
+ CpuStatPrivate::~CpuStatPrivate()
+@@ -127,6 +241,88 @@ void CpuStatPrivate::recalculateMinMax()
+ 
+ void CpuStatPrivate::timeout()
+ {
++#ifdef HAVE_SYSCTL_H
++    if ( (mMonitoring == CpuStat::LoadOnly)
++      || (mMonitoring == CpuStat::LoadAndFrequency) )
++    {
++        int cpuNumber=0;
++        long *cp_times=0;
++        if(mSource!="cpu") {
++            size_t cp_size = sizeof(long) * CPUSTATES * GetCpu();
++            cp_times = (long *)malloc(cp_size);
++            cpuNumber = mSource.midRef(3).toInt();
++            if (sysctl(mib0,2, cp_times, &cp_size, NULL, 0) < 0)
++                free(cp_times);
++        } else {
++            size_t cp_size = sizeof(long)*CPUSTATES;
++            cp_times = (long *)malloc(cp_size);
++            if(sysctl(mib1,2,cp_times,&cp_size,NULL,0) < 0)
++                free(cp_times);
++        }
++        Values current;
++        current.user = static_cast<ulong>(cp_times[CP_USER+cpuNumber*CPUSTATES]);
++        current.nice = static_cast<ulong>(cp_times[CP_NICE+cpuNumber*CPUSTATES]);
++        current.system = static_cast<ulong>(cp_times[CP_SYS+cpuNumber*CPUSTATES]);
++        current.idle = static_cast<ulong>(cp_times[CP_IDLE+cpuNumber*CPUSTATES]);
++        current.other = static_cast<ulong>(cp_times[CP_INTR+cpuNumber*CPUSTATES]);
++        current.total = current.user + current.nice + current.system+current.idle+current.other;
++
++        float sumDelta = static_cast<float>(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
++                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=="cpu")
++                        freqRate = static_cast<float>(freq) / static_cast<float>(mBounds[QStringLiteral("cpu0")].second);// use max cpu0 for this case
++                    else
++                        freqRate = static_cast<float>(freq) / static_cast<float>(mBounds[mSource].second);
++                   emit update(
++                       static_cast<float>(current.user   - mPrevious.user  ) / sumDelta,
++                       static_cast<float>(current.nice   - mPrevious.nice  ) / sumDelta,
++                       static_cast<float>(current.system - mPrevious.system) / sumDelta,
++                       static_cast<float>(current.other  - mPrevious.other ) / sumDelta,
++                       static_cast<float>(freqRate),
++                       freq);
++                    }
++                }
++                else
++                {
++                    emit update(
++                        static_cast<float>(current.user   - mPrevious.user  ) / sumDelta,
++                        static_cast<float>(current.nice   - mPrevious.nice  ) / sumDelta,
++                        static_cast<float>(current.system - mPrevious.system) / sumDelta,
++                        static_cast<float>(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()
+         }
+         emit update(freq);
+     }
++#endif
+ }
+ 
+ QString CpuStatPrivate::defaultSource()

Added: head/sysutils/libsysstat/files/patch-cpustat.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/files/patch-cpustat.h	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,26 @@
+--- cpustat.h.orig	2018-07-28 14:34:23 UTC
++++ cpustat.h
+@@ -27,7 +27,9 @@
+ #ifndef LIBSYSSTAT__CPU_STAT__INCLUDED
+ #define LIBSYSSTAT__CPU_STAT__INCLUDED
+ 
+-
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
+ #include <QtCore/QObject>
+ 
+ #include "basestat.h"
+@@ -35,6 +37,12 @@
+ 
+ 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

Added: head/sysutils/libsysstat/files/patch-cpustat__p.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/files/patch-cpustat__p.h	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,62 @@
+--- cpustat_p.h.orig	2018-07-28 14:34:10 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 <QtCore/QObject>
+ #include <QtCore/QtGlobal>
+@@ -52,8 +55,13 @@ 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;
++#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:
+     {
+         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:
+ 
+     CpuStat::Monitoring mMonitoring;
+ 
++#ifdef HAVE_SYSCTL_H
++    typedef QMap<QString, QPair<ulong, ulong> > Bounds;
++    int mib0[2];
++    int mib1[2];
++#else
+     typedef QMap<QString, QPair<uint, uint> > Bounds;
++#endif
+     Bounds mBounds;
+ 
+     int mUserHz;

Added: head/sysutils/libsysstat/files/patch-memstat.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/files/patch-memstat.cpp	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,125 @@
+--- memstat.cpp.orig	2018-07-28 14:33:22 UTC
++++ memstat.cpp
+@@ -26,10 +26,61 @@
+ 
+ #include "memstat.h"
+ #include "memstat_p.h"
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
++#if defined(HAVE_KVM_H) && defined(HAVE_SYSCTL_H)
++extern "C"
++{
++    #include <paths.h>
++    #include <unistd.h>
++    #include <fcntl.h>
+ 
++    #include <kvm.h>
++    #include <sys/types.h>
++    #include <sys/sysctl.h>
++}
++#endif
+ 
+ namespace SysStat {
++#ifdef HAVE_SYSCTL_H
++int SwapDevices()
++{
++    int buf;
++    size_t len = sizeof(int);
+ 
++    if (sysctlbyname("vm.nswapdev", &buf, &len, NULL, 0) < 0)
++        return 0;
++    else
++        return buf;
++}
++
++qulonglong MemGetByBytes(QString property)
++{
++    qulonglong buf=0;
++    size_t len = sizeof(qulonglong);
++
++    std::string s = property.toStdString();
++    const char *name = s.c_str();
++
++    if (sysctlbyname(name, &buf, &len, NULL, 0) < 0)
++        return 0;
++    else
++        return buf;
++}
++
++qulonglong MemGetByPages(QString name)
++{
++    qulonglong res = 0;
++
++
++    res = MemGetByBytes(name);
++    if (res > 0)
++        res = res * getpagesize();
++
++    return res;
++}
++#endif
+ MemStatPrivate::MemStatPrivate(MemStat *parent)
+     : BaseStatPrivate(parent)
+ {
+@@ -52,7 +103,38 @@ void MemStatPrivate::timeout()
+     qulonglong memCached = 0;
+     qulonglong swapTotal = 0;
+     qulonglong swapFree = 0;
++#ifdef HAVE_SYSCTL_H
++    memTotal = MemGetByBytes("hw.physmem");
++    memFree = MemGetByPages("vm.stats.vm.v_free_count");
++    memBuffers = MemGetByBytes("vfs.bufspace");
++    memCached = MemGetByPages("vm.stats.vm.v_inactive_count");
++#endif
++#ifdef HAVE_KVM_H
++    qulonglong swapUsed = 0;
++    kvm_t *kd;
++    struct kvm_swap kswap[16]; /* size taken from pstat/pstat.c */
++
++    kd = kvm_open(NULL, _PATH_DEVNULL, NULL, O_RDONLY, "kvm_open");
++    if (kd == NULL)
++        kvm_close(kd);
++
++    if (kvm_getswapinfo(kd, kswap, (sizeof(kswap) / sizeof(kswap[0])), SWIF_DEV_PREFIX) > 0)
++    {
++        int swapd = SwapDevices();
++        /* TODO: loop over swap devives */
++        if (swapd >= 1)
++        {
++            swapTotal = static_cast<qulonglong>(kswap[0].ksw_total * getpagesize());
++            swapUsed = static_cast<qulonglong>(kswap[0].ksw_used * getpagesize());
++        }
++
++        kvm_close(kd);
++    }
++    else
++        kvm_close(kd);
++#endif
+ 
++#ifndef HAVE_SYSCTL_H
+     const QStringList rows = readAllFile("/proc/meminfo").split(QChar('\n'), QString::SkipEmptyParts);
+     for (const QString &row : rows)
+     {
+@@ -73,7 +155,7 @@ void MemStatPrivate::timeout()
+         else if(tokens[0] == "SwapFree:")
+             swapFree = tokens[1].toULong();
+     }
+-
++#endif
+     if (mSource == "memory")
+     {
+         if (memTotal)
+@@ -90,8 +172,11 @@ void MemStatPrivate::timeout()
+     {
+         if (swapTotal)
+         {
++#ifndef HAVE_KVM_H
+             float swapUsed_d = static_cast<float>(swapTotal - swapFree) / static_cast<float>(swapTotal);
+-
++#else
++            float swapUsed_d = static_cast<float>(swapUsed) / static_cast<float>(swapTotal);
++#endif
+             emit swapUpdate(swapUsed_d);
+         }
+     }

Added: head/sysutils/libsysstat/files/patch-memstat.h
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/files/patch-memstat.h	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,25 @@
+--- memstat.h.orig	2018-07-28 14:33:10 UTC
++++ memstat.h
+@@ -27,6 +27,9 @@
+ #ifndef LIBSYSSTAT__MEM_STAT__INCLUDED
+ #define LIBSYSSTAT__MEM_STAT__INCLUDED
+ 
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
+ 
+ #include <QtCore/QObject>
+ 
+@@ -35,6 +38,12 @@
+ 
+ namespace SysStat {
+ 
++#if defined(HAVE_SYSCTL_H) && defined(HAVE_KVM_H)
++    int SwapDevices();
++    qulonglong MemGetByBytes(const QString property);
++    qulonglong MemGetByPages(const QString property);
++#endif
++
+ class MemStatPrivate;
+ 
+ class SYSSTATSHARED_EXPORT MemStat : public BaseStat

Added: head/sysutils/libsysstat/files/patch-netstat.cpp
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/files/patch-netstat.cpp	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,122 @@
+--- netstat.cpp.orig	2018-07-28 14:38:10 UTC
++++ netstat.cpp
+@@ -26,7 +26,21 @@
+ 
+ #include "netstat.h"
+ #include "netstat_p.h"
++#ifdef HAVE_CONFIG_H
++#include "config.h"
++#endif
+ 
++#if defined(HAVE_SYSCTL_H) && defined(HAVE_IF_H)
++extern "C"
++{
++    #include <net/if.h>
++    #include <net/if_mib.h>
++    #include <net/if_types.h>
++    #include <sys/socket.h> /* PF_LINK */
++    #include <sys/types.h>
++    #include <sys/sysctl.h>
++}
++#endif
+ 
+ namespace SysStat {
+ 
+@@ -37,7 +51,7 @@ NetStatPrivate::NetStatPrivate(NetStat *
+ 
+     connect(mTimer, SIGNAL(timeout()), SLOT(timeout()));
+ 
+-
++#ifndef HAVE_SYSCTL_H
+     QStringList rows(readAllFile("/proc/net/dev").split(QChar('\n'), QString::SkipEmptyParts));
+ 
+     rows.erase(rows.begin(), rows.begin() + 2);
+@@ -50,6 +64,29 @@ NetStatPrivate::NetStatPrivate(NetStat *
+ 
+         mSources.append(tokens[0].trimmed());
+     }
++#else
++    int count;
++    size_t len;
++    int cntifmib[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT };// net.link.generic.system.ifcount;
++    len = sizeof(int);
++    if (sysctl(cntifmib, 5, &count, &len, NULL, 0) < 0)
++        perror("sysctl");
++
++
++    struct ifmibdata ifmd;
++    size_t len1 = sizeof(ifmd);
++    for (int i=1; i<=count;i++) {
++        int name[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_IFDATA, i, IFDATA_GENERAL };
++
++        if (sysctl(name, 6, &ifmd, &len1, NULL, 0) < 0) {
++            perror("sysctl");
++        }
++        if ((ifmd.ifmd_data.ifi_type == IFT_ETHER) || (ifmd.ifmd_data.ifi_type == IFT_IEEE80211)) {
++        const char *iface = ifmd.ifmd_name;
++        mSources.append(QString::fromLatin1(iface));
++        }
++    }
++#endif
+ }
+ 
+ NetStatPrivate::~NetStatPrivate()
+@@ -58,6 +95,50 @@ NetStatPrivate::~NetStatPrivate()
+ 
+ void NetStatPrivate::timeout()
+ {
++#if defined(HAVE_IF_H) && defined(HAVE_SYSCTL_H)
++    int count;
++    size_t len;
++    int name[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_SYSTEM, IFMIB_IFCOUNT };
++    struct ifmibdata ifmd;
++
++    len = sizeof(int);
++    if (sysctl(name, 5, &count, &len, NULL, 0) < 0)
++        return;
++
++    for (int i = 1; i <= count; i++)
++    {
++        len = sizeof(ifmd);
++        int name[] = { CTL_NET, PF_LINK, NETLINK_GENERIC, IFMIB_IFDATA, i, IFDATA_GENERAL };
++
++        if (sysctl(name, 6, &ifmd, &len, NULL, 0) < 0)
++            break;
++
++        if ((ifmd.ifmd_data.ifi_type == IFT_ETHER) || (ifmd.ifmd_data.ifi_type == IFT_IEEE80211))
++        {
++            const char *iface = ifmd.ifmd_name;
++            QString interfaceName = QString::fromLatin1(iface);
++            if ((ifmd.ifmd_data.ifi_link_state == LINK_STATE_UP) && (ifmd.ifmd_data.ifi_ipackets > 0))
++            {
++
++
++                Values current;
++                current.received = ifmd.ifmd_data.ifi_ibytes;
++                current.transmitted = ifmd.ifmd_data.ifi_obytes;
++
++                if (!mPrevious.contains(interfaceName))
++                    mPrevious.insert(interfaceName, Values());
++                const Values &previous = mPrevious[interfaceName];
++
++                if (interfaceName == mSource)
++                    emit update((( current.received - previous.received ) * 1000 ) / mTimer->interval(), (( current.transmitted - previous.transmitted ) * 1000 ) / mTimer->interval());
++
++                mPrevious[interfaceName] = current;
++            } else if(interfaceName == mSource)
++                emit(update(0,0));
++
++        }
++    }
++#else
+     QStringList rows(readAllFile("/proc/net/dev").split(QChar('\n'), QString::SkipEmptyParts));
+ 
+ 
+@@ -99,6 +180,7 @@ void NetStatPrivate::timeout()
+ 
+         mPrevious[interfaceName] = current;
+     }
++#endif
+ }
+ 
+ QString NetStatPrivate::defaultSource()

Added: head/sysutils/libsysstat/pkg-descr
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/pkg-descr	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,4 @@
+Qt-based library to query system information like CPU, memory usage and
+network traffic.
+
+WWW: http://lxqt.org/

Added: head/sysutils/libsysstat/pkg-plist
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/sysutils/libsysstat/pkg-plist	Mon Jul 30 15:00:40 2018	(r475896)
@@ -0,0 +1,20 @@
+include/sysstat-qt5/SysStat/BaseStat
+include/sysstat-qt5/SysStat/CpuStat
+include/sysstat-qt5/SysStat/Global
+include/sysstat-qt5/SysStat/MemStat
+include/sysstat-qt5/SysStat/NetStat
+include/sysstat-qt5/SysStat/Version
+include/sysstat-qt5/basestat.h
+include/sysstat-qt5/cpustat.h
+include/sysstat-qt5/memstat.h
+include/sysstat-qt5/netstat.h
+include/sysstat-qt5/sysstat_global.h
+include/sysstat-qt5/version.h
+lib/libsysstat-qt5.so
+lib/libsysstat-qt5.so.0
+lib/libsysstat-qt5.so.%%VERSION%%
+libdata/pkgconfig/sysstat-qt5.pc
+share/cmake/sysstat-qt5/sysstat-qt5-config-version.cmake
+share/cmake/sysstat-qt5/sysstat-qt5-config.cmake
+share/cmake/sysstat-qt5/sysstat-qt5-targets-%%CMAKE_BUILD_TYPE%%.cmake
+share/cmake/sysstat-qt5/sysstat-qt5-targets.cmake



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201807301500.w6UF0ePc095536>