adding zephyr-im master branch

This commit is contained in:
2022-07-25 09:01:27 -06:00
parent 61f5ed8f01
commit ee1236fa5c
311 changed files with 62265 additions and 0 deletions

56
clients/zstat/Makefile.in Normal file
View File

@ -0,0 +1,56 @@
SHELL=@SHELL@
prefix=@prefix@
exec_prefix=@exec_prefix@
datadir=@datadir@
sysconfdir=@sysconfdir@
sbindir=@sbindir@
lsbindir=@lsbindir@
datarootdir=@datarootdir@
includedir=@includedir@
mandir=@mandir@
libdir=@libdir@
bindir=@bindir@
top_builddir=../..
srcdir=@srcdir@
top_srcdir=@top_srcdir@
BUILDTOP=../..
VPATH=@srcdir@
LIBTOOL=@LIBTOOL@
CC=@CC@
INSTALL=@INSTALL@
LIBZEPHYR=${BUILDTOP}/lib/libzephyr.la
CPPFLAGS=@CPPFLAGS@
CFLAGS=@CFLAGS@
ALL_CFLAGS=${CFLAGS} -I${top_srcdir}/h -I${BUILDTOP}/h ${CPPFLAGS}
LDFLAGS=@LDFLAGS@
LIBS=${LIBZEPHYR} @LIBS@ -lcom_err
OBJS= zstat.o
all: zstat
zstat: ${OBJS} ${LIBZEPHYR}
${LIBTOOL} --mode=link ${CC} ${LDFLAGS} -o $@ ${OBJS} ${LIBS}
.c.o:
${CC} -c ${ALL_CFLAGS} $<
check:
install: zstat
${LIBTOOL} --mode=install ${INSTALL} -m 755 zstat ${DESTDIR}${bindir}
${INSTALL} -m 644 ${srcdir}/zstat.8 ${DESTDIR}${mandir}/man8
clean:
${LIBTOOL} --mode=clean rm -f zstat
rm -f ${OBJS}
${OBJS}: zserver.h ${top_srcdir}/h/sysdep.h ${BUILDTOP}/h/config.h
${OBJS}: ${BUILDTOP}/h/zephyr/zephyr.h ${BUILDTOP}/h/zephyr/zephyr_err.h
.PHONY: all check install clean

26
clients/zstat/zserver.h Normal file
View File

@ -0,0 +1,26 @@
#ifndef __ZSERVER_H__
#define __ZSERVER_H__
/* This file is part of the Project Athena Zephyr Notification System.
* It contains declarations for use in the server.
*
* Created by: John T. Kohl
*
* $Id$
*
* Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
* "mit-copyright.h".
*/
#define ADMIN_HELLO "HELLO" /* Opcode: hello, are you there */
#define ADMIN_IMHERE "IHEARDYOU" /* Opcode: yes, I am here */
#define ADMIN_SHUTDOWN "GOODBYE" /* Opcode: I am shutting down */
#define ADMIN_BDUMP "DUMP_AVAIL" /* Opcode: I will give you a dump */
#define ADMIN_DONE "DUMP_DONE" /* Opcode: brain dump for this server
is complete */
#define ADMIN_NEWCLT "NEXT_CLIENT" /* Opcode: this is a new client */
#define ADMIN_LOST_CLT "LOST_CLIENT" /* Opcode: client not ack'ing */
#define ADMIN_KILL_CLT "KILL_CLIENT" /* Opcode: client is dead, remove */
#define ADMIN_STATUS "STATUS" /* Opcode: please send status */
#endif /* !__ZSERVER_H__ */

51
clients/zstat/zstat.8 Normal file
View File

