From 20646001d045893673fa4db1fe58f529ddfeabf4 Mon Sep 17 00:00:00 2001 From: Michael Grote Date: Sun, 16 Apr 2023 12:08:53 +0200 Subject: [PATCH] "first" commit --- .drone.yml | 21 +++++++++++++- Dockerfile | 3 -- README.md | 74 ------------------------------------------------ munin_slack.conf | 2 -- run.sh | 17 ----------- slack_munin.sh | 58 ------------------------------------- 6 files changed, 20 insertions(+), 155 deletions(-) delete mode 100644 README.md delete mode 100644 munin_slack.conf delete mode 100644 slack_munin.sh diff --git a/.drone.yml b/.drone.yml index 07b0600..e5bc035 100644 --- a/.drone.yml +++ b/.drone.yml @@ -14,7 +14,8 @@ steps: - hadolint --version - hadolint Dockerfile - - name: docker_build_and_push + # Bauen, taggen und pushen + - name: docker_build_and_push_master image: plugins/docker settings: username: @@ -26,9 +27,27 @@ steps: tags: - latest - ${DRONE_COMMIT_SHA:0:8} + - ${DRONE_COMMIT_BRANCH} when: branch: - master event: exclude: - pull_request + + - name: docker_build_and_push + image: plugins/docker + settings: + username: + from_secret: DOCKERHUB_USER + password: + from_secret: DOCKERHUB_PASS + dockerfile: Dockerfile + repo: quotengrote/munin-server + tags: + - ${DRONE_COMMIT_SHA:0:8} + - ${DRONE_COMMIT_BRANCH} + when: + event: + exclude: + - pull_request diff --git a/Dockerfile b/Dockerfile index 4c310c8..515f7e4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -35,9 +35,6 @@ COPY munin.conf /etc/munin/munin.conf COPY ssmtp.conf /etc/ssmtp/ssmtp.conf COPY revaliases /etc/ssmtp/revaliases COPY munin_mail.conf /etc/munin/munin-conf.d/munin_mail.conf -COPY slack_munin.sh /usr/local/bin/notify_slack_munin -RUN chmod +x /usr/local/bin/notify_slack_munin -COPY munin_slack.conf /etc/munin/munin-conf.d/munin_slack.conf # copy launcher COPY run.sh /usr/local/bin/run diff --git a/README.md b/README.md deleted file mode 100644 index 48a9575..0000000 --- a/README.md +++ /dev/null @@ -1,74 +0,0 @@ -# Munin (master) - -**UNMAINTAINED** This repository is not maintained anymore, please use and report issues on it. - -## Quickstart - -Munin stats aggregator and reporting, based on lrivallain () and Arcus () work. -Update base image (ubuntu 20.04) and munin (2.0.56) and add easily configurable mail and Slack notifications. - -### Build - -```bash -git clone https://github.com/occitech/docker.git -docker build -t munin ./munin -docker run -p 80 munin -``` - -### Or pull - -```bash -docker pull occitech/munin -docker run -p 80 occitech/munin:latest -``` - -## How it works - -### Ports - -* 80 - -### Volumes - -* `/var/lib/munin` : Databases files -* `/var/log/munin` : Logs -* `/var/cache/munin` : Where are generated graphs - -### Environment Variables - -* `NODES`: Space separated list of `:` munin node pairs. (i.e. `foo.local:127.0.0.1 bar.remote:1.2.3.4`) -* `CRONDELAY`: Change the cron settings to update charts every X minutes (default: 5) -* `TZ`: Customize the timezone according to your place: (i.e. `Europe/London`) (default: `Europe/Paris`) -* `THISNODENAME`: Customize the displayed node name for local host (default: `munin`) -* `THISNODEIP`: Customize the node IP for local host (default: `127.0.0.1`) -* `DISABLELOCALNODE`: Disable local munin node (default: `no`) -* `MAILCONTACT`: Recipient of the mail alert (i.e. `alert@example.test`, needed for mail alert) -* `MAILSERVER`: Address of your mail server (i.e. `mail.example.test`, needed for mail alert) -* `MAILPORT`: Port of your SMTP mail server (i.e. `25`, needed for mail alert) -* `MAILUSER`: User to Auth on your mail server (i.e. `user@example.test`, needed for mail alert) -* `MAILPASSWORD`: Password of your mail server (needed for mail alert) -* `MAILFROM`: Where the mail seems to come from (i.e. `munin@example.test`, needed for mail alert) -* `MAILNAME`: Friendly sender name displayed for recipiend -* `MAILDOMAIN`: Domain of your mail server (i.e. `example.test`, needed for mail alert) -* `SLACKCHANNEL`: Name of your Slack channel (i.e. `hosting`, needed for Slack alert) -* `SLACKWEBHOOKURL`: URL of your Slack webhook (i.e. `https://hooks.slack.com/services/XXXXX/YYYYYYY/ZZZZZZZ`, needed for Slack alert) -* `SLACKUSER`: Username of munin bot on your Slack -* `SLACKICON`: Icon of munin bot on your Slack -* `VIRTUAL_HOST`: FQDN of your munin website - -## Persistent example - -```bash -docker run \ - -d \ - --name=munin \ - -p 127.0.0.1:8080:80 \ - -e THISNODENAME="munin.example.com" \ - -e TZ="Europe/London" \ - -e CRONDELAY=2 \ - -e NODES="anothernode.example.com:1.2.3.4 anothernode2.example.com:5.6.7.8" \ - -v /data/munin/db:/var/lib/munin \ - -v /data/munin/logs:/var/log/munin \ - -v /data/munin/cache:/var/cache/munin \ - munin -``` diff --git a/munin_slack.conf b/munin_slack.conf deleted file mode 100644 index 29009f7..0000000 --- a/munin_slack.conf +++ /dev/null @@ -1,2 +0,0 @@ -# notify slack -contact.slack.command MUNIN_SERVICESTATE="${var:worst}" MUNIN_HOST="${var:host}" MUNIN_SERVICE="${var:graph_title}" MUNIN_GROUP=${var:group} MUNIN_IMAGE="https://muninurl/${var:group}/${var:host}/${var:plugin}-day.png" /usr/local/bin/notify_slack_munin diff --git a/run.sh b/run.sh index 6c3642f..34aa4d2 100644 --- a/run.sh +++ b/run.sh @@ -54,23 +54,6 @@ else rm /etc/munin/munin-conf.d/munin_mail.conf /etc/ssmtp/ssmtp.conf fi -# configure Slack notification - -if [[ -n "$SLACKCHANNEL" && -n "$SLACKWEBHOOKURL" ]] ; then - SLACKCHANNEL=${SLACKCHANNEL:="hosting"} - sed -i "s/slackchannel/$SLACKCHANNEL/g" /usr/local/bin/notify_slack_munin - SLACKWEBHOOKURL=${SLACKWEBHOOKURL:="https://hooks.slack.com/services/XXXXX/YYYYYYY/ZZZZZZZ"} - sed -i "s,slackwebhookurl,$SLACKWEBHOOKURL,g" /usr/local/bin/notify_slack_munin - SLACKUSER=${SLACKUSER:="munin"} - sed -i "s/slackuser/$SLACKUSER/g" /usr/local/bin/notify_slack_munin - SLACKICON=${SLACKICON:=":bomb:"} - sed -i "s/slackicon/$SLACKICON/g" /usr/local/bin/notify_slack_munin - sed -i "s/muninurl/$VIRTUAL_HOST/g" /usr/local/bin/notify_slack_munin - sed -i "s/muninurl/$VIRTUAL_HOST/g" /etc/munin/munin-conf.d/munin_slack.conf -else - rm /etc/munin/munin-conf.d/munin_slack.conf -fi - # generate node list NODES=${NODES:-} for NODE in $NODES diff --git a/slack_munin.sh b/slack_munin.sh deleted file mode 100644 index 848196f..0000000 --- a/slack_munin.sh +++ /dev/null @@ -1,58 +0,0 @@ -#!/bin/bash - -# Slack notification script for Munin -# Mark Matienzo (@anarchivist) -# -# To use: -# 1) Create a new incoming webhook for Slack -# 2) Edit the configuration variables that start with "SLACK_" below -# 3) Add the following to your munin configuration: -# -# # -- Slack contact configuration -# contact.slack.command MUNIN_SERVICESTATE="${var:worst}" MUNIN_HOST="${var:host}" MUNIN_SERVICE="${var:graph_title}" MUNIN_GROUP=${var:group} MUNIN_IMAGE="http://munin.example.org/${var:group}/${var:host}/${var:plugin}-day.png" /usr/local/bin/notify_slack_munin -# contact.slack.always_send warning critical -# # note: This has to be on one line for munin to parse properly -# contact.slack.text ${if:cfields \u000A* CRITICALs:${loop<,>:cfields ${var:label} is ${var:value} (outside range [${var:crange}])${if:extinfo : ${var:extinfo}}}.}${if:wfields \u000A* WARNINGs:${loop<,>:wfields ${var:label} is ${var:value} (outside range [${var:wrange}])${if:extinfo : ${var:extinfo}}}.}${if:ufields \u000A* UNKNOWNs:${loop<,>:ufields ${var:label} is ${var:value}${if:extinfo : ${var:extinfo}}}.}${if:fofields \u000A* OKs:${loop<,>:fofields ${var:label} is ${var:value}${if:extinfo : ${var:extinfo}}}.} - - -SLACK_CHANNEL="slackchannel" -SLACK_WEBHOOK_URL="slackwebhookurl" -SLACK_USERNAME="slackuser" -SLACK_ICON_EMOJI="slackicon" - -# Url to link from slack notifications -MUNIN_URL="http://muninurl/problems.html" - -input=`cat` - -#Set the message icon based on service state -if [ "$MUNIN_SERVICESTATE" = "CRITICAL" ] -then - ICON=":exclamation:" - COLOR="danger" -elif [ "$MUNIN_SERVICESTATE" = "WARNING" ] -then - ICON=":warning:" - COLOR="warning" -elif [ "$MUNIN_SERVICESTATE" = "ok" ] -then - ICON=":white_check_mark:" - COLOR="good" -elif [ "$MUNIN_SERVICESTATE" = "OK" ] -then - ICON=":white_check_mark:" - COLOR="good" -elif [ "$MUNIN_SERVICESTATE" = "UNKNOWN" ] -then - ICON=":question:" - COLOR="#00CCCC" -else - ICON=":white_medium_square:" - COLOR="#CCCCCC" -fi - -# Generate the JSON payload -PAYLOAD="{\"channel\": \"${SLACK_CHANNEL}\", \"username\": \"${SLACK_USERNAME}\", \"attachments\": [{\"image_url\": \"${MUNIN_IMAGE}\", \"color\": \"${COLOR}\", \"fallback\": \"Munin alert - ${MUNIN_SERVICESTATE}: ${MUNIN_SERVICE} on ${MUNIN_HOST}\", \"pretext\": \"${ICON} Munin alert - ${MUNIN_SERVICESTATE}: ${MUNIN_SERVICE} on ${MUNIN_HOST} in ${MUNIN_GROUP} - <${MUNIN_URL}|View Munin>\", \"fields\": [{\"title\": \"Severity\", \"value\": \"${MUNIN_SERVICESTATE}\", \"short\": \"true\"}, {\"title\": \"Service\", \"value\": \"${MUNIN_SERVICE}\", \"short\": \"true\"}, {\"title\": \"Host\", \"value\": \"${MUNIN_HOST}\", \"short\": \"true\"}, {\"title\": \"Current Values\", \"value\": \"${input}\", \"short\": \"false\"}]}]}" - -#Send message to Slack -curl -sX POST -o /dev/null --data "payload=${PAYLOAD}" $SLACK_WEBHOOK_URL