AIX Open Source

AIX Open Source

Share your experiences and connect with fellow developers to discover how to build and manage open source software for the AIX operating system

 View Only
Expand all | Collapse all

psutil.boot_time stopped working after an update to AIX 7.3 TL3

  • 1.  psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Thu March 06, 2025 10:19 AM

    We had this with AIX 7.3 TL2 (example /opt/freeware/bin/python3 and DNF repo-supplied psutil but we can easily reproduce this with AIX's native python3 and compiled module):

    >>> import psutil
    >>> psutil.boot_time()
    1736354304.0

    Since update to AIX 7.3 TL3:
    >>> import psutil
    >>> psutil.boot_time()
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
      File "/opt/freeware/lib64/python3.9/site-packages/psutil/__init__.py", line 2310, in boot_time
        return _psplatform.boot_time()
      File "/opt/freeware/lib64/python3.9/site-packages/psutil/_psaix.py", line 272, in boot_time
        return cext.boot_time()
    RuntimeError: can't determine boot time

    Developer of psutil is unable to debug this due to his lack of access to an AIX box.

    Could someone please confirm the same? Wonder if this may be an issue only with certain settings/configuration.

    Thanks, j



    ------------------------------
    Jozef Riha
    ------------------------------


  • 2.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Fri March 07, 2025 04:18 AM

    Hi Jozef,

    This is the source of psutil which is used to provide boot_time.

    psutil_boot_time(PyObject *self, PyObject *args) {
        float boot_time = 0.0;
        struct utmpx *ut;
     
        setutxent();
        while (NULL != (ut = getutxent())) {
            if (ut->ut_type == BOOT_TIME) {
                boot_time = (float)ut->ut_tv.tv_sec;
                break;
            }
        }
        endutxent();

    The API getutxent is failing in AIX 7.3 TL3 as you have observed.
    Please raise a case against IBM for this issue.



    ------------------------------
    Shubham Gupta
    ------------------------------



  • 3.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Tue March 11, 2025 10:05 AM

    Thank you Shubham,

    I did raise this to IBM support and tried really hard to make them look into this. No luck. Their response (repeated a few time) was:

    > Note that this issue is still handled by opensource as this issue is with python modules and not handled by AIX Support teams

    > Kindly note that we cannot see any issues from OS side and such an issue is handled by Opensource community.

    The ticket was closed the next day.



    ------------------------------
    Jozef Riha
    ------------------------------



  • 4.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Tue March 11, 2025 10:22 AM

    May be you want to just say getutxent is not working as expected in AIX 7.3 TL3 and share the below example.,

    test.c
    =====
    #include<utmpx.h>
    int main(){
        float boot_time = 0.0;
        struct utmpx *ut;

        setutxent();
        while (NULL != (ut = getutxent())) {
            if (ut->ut_type == BOOT_TIME) {
                boot_time = (float)ut->ut_tv.tv_sec;
                break;
            }
        }
        endutxent();
        if (boot_time == 0.0) {
            /* could not find BOOT_TIME in getutxent loop */
            printf("can't determine boot time");
            return NULL;
        } else {
            printf("boot time = %f", boot_time);
            return 0;
        }
    }

    xlc_r -q64 test.c 
        or 
    gcc -maix64 test.c

    # ./a.out
    can't determine boot time



    ------------------------------
    Ayappan P
    ------------------------------



  • 5.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Tue March 11, 2025 10:30 AM

    Hi

    Utility like w, uptime also uses the same internal config file which is read by getutxent(). So I guess, these commands will also not work in your system.
    Run these command and check the outputs.

    https://www.ibm.com/support/pages/problems-etcutmp-file-aix

    Thanks
    Ranjit



    ------------------------------
    Ranjit Ranjan
    ------------------------------



  • 6.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Wed March 12, 2025 10:09 AM

    who -b and uptime commands work without issues.



    ------------------------------
    Jozef Riha
    ------------------------------



  • 7.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Wed March 12, 2025 02:28 AM

    Thank you, this is truly helpful. I did start to compile the c-program previously. But.. forgot the 64 flag. Compiling with 32-bit works:

    $ /opt/IBM/xlc/16.1.0/bin/xlc_r -o test.bin test.c; ./test.bin
    boot time = 1741082496.000000$
    $
    $ /opt/IBM/xlc/16.1.0/bin/xlc_r -o test.bin -q64 test.c; ./test.bin
    can't determine boot time$
    $

    I will reopen the case.



    ------------------------------
    Jozef Riha
    ------------------------------



  • 8.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Wed March 12, 2025 10:20 AM

    IBM is turning their back on me refusing to admit it's an OS problem and rather pointing me towards (expensive) lab services.

    I was able to pinpoint the issue to shr.o inside libc.a - a patched version of libc is working.

    # commands executed on TL3 with libc copied from TL2
    mkdir /tmp/patchedlibc && cd /tmp/patchedlibc
    ar -X32_64 xv /usr/lib/libc.a
    # /tmp/73tl2.libc contains libc.a extracted from 7.3TL2SP01
    cp ../73tl2.libc/_shr_64.o ../73tl2.libc/shr_64.o .
    rm libc.a
    # repack libc
    ar -X32_64 -v -q libc.a *
    LIBPATH=. ../test.bin
    # returns 1741082496.000000



    ------------------------------
    Jozef Riha
    ------------------------------



  • 9.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Wed March 12, 2025 10:25 AM

    We (AIX Toolbox team) have raised this issue internally with AIX libc team and they are working on it (The issue is genuine and it is acknowledged by them).



    ------------------------------
    Ayappan P
    ------------------------------



  • 10.  RE: psutil.boot_time stopped working after an update to AIX 7.3 TL3

    Posted Wed March 12, 2025 10:30 AM

    Thank you!



    ------------------------------
    Jozef Riha
    ------------------------------