diff options
| -rw-r--r-- | .gitignore | 9 | ||||
| -rw-r--r-- | Makefile | 4 | ||||
| -rw-r--r-- | PHPINFO | 6 | ||||
| -rw-r--r-- | REFLECTION | 363 | ||||
| -rw-r--r-- | composer.json | 29 | ||||
| -rw-r--r-- | php-iliaal-statgrab.spec | 131 |
6 files changed, 542 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..01f0400 --- /dev/null +++ b/.gitignore @@ -0,0 +1,9 @@ +clog +package-*.xml +*.tgz +*.tar.bz2 +*.tar.gz +*.tar.xz +*.tar.xz.asc +*.src.rpm +*/*rpm diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..13af741 --- /dev/null +++ b/Makefile @@ -0,0 +1,4 @@ +SRCDIR := $(shell pwd) +NAME := $(shell basename $(SRCDIR)) +include ../../../common/Makefile + @@ -0,0 +1,6 @@ + +statgrab + +statgrab support => enabled +Extension version => 2.2.0 +libstatgrab => initialized diff --git a/REFLECTION b/REFLECTION new file mode 100644 index 0000000..f269dcb --- /dev/null +++ b/REFLECTION @@ -0,0 +1,363 @@ +Extension [ <persistent> extension #125 statgrab version 2.2.0 ] { + + - Constants [16] { + Constant [ <persistent> int SG_FULL_DUPLEX ] { 0 } + Constant [ <persistent> int SG_HALF_DUPLEX ] { 1 } + Constant [ <persistent> int SG_UNKNOWN_DUPLEX ] { 2 } + Constant [ <persistent> int SG_PS_SORT_NAME ] { 0 } + Constant [ <persistent> int SG_PS_SORT_PID ] { 1 } + Constant [ <persistent> int SG_PS_SORT_UID ] { 2 } + Constant [ <persistent> int SG_PS_SORT_GID ] { 3 } + Constant [ <persistent> int SG_PS_SORT_SIZE ] { 4 } + Constant [ <persistent> int SG_PS_SORT_RES ] { 5 } + Constant [ <persistent> int SG_PS_SORT_CPU ] { 6 } + Constant [ <persistent> int SG_PS_SORT_TIME ] { 7 } + Constant [ <persistent> int SG_PROCESS_STATE_RUNNING ] { 0 } + Constant [ <persistent> int SG_PROCESS_STATE_SLEEPING ] { 1 } + Constant [ <persistent> int SG_PROCESS_STATE_STOPPED ] { 2 } + Constant [ <persistent> int SG_PROCESS_STATE_ZOMBIE ] { 3 } + Constant [ <persistent> int SG_PROCESS_STATE_UNKNOWN ] { 4 } + } + + - Functions { + Function [ <internal:statgrab> function sg_cpu_percent_usage ] { + + - Parameters [1] { + Parameter #0 [ <optional> int $source = 0 ] + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_cpu_totals ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_cpu_diff ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_diskio_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_diskio_stats_diff ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_fs_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_general_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_load_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_memory_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_swap_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_network_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_network_stats_diff ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_page_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_page_stats_diff ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_process_count ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_process_stats ] { + + - Parameters [2] { + Parameter #0 [ <optional> ?int $sort_order = null ] + Parameter #1 [ <optional> int $num_entries = 0 ] + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_user_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_network_iface_stats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_valid_filesystems ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + Function [ <internal:statgrab> function sg_set_valid_filesystems ] { + + - Parameters [1] { + Parameter #0 [ <required> array $filesystems ] + } + - Return [ bool ] + } + Function [ <internal:statgrab> function sg_snapshot ] { + + - Parameters [0] { + } + - Return [ bool ] + } + Function [ <internal:statgrab> function sg_error_details ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + } + + - Classes [1] { + Class [ <internal:statgrab> final class Statgrab ] { + + - Constants [37] { + Constant [ public int DUPLEX_FULL ] { 0 } + Constant [ public int DUPLEX_HALF ] { 1 } + Constant [ public int DUPLEX_UNKNOWN ] { 2 } + Constant [ public int SORT_NAME ] { 0 } + Constant [ public int SORT_PID ] { 1 } + Constant [ public int SORT_UID ] { 2 } + Constant [ public int SORT_GID ] { 3 } + Constant [ public int SORT_SIZE ] { 4 } + Constant [ public int SORT_RES ] { 5 } + Constant [ public int SORT_CPU ] { 6 } + Constant [ public int SORT_TIME ] { 7 } + Constant [ public int STATE_RUNNING ] { 0 } + Constant [ public int STATE_SLEEPING ] { 1 } + Constant [ public int STATE_STOPPED ] { 2 } + Constant [ public int STATE_ZOMBIE ] { 3 } + Constant [ public int STATE_UNKNOWN ] { 4 } + Constant [ public int CPU_PERCENT_ENTIRE ] { 0 } + Constant [ public int CPU_PERCENT_LAST_DIFF ] { 1 } + Constant [ public int CPU_PERCENT_NEW_DIFF ] { 2 } + Constant [ public int HOST_STATE_UNKNOWN ] { 0 } + Constant [ public int HOST_STATE_PHYSICAL ] { 1 } + Constant [ public int HOST_STATE_VIRTUAL_MACHINE ] { 2 } + Constant [ public int HOST_STATE_PARAVIRTUAL_MACHINE ] { 3 } + Constant [ public int HOST_STATE_HARDWARE_VIRTUALIZED ] { 4 } + Constant [ public int FS_UNKNOWN ] { 0 } + Constant [ public int FS_REGULAR ] { 1 } + Constant [ public int FS_SPECIAL ] { 2 } + Constant [ public int FS_LOOPBACK ] { 4 } + Constant [ public int FS_REMOTE ] { 8 } + Constant [ public int FS_LOCAL ] { 3 } + Constant [ public int FS_ALLTYPES ] { 15 } + Constant [ public int ERROR_NONE ] { 0 } + Constant [ public int ERROR_INVALID_ARGUMENT ] { 1 } + Constant [ public int ERROR_OPEN ] { 21 } + Constant [ public int ERROR_OPENDIR ] { 22 } + Constant [ public int ERROR_PERMISSION ] { 29 } + Constant [ public int ERROR_UNSUPPORTED ] { 44 } + } + + - Static properties [0] { + } + + - Static methods [0] { + } + + - Properties [0] { + } + + - Methods [20] { + Method [ <internal:statgrab, ctor> public method __construct ] { + + - Parameters [0] { + } + } + + Method [ <internal:statgrab> public method cpu ] { + + - Parameters [1] { + Parameter #0 [ <optional> int $source = 0 ] + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method cpuStats ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method cpuDiff ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method disks ] { + + - Parameters [1] { + Parameter #0 [ <optional> bool $diff = false ] + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method filesystems ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method host ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method load ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method memory ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method swap ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method network ] { + + - Parameters [1] { + Parameter #0 [ <optional> bool $diff = false ] + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method pages ] { + + - Parameters [1] { + Parameter #0 [ <optional> bool $diff = false ] + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method processes ] { + + - Parameters [2] { + Parameter #0 [ <optional> ?int $sort_order = null ] + Parameter #1 [ <optional> int $num_entries = 0 ] + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method processCount ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method users ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method interfaces ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method validFilesystems ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + + Method [ <internal:statgrab> public method setValidFilesystems ] { + + - Parameters [1] { + Parameter #0 [ <required> array $filesystems ] + } + - Return [ bool ] + } + + Method [ <internal:statgrab> public method snapshot ] { + + - Parameters [0] { + } + - Return [ bool ] + } + + Method [ <internal:statgrab> public method errorDetails ] { + + - Parameters [0] { + } + - Return [ array|false ] + } + } + } + } +} + diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..9f87341 --- /dev/null +++ b/composer.json @@ -0,0 +1,29 @@ +{ + "name": "iliaal/statgrab", + "type": "php-ext", + "description": "PHP extension wrapping libstatgrab, the cross-platform system-statistics library. CPU, memory, disk I/O, filesystems, network interfaces, processes, users.", + "keywords": ["system", "monitoring", "statistics", "libstatgrab", "php-extension", "pie", "pecl"], + "license": "PHP-3.01", + "homepage": "https://github.com/iliaal/statgrab", + "authors": [ + { + "name": "Ilia Alshanetsky", + "email": "ilia@ilia.ws" + } + ], + "require": { + "php": ">=8.0" + }, + "php-ext": { + "extension-name": "statgrab", + "configure-options": [ + { + "name": "with-statgrab", + "description": "Enable libstatgrab support (use =bundled for the vendored, leak-fixed copy)", + "needs-value": false + } + ], + "support-zts": false, + "support-nts": true + } +} diff --git a/php-iliaal-statgrab.spec b/php-iliaal-statgrab.spec new file mode 100644 index 0000000..d1dcd60 --- /dev/null +++ b/php-iliaal-statgrab.spec @@ -0,0 +1,131 @@ +# remirepo spec file for php-iliaal-statgrab +# +# SPDX-FileCopyrightText: Copyright 2026 Remi Collet +# SPDX-License-Identifier: CECILL-2.1 +# http://www.cecill.info/licences/Licence_CeCILL_V2-en.txt +# +# Please, preserve the changelog entries +# +%if 0%{?scl:1} +%scl_package php-iliaal-statgrab +%else +%global pkg_name %{name} +%endif + +%bcond_without tests + +%global gh_owner iliaal +%global gh_project statgrab +%global ext_name statgrab +%global pie_vend %{gh_owner} +%global pie_proj %{gh_project} +%global ini_name 40-%{ext_name}.ini +%global forgeurl https://github.com/%{gh_owner}/%{gh_project} +%global tag %{version} +# for EL-8 to avoid TAG usage +%global archivename %{gh_project}-%{tag} + +Name: %{?scl_prefix}php-%{pie_vend}-%{pie_proj} +Summary: PHP extension wrapping libstatgrab +License: PHP-3.01 +Version: 2.2.0 +Release: 1%{?dist} +%forgemeta +URL: %{forgeurl} +Source0: %{forgesource} + + +BuildRequires: %{?dtsprefix}gcc +BuildRequires: %{?scl_prefix}php-devel >= 8.0 +BuildRequires: pkgconfig(libstatgrab) >= 0.92 + +Requires: %{?scl_prefix}php(zend-abi) = %{php_zend_api} +Requires: %{?scl_prefix}php(api) = %{php_core_api} + +# Extension +Provides: %{?scl_prefix}php-%{ext_name} = %{version} +Provides: %{?scl_prefix}php-%{ext_name}%{?_isa} = %{version} +# PECL +Obsoletes: %{?scl_prefix}php-pecl-%{ext_name} < 2 +Provides: %{?scl_prefix}php-pecl-%{ext_name} = %{version} +Provides: %{?scl_prefix}php-pecl-%{ext_name}%{?_isa} = %{version} +# PIE +Provides: %{?scl_prefix}php-pie(%{pie_vend}/%{pie_proj}) = %{version} + + +%description +A native PHP extension wrapping libstatgrab, the cross-platform +system-statistics library. CPU, memory, disk I/O, filesystems, +network interfaces, processes, users. + +Package built for PHP %(%{__php} -r 'echo PHP_MAJOR_VERSION.".".PHP_MINOR_VERSION;')%{?scl: as Software Collection (%{scl} by %{?scl_vendor}%{!?scl_vendor:rh})}. + + +%prep +%forgesetup + +rm -r vendor + +# Sanity check, really often broken +extver=$(sed -n '/#define PHP_STATGRAB_VERSION/{s/.* "//;s/".*$//;p}' php_statgrab.h) +if test "x${extver}" != "x%{version}"; then + : Error: Upstream extension version is ${extver}, expecting %{version}. + exit 1 +fi + +# Drop in the bit of configuration +cat << 'EOF' | tee %{ini_name} +; Enable '%{summary}' extension module +extension = %{ext_name} +EOF + + +%build +%{?dtsenable} + +%{__phpize} +sed -e 's/INSTALL_ROOT/DESTDIR/' -i build/Makefile.global + +%configure \ + --with-php-config=%{__phpconfig} \ + --with-libdir=%{_lib} \ + --with-statgrab + +%make_build + + +%install +%{?dtsenable} + +# Install the NTS stuff +%make_install +install -D -m 644 %{ini_name} %{buildroot}%{php_inidir}/%{ini_name} + + +%check +: Minimal load test for NTS extension +%{__php} --no-php-ini \ + --define extension=%{buildroot}%{php_extdir}/%{ext_name}.so \ + --modules | grep '^%{ext_name}$' + +%if %{with tests} +: Upstream test suite for NTS extension +TEST_PHP_ARGS="-n -d extension=%{buildroot}%{php_extdir}/%{ext_name}.so" \ +%{__php} -n run-tests.php --show-diff %{?_smp_mflags} +%endif + + +%files +%license LICENSE +%doc composer.json +%doc CREDITS +%doc *.md + +%config(noreplace) %{php_inidir}/%{ini_name} +%{php_extdir}/%{ext_name}.so + + + +%changelog +* Wed Apr 29 2026 Remi Collet <remi@remirepo.net> - 2.2.0-1 +- new package |
