diff --git a/LICENSE b/LICENSE index a782f2c..8fbe809 100644 --- a/LICENSE +++ b/LICENSE @@ -1,7 +1,7 @@ License for Chkok ================= -Copyright 2022 Farzad Ghanei +Copyright 2024 Farzad Ghanei Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, diff --git a/Makefile b/Makefile index fa2842d..7b81329 100644 --- a/Makefile +++ b/Makefile @@ -36,6 +36,8 @@ DESTDIR ?= prefix ?= /usr/local exec_prefix ?= $(prefix) bindir ?= $(exec_prefix)/bin +sharedir ?= $(exec_prefix)/share +mandir ?= $(sharedir)/man/man1 # use Make's builtin variable to call 'install' INSTALL ?= install @@ -84,14 +86,18 @@ build: chkok test: go test -v -race ./... + ./scripts/staticchecks install: build $(INSTALL_PROGRAM) -d $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) chkok $(DESTDIR)$(bindir) + mkdir -p $(DESTDIR)$(mandir) + cp docs/man/chkok.1 $(DESTDIR)$(mandir) uninstall: - rm $(DESTDIR)$(bindir)/chkok + rm -f $(DESTDIR)$(bindir)/chkok + rm -f $(DESTDIR)$(mandir)/chkok.1 clean: rm -f chkok @@ -131,8 +137,9 @@ pkg-tgz: build # override prefix so .rpm package installs binaries to /usr/bin instead of /usr/local/bin pkg-rpm: export prefix = /usr -# requires golang compiler > 1.22, and rpmdevtools package +# requires golang compiler > 1.22, and rpm-build/rpmdevtools package pkg-rpm: + mkdir -p $(RPM_DEV_TREE)/RPMS $(RPM_DEV_TREE)/SRPMS $(RPM_DEV_TREE)/SOURCES $(RPM_DEV_TREE)/SPECS rm -f $(RPM_DEV_SRC_TGZ) tar --exclude-vcs -zcf $(RPM_DEV_SRC_TGZ) . cp build/package/chkok.spec $(RPM_DEV_SPEC) @@ -151,11 +158,11 @@ pkg-checksum: if test -e $(PKG_DIST_DIR); then cd $(PKG_DIST_DIR) \ && (sed -i '/chkok_$(CHKOK_DEB_VERSION).*deb/d' $(PKG_CHECKSUM_NAME) || true) \ && find . -maxdepth 1 -readable -type f -name 'chkok_$(CHKOK_DEB_VERSION)*.deb' \ - -exec sha256sum '{}' \; >> $(PKG_CHECKSUM_NAME); fi + -exec sha256sum '{}' \; | sed 's|./||g' >> $(PKG_CHECKSUM_NAME); fi if test -e $(PKG_DIST_DIR); then cd $(PKG_DIST_DIR) \ && (sed -i '/chkok-$(CHKOK_RPM_VERSION).*rpm/d' $(PKG_CHECKSUM_NAME) || true) \ && find . -maxdepth 1 -readable -type f -name 'chkok-$(CHKOK_RPM_VERSION)*.rpm' \ - -exec sha256sum '{}' \; >> $(PKG_CHECKSUM_NAME); fi + -exec sha256sum '{}' \; | sed 's|./||g' >> $(PKG_CHECKSUM_NAME); fi # sync version from source code to other files (docs, packaging, etc.) sync-version: diff --git a/README.rst b/README.rst index 76718a9..40e447c 100644 --- a/README.rst +++ b/README.rst @@ -7,6 +7,28 @@ system state is as expected. It can be used to monitor system health and resourc Provides different running modes, useful for reporting to local and remote monitoring. It's written in Go, has a small resource overhead with no runtime dependencies. +Main target platforms are modern GNU/Linux systems, but other operating systems may work as well. + + +Installation +------------ + +Download the latest release from the `releases` page. +Released artifacts can be verified with the checksum file containing sha256 hashes. + +.. code-block:: shell + + sha256sum -c chkok-*SHA256SUMS + + +Or build and install from source (requires Go 1.22+): + +.. code-block:: shell + + sudo make install + # or to install in a custom location (e.g. for packaging) + env DESTDIR=/tmp make install + Usage ----- @@ -27,6 +49,11 @@ Run in HTTP mode, starting an HTTP server on the configured port: chkok -conf examples/config.yaml -verbose -mode http +The HTTP mode is useful for checking the results remotely, for example, from a monitoring system. +Currently there is no encryption supported, so it's recommended to use only in trusted networks, +or behind a local SSL terminating service. + + Configuration ------------- @@ -90,9 +117,29 @@ to be checked. See the `examples` directory for sample configuration files. +Development +----------- + +Make sure you have Go 1.22+ installed. +Most of the development and build tasks are automated with the `Makefile`. + +To build the binary from source, run: + +.. code-block:: shell + + make clean build + + +To run the tests and static checks, run: + +.. code-block:: shell + + make test + + License ------- "chkok" is an open source project released under the terms of the `MIT license `_. It uses yaml.v3 library which is licensed under the MIT and Apache License 2.0 licenses. -See LICENSE file for more details. \ No newline at end of file +See LICENSE file for more details. diff --git a/build/package/chkok.spec b/build/package/chkok.spec index fd8c981..f151609 100644 --- a/build/package/chkok.spec +++ b/build/package/chkok.spec @@ -31,8 +31,6 @@ Provides different running modes, useful for reporting to local and remote monit %install rm -rf $RPM_BUILD_ROOT %make_install -mkdir -p $RPM_BUILD_ROOT/usr/share/man/man1 -cp -a docs/man/chkok.1 $RPM_BUILD_ROOT/usr/share/man/man1/%{name}.1 cp -a examples/config.yaml example-config.yaml