Skip to content
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

Exit codes are not documented in the man page #261

Open
kpinc opened this issue Jan 18, 2023 · 4 comments
Open

Exit codes are not documented in the man page #261

kpinc opened this issue Jan 18, 2023 · 4 comments

Comments

@kpinc
Copy link

kpinc commented Jan 18, 2023

Hi,

There is no documentation of needrestart's exit codes. At least not in the man page needrestart(1). Knowing exit codes could be useful. For example, when writing a shell script to email needrestart output (Issue# 24, email frontend #24) the exit code might reveal whether or not anything needs restarting and so whether or not to send an email.

@l0f4r0
Copy link

l0f4r0 commented Jun 23, 2023

I'm not sure needrestart exits differently than 0 by default (I've not made exhaustive tests though but right now it's exiting 0 should my user session is running outdated binaries or not...).

However, you can activate nagios mode with -p switch (equivalent of -t switch with checkrestart) and then you have different exit codes, nagios-compatible, depending on the situation.
Those return codes are documented by Nagios itself here: https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/pluginapi.html

@phrozen77
Copy link

phrozen77 commented Apr 10, 2024

However, you can activate nagios mode with -p switch (equivalent of -t switch with checkrestart) and then you have different exit codes, nagios-compatible, depending on the situation.

I think it does, yes - at least i'm seeing 0 as well as 128 when being run as part of an Ansible playbook.

I tried your suggestion of adding "-p" - however, it seems it's just doing the output anymore, no more service restarts seem to happen..

Relevant config in my playbook:

    - name: Restart services if needed
      ansible.builtin.command: needrestart -r a -p
      register: returned
      changed_when: returned.rc != 0

If anyone has helpful pointers on how to handle that, i'd really appreciate it (just getting my feet wet with Ansible).

@nlsschmdt
Copy link

I'm in the same boat using needrestart -r -a from ansible. Occasionally I see return code 128 with empty stderr and empty stdout. This is happening for months now, but I can not find out what is causing it. Running needrestart again leads to exit code 0. I would really like to know the meaning of the return code 128 to be able to decide on how to handle those situations.

@kpinc
Copy link
Author

kpinc commented Jul 11, 2024 via email

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

No branches or pull requests

4 participants