├── AUTHORS ├── CHANGELOG ├── CMakeLists.txt ├── COPYING ├── README.md ├── basestat.cpp ├── basestat.h ├── basestat_p.h ├── cmake └── sysstat-config.cmake.in ├── cpustat.cpp ├── cpustat.h ├── cpustat_p.h ├── memstat.cpp ├── memstat.h ├── memstat_p.h ├── netstat.cpp ├── netstat.h ├── netstat_p.h ├── sysstat.pro ├── sysstat_global.h ├── version.cpp ├── version.h └── version_p.h /AUTHORS: -------------------------------------------------------------------------------- 1 | Upstream Authors: 2 | LXQt team: https://lxqt-project.org 3 | Razor team: http://razor-qt.org 4 | Kuzma Shapran 5 | 6 | Copyright: 7 | Copyright (c) 2012 Razor team 8 | Copyright (c) 2012-2018 LXQt team 9 | 10 | License: LGPL-2.1+ 11 | The full text of the licenses can be found in the 'COPYING' file. 12 | -------------------------------------------------------------------------------- /CHANGELOG: -------------------------------------------------------------------------------- 1 | libsysstat-1.1.0 / 2024-11-05 2 | ============================= 3 | * Don't mix const and non const iterators. 4 | * Drop deprecated `Q_ENUMS` macro. 5 | 6 | libsysstat-1.0.0 / 2024-04-17 7 | ============================= 8 | * Ported to Qt6. 9 | 10 | libsysstat-0.4.6 / 2021-11-04 11 | ============================= 12 | * Updated AUTHORS. 13 | * Bumped minimum required Qt version to 5.15. 14 | * Dropped Qt < 15 conditional dead code. 15 | 16 | libsysstat-0.4.5 / 2021-04-15 17 | ============================= 18 | * Initialized some variables. 19 | * Used "= default" to define trivial destructors. 20 | * Handled Qt5.15's deprecations. 21 | 22 | libsysstat-0.4.4 / 2020-11-01 23 | ============================= 24 | * Bumped version to 0.4.4. 25 | 26 | libsysstat-0.4.3 / 2020-04-22 27 | ============================= 28 | * Bumped version to 0.4.3. 29 | * C++11 code updates. 30 | * Removed (duplicated) string casts definitions. 31 | 32 | libsysstat-0.4.2 / 2019-01-25 33 | ============================= 34 | 35 | * Bumped version to 0.4.2 36 | * Improved cmake scripting and set cmake_minimum_required to 3.1.0 37 | * Don't use automatic string conversions 38 | * Removes local compile definition 39 | 40 | libsysstat-0.4.1 / 2018-05-21 41 | ============================= 42 | 43 | * Bump patch version to 1 44 | * CMake: Prevent in-source builds 45 | * Fixed year and https 46 | * Fixes some lxde mentions 47 | * Bump LXQTBT_MINIMUM_VERSION to 0.4.1 48 | * Drop Qt foreach. 49 | * Handle CMake CMP0024 50 | * Don't export github templates 51 | 52 | 0.4.0 / 2017-09-23 53 | ================== 54 | 55 | * Release 0.4.0: Update changelog 56 | * correct spelling mistake 57 | * bump version and needed version of lxqt-build-tools 58 | * liblxqt make no sense here 59 | * Copied issue template 60 | * Drops Qt5Core_VERSION_STRING 61 | * Fixes (#17) 62 | * Bump years 63 | 64 | 0.3.3 / 2016-12-11 65 | ================== 66 | 67 | * Release 0.3.3: Update changelog 68 | * Bump patch version to 3 69 | * Simplify include_directories and compile definitions 70 | * Adds Building project name and Qt version message 71 | * Adds a minimum Qt minimum version requirement 72 | * README.md: Add build dependency lxqt-build-tools 73 | * Use the lxqt-build-tools LXQtCreatePkgConfigFile 74 | * Use the lxqt-build-tools LXQtCreatePortableHeaders module 75 | * Use the new lxqt-build-tools package 76 | * Remove cpack (#14) 77 | 78 | 0.3.2 / 2016-09-17 79 | ================== 80 | 81 | * Release 0.3.2: Add changelog 82 | * Bump version to 0.3.2 83 | * Add README.md 84 | * fixes lxde/libsysstat/issues/11 85 | * Bump year and change listed licenses 86 | * Fix rare file descriptor leak in readAllFile() 87 | 88 | 0.3.1 / 2015-10-31 89 | ================== 90 | 91 | * Release 0.3.1 92 | * Remove duplicate LICENSE file 93 | * Remove leftover translation comments 94 | * Fix license file 95 | * Add release script 96 | * Handles CMake policy CMP0063 97 | * Uses a local copy of LXQCompilerSettings 98 | * CMake: Adds Runtime and Devel install COMPONENTs 99 | * Use target_compile_definitions() 100 | * Use CMAKE_INCLUDE_CURRENT_DIR 101 | * Use GNUInstallDirs 102 | * Coding style cleanups 103 | * Disables translations support 104 | * Use CMAKE_AUTOMOC, drops qt5_wrap_cpp() 105 | * Adapts the buildsystem to use CMake Targets 106 | * Fix warnings about using uninitialized variables 107 | * - Bump missing versioning 108 | 109 | 0.3.0 / 2014-10-21 110 | ================== 111 | 112 | * Adds the Requires field to the .pc confile file 113 | * Generate .pc file with the proper version value 114 | * Clean up CMakeLists.txt, drop Qt4 support 115 | 116 | 0.2.0 / 2014-10-19 117 | ================== 118 | 119 | * Release 0.2.0 120 | * simplify QT switching, use ENV 121 | * Use QString::fromLatin1() instead of QString::fromAscii() 122 | * Adapt the build system to handle Qt4 and Qt5 123 | * Improve FreeBSD support 124 | 125 | 0.1.0 / 2014-04-29 126 | ================== 127 | 128 | * Update AUTHORS and COPYING 129 | * Add CPack rules for creating tarball 130 | * Don't append library suffix to library install path, but use it by default 131 | * Allow installation path configuration with standard CMake X_INSTALL_DIR 132 | * Retain old CMAKE_CXX_FLAGS while setting visibility. 133 | * Install cmake files. 134 | * Use gcc visibility to avoid unecessary symbol exports. 135 | * Make the lib buildable independently. Fix AUTHORS file. 136 | * Add COPYING and AUTHORS files 137 | * libraries: Removes unneeded include(RazorLibSuffix) 138 | * libraries: Removes unneeded cmake_minimum_required(VERSION 2.6) 139 | * libraries: Removes unneeded find_package(Qt4) 140 | * Style follows the Coding Standard 141 | * Sysstat lib: version number functions renamed to avoid conflicts 142 | * SysStat: license updated & unused files removed 143 | * Time zone list built from ICU 144 | * SysStat lib: Better CPU stat handling (possible fix for issue #480) 145 | * Revert "Sysstat lib: default c-tors fixed (issue #480)" 146 | * Sysstat lib: default c-tors fixed (issue #480) 147 | * Relicensing again 148 | * Parent folder added for inclusion 149 | * Relicensing 150 | * code style is up to Coding Standards 151 | * SysStat library and plugin 152 | -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.18.0 FATAL_ERROR) 2 | # CMP0000: Call the cmake_minimum_required() command at the beginning of the top-level 3 | # CMakeLists.txt file even before calling the project() command. 4 | # The cmake_minimum_required(VERSION) command implicitly invokes the cmake_policy(VERSION) 5 | # command to specify that the current project code is written for the given range of CMake 6 | # versions. 7 | project(libsysstat) 8 | 9 | set(MAJOR_VERSION 1) 10 | set(MINOR_VERSION 1) 11 | set(PATCH_VERSION 0) 12 | set(SYSSTAT_VERSION "${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION}") 13 | 14 | set(LXQTBT_MINIMUM_VERSION "2.1.0") 15 | set(QT_MINIMUM_VERSION "6.6.0") 16 | 17 | # additional cmake files 18 | list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 19 | 20 | find_package(lxqt2-build-tools ${LXQTBT_MINIMUM_VERSION} REQUIRED) 21 | find_package(Qt6Core ${QT_MINIMUM_VERSION} REQUIRED) 22 | message(STATUS "Building ${PROJECT_NAME} with Qt ${Qt6Core_VERSION}") 23 | 24 | include(CMakePackageConfigHelpers) 25 | include(GNUInstallDirs) # Standard directories for installation 26 | include(LXQtPreventInSourceBuilds) 27 | include(LXQtCreatePkgConfigFile) 28 | include(LXQtCreatePortableHeaders) 29 | include(LXQtCompilerSettings NO_POLICY_SCOPE) 30 | 31 | set(CMAKE_AUTOMOC ON) 32 | set(CMAKE_INCLUDE_CURRENT_DIR ON) 33 | 34 | set(SYSSTAT_LIBRARY_NAME "sysstat-qt6") 35 | set(HEADER_NAMESPACE "SysStat") 36 | 37 | set(SYSSTAT_PUBLIC_HDRS 38 | version.h 39 | sysstat_global.h 40 | basestat.h 41 | cpustat.h 42 | memstat.h 43 | netstat.h 44 | ) 45 | 46 | set(SYSSTAT_PUBLIC_CLASSES 47 | Version 48 | Global 49 | BaseStat 50 | CpuStat 51 | MemStat 52 | NetStat 53 | ) 54 | 55 | set(SYSSTAT_PRIVATE_HDRS 56 | version_p.h 57 | basestat_p.h 58 | cpustat_p.h 59 | memstat_p.h 60 | netstat_p.h 61 | ) 62 | 63 | set(SYSSTAT_SRCS 64 | version.cpp 65 | basestat.cpp 66 | cpustat.cpp 67 | memstat.cpp 68 | netstat.cpp 69 | ) 70 | 71 | set(SYSSTAT_QM_FILES "") 72 | 73 | set(APP_SHARE_DIR "${CMAKE_INSTALL_DATAROOTDIR}/${SYSSTAT_LIBRARY_NAME}") 74 | 75 | add_library(${SYSSTAT_LIBRARY_NAME} 76 | SHARED 77 | ${SYSSTAT_PUBLIC_HDRS} 78 | ${SYSSTAT_PRIVATE_HDRS} 79 | ${SYSSTAT_SRCS} 80 | ${SYSSTAT_QM_FILES} 81 | ) 82 | 83 | target_link_libraries(${SYSSTAT_LIBRARY_NAME} Qt6::Core) 84 | 85 | set_target_properties(${SYSSTAT_LIBRARY_NAME} PROPERTIES 86 | VERSION ${SYSSTAT_VERSION} 87 | SOVERSION ${MAJOR_VERSION} 88 | ) 89 | 90 | target_compile_definitions(${SYSSTAT_LIBRARY_NAME} 91 | PRIVATE 92 | "MAJOR_VERSION=${MAJOR_VERSION}" 93 | "MINOR_VERSION=${MINOR_VERSION}" 94 | "PATCH_VERSION=${PATCH_VERSION}" 95 | "SYSSTAT_LIBRARY" 96 | ) 97 | 98 | target_include_directories(${SYSSTAT_LIBRARY_NAME} 99 | INTERFACE 100 | "$" 101 | "$" 102 | ) 103 | 104 | lxqt_create_portable_headers(SYSSTAT_NAMESPACE_HEADERS 105 | PATH_PREFIX ".." 106 | HEADER_NAMES ${SYSSTAT_PUBLIC_CLASSES} 107 | ) 108 | 109 | foreach(h ${SYSSTAT_NAMESPACE_HEADERS}) 110 | get_filename_component(bh ${h} NAME) 111 | configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${SYSSTAT_LIBRARY_NAME}/${HEADER_NAMESPACE}/${bh}" COPYONLY) 112 | endforeach() 113 | 114 | foreach(h ${SYSSTAT_PUBLIC_HDRS}) 115 | get_filename_component(bh ${h} NAME) 116 | configure_file("${h}" "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_FILES_DIRECTORY}/include/${SYSSTAT_LIBRARY_NAME}/${bh}" COPYONLY) 117 | endforeach() 118 | 119 | install(TARGETS 120 | ${SYSSTAT_LIBRARY_NAME} 121 | DESTINATION "${CMAKE_INSTALL_LIBDIR}" EXPORT ${SYSSTAT_LIBRARY_NAME}-targets 122 | COMPONENT Runtime 123 | ) 124 | 125 | install(FILES 126 | ${SYSSTAT_PUBLIC_HDRS} 127 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${SYSSTAT_LIBRARY_NAME}" 128 | COMPONENT Devel 129 | ) 130 | 131 | install(FILES 132 | ${SYSSTAT_NAMESPACE_HEADERS} 133 | DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${SYSSTAT_LIBRARY_NAME}/${HEADER_NAMESPACE}" 134 | COMPONENT Devel 135 | ) 136 | 137 | #install(FILES ${SYSSTAT_QM_FILES} DESTINATION "${APP_SHARE_DIR}") 138 | 139 | export(TARGETS 140 | ${SYSSTAT_LIBRARY_NAME} 141 | FILE "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-targets.cmake" 142 | ) 143 | 144 | lxqt_create_pkgconfig_file( 145 | PACKAGE_NAME ${SYSSTAT_LIBRARY_NAME} 146 | DESCRIPTIVE_NAME ${SYSSTAT_LIBRARY_NAME} 147 | DESCRIPTION "SysStat, a Qt-based interface to system statistics" 148 | INCLUDEDIRS ${SYSSTAT_LIBRARY_NAME} 149 | LIBS ${SYSSTAT_LIBRARY_NAME} 150 | REQUIRES "Qt6Core" 151 | VERSION ${SYSSTAT_VERSION} 152 | INSTALL 153 | ) 154 | 155 | 156 | # cmake config file 157 | set(SYSSTAT_INCLUDE_DIR "${CMAKE_INSTALL_PREFIX}/include/${SYSSTAT_LIBRARY_NAME}") 158 | configure_package_config_file( 159 | "${CMAKE_CURRENT_SOURCE_DIR}/cmake/sysstat-config.cmake.in" 160 | "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config.cmake" 161 | INSTALL_DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}" 162 | ) 163 | 164 | # cmake version config file 165 | write_basic_package_version_file( 166 | "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config-version.cmake" 167 | VERSION ${MAJOR_VERSION}.${MINOR_VERSION}.${PATCH_VERSION} 168 | COMPATIBILITY AnyNewerVersion 169 | ) 170 | 171 | install(FILES 172 | "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config.cmake" 173 | "${CMAKE_BINARY_DIR}/${SYSSTAT_LIBRARY_NAME}-config-version.cmake" 174 | DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}" 175 | COMPONENT Devel 176 | ) 177 | 178 | install(EXPORT 179 | ${SYSSTAT_LIBRARY_NAME}-targets 180 | DESTINATION "${CMAKE_INSTALL_DATAROOTDIR}/cmake/${SYSSTAT_LIBRARY_NAME}" 181 | COMPONENT Devel 182 | ) 183 | -------------------------------------------------------------------------------- /COPYING: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 2.1, February 1999 3 | 4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc. 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | [This is the first released version of the Lesser GPL. It also counts 10 | as the successor of the GNU Library Public License, version 2, hence 11 | the version number 2.1.] 12 | 13 | Preamble 14 | 15 | The licenses for most software are designed to take away your 16 | freedom to share and change it. By contrast, the GNU General Public 17 | Licenses are intended to guarantee your freedom to share and change 18 | free software--to make sure the software is free for all its users. 19 | 20 | This license, the Lesser General Public License, applies to some 21 | specially designated software packages--typically libraries--of the 22 | Free Software Foundation and other authors who decide to use it. You 23 | can use it too, but we suggest you first think carefully about whether 24 | this license or the ordinary General Public License is the better 25 | strategy to use in any particular case, based on the explanations below. 26 | 27 | When we speak of free software, we are referring to freedom of use, 28 | not price. Our General Public Licenses are designed to make sure that 29 | you have the freedom to distribute copies of free software (and charge 30 | for this service if you wish); that you receive source code or can get 31 | it if you want it; that you can change the software and use pieces of 32 | it in new free programs; and that you are informed that you can do 33 | these things. 34 | 35 | To protect your rights, we need to make restrictions that forbid 36 | distributors to deny you these rights or to ask you to surrender these 37 | rights. These restrictions translate to certain responsibilities for 38 | you if you distribute copies of the library or if you modify it. 39 | 40 | For example, if you distribute copies of the library, whether gratis 41 | or for a fee, you must give the recipients all the rights that we gave 42 | you. You must make sure that they, too, receive or can get the source 43 | code. If you link other code with the library, you must provide 44 | complete object files to the recipients, so that they can relink them 45 | with the library after making changes to the library and recompiling 46 | it. And you must show them these terms so they know their rights. 47 | 48 | We protect your rights with a two-step method: (1) we copyright the 49 | library, and (2) we offer you this license, which gives you legal 50 | permission to copy, distribute and/or modify the library. 51 | 52 | To protect each distributor, we want to make it very clear that 53 | there is no warranty for the free library. Also, if the library is 54 | modified by someone else and passed on, the recipients should know 55 | that what they have is not the original version, so that the original 56 | author's reputation will not be affected by problems that might be 57 | introduced by others. 58 | 59 | Finally, software patents pose a constant threat to the existence of 60 | any free program. We wish to make sure that a company cannot 61 | effectively restrict the users of a free program by obtaining a 62 | restrictive license from a patent holder. Therefore, we insist that 63 | any patent license obtained for a version of the library must be 64 | consistent with the full freedom of use specified in this license. 65 | 66 | Most GNU software, including some libraries, is covered by the 67 | ordinary GNU General Public License. This license, the GNU Lesser 68 | General Public License, applies to certain designated libraries, and 69 | is quite different from the ordinary General Public License. We use 70 | this license for certain libraries in order to permit linking those 71 | libraries into non-free programs. 72 | 73 | When a program is linked with a library, whether statically or using 74 | a shared library, the combination of the two is legally speaking a 75 | combined work, a derivative of the original library. The ordinary 76 | General Public License therefore permits such linking only if the 77 | entire combination fits its criteria of freedom. The Lesser General 78 | Public License permits more lax criteria for linking other code with 79 | the library. 80 | 81 | We call this license the "Lesser" General Public License because it 82 | does Less to protect the user's freedom than the ordinary General 83 | Public License. It also provides other free software developers Less 84 | of an advantage over competing non-free programs. These disadvantages 85 | are the reason we use the ordinary General Public License for many 86 | libraries. However, the Lesser license provides advantages in certain 87 | special circumstances. 88 | 89 | For example, on rare occasions, there may be a special need to 90 | encourage the widest possible use of a certain library, so that it becomes 91 | a de-facto standard. To achieve this, non-free programs must be 92 | allowed to use the library. A more frequent case is that a free 93 | library does the same job as widely used non-free libraries. In this 94 | case, there is little to gain by limiting the free library to free 95 | software only, so we use the Lesser General Public License. 96 | 97 | In other cases, permission to use a particular library in non-free 98 | programs enables a greater number of people to use a large body of 99 | free software. For example, permission to use the GNU C Library in 100 | non-free programs enables many more people to use the whole GNU 101 | operating system, as well as its variant, the GNU/Linux operating 102 | system. 103 | 104 | Although the Lesser General Public License is Less protective of the 105 | users' freedom, it does ensure that the user of a program that is 106 | linked with the Library has the freedom and the wherewithal to run 107 | that program using a modified version of the Library. 108 | 109 | The precise terms and conditions for copying, distribution and 110 | modification follow. Pay close attention to the difference between a 111 | "work based on the library" and a "work that uses the library". The 112 | former contains code derived from the library, whereas the latter must 113 | be combined with the library in order to run. 114 | 115 | GNU LESSER GENERAL PUBLIC LICENSE 116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 117 | 118 | 0. This License Agreement applies to any software library or other 119 | program which contains a notice placed by the copyright holder or 120 | other authorized party saying it may be distributed under the terms of 121 | this Lesser General Public License (also called "this License"). 122 | Each licensee is addressed as "you". 123 | 124 | A "library" means a collection of software functions and/or data 125 | prepared so as to be conveniently linked with application programs 126 | (which use some of those functions and data) to form executables. 127 | 128 | The "Library", below, refers to any such software library or work 129 | which has been distributed under these terms. A "work based on the 130 | Library" means either the Library or any derivative work under 131 | copyright law: that is to say, a work containing the Library or a 132 | portion of it, either verbatim or with modifications and/or translated 133 | straightforwardly into another language. (Hereinafter, translation is 134 | included without limitation in the term "modification".) 135 | 136 | "Source code" for a work means the preferred form of the work for 137 | making modifications to it. For a library, complete source code means 138 | all the source code for all modules it contains, plus any associated 139 | interface definition files, plus the scripts used to control compilation 140 | and installation of the library. 141 | 142 | Activities other than copying, distribution and modification are not 143 | covered by this License; they are outside its scope. The act of 144 | running a program using the Library is not restricted, and output from 145 | such a program is covered only if its contents constitute a work based 146 | on the Library (independent of the use of the Library in a tool for 147 | writing it). Whether that is true depends on what the Library does 148 | and what the program that uses the Library does. 149 | 150 | 1. You may copy and distribute verbatim copies of the Library's 151 | complete source code as you receive it, in any medium, provided that 152 | you conspicuously and appropriately publish on each copy an 153 | appropriate copyright notice and disclaimer of warranty; keep intact 154 | all the notices that refer to this License and to the absence of any 155 | warranty; and distribute a copy of this License along with the 156 | Library. 157 | 158 | You may charge a fee for the physical act of transferring a copy, 159 | and you may at your option offer warranty protection in exchange for a 160 | fee. 161 | 162 | 2. You may modify your copy or copies of the Library or any portion 163 | of it, thus forming a work based on the Library, and copy and 164 | distribute such modifications or work under the terms of Section 1 165 | above, provided that you also meet all of these conditions: 166 | 167 | a) The modified work must itself be a software library. 168 | 169 | b) You must cause the files modified to carry prominent notices 170 | stating that you changed the files and the date of any change. 171 | 172 | c) You must cause the whole of the work to be licensed at no 173 | charge to all third parties under the terms of this License. 174 | 175 | d) If a facility in the modified Library refers to a function or a 176 | table of data to be supplied by an application program that uses 177 | the facility, other than as an argument passed when the facility 178 | is invoked, then you must make a good faith effort to ensure that, 179 | in the event an application does not supply such function or 180 | table, the facility still operates, and performs whatever part of 181 | its purpose remains meaningful. 182 | 183 | (For example, a function in a library to compute square roots has 184 | a purpose that is entirely well-defined independent of the 185 | application. Therefore, Subsection 2d requires that any 186 | application-supplied function or table used by this function must 187 | be optional: if the application does not supply it, the square 188 | root function must still compute square roots.) 189 | 190 | These requirements apply to the modified work as a whole. If 191 | identifiable sections of that work are not derived from the Library, 192 | and can be reasonably considered independent and separate works in 193 | themselves, then this License, and its terms, do not apply to those 194 | sections when you distribute them as separate works. But when you 195 | distribute the same sections as part of a whole which is a work based 196 | on the Library, the distribution of the whole must be on the terms of 197 | this License, whose permissions for other licensees extend to the 198 | entire whole, and thus to each and every part regardless of who wrote 199 | it. 200 | 201 | Thus, it is not the intent of this section to claim rights or contest 202 | your rights to work written entirely by you; rather, the intent is to 203 | exercise the right to control the distribution of derivative or 204 | collective works based on the Library. 205 | 206 | In addition, mere aggregation of another work not based on the Library 207 | with the Library (or with a work based on the Library) on a volume of 208 | a storage or distribution medium does not bring the other work under 209 | the scope of this License. 210 | 211 | 3. You may opt to apply the terms of the ordinary GNU General Public 212 | License instead of this License to a given copy of the Library. To do 213 | this, you must alter all the notices that refer to this License, so 214 | that they refer to the ordinary GNU General Public License, version 2, 215 | instead of to this License. (If a newer version than version 2 of the 216 | ordinary GNU General Public License has appeared, then you can specify 217 | that version instead if you wish.) Do not make any other change in 218 | these notices. 219 | 220 | Once this change is made in a given copy, it is irreversible for 221 | that copy, so the ordinary GNU General Public License applies to all 222 | subsequent copies and derivative works made from that copy. 223 | 224 | This option is useful when you wish to copy part of the code of 225 | the Library into a program that is not a library. 226 | 227 | 4. You may copy and distribute the Library (or a portion or 228 | derivative of it, under Section 2) in object code or executable form 229 | under the terms of Sections 1 and 2 above provided that you accompany 230 | it with the complete corresponding machine-readable source code, which 231 | must be distributed under the terms of Sections 1 and 2 above on a 232 | medium customarily used for software interchange. 233 | 234 | If distribution of object code is made by offering access to copy 235 | from a designated place, then offering equivalent access to copy the 236 | source code from the same place satisfies the requirement to 237 | distribute the source code, even though third parties are not 238 | compelled to copy the source along with the object code. 239 | 240 | 5. A program that contains no derivative of any portion of the 241 | Library, but is designed to work with the Library by being compiled or 242 | linked with it, is called a "work that uses the Library". Such a 243 | work, in isolation, is not a derivative work of the Library, and 244 | therefore falls outside the scope of this License. 245 | 246 | However, linking a "work that uses the Library" with the Library 247 | creates an executable that is a derivative of the Library (because it 248 | contains portions of the Library), rather than a "work that uses the 249 | library". The executable is therefore covered by this License. 250 | Section 6 states terms for distribution of such executables. 251 | 252 | When a "work that uses the Library" uses material from a header file 253 | that is part of the Library, the object code for the work may be a 254 | derivative work of the Library even though the source code is not. 255 | Whether this is true is especially significant if the work can be 256 | linked without the Library, or if the work is itself a library. The 257 | threshold for this to be true is not precisely defined by law. 258 | 259 | If such an object file uses only numerical parameters, data 260 | structure layouts and accessors, and small macros and small inline 261 | functions (ten lines or less in length), then the use of the object 262 | file is unrestricted, regardless of whether it is legally a derivative 263 | work. (Executables containing this object code plus portions of the 264 | Library will still fall under Section 6.) 265 | 266 | Otherwise, if the work is a derivative of the Library, you may 267 | distribute the object code for the work under the terms of Section 6. 268 | Any executables containing that work also fall under Section 6, 269 | whether or not they are linked directly with the Library itself. 270 | 271 | 6. As an exception to the Sections above, you may also combine or 272 | link a "work that uses the Library" with the Library to produce a 273 | work containing portions of the Library, and distribute that work 274 | under terms of your choice, provided that the terms permit 275 | modification of the work for the customer's own use and reverse 276 | engineering for debugging such modifications. 277 | 278 | You must give prominent notice with each copy of the work that the 279 | Library is used in it and that the Library and its use are covered by 280 | this License. You must supply a copy of this License. If the work 281 | during execution displays copyright notices, you must include the 282 | copyright notice for the Library among them, as well as a reference 283 | directing the user to the copy of this License. Also, you must do one 284 | of these things: 285 | 286 | a) Accompany the work with the complete corresponding 287 | machine-readable source code for the Library including whatever 288 | changes were used in the work (which must be distributed under 289 | Sections 1 and 2 above); and, if the work is an executable linked 290 | with the Library, with the complete machine-readable "work that 291 | uses the Library", as object code and/or source code, so that the 292 | user can modify the Library and then relink to produce a modified 293 | executable containing the modified Library. (It is understood 294 | that the user who changes the contents of definitions files in the 295 | Library will not necessarily be able to recompile the application 296 | to use the modified definitions.) 297 | 298 | b) Use a suitable shared library mechanism for linking with the 299 | Library. A suitable mechanism is one that (1) uses at run time a 300 | copy of the library already present on the user's computer system, 301 | rather than copying library functions into the executable, and (2) 302 | will operate properly with a modified version of the library, if 303 | the user installs one, as long as the modified version is 304 | interface-compatible with the version that the work was made with. 305 | 306 | c) Accompany the work with a written offer, valid for at 307 | least three years, to give the same user the materials 308 | specified in Subsection 6a, above, for a charge no more 309 | than the cost of performing this distribution. 310 | 311 | d) If distribution of the work is made by offering access to copy 312 | from a designated place, offer equivalent access to copy the above 313 | specified materials from the same place. 314 | 315 | e) Verify that the user has already received a copy of these 316 | materials or that you have already sent this user a copy. 317 | 318 | For an executable, the required form of the "work that uses the 319 | Library" must include any data and utility programs needed for 320 | reproducing the executable from it. However, as a special exception, 321 | the materials to be distributed need not include anything that is 322 | normally distributed (in either source or binary form) with the major 323 | components (compiler, kernel, and so on) of the operating system on 324 | which the executable runs, unless that component itself accompanies 325 | the executable. 326 | 327 | It may happen that this requirement contradicts the license 328 | restrictions of other proprietary libraries that do not normally 329 | accompany the operating system. Such a contradiction means you cannot 330 | use both them and the Library together in an executable that you 331 | distribute. 332 | 333 | 7. You may place library facilities that are a work based on the 334 | Library side-by-side in a single library together with other library 335 | facilities not covered by this License, and distribute such a combined 336 | library, provided that the separate distribution of the work based on 337 | the Library and of the other library facilities is otherwise 338 | permitted, and provided that you do these two things: 339 | 340 | a) Accompany the combined library with a copy of the same work 341 | based on the Library, uncombined with any other library 342 | facilities. This must be distributed under the terms of the 343 | Sections above. 344 | 345 | b) Give prominent notice with the combined library of the fact 346 | that part of it is a work based on the Library, and explaining 347 | where to find the accompanying uncombined form of the same work. 348 | 349 | 8. You may not copy, modify, sublicense, link with, or distribute 350 | the Library except as expressly provided under this License. Any 351 | attempt otherwise to copy, modify, sublicense, link with, or 352 | distribute the Library is void, and will automatically terminate your 353 | rights under this License. However, parties who have received copies, 354 | or rights, from you under this License will not have their licenses 355 | terminated so long as such parties remain in full compliance. 356 | 357 | 9. You are not required to accept this License, since you have not 358 | signed it. However, nothing else grants you permission to modify or 359 | distribute the Library or its derivative works. These actions are 360 | prohibited by law if you do not accept this License. Therefore, by 361 | modifying or distributing the Library (or any work based on the 362 | Library), you indicate your acceptance of this License to do so, and 363 | all its terms and conditions for copying, distributing or modifying 364 | the Library or works based on it. 365 | 366 | 10. Each time you redistribute the Library (or any work based on the 367 | Library), the recipient automatically receives a license from the 368 | original licensor to copy, distribute, link with or modify the Library 369 | subject to these terms and conditions. You may not impose any further 370 | restrictions on the recipients' exercise of the rights granted herein. 371 | You are not responsible for enforcing compliance by third parties with 372 | this License. 373 | 374 | 11. If, as a consequence of a court judgment or allegation of patent 375 | infringement or for any other reason (not limited to patent issues), 376 | conditions are imposed on you (whether by court order, agreement or 377 | otherwise) that contradict the conditions of this License, they do not 378 | excuse you from the conditions of this License. If you cannot 379 | distribute so as to satisfy simultaneously your obligations under this 380 | License and any other pertinent obligations, then as a consequence you 381 | may not distribute the Library at all. For example, if a patent 382 | license would not permit royalty-free redistribution of the Library by 383 | all those who receive copies directly or indirectly through you, then 384 | the only way you could satisfy both it and this License would be to 385 | refrain entirely from distribution of the Library. 386 | 387 | If any portion of this section is held invalid or unenforceable under any 388 | particular circumstance, the balance of the section is intended to apply, 389 | and the section as a whole is intended to apply in other circumstances. 390 | 391 | It is not the purpose of this section to induce you to infringe any 392 | patents or other property right claims or to contest validity of any 393 | such claims; this section has the sole purpose of protecting the 394 | integrity of the free software distribution system which is 395 | implemented by public license practices. Many people have made 396 | generous contributions to the wide range of software distributed 397 | through that system in reliance on consistent application of that 398 | system; it is up to the author/donor to decide if he or she is willing 399 | to distribute software through any other system and a licensee cannot 400 | impose that choice. 401 | 402 | This section is intended to make thoroughly clear what is believed to 403 | be a consequence of the rest of this License. 404 | 405 | 12. If the distribution and/or use of the Library is restricted in 406 | certain countries either by patents or by copyrighted interfaces, the 407 | original copyright holder who places the Library under this License may add 408 | an explicit geographical distribution limitation excluding those countries, 409 | so that distribution is permitted only in or among countries not thus 410 | excluded. In such case, this License incorporates the limitation as if 411 | written in the body of this License. 412 | 413 | 13. The Free Software Foundation may publish revised and/or new 414 | versions of the Lesser General Public License from time to time. 415 | Such new versions will be similar in spirit to the present version, 416 | but may differ in detail to address new problems or concerns. 417 | 418 | Each version is given a distinguishing version number. If the Library 419 | specifies a version number of this License which applies to it and 420 | "any later version", you have the option of following the terms and 421 | conditions either of that version or of any later version published by 422 | the Free Software Foundation. If the Library does not specify a 423 | license version number, you may choose any version ever published by 424 | the Free Software Foundation. 425 | 426 | 14. If you wish to incorporate parts of the Library into other free 427 | programs whose distribution conditions are incompatible with these, 428 | write to the author to ask for permission. For software which is 429 | copyrighted by the Free Software Foundation, write to the Free 430 | Software Foundation; we sometimes make exceptions for this. Our 431 | decision will be guided by the two goals of preserving the free status 432 | of all derivatives of our free software and of promoting the sharing 433 | and reuse of software generally. 434 | 435 | NO WARRANTY 436 | 437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO 438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. 439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR 440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY 441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE 442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE 444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME 445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 446 | 447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN 448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY 449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU 450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR 451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE 452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING 453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A 454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF 455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH 456 | DAMAGES. 457 | 458 | END OF TERMS AND CONDITIONS 459 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # libsysstat 2 | 3 | ## Overview 4 | 5 | libsysstat is a library to query system information like CPU and memory usage or 6 | network traffic. Conceptually it's roughly similar to 7 | [libstatgrab](https://www.i-scream.org/libstatgrab), a third-party library used 8 | by LXQt as well. 9 | 10 | It is maintained by the LXQt project but can be used independently from this 11 | desktop environment, too. As for LXQt libsysstat is used by plugin-sysstat of 12 | lxqt-panel and hence an optional dependency of the latter. 13 | 14 | Note replacing both libsysstat and libstatgrab in LXQt by KDE Frameworks components 15 | is being considered but a final decision hasn't been made yet, see 16 | https://github.com/lxqt/lxqt/issues/704. 17 | 18 | ## Installation 19 | 20 | ### Sources 21 | 22 | The only runtime dependency is qtbase. To build CMake and 23 | [lxqt-build-tools](https://github.com/lxqt/lxqt-build-tools) are needed in 24 | addition, as well as optionally Git to pull latest VCS checkouts. 25 | 26 | Code configuration is handled by CMake. CMake variable `CMAKE_INSTALL_PREFIX` 27 | will normally have to be set to `/usr`, depending on the way library paths are 28 | dealt with on 64bit systems variables like `CMAKE_INSTALL_LIBDIR` may have to be 29 | set as well. 30 | 31 | To build run `make`, to install `make install` which accepts variable `DESTDIR` 32 | as usual. 33 | 34 | ### Binary packages 35 | 36 | The library is provided by all major Linux distributions like Arch Linux, 37 | Debian, Fedora and openSUSE. Just use the distributions' package managers to 38 | search for string `libsysstat`. 39 | -------------------------------------------------------------------------------- /basestat.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #include 28 | #include 29 | 30 | #include 31 | 32 | #include "basestat.h" 33 | #include "basestat_p.h" 34 | 35 | 36 | namespace SysStat { 37 | 38 | BaseStatPrivate::BaseStatPrivate(BaseStat* parent) 39 | : QObject(parent) 40 | , mTimer(new QTimer(this)) 41 | , mSynchroTimer(new QTimer(this)) 42 | { 43 | mTimer->setSingleShot(false); 44 | 45 | mSynchroTimer->setSingleShot(false); 46 | connect(mSynchroTimer, SIGNAL(timeout()), SLOT(synchroTimeout())); 47 | } 48 | 49 | BaseStatPrivate::~BaseStatPrivate() = default; 50 | 51 | bool BaseStatPrivate::timerIsActive() const 52 | { 53 | return mTimer->isActive(); 54 | } 55 | 56 | int BaseStatPrivate::updateInterval() const 57 | { 58 | return mTimer->interval(); 59 | } 60 | 61 | void BaseStatPrivate::intervalChanged() 62 | { 63 | } 64 | 65 | void BaseStatPrivate::sourceChanged() 66 | { 67 | } 68 | 69 | void BaseStatPrivate::setUpdateInterval(int msec) 70 | { 71 | mTimer->stop(); 72 | mTimer->setInterval(msec); 73 | this->intervalChanged(); 74 | mSynchroTimer->setInterval(msec / 10); 75 | if (msec > 0) 76 | { 77 | mLastSynchro = 0; 78 | mSynchroTimer->start(); 79 | } 80 | } 81 | 82 | void BaseStatPrivate::synchroTimeout() 83 | { 84 | QTime now(QTime::currentTime()); 85 | int synchro = ((now.minute() * 60 + now.second()) * 1000 + now.msec() ) / mTimer->interval(); 86 | if ((mLastSynchro != 0) && (mLastSynchro != synchro)) 87 | { 88 | mSynchroTimer->stop(); 89 | mTimer->start(); 90 | } 91 | mLastSynchro = synchro; 92 | } 93 | 94 | void BaseStatPrivate::stopUpdating() 95 | { 96 | mTimer->stop(); 97 | } 98 | 99 | QString BaseStatPrivate::monitoredSource() const 100 | { 101 | return mSource; 102 | } 103 | 104 | void BaseStatPrivate::setMonitoredSource(const QString &Source) 105 | { 106 | mSource = Source; 107 | this->sourceChanged(); 108 | } 109 | 110 | void BaseStatPrivate::monitorDefaultSource() 111 | { 112 | mSource = defaultSource(); 113 | } 114 | 115 | QString BaseStatPrivate::readAllFile(const char *filename) 116 | { 117 | QString result; 118 | 119 | static const size_t bufferSize = 1 << 12; // 4096 120 | static char buffer[bufferSize]; 121 | 122 | int fd = ::open(filename, O_RDONLY); 123 | if (fd > -1) 124 | { 125 | ssize_t size = ::read(fd, buffer, bufferSize); 126 | ::close(fd); 127 | if (size > 0) 128 | result = QString::fromLatin1(buffer, size); 129 | } 130 | 131 | return result; 132 | } 133 | 134 | QStringList BaseStatPrivate::sources() const 135 | { 136 | return mSources; 137 | } 138 | 139 | BaseStat::BaseStat(QObject *parent) 140 | : QObject(parent) 141 | { 142 | } 143 | 144 | BaseStat::~BaseStat() = default; 145 | 146 | QStringList BaseStat::sources() const 147 | { 148 | return baseimpl->sources(); 149 | } 150 | 151 | int BaseStat::updateInterval() const 152 | { 153 | return baseimpl->updateInterval(); 154 | } 155 | 156 | void BaseStat::setUpdateInterval(int msec) 157 | { 158 | if ((updateInterval() != msec) || (!baseimpl->timerIsActive())) 159 | { 160 | baseimpl->setUpdateInterval(msec); 161 | emit updateIntervalChanged(msec); 162 | } 163 | } 164 | 165 | void BaseStat::stopUpdating() 166 | { 167 | if (updateInterval() != 0) 168 | { 169 | baseimpl->stopUpdating(); 170 | emit updateIntervalChanged(0); 171 | } 172 | } 173 | 174 | QString BaseStat::monitoredSource() const 175 | { 176 | return baseimpl->monitoredSource(); 177 | } 178 | 179 | void BaseStat::setMonitoredSource(const QString &source) 180 | { 181 | if (monitoredSource() != source) 182 | { 183 | baseimpl->setMonitoredSource(source); 184 | emit monitoredSourceChanged(source); 185 | } 186 | } 187 | 188 | void BaseStat::monitorDefaultSource() 189 | { 190 | QString oldSource = monitoredSource(); 191 | baseimpl->monitorDefaultSource(); 192 | if (monitoredSource() != oldSource) 193 | emit monitoredSourceChanged(monitoredSource()); 194 | } 195 | 196 | } 197 | -------------------------------------------------------------------------------- /basestat.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__BASE_STAT__INCLUDED 28 | #define LIBSYSSTAT__BASE_STAT__INCLUDED 29 | 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "sysstat_global.h" 36 | 37 | 38 | namespace SysStat { 39 | 40 | class BaseStatPrivate; 41 | 42 | class SYSSTATSHARED_EXPORT BaseStat : public QObject 43 | { 44 | Q_OBJECT 45 | 46 | public: 47 | BaseStat(QObject *parent = nullptr); 48 | ~BaseStat() override; 49 | 50 | QStringList sources() const; 51 | 52 | signals: 53 | void updateIntervalChanged(int); 54 | void monitoredSourceChanged(QString); 55 | 56 | public: 57 | Q_PROPERTY(int updateInterval READ updateInterval WRITE setUpdateInterval RESET stopUpdating NOTIFY updateIntervalChanged) 58 | Q_PROPERTY(QString monitoredSource READ monitoredSource WRITE setMonitoredSource RESET monitorDefaultSource NOTIFY monitoredSourceChanged) 59 | 60 | public slots: 61 | int updateInterval() const; 62 | void setUpdateInterval(int msec); 63 | void stopUpdating(); 64 | 65 | QString monitoredSource() const; 66 | void setMonitoredSource(const QString &Source); 67 | void monitorDefaultSource(); 68 | 69 | protected: 70 | BaseStatPrivate* baseimpl; 71 | }; 72 | 73 | } 74 | 75 | #endif //LIBSYSSTAT__BASE_STAT__INCLUDED 76 | -------------------------------------------------------------------------------- /basestat_p.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__BASE_STAT__PRIVATE__INCLUDED 28 | #define LIBSYSSTAT__BASE_STAT__PRIVATE__INCLUDED 29 | 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | #include 36 | 37 | #include "cpustat.h" 38 | 39 | 40 | namespace SysStat { 41 | 42 | class BaseStatPrivate : public QObject 43 | { 44 | Q_OBJECT 45 | 46 | public: 47 | BaseStatPrivate(BaseStat *parent = nullptr); 48 | ~BaseStatPrivate() override; 49 | 50 | QStringList sources() const; 51 | 52 | bool timerIsActive() const; 53 | int updateInterval() const; 54 | void setUpdateInterval(int msec); 55 | void stopUpdating(); 56 | 57 | QString monitoredSource() const; 58 | void setMonitoredSource(const QString &Source); 59 | void monitorDefaultSource(); 60 | 61 | private slots: 62 | void synchroTimeout(); 63 | 64 | protected: 65 | virtual QString defaultSource() = 0; 66 | 67 | QString readAllFile(const char *filename); 68 | 69 | QTimer *mTimer; 70 | QTimer *mSynchroTimer; 71 | QString mSource; 72 | QStringList mSources; 73 | 74 | int mLastSynchro; 75 | 76 | virtual void intervalChanged(); 77 | virtual void sourceChanged(); 78 | }; 79 | 80 | } 81 | 82 | #endif //LIBSYSSTAT__BASE_STAT__PRIVATE__INCLUDED 83 | -------------------------------------------------------------------------------- /cmake/sysstat-config.cmake.in: -------------------------------------------------------------------------------- 1 | # - Find the sysstat include and library dirs and define a some macros 2 | # 3 | # The module defines the following variables 4 | # 5 | # SYSSTAT_FOUND - Set to TRUE if all of the above has been found 6 | 7 | 8 | @PACKAGE_INIT@ 9 | 10 | set(SYSSTAT_MAJOR_VERSION @MAJOR_VERSION@) 11 | set(SYSSTAT_MINOR_VERSION @MINOR_VERSION@) 12 | set(SYSSTAT_PATCH_VERSION @PATCH_VERSION@) 13 | set(SYSSTAT_VERSION @SYSSTAT_VERSION@) 14 | 15 | include(CMakeFindDependencyMacro) 16 | 17 | find_dependency(Qt6Core @QT_MINIMUM_VERSION@) 18 | if (NOT TARGET @SYSSTAT_LIBRARY_NAME@) 19 | if (POLICY CMP0024) 20 | cmake_policy(SET CMP0024 NEW) 21 | endif() 22 | include("${CMAKE_CURRENT_LIST_DIR}/@SYSSTAT_LIBRARY_NAME@-targets.cmake") 23 | endif() 24 | -------------------------------------------------------------------------------- /cpustat.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #include 28 | 29 | #include "cpustat.h" 30 | #include "cpustat_p.h" 31 | 32 | 33 | namespace SysStat { 34 | 35 | CpuStatPrivate::CpuStatPrivate(CpuStat *parent) 36 | : BaseStatPrivate(parent) 37 | , mMonitoring(CpuStat::LoadAndFrequency) 38 | { 39 | mSource = defaultSource(); 40 | 41 | connect(mTimer, SIGNAL(timeout()), SLOT(timeout())); 42 | 43 | mUserHz = sysconf(_SC_CLK_TCK); 44 | 45 | updateSources(); 46 | } 47 | 48 | void CpuStatPrivate::addSource(const QString &source) 49 | { 50 | bool ok = false; 51 | 52 | uint min = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_min_freq").arg(source))).toUInt(&ok); 53 | if (ok) 54 | { 55 | uint max = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_max_freq").arg(source))).toUInt(&ok); 56 | if (ok) 57 | mBounds[source] = qMakePair(min, max); 58 | } 59 | } 60 | 61 | void CpuStatPrivate::updateSources() 62 | { 63 | mSources.clear(); 64 | const QStringList rows = readAllFile("/proc/stat").split(QLatin1Char('\n'), Qt::SkipEmptyParts); 65 | for (const QString &row : rows) 66 | { 67 | QStringList tokens = row.split(QLatin1Char(' '), Qt::SkipEmptyParts); 68 | if( (tokens.size() < 5) 69 | || (!tokens[0].startsWith(QLatin1String("cpu"))) ) 70 | continue; 71 | 72 | mSources.append(tokens[0]); 73 | } 74 | 75 | mBounds.clear(); 76 | 77 | bool ok = false; 78 | 79 | const QStringList ranges = readAllFile("/sys/devices/system/cpu/online").split(QLatin1Char(','), Qt::SkipEmptyParts); 80 | for (const QString &range : ranges) 81 | { 82 | int dash = range.indexOf(QLatin1Char('-')); 83 | if (dash != -1) 84 | { 85 | uint min = range.first(dash).toUInt(&ok); 86 | if (ok) 87 | { 88 | uint max = range.sliced(dash + 1, range.size() - dash - 1).toUInt(&ok); 89 | if (ok) 90 | for (uint number = min; number <= max; ++number) 91 | addSource(QString::fromLatin1("cpu%1").arg(number)); 92 | } 93 | } 94 | else 95 | { 96 | uint number = range.toUInt(&ok); 97 | if (ok) 98 | addSource(QString::fromLatin1("cpu%1").arg(number)); 99 | } 100 | } 101 | } 102 | 103 | CpuStatPrivate::~CpuStatPrivate() = default; 104 | 105 | void CpuStatPrivate::intervalChanged() 106 | { 107 | recalculateMinMax(); 108 | } 109 | 110 | void CpuStatPrivate::sourceChanged() 111 | { 112 | recalculateMinMax(); 113 | } 114 | 115 | void CpuStatPrivate::recalculateMinMax() 116 | { 117 | int cores = 1; 118 | if (mSource == QLatin1String("cpu")) 119 | cores = mSources.size() - 1; 120 | 121 | mIntervalMin = static_cast(mTimer->interval()) / 1000 * static_cast(mUserHz) * static_cast(cores) / 1.25; // -25% 122 | mIntervalMax = static_cast(mTimer->interval()) / 1000 * static_cast(mUserHz) * static_cast(cores) * 1.25; // +25% 123 | } 124 | 125 | void CpuStatPrivate::timeout() 126 | { 127 | if ( (mMonitoring == CpuStat::LoadOnly) 128 | || (mMonitoring == CpuStat::LoadAndFrequency) ) 129 | { 130 | const QStringList rows = readAllFile("/proc/stat").split(QLatin1Char('\n'), Qt::SkipEmptyParts); 131 | for (const QString &row : rows) 132 | { 133 | if (!row.startsWith(QLatin1String("cpu"))) 134 | continue; 135 | 136 | if (row.startsWith(mSource + QLatin1Char(' '))) 137 | { 138 | QStringList tokens = row.split(QLatin1Char(' '), Qt::SkipEmptyParts); 139 | if (tokens.size() < 5) 140 | continue; 141 | 142 | Values current; 143 | current.user = tokens[1].toULongLong(); 144 | current.nice = tokens[2].toULongLong(); 145 | current.system = tokens[3].toULongLong(); 146 | current.idle = tokens[4].toULongLong(); 147 | current.other = 0; 148 | int m = tokens.size(); 149 | for (int i = 5; i < m; ++i) 150 | current.other += tokens[i].toULongLong(); 151 | current.sum(); 152 | 153 | float sumDelta = static_cast(current.total - mPrevious.total); 154 | 155 | if ((mPrevious.total != 0) && ((sumDelta < mIntervalMin) || (sumDelta > mIntervalMax))) 156 | { 157 | if (mMonitoring == CpuStat::LoadAndFrequency) 158 | emit update(0.0, 0.0, 0.0, 0.0, 0.0, 0); 159 | else 160 | emit update(0.0, 0.0, 0.0, 0.0); 161 | 162 | mPrevious.clear(); // make sure it won't keep crazy values. 163 | } 164 | else 165 | { 166 | if (mMonitoring == CpuStat::LoadAndFrequency) 167 | { 168 | float freqRate = 1.0; 169 | uint freq = 0; 170 | 171 | bool ok = false; 172 | 173 | if (mSource == QLatin1String("cpu")) 174 | { 175 | uint count = 0; 176 | freqRate = 0.0; 177 | 178 | for (Bounds::ConstIterator I = mBounds.constBegin(); I != mBounds.constEnd(); ++I) 179 | { 180 | uint thisFreq = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_cur_freq").arg(I.key()))).toUInt(&ok); 181 | 182 | if (ok) 183 | { 184 | freq += thisFreq; 185 | freqRate += static_cast(thisFreq) / static_cast(I.value().second); 186 | ++count; 187 | } 188 | } 189 | if (!count) 190 | freqRate = 1.0; 191 | else 192 | { 193 | freq /= count; 194 | freqRate /= count; 195 | } 196 | } 197 | else 198 | { 199 | freq = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_cur_freq").arg(mSource))).toUInt(&ok); 200 | 201 | if (ok) 202 | { 203 | Bounds::ConstIterator I = mBounds.constFind(mSource); 204 | if (I != mBounds.constEnd()) 205 | freqRate = static_cast(freq) / static_cast(I.value().second); 206 | } 207 | } 208 | 209 | emit update( 210 | static_cast(current.user - mPrevious.user ) / sumDelta, 211 | static_cast(current.nice - mPrevious.nice ) / sumDelta, 212 | static_cast(current.system - mPrevious.system) / sumDelta, 213 | static_cast(current.other - mPrevious.other ) / sumDelta, 214 | freqRate, 215 | freq); 216 | } 217 | else 218 | { 219 | emit update( 220 | static_cast(current.user - mPrevious.user ) / sumDelta, 221 | static_cast(current.nice - mPrevious.nice ) / sumDelta, 222 | static_cast(current.system - mPrevious.system) / sumDelta, 223 | static_cast(current.other - mPrevious.other ) / sumDelta); 224 | } 225 | 226 | mPrevious = current; 227 | } 228 | } 229 | } 230 | } 231 | else 232 | { 233 | bool ok = false; 234 | uint freq = 0; 235 | 236 | if (mSource == QLatin1String("cpu")) 237 | { 238 | uint count = 0; 239 | 240 | for (Bounds::ConstIterator I = mBounds.constBegin(); I != mBounds.constEnd(); ++I) 241 | { 242 | uint thisFreq = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_cur_freq").arg(I.key()))).toUInt(&ok); 243 | 244 | if (ok) 245 | { 246 | freq += thisFreq; 247 | ++count; 248 | } 249 | } 250 | if (count) 251 | { 252 | freq /= count; 253 | } 254 | } 255 | else 256 | { 257 | freq = readAllFile(qPrintable(QString::fromLatin1("/sys/devices/system/cpu/%1/cpufreq/scaling_cur_freq").arg(mSource))).toUInt(&ok); 258 | } 259 | emit update(freq); 260 | } 261 | } 262 | 263 | QString CpuStatPrivate::defaultSource() 264 | { 265 | return QLatin1String("cpu"); 266 | } 267 | 268 | CpuStatPrivate::Values::Values() 269 | : user(0) 270 | , nice(0) 271 | , system(0) 272 | , idle(0) 273 | , other(0) 274 | , total(0) 275 | { 276 | } 277 | 278 | void CpuStatPrivate::Values::sum() 279 | { 280 | total = user + nice + system + idle + other; 281 | } 282 | 283 | void CpuStatPrivate::Values::clear() 284 | { 285 | total = user = nice = system = idle = other = 0; 286 | } 287 | 288 | CpuStat::Monitoring CpuStatPrivate::monitoring() const 289 | { 290 | return mMonitoring; 291 | } 292 | 293 | void CpuStatPrivate::setMonitoring(CpuStat::Monitoring value) 294 | { 295 | mPrevious.clear(); 296 | mMonitoring = value; 297 | } 298 | 299 | CpuStat::CpuStat(QObject *parent) 300 | : BaseStat(parent) 301 | { 302 | impl = new CpuStatPrivate(this); 303 | baseimpl = impl; 304 | 305 | connect(impl, SIGNAL(update(float,float,float,float,float,uint)), this, SIGNAL(update(float,float,float,float,float,uint))); 306 | connect(impl, SIGNAL(update(float,float,float,float)), this, SIGNAL(update(float,float,float,float))); 307 | connect(impl, SIGNAL(update(uint)), this, SIGNAL(update(uint))); 308 | } 309 | 310 | CpuStat::~CpuStat() = default; 311 | 312 | void CpuStat::updateSources() 313 | { 314 | dynamic_cast(impl)->updateSources(); 315 | } 316 | 317 | CpuStat::Monitoring CpuStat::monitoring() const 318 | { 319 | return impl->monitoring(); 320 | } 321 | 322 | void CpuStat::setMonitoring(CpuStat::Monitoring value) 323 | { 324 | if (impl->monitoring() != value) 325 | { 326 | impl->setMonitoring(value); 327 | emit monitoringChanged(value); 328 | } 329 | } 330 | 331 | } 332 | -------------------------------------------------------------------------------- /cpustat.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__CPU_STAT__INCLUDED 28 | #define LIBSYSSTAT__CPU_STAT__INCLUDED 29 | 30 | 31 | #include 32 | 33 | #include "basestat.h" 34 | 35 | 36 | namespace SysStat { 37 | 38 | class CpuStatPrivate; 39 | 40 | class SYSSTATSHARED_EXPORT CpuStat : public BaseStat 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | CpuStat(QObject *parent = nullptr); 46 | ~CpuStat() override; 47 | 48 | enum Monitoring { LoadAndFrequency, LoadOnly, FrequencyOnly }; 49 | Q_ENUM(Monitoring) 50 | 51 | void updateSources(); 52 | 53 | uint minFreq(const QString &source) const; 54 | uint maxFreq(const QString &source) const; 55 | 56 | signals: 57 | void update(float user, float nice, float system, float other, float frequencyRate, uint frequency); 58 | void update(float user, float nice, float system, float other); 59 | void update(uint frequency); 60 | 61 | void monitoringChanged(Monitoring); 62 | 63 | public: 64 | Q_PROPERTY(Monitoring monitoring READ monitoring WRITE setMonitoring NOTIFY monitoringChanged) 65 | 66 | public slots: 67 | Monitoring monitoring() const; 68 | void setMonitoring(Monitoring value); 69 | 70 | protected: 71 | CpuStatPrivate* impl; 72 | }; 73 | 74 | } 75 | 76 | #endif //LIBSYSSTAT__CPU_STAT__INCLUDED 77 | -------------------------------------------------------------------------------- /cpustat_p.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__CPU_STAT__PRIVATE__INCLUDED 28 | #define LIBSYSSTAT__CPU_STAT__PRIVATE__INCLUDED 29 | 30 | 31 | #include 32 | #include 33 | #include 34 | #include 35 | 36 | #include "basestat_p.h" 37 | #include "cpustat.h" 38 | 39 | 40 | namespace SysStat { 41 | 42 | class CpuStatPrivate : public BaseStatPrivate 43 | { 44 | Q_OBJECT 45 | 46 | public: 47 | CpuStatPrivate(CpuStat *parent = nullptr); 48 | ~CpuStatPrivate() override; 49 | 50 | void updateSources(); 51 | 52 | CpuStat::Monitoring monitoring() const; 53 | void setMonitoring(CpuStat::Monitoring value); 54 | 55 | uint minFreq(const QString &source) const; 56 | uint maxFreq(const QString &source) const; 57 | 58 | signals: 59 | void update(float user, float nice, float system, float other); 60 | void update(uint frequency); 61 | void update(float user, float nice, float system, float other, float frequencyRate, uint frequency); 62 | 63 | private slots: 64 | void timeout(); 65 | 66 | protected: 67 | void intervalChanged() override; 68 | void sourceChanged() override; 69 | 70 | private: 71 | QString defaultSource() override; 72 | 73 | typedef struct Values 74 | { 75 | Values(); 76 | 77 | qulonglong user; 78 | qulonglong nice; 79 | qulonglong system; 80 | qulonglong idle; 81 | qulonglong other; 82 | qulonglong total; 83 | 84 | void sum(); 85 | 86 | void clear(); 87 | } Values; 88 | Values mPrevious; 89 | 90 | CpuStat::Monitoring mMonitoring; 91 | 92 | typedef QMap > Bounds; 93 | Bounds mBounds; 94 | 95 | int mUserHz; 96 | 97 | void addSource(const QString &source); 98 | 99 | float mIntervalMin; 100 | float mIntervalMax; 101 | 102 | void recalculateMinMax(); 103 | }; 104 | 105 | } 106 | 107 | #endif //LIBSYSSTAT__CPU_STAT__PRIVATE__INCLUDED 108 | -------------------------------------------------------------------------------- /memstat.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #include "memstat.h" 28 | #include "memstat_p.h" 29 | 30 | 31 | namespace SysStat { 32 | 33 | MemStatPrivate::MemStatPrivate(MemStat *parent) 34 | : BaseStatPrivate(parent) 35 | { 36 | mSource = defaultSource(); 37 | 38 | connect(mTimer, SIGNAL(timeout()), SLOT(timeout())); 39 | 40 | mSources << QLatin1String("memory") << QLatin1String("swap"); 41 | } 42 | 43 | MemStatPrivate::~MemStatPrivate() = default; 44 | 45 | void MemStatPrivate::timeout() 46 | { 47 | qulonglong memTotal = 0; 48 | qulonglong memFree = 0; 49 | qulonglong memBuffers = 0; 50 | qulonglong memCached = 0; 51 | qulonglong swapTotal = 0; 52 | qulonglong swapFree = 0; 53 | 54 | const QStringList rows = readAllFile("/proc/meminfo").split(QLatin1Char('\n'), Qt::SkipEmptyParts); 55 | for (const QString &row : rows) 56 | { 57 | QStringList tokens = row.split(QLatin1Char(' '), Qt::SkipEmptyParts); 58 | if (tokens.size() != 3) 59 | continue; 60 | 61 | if (tokens[0] == QLatin1String("MemTotal:")) 62 | memTotal = tokens[1].toULong(); 63 | else if(tokens[0] == QLatin1String("MemFree:")) 64 | memFree = tokens[1].toULong(); 65 | else if(tokens[0] == QLatin1String("Buffers:")) 66 | memBuffers = tokens[1].toULong(); 67 | else if(tokens[0] == QLatin1String("Cached:")) 68 | memCached = tokens[1].toULong(); 69 | else if(tokens[0] == QLatin1String("SwapTotal:")) 70 | swapTotal = tokens[1].toULong(); 71 | else if(tokens[0] == QLatin1String("SwapFree:")) 72 | swapFree = tokens[1].toULong(); 73 | } 74 | 75 | if (mSource == QLatin1String("memory")) 76 | { 77 | if (memTotal) 78 | { 79 | float memTotal_d = static_cast(memTotal); 80 | float applications_d = static_cast(memTotal - memFree - memBuffers - memCached) / memTotal_d; 81 | float buffers_d = static_cast(memBuffers) / memTotal_d; 82 | float cached_d = static_cast(memCached) / memTotal_d; 83 | 84 | emit memoryUpdate(applications_d, buffers_d, cached_d); 85 | } 86 | } 87 | else if (mSource == QLatin1String("swap")) 88 | { 89 | if (swapTotal) 90 | { 91 | float swapUsed_d = static_cast(swapTotal - swapFree) / static_cast(swapTotal); 92 | 93 | emit swapUpdate(swapUsed_d); 94 | } 95 | } 96 | } 97 | 98 | QString MemStatPrivate::defaultSource() 99 | { 100 | return QLatin1String("memory"); 101 | } 102 | 103 | MemStat::MemStat(QObject *parent) 104 | : BaseStat(parent) 105 | { 106 | impl = new MemStatPrivate(this); 107 | baseimpl = impl; 108 | 109 | connect(impl, SIGNAL(memoryUpdate(float,float,float)), this, SIGNAL(memoryUpdate(float,float,float))); 110 | connect(impl, SIGNAL(swapUpdate(float)), this, SIGNAL(swapUpdate(float))); 111 | } 112 | 113 | MemStat::~MemStat() = default; 114 | 115 | } 116 | -------------------------------------------------------------------------------- /memstat.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__MEM_STAT__INCLUDED 28 | #define LIBSYSSTAT__MEM_STAT__INCLUDED 29 | 30 | 31 | #include 32 | 33 | #include "basestat.h" 34 | 35 | 36 | namespace SysStat { 37 | 38 | class MemStatPrivate; 39 | 40 | class SYSSTATSHARED_EXPORT MemStat : public BaseStat 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | MemStat(QObject *parent = nullptr); 46 | ~MemStat() override; 47 | 48 | signals: 49 | void memoryUpdate(float apps, float buffers, float cached); 50 | void swapUpdate(float used); 51 | 52 | protected: 53 | MemStatPrivate* impl; 54 | }; 55 | 56 | } 57 | 58 | #endif //LIBSYSSTAT__MEM_STAT__INCLUDED 59 | -------------------------------------------------------------------------------- /memstat_p.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__MEM_STAT__PRIVATE__INCLUDED 28 | #define LIBSYSSTAT__MEM_STAT__PRIVATE__INCLUDED 29 | 30 | 31 | #include 32 | #include 33 | 34 | #include "basestat_p.h" 35 | #include "memstat.h" 36 | 37 | 38 | namespace SysStat { 39 | 40 | class MemStatPrivate : public BaseStatPrivate 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | MemStatPrivate(MemStat *parent = nullptr); 46 | ~MemStatPrivate() override; 47 | 48 | signals: 49 | void memoryUpdate(float apps, float buffers, float cached); 50 | void swapUpdate(float used); 51 | 52 | private slots: 53 | void timeout(); 54 | 55 | private: 56 | QString defaultSource() override; 57 | }; 58 | 59 | } 60 | 61 | #endif //LIBSYSSTAT__MEM_STAT__PRIVATE__INCLUDED 62 | -------------------------------------------------------------------------------- /netstat.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #include "netstat.h" 28 | #include "netstat_p.h" 29 | 30 | 31 | namespace SysStat { 32 | 33 | NetStatPrivate::NetStatPrivate(NetStat *parent) 34 | : BaseStatPrivate(parent) 35 | { 36 | mSource = defaultSource(); 37 | 38 | connect(mTimer, SIGNAL(timeout()), SLOT(timeout())); 39 | 40 | 41 | QStringList rows(readAllFile("/proc/net/dev").split(QLatin1Char('\n'), Qt::SkipEmptyParts)); 42 | 43 | rows.erase(rows.cbegin(), rows.cbegin() + 2); 44 | 45 | for (const QString &row : std::as_const(rows)) 46 | { 47 | QStringList tokens = row.split(QLatin1Char(':'), Qt::SkipEmptyParts); 48 | if (tokens.size() != 2) 49 | continue; 50 | 51 | mSources.append(tokens[0].trimmed()); 52 | } 53 | } 54 | 55 | NetStatPrivate::~NetStatPrivate() = default; 56 | 57 | void NetStatPrivate::timeout() 58 | { 59 | QStringList rows(readAllFile("/proc/net/dev").split(QLatin1Char('\n'), Qt::SkipEmptyParts)); 60 | 61 | 62 | if (rows.size() < 2) 63 | return; 64 | 65 | QStringList names = rows[1].split(QLatin1Char('|')); 66 | if (names.size() != 3) 67 | return; 68 | QStringList namesR = names[1].split(QLatin1Char(' '), Qt::SkipEmptyParts); 69 | QStringList namesT = names[2].split(QLatin1Char(' '), Qt::SkipEmptyParts); 70 | int receivedIndex = namesR.indexOf(QLatin1String("bytes")); 71 | int transmittedIndex = namesR.size() + namesT.indexOf(QLatin1String("bytes")); 72 | 73 | rows.erase(rows.cbegin(), rows.cbegin() + 2); 74 | 75 | for (const QString &row : std::as_const(rows)) 76 | { 77 | QStringList tokens = row.split(QLatin1Char(':'), Qt::SkipEmptyParts); 78 | if (tokens.size() != 2) 79 | continue; 80 | 81 | QString interfaceName = tokens[0].trimmed(); 82 | 83 | QStringList data = tokens[1].split(QLatin1Char(' '), Qt::SkipEmptyParts); 84 | if (data.size() < transmittedIndex) 85 | continue; 86 | 87 | Values current; 88 | current.received = data[receivedIndex ].toULongLong(); 89 | current.transmitted = data[transmittedIndex].toULongLong(); 90 | 91 | if (!mPrevious.contains(interfaceName)) 92 | mPrevious.insert(interfaceName, Values()); 93 | const Values &previous = mPrevious[interfaceName]; 94 | 95 | if (interfaceName == mSource) 96 | emit update((( current.received - previous.received ) * 1000 ) / mTimer->interval(), (( current.transmitted - previous.transmitted ) * 1000 ) / mTimer->interval()); 97 | 98 | mPrevious[interfaceName] = current; 99 | } 100 | } 101 | 102 | QString NetStatPrivate::defaultSource() 103 | { 104 | return QLatin1String("lo"); 105 | } 106 | 107 | NetStatPrivate::Values::Values() 108 | : received(0) 109 | , transmitted(0) 110 | { 111 | } 112 | 113 | NetStat::NetStat(QObject *parent) 114 | : BaseStat(parent) 115 | { 116 | impl = new NetStatPrivate(this); 117 | baseimpl = impl; 118 | 119 | connect(impl, SIGNAL(update(unsigned,unsigned)), this, SIGNAL(update(unsigned,unsigned))); 120 | } 121 | 122 | NetStat::~NetStat() = default; 123 | 124 | } 125 | -------------------------------------------------------------------------------- /netstat.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__NET_STAT__INCLUDED 28 | #define LIBSYSSTAT__NET_STAT__INCLUDED 29 | 30 | 31 | #include 32 | 33 | #include "basestat.h" 34 | 35 | 36 | namespace SysStat { 37 | 38 | class NetStatPrivate; 39 | 40 | class SYSSTATSHARED_EXPORT NetStat : public BaseStat 41 | { 42 | Q_OBJECT 43 | 44 | public: 45 | NetStat(QObject *parent = nullptr); 46 | ~NetStat() override; 47 | 48 | signals: 49 | void update(unsigned received, unsigned transmitted); 50 | 51 | protected: 52 | NetStatPrivate* impl; 53 | }; 54 | 55 | } 56 | 57 | #endif //LIBSYSSTAT__NET_STAT__INCLUDED 58 | -------------------------------------------------------------------------------- /netstat_p.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__NET_STAT__PRIVATE__INCLUDED 28 | #define LIBSYSSTAT__NET_STAT__PRIVATE__INCLUDED 29 | 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include "basestat_p.h" 36 | #include "netstat.h" 37 | 38 | 39 | namespace SysStat { 40 | 41 | class NetStatPrivate : public BaseStatPrivate 42 | { 43 | Q_OBJECT 44 | 45 | public: 46 | NetStatPrivate(NetStat *parent = nullptr); 47 | ~NetStatPrivate() override; 48 | 49 | signals: 50 | void update(unsigned received, unsigned transmitted); 51 | 52 | private slots: 53 | void timeout(); 54 | 55 | private: 56 | QString defaultSource() override; 57 | 58 | typedef struct Values 59 | { 60 | Values(); 61 | 62 | qulonglong received; 63 | qulonglong transmitted; 64 | } Values; 65 | typedef QMap NamedValues; 66 | NamedValues mPrevious; 67 | }; 68 | 69 | } 70 | 71 | #endif //LIBSYSSTAT__NET_STAT__PRIVATE__INCLUDED 72 | -------------------------------------------------------------------------------- /sysstat.pro: -------------------------------------------------------------------------------- 1 | ## BEGIN_COMMON_COPYRIGHT_HEADER 2 | ## (c)LGPL2+ 3 | ## 4 | ## SysStat is a Qt-based interface to system statistics 5 | ## 6 | ## Authors: 7 | ## Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ## 9 | ## This library is free software; you can redistribute it and/or 10 | ## modify it under the terms of the GNU Lesser General Public 11 | ## License as published by the Free Software Foundation; either 12 | ## version 2.1 of the License, or (at your option) any later version. 13 | ## 14 | ## This library is distributed in the hope that it will be useful, 15 | ## but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ## MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ## Lesser General Public License for more details. 18 | ## 19 | ## You should have received a copy of the GNU Lesser General Public 20 | ## License along with this library; 21 | ## if not, write to the Free Software Foundation, Inc., 22 | ## 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ## 24 | ## END_COMMON_COPYRIGHT_HEADER 25 | 26 | 27 | TARGET = sysstat 28 | 29 | DEFINES += SYSSTAT_LIBRARY 30 | 31 | TEMPLATE = lib 32 | 33 | QT -= gui 34 | 35 | isEmpty(MAJOR_VERSION):MAJOR_VERSION = 1 36 | isEmpty(MINOR_VERSION):MINOR_VERSION = 0 37 | 38 | VERSION = $${MAJOR_VERSION}.$${MINOR_VERSION}.0 39 | 40 | INCLUDEPATH += .. 41 | 42 | DEFINES += \ 43 | MAJOR_VERSION=$${MAJOR_VERSION} \ 44 | MINOR_VERSION=$${MINOR_VERSION} 45 | 46 | SOURCES += \ 47 | version.cpp \ 48 | basestat.cpp \ 49 | cpustat.cpp \ 50 | memstat.cpp \ 51 | netstat.cpp 52 | 53 | PUBLIC_HEADERS += \ 54 | version.hpp \ 55 | sysstat_global.hpp \ 56 | basestat.hpp \ 57 | cpustat.hpp \ 58 | memstat.hpp \ 59 | netstat.hpp 60 | 61 | PRIVATE_HEADERS += \ 62 | version_p.hpp \ 63 | basestat_p.hpp \ 64 | cpustat_p.hpp \ 65 | memstat_p.hpp \ 66 | netstat_p.hpp 67 | 68 | HEADERS += \ 69 | $${PUBLIC_HEADERS} \ 70 | $${PRIVATE_HEADERS} 71 | 72 | OTHER_FILES += \ 73 | COPYING 74 | -------------------------------------------------------------------------------- /sysstat_global.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__SYSSTAT__GLOBAL__INCLUDED 28 | #define LIBSYSSTAT__SYSSTAT__GLOBAL__INCLUDED 29 | 30 | #include 31 | 32 | #if defined(SYSSTAT_LIBRARY) 33 | # define SYSSTATSHARED_EXPORT Q_DECL_EXPORT 34 | #else 35 | # define SYSSTATSHARED_EXPORT Q_DECL_IMPORT 36 | #endif 37 | 38 | #endif // LIBSYSSTAT__SYSSTAT__GLOBAL__INCLUDED 39 | -------------------------------------------------------------------------------- /version.cpp: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #include 28 | #include "version_p.h" 29 | 30 | 31 | namespace SysStat { 32 | 33 | namespace version { 34 | 35 | QString verbose() 36 | { 37 | return QString::fromLatin1("%1.%2.%3").arg(QLatin1String(MAJOR_VERSION_STR)).arg(QLatin1String(MINOR_VERSION_STR)).arg(QLatin1String(PATCH_VERSION_STR)); 38 | } 39 | 40 | int majorNumber() 41 | { 42 | return MAJOR_VERSION; 43 | } 44 | 45 | int minorNumber() 46 | { 47 | return MINOR_VERSION; 48 | } 49 | 50 | int patchNumber() 51 | { 52 | return PATCH_VERSION; 53 | } 54 | 55 | } 56 | 57 | } 58 | -------------------------------------------------------------------------------- /version.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__VERSION__INCLUDED 28 | #define LIBSYSSTAT__VERSION__INCLUDED 29 | 30 | 31 | namespace SysStat { 32 | 33 | namespace version { 34 | QString verbose(); 35 | int majorNumber(); 36 | int minorNumber(); 37 | int patchNumber(); 38 | } 39 | } 40 | 41 | #endif // LIBSYSSTAT__VERSION__INCLUDED 42 | -------------------------------------------------------------------------------- /version_p.h: -------------------------------------------------------------------------------- 1 | /* BEGIN_COMMON_COPYRIGHT_HEADER 2 | * (c)LGPL2+ 3 | ** 4 | ** SysStat is a Qt-based interface to system statistics 5 | ** 6 | ** Authors: 7 | ** Copyright (c) 2009 - 2012 Kuzma Shapran 8 | ** 9 | ** This library is free software; you can redistribute it and/or 10 | ** modify it under the terms of the GNU Lesser General Public 11 | ** License as published by the Free Software Foundation; either 12 | ** version 2.1 of the License, or (at your option) any later version. 13 | ** 14 | ** This library is distributed in the hope that it will be useful, 15 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of 16 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 17 | ** Lesser General Public License for more details. 18 | ** 19 | ** You should have received a copy of the GNU Lesser General Public 20 | ** License along with this library; 21 | ** if not, write to the Free Software Foundation, Inc., 22 | ** 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 23 | ** 24 | ** END_COMMON_COPYRIGHT_HEADER */ 25 | 26 | 27 | #ifndef LIBSYSSTAT__VERSION__PRIVATE__INCLUDED 28 | #define LIBSYSSTAT__VERSION__PRIVATE__INCLUDED 29 | 30 | 31 | #define STRINGIFY(x) #x 32 | #define TOSTRING(x) STRINGIFY(x) 33 | #define MAJOR_VERSION_STR TOSTRING(MAJOR_VERSION) 34 | #define MINOR_VERSION_STR TOSTRING(MINOR_VERSION) 35 | #define PATCH_VERSION_STR TOSTRING(PATCH_VERSION) 36 | 37 | 38 | #endif // LIBSYSSTAT__VERSION__PRIVATE__INCLUDED 39 | --------------------------------------------------------------------------------