Code Monkey home page Code Monkey logo

Comments (4)

JasonRivers avatar JasonRivers commented on July 20, 2024

How are you setting the SMTP Relay?

from docker-nagios.

SigmaOutdoors avatar SigmaOutdoors commented on July 20, 2024

I made my own Dockerfile to install a few other packages and a script as my ENTRYPOINT, the script does a sed to replace the relayhost and then starts nagios.

Dockerfile

FROM jasonrivers/nagios:latest
COPY ./dep/container-startup.sh /usr/bin/
RUN  apt-get update; \
    apt-get install vim -y; \
    apt-get install telnet -y; \
    chmod 777 /usr/bin/container-startup.sh;

# Set the entry point for the docker image.
ENTRYPOINT ["/usr/bin/container-startup.sh"]

container-startup.sh

#!/bin/sh
# need to /etc/postfix/main.cf to add our SMTP server as relay host
echo "STARTUP Adjusting SMTP_HOST..."
#Send to the log what we passed in the env
echo "SMTP_HOST=${SMTP_HOST}" >> /tmp/container-startup.log
#replace relayhost with our host
sed -i "s/relayhost =/relayhost =${SMTP_HOST}/g" /etc/postfix/main.cf
#echo to Docker log and write to our log to prove we have done the replace
cat /etc/postfix/main.cf | grep relayhost
cat /etc/postfix/main.cf | grep relayhost >>  /tmp/container-startup.log
# We set the relay host in main.cf and then once we start nagios it gets blown away, and reset to empty
echo "STARTUP Starting nagios..."
/usr/local/bin/start_nagios

Results from within Containter
My log shows that I changed it, but when I go and look it is back to relayhost=

# cat  /tmp/container-startup.log
SMTP_HOST=12.14.25.151
relayhost =12.14.25.151
#
# cat /etc/postfix/main.cf | grep relayhost
relayhost =
#

And that bonus question I talked about...how is this picking up my corporate email server? I know WHY it is bouncing and I can fix that by just giving a valid corporate email from address. What I don't get is where the nagios container is getting THAT IP & SMTP host from...I didn't set it anywhere. The servers and IPs in the log below have been obfuscated.

Docker Log
postfix/smtp[8964]: 21F2C1805507: to=<[email protected]>, relay=mycompany-mx01.com[12.22.8.37]:25, delay=0.29, delays=0.15/0/0.07/0.06, dsn=7.1.2, status=bounced (host mycompany-mx01.com[12.22.8.37] said: 504 7.1.2 <nagios@a123acfdf44d>: Sender address rejected: need fully-qualified address (in reply to RCPT TO command))

from docker-nagios.

thinkitdata avatar thinkitdata commented on July 20, 2024

Alternatively you can have a simple script that executes:
postconf -e "relayhost=YOURSMTPRELAY"
postfix reload

whenever your container is started....

from docker-nagios.

JasonRivers avatar JasonRivers commented on July 20, 2024

The problem here is that you're still calling /usr/local/bin/start_nagios which I assume you have not modified, this script then starts runsvdir on /erc/service - which I again assume you did not change any of the contents of.
In the postfix/run script there is this line:
sed -i "s/relayhost =.*/relayhost = ${MAIL_RELAY_HOST}/" /etc/postfix/main.cf
which is what is replacing it before postfix has started. This could be better by checking MAIL_RELAY_HOST first, and also using postconf, but you'll need to edit this script too. Alternatively, just use: -e MAIL_RELAY_HOST=mail.example.com when you start the container.

from docker-nagios.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.