Skip to content

Update ps_section.py #805

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open

Update ps_section.py #805

wants to merge 1 commit into from

Conversation

fuf42
Copy link

@fuf42 fuf42 commented Mar 25, 2025

General information

Simply ignore empty string_table here to prevent crash of ps check.

That occured through a broken agent not returning all needed ps-Informations but checking the existance of the dictionary won't hurt otherwise and makes the code more rubust

Bug reports

Crash report fcdadad2-0961-11f0-8161-ad7691f8c67a

Proposed changes

Expected behaviour: be more resilient against broken agent input. Do not crash. Ignore it.

prevent crash on empty string_table.
@m3hransh
Copy link
Contributor

@fuf42 After investigating, it seems that the check might be unnecessary. Could you provide more details on when exactly you encounter this crash? I highly doubt that the check for StringTable is needed, as the agent output should always be non-empty if the ps_lnx section is present (unless the agent crash between two echo).
For reference, here’s the relevant part from agents/check_mk_agent.linux:

section_ps() {
    if inpath ps; then
        # processes including username, without kernel processes
        echo '<<<ps_lnx>>>'
        echo "[time]"
        get_epoch
        echo "[processes]"
        CGROUP=""
        if [ -e /sys/fs/cgroup ]; then
            CGROUP="cgroup:512,"
        fi
        echo "[header] $(ps ax -ww -o "${CGROUP}"user:32,vsz,rss,cputime,etime,pid,command | tr -s ' ')"
    fi
}

@fuf42
Copy link
Author

fuf42 commented Apr 28, 2025

Hi,

it's an android device with a broken agent which I cannot fix. The ps-section is simply empty.

<<<mounts>>>
rootfs / rootfs ro,seclabel 0 0
....
tmpfs /storage/self tmpfs rw,seclabel,relatime,size=906132k,mode=755,gid=1000 0 0
<<<ps>>>
<<<mem>>>
....

yes, this is not really a checkmk-core-Problem, more a fundamental question, but as I wrote I think it might be better to deal with possible wrong inputs than to crash the check

Christian

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants