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

Use "Nagios" check functionality to validate SQLite database before rewriting it #7

Open
atc0005 opened this issue Sep 20, 2020 · 3 comments
Assignees
Labels
enhancement New feature or request sqlite
Milestone

Comments

@atc0005
Copy link
Owner

atc0005 commented Sep 20, 2020

Currently the plan is to drop existing tables before recreating them each time the application is run. At some point the hope is to synchronize database changes instead of brute force destroying/recreating the data each time.

An intermediate step is to validate the SQLite database tables and skip recreating them if they already contain 1:1 the data found in the source MySQL database. Since this functionality is being written for the Nagios plugin, it could be refactored and made available to the base binary to execute before attempting to recreate the SQLite database tables.

@atc0005 atc0005 added enhancement New feature or request sqlite labels Sep 20, 2020
@atc0005 atc0005 added this to the Future milestone Sep 20, 2020
@atc0005 atc0005 self-assigned this Sep 20, 2020
@atc0005
Copy link
Owner Author

atc0005 commented Sep 26, 2020

An intermediate step is to validate the SQLite database tables and skip recreating them if they already contain 1:1 the data found in the source MySQL database

I ended up writing a shell script that checks the exit code of the Nagios plugin, then only regenerates the SQLite database if a WARNING result was returned from the Nagios plugin. Otherwise, it logs a "no need" style message and exits successfully.

I'm not sure yet if this functionality is needed in the base application, or if keeping it in the wrapper script is a valid choice.

@atc0005
Copy link
Owner Author

atc0005 commented Sep 26, 2020

I expect after some time and much needed refactoring work this choice will become clearer.

@atc0005
Copy link
Owner Author

atc0005 commented Jan 21, 2021

I ended up writing a shell script that checks the exit code of the Nagios plugin, then only regenerates the SQLite database if a WARNING result was returned from the Nagios plugin. Otherwise, it logs a "no need" style message and exits successfully.

When deploying the binaries from this project on a new system, I was "surprised" (quickly; how we forget) that the wrapper script used to generate the SQLite database requires either an OK or WARNING state as a response from the Nagios plugin. If a CRITICAL state is returned (e.g., the database file is missing or empty) the mysql2sqlite binary is never called. On a fresh system, this leads to a sort of dependency loop.

The workaround is to run the mysql2sqlite binary once manually to bootstrap the process. This "bootstrapping" needs to be documented.

atc0005 added a commit that referenced this issue Jan 21, 2021
- Add Wrap-up section to README
- Extend deployment doc
  - add steps for deploying Postfix support packages,
    config fragments
- Add wrap-up doc file listing manual first-run requirement

refs GH-7
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request sqlite
Projects
None yet
Development

No branches or pull requests

1 participant