1 /* If KEYQUIT is set, hitting q or Q in the window will cause xsysstats to 2 * exit. 3 * I personally don't like the idea of Q exiting the program - many times 4 * I find I moved my mouse pointer to the wrong place, and I certainly don't 5 * want XSysStats exiting because of that. However, if you are using click 6 * to focus, or are expirementing, this might not be bad. 7 */ 8 9 /*#define KEYQUIT*/ 10 11 #define USE_NEW_RSTAT 12 13 #include <X11/Xlib.h> 14 #include <X11/Xutil.h> 15 #include <stdio.h> 16 #include <sys/param.h> 17 18 #include <stdlib.h> 19 #include <string.h> 20 #include <unistd.h> 21 #include <netdb.h> 22 #include <rpcsvc/rstat.h> 23 24 #ifdef USE_NEW_RSTAT 25 #include <rpc/rpc.h> 26 #endif 27 28 /* If this hasn't been set, then set it. 64 is the value on sunos 4.1.1 29 * systems - hopefully, this is a sane value for other systems that 30 * lack a definition 31 */ 32 33 #ifndef MAXHOSTNAMELEN 34 #define MAXHOSTNAMELEN 64 35 #endif 36 37 /* Font is a nice small font. */ 38 #define FONT "-adobe-times-medium-r-normal--10-100-75-75-p-54-iso8859-1" 39 #define DEFAULT_SIZE 64 /* default width & height of the window */ 40 #define TEXT_WIDTH 60 /* How many pixels (width) is the minimum 41 * to display the text at the bottom. 42 * Number is sort of arbitrarily chosen. 43 * It must be less than DEFAULT_SIZE however. 44 */ 45 #define PTSSCALELINE 5 /* If scale lines (by -scale arguement) 46 * are closer than this many pixels together, 47 * fewer scale lines are drawn. If you always 48 * want scale lines drawn, even if they are 49 * right next to each other, set this to 0. 50 * If the lines would be within this range, 51 * -scale value is doubled, then quadrapuled, 52 * and so on until it it can be drawn properly. 53 */ 54 55 enum Report_Types { CPU, PACKETS, PAGEI, SWAPI, INT, DISK, CONTEXT, LOAD1, 56 LOAD5, LOAD15, COLL, ERRORS, IPACKETS, OPACKETS, APAGEI, APAGEO, PAGEO, 57 PAGE, SWAPO, SWAP, UCPU, NICECPU, SCPU, ICPU, 58 /* NUM_TYPES should always be the last element. */ 59 NUM_TYPES}; 60 61 #define INSIDE_BORDER_WIDTH 1 /* Default spacing between the 62 * edge of the window and the 63 * graphs, as well as how much 64 * space between windows in 65 * -split mode. 66 */ 67 #define DOWNSCALE_OCCURANCE 30 /* How many ticks between each 68 * downscale attempt */ 69 #define LOAD_FACTOR 100 /* internal representation of load is 70 * this many times bigger */ 71 72 #ifndef TRUE 73 #define TRUE 1 74 #endif 75 #ifndef FALSE 76 #define FALSE 0 77 #endif 78 79 struct graph_info { 80 int scale,true_scale; /* true_scale is the scale that would 81 * be used if this graph was not 82 * synced with another graph. 83 */ 84 int link; /* This points to the position in the 85 * graphs array that this graph is 86 * linked to. If it points to its 87 * own position, it is not linked. 88 * linking means the graphs keep 89 * the same scale. 90 */ 91 enum Report_Types type; 92 unsigned long color_pixel; 93 char name[MAXHOSTNAMELEN + 10]; 94 short name_len; 95 int max_scale; 96 int min_scale; 97 int scale_mult; /* How much to multiply the 98 * scale by for it to correspond 99 * to the point values. This is used 100 * only for load to give good 101 * resolution. 102 */ 103 int scale_lines; /* Dashed horizontal lines. will be 104 * drawn at the value this variable 105 * holds. Ie, if this is 32, and the 106 * scale of the graph is 64, there will 107 * be 1 line in the center of the window. 108 * if the scale is 128, there will be 109 * 3 lines, equally spaced. 110 */ 111 int running_avg; /* use this as a guide for re-sizes */ 112 short host_offset; 113 short window; /* What window to put this graph in */ 114 int max_val; /* maximum value this graph ever reached */ 115 }; 116 117 extern struct graph_info *graphs; 118 119 struct Xss_Window { 120 short x, y; /* Upper left corner of window */ 121 short width,height; /* width and height of the window. height 122 * is the space available for the graph - 123 * label lines are taken into consideration 124 * when computing this value. 125 */ 126 short label_lines; /* how many lines are needed to print out */ 127 /* the graph labels */ 128 short num_graphs; /* Number of graphs in this window */ 129 char redraw_needed; /* This window needs to be redrawn because 130 * of graph rescaling 131 */ 132 short xpos; /* Drawing position of this window */ 133 char *title; /* Title to use in minimal mode */ 134 }; 135 136 struct Host_Info { 137 char *name; /*Name of the host */ 138 #ifdef USE_NEW_RSTAT 139 CLIENT *client; /* client connection for rstat */ 140 #endif /* USE_NEW_RSTAT */ 141 }; 142 143 extern struct Xss_Window **windows; 144 extern struct Host_Info *hosts; 145 146 extern int num_hosts,point_pos,num_graphs,**points,sleep_time, 147 hide_labels,split_width, graph_spacing; 148 149 void set_first_values(); 150 void set_values(); 151