Announcement Banner

sumcallmetim

updated

8 months ago

S

sumcallmetim

1 Rookie

•

2 Posts

0

11731

July 26th, 2013 14:00

Sendmail from an Isilon cluster

I am trying to send mail from my cluster using the command line. Using either the mail or mailx command. When I try to send mail the logs show the wrong relay and mail is deferred. I tried adding the correct relay to the line in /etc/mail/sendmail.cf starting with the DS. Then I tried to bounce sendmail using /etc/rc.d_disabled/sendmail onerestart... But I'm getting the same results.

Using the GUI under cluster management, email settings everything is correct and the call home seems to be working when I run a manual test.

What am I missing?

  • Peter_Sero

    6 Operator

    •

    1169 Posts

    6646

    1

    Posted August 3rd, 2013 05:00

    (To the original poster:)

    Here is sort of a bad hack that once helped me when sending e-mail

    from a machine whose root disk (with /tmp) occasionally went into a read-only state,

    making use of sendmail etc. just impossible.

    It is simply shell-based, plus "nc":

      

        (

            echo "HELO "

            sleep 1

            echo "MAIL FROM: "

            sleep 1

            echo "RCPT TO:

            sleep 1

            echo "DATA"

            sleep 1

        echo "Subject:

            sleep 1

        echo ""

            sleep 1

        echo " "

            sleep 1

            echo "."

            sleep 1

            echo "QUIT"

            sleep 1

        ) |

        nc   25

    Everything in <...> needs to be replaced by actual values of course!

    The key is the "nc" (netcat) command in UNIX (also OneFS),

    which opens a network connection to the given host and port (smtp = 25)

    and allows to send and receive any data over it.

    Here we "speak" the text-based SMTP mail protocol line by line.

    (You might also use telnet, probably with an "expect" script.)

    Note there is no error handling in here, no retry after failure etc.

    And the mailhost is fixed -- no problem assuming you want to send

    e-mails only to few in-house addresses. Otherwise you would

    need to look up the server for each e-mail address, probably deal

    with relays,  and more or less you would arrive at something that

    acts like the Python mail module mentioned by Andrew.

    (You could use that Python module of course, it is not Isilon-specific.

    Only obtaining the mail config is; you could feed in your mail params

    on your own instead.)

    -- Peter

  • Jeffey1

    6 Operator

    •

    2755 Posts

    6637

    0

    Posted July 26th, 2013 15:00

    Primus article emc14003816 will walk you through "How to trigger a specific event notification"

  • AndrewChung

    132 Posts

    6637

    1

    Posted August 2nd, 2013 09:00

    Unfortunately sending mail from an Isilon cluster directly is not so simple.  The sendmail configuration is stored in an internal database and our tools use internal Python APIs to send the e-mail properly.  This is not exposed directly to the CLI even though at the core we use sendmail.

  • sumcallmetim

    1 Rookie

    •

    2 Posts

    3542

    0

    Posted August 5th, 2013 08:00

    Thank you all for the help. I was thinking is was going to take something out of the normal set up to get working.

  • Ajithfrank

    12 Posts

    6646

    0

    Posted June 13th, 2017 02:00

    Hello Peter,

    Thank you for this script.

    I have wrote a script and the output of that has been saved in text file.

    We are using Onefs 8.0.0.4. I want to email the output.

    I am trying by using this script, but i am not getting the email. Kindly help me in doing this.

  • Phil.Lam

    4 Apprentice

    •

    642 Posts

    •

    15 Points

    6645

    2

    Posted June 14th, 2017 21:00

    Ajithfrank,

    OneFS 8.x does not have mail/mailx/sendmail anymore. Try sendml.py script from here:

    Google Groups

    I take no credit for this script and I'm not sure who made it either.

    It should be 64 lines long according to xcode.

    ********************************************************

    #!/usr/bin/env python

    #

    # Helper script to send mail using the Isilon libraries

    #

    import sys

    from optparse import OptionParser

    import socket

    from isi.app.lib.emailer import Emailer, EmailAttachmentFromFile

    # Emailer.send_email(to_addresses(list), message(string), from_address=None(string),  subject=None(string),

    #                    attachments=None(list), headers=None(list), charset="us-ascii"(string))

    def main():

        usage = '%prog: [-f sender] -t recipient [ -t recipient ... ] [-s subject] [-b body] [-a attachment]'

        argparser = OptionParser(usage = usage, description = 'Send email from a cluser node')

        argparser.add_option('-f', '--from', '--sender', dest='sender',

    help="email sender (From:)")

        argparser.add_option('-t', '--to', '--recipients', dest='recipients',

    action = 'append', help="email recipient (To:)")

        argparser.add_option('-s', '--subject', dest='subject',

    help="email subject (Subject:)")

        argparser.add_option('-b', '--body', dest='body',

    help="email body (default stdin)")

        argparser.add_option('-a', '--attachment', '--file', dest='attfiles',

    action = 'append', help="attachment filename")

        (options, args) = argparser.parse_args()

        if options.sender is None:

    fqdn = socket.getfqdn()

    sender = "root@%s" % fqdn

        else:

           sender = options.sender

        if options.recipients is None:

    argparser.error("Unable to send mail without at least one recipient");

    sys.exit(1);

        else:

    recipients = options.recipients

        if options.subject is None:

         subject = 'No subject specified'

        else:

    subject = options.subject

        if options.body is None:

    lines = sys.stdin.readlines()

    body = ''.join(lines)

        else:

    body = options.body

        if options.attfiles is None:

    atts = None

        else:

    atts = []

    for attfile in options.attfiles:

        att = EmailAttachmentFromFile(attfile)

        atts.append(att)

        try:

            Emailer.send_email(recipients, body, sender, subject, attachments = atts)

        except:

            print "Error sending email."

            sys.exit(1)

        sys.exit(0)

    if __name__ == "__main__":

        main()

  • Ajithfrank

    12 Posts

    6645

    0

    Posted June 14th, 2017 22:00

    Hello Phil,

    Thank you very much for this script.

    Actually i am new to python script. Kindly let me in this script what are fields i have modify with the actual values. (Ex: sender mail id, receptionist, whether i have to mention SMTP IP and port no...) Kindly provide these details.

  • Phil.Lam

    4 Apprentice

    •

    642 Posts

    •

    15 Points

    6645

    0

    Posted June 15th, 2017 16:00

    Ajithfrank

    It's similar to mailx linux syntax. SMTP has to be set on Isilon cluster. Check local node "/var/log/messages" for any messages.

    # python sendml.py

    Usage: sendml.py: [-f sender] -t recipient [ -t recipient ... ] [-s subject] [-b body] [-a attachment]

    # python sendml.py  -t name@company.com -s "test0" -b "test1"

    # tail /var/log/messages

    ...

    2017-06-14T22:28:37-07:00 <1.4> isilon-1 python: Successfully sent to ['name@company.com'] through 'mailhost'

    Phil

  • Ajithfrank

    12 Posts

    6645

    0

    Posted July 26th, 2017 07:00

    Hello Phil

    Sorry for late reply, i was stuck in another issues. Now again i have started working on this. Need your kind kind assistance in resolving this.

    While i am trying to run the script i am getting the below error. Kindly assist me on this.

    dxbisilon-1# python sendml.py -f xxxx@xxxx.xx -t xxxx.xxxx@xxx.xxx -s "test0" -b "test1"

      File "sendml.py", line 67

        fqdn = socket.getfqdn()

    ^

    IndentationError: unindent does not match any outer indentation level

    xxxisilon-1# tail /var/log/messages

    2017-07-26T09:04:17Z <3.4> dxbisilon-1 celog_alerting:channel_updater[71109:channel_controller.py:236] WARNING:`1-reporter-16427`: scheduling next send attempt for Wed Jul 26 17:04:16 2017

    2017-07-26T09:04:34Z <3.3> dxbisilon-1 celog_alerting:Main[4857:celog_main.py:63] ERROR:Sender process exited non-zero. Setting backoff of 60 seconds

    2017-07-26T09:15:39Z <1.4> dxbisilon-1 isi_celog_alerting: Unable to send to [u'xxxx@xxxx.xxx', u'xxxx@xxxx.xxx'] through u'xx.x.x.xx': STARTTLS extension not supported by server.

    2017-07-26T09:15:39Z <3.3> dxbisilon-1 celog_alerting:channels[72042:channels.py:149] ERROR:Could not send email notification: All SMTP hosts (xx.x.x.xx) failed to deliver to [u'xxxx@xxxx.xxx', u'xxxx@xxxx.xxx']

    2017-07-26T09:15:39Z <3.4> dxbisilon-1 celog_alerting:channel_updater[72042:channel_controller.py:236] WARNING:`1-reporter-18723`: scheduling next send attempt for Wed Jul 26 17:15:38 2017

    2017-07-26T09:15:39Z <3.4> dxbisilon-1 celog_alerting:channel_updater[72042:channel_controller.py:236] WARNING:`1-reporter-18724`: scheduling next send attempt for Wed Jul 26 17:15:38 2017

    2017-07-26T09:15:40Z <3.4> dxbisilon-1 celog_alerting:channel_updater[72042:channel_controller.py:236] WARNING:`1-reporter-18722`: scheduling next send attempt for Wed Jul 26 17:15:38 2017

    2017-07-26T09:15:40Z <3.4> dxbisilon-1 celog_alerting:channel_updater[72042:channel_controller.py:236] WARNING:`1-reporter-18725`: scheduling next send attempt for Wed Jul 26 17:15:38 2017

    2017-07-26T09:15:53Z <3.3> dxbisilon-1 celog_alerting:Main[4857:celog_main.py:63] ERROR:Sender process exited non-zero. Setting backoff of 60 seconds

    2017-07-26T11:57:49Z <3.3> dxbisilon-1 celog_analysis:prune[77335:eventgroup_pruner.py:284] ERROR:Unable to stat files, skipping cleanup: [Errno 2] No such file or directory: '/ifs/.ifsvar/db/celog_capture/2/attachments/asbuilt.3'

    dxbisilon-1#

  • Phil.Lam

    4 Apprentice

    •

    642 Posts

    •

    15 Points

    4171

    0

    Posted July 26th, 2017 14:00

    Ajithfrank


    sendml.py should be 64 lines only. What editor are you using?  I use vi.


    Phil