Xymon Mailing List Archive search

xymonnet additional capability -- pause

list Ralph Mitchell
Sat, 29 May 2021 20:19:33 -0400
Message-Id: <user-3eacbc26000d@xymon.invalid>

As far as the sleep() thing goes, you may be running into this, from the
'man 3 sleep' man page:

   BUGS
          sleep()  may be implemented using SIGALRM; mixing calls to
alarm(2) and
          sleep() is a bad idea.

I don't know how you'd fix it.  Hopefully this gives you a starting point.

Ralph Mitchell


On Sat, May 29, 2021 at 4:11 PM Shawn Heisey <user-5d0d01dba542@xymon.invalid> wrote:
Over ten years ago, I asked on this list how I could get rid of the
"incorrect pipelining message" logged by postfix every time the smtp,
smtps, or submission tests are done.

https://lists.xymon.com/oldarchive/2010/11/msg00207.html

The fix that I claim worked (multiple send commands) was for a job I had
at the time.  Now I am have a personal mail server (that also runs
xymon) and that fix I mentioned so long ago is not working.

I tweaked the code to allow a "pause" action in protocols.cfg and after
modifying protocols.cfg to utilize it, I have eliminated the "incorrect
command pipelining" message in mail.log.  Here's the patch:

--- xymon-4.3.28/lib/netservices.c      2017-01-05 19:00:06.000000000 -0700
+++ pause-xymon-4.3.28/lib/netservices.c        2021-05-29
12:51:09.717461323 -0600
@@ -259,6 +259,10 @@
                                 }
                         }
                 }
+               else if (strncmp(l, "pause ", 6) == 0) {
+                       int pausetime = atoi(skipwhitespace(l+5));
+                       sleep(pausetime);
+               }
         }

         if (fd) stackfclose(fd);

Here's the new definitions I created in protocols.cfg:

[smtp]
    pause 2
    send "ehlo xymonnet.localdomain\r\n"
    pause 2
    send "mail\r\n"
    pause 2
    send "quit\r\n"
    expect "220"
    options banner
    port 25

[smtps]
    pause 2
    send "ehlo xymonnet.localdomain\r\n"
    pause 2
    send "mail\r\n"
    pause 2
    send "quit\r\n"
    expect "220"
    options ssl,banner
#  No default port-number assignment for smtps - nonstandard according
to IANA

[submission|msa]
    pause 2
    send "ehlo xymonnet.localdomain\r\n"
    pause 2
    send "mail\r\n"
    pause 2
    send "quit\r\n"
    expect "220"
    options banner
    port 587


And this is now what I see in mail.log (testing smtps and submission:

May 29 13:51:15 bilbo postfix/submission/smtpd[16324]: connect from
bilbo.elyograg.org[172.31.8.104]
May 29 13:51:15 bilbo postfix/submission/smtpd[16324]: disconnect from
bilbo.elyograg.org[172.31.8.104] quit=1 commands=1
May 29 13:51:15 bilbo postfix/smtps/smtpd[16325]: connect from
bilbo.elyograg.org[172.31.8.104]
May 29 13:51:15 bilbo postfix/smtps/smtpd[16325]: disconnect from
bilbo.elyograg.org[172.31.8.104] quit=1 commands=1

Interesting thing here is that it's not actually pausing.  Which
probably means that I implemented it incorrectly.  My training on C is
ancient and I'm very rusty.  But even though it doesn't pause, the error
is gone, simply because each smtp command is now sent in a separate
packet, which appears to *sometimes* be enough "delay" for postfix to
not complain about pipelining.  What happens now is occasionally I will
get a yellow status on smtps with the xymon UI saying "Service smtps on
bilbo.elyograg.org is not OK : Unexpected service response".

So I think what I will do before submitting a patch is implement a
"null" action (which will do nothing) as well as a "pause" action, and
get some help from the real C developers here for making "pause" behave
as advertised.  Can somebody point me to some instructions on properly
creating and submitting a patch?  Also, if I could get some info on any
other files I need to modify (man pages, readme files, etc), I would
really appreciate it.

Thanks,
Shawn