Xymon Mailing List Archive search

bbcombotest patch

2 messages in this thread

list Cade Robinson · Tue, 02 Mar 2010 14:56:00 -0600 ·
bbcombotest in 4.4.0 (probably 4.3.0 too) was failing for me with the
error:
Could not access hobbitd board, error 0

I found that line:
if ((hobbitdresult != BB_OK) || (board == NULL)) {
always evaled true due to board being set to NULL  at the start of the
function and then never being set again.

Also I didn't like that a yellow status didn't trip the combo test
color, so that is the last part.

So here is a patch:

Index: bbcombotest.c
===================================================================
--- bbcombotest.c       (revision 6223)
+++ bbcombotest.c       (working copy)
@@ -209,20 +209,16 @@
        int result = COL_CLEAR;
        char *pattern, *found, *colstr;

-       if (board == NULL) {
                sendreturn_t *sres = newsendreturnbuf(1, NULL);

                hobbitdresult = sendmessage("hobbitdboard
fields=hostname,testname,color", NULL, BBTALK_TIMEOUT, sres);
+    board = getsendreturnstr(sres, 1);
                if ((hobbitdresult != BB_OK) || (board == NULL)) {
                        board = "";
                        *errptr += sprintf(*errptr, "Could not access
hobbitd board, error %d\n", hobbitdresult);
                        return COL_CLEAR;
                }
-               else {
-                       board = getsendreturnstr(sres, 1);
-               }
                freesendreturnbuf(sres);
-       }

        pattern = (char *)malloc(1 + strlen(hostname) + 1 +
strlen(testname) + 1 + 1);
        sprintf(pattern, "\n%s|%s|", hostname, testname);
@@ -275,7 +271,7 @@
        }

        if (*color == -1) return -1;
-       else return ( (*color == COL_GREEN) || (*color == COL_YELLOW) ||
(*color == COL_CLEAR) );
+       else return ( (*color == COL_GREEN) || (*color == COL_CLEAR) );
 }
list Cade Robinson · Thu, 04 Mar 2010 11:39:35 -0600 ·
I found that bbcombotest didn't work for hostnames starting with a
number.

My fix:  (this is on the 4.4.0 branch)

@@ -295,13 +291,10 @@

        done = 0; inp=symbolicexpr; outp=expr; symp = NULL;
        while (!done) {
-               if (isalpha((int)*inp)) {
+        if (isalpha((int)*inp) || isdigit((int) *inp) || *inp == '.') {
                        if (!insymbol) { insymbol = 1; symp = symbol; }
                        *symp = *inp; symp++;
                }
-               else if (insymbol && (isdigit((int) *inp) || (*inp ==
'.'))) {
-                       *symp = *inp; symp++;
-               }
                else if (insymbol && ((*inp == '\\') && (*(inp+1) > '
'))) {
                        *symp = *(inp+1); symp++; inp++;
                }