コード例 #1
0
ファイル: mafdcmd.c プロジェクト: hfs/afd
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$ mafdcmd() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
   int  errors = 0,
        i,
        position,
        user_offset;
   char fake_user[MAX_FULL_USER_ID_LENGTH],
        *perm_buffer,
        *ptr,
        user[MAX_FULL_USER_ID_LENGTH],
        work_dir[MAX_PATH_LENGTH];

   CHECK_FOR_VERSION(argc, argv);

   if ((argc > 1) &&
       (argv[1][0] == '-') && (argv[1][1] == 'v') && (argv[1][2] == '\0'))
   {
      (void)fprintf(stdout, "%s\n", PACKAGE_VERSION);
      exit(SUCCESS);
   }

   if (get_mon_path(&argc, argv, work_dir) < 0)
   {
      exit(INCORRECT);
   }
   p_work_dir = work_dir;
   if (get_arg(&argc, argv, "-p", user, MAX_PROFILE_NAME_LENGTH) == INCORRECT)
   {
      user_offset = 0;
   }
   else
   {
      user_offset = strlen(user);
   }
#ifdef WITH_SETUID_PROGS
   set_afd_euid(work_dir);
#endif

   if (argc < 2)
   {
      usage(argv[0]);
      exit(INCORRECT);
   }
   check_fake_user(&argc, argv, MON_CONFIG_FILE, fake_user);
   eval_input(argc, argv);
   get_user(user, fake_user, user_offset);

   /*
    * Ensure that the user may use this program.
    */
   switch (get_permissions(&perm_buffer, fake_user))
   {
      case NO_ACCESS : /* Cannot access afd.users file. */
         {
            char afd_user_file[MAX_PATH_LENGTH];

            (void)strcpy(afd_user_file, p_work_dir);
            (void)strcat(afd_user_file, ETC_DIR);
            (void)strcat(afd_user_file, AFD_USER_FILE);

            (void)fprintf(stderr,
                          "Failed to access `%s', unable to determine users permissions.\n",
                          afd_user_file);
         }
         exit(INCORRECT);

      case NONE :
         (void)fprintf(stderr, "%s\n", PERMISSION_DENIED_STR);
         exit(INCORRECT);

      case SUCCESS : /* Lets evaluate the permissions and see what */
                     /* the user may do.                           */
         {
            int permission = NO;

            if ((perm_buffer[0] == 'a') && (perm_buffer[1] == 'l') &&
                (perm_buffer[2] == 'l') &&
                ((perm_buffer[3] == '\0') || (perm_buffer[3] == ' ') ||
                 (perm_buffer[3] == '\t')))
            {
               permission = YES;
            }
            else
            {
               if (lposi(perm_buffer, MAFD_CMD_PERM,
                         MAFD_CMD_PERM_LENGTH) != NULL)
               {
                  permission = YES;

                  /*
                   * Check if the user may do everything
                   * he has requested. If not remove it
                   * from the option list.
                   */
                  if ((options & ENABLE_AFD_OPTION) ||
                      (options & DISABLE_AFD_OPTION))
                  {
                     if (lposi(perm_buffer, DISABLE_AFD_PERM,
                               DISABLE_AFD_PERM_LENGTH) == NULL)
                     {
                        if (options & ENABLE_AFD_OPTION)
                        {
                           options ^= ENABLE_AFD_OPTION;
                        }
                        if (options & DISABLE_AFD_OPTION)
                        {
                           options ^= DISABLE_AFD_OPTION;
                        }
                        if (options & TOGGLE_AFD_OPTION)
                        {
                           options ^= TOGGLE_AFD_OPTION;
                        }
                        (void)fprintf(stderr,
                                      "User %s not permitted to enable/disable a AFD.\n",
                                      user);
                     }
                  }
                  if (options & RETRY_OPTION)
                  {
                     if (lposi(perm_buffer, RETRY_PERM,
                               RETRY_PERM_LENGTH) == NULL)
                     {
                        options ^= RETRY_OPTION;
                        (void)fprintf(stderr,
                                      "User %s not permitted to retry.\n",
                                      user);
                     }
                  }
                  if (options & SWITCH_AFD_OPTION)
                  {
                     if (lposi(perm_buffer, SWITCH_HOST_PERM,
                               SWITCH_HOST_PERM_LENGTH) == NULL)
                     {
                        options ^= SWITCH_AFD_OPTION;
                        (void)fprintf(stderr,
                                      "User %s not permitted to retry.\n",
                                      user);
                     }
                  }
               }
            }
            free(perm_buffer);
            if (permission != YES)
            {
               (void)fprintf(stderr, "%s\n", PERMISSION_DENIED_STR);
               exit(INCORRECT);
            }
         }
         break;

      case INCORRECT: /* Hmm. Something did go wrong. Since we want to */
                      /* be able to disable permission checking let    */
                      /* the user have all permissions.                */
         break;

      default :
         (void)fprintf(stderr, "Impossible!! Remove the programmer!\n");
         exit(INCORRECT);
   }

   if (msa_attach() < 0)
   {
      (void)fprintf(stderr, "ERROR   : Failed to attach to MSA. (%s %d)\n",
                    __FILE__, __LINE__);
      exit(INCORRECT);
   }

   for (i = 0; i < no_of_afd_names; i++)
   {
      position = -1;
      ptr = afds[i];
      while ((*ptr != '\0') && (isdigit((int)(*ptr))))
      {
         ptr++;
      }
      if ((*ptr == '\0') && (ptr != afds[i]))
      {
         position = atoi(afds[i]);
         if ((position < 0) || (position > (no_of_afds - 1)))
         {
            (void)fprintf(stderr,
                          "WARNING : Position %d out of range. Ignoring. (%s %d)\n",
                          position, __FILE__, __LINE__);
            errors++;
            continue;
         }
      }
      if (position < 0)
      {
         if ((position = get_afd_position(msa, afds[i], no_of_afds)) < 0)
         {
            (void)fprintf(stderr,
                          "WARNING : Could not find AFD %s in MSA. (%s %d)\n",
                          afds[i], __FILE__, __LINE__);
            errors++;
            continue;
         }
      }

      /*
       * ENABLE AFD
       */
      if (options & ENABLE_AFD_OPTION)
      {
         if (msa[position].connect_status == DISABLED)
         {
            int  fd;
#ifdef WITHOUT_FIFO_RW_SUPPORT
            int  readfd;
#endif
            char mon_cmd_fifo[MAX_PATH_LENGTH];

            (void)sprintf(mon_cmd_fifo, "%s%s%s",
                          p_work_dir, FIFO_DIR, MON_CMD_FIFO);
#ifdef WITHOUT_FIFO_RW_SUPPORT
            if (open_fifo_rw(mon_cmd_fifo, &readfd, &fd) == -1)
#else
            if ((fd = open(mon_cmd_fifo, O_RDWR)) == -1)
#endif
            {
               system_log(ERROR_SIGN, __FILE__, __LINE__,
                          "Failed to open() %s : %s",
                          mon_cmd_fifo, strerror(errno));
               errors++;
            }
            else
            {
               char cmd[1 + SIZEOF_INT];

               cmd[0] = ENABLE_MON;
               (void)memcpy(&cmd[1], &position, SIZEOF_INT);
               if (write(fd, cmd, (1 + SIZEOF_INT)) != (1 + SIZEOF_INT))
               {
                  system_log(ERROR_SIGN, __FILE__, __LINE__,
                             "Failed to write() to %s : %s",
                             mon_cmd_fifo, strerror(errno));
                  errors++;
               }
               else
               {
                  system_log(DEBUG_SIGN, NULL, 0,
                             "%-*s: ENABLED (%s) [mafdcmd].",
                             MAX_AFD_NAME_LENGTH, msa[position].afd_alias, user);
               }
#ifdef WITHOUT_FIFO_RW_SUPPORT
               if (close(readfd) == -1)
               {
                  system_log(DEBUG_SIGN, __FILE__, __LINE__,
                             "Failed to close() FIFO %s : %s",
                             mon_cmd_fifo, strerror(errno));
               }
#endif
               if (close(fd) == -1)
               {
                  system_log(DEBUG_SIGN, __FILE__, __LINE__,
                             "Failed to close() FIFO %s : %s",
                             mon_cmd_fifo, strerror(errno));
               }
            }
         }
         else
         {
            (void)fprintf(stderr,
                          "INFO    : AFD %s is already enabled.\n",
                          msa[position].afd_alias);
         }
      }

      /*
       * DISABLE AFD
       */
      if (options & DISABLE_AFD_OPTION)
      {
         if (msa[position].connect_status == DISABLED)
         {
            (void)fprintf(stderr,
                          "INFO    : AFD %s is already disabled.\n",
                          msa[position].afd_alias);
         }
         else
         {
            int  fd;
#ifdef WITHOUT_FIFO_RW_SUPPORT
            int  readfd;
#endif
            char mon_cmd_fifo[MAX_PATH_LENGTH];

            (void)sprintf(mon_cmd_fifo, "%s%s%s",
                          p_work_dir, FIFO_DIR, MON_CMD_FIFO);
#ifdef WITHOUT_FIFO_RW_SUPPORT
            if (open_fifo_rw(mon_cmd_fifo, &readfd, &fd) == -1)
#else
            if ((fd = open(mon_cmd_fifo, O_RDWR)) == -1)
#endif
            {
               system_log(ERROR_SIGN, __FILE__, __LINE__,
                          "Failed to open() %s : %s",
                          mon_cmd_fifo, strerror(errno));
               errors++;
            }
            else
            {
               char cmd[1 + SIZEOF_INT];

               cmd[0] = DISABLE_MON;
               (void)memcpy(&cmd[1], &position, SIZEOF_INT);
               if (write(fd, cmd, (1 + SIZEOF_INT)) != (1 + SIZEOF_INT))
               {
                  system_log(ERROR_SIGN, __FILE__, __LINE__,
                             "Failed to write() to %s : %s",
                             mon_cmd_fifo, strerror(errno));
                  errors++;
               }
               else
               {
                  system_log(DEBUG_SIGN, NULL, 0,
                             "%-*s: DISABLED (%s) [mafdcmd].",
                             MAX_AFD_NAME_LENGTH, msa[position].afd_alias, user);
               }
#ifdef WITHOUT_FIFO_RW_SUPPORT
               if (close(readfd) == -1)
               {
                  system_log(DEBUG_SIGN, __FILE__, __LINE__,
                             "Failed to close() FIFO %s : %s",
                             mon_cmd_fifo, strerror(errno));
               }
#endif
               if (close(fd) == -1)
               {
                  system_log(DEBUG_SIGN, __FILE__, __LINE__,
                             "Failed to close() FIFO %s : %s",
                             mon_cmd_fifo, strerror(errno));
               }
            }
         }
      }

      /*
       * ENABLE or DISABLE a AFD.
       */
      if (options & TOGGLE_AFD_OPTION)
      {
         int  fd;
#ifdef WITHOUT_FIFO_RW_SUPPORT
         int  readfd;
#endif
         char mon_cmd_fifo[MAX_PATH_LENGTH];

         (void)sprintf(mon_cmd_fifo, "%s%s%s",
                       p_work_dir, FIFO_DIR, MON_CMD_FIFO);
#ifdef WITHOUT_FIFO_RW_SUPPORT
         if (open_fifo_rw(mon_cmd_fifo, &readfd, &fd) == -1)
#else
         if ((fd = open(mon_cmd_fifo, O_RDWR)) == -1)
#endif
         {
            system_log(ERROR_SIGN, __FILE__, __LINE__,
                       "Failed to open() %s : %s",
                       mon_cmd_fifo, strerror(errno));
            errors++;
         }
         else
         {
            char cmd[1 + SIZEOF_INT];

            if (msa[position].connect_status == DISABLED)
            {
               cmd[0] = ENABLE_MON;
            }
            else /* DISABLE AFD */
            {
               cmd[0] = DISABLE_MON;
            }
            (void)memcpy(&cmd[1], &position, SIZEOF_INT);
            if (write(fd, cmd, (1 + SIZEOF_INT)) != (1 + SIZEOF_INT))
            {
               system_log(ERROR_SIGN, __FILE__, __LINE__,
                          "Failed to write() to %s : %s",
                          mon_cmd_fifo, strerror(errno));
               errors++;
            }
            else
            {
               system_log(DEBUG_SIGN, NULL, 0,
                          "%-*s: %s (%s) [mafdcmd].",
                          MAX_AFD_NAME_LENGTH, msa[position].afd_alias,
                          (cmd[0] == DISABLE_MON) ? "DISABLE" : "ENABLE", user);
            }
#ifdef WITHOUT_FIFO_RW_SUPPORT
            if (close(readfd) == -1)
            {
               system_log(DEBUG_SIGN, __FILE__, __LINE__,
                          "Failed to close() FIFO %s : %s",
                          mon_cmd_fifo, strerror(errno));
            }
#endif
            if (close(fd) == -1)
            {
               system_log(DEBUG_SIGN, __FILE__, __LINE__,
                          "Failed to close() FIFO %s : %s",
                          mon_cmd_fifo, strerror(errno));
            }
         }
      }

      if (options & RETRY_OPTION)
      {
         int  fd;
#ifdef WITHOUT_FIFO_RW_SUPPORT
         int  readfd;
#endif
         char retry_fifo[MAX_PATH_LENGTH];

         (void)sprintf(retry_fifo, "%s%s%s%d",
                       p_work_dir, FIFO_DIR, RETRY_MON_FIFO, position);
#ifdef WITHOUT_FIFO_RW_SUPPORT
         if (open_fifo_rw(retry_fifo, &readfd, &fd) == -1)
#else
         if ((fd = open(retry_fifo, O_RDWR)) == -1)
#endif
         {
            (void)fprintf(stderr,
                          "WARNING : Failed to open() %s : %s (%s %d)\n",
                          retry_fifo, strerror(errno),
                          __FILE__, __LINE__);
            errors++;
         }
         else
         {
            if (write(fd, &position, sizeof(int)) != sizeof(int))
            {
               (void)fprintf(stderr,
                             "WARNING : Failed to write() to %s : %s (%s %d)\n",
                             retry_fifo, strerror(errno),
                             __FILE__, __LINE__);
               errors++;
            }
#ifdef WITHOUT_FIFO_RW_SUPPORT
            if (close(readfd) == -1)
            {
               system_log(DEBUG_SIGN, __FILE__, __LINE__,
                          "Failed to close() FIFO %s : %s"
                          RETRY_FD_FIFO, strerror(errno));
            }
#endif
            if (close(fd) == -1)
            {
               system_log(DEBUG_SIGN, __FILE__, __LINE__,
                          "Failed to close() FIFO %s : %s"
                          RETRY_FD_FIFO, strerror(errno));
            }
         }
      }

      /*
       * Switch AFD
       */
      if (options & SWITCH_AFD_OPTION)
      {
         if (msa[position].afd_switching == NO_SWITCHING)
         {
            (void)fprintf(stderr,
                          "INFO    : AFD %s cannot be switched.\n",
                          msa[position].afd_alias);
            errors++;
         }
         else
         {
            if (msa[position].afd_toggle == (HOST_ONE - 1))
            {
               msa[position].afd_toggle = (HOST_TWO - 1);
            }
            else
            {
               msa[position].afd_toggle = (HOST_ONE - 1);
            }
            system_log(DEBUG_SIGN, NULL, 0,
                       "%-*s: SWITCHED (%s) [mafdcmd].",
                       MAX_AFD_NAME_LENGTH, msa[position].afd_alias, user);
         }
      }
   } /* for (i = 0; i < no_of_afd_names; i++) */

   (void)msa_detach();

   exit(errors);
}
コード例 #2
0
ファイル: hmon_ctrl.c プロジェクト: holger24/AFD
/*$$$$$$$$$$$$$$$$$$$$$$$$$$$$ msa_view() $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$*/
int
main(int argc, char *argv[])
{
   int          flush_output,
                i, j,
                last = 0,
                position = -1;
   unsigned int interval;
   FILE         *output;
   char         afdname[MAX_AFDNAME_LENGTH + 1],
                *ptr,
                str_fc[5],
                str_fs[5],
                str_tr[5],
                str_fr[4],
                str_jq[4],
                str_at[4],
                str_ec[3],
                str_hec[3],
                val[MAX_PATH_LENGTH + 1],
                work_dir[MAX_PATH_LENGTH];
   const char   *color_pool[COLOR_POOL_SIZE] =
                {
                   HTML_COLOR_0,
                   HTML_COLOR_1,
                   HTML_COLOR_2,
                   HTML_COLOR_3,
                   HTML_COLOR_4,
                   HTML_COLOR_5,
                   HTML_COLOR_6,
                   HTML_COLOR_7,
                   HTML_COLOR_8,
                   HTML_COLOR_9,
                   HTML_COLOR_10,
                   HTML_COLOR_11,
                   HTML_COLOR_12,
                   HTML_COLOR_13,
                   HTML_COLOR_14,
                   HTML_COLOR_15,
                   HTML_COLOR_16,
                   HTML_COLOR_17,
                   HTML_COLOR_18,
#ifdef _WITH_WMO_SUPPORT
                   HTML_COLOR_19,
                   HTML_COLOR_20
#else
                   HTML_COLOR_19
#endif
                };

   CHECK_FOR_VERSION(argc, argv);

   if (get_mon_path(&argc, argv, work_dir) < 0)
   {
      exit(INCORRECT);
   }
   p_work_dir = work_dir;
#ifdef WITH_SETUID_PROGS
   set_afd_euid(work_dir);
#endif

   if (get_arg(&argc, argv, "-d", val, MAX_INT_LENGTH) == SUCCESS)
   {
      interval = atoi(val);
   }
   else
   {
      interval = 0;
   }

   if (get_arg(&argc, argv, "-o", val, MAX_PATH_LENGTH) == SUCCESS)
   {
      if ((output = fopen(val, "w")) == NULL)
      {
         (void)fprintf(stderr, "Failed to fopen() %s : %s\n",
                       val, strerror(errno));
         exit(INCORRECT);
      }
      flush_output = YES;
   }
   else
   {
      output = stdout;
      flush_output = NO;
   }

   if (argc == 2)
   {
      if (isdigit((int)(argv[1][0])) != 0)
      {
         position = atoi(argv[1]);
         last = position + 1;
      }
      else
      {
         (void)my_strncpy(afdname, argv[1], MAX_AFDNAME_LENGTH + 1);
      }
   }
   else if (argc == 1)
        {
           position = -2;
        }
        else
        {
           usage();
           exit(INCORRECT);
        }

   if ((i = msa_attach_passive()) < 0)
   {
      if (i == INCORRECT_VERSION)
      {
         (void)fprintf(stderr,
                       "ERROR   : This program is not able to attach to the MSA due to incorrect version. (%s %d)\n",
                       __FILE__, __LINE__);
      }
      else
      {
         (void)fprintf(stderr, "ERROR   : Failed to attach to MSA. (%s %d)\n",
                       __FILE__, __LINE__);
      }
      exit(INCORRECT);
   }

   if (position == -1)
   {
      for (i = 0; i < no_of_afds; i++)
      {
         if (my_strcmp(msa[i].afd_alias, afdname) == 0)
         {
            position = i;
            break;
         }
      }
      if (position < 0)
      {
         (void)fprintf(stderr,
                       "WARNING : Could not find AFD `%s' in MSA. (%s %d)\n",
                       afdname, __FILE__, __LINE__);
         exit(INCORRECT);
      }
      last = position + 1;
   }
   else if (position == -2)
        {
           last = no_of_afds;
           position = 0;
        }
   else if (position >= no_of_afds)
        {
           (void)fprintf(stderr,
                         "WARNING : There are only %d AFD's in the MSA. (%s %d)\n",
                         no_of_afds, __FILE__, __LINE__);
           exit(INCORRECT);
        }

   ptr = (char *)msa;
   ptr -= AFD_WORD_OFFSET;

   for (;;)
   {
      (void)fprintf(output,
                    "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">\n");
      (void)fprintf(output,
                    "<html>\n<head>\n   <meta charset=\"utf-8\"/>\n");
      (void)fprintf(output,
                    "   <meta http-equiv=\"refresh\" content=\"5\"/>\n");
      (void)fprintf(output,
                    "   <title>AFD Monitor</title>\n</head>\n");
      (void)fprintf(output, "<body bgcolor=\"#F0ECD6\">\n");
      (void)fprintf(output, "<table align=center bgcolor=\"%s\">\n",
                    color_pool[(int)DEFAULT_BG]);
      (void)fprintf(output, "<tr>\n");
      (void)fprintf(output, "<th style=\"width:%dem;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">%s</th>\n",
                    MAX_AFDNAME_LENGTH, color_pool[(int)LABEL_BG], "AFD");
      (void)fprintf(output, "<th style=\"width:4em;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">fc</th>\n",
                    color_pool[(int)LABEL_BG]);
      (void)fprintf(output, "<th style=\"width:4em;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">fs</th>\n",
                    color_pool[(int)LABEL_BG]);
      (void)fprintf(output, "<th style=\"width:4em;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">tr</th>\n",
                    color_pool[(int)LABEL_BG]);
      (void)fprintf(output, "<th style=\"width:3em;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">fr</th>\n",
                    color_pool[(int)LABEL_BG]);
      (void)fprintf(output, "<th style=\"width:3em;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">jq</th>\n",
                    color_pool[(int)LABEL_BG]);
      (void)fprintf(output, "<th style=\"width:3em;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">at</th>\n",
                    color_pool[(int)LABEL_BG]);
      (void)fprintf(output, "<th style=\"width:2em;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">ec</th>\n",
                    color_pool[(int)LABEL_BG]);
      (void)fprintf(output, "<th style=\"width:2em;\" align=\"center\" valign=\"middle\" bgcolor=\"%s\">eh</th>\n",
                    color_pool[(int)LABEL_BG]);
      (void)fprintf(output, "</tr>\n");
      for (j = position; j < last; j++)
      {
         (void)fprintf(output, "<tr>\n");
         if (msa[j].connect_status == NOT_WORKING2)
         {
            (void)fprintf(output,
                          "<td align=\"left\" valign=\"middle\" style=\"background-color:%s; color:%s\">%-*s</td>\n",
                          color_pool[(int)NOT_WORKING2], color_pool[(int)WHITE],
                          MAX_AFDNAME_LENGTH, msa[j].afd_alias);
         }
         else
         {
            (void)fprintf(output,
                          "<td align=\"left\" valign=\"middle\" bgcolor=\"%s\">%-*s</td>\n",
                          color_pool[(int)msa[j].connect_status],
                          MAX_AFDNAME_LENGTH, msa[j].afd_alias);
         }
         CREATE_FC_STRING(str_fc, msa[j].fc);
         (void)fprintf(output, "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n", color_pool[(int)CHAR_BACKGROUND], str_fc);
         CREATE_FS_STRING(str_fs,  msa[j].fs);
         (void)fprintf(output, "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n", color_pool[(int)CHAR_BACKGROUND], str_fs);
         CREATE_FS_STRING(str_tr,  msa[j].tr);
         (void)fprintf(output, "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n", color_pool[(int)CHAR_BACKGROUND], str_tr);
         CREATE_JQ_STRING(str_fr, msa[j].fr);
         (void)fprintf(output, "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n", color_pool[(int)CHAR_BACKGROUND], str_fr);
         CREATE_JQ_STRING(str_jq, msa[j].jobs_in_queue);
         if ((msa[j].danger_no_of_jobs != 0) &&
             (msa[j].jobs_in_queue > msa[j].danger_no_of_jobs) &&
             (msa[j].jobs_in_queue <= ((msa[j].danger_no_of_jobs * 2) - STOP_AMG_THRESHOLD - DIRS_IN_FILE_DIR)))
         {
            (void)fprintf(output,
                          "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n",
                          color_pool[(int)WARNING_ID], str_jq);
         }
         else if ((msa[j].danger_no_of_jobs != 0) &&
                  (msa[j].jobs_in_queue > ((msa[j].danger_no_of_jobs * 2) - STOP_AMG_THRESHOLD - DIRS_IN_FILE_DIR)))
              {
                 (void)fprintf(output,
                               "<td align=\"right\" valign=\"middle\" style=\"background-color:%s; color:%s\">%s</td>\n",
                               color_pool[(int)NOT_WORKING2], color_pool[(int)WHITE],
                               str_jq);
              }
              else
              {
                 (void)fprintf(output,
                               "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n",
                               color_pool[(int)CHAR_BACKGROUND], str_jq);
              }
         CREATE_JQ_STRING(str_at, msa[j].no_of_transfers);
         (void)fprintf(output, "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n", color_pool[(int)CHAR_BACKGROUND], str_at);
         CREATE_EC_STRING(str_ec, msa[j].ec);
         if (msa[j].ec > 0)
         {
            (void)fprintf(output, "<td align=\"right\" valign=\"middle\" style=\"background-color:%s; color:%s\">%s</td>\n",
                          color_pool[(int)CHAR_BACKGROUND],
                          color_pool[(int)NOT_WORKING2], str_ec);
         }
         else
         {
            (void)fprintf(output,
                          "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n",
                          color_pool[(int)CHAR_BACKGROUND], str_ec);
         }
         CREATE_EC_STRING(str_hec, msa[j].host_error_counter);
         if (msa[j].host_error_counter > 0)
         {
            (void)fprintf(output,
                          "<td align=\"right\" valign=\"middle\" style=\"background-color:%s; color:%s\">%s</td>\n",
                          color_pool[(int)NOT_WORKING2], color_pool[(int)WHITE],
                          str_hec);
         }
         else
         {
            (void)fprintf(output, "<td align=\"right\" valign=\"middle\" bgcolor=\"%s\">%s</td>\n",
                          color_pool[(int)CHAR_BACKGROUND], str_hec);
         }
         (void)fprintf(output, "</tr>\n");
      }
      (void)fprintf(output, "</table>\n</body>\n</html>\n");

      if (interval > 0)
      {
         if (flush_output == YES)
         {
            (void)fflush(output);
         }
         (void)sleep(interval);
         if (flush_output == YES)
         {
            (void)ftruncate(fileno(output), 0);
            (void)fseek(output, 0L, SEEK_SET);
         }
      }
      else
      {
         break;
      }
   }

   exit(SUCCESS);
}