3 * Log and send a zephyrgram about any critical errors.
5 * (c) Copyright 1988-1998 by the Massachusetts Institute of Technology.
6 * For copying and distribution information, please see the file
12 /* need to include before moira.h, which includes krb_et.h, because
14 #include <zephyr/zephyr.h>
15 /* zephyr.h doesn't prototype this */
16 extern Code_t ZSendNotice(ZNotice_t *notice, Z_AuthProc cert_routine);
19 #include <mit-copyright.h>
21 #include <moira_site.h>
31 /* mode to create the file with */
32 #define LOGFILEMODE 0644
36 /* This routine sends a class MOIRA zephyrgram of specified instance
37 * and logs to a special logfile the message passed to it via msg
38 * and args in printf format. *** It expects the global variable
39 * whoami to be defined and contain the name of the calling program.
42 void critical_alert(char *instance, char *msg, ...)
44 FILE *crit; /* FILE for critical log file */
45 char buf[BUFSIZ]; /* Holds the formatted message */
49 vsprintf(buf, msg, ap);
52 /* Send zephyr notice */
53 send_zgram(instance, buf);
55 /* Log message to critical file */
56 if ((crit = fopen(CRITERRLOG, "a")))
62 time_s = ctime(&t) + 4;
63 time_s[strlen(time_s) - 6] = '\0';
65 fprintf(crit, "%s <%ld> %s\n", time_s, (long)getpid(), buf);
69 com_err(whoami, 0, buf);
74 /* Sends a zephyrgram of class "MOIRA", instance as a parameter. Ignores
75 * errors while sending message.
78 void send_zgram(char *inst, char *msg)
83 memset(&znotice, 0, sizeof(znotice));
84 znotice.z_kind = UNSAFE;
85 znotice.z_class = "MOIRA";
86 znotice.z_class_inst = inst;
87 znotice.z_default_format = "MOIRA $instance on $fromhost:\n $message\n";
89 znotice.z_message = msg;
90 znotice.z_message_len = strlen(msg) + 1;
91 znotice.z_opcode = "";
92 znotice.z_recipient = "";
93 ZSendNotice(&znotice, ZNOAUTH);
98 sprintf(buf, "MOIRA: %s %s", inst, msg);