├── .github ├── make-release.sh └── workflows │ ├── docs.yml │ └── obs.yml ├── .gitignore ├── .mailmap ├── AUTHORS ├── CHANGELOG.md ├── CONTRIBUTING.md ├── COPYING ├── HOWTO ├── Makefile.am ├── NEWS ├── README ├── README.md ├── SPECS ├── TECHNICAL ├── apps ├── .gitignore ├── cluster_tools │ └── cluster_tools.py.in ├── libexec │ ├── .gitignore │ ├── ascii.py │ ├── bash │ │ ├── inc.sh │ │ └── syscheck.proc.sh │ ├── check.py.in │ ├── containerhealth.py.in │ ├── db.py.in │ ├── ecmd.py │ ├── helpfiles │ │ ├── log.push.txt │ │ ├── node.tree.txt │ │ ├── query.ls.txt │ │ ├── query.lsq.txt │ │ ├── sshkey.fetch.txt │ │ ├── sshkey.push.txt │ │ ├── sysconf.check.txt │ │ └── sysconf.ramdisk.txt │ ├── id.py │ ├── log.py.in │ ├── merlinkey.py.in │ ├── modules │ │ ├── compound_config.py │ │ ├── coredump.py │ │ ├── merlin_apps_utils.py │ │ ├── merlin_conf.py.in │ │ ├── merlin_db.py │ │ ├── merlin_qh.py │ │ ├── merlin_status.py │ │ ├── merlin_test_utils.py │ │ ├── nagios_command.py │ │ ├── nagios_plugin.py │ │ ├── nagios_qh.py │ │ ├── pytap │ │ │ ├── pytap.py │ │ │ └── ttest.py │ │ ├── qhcheck.py │ │ └── test │ │ │ └── test_nagios_qh.py │ ├── node.py │ ├── node.tree.php │ ├── oconf.py.in │ ├── qh.py │ ├── query.ls.sh.in │ ├── query.lsq.sh.in │ ├── reportdata.py.in │ ├── restart.sh.in │ ├── slim-poller.py.in │ ├── sshkey.fetch.sh.in │ ├── sshkey.push.sh.in │ ├── start.sh │ ├── status.py │ ├── stop.sh │ ├── syscheck │ │ ├── .gitignore │ │ ├── db_mysql_check.sh │ │ ├── fs_ext_state.sh │ │ ├── fs_free_inodes.sh │ │ ├── fs_free_space.sh │ │ ├── fs_mount_opts.sh │ │ ├── license.sh │ │ ├── proc_collector.sh │ │ ├── proc_crond.sh │ │ ├── proc_httpd.sh │ │ ├── proc_merlind.sh.in │ │ ├── proc_monitor_core.sh │ │ ├── proc_monitor_worker.sh │ │ ├── proc_mysqld.sh │ │ ├── proc_npcd.sh │ │ ├── proc_ntpd.sh │ │ ├── proc_op5config.sh │ │ ├── proc_op5kad.sh │ │ ├── proc_pgsql_postmaster.sh │ │ ├── proc_processor.sh │ │ ├── proc_rrdcached.sh │ │ ├── proc_smsd.sh │ │ ├── proc_synergy.sh │ │ └── proc_syslog_ng.sh │ ├── sysconf.check.sh │ ├── sysconf.ramdisk.sh │ ├── test.py │ └── tests │ │ └── test_merlin_qh.py ├── mon.py.in └── tests │ └── oconf-poller-fix │ ├── fixed-config.cfg │ ├── merlin.conf │ ├── test-config.cfg │ └── test.sh ├── autogen.sh ├── compat ├── asprintf.c └── memrchr.c ├── configure.ac ├── daemon ├── daemon.c ├── daemonize.c ├── daemonize.h ├── db_updater.c ├── db_updater.h ├── db_wrap.c ├── db_wrap.h ├── db_wrap_dbi.c ├── db_wrap_dbi.h ├── merlind.c ├── sql.c ├── sql.h ├── state.c ├── state.h ├── string_utils.c └── string_utils.h ├── data ├── .gitignore ├── kad.conf.in ├── merlin.cfg.in ├── merlin.conf.in ├── merlin.in └── merlind.in ├── docs ├── .gitignore ├── Makefile ├── _templates │ └── layout.html ├── changelog.md ├── clustering.rst ├── conf.py ├── configuration.rst ├── container-poller.md ├── encryption.rst ├── index.rst ├── install.rst └── merlin.conf.sample ├── features ├── active_checks.feature ├── binlog.feature ├── check_result_output.feature ├── check_results_propagation.feature ├── cluster_update.feature ├── config_split_poller.feature ├── config_sync_passive_poller.feature ├── config_sync_peer.feature ├── config_sync_poller.feature ├── connection.feature ├── csync_unsynced_masters.feature ├── data │ ├── README │ ├── module.my-peer.binlog.meta │ └── module.my-peer.binlog.save ├── event_handler_execution.feature ├── execute_host_checks.feature ├── hostgroup_split.feature ├── ipc_nodeinfo_version.feature ├── livestatus.feature ├── notification_contact_propagation.feature ├── notification_host_execution.feature ├── notification_persistence.feature ├── notification_propagation.feature ├── notification_service_execution.feature ├── passive_check_results.feature ├── peer_nodeinfo_version.feature ├── report_data_host_active.feature ├── report_data_service_active.feature ├── retention_data_oconf_hash.feature ├── runcmd.feature ├── scheduled_downtime.feature ├── startup.feature ├── step_definitions │ ├── cukemerlin.wire │ ├── database.rb │ ├── delay.rb │ ├── livestatus.rb │ ├── merlin.rb │ ├── merlin_node_config.rb │ ├── naemon.rb │ ├── naemon_object_config.rb │ ├── naemon_system_config.rb │ ├── network_setup.rb │ ├── repeat.rb │ ├── service_startup.rb │ └── systemd_merlind.rb └── support │ ├── database_config.rb │ ├── env.rb │ ├── merlin_node_config.rb │ ├── merlin_packet_defaults.rb │ ├── naemon_object_config.rb │ └── naemon_system_config.rb ├── generate_version_number.sh ├── install-merlin.sh.in ├── logs ├── beta.log ├── no-lf-terminator.log ├── nuls.log └── single-read.log ├── m4 └── acinclude.m4 ├── merlin_logo.svg ├── merlind.service.in ├── module ├── hooks.c ├── hooks.h ├── misc.c ├── misc.h ├── module.c ├── module.h ├── net.c ├── net.h ├── oconfsplit.c ├── oconfsplit.h ├── queries.c ├── queries.h ├── runcmd.c ├── runcmd.h ├── script-helpers.c ├── script-helpers.h ├── sha1.c ├── sha1.h ├── testif_qh.c └── testif_qh.h ├── nrpe-merlin.cfg ├── obs └── rpm │ └── merlin.spec ├── op5build ├── ci_config.yml ├── merlin.spec └── nacoma_hook.py ├── shared ├── binlog.c ├── binlog.h ├── cfgfile.c ├── cfgfile.h ├── codec.c ├── codec.h ├── compat.h ├── configuration.c ├── configuration.h ├── dlist.c ├── dlist.h ├── encryption.c ├── encryption.h ├── io.c ├── io.h ├── ipc.c ├── ipc.h ├── logging.c ├── logging.h ├── node.c ├── node.h ├── pgroup.c ├── pgroup.h ├── shared.c └── shared.h ├── sort-merge_logs.sh ├── sql ├── mysql │ ├── drop_indexes.sql │ ├── merlin.sql │ ├── notification-indexes.sql │ └── perfdata-indexes.sql ├── update-db-1to2.sql └── update-db-2to3.sql ├── sudo └── merlin.in ├── test_protocol ├── dotest.py ├── merlinnet.py └── merlinpkt.py ├── tests ├── bltest.c ├── codectest.c ├── cukemerlin │ ├── base │ │ ├── cukemerlin.c │ │ ├── cukesocket.c │ │ ├── cukesocket.h │ │ ├── json.c │ │ ├── json.h │ │ ├── jsonsocket.c │ │ ├── jsonsocket.h │ │ ├── jsonx.c │ │ └── jsonx.h │ └── steps │ │ ├── steps.c │ │ ├── steps.h │ │ ├── steps_config.c │ │ ├── steps_config.h │ │ ├── steps_daemons.c │ │ ├── steps_daemons.h │ │ ├── steps_livestatus.c │ │ ├── steps_livestatus.h │ │ ├── steps_merlin.c │ │ ├── steps_merlin.h │ │ ├── steps_queryhandler.c │ │ ├── steps_queryhandler.h │ │ ├── steps_test.c │ │ └── steps_test.h ├── importlog_naemon.log ├── merlincat │ ├── client_gsource.c │ ├── client_gsource.h │ ├── conn_info.c │ ├── conn_info.h │ ├── console.c │ ├── console.h │ ├── event_packer.c │ ├── event_packer.h │ ├── generate-nebev2kvvec.py │ ├── merlincat.c │ ├── merlincat_codec.c │ ├── merlincat_codec.h │ ├── merlincat_encryption.c │ ├── merlincat_encryption.h │ ├── merlinreader.c │ ├── merlinreader.h │ ├── server_gsource.c │ └── server_gsource.h ├── pyunit │ ├── test_log.py │ └── test_oconf.py ├── showlog_test.log ├── showlog_test_monitor_and_not_monitor1_svc.log ├── showlog_test_monitoronly.log ├── showlog_test_not_monitor1_svc_only.log ├── singlenode.conf ├── sltest.c ├── test-csync.c ├── test-dbwrap.c ├── test-hooks.c ├── test-importlog.c ├── test-lparse.c ├── test-showlog.c ├── test-stringutils.c └── twopeers.conf └── tools ├── auth.c ├── auth.h ├── colors.h ├── import.c ├── keygen.c ├── logutils.c ├── logutils.h ├── lparse.c ├── lparse.h ├── oconf.c ├── rename.c ├── showlog.c ├── slist.c ├── slist.h ├── test_utils.c └── test_utils.h /.github/make-release.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Check for OBS_TOKEN 4 | if [ -z "${OBS_PROJECT}" ] ; then 5 | echo "Enviorment variable OBS_PROJECT must be set" 6 | exit 1 7 | fi 8 | if [ -z "${OBS_PACKAGE}" ] ; then 9 | echo "Enviorment variable OBS_PACKAGE must be set" 10 | exit 1 11 | fi 12 | if [ -z "${MERLIN_VERSION}" ] ; then 13 | echo "Enviorment variable MERLIN_VERSION must be set" 14 | exit 1 15 | fi 16 | 17 | # TODO: automate getting platforms from OBS 18 | PLATFORMS=(CentOS_8_Stream CentOS_7) 19 | EXPECTED_PACKAGES=${#PLATFORMS[@]} 20 | 21 | # Trigger the OBS build 22 | osc api -X POST "/source/$OBS_PROJECT/$OBS_PACKAGE?cmd=runservice" 23 | 24 | echo "Waiting for builds to finish" 25 | 26 | # list of possible OBS errors 27 | errors=(broken unresolvable failed) 28 | 29 | # loop until we built all packages or we get an error or max timeout (2hours) 30 | end=$((SECONDS+7200)) 31 | failed=true 32 | while [ $SECONDS -lt $end ] 33 | do 34 | sleep 60 35 | obs_status=$(osc r $OBS_PROJECT $OBS_PACKAGE) 36 | published_count=$(echo $obs_status | grep -o "succeeded" | wc -l) 37 | if [ $published_count -ge $EXPECTED_PACKAGES ] 38 | then 39 | failed=false 40 | break 41 | fi 42 | # check for possible errors 43 | for error in ${errors[*]} 44 | do 45 | error_count=$(echo $obs_status | grep -o "$error" | wc -l) 46 | if [ $error_count -ge 1 ] 47 | then 48 | echo "OBS build failed" 49 | echo $obs_status 50 | exit 1; 51 | fi 52 | done 53 | done 54 | 55 | # check if everything worked OK 56 | if $failed; then 57 | echo "Timeout" 58 | exit 1 59 | fi 60 | 61 | # get rpms for each release, tar them and cleanup 62 | mkdir -p release_archives 63 | for platform in ${PLATFORMS[*]} 64 | do 65 | echo $platform 66 | osc getbinaries $OBS_PROJECT $OBS_PACKAGE $platform x86_64 -d ./$platform 67 | # get rid of metadata files 68 | rm -f ./$platform/_* 69 | # Get slim packages and delete them 70 | tar cfJ release_archives/merlin-slim-$MERLIN_VERSION-$platform.tar.xz ./$platform/*slim* 71 | rm ./$platform/*slim* 72 | # get the normal packages 73 | tar cfJ release_archives/merlin-$MERLIN_VERSION-$platform.tar.xz ./$platform/* 74 | # clean up 75 | rm -rf ./$platform/ 76 | done 77 | -------------------------------------------------------------------------------- /.github/workflows/docs.yml: -------------------------------------------------------------------------------- 1 | name: Github Pages 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | 7 | 8 | jobs: 9 | deploy: 10 | runs-on: ubuntu-20.04 11 | concurrency: 12 | group: ${{ github.workflow }}-${{ github.ref }} 13 | steps: 14 | - uses: actions/checkout@v2 15 | - name: Install doc dependencies 16 | run: | 17 | sudo apt-get -y update 18 | sudo apt-get -y install python3-sphinx python3-sphinx-rtd-theme python3-pip 19 | sudo pip install myst-parser 20 | - name: Make docs 21 | run: cd docs && make html 22 | - name: test 23 | run: ls -la && ls -la ./docs 24 | - name: Deploy 25 | uses: peaceiris/actions-gh-pages@v3 26 | with: 27 | github_token: ${{ secrets.GITHUB_TOKEN }} 28 | publish_dir: ./docs/_build/html 29 | user_name: 'github-actions[bot]' 30 | user_email: 'github-actions[bot]@users.noreply.github.com' 31 | -------------------------------------------------------------------------------- /.github/workflows/obs.yml: -------------------------------------------------------------------------------- 1 | name: Build and Release 2 | 3 | on: 4 | workflow_dispatch: 5 | 6 | jobs: 7 | build_obs: 8 | runs-on: ubuntu-latest 9 | steps: 10 | - uses: actions/checkout@v2 11 | - name: install OBS tools 12 | env: 13 | OBS_USERNAME: ${{ secrets.OBS_USERNAME }} 14 | OBS_PASSWORD: ${{ secrets.OBS_PASSWORD }} 15 | run: | 16 | curl -s "https://build.opensuse.org/projects/openSUSE:Tools/public_key" | sudo apt-key add - 17 | sudo sh -c 'echo "deb http://download.opensuse.org/repositories/openSUSE:/Tools/xUbuntu_$(lsb_release -rs)/ ./" >> /etc/apt/sources.list.d/openSUSE-tools.list' 18 | sudo apt-get -y update 19 | sudo apt-get -y install osc 20 | mkdir -p ~/.config/osc 21 | cat > ~/.config/osc/oscrc << EOL 22 | [general] 23 | apiurl = https://api.opensuse.org 24 | [https://api.opensuse.org] 25 | user=$OBS_USERNAME 26 | pass=$OBS_PASSWORD 27 | credentials_mgr_class=osc.credentials.PlaintextConfigFileCredentialsManager 28 | EOL 29 | - name: Get tag 30 | id: tag 31 | uses: dawidd6/action-get-tag@v1 32 | - name: Build and fetch binaries on OBS 33 | env: 34 | OBS_PROJECT: ${{ secrets.OBS_PROJECT }} 35 | OBS_PACKAGE: ${{ secrets.OBS_PACKAGE }} 36 | MERLIN_VERSION: ${{ steps.tag.outputs.tag }} 37 | run: .github/make-release.sh 38 | - uses: actions/upload-artifact@v2 39 | with: 40 | name: obs-binaries 41 | path: release_archives/*.tar.xz 42 | make_release: 43 | runs-on: ubuntu-latest 44 | needs: 45 | - build_obs 46 | steps: 47 | - name: Checkout 48 | uses: actions/checkout@v2 49 | - uses: actions/download-artifact@v2 50 | with: 51 | name: obs-binaries 52 | - name: Extract release notes 53 | id: extract-release-notes 54 | uses: ffurrer2/extract-release-notes@v1 55 | - name: Release 56 | uses: softprops/action-gh-release@v1 57 | with: 58 | body: ${{ steps.extract-release-notes.outputs.release_notes }} 59 | - name: Upload release binaries 60 | uses: alexellis/upload-assets@0.2.2 61 | env: 62 | GITHUB_TOKEN: ${{ github.token }} 63 | with: 64 | asset_paths: '["./*.tar.xz"]' 65 | 66 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.o 2 | *.so 3 | *.lo 4 | *.la 5 | .deps 6 | .libs 7 | .dirstamp 8 | core.[0-9]* 9 | core 10 | mod.log 11 | junk 12 | monitor 13 | test 14 | blread 15 | endpoint 16 | *.log 17 | *.bin 18 | merlind 19 | *test 20 | version.c 21 | mtest 22 | check_latency 23 | start.sh 24 | postgres.sh 25 | funused.sh 26 | test-hash 27 | test-csync 28 | bltest 29 | sltest 30 | test-lparse 31 | import 32 | showlog 33 | keygen 34 | *.pyc 35 | oconf 36 | test-dbwrap 37 | ocimp 38 | entries.sh 39 | ca-debug.py 40 | data/merlin.conf 41 | .lock* 42 | rename 43 | install-merlin.sh 44 | apps/op5 45 | *.swp 46 | *~ 47 | TAGS 48 | INSTALL 49 | Makefile.in 50 | Makefile 51 | /autom4te.cache 52 | /aclocal.m4 53 | /compile 54 | /configure 55 | /depcomp 56 | /install-sh 57 | /missing 58 | /stamp-h1 59 | libtool 60 | ltmain.sh 61 | py-compile 62 | test-driver 63 | config.guess 64 | config.h 65 | config.h.in 66 | config.status 67 | config.sub 68 | merlincat$ 69 | /tests/merlincat/nebev-col2key.gperf 70 | /tests/merlincat/nebev-col2key.[ch] 71 | /tests/merlincat/nebev2kvvec.[ch] 72 | /tests/merlincat/kvvec2nebev.[ch] 73 | /*.trs 74 | 75 | /cukemerlin 76 | /merlincat 77 | /apps/libexec/restart.sh 78 | apps/tests/oconf-poller-fix/fixme.cfg 79 | apps/tests/oconf-poller-fix/fixed-config.cfg-first 80 | m4/*.m4 81 | sudo/merlin 82 | .DS_Store 83 | .pydevproject 84 | merlind.service 85 | apps/cluster_tools/cluster_tools.py 86 | apps/cluster_tools/merlin_cluster_tools 87 | !docs/Makefile 88 | docs/_build/ 89 | -------------------------------------------------------------------------------- /.mailmap: -------------------------------------------------------------------------------- 1 | Per Åsberg 2 | Oleksandr Lepetyukh 3 | Mattias Ryrlén 4 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | This file is populated automatically by make dist. 2 | 3 | To view authors sorted by contributions, use 'git shortlog -ns' 4 | -------------------------------------------------------------------------------- /NEWS: -------------------------------------------------------------------------------- 1 | See https://support.itrsgroup.com/hc/en-us/articles/360020292133-Distributed-Merlin-Introduction for places 2 | to find out more about merlin news. 3 | -------------------------------------------------------------------------------- /README: -------------------------------------------------------------------------------- 1 | README.md -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ![merlin logo](merlin_logo.svg) 2 | 3 | # Welcome to Merlin # 4 | [![GitHub release (latest by date)](https://img.shields.io/github/v/release/itrs-group/monitor-merlin?display_name=release)](https://github.com/ITRS-Group/monitor-merlin/releases) 5 | [![GitHub](https://img.shields.io/github/license/itrs-group/monitor-merlin)](https://github.com/ITRS-Group/monitor-merlin/blob/master/COPYING) 6 | 7 | The Merlin project, or Module for Effortless Redundancy and Loadbalancing In 8 | [Naemon](https://naemon.org), is a Naemon module built to create an easy way to 9 | set up distributed Naemon installations, allowing Naemon processes to exchange 10 | information. This allows Naemon to scale past a single installation to handle 11 | a bigger monitoring workload. 12 | 13 | Merlin can also save state changes to a database, which can be 14 | used for reporting purposes. 15 | 16 | ## Documentation ## 17 | 18 | Full documentation including installation and usage guides can be found 19 | at [Github Pages](https://itrs-group.github.io/monitor-merlin/). 20 | 21 | ## Contributing to Merlin 22 | 23 | Contributions are always welcome. Please see [CONTRIBUTING.md](CONTRIBUTING.md) 24 | for the full details. 25 | -------------------------------------------------------------------------------- /apps/.gitignore: -------------------------------------------------------------------------------- 1 | mon.py 2 | -------------------------------------------------------------------------------- /apps/libexec/.gitignore: -------------------------------------------------------------------------------- 1 | oconf.py 2 | oconf.fetch.sh 3 | merlinkey.py 4 | check.py 5 | query.ls.sh 6 | query.lsq.sh 7 | reportdata.py 8 | slim-poller.py 9 | db.py 10 | log.py 11 | sshkey.push.sh 12 | sshkey.fetch.sh 13 | containerhealth.py 14 | modules/merlin_conf.py 15 | -------------------------------------------------------------------------------- /apps/libexec/bash/inc.sh: -------------------------------------------------------------------------------- 1 | # SNTX: msgdie 2 | # DESC: Prints specified text and exits with given exit code. 3 | msgdie() 4 | { 5 | printf '%s\n' "$2" 6 | exit $1 7 | } 8 | 9 | # SNTX: dieplug 10 | # DESC: Prints the final status text and prepends the exit state prefix 11 | # depending on which exit code it was called with. 12 | dieplug() 13 | { 14 | local code text prefix 15 | code="$1" 16 | 17 | case "$code" in 18 | '0') 19 | text='OK' 20 | ;; 21 | '1') 22 | text='WARNING' 23 | ;; 24 | '2') 25 | text='CRITICAL' 26 | ;; 27 | '3') 28 | text='UNKNOWN' 29 | ;; 30 | *) 31 | text="INVALID exit code ($code)" 32 | code='3' 33 | ;; 34 | esac 35 | 36 | # append any additional text if specified 37 | [ -n "$2" ] && text+=": $2" 38 | 39 | # print text to stdout 40 | msgdie "$code" "$text" 41 | } 42 | 43 | # SNTX: depchk [depN].. 44 | # DESC: Exits in case any given dependencies are missing. 45 | depchk() 46 | { 47 | local arg miss 48 | 49 | miss='' 50 | for arg; do 51 | hash -- "$arg" &> /dev/null || miss+=" $arg" 52 | done 53 | 54 | [ -n "$miss" ] || return 0 55 | 56 | msgdie '3' "Missing dependencies:$miss" 57 | } 58 | 59 | 60 | # SNTX: cmd_exec [arg1] [argN].. 61 | # DESC: Executes given command line, which if it fails, exits with debug output. 62 | cmd_exec() 63 | { 64 | OUT="$("$@" 2>&1)" 65 | RET="$?" 66 | 67 | [ "$RET" == '0' ] || \ 68 | msgdie '3' "$(cmd_debug_output "$@")" 69 | 70 | return 0 71 | } 72 | 73 | # SNTX: [OUT=] [RET=<$?>] cmd_debug_output [arg1] [argN].. 74 | # DESC: Verbosely describes the given command line and possible results. 75 | cmd_debug_output() 76 | { 77 | local args 78 | args="$(for arg; do printf '(%s)\n' "$arg"; done)" 79 | 80 | printf 'Executed command failed unexpectedly.\n' 81 | cmd_debug_section 'CMD LINE' "$*" 82 | cmd_debug_section 'ARGUMENTS' "$args" 83 | [ -n "$RET" ] && cmd_debug_section 'RETURN CODE' "$RET" 84 | [ -n "$OUT" ] && cmd_debug_section 'OUTPUT' "$OUT" 85 | } 86 | 87 | # SNTX: cmd_debug_section 88 | # DESC: Encapsulates given text with tagged header and footer. 89 | cmd_debug_section() 90 | { 91 | printf '\n' 92 | printf '==%s:START==\n' "$1" 93 | printf '%s\n' "$2" 94 | printf '==%s:END==\n' "$1" 95 | } 96 | 97 | 98 | # SNTX: is_rhel 99 | # DESC: Basic check if this is a RHEL system. 100 | is_rhel() 101 | { 102 | test -f /etc/rc.d/init.d/functions 103 | return $? 104 | } 105 | 106 | # SNTX: is_sles 107 | # DESC: Basic check if this is a SLES system. 108 | is_sles() 109 | { 110 | test -f /etc/rc.status 111 | return $? 112 | } 113 | -------------------------------------------------------------------------------- /apps/libexec/db.py.in: -------------------------------------------------------------------------------- 1 | import os.path, glob, sys 2 | try: 3 | from hashlib import sha1 4 | except ImportError: 5 | from sha import sha as sha1 6 | 7 | import merlin_db 8 | 9 | log_file = '/tmp/merlin-sql-upgrade.log' 10 | 11 | def cmd_fixindexes(args): 12 | """ 13 | Fixes indexes on merlin tables containing historical data. 14 | """ 15 | print('Adding indexes...') 16 | print('(if this takes forever, aborting this and running') 17 | print('\tmon log import --truncate-db') 18 | print('might be quicker, but could permanently remove some old logs)') 19 | conn = merlin_db.connect(mconf) 20 | cursor = conn.cursor() 21 | log = [] 22 | for table in glob.glob('@datarootdir@/merlin/sql/mysql/*-indexes.sql'): 23 | queries = open(table) 24 | try: 25 | cursor.execute(queries.read()) 26 | except Exception as ex: 27 | log.append(f'%s: %s' % (os.path.basename(table), ex)) 28 | queries.close() 29 | conn.commit() 30 | conn.close() 31 | if not log: 32 | print('Indexes installed successfully') 33 | else: 34 | print('\nThere were problems. This is normal if the indexes already', end=' ') 35 | print('(partially) exist,\nbut could also indicate a problem.') 36 | print('\nMessages:') 37 | for msg in log: 38 | print(' %s' % msg) 39 | 40 | def module_init(args): 41 | return args 42 | -------------------------------------------------------------------------------- /apps/libexec/helpfiles/log.push.txt: -------------------------------------------------------------------------------- 1 | [--push-all|--since