]> andersk Git - moira.git/blobdiff - gen/hosts.dc
Send zgrams if the disk usage is over 90% or the quota change, if used, would bring...
[moira.git] / gen / hosts.dc
index 0e396a5f985020eb6065a38f591eb68a5da2b9f2..8119f6e3e99e3e9dae1a511b7bf8019cd0e7d616 100644 (file)
@@ -69,7 +69,13 @@ char **argv;
     EXEC SQL WHENEVER SQLERROR GOTO sqlerr;
 
     gettimeofday(&now, NULL);
-    fprintf(out, "; Host table generated %s;\n", ctime(&now.tv_sec));
+    
+    fprintf(out, "; MIT Network Host Table\n;\n");
+    fprintf(out, "; \t%cAuthor: $\n", '$');
+    fprintf(out, "; \t%cDate: $\n", '$');
+    fprintf(out, "; \t%cRevision: $\n;\n", '$');
+    fprintf(out, "; Host table generated by Moira at %s;\n",
+           ctime(&now.tv_sec));
 
     EXEC SQL DECLARE y CURSOR FOR SELECT
       mach_id, name FROM hostalias;
@@ -78,6 +84,7 @@ char **argv;
     while (1) {
        EXEC SQL FETCH y INTO :id, :name;
        if (sqlca.sqlcode != 0) break;
+       if (id == 0) continue;
        if (*strtrim(name) == 0) continue;
        if ((i = strlen(name)) < 9 || strcmp(&name[i-8], ".MIT.EDU")) {
            fprintf(stderr, "Name %s not in MIT domain\n", name);
@@ -87,8 +94,8 @@ char **argv;
        }
        if (p = hash_lookup(aliases, id)) {
            sprintf(buf, "%s,%s", p, name);
-           free(p);
            hash_update(aliases, id, strsave(buf));
+           free(p);
        } else
          hash_store(aliases, id, strsave(name));
     }
@@ -100,9 +107,9 @@ char **argv;
     while (1) {
        EXEC SQL FETCH x INTO :name, :id, :vendor, :model, :os, :addr;
        if (sqlca.sqlcode != 0) break;
+       if (id == 0) continue;
        if (*strtrim(name) == 0) continue;
        if ((i = strlen(name)) < 9 || strcmp(&name[i-8], ".MIT.EDU")) {
-           fprintf(stderr, "Name %s not in MIT domain\n", name);
            continue;
        } else {
            name[i-8] = 0;
@@ -111,17 +118,20 @@ char **argv;
        strtrim(model);
        strtrim(os);
        strtrim(addr);
-       if (*addr == 0)
+       if (*addr == 0 || inet_addr(addr) == -1)
          continue;
        if (p = hash_lookup(aliases, id))
          sprintf(buf, "%s,%s", name, p);
        else
          strcpy(buf, name);
        fprintf(out, "HOST : %s : %s : ", addr, buf);
-       if (*vendor && *model)
-         fprintf(out, "%s/%s : %s :\n", vendor, model, os);
-       else
-         fprintf(out, "%s%s : %s :\n", vendor, model, os);
+       if ((*vendor || *model) && *os) {
+           if (*vendor && *model)
+             fprintf(out, "%s/%s : %s :\n", vendor, model, os);
+           else
+             fprintf(out, "%s%s : %s :\n", vendor, model, os);
+       } else
+         fputs("\n", out);
     }
 
     EXEC SQL CLOSE x;
@@ -143,6 +153,10 @@ char **argv;
 
  sqlerr:
     com_err(whoami, MR_INGRES_ERR, " code %d\n", sqlca.sqlcode);
+#ifsql INGRES
+    if (sqlca.sqlcode == 17700 || sqlca.sqlcode == -37000)
+      exit(MR_DEADLOCK);
+#endsql
     critical_alert("DCM", "Hosts build encountered INGRES ERROR %d",
                   sqlca.sqlcode);
     exit(MR_INGRES_ERR);
This page took 0.033349 seconds and 4 git commands to generate.