Xymon Mailing List Archive search

Fun with xymonlaunch and MAXTIME

list Ralph Mitchell
Wed, 22 Feb 2017 16:06:39 -0500
Message-Id: <CAAEjoCVeVXCcpQ2OvuPX1QJHRgiFa+Mx3=6YPRNsEZ3S=user-932a65d3ea7f@xymon.invalid>

Apparently the tasks.cfg MAXTIME option is not very tolerant of spacing:

   MAXTIME  10m    - with two spaces, is interpreted as 10 seconds
   MAXTIME 10m     - with one space, is interpreted as 600 seconds

I think the problem lies at line 276 in xymon-4.3.28/common/xymonlaunch.c:

                        tspec = p + strspn(p, "0123456789");
                        switch (*tspec) {
                          case 'm': curtask->maxruntime *= 60; break;   /*
Minutes */
                          case 'h': curtask->maxruntime *= 3600; break; /*
Hours */
                          case 'd': curtask->maxruntime *= 86400;
break;        /* Days */
                        }

The pointer p is pointing to the first character after "MAXTIME ".  That's
fine as long as it points to a numeric string.  If it doesn't point to a
string of digits, tspec doesn't end up pointing to the multiplier, so
MAXTIME is handled as seconds.

Adding a space to the strspn string should fix it:

       tspec = p + strspn(p, " 0123456789");

Similarly, at line 254, for the INTERVAL option.

Ralph Mitchell