{"id":18030845,"url":"https://github.com/atc0005/check-restart","last_synced_at":"2025-09-18T00:32:46.436Z","repository":{"id":62866811,"uuid":"539417734","full_name":"atc0005/check-restart","owner":"atc0005","description":"Go-based tooling used to detect whether a restart (service) or reboot (system) is needed.","archived":false,"fork":false,"pushed_at":"2024-12-05T09:02:24.000Z","size":4400,"stargazers_count":2,"open_issues_count":12,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-12-31T19:11:27.407Z","etag":null,"topics":["go","golang","monitoring","nagios","nagios-plugin","plugin","reboot","restart","windows"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/atc0005.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-09-21T09:56:30.000Z","updated_at":"2024-12-04T16:01:31.000Z","dependencies_parsed_at":"2024-01-26T13:38:24.293Z","dependency_job_id":"3a86ef82-2bda-4852-a76e-568e085702ee","html_url":"https://github.com/atc0005/check-restart","commit_stats":null,"previous_names":[],"tags_count":47,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atc0005%2Fcheck-restart","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atc0005%2Fcheck-restart/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atc0005%2Fcheck-restart/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/atc0005%2Fcheck-restart/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/atc0005","download_url":"https://codeload.github.com/atc0005/check-restart/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":233433690,"owners_count":18675603,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["go","golang","monitoring","nagios","nagios-plugin","plugin","reboot","restart","windows"],"created_at":"2024-10-30T09:15:19.883Z","updated_at":"2025-09-18T00:32:40.797Z","avatar_url":"https://github.com/atc0005.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003c!-- omit in toc --\u003e\n# check-restart\n\nGo-based tooling used to detect whether a restart (service) or reboot (system) is needed.\n\n[![Latest Release](https://img.shields.io/github/release/atc0005/check-restart.svg?style=flat-square)](https://github.com/atc0005/check-restart/releases/latest)\n[![Go Reference](https://pkg.go.dev/badge/github.com/atc0005/check-restart.svg)](https://pkg.go.dev/github.com/atc0005/check-restart)\n[![go.mod Go version](https://img.shields.io/github/go-mod/go-version/atc0005/check-restart)](https://github.com/atc0005/check-restart)\n[![Lint and Build](https://github.com/atc0005/check-restart/actions/workflows/lint-and-build.yml/badge.svg)](https://github.com/atc0005/check-restart/actions/workflows/lint-and-build.yml)\n[![Project Analysis](https://github.com/atc0005/check-restart/actions/workflows/project-analysis.yml/badge.svg)](https://github.com/atc0005/check-restart/actions/workflows/project-analysis.yml)\n\n\u003c!-- omit in toc --\u003e\n## Table of Contents\n\n- [Project home](#project-home)\n- [Overview](#overview)\n- [Features](#features)\n- [Changelog](#changelog)\n- [Requirements](#requirements)\n  - [Building source code](#building-source-code)\n  - [Running](#running)\n- [Installation](#installation)\n  - [From source](#from-source)\n  - [Using release binaries](#using-release-binaries)\n  - [Deployment](#deployment)\n- [Configuration](#configuration)\n  - [Command-line arguments](#command-line-arguments)\n    - [`check_reboot`](#check_reboot)\n  - [Logging output](#logging-output)\n- [Examples](#examples)\n  - [`OK` result](#ok-result)\n    - [Nothing found](#nothing-found)\n    - [Problematic assertion listed but evaluation result ignored](#problematic-assertion-listed-but-evaluation-result-ignored)\n    - [Disable default ignored assertion path entries](#disable-default-ignored-assertion-path-entries)\n  - [`WARNING` result](#warning-result)\n    - [Without `verbose` flag](#without-verbose-flag)\n    - [Verbose output](#verbose-output)\n  - [`CRITICAL` result](#critical-result)\n- [License](#license)\n- [References](#references)\n\n## Project home\n\nSee [our GitHub repo][repo-url] for the latest code, to file an issue or\nsubmit improvements for review and potential inclusion into the project.\n\n## Overview\n\nThis repo is intended to provide various tools used to detect whether a\nrestart (service) or reboot (system) is needed.\n\n| Tool Name      | Overall Status | Description                                                                 |\n| -------------- | -------------- | --------------------------------------------------------------------------- |\n| `check_reboot` | Alpha          | Nagios plugin used to monitor for \"reboot needed\" status of Windows systems |\n\n## Features\n\n- Nagios plugin (`check_reboot`) for monitoring \"reboot needed\" status of\n  Windows systems\n  - NOTE: The intent is to support multiple operating systems, but as of this\n    writing Windows is the only supported OS\n    - see \u003chttps://github.com/atc0005/check-restart/labels/linux\u003e\n\n- Optionally list ignored assertions\n  - ignored assertions are not shown by default\n\n- Optionally disable list of default ignored paths\n  - by default a small list of ignored paths are used to prevent known\n    problematic assertion matches from affecting service check results\n\n- Optional branding \"signature\"\n  - used to indicate what Nagios plugin (and what version) is responsible for\n    the service check result\n\n- Optional, leveled logging using `rs/zerolog` package\n  - [`logfmt`][logfmt] format output (to `stderr`)\n  - choice of `disabled`, `panic`, `fatal`, `error`, `warn`, `info` (the\n    default), `debug` or `trace`.\n\n## Changelog\n\nSee the [`CHANGELOG.md`](CHANGELOG.md) file for the changes associated with\neach release of this application. Changes that have been merged to `master`,\nbut not yet an official release may also be noted in the file under the\n`Unreleased` section. A helpful link to the Git commit history since the last\nofficial release is also provided for further review.\n\n## Requirements\n\nThe following is a loose guideline. Other combinations of Go and operating\nsystems for building and running tools from this repo may work, but have not\nbeen tested.\n\n### Building source code\n\n- Go\n  - see this project's `go.mod` file for *preferred* version\n  - this project tests against [officially supported Go\n    releases][go-supported-releases]\n    - the most recent stable release (aka, \"stable\")\n    - the prior, but still supported release (aka, \"oldstable\")\n- GCC\n  - if building with custom options (as the provided `Makefile` does)\n- `make`\n  - if using the provided `Makefile`\n\n### Running\n\n- Windows 8.1\n- Windows 10\n\n- Windows Server 2012 R2\n- Windows Server 2016\n- Windows Server 2019\n- Windows Server 2022\n\n## Installation\n\n### From source\n\n1. [Download][go-docs-download] Go\n1. [Install][go-docs-install] Go\n1. Clone the repo\n   1. `cd /tmp`\n   1. `git clone https://github.com/atc0005/check-restart`\n   1. `cd check-restart`\n1. Install dependencies (optional)\n   - for Ubuntu Linux\n     - `sudo apt-get install make gcc`\n   - for CentOS Linux\n     1. `sudo yum install make gcc`\n1. Build\n   - manually, explicitly specifying target OS and architecture\n     - `GOOS=windows GOARCH=amd64 go build -mod=vendor ./cmd/check_reboot/`\n       - most likely this is what you want\n       - substitute `amd64` with the appropriate architecture if using\n         different hardware (e.g., `arm64`)\n   - using Makefile `windows` recipe\n     - `make windows`\n       - generates x86 and x64 binaries\n   - using Makefile `release-build` recipe\n     - `make release-build`\n       - generates the same release assets as provided by this project's\n         releases\n1. Locate generated binaries\n   - if using `Makefile`\n     - look in `/tmp/check-restart/release_assets/check_reboot/`\n   - if using `go build`\n     - look in `/tmp/check-restart/`\n1. Copy the applicable binaries to whatever systems needs to run them so that\n   they can be deployed\n\n**NOTE**: Depending on which `Makefile` recipe you use the generated binary\nmay be compressed and have an `xz` extension. If so, you should decompress the\nbinary first before deploying it (e.g., `xz -d\ncheck_reboot-windows-amd64.exe.xz`).\n\n### Using release binaries\n\n1. Download the [latest release][repo-url] binaries\n1. Decompress binaries\n   - e.g., `xz -d check_reboot-windows-amd64.exe.xz`\n1. Copy the applicable binaries to whatever systems needs to run them so that\n   they can be deployed\n\n### Deployment\n\n1. Place `check_reboot` in a location where it can be executed by the\n   monitoring agent\n   - Usually the same place as other Nagios plugins\n   - For example, on a default Windows system with `NSClient++ x64` installed\n    the `check_reboot.exe` plugin would be deployed to `C:\\Program\n    Files\\NSClient++\\scripts\\custom\\check_reboot.exe`\n1. Update the monitoring agent configuration configuration (on a system that\n   you wish to monitor for \"needs reboot\" condition) to create a new command\n   definition\n   - We will pretend that the DNS name for the system is `windows.example.com`\n\n   - ```ini\n     [/settings/external scripts/scripts]\n     ; NOTE: stderr output is returned mixed in with stdout content. Disable logging to prevent this.\n     ; check_reboot=scripts\\\\custom\\\\check_reboot.exe --verbose --show-ignored --log-level disabled\n     ;\n     ; By default specific paths are ignored. You can optionally disable the default ignored paths.\n     ; check_reboot=scripts\\\\custom\\\\check_reboot.exe --verbose --show-ignored --disable-default-ignored\n     ;\n     check_reboot=scripts\\\\custom\\\\check_reboot.exe --verbose --show-ignored\n     ```\n\n   - see [NSClient++ External scripts doc][nsclient-external-scripts] for\n     additional details\n1. Restart the `nscp` service (label of `NSClient++ (x64)`)\n1. Create a new Nagios \"console\" command definition to allow requesting the\n   monitoring agent to run the plugin\n\n   - ```nagios\n     define command {\n         # $ARG1$ is an optional non-default port\n         command_name    wcheck_reboot\n         command_line    $USER1$/check_nrpe -H $HOSTADDRESS$ -p $ARG1$ -t 30 -c check_reboot\n     }\n     ```\n\n1. Create a new Nagios \"console\" service check that requests the monitoring\n   agent to execute the plugin\n\n   - ```nagios\n     define service {\n         host_name              windows.example.com\n         service_description    check reboot\n         use                    generic-service\n         check_command          wcheck_reboot!12345!!!!!!!\n         notification_period    24x7withMaintenanceWindow\n         contacts               atc0005\n         register               1\n     }\n     ```\n\n## Configuration\n\n### Command-line arguments\n\n- Use the `-h` or `--help` flag to display current usage information.\n- Flags marked as **`required`** must be set via CLI flag.\n- Flags *not* marked as required are for settings where a useful default is\n  already defined, but may be overridden if desired.\n\n#### `check_reboot`\n\n| Flag                            | Required | Default | Repeat | Possible                                                                | Description                                                                                            |\n| ------------------------------- | -------- | ------- | ------ | ----------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------ |\n| `branding`                      | No       | `false` | No     | `branding`                                                              | Toggles emission of branding details with plugin status details. This output is disabled by default.   |\n| `h`, `help`                     | No       | `false` | No     | `h`, `help`                                                             | Show Help text along with the list of supported flags.                                                 |\n| `version`                       | No       | `false` | No     | `version`                                                               | Whether to display application version and then immediately exit application.                          |\n| `v`, `verbose`                  | No       | `false` | No     | `v`, `verbose`                                                          | Toggles emission of detailed output. This level of output is disabled by default.                      |\n| `si`, `show-ignored`            | No       | `false` | No     | `si`, `show-ignored`                                                    | Toggles emission of ignored assertion matches in the final plugin output. This is disabled by default. |\n| `dd`, `disable-default-ignored` | No       | `false` | No     | `dd`, `disable-default-ignored`                                         | Disables use of default ignored assertion path entries.                                                |\n| `ll`, `log-level`               | No       | `info`  | No     | `disabled`, `panic`, `fatal`, `error`, `warn`, `info`, `debug`, `trace` | Log message priority filter. Log messages with a lower level are ignored.                              |\n\n### Logging output\n\nEarly testing using NSClient++ suggests that both `stderr` and `stdout` are\nmixed together and sent back to the Nagios console as one output stream.\n\nIf this becomes a problem you can disable logging output (`--log-level\ndisabled`) to prevent `stderr` from being including in the output sent back to\nthe Nagios console.\n\nIf you know of a way to prevent `stderr` from being mixed into the output sent\nback to Nagios, please file a GitHub issue in this project to share your\nfindings.\n\n## Examples\n\n### `OK` result\n\n#### Nothing found\n\nNo reboot needed.\n\nThis output is emitted by the plugin when a reboot is not needed.\n\n```console\nC:\\Users\\Administrator\u003e\"C:\\Program Files\\NSClient++\\scripts\\custom\\check_reboot.exe\"\nOK: Reboot not needed (assertions: 15 applied, 0 matched, 0 ignored)\n\nReboot not required\n\n | 'errors'=0;;;; 'evaluated_assertions'=15;;;; 'evaluated_file_assertions'=1;;;; 'evaluated_registry_assertions'=14;;;; 'ignored_assertions'=0;;;; 'matched_assertions'=0;;;; 'time'=42ms;;;;\n```\n\nRegarding the output:\n\n- The last line beginning with a space and the `|` symbol are performance\n  data metrics emitted by the plugin. Depending on your monitoring system, these\n  metrics may be collected and exposed as graphs/charts.\n- This output was captured on a Windows 10 system, but is comparable to the\n  output emitted by other Windows desktop \u0026 server systems.\n\n#### Problematic assertion listed but evaluation result ignored\n\n```console\nC:\\Users\\Administrator\u003e\"C:\\Program Files\\NSClient++\\scripts\\custom\\check_reboot.exe\" --verbose --show-ignored\nOK: Reboot not needed (assertions: 15 applied, 0 matched, 1 ignored)\n\nReboot not required\n\nAssertions ignored:\n\n  - Subkeys for key HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/WindowsUpdate/Services/Pending found\n    subkey: 117cab2d-82b1-4b5a-a08c-4d62dbee7782\n\n\n | 'errors'=0;;;; 'evaluated_assertions'=15;;;; 'evaluated_file_assertions'=1;;;; 'evaluated_registry_assertions'=14;;;; 'ignored_assertions'=1;;;; 'matched_assertions'=0;;;; 'time'=1ms;;;;\n```\n\nRegarding the output:\n\n- The last line beginning with a space and the `|` symbol are performance\n  data metrics emitted by the plugin. Depending on your monitoring system, these\n  metrics may be collected and exposed as graphs/charts.\n- The `--verbose` flag is used to display additional details (where available)\n  for an assertion match.\n- The `--show-ignored` flag is used to display assertions whose evaluation\n  results were recorded, but are ignored when determining final plugin state.\n- This output was captured on a Windows Server 2012 system, but is comparable\n  to the output emitted by other Windows desktop \u0026 server systems.\n\n#### Disable default ignored assertion path entries\n\nThis example uses the `--disable-default-ignored` flag to skip using the\ndefault ignored assertion path entries. This can be useful for cases where a\nsysadmin *wants* to apply the assertion match results for all discovered\npaths, even ones historically found to be false-positives or otherwise\nunreliable.\n\n```console\nC:\\Users\\Administrator\u003e\"C:\\Program Files\\NSClient++\\scripts\\custom\\check_reboot.exe\" --verbose --disable-default-ignored\nWARNING: Reboot needed (assertions: 15 applied, 1 matched, 0 ignored)\n\n**ERRORS**\n\n* reboot assertions matched, reboot needed\n\n**DETAILED INFO**\n\nReboot required because:\n\n  - Subkeys for key HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/WindowsUpdate/Services/Pending found\n    subkey: 117cab2d-82b1-4b5a-a08c-4d62dbee7782\n\n\n | 'errors'=0;;;; 'evaluated_assertions'=15;;;; 'evaluated_file_assertions'=1;;;; 'evaluated_registry_assertions'=14;;;; 'ignored_assertions'=0;;;; 'matched_assertions'=1;;;; 'time'=0ms;;;;\n```\n\nRegarding the output:\n\n- The last line beginning with a space and the `|` symbol are performance\n  data metrics emitted by the plugin. Depending on your monitoring system, these\n  metrics may be collected and exposed as graphs/charts.\n- The `--verbose` flag is used to display additional details (where available)\n  for an assertion match.\n- The `--disable-default-ignored` flag indicates that the default ignored path\n  entries will not be used; all discovered paths will be used to determine\n  final plugin state.\n- This output was captured on a Windows Server 2012 system, but is comparable\n  to the output emitted by other Windows desktop \u0026 server systems.\n\n### `WARNING` result\n\nThis output is emitted by the plugin when a reboot is needed.\n\n#### Without `verbose` flag\n\n```console\nC:\\Users\\Administrator\u003e\"C:\\Program Files\\NSClient++\\scripts\\custom\\check_reboot.exe\"\nWARNING: Reboot needed (assertions: 15 applied, 5 matched, 0 ignored)\n\n**ERRORS**\n\n* reboot assertions matched, reboot needed\n\n**DETAILED INFO**\n\nReboot required because:\n\n  - Value PendingFileRenameOperations of type MULTI_SZ for key HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager found\n\n  - Key HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/WindowsUpdate/Auto Update/RebootRequired found\n\n  - Key HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Component Based Servicing/RebootPending found\n\n  - Key HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Component Based Servicing/PackagesPending found\n\n  - File C:/Windows/WinSxS/pending.xml found\n\n\n | 'errors'=0;;;; 'evaluated_assertions'=15;;;; 'evaluated_file_assertions'=1;;;; 'evaluated_registry_assertions'=14;;;; 'ignored_assertions'=0;;;; 'matched_assertions'=5;;;; 'time'=1ms;;;;\n```\n\nRegarding the output:\n\n- The last line beginning with a space and the `|` symbol are performance\n  data metrics emitted by the plugin. Depending on your monitoring system, these\n  metrics may be collected and exposed as graphs/charts.\n- This output was captured on a Windows Server 2022 system, but is comparable\n  to the output emitted by other Windows desktop \u0026 server systems.\n\n#### Verbose output\n\n```console\nC:\\Users\\Administrator\u003e\"C:\\Program Files\\NSClient++\\scripts\\custom\\check_reboot.exe\" --verbose\nWARNING: Reboot needed (assertions: 15 applied, 5 matched, 0 ignored)\n\n**ERRORS**\n\n* reboot assertions matched, reboot needed\n\n**DETAILED INFO**\n\nReboot required because:\n\n  - Value PendingFileRenameOperations of type MULTI_SZ for key HKEY_LOCAL_MACHINE/SYSTEM/CurrentControlSet/Control/Session Manager found\n    Entries [14 total, 12 skipped]: C:/Program Files (x86)/Microsoft/EdgeUpdate/1.3.167.21, C:/Windows/Temp/f7cbd550-567a-4a88-a3e4-c67b414b439d.tmp\n\n  - Key HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/WindowsUpdate/Auto Update/RebootRequired found\n\n  - Key HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Component Based Servicing/RebootPending found\n\n  - Key HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Component Based Servicing/PackagesPending found\n\n  - File C:/Windows/WinSxS/pending.xml found\n\n\n | 'errors'=0;;;; 'evaluated_assertions'=15;;;; 'evaluated_file_assertions'=1;;;; 'evaluated_registry_assertions'=14;;;; 'ignored_assertions'=0;;;; 'matched_assertions'=5;;;; 'time'=0ms;;;;\n```\n\nRegarding the output:\n\n- The last line beginning with a space and the `|` symbol are performance\n  data metrics emitted by the plugin. Depending on your monitoring system, these\n  metrics may be collected and exposed as graphs/charts.\n- The `--verbose` flag is used to display additional details (where available)\n  for an assertion match.\n- This output was captured on a Windows Server 2022 system, but is comparable\n  to the output emitted by other Windows desktop \u0026 server systems.\n\n### `CRITICAL` result\n\nThis result is returned when an error occurs during the attempt to determine\nwhether a reboot is needed.\n\nTODO: Provide example output when this scenario is encountered.\n\n## License\n\nSee the [LICENSE](LICENSE) file for details.\n\n## References\n\n- \u003chttps://adamtheautomator.com/pending-reboot-registry/\u003e\n- \u003chttps://github.com/adbertram/Random-PowerShell-Work/blob/master/Random%20Stuff/Test-PendingReboot.ps1\u003e\n\n\u003c!-- Footnotes here  --\u003e\n\n[repo-url]: \u003chttps://github.com/atc0005/check-restart\u003e  \"This project's GitHub repo\"\n\n[go-docs-download]: \u003chttps://golang.org/dl\u003e  \"Download Go\"\n\n[go-docs-install]: \u003chttps://golang.org/doc/install\u003e  \"Install Go\"\n\n[go-supported-releases]: \u003chttps://go.dev/doc/devel/release#policy\u003e \"Go Release Policy\"\n\n[nsclient-external-scripts]: \u003chttps://docs.nsclient.org/howto/external_scripts/\u003e \"NSClient++ External scripts\"\n\n[logfmt]: \u003chttps://brandur.org/logfmt\u003e\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatc0005%2Fcheck-restart","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fatc0005%2Fcheck-restart","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fatc0005%2Fcheck-restart/lists"}