#include <afsconfig.h>
#include <afs/param.h>
-RCSID
- ("$Header$");
#include <stdio.h>
#include <math.h>
#undef IN
#include <sys/types.h>
#include <netinet/in.h>
-#ifndef AFS_DEC_ENV
#include <sys/socket.h>
#include <netdb.h>
-#endif
#include <ctype.h>
#include <gtxwindows.h> /*Generic window package */
#include <gtxobjects.h> /*Object definitions */
-#if 0
-#include <gtxtextobj.h> /*Text object interface */
-#endif
#include <gtxlightobj.h> /*Light object interface */
#include <gtxcurseswin.h> /*Curses window package */
#include <gtxdumbwin.h> /*Dumb terminal window package */
#include <gtxX11win.h> /*X11 window package */
#include <gtxframe.h> /*Frame package */
-
-
+#include <gtxinput.h>
#include <afs/xstat_fs.h>
#include <afs/xstat_cm.h>
-
#include "afsmonitor.h"
-
/* command line parameter indices */
#define P_CONFIG 0
/* names of the last host processed in the config file */
static char last_fsHost[HOST_NAME_LEN];
static char last_cmHost[HOST_NAME_LEN];
-static lastHostType = 0; /* 0 = no host entries processed
+static int lastHostType = 0; /* 0 = no host entries processed
* 1 = last host was file server
* 2 = last host was cache manager. */
/* for previous probe cycle */
struct cm_Display_Data *prev_cmData = (struct cm_Display_Data *)0;
-
/* EXTERN DEFINITIONS */
-extern struct hostent *hostutil_GetHostByName();
-
-
-
-/* routines from afsmon-output.c */
-extern int afsmon_fsOutput();
-extern int afsmon_cmOutput();
-
/* file server and cache manager variable names (from afsmon_labels.h) */
extern char *fs_varNames[];
extern char *cm_varNames[];
/* flag to indicate that atleast one probe cycle has completed and
data is available for updating the display */
-extern fs_Data_Available;
-extern cm_Data_Available;
+extern int fs_Data_Available;
+extern int cm_Data_Available;
extern int gtx_initialized; /* gtx initialized ? */
-#if !defined(AFS_FBSD_ENV) && !defined(AFS_DARWIN70_ENV) && !defined(AFS_NBSD20_ENV)
+#ifdef HAVE_STRCASESTR
+extern char * strcasestr(const char *, const char *);
+#else
/*
strcasestr(): Return first occurence of pattern s2 in s1, case
insensitive.
#endif
struct hostent *
-GetHostByName(name)
- char *name;
+GetHostByName(char *name)
{
struct hostent *he;
#ifdef AFS_SUN5_ENV
*----------------------------------------------------------------------*/
int
-afsmon_Exit(a_exitVal)
- int a_exitVal; /* exit code */
+afsmon_Exit(int a_exitVal) /* exit code */
{ /* afsmon_Exit */
static char rn[] = "afsmon_Exit";
struct afsmon_fs_Results_list *tmp_fslist;
*----------------------------------------------------------------------*/
int
-insert_FS(a_hostName)
- char *a_hostName; /* name of cache manager to be inserted in list */
+insert_FS(char *a_hostName) /* name of cache manager to be inserted in list */
{ /* insert_FS() */
- static char rn[] = "insert_FS"; /* routine name */
static struct afsmon_hostEntry *curr_item;
static struct afsmon_hostEntry *prev_item;
* Nothing.
*----------------------------------------------------------------------*/
void
-print_FS()
+print_FS(void)
{ /* print_FS() */
static char rn[] = "print_FS";
struct afsmon_hostEntry *tempFS;
*----------------------------------------------------------------------*/
int
-insert_CM(a_hostName)
- char *a_hostName; /* name of cache manager to be inserted in list */
+insert_CM(char *a_hostName) /* name of cache manager to be inserted in list */
{ /* insert_CM */
- static char rn[] = "insert_CM"; /* routine name */
static struct afsmon_hostEntry *curr_item;
static struct afsmon_hostEntry *prev_item;
* Nothing.
*----------------------------------------------------------------------*/
int
-print_CM()
+print_CM(void)
{ /* print_CM() */
static char rn[] = "print_CM";
struct afsmon_hostEntry *tempCM;
*----------------------------------------------------------------------*/
int
-parse_hostEntry(a_line)
- char *a_line;
+parse_hostEntry(char *a_line)
{ /* parse_hostEntry */
static char rn[] = "parse_hostEntry"; /* routine name */
*----------------------------------------------------------------------*/
int
-parse_threshEntry(a_line)
- char *a_line;
+parse_threshEntry(char *a_line)
{ /* parse_threshEntry */
static char rn[] = "parse_threshEntry"; /* routine name */
char opcode[CFG_STR_LEN]; /* specifies type of config entry */
*----------------------------------------------------------------------*/
int
-store_threshold(a_type, a_varName, a_value, a_handler)
- int a_type; /* 1 = fs , 2 = cm */
- char *a_varName; /* threshold name */
- char *a_value; /* threshold value */
- char *a_handler; /* threshold overflow handler */
-
+store_threshold(int a_type, /* 1 = fs , 2 = cm */
+ char *a_varName, /* threshold name */
+ char *a_value, /* threshold value */
+ char *a_handler) /* threshold overflow handler */
{ /* store_thresholds */
static char rn[] = "store_thresholds"; /* routine name */
*----------------------------------------------------------------------*/
int
-parse_showEntry(a_line)
- char *a_line;
+parse_showEntry(char *a_line)
{ /* parse_showEntry */
static char rn[] = "parse_showEntry";
char opcode[CFG_STR_LEN]; /* specifies type of config entry */
idx++;
numGroups--;
} /* for each group in section */
-
-
-
-
-
-
} else { /* it is a variable name */
for (i = 0; i < NUM_CM_STAT_ENTRIES; i++) {
}
/* it is an cm entry */
return (0);
-
-
} /* parse_showEntry */
*----------------------------------------------------------------------*/
int
-process_config_file(a_config_filename)
- char *a_config_filename;
+process_config_file(char *a_config_filename)
{ /* process_config_file() */
static char rn[] = "process_config_file"; /* routine name */
FILE *configFD; /* config file descriptor */
*----------------------------------------------------------------------*/
void
-Print_FS_CB()
+Print_FS_CB(void)
{ /* Print_FS_CB() */
struct afsmon_fs_Results_list *fslist;
* Failure: Exits afsmonitor.
*----------------------------------------------------------------------*/
int
-save_FS_results_inCB(a_newProbeCycle)
- int a_newProbeCycle; /* start of a new probe cycle ? */
-
+save_FS_results_inCB(int a_newProbeCycle) /* start of a new probe cycle ? */
{ /* save_FS_results_inCB() */
static char rn[] = "save_FS_results_inCB"; /* routine name */
struct afsmon_fs_Results_list *tmp_fslist_item; /* temp fs list item */
*----------------------------------------------------------------------*/
int
-fs_Results_ltoa(a_fsData, a_fsResults)
- struct fs_Display_Data *a_fsData; /* target buffer */
- struct xstat_fs_ProbeResults *a_fsResults; /* ptr to xstat fs Results */
+fs_Results_ltoa(struct fs_Display_Data *a_fsData, /* target buffer */
+ struct xstat_fs_ProbeResults *a_fsResults) /* ptr to xstat fs Results */
{ /* fs_Results_ltoa */
static char rn[] = "fs_Results_ltoa"; /* routine name */
afs_int32 *tmpbuf;
if (afsmon_debug) {
- fprintf(debugFD, "[ %s ] Called, a_fsData= %d, a_fsResults= %d\n", rn,
+ fprintf(debugFD, "[ %s ] Called, a_fsData= %p, a_fsResults= %p\n", rn,
a_fsData, a_fsResults);
fflush(debugFD);
}
*----------------------------------------------------------------------*/
int
-execute_thresh_handler(a_handler, a_hostName, a_hostType, a_threshName,
- a_threshValue, a_actValue)
- char *a_handler; /* ptr to handler function + args */
- char *a_hostName; /* host name for which threshold crossed */
- int a_hostType; /* fs or cm ? */
- char *a_threshName; /* threshold variable name */
- char *a_threshValue; /* threshold value */
- char *a_actValue; /* actual value */
-
+execute_thresh_handler(char *a_handler, /* ptr to handler function + args */
+ char *a_hostName, /* host name for which threshold crossed */
+ int a_hostType, /* fs or cm ? */
+ char *a_threshName, /* threshold variable name */
+ char *a_threshValue, /* threshold value */
+ char *a_actValue) /* actual value */
{ /* execute_thresh_handler */
static char rn[] = "execute_thresh_handler";
*----------------------------------------------------------------------*/
int
-check_fs_thresholds(a_hostEntry, a_Data)
- struct afsmon_hostEntry *a_hostEntry; /* ptr to hostEntry */
- struct fs_Display_Data *a_Data; /* ptr to fs data to be displayed */
-
+check_fs_thresholds(struct afsmon_hostEntry *a_hostEntry, /* ptr to hostEntry */
+ struct fs_Display_Data *a_Data) /* ptr to fs data to be displayed */
{ /* check_fs_thresholds */
static char rn[] = "check_fs_thresholds";
int count; /* number of thresholds exceeded */
if (afsmon_debug) {
- fprintf(debugFD, "[ %s ] Called, a_hostEntry= %d, a_Data= %d\n", rn,
+ fprintf(debugFD, "[ %s ] Called, a_hostEntry= %p, a_Data= %p\n", rn,
a_hostEntry, a_Data);
fflush(debugFD);
}
*----------------------------------------------------------------------*/
int
-save_FS_data_forDisplay(a_fsResults)
- struct xstat_fs_ProbeResults *a_fsResults;
+save_FS_data_forDisplay(struct xstat_fs_ProbeResults *a_fsResults)
{ /* save_FS_data_forDisplay */
static char rn[] = "save_FS_data_forDisplay"; /* routine name */
if (afsmon_debug) {
- fprintf(debugFD, "[ %s ] Called, a_fsResults= %d\n", rn, a_fsResults);
+ fprintf(debugFD, "[ %s ] Called, a_fsResults= %p\n", rn, a_fsResults);
fflush(debugFD);
}
-
-
/* store results in the display array */
okay = 0;
afsmon_Exit(75);
}
-
-
-
/* print the info we just saved */
if (afsmon_debug) {
*----------------------------------------------------------------------*/
int
-afsmon_FS_Handler()
+afsmon_FS_Handler(void)
{ /* afsmon_FS_Handler() */
static char rn[] = "afsmon_FS_Handler"; /* routine name */
int newProbeCycle; /* start of new probe cycle ? */
*----------------------------------------------------------------------*/
void
-Print_CM_CB()
+Print_CM_CB(void)
{ /* Print_CM_CB() */
struct afsmon_cm_Results_list *cmlist;
*----------------------------------------------------------------------*/
int
-save_CM_results_inCB(a_newProbeCycle)
- int a_newProbeCycle; /* start of new probe cycle ? */
-
+save_CM_results_inCB(int a_newProbeCycle) /* start of new probe cycle ? */
{ /* save_CM_results_inCB() */
static char rn[] = "save_CM_results_inCB"; /* routine name */
struct afsmon_cm_Results_list *tmp_cmlist_item; /* temp cm list item */
*----------------------------------------------------------------------*/
int
-cm_Results_ltoa(a_cmData, a_cmResults)
- struct cm_Display_Data *a_cmData; /* target buffer */
- struct xstat_cm_ProbeResults *a_cmResults; /* ptr to xstat cm Results */
+cm_Results_ltoa(struct cm_Display_Data *a_cmData, /* target buffer */
+ struct xstat_cm_ProbeResults *a_cmResults) /* ptr to xstat cm Results */
{ /* cm_Results_ltoa */
static char rn[] = "cm_Results_ltoa"; /* routine name */
afs_int32 numLongs;
if (afsmon_debug) {
- fprintf(debugFD, "[ %s ] Called, a_cmData= %d, a_cmResults= %d\n", rn,
+ fprintf(debugFD, "[ %s ] Called, a_cmData= %p, a_cmResults= %p\n", rn,
a_cmData, a_cmResults);
fflush(debugFD);
}
*----------------------------------------------------------------------*/
int
-check_cm_thresholds(a_hostEntry, a_Data)
- struct afsmon_hostEntry *a_hostEntry; /* ptr to hostEntry */
- struct cm_Display_Data *a_Data; /* ptr to cm data to be displayed */
-
+check_cm_thresholds(struct afsmon_hostEntry *a_hostEntry, /* ptr to hostEntry */
+ struct cm_Display_Data *a_Data) /* ptr to cm data to be displayed */
{ /* check_cm_thresholds */
static char rn[] = "check_cm_thresholds";
int count; /* number of thresholds exceeded */
if (afsmon_debug) {
- fprintf(debugFD, "[ %s ] Called, a_hostEntry= %d, a_Data= %d\n", rn,
+ fprintf(debugFD, "[ %s ] Called, a_hostEntry= %p, a_Data= %p\n", rn,
a_hostEntry, a_Data);
fflush(debugFD);
}
*----------------------------------------------------------------------*/
int
-save_CM_data_forDisplay(a_cmResults)
- struct xstat_cm_ProbeResults *a_cmResults;
+save_CM_data_forDisplay(struct xstat_cm_ProbeResults *a_cmResults)
{ /* save_CM_data_forDisplay */
static char rn[] = "save_CM_data_forDisplay"; /* routine name */
int i;
if (afsmon_debug) {
- fprintf(debugFD, "[ %s ] Called, a_cmResults= %d\n", rn, a_cmResults);
+ fprintf(debugFD, "[ %s ] Called, a_cmResults= %p\n", rn, a_cmResults);
fflush(debugFD);
}
afsmon_Exit(105);
}
-
/* print the info we just saved */
if (afsmon_debug) {
fprintf(debugFD, "\n\t\t ----- CM display data ------\n");
*----------------------------------------------------------------------*/
int
-afsmon_CM_Handler()
+afsmon_CM_Handler(void)
{ /* afsmon_CM_Handler() */
static char rn[] = "afsmon_CM_Handler"; /* routine name */
int code; /* return status */
*----------------------------------------------------------------------*/
int
-init_fs_buffers()
+init_fs_buffers(void)
{ /* init_fs_buffers() */
static char rn[] = "init_fs_buffers"; /* routine name */
struct afsmon_fs_Results_list *new_fslist_item; /* ptr for new struct */
*----------------------------------------------------------------------*/
int
-init_cm_buffers()
+init_cm_buffers(void)
{ /* init_cm_buffers() */
static char rn[] = "init_cm_buffers"; /* routine name */
struct afsmon_cm_Results_list *new_cmlist_item; /* ptr for new struct */
*------------------------------------------------------------------------*/
int
-init_print_buffers()
+init_print_buffers(void)
{ /* init_print_buffers */
static char rn[] = "init_print_buffers"; /* routine name */
}
-
-
/* if file servers to monitor */
/* allocate numCM blocks of the CM print structure */
/* we need two instances of this structure for the same reasons as above */
*----------------------------------------------------------------------*/
void
-quit_signal(sig)
- int sig;
+quit_signal(int sig)
{ /* quit_signal */
- static char *rn = "quit_signal"; /* routine name */
-
fprintf(stderr, "Received signal %d \n", sig);
afsmon_Exit(120);
} /* quit_signal */
*----------------------------------------------------------------------*/
int
-afsmon_execute()
+afsmon_execute(void)
{ /* afsmon_execute() */
static char rn[] = "afsmon_execute"; /* routine name */
static char fullhostname[128]; /* full host name */
}
strncpy(curr_FS->hostName, he->h_name, HOST_NAME_LEN); /* complete name */
memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4);
- curr_skt->sin_family = htons(AF_INET); /*Internet family */
+ curr_skt->sin_family = AF_INET; /*Internet family */
curr_skt->sin_port = htons(7000); /*FileServer port */
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
curr_skt->sin_len = sizeof(struct sockaddr_in);
}
strncpy(curr_CM->hostName, he->h_name, HOST_NAME_LEN); /* complete name */
memcpy(&(curr_skt->sin_addr.s_addr), he->h_addr, 4);
+#if defined(AFS_DARWIN_ENV) || defined(AFS_FBSD_ENV)
+ curr_skt->sin_family = AF_INET; /*Internet family */
+#else
curr_skt->sin_family = htons(AF_INET); /*Internet family */
+#endif
curr_skt->sin_port = htons(7001); /*Cache Manager port */
#ifdef STRUCT_SOCKADDR_HAS_SA_LEN
curr_skt->sin_len = sizeof(struct sockaddr_in);
}
/* start the gtx input server */
- code = gtx_InputServer(afsmon_win);
+ code = (intptr_t)gtx_InputServer(afsmon_win);
if (code) {
fprintf(stderr, "[ %s ] Failed to start input server \n", rn);
afsmon_Exit(140);
*----------------------------------------------------------------------*/
int
-afsmonInit(as)
- struct cmd_syndesc *as;
+afsmonInit(struct cmd_syndesc *as, void *arock)
{ /* afsmonInit() */
static char rn[] = "afsmonInit"; /* Routine name */
int i;
if (afsmon_debug) {
- fprintf(debugFD, "[ %s ] Called, as= %d\n", rn, as);
+ fprintf(debugFD, "[ %s ] Called, as= %p\n", rn, as);
fflush(debugFD);
}
#include "AFS_component_version_number.c"
int
-main(argc, argv)
- int argc;
- char **argv;
+main(int argc, char **argv)
{ /* main() */
-
- static char rn[] = "main"; /* routine name */
afs_int32 code; /*Return code */
struct cmd_syndesc *ts; /*Ptr to cmd line syntax descriptor */
/*
* Set up the commands we understand.
*/
- ts = cmd_CreateSyntax("initcmd", afsmonInit, 0, "initialize the program");
+ ts = cmd_CreateSyntax("initcmd", afsmonInit, NULL, "initialize the program");
cmd_AddParm(ts, "-config", CMD_SINGLE, CMD_OPTIONAL,
"configuration file");
cmd_AddParm(ts, "-frequency", CMD_SINGLE, CMD_OPTIONAL,