@ -0,0 +1,51 @@
.\" $Id$
.\"
.\" Copyright 1987,1988 by the Massachusetts Institute of Technology
.\" All rights reserved. The file /usr/include/zephyr/mit-copyright.h
.\" specifies the terms and conditions for redistribution.
.\"
.\"
.TH ZSTAT 8 "July 1, 1988" "MIT Project Athena"
.ds ]W MIT Project Athena
.SH NAME
zstat \- display Zephyr statistics
.SH SYNOPSIS
.B zstat
[
.BI -h
] [
.BI -s
] [
.BI host \ ...
]
.SH DESCRIPTION
.I Zstat
is used to display statistics reported by a HostManager,
.I zhm(8),
or a Zephyr Server
.I zephyrd(8),
or both.
.TP 12
.B \-h
is used to indicate that only HostManager statistics should be displayed.
.TP
.B \-s
is used to indicate that only server statistics should be displayed.
.TP
If no hosts are specified, the current host is assumed.
When both HostManager and server statistics are displayed,
statistics from the current server for each host are displayed.
.SH SEE ALSO
zephyr(1), zhm(8), zephyrd(8)
.br
Project Athena Technical Plan Section E.4.1, `Zephyr Notification
Service'
.SH AUTHOR
.PP
David C. Jedlinsky (MIT-Project Athena)
.SH RESTRICTIONS
Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
All Rights Reserved.
.br
.I zephyr(1)
specifies the terms and conditions for redistribution.

312
clients/zstat/zstat.c Normal file
View File

@ -0,0 +1,312 @@
/* This file is part of the Project Athena Zephyr Notification System.
* It contains the zstat program.
*
* Created by: David C. Jedlinsky
*
* $Id$
*
* Copyright (c) 1987,1988 by the Massachusetts Institute of Technology.
* For copying and distribution information, see the file
* "mit-copyright.h".
*/
/* There should be library interfaces for the operations in zstat; for now,
* however, zstat is more or less internal to the Zephyr system. */
#include <internal.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <arpa/nameser.h>
#include "zserver.h"
#if !defined(lint) && !defined(SABER)
static const char rcsid_zstat_c[] = "$Id$";
#endif
const char *hm_head[] = {
"Current server =",
"Items in queue:",
"Client packets received:",
"Server packets received:",
"Server changes:",
"Version:",
"Looking for a new server:",
"Time running:",
"Size:",
"Machine type:"
};
#define HM_SIZE (sizeof(hm_head) / sizeof (char *))
const char *srv_head[] = {
"Current server version =",
"Packets handled:",
"Uptime:",
"Server states:",
};
#define SRV_SIZE (sizeof(srv_head) / sizeof (char *))
int outoftime = 0;
int serveronly = 0,hmonly = 0;
u_short srv_port;
void usage(char *);
void do_stat(char *);
int srv_stat(char *);
int hm_stat(char *, char *);
static RETSIGTYPE
timeout(int ignored)
{
outoftime = 1;
}
int
main(int argc,
char *argv[])
{
Code_t ret;
char hostname[NS_MAXDNAME];
int optchar;
struct servent *sp;
if ((ret = ZInitialize()) != ZERR_NONE) {
com_err("zstat", ret, "initializing");
exit(-1);
}
if ((ret = ZOpenPort((u_short *)0)) != ZERR_NONE) {
com_err("zstat", ret, "opening port");
exit(-1);
}
while ((optchar = getopt(argc, argv, "sh")) != EOF) {
switch(optchar) {
case 's':
serveronly++;
break;
case 'h':
hmonly++;
break;
case '?':
default:
usage(argv[0]);
exit(1);
}
}
if (serveronly && hmonly) {
fprintf(stderr,"Only one of -s and -h may be specified\n");
exit(1);
}
sp = getservbyname(SERVER_SVCNAME,"udp");
srv_port = (sp) ? sp->s_port : SERVER_SVC_FALLBACK;
if (optind == argc) {
do_stat("127.0.0.1");
exit(0);
}
for (;optind<argc;optind++)
do_stat(argv[optind]);
exit(0);
}
void
do_stat(char *host)
{
char srv_host[NS_MAXDNAME];
if (serveronly) {
(void) srv_stat(host);
return;
}
if (hm_stat(host,srv_host))
return;
if (!hmonly)
(void) srv_stat(srv_host);
}
int
hm_stat(char *host,
char *server)
{
struct in_addr inaddr;
Code_t code;
char *line[20],*mp;
unsigned int i,nf;
struct hostent *hp;
time_t runtime;
struct tm *tim;
ZNotice_t notice;
if ((inaddr.s_addr = inet_addr(host)) == (unsigned)(-1)) {
if ((hp = gethostbyname(host)) == NULL) {
fprintf(stderr,"Unknown host: %s\n",host);
exit(-1);
}
(void) memcpy((char *) &inaddr, hp->h_addr, hp->h_length);
printf("Hostmanager stats: %s\n", hp->h_name);
} else {
printf("Hostmanager stats: %s\n", host);
}
if ((code = ZhmStat(&inaddr, &notice)) != ZERR_NONE) {
com_err("zstat", code, "getting hostmanager status");
exit(-1);
}
mp = notice.z_message;
for (nf=0;mp<notice.z_message+notice.z_message_len;nf++) {
line[nf] = mp;
mp += strlen(mp)+1;
}
(void) strcpy(server,line[0]);
printf("HostManager protocol version = %s\n",notice.z_version);
for (i=0; (i < nf) && (i < HM_SIZE); i++) {
if (!strncmp("Time",hm_head[i],4)) {
runtime = atol(line[i]);
tim = gmtime(&runtime);
printf("%s %d days, %02d:%02d:%02d\n", hm_head[i],
tim->tm_yday,
tim->tm_hour,
tim->tm_min,
tim->tm_sec);
}
else
printf("%s %s\n",hm_head[i],line[i]);
}
printf("\n");
ZFreeNotice(&notice);
return(0);
}
int
srv_stat(char *host)
{
char *line[20],*mp;
int sock,i,nf,ret;
struct hostent *hp;
struct sockaddr_in sin;
ZNotice_t notice;
time_t runtime;
struct tm *tim;
#ifdef _POSIX_VERSION
struct sigaction sa;
#endif
(void) memset((char *) &sin, 0, sizeof(struct sockaddr_in));
sin.sin_port = srv_port;
if ((sock = socket(PF_INET, SOCK_DGRAM, 0)) < 0) {
perror("socket:");
exit(-1);
}
sin.sin_family = AF_INET;
if ((sin.sin_addr.s_addr = inet_addr(host)) == (unsigned)(-1)) {
if ((hp = gethostbyname(host)) == NULL) {
fprintf(stderr,"Unknown host: %s\n",host);
exit(-1);
}
(void) memcpy((char *) &sin.sin_addr, hp->h_addr, hp->h_length);
printf("Server stats: %s\n", hp->h_name);
} else {
printf("Server stats: %s\n", host);
}
(void) memset((char *)&notice, 0, sizeof(notice));
notice.z_kind = UNSAFE;
notice.z_port = 0;
notice.z_charset = ZCHARSET_UNKNOWN;
notice.z_class = ZEPHYR_ADMIN_CLASS;
notice.z_class_inst = "";
notice.z_opcode = ADMIN_STATUS;
notice.z_sender = "";
notice.z_recipient = "";
notice.z_default_format = "";
notice.z_message_len = 0;
if ((ret = ZSetDestAddr(&sin)) != ZERR_NONE) {
com_err("zstat", ret, "setting destination");
exit(-1);
}
if ((ret = ZSendNotice(&notice, ZNOAUTH)) != ZERR_NONE) {
com_err("zstat", ret, "sending notice");
exit(-1);
}
#ifdef _POSIX_VERSION
sigemptyset(&sa.sa_mask);
sa.sa_flags = 0;
sa.sa_handler = timeout;
(void) sigaction(SIGALRM, &sa, (struct sigaction *)0);
#else
(void) signal(SIGALRM,timeout);
#endif
outoftime = 0;
(void) alarm(10);
if (((ret = ZReceiveNotice(&notice, (struct sockaddr_in *) 0))
!= ZERR_NONE) &&
ret != EINTR) {
com_err("zstat", ret, "receiving notice");
return (1);
}
(void) alarm(0);
if (outoftime) {
fprintf(stderr,"No response after 10 seconds.\n");
return (1);
}
mp = notice.z_message;
for (nf=0;mp<notice.z_message+notice.z_message_len;nf++) {
line[nf] = mp;
mp += strlen(mp)+1;
}
printf("Server protocol version = %s\n",notice.z_version);
for (i=0; i < nf; i++) {
if (i < 2)
printf("%s %s\n",srv_head[i],line[i]);
else if (i == 2) { /* uptime field */
runtime = atol(line[i]);
tim = gmtime(&runtime);
printf("%s %d days, %02d:%02d:%02d\n",
srv_head[i],
tim->tm_yday,
tim->tm_hour,
tim->tm_min,
tim->tm_sec);
} else if (i == 3) {
printf("%s\n",srv_head[i]);
printf("%s\n",line[i]);
} else printf("%s\n",line[i]);
}
printf("\n");
(void) close(sock);
ZFreeNotice(&notice);
return(0);
}
void
usage(char *s)
{
fprintf(stderr,"usage: %s [-s] [-h] [host ...]\n",s);
exit(1);
}