17836SJohn.Forte@Sun.COM /*
27836SJohn.Forte@Sun.COM * CDDL HEADER START
37836SJohn.Forte@Sun.COM *
47836SJohn.Forte@Sun.COM * The contents of this file are subject to the terms of the
57836SJohn.Forte@Sun.COM * Common Development and Distribution License (the "License").
67836SJohn.Forte@Sun.COM * You may not use this file except in compliance with the License.
77836SJohn.Forte@Sun.COM *
87836SJohn.Forte@Sun.COM * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
97836SJohn.Forte@Sun.COM * or http://www.opensolaris.org/os/licensing.
107836SJohn.Forte@Sun.COM * See the License for the specific language governing permissions
117836SJohn.Forte@Sun.COM * and limitations under the License.
127836SJohn.Forte@Sun.COM *
137836SJohn.Forte@Sun.COM * When distributing Covered Code, include this CDDL HEADER in each
147836SJohn.Forte@Sun.COM * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
157836SJohn.Forte@Sun.COM * If applicable, add the following below this CDDL HEADER, with the
167836SJohn.Forte@Sun.COM * fields enclosed by brackets "[]" replaced with your own identifying
177836SJohn.Forte@Sun.COM * information: Portions Copyright [yyyy] [name of copyright owner]
187836SJohn.Forte@Sun.COM *
197836SJohn.Forte@Sun.COM * CDDL HEADER END
207836SJohn.Forte@Sun.COM */
21*11576SSurya.Prakki@Sun.COM
227836SJohn.Forte@Sun.COM /*
23*11576SSurya.Prakki@Sun.COM * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
247836SJohn.Forte@Sun.COM * Use is subject to license terms.
257836SJohn.Forte@Sun.COM */
267836SJohn.Forte@Sun.COM
277836SJohn.Forte@Sun.COM #include <errno.h>
287836SJohn.Forte@Sun.COM #include <stdio.h>
297836SJohn.Forte@Sun.COM #include <unistd.h>
307836SJohn.Forte@Sun.COM #include <strings.h>
317836SJohn.Forte@Sun.COM #include <stdlib.h>
327836SJohn.Forte@Sun.COM
337836SJohn.Forte@Sun.COM #include <sys/types.h>
347836SJohn.Forte@Sun.COM #include <sys/time.h>
357836SJohn.Forte@Sun.COM #include <sys/nsctl/sdbc_ioctl.h>
367836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_ioctl.h>
377836SJohn.Forte@Sun.COM #include <sys/nsctl/sd_bcache.h>
387836SJohn.Forte@Sun.COM #include <sys/nsctl/sd_conf.h>
397836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_io.h>
407836SJohn.Forte@Sun.COM #include <sys/nsctl/rdc_bitmap.h>
417836SJohn.Forte@Sun.COM #include <sys/unistat/spcs_s_u.h>
427836SJohn.Forte@Sun.COM #include <curses.h>
437836SJohn.Forte@Sun.COM
447836SJohn.Forte@Sun.COM static rdc_status_t *rdc_status;
457836SJohn.Forte@Sun.COM static rdc_u_info_t *rdc_info;
467836SJohn.Forte@Sun.COM static int rdc_maxsets;
477836SJohn.Forte@Sun.COM static int rdc_enabled_sets;
487836SJohn.Forte@Sun.COM
497836SJohn.Forte@Sun.COM static unsigned prev_time, delta_time;
507836SJohn.Forte@Sun.COM #ifdef m88k
517836SJohn.Forte@Sun.COM extern unsigned *usec_ptr;
527836SJohn.Forte@Sun.COM #endif
537836SJohn.Forte@Sun.COM static int bright = 0;
547836SJohn.Forte@Sun.COM
557836SJohn.Forte@Sun.COM extern int sdbc_max_devices;
567836SJohn.Forte@Sun.COM
577836SJohn.Forte@Sun.COM extern _sd_stats_t *cs_cur;
587836SJohn.Forte@Sun.COM extern _sd_stats_t *cs_prev;
597836SJohn.Forte@Sun.COM extern _sd_stats_t *cs_persec;
607836SJohn.Forte@Sun.COM
617836SJohn.Forte@Sun.COM extern int *on_off;
627836SJohn.Forte@Sun.COM extern int *dual_on_off;
637836SJohn.Forte@Sun.COM extern int *updates_prev;
647836SJohn.Forte@Sun.COM extern double *rate_prev;
657836SJohn.Forte@Sun.COM extern int *samples;
667836SJohn.Forte@Sun.COM
677836SJohn.Forte@Sun.COM int range_num = 0;
687836SJohn.Forte@Sun.COM int screen = 0;
697836SJohn.Forte@Sun.COM int dual_screen = 0;
707836SJohn.Forte@Sun.COM static int rnum = 0;
717836SJohn.Forte@Sun.COM
727836SJohn.Forte@Sun.COM typedef struct {
737836SJohn.Forte@Sun.COM int lb, ub;
747836SJohn.Forte@Sun.COM } range_t;
757836SJohn.Forte@Sun.COM range_t ranges[100];
767836SJohn.Forte@Sun.COM
777836SJohn.Forte@Sun.COM extern int range_first();
787836SJohn.Forte@Sun.COM extern int range_next(int);
797836SJohn.Forte@Sun.COM extern int range_last();
807836SJohn.Forte@Sun.COM
817836SJohn.Forte@Sun.COM static int dual_initted = 0;
827836SJohn.Forte@Sun.COM static char status[11][30];
837836SJohn.Forte@Sun.COM
847836SJohn.Forte@Sun.COM unsigned dc_delta_time, dc_prev_time;
857836SJohn.Forte@Sun.COM
867836SJohn.Forte@Sun.COM #ifdef m88k
877836SJohn.Forte@Sun.COM #define USEC_INIT() usec_ptr = (unsigned int *)timer_init()
887836SJohn.Forte@Sun.COM #define USEC_READ() (*usec_ptr)
897836SJohn.Forte@Sun.COM #else /* !m88k */
907836SJohn.Forte@Sun.COM #define USEC_INIT() USEC_START()
917836SJohn.Forte@Sun.COM #include <sys/time.h>
927836SJohn.Forte@Sun.COM static struct timeval Usec_time;
937836SJohn.Forte@Sun.COM static int Usec_started = 0;
947836SJohn.Forte@Sun.COM
957836SJohn.Forte@Sun.COM void total_display(void);
967836SJohn.Forte@Sun.COM void disp_stats(void);
977836SJohn.Forte@Sun.COM void do_calc(void);
987836SJohn.Forte@Sun.COM void init_dual(void);
997836SJohn.Forte@Sun.COM void calc_time(void);
1007836SJohn.Forte@Sun.COM void calc_completion(int, int, int);
1017836SJohn.Forte@Sun.COM void disp_total_stats(void);
1027836SJohn.Forte@Sun.COM void display_cache(void);
1037836SJohn.Forte@Sun.COM
1047836SJohn.Forte@Sun.COM #define DISPLEN 16
1057836SJohn.Forte@Sun.COM
1067836SJohn.Forte@Sun.COM static void
USEC_START(void)1077836SJohn.Forte@Sun.COM USEC_START(void)
1087836SJohn.Forte@Sun.COM {
1097836SJohn.Forte@Sun.COM if (!Usec_started) {
1107836SJohn.Forte@Sun.COM (void) gettimeofday(&Usec_time, NULL);
1117836SJohn.Forte@Sun.COM Usec_started = 1;
1127836SJohn.Forte@Sun.COM }
1137836SJohn.Forte@Sun.COM }
1147836SJohn.Forte@Sun.COM
1157836SJohn.Forte@Sun.COM static unsigned int
USEC_READ()1167836SJohn.Forte@Sun.COM USEC_READ()
1177836SJohn.Forte@Sun.COM {
1187836SJohn.Forte@Sun.COM struct timeval tv;
1197836SJohn.Forte@Sun.COM if (!Usec_started)
1207836SJohn.Forte@Sun.COM USEC_START();
1217836SJohn.Forte@Sun.COM
1227836SJohn.Forte@Sun.COM (void) gettimeofday(&tv, NULL);
1237836SJohn.Forte@Sun.COM return (unsigned)((tv.tv_sec - Usec_time.tv_sec) * 1000000 +
1247836SJohn.Forte@Sun.COM (tv.tv_usec - Usec_time.tv_usec));
1257836SJohn.Forte@Sun.COM }
1267836SJohn.Forte@Sun.COM #endif /* m88k */
1277836SJohn.Forte@Sun.COM
1287836SJohn.Forte@Sun.COM #define SAMPLE_RATE 5
1297836SJohn.Forte@Sun.COM
1307836SJohn.Forte@Sun.COM /*
1317836SJohn.Forte@Sun.COM * refresh curses window to file
1327836SJohn.Forte@Sun.COM */
1337836SJohn.Forte@Sun.COM void
wrefresh_file(WINDOW * win,int fd)1347836SJohn.Forte@Sun.COM wrefresh_file(WINDOW *win, int fd)
1357836SJohn.Forte@Sun.COM {
1367836SJohn.Forte@Sun.COM char buf[8192], c, *cp = buf, *line, *blank, *empty;
1377836SJohn.Forte@Sun.COM int x, y;
1387836SJohn.Forte@Sun.COM
1397836SJohn.Forte@Sun.COM empty = NULL; /* cull trailing empty lines */
1407836SJohn.Forte@Sun.COM for (y = 0; y < win->_maxy; y++) {
1417836SJohn.Forte@Sun.COM line = cp;
1427836SJohn.Forte@Sun.COM blank = NULL; /* cull trailing blanks */
1437836SJohn.Forte@Sun.COM for (x = 0; x < win->_maxx; x++) {
1447836SJohn.Forte@Sun.COM c = (win->_y[y][x]) & A_CHARTEXT;
1457836SJohn.Forte@Sun.COM if (c != ' ')
1467836SJohn.Forte@Sun.COM blank = NULL;
1477836SJohn.Forte@Sun.COM else if (blank == NULL)
1487836SJohn.Forte@Sun.COM blank = cp;
1497836SJohn.Forte@Sun.COM *cp++ = c;
1507836SJohn.Forte@Sun.COM }
1517836SJohn.Forte@Sun.COM if (blank)
1527836SJohn.Forte@Sun.COM cp = blank;
1537836SJohn.Forte@Sun.COM if (line != cp)
1547836SJohn.Forte@Sun.COM empty = NULL;
1557836SJohn.Forte@Sun.COM else if (empty == NULL)
1567836SJohn.Forte@Sun.COM empty = cp + 1;
1577836SJohn.Forte@Sun.COM *cp++ = '\n';
1587836SJohn.Forte@Sun.COM }
1597836SJohn.Forte@Sun.COM if (empty)
1607836SJohn.Forte@Sun.COM cp = empty;
1617836SJohn.Forte@Sun.COM *cp++ = '\f'; *cp++ = '\n'; *cp = '\0';
1627836SJohn.Forte@Sun.COM /* cp is eliminated by short _maxy and _maxx, it won't overflow */
1637836SJohn.Forte@Sun.COM /* LINTED, cp - buf won't be > INT32_MAX */
1647836SJohn.Forte@Sun.COM (void) write(fd, buf, cp - buf);
1657836SJohn.Forte@Sun.COM }
1667836SJohn.Forte@Sun.COM
1677836SJohn.Forte@Sun.COM
1687836SJohn.Forte@Sun.COM int
higher(int high)1697836SJohn.Forte@Sun.COM higher(int high)
1707836SJohn.Forte@Sun.COM {
1717836SJohn.Forte@Sun.COM int i;
1727836SJohn.Forte@Sun.COM
1737836SJohn.Forte@Sun.COM for (i = high + 1; i <= sdbc_max_devices; i++) {
1747836SJohn.Forte@Sun.COM if (cs_cur->st_shared[i].sh_alloc)
1757836SJohn.Forte@Sun.COM return (i);
1767836SJohn.Forte@Sun.COM }
1777836SJohn.Forte@Sun.COM return (0);
1787836SJohn.Forte@Sun.COM }
1797836SJohn.Forte@Sun.COM
1807836SJohn.Forte@Sun.COM int
is_dirty()1817836SJohn.Forte@Sun.COM is_dirty()
1827836SJohn.Forte@Sun.COM {
1837836SJohn.Forte@Sun.COM int i, dirty = 0;
1847836SJohn.Forte@Sun.COM spcs_s_info_t ustats;
1857836SJohn.Forte@Sun.COM
1867836SJohn.Forte@Sun.COM if (SDBC_IOCTL(SDBC_STATS, cs_cur, 0, 0, 0, 0,
1877836SJohn.Forte@Sun.COM &ustats) == SPCS_S_ERROR) {
1887836SJohn.Forte@Sun.COM perror("Could not get stats from kernel");
1897836SJohn.Forte@Sun.COM if (ustats) {
1907836SJohn.Forte@Sun.COM spcs_s_report(ustats, stderr);
1917836SJohn.Forte@Sun.COM spcs_s_ufree(&ustats);
1927836SJohn.Forte@Sun.COM }
1937836SJohn.Forte@Sun.COM return (-errno);
1947836SJohn.Forte@Sun.COM }
1957836SJohn.Forte@Sun.COM if (cs_cur->st_cachesize == 0)
1967836SJohn.Forte@Sun.COM return (0);
1977836SJohn.Forte@Sun.COM
1987836SJohn.Forte@Sun.COM for (i = 0; i < cs_cur->st_count; i++) {
1997836SJohn.Forte@Sun.COM if (cs_cur->st_shared[i].sh_alloc)
2007836SJohn.Forte@Sun.COM dirty += cs_cur->st_shared[i].sh_numdirty;
2017836SJohn.Forte@Sun.COM }
2027836SJohn.Forte@Sun.COM
2037836SJohn.Forte@Sun.COM return (dirty != 0);
2047836SJohn.Forte@Sun.COM }
2057836SJohn.Forte@Sun.COM
2067836SJohn.Forte@Sun.COM void
display_cache(void)2077836SJohn.Forte@Sun.COM display_cache(void)
2087836SJohn.Forte@Sun.COM {
2097836SJohn.Forte@Sun.COM static int first = 1;
2107836SJohn.Forte@Sun.COM spcs_s_info_t ustats;
2117836SJohn.Forte@Sun.COM
2127836SJohn.Forte@Sun.COM if (SDBC_IOCTL(SDBC_STATS, cs_cur, 0, 0, 0, 0, &ustats) ==
2137836SJohn.Forte@Sun.COM SPCS_S_ERROR) {
2147836SJohn.Forte@Sun.COM perror("sd_stats");
2157836SJohn.Forte@Sun.COM if (ustats) {
2167836SJohn.Forte@Sun.COM spcs_s_report(ustats, stderr);
2177836SJohn.Forte@Sun.COM spcs_s_ufree(&ustats);
2187836SJohn.Forte@Sun.COM }
2197836SJohn.Forte@Sun.COM }
2207836SJohn.Forte@Sun.COM
2217836SJohn.Forte@Sun.COM do_calc();
2227836SJohn.Forte@Sun.COM if (first) {
2237836SJohn.Forte@Sun.COM prev_time = USEC_READ();
2247836SJohn.Forte@Sun.COM first = 0;
2257836SJohn.Forte@Sun.COM } else
2267836SJohn.Forte@Sun.COM disp_stats();
2277836SJohn.Forte@Sun.COM }
2287836SJohn.Forte@Sun.COM
2297836SJohn.Forte@Sun.COM void
total_display(void)2307836SJohn.Forte@Sun.COM total_display(void)
2317836SJohn.Forte@Sun.COM {
2327836SJohn.Forte@Sun.COM spcs_s_info_t ustats;
2337836SJohn.Forte@Sun.COM
2347836SJohn.Forte@Sun.COM if (SDBC_IOCTL(SDBC_STATS, cs_cur, 0, 0, 0, 0, &ustats) ==
2357836SJohn.Forte@Sun.COM SPCS_S_ERROR) {
2367836SJohn.Forte@Sun.COM if (ustats) {
2377836SJohn.Forte@Sun.COM spcs_s_report(ustats, stderr);
2387836SJohn.Forte@Sun.COM spcs_s_ufree(&ustats);
2397836SJohn.Forte@Sun.COM }
2407836SJohn.Forte@Sun.COM perror("sd_stats");
2417836SJohn.Forte@Sun.COM }
2427836SJohn.Forte@Sun.COM disp_total_stats();
2437836SJohn.Forte@Sun.COM }
2447836SJohn.Forte@Sun.COM
2457836SJohn.Forte@Sun.COM
2467836SJohn.Forte@Sun.COM int
range_first()2477836SJohn.Forte@Sun.COM range_first()
2487836SJohn.Forte@Sun.COM {
2497836SJohn.Forte@Sun.COM rnum = 0;
2507836SJohn.Forte@Sun.COM return (ranges[rnum].lb);
2517836SJohn.Forte@Sun.COM }
2527836SJohn.Forte@Sun.COM
2537836SJohn.Forte@Sun.COM int
range_next(int cd)2547836SJohn.Forte@Sun.COM range_next(int cd)
2557836SJohn.Forte@Sun.COM {
2567836SJohn.Forte@Sun.COM if (ranges[rnum].ub > cd)
2577836SJohn.Forte@Sun.COM return (cd + 1);
2587836SJohn.Forte@Sun.COM if (range_num > rnum)
2597836SJohn.Forte@Sun.COM rnum++;
2607836SJohn.Forte@Sun.COM else
2617836SJohn.Forte@Sun.COM return (cd + 1);
2627836SJohn.Forte@Sun.COM return (ranges[rnum].lb);
2637836SJohn.Forte@Sun.COM }
2647836SJohn.Forte@Sun.COM
2657836SJohn.Forte@Sun.COM int
range_last()2667836SJohn.Forte@Sun.COM range_last() {
2677836SJohn.Forte@Sun.COM return (ranges[range_num].ub);
2687836SJohn.Forte@Sun.COM }
2697836SJohn.Forte@Sun.COM
2707836SJohn.Forte@Sun.COM
2717836SJohn.Forte@Sun.COM void
set_dual_on_off()2727836SJohn.Forte@Sun.COM set_dual_on_off()
2737836SJohn.Forte@Sun.COM {
2747836SJohn.Forte@Sun.COM int i, j, ct = 0, newct = 0;
2757836SJohn.Forte@Sun.COM
2767836SJohn.Forte@Sun.COM for (i = range_first(); i < rdc_enabled_sets && i <= range_last();
2777836SJohn.Forte@Sun.COM i = range_next(i)) {
2787836SJohn.Forte@Sun.COM if (rdc_info[i].flags & RDC_ENABLED) {
2797836SJohn.Forte@Sun.COM ct++;
2807836SJohn.Forte@Sun.COM if (ct > dual_screen * ((LINES - 9) / 2))
2817836SJohn.Forte@Sun.COM break;
2827836SJohn.Forte@Sun.COM }
2837836SJohn.Forte@Sun.COM }
2847836SJohn.Forte@Sun.COM if (((i >= rdc_enabled_sets) ||
2857836SJohn.Forte@Sun.COM (i > range_last())) && (dual_screen > 0)) {
2867836SJohn.Forte@Sun.COM dual_screen--;
2877836SJohn.Forte@Sun.COM set_dual_on_off();
2887836SJohn.Forte@Sun.COM } else {
2897836SJohn.Forte@Sun.COM bzero(dual_on_off, sdbc_max_devices * sizeof (int));
2907836SJohn.Forte@Sun.COM for (j = i; j < rdc_enabled_sets && j <= range_last();
2917836SJohn.Forte@Sun.COM j = range_next(j)) {
2927836SJohn.Forte@Sun.COM if (rdc_info[j].flags & RDC_ENABLED) {
2937836SJohn.Forte@Sun.COM newct++;
2947836SJohn.Forte@Sun.COM if (newct <= (LINES - 9) / 2) {
2957836SJohn.Forte@Sun.COM dual_on_off[j] = 1;
2967836SJohn.Forte@Sun.COM } else
2977836SJohn.Forte@Sun.COM break;
2987836SJohn.Forte@Sun.COM }
2997836SJohn.Forte@Sun.COM }
3007836SJohn.Forte@Sun.COM }
3017836SJohn.Forte@Sun.COM }
3027836SJohn.Forte@Sun.COM
3037836SJohn.Forte@Sun.COM
3047836SJohn.Forte@Sun.COM void
set_on_off()3057836SJohn.Forte@Sun.COM set_on_off()
3067836SJohn.Forte@Sun.COM {
3077836SJohn.Forte@Sun.COM int i, j, ct = 0, newct = 0;
3087836SJohn.Forte@Sun.COM
3097836SJohn.Forte@Sun.COM for (i = range_first(); i <= range_last(); i = range_next(i)) {
3107836SJohn.Forte@Sun.COM if (cs_cur->st_shared[i].sh_alloc) {
3117836SJohn.Forte@Sun.COM ct++;
3127836SJohn.Forte@Sun.COM if (ct > screen*((LINES - 9) / 2))
3137836SJohn.Forte@Sun.COM break;
3147836SJohn.Forte@Sun.COM }
3157836SJohn.Forte@Sun.COM }
3167836SJohn.Forte@Sun.COM if ((i > range_last()) && (screen > 0)) {
3177836SJohn.Forte@Sun.COM screen--;
3187836SJohn.Forte@Sun.COM set_on_off();
3197836SJohn.Forte@Sun.COM } else {
3207836SJohn.Forte@Sun.COM bzero(on_off, sdbc_max_devices * sizeof (int));
3217836SJohn.Forte@Sun.COM for (j = i; j <= range_last(); j = range_next(j)) {
3227836SJohn.Forte@Sun.COM if (cs_cur->st_shared[j].sh_alloc) {
3237836SJohn.Forte@Sun.COM newct++;
3247836SJohn.Forte@Sun.COM if (newct <= (LINES - 9) / 2)
3257836SJohn.Forte@Sun.COM on_off[j] = 1;
3267836SJohn.Forte@Sun.COM else
3277836SJohn.Forte@Sun.COM break;
3287836SJohn.Forte@Sun.COM }
3297836SJohn.Forte@Sun.COM }
3307836SJohn.Forte@Sun.COM }
3317836SJohn.Forte@Sun.COM }
3327836SJohn.Forte@Sun.COM
3337836SJohn.Forte@Sun.COM void
disp_stats(void)3347836SJohn.Forte@Sun.COM disp_stats(void)
3357836SJohn.Forte@Sun.COM {
3367836SJohn.Forte@Sun.COM double read_s, write_s, access_s, readp, writep;
3377836SJohn.Forte@Sun.COM double rmiss_s, wmiss_s;
3387836SJohn.Forte@Sun.COM double elapsed = delta_time / 1000000.0;
3397836SJohn.Forte@Sun.COM double kbps = elapsed * 1024.0; /* for Kbytes per second */
3407836SJohn.Forte@Sun.COM int rtotal, wtotal, i, j;
3417836SJohn.Forte@Sun.COM double throughput = 0.0, rthroughput = 0.0;
3427836SJohn.Forte@Sun.COM double creads = 0.0, cwrites = 0.0;
3437836SJohn.Forte@Sun.COM char status_bit, down = 0;
3447836SJohn.Forte@Sun.COM int len;
3457836SJohn.Forte@Sun.COM char fn[19];
3467836SJohn.Forte@Sun.COM
3477836SJohn.Forte@Sun.COM if (delta_time != 0) {
3487836SJohn.Forte@Sun.COM read_s = cs_persec->st_rdhits / elapsed;
3497836SJohn.Forte@Sun.COM write_s = cs_persec->st_wrhits / elapsed;
3507836SJohn.Forte@Sun.COM rmiss_s = cs_persec->st_rdmiss / elapsed;
3517836SJohn.Forte@Sun.COM wmiss_s = cs_persec->st_wrmiss / elapsed;
3527836SJohn.Forte@Sun.COM access_s = (cs_persec->st_wrhits + cs_persec->st_rdhits +
3537836SJohn.Forte@Sun.COM cs_persec->st_rdmiss + cs_persec->st_wrmiss) / elapsed;
3547836SJohn.Forte@Sun.COM } else
3557836SJohn.Forte@Sun.COM read_s = write_s = access_s = 0.0;
3567836SJohn.Forte@Sun.COM
3577836SJohn.Forte@Sun.COM rtotal = cs_persec->st_rdhits + cs_persec->st_rdmiss;
3587836SJohn.Forte@Sun.COM wtotal = cs_persec->st_wrhits + cs_persec->st_wrmiss;
3597836SJohn.Forte@Sun.COM if (rtotal != 0)
3607836SJohn.Forte@Sun.COM readp = cs_persec->st_rdhits / (double)rtotal;
3617836SJohn.Forte@Sun.COM else
3627836SJohn.Forte@Sun.COM readp = 0.0;
3637836SJohn.Forte@Sun.COM
3647836SJohn.Forte@Sun.COM if (wtotal != 0) {
3657836SJohn.Forte@Sun.COM writep = cs_persec->st_wrhits / (double)wtotal;
3667836SJohn.Forte@Sun.COM } else
3677836SJohn.Forte@Sun.COM writep = 0.0;
3687836SJohn.Forte@Sun.COM
3697836SJohn.Forte@Sun.COM set_on_off();
3707836SJohn.Forte@Sun.COM if (cs_cur->st_cachesize == 0)
3717836SJohn.Forte@Sun.COM (void) mvprintw(0, 20, "****** Storage Cache Disabled ******");
3727836SJohn.Forte@Sun.COM else
3737836SJohn.Forte@Sun.COM (void) mvprintw(0, 20, "****** Storage Cache ******");
3747836SJohn.Forte@Sun.COM (void) mvprintw(2, 26, "disk_io cache write_blocks");
3757836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
3767836SJohn.Forte@Sun.COM (void) mvprintw(3, 1, " cd cached_partition reads writes reads writes"
3777836SJohn.Forte@Sun.COM " dirty todisk failed");
3787836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
3797836SJohn.Forte@Sun.COM for (i = 0, j = 0; j < cs_cur->st_count; i++) {
3807836SJohn.Forte@Sun.COM if (i >= sdbc_max_devices)
3817836SJohn.Forte@Sun.COM break;
3827836SJohn.Forte@Sun.COM if (cs_cur->st_shared[i].sh_alloc) {
3837836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_disk_write /= kbps;
3847836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_disk_read /= kbps;
3857836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_cache_write /= kbps;
3867836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_cache_read /= kbps;
3877836SJohn.Forte@Sun.COM rthroughput += cs_persec->st_shared[i].sh_disk_read;
3887836SJohn.Forte@Sun.COM throughput += cs_persec->st_shared[i].sh_disk_write;
3897836SJohn.Forte@Sun.COM creads += cs_persec->st_shared[i].sh_cache_read;
3907836SJohn.Forte@Sun.COM cwrites += cs_persec->st_shared[i].sh_cache_write;
3917836SJohn.Forte@Sun.COM if (!down)
3927836SJohn.Forte@Sun.COM down = cs_cur->st_shared[i].sh_failed;
3937836SJohn.Forte@Sun.COM if (cs_cur->st_shared[i].sh_failed && bright) {
3947836SJohn.Forte@Sun.COM status_bit = '*';
3957836SJohn.Forte@Sun.COM } else
3967836SJohn.Forte@Sun.COM status_bit = ' ';
3977836SJohn.Forte@Sun.COM if ((len = strlen(cs_cur->st_shared[i].sh_filename))
3987836SJohn.Forte@Sun.COM > 15) {
399*11576SSurya.Prakki@Sun.COM (void) strcpy(fn, "...");
400*11576SSurya.Prakki@Sun.COM (void) strcat(fn,
401*11576SSurya.Prakki@Sun.COM cs_cur->st_shared[i].sh_filename +
4027836SJohn.Forte@Sun.COM len - 12);
4037836SJohn.Forte@Sun.COM } else
404*11576SSurya.Prakki@Sun.COM (void) strcpy(fn,
405*11576SSurya.Prakki@Sun.COM cs_cur->st_shared[i].sh_filename);
4067836SJohn.Forte@Sun.COM if (on_off[i]) {
4077836SJohn.Forte@Sun.COM (void) mvprintw(4 + j, 1,
4087836SJohn.Forte@Sun.COM "%3d %-15s%c %6d %6d %6d %6d %6d %6d %6d",
4097836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_cd,
4107836SJohn.Forte@Sun.COM fn,
4117836SJohn.Forte@Sun.COM status_bit,
4127836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_disk_read,
4137836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_disk_write,
4147836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_cache_read,
4157836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_cache_write,
4167836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_numdirty,
4177836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_numio,
4187836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_numfail);
4197836SJohn.Forte@Sun.COM j++;
4207836SJohn.Forte@Sun.COM }
4217836SJohn.Forte@Sun.COM }
4227836SJohn.Forte@Sun.COM }
4237836SJohn.Forte@Sun.COM bright = !bright;
4247836SJohn.Forte@Sun.COM
4257836SJohn.Forte@Sun.COM (void) mvprintw(4 + j, 22, "------ ------ ------ ------");
4267836SJohn.Forte@Sun.COM (void) mvprintw(5 + j, 6, " Kbytes/s total:%6d %6d %6d %6d",
4277836SJohn.Forte@Sun.COM (int)rthroughput, (int)throughput,
4287836SJohn.Forte@Sun.COM (int)creads, (int)cwrites);
4297836SJohn.Forte@Sun.COM (void) mvprintw(7 + j, 1, "accesses/s");
4307836SJohn.Forte@Sun.COM (void) mvprintw(7 + j, 15, "read/s write/s %%readh %%writeh");
4317836SJohn.Forte@Sun.COM
4327836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
4337836SJohn.Forte@Sun.COM (void) mvprintw(8 + j, 1, " ");
4347836SJohn.Forte@Sun.COM (void) mvprintw(8 + j, 13,
4357836SJohn.Forte@Sun.COM " ");
4367836SJohn.Forte@Sun.COM (void) mvprintw(8 + j, 13, "(misses/s) (misses/s)");
4377836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
4387836SJohn.Forte@Sun.COM
4397836SJohn.Forte@Sun.COM (void) mvprintw(9 + j, 0, "%10.2lf %7.2f %7.2f %6.1f %6.1f",
4407836SJohn.Forte@Sun.COM access_s, read_s, write_s, readp * 100.0, writep * 100.0);
4417836SJohn.Forte@Sun.COM (void) mvprintw(10 + j, 0, " (%7.2f ) (%7.2f )\n\n",
4427836SJohn.Forte@Sun.COM rmiss_s, wmiss_s);
4437836SJohn.Forte@Sun.COM
4447836SJohn.Forte@Sun.COM if (down)
4457836SJohn.Forte@Sun.COM (void) mvprintw(20 + j, 1, "* -- disk off-line");
4467836SJohn.Forte@Sun.COM }
4477836SJohn.Forte@Sun.COM
4487836SJohn.Forte@Sun.COM void
do_calc(void)4497836SJohn.Forte@Sun.COM do_calc(void)
4507836SJohn.Forte@Sun.COM {
4517836SJohn.Forte@Sun.COM int i, j;
4527836SJohn.Forte@Sun.COM
4537836SJohn.Forte@Sun.COM delta_time = USEC_READ() - prev_time;
4547836SJohn.Forte@Sun.COM
4557836SJohn.Forte@Sun.COM cs_persec->st_rdhits = cs_cur->st_rdhits - cs_prev->st_rdhits;
4567836SJohn.Forte@Sun.COM cs_persec->st_rdmiss = cs_cur->st_rdmiss - cs_prev->st_rdmiss;
4577836SJohn.Forte@Sun.COM cs_persec->st_wrhits = cs_cur->st_wrhits - cs_prev->st_wrhits;
4587836SJohn.Forte@Sun.COM cs_persec->st_wrmiss = cs_cur->st_wrmiss - cs_prev->st_wrmiss;
4597836SJohn.Forte@Sun.COM
4607836SJohn.Forte@Sun.COM for (i = 0, j = 0; j < cs_cur->st_count; i++) {
4617836SJohn.Forte@Sun.COM if (i >= sdbc_max_devices)
4627836SJohn.Forte@Sun.COM break;
4637836SJohn.Forte@Sun.COM if (cs_cur->st_shared[i].sh_alloc) {
4647836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_disk_write =
4657836SJohn.Forte@Sun.COM FBA_SIZE(cs_cur->st_shared[i].sh_disk_write -
4667836SJohn.Forte@Sun.COM cs_prev->st_shared[i].sh_disk_write);
4677836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_disk_read =
4687836SJohn.Forte@Sun.COM FBA_SIZE(cs_cur->st_shared[i].sh_disk_read -
4697836SJohn.Forte@Sun.COM cs_prev->st_shared[i].sh_disk_read);
4707836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_cache_read =
4717836SJohn.Forte@Sun.COM FBA_SIZE(cs_cur->st_shared[i].sh_cache_read -
4727836SJohn.Forte@Sun.COM cs_prev->st_shared[i].sh_cache_read);
4737836SJohn.Forte@Sun.COM cs_persec->st_shared[i].sh_cache_write =
4747836SJohn.Forte@Sun.COM FBA_SIZE(cs_cur->st_shared[i].sh_cache_write -
4757836SJohn.Forte@Sun.COM cs_prev->st_shared[i].sh_cache_write);
4767836SJohn.Forte@Sun.COM j++;
4777836SJohn.Forte@Sun.COM }
4787836SJohn.Forte@Sun.COM }
4797836SJohn.Forte@Sun.COM (void) memcpy((char *) cs_prev, (char *) cs_cur, sizeof (_sd_stats_t) +
4807836SJohn.Forte@Sun.COM (sdbc_max_devices - 1) * sizeof (_sd_shared_t));
4817836SJohn.Forte@Sun.COM prev_time = USEC_READ();
4827836SJohn.Forte@Sun.COM }
4837836SJohn.Forte@Sun.COM
4847836SJohn.Forte@Sun.COM
4857836SJohn.Forte@Sun.COM void
init_dual(void)4867836SJohn.Forte@Sun.COM init_dual(void)
4877836SJohn.Forte@Sun.COM {
4887836SJohn.Forte@Sun.COM #define IND_ENABLED 0
4897836SJohn.Forte@Sun.COM #define IND_RESYNC 1
4907836SJohn.Forte@Sun.COM #define IND_RESYNC_REVERSE 2
4917836SJohn.Forte@Sun.COM #define IND_VOLUME_DOWN 3
4927836SJohn.Forte@Sun.COM #define IND_MIRROR_DOWN 4
4937836SJohn.Forte@Sun.COM #define IND_LOGGING 5
4947836SJohn.Forte@Sun.COM #define IND_RESYNC_NEEDED 6
4957836SJohn.Forte@Sun.COM #define IND_REV_RESYNC_NEEDED 7
4967836SJohn.Forte@Sun.COM #define IND_BITMAP_FAILED 8
4977836SJohn.Forte@Sun.COM #define IND_FULL_SYNC_NEEDED 9
4987836SJohn.Forte@Sun.COM #define IND_FCAL_FAILED 10
499*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_ENABLED], "replicating");
500*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_RESYNC], "sync");
501*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_RESYNC_REVERSE], "rev sync");
502*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_VOLUME_DOWN], "volume down");
503*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_MIRROR_DOWN], "mirror down");
504*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_LOGGING], "logging");
505*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_RESYNC_NEEDED], "need sync");
506*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_REV_RESYNC_NEEDED], "need rev sync");
507*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_BITMAP_FAILED], "bitmap failed");
508*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_FULL_SYNC_NEEDED], "full sync needed");
509*11576SSurya.Prakki@Sun.COM (void) strcpy(status[IND_FCAL_FAILED], "fcal failed");
5107836SJohn.Forte@Sun.COM dual_initted = 1;
5117836SJohn.Forte@Sun.COM }
5127836SJohn.Forte@Sun.COM
5137836SJohn.Forte@Sun.COM
5147836SJohn.Forte@Sun.COM int
rdc_get_maxsets(void)5157836SJohn.Forte@Sun.COM rdc_get_maxsets(void)
5167836SJohn.Forte@Sun.COM {
5177836SJohn.Forte@Sun.COM rdc_status_t rdc_status;
5187836SJohn.Forte@Sun.COM spcs_s_info_t ustatus;
5197836SJohn.Forte@Sun.COM int rc;
5207836SJohn.Forte@Sun.COM
5217836SJohn.Forte@Sun.COM rdc_status.nset = 0;
5227836SJohn.Forte@Sun.COM ustatus = spcs_s_ucreate();
5237836SJohn.Forte@Sun.COM
5247836SJohn.Forte@Sun.COM rc = RDC_IOCTL(RDC_STATUS, &rdc_status, 0, 0, 0, 0, ustatus);
5257836SJohn.Forte@Sun.COM spcs_s_ufree(&ustatus);
5267836SJohn.Forte@Sun.COM
5277836SJohn.Forte@Sun.COM if (rc == SPCS_S_ERROR)
5287836SJohn.Forte@Sun.COM return (-1);
5297836SJohn.Forte@Sun.COM
5307836SJohn.Forte@Sun.COM return (rdc_status.maxsets);
5317836SJohn.Forte@Sun.COM }
5327836SJohn.Forte@Sun.COM
5337836SJohn.Forte@Sun.COM int
dual_stats()5347836SJohn.Forte@Sun.COM dual_stats()
5357836SJohn.Forte@Sun.COM {
5367836SJohn.Forte@Sun.COM int ind, i, k, len;
5377836SJohn.Forte@Sun.COM int stars, size, segs;
5387836SJohn.Forte@Sun.COM int rdcindex;
5397836SJohn.Forte@Sun.COM float pct;
5407836SJohn.Forte@Sun.COM char fn[19];
5417836SJohn.Forte@Sun.COM char *phost;
5427836SJohn.Forte@Sun.COM char *shost;
5437836SJohn.Forte@Sun.COM char *pfile;
5447836SJohn.Forte@Sun.COM char *sfile;
5457836SJohn.Forte@Sun.COM char lhost[16];
5467836SJohn.Forte@Sun.COM spcs_s_info_t ustats = NULL;
5477836SJohn.Forte@Sun.COM
5487836SJohn.Forte@Sun.COM (void) gethostname(lhost, 16);
5497836SJohn.Forte@Sun.COM
5507836SJohn.Forte@Sun.COM if (rdc_maxsets <= 0)
5517836SJohn.Forte@Sun.COM rdc_maxsets = rdc_get_maxsets();
5527836SJohn.Forte@Sun.COM
5537836SJohn.Forte@Sun.COM if (rdc_maxsets < 0)
5547836SJohn.Forte@Sun.COM goto no_stats;
5557836SJohn.Forte@Sun.COM
5567836SJohn.Forte@Sun.COM if (!rdc_status) {
5577836SJohn.Forte@Sun.COM rdc_status = malloc(sizeof (rdc_status_t) +
5587836SJohn.Forte@Sun.COM (sizeof (rdc_set_t) * (rdc_maxsets - 1)));
5597836SJohn.Forte@Sun.COM if (!rdc_status) {
5607836SJohn.Forte@Sun.COM no_stats:
5617836SJohn.Forte@Sun.COM (void) mvprintw(0, 20,
5627836SJohn.Forte@Sun.COM "****** Dual Copy Not Available ******");
5637836SJohn.Forte@Sun.COM return (-1);
5647836SJohn.Forte@Sun.COM }
5657836SJohn.Forte@Sun.COM
5667836SJohn.Forte@Sun.COM rdc_info = rdc_status->rdc_set;
5677836SJohn.Forte@Sun.COM }
5687836SJohn.Forte@Sun.COM
5697836SJohn.Forte@Sun.COM rdc_status->nset = rdc_maxsets;
5707836SJohn.Forte@Sun.COM ustats = spcs_s_ucreate();
5717836SJohn.Forte@Sun.COM
5727836SJohn.Forte@Sun.COM size = RDC_IOCTL(RDC_STATUS, rdc_status, 0, 0, 0, 0, ustats);
5737836SJohn.Forte@Sun.COM if (size == SPCS_S_ERROR) {
5747836SJohn.Forte@Sun.COM if (ustats) {
5757836SJohn.Forte@Sun.COM spcs_s_report(ustats, stderr);
5767836SJohn.Forte@Sun.COM spcs_s_ufree(&ustats);
5777836SJohn.Forte@Sun.COM }
5787836SJohn.Forte@Sun.COM (void) mvprintw(0, 20, "****** Dual Copy Not Available ******");
5797836SJohn.Forte@Sun.COM return (-1);
5807836SJohn.Forte@Sun.COM }
5817836SJohn.Forte@Sun.COM spcs_s_ufree(&ustats);
5827836SJohn.Forte@Sun.COM rdc_enabled_sets = rdc_status->nset;
5837836SJohn.Forte@Sun.COM
5847836SJohn.Forte@Sun.COM if (!dual_initted)
5857836SJohn.Forte@Sun.COM init_dual();
5867836SJohn.Forte@Sun.COM
5877836SJohn.Forte@Sun.COM set_dual_on_off();
5887836SJohn.Forte@Sun.COM
5897836SJohn.Forte@Sun.COM calc_time();
5907836SJohn.Forte@Sun.COM
5917836SJohn.Forte@Sun.COM (void) mvprintw(0, 20, "****** Dual Copy Statistics ******");
5927836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
5937836SJohn.Forte@Sun.COM (void) mvprintw(2, 0, "primary");
5947836SJohn.Forte@Sun.COM (void) mvprintw(2, 22, "link status");
5957836SJohn.Forte@Sun.COM (void) mvprintw(2, 36, "secondary");
5967836SJohn.Forte@Sun.COM (void) mvprintw(2, 54, "dual copy status");
5977836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
5987836SJohn.Forte@Sun.COM
5997836SJohn.Forte@Sun.COM for (rdcindex = 0, k = 0; rdcindex < rdc_enabled_sets; rdcindex++) {
6007836SJohn.Forte@Sun.COM if (!(rdc_info[rdcindex].flags & RDC_ENABLED) ||
6017836SJohn.Forte@Sun.COM !dual_on_off[rdcindex])
6027836SJohn.Forte@Sun.COM continue;
6037836SJohn.Forte@Sun.COM
6047836SJohn.Forte@Sun.COM if (rdc_info[rdcindex].sync_flags & RDC_VOL_FAILED)
6057836SJohn.Forte@Sun.COM ind = IND_VOLUME_DOWN;
6067836SJohn.Forte@Sun.COM else if (rdc_info[rdcindex].flags & RDC_FCAL_FAILED)
6077836SJohn.Forte@Sun.COM ind = IND_FCAL_FAILED;
6087836SJohn.Forte@Sun.COM else if (rdc_info[rdcindex].bmap_flags & RDC_BMP_FAILED)
6097836SJohn.Forte@Sun.COM ind = IND_BITMAP_FAILED;
6107836SJohn.Forte@Sun.COM else if (rdc_info[rdcindex].flags & RDC_LOGGING) {
6117836SJohn.Forte@Sun.COM if (rdc_info[rdcindex].sync_flags &
6127836SJohn.Forte@Sun.COM RDC_SYNC_NEEDED)
6137836SJohn.Forte@Sun.COM ind = IND_RESYNC_NEEDED;
6147836SJohn.Forte@Sun.COM else if (rdc_info[rdcindex].sync_flags &
6157836SJohn.Forte@Sun.COM RDC_RSYNC_NEEDED)
6167836SJohn.Forte@Sun.COM ind = IND_REV_RESYNC_NEEDED;
6177836SJohn.Forte@Sun.COM else
6187836SJohn.Forte@Sun.COM ind = IND_LOGGING;
6197836SJohn.Forte@Sun.COM } else if ((rdc_info[rdcindex].flags & RDC_SLAVE) &&
6207836SJohn.Forte@Sun.COM (rdc_info[rdcindex].flags & RDC_SYNCING)) {
6217836SJohn.Forte@Sun.COM if (rdc_info[rdcindex].flags & RDC_PRIMARY)
6227836SJohn.Forte@Sun.COM ind = IND_RESYNC_REVERSE;
6237836SJohn.Forte@Sun.COM else
6247836SJohn.Forte@Sun.COM ind = IND_RESYNC;
6257836SJohn.Forte@Sun.COM } else if (rdc_info[rdcindex].flags & RDC_SYNCING) {
6267836SJohn.Forte@Sun.COM if (rdc_info[rdcindex].flags & RDC_PRIMARY)
6277836SJohn.Forte@Sun.COM ind = IND_RESYNC;
6287836SJohn.Forte@Sun.COM else
6297836SJohn.Forte@Sun.COM ind = IND_RESYNC_REVERSE;
6307836SJohn.Forte@Sun.COM } else
6317836SJohn.Forte@Sun.COM ind = IND_ENABLED;
6327836SJohn.Forte@Sun.COM
6337836SJohn.Forte@Sun.COM phost = rdc_info[rdcindex].primary.intf;
6347836SJohn.Forte@Sun.COM pfile = rdc_info[rdcindex].primary.file;
6357836SJohn.Forte@Sun.COM shost = rdc_info[rdcindex].secondary.intf;
6367836SJohn.Forte@Sun.COM sfile = rdc_info[rdcindex].secondary.file;
6377836SJohn.Forte@Sun.COM
6387836SJohn.Forte@Sun.COM if ((len = strlen(phost)) > 8) {
6397836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 0, ".%+7s:",
6407836SJohn.Forte@Sun.COM phost + len - 7);
6417836SJohn.Forte@Sun.COM } else
6427836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 0, "%+8s:", phost);
6437836SJohn.Forte@Sun.COM
6447836SJohn.Forte@Sun.COM if ((len = strlen(pfile)) > DISPLEN) {
6457836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 9, "...%-13s",
6467836SJohn.Forte@Sun.COM pfile + len - DISPLEN + 3);
6477836SJohn.Forte@Sun.COM } else
6487836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 9, "%-16s", pfile);
6497836SJohn.Forte@Sun.COM
6507836SJohn.Forte@Sun.COM (void) attron(A_BOLD);
6517836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 26, "*");
6527836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 28, "*");
6537836SJohn.Forte@Sun.COM
6547836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 56, "%-8s", status[ind]);
6557836SJohn.Forte@Sun.COM (void) attroff(A_BOLD);
6567836SJohn.Forte@Sun.COM
6577836SJohn.Forte@Sun.COM if (ind == IND_RESYNC_REVERSE) {
6587836SJohn.Forte@Sun.COM if (bright && !(rdc_info[rdcindex].flags & RDC_LOGGING))
6597836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 27, "<");
6607836SJohn.Forte@Sun.COM if (rdc_info[rdcindex].flags & RDC_PRIMARY &&
6617836SJohn.Forte@Sun.COM !(rdc_info[rdcindex].flags & RDC_LOGGING))
6627836SJohn.Forte@Sun.COM calc_completion(rdcindex,
6637836SJohn.Forte@Sun.COM rdc_info[rdcindex].bits_set, 4 + k);
6647836SJohn.Forte@Sun.COM } else if (ind == IND_RESYNC) {
6657836SJohn.Forte@Sun.COM if (bright && !(rdc_info[rdcindex].flags & RDC_LOGGING))
6667836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 27, ">");
6677836SJohn.Forte@Sun.COM if (rdc_info[rdcindex].flags & RDC_PRIMARY &&
6687836SJohn.Forte@Sun.COM !(rdc_info[rdcindex].flags & RDC_LOGGING))
6697836SJohn.Forte@Sun.COM calc_completion(rdcindex,
6707836SJohn.Forte@Sun.COM rdc_info[rdcindex].bits_set, 4 + k);
6717836SJohn.Forte@Sun.COM } else if (ind == IND_LOGGING)
6727836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 27, ".");
6737836SJohn.Forte@Sun.COM else if (ind == IND_ENABLED)
6747836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 27, "=");
6757836SJohn.Forte@Sun.COM
6767836SJohn.Forte@Sun.COM if ((len = strlen(shost)) > 8) {
6777836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 30, ".%+7s:",
6787836SJohn.Forte@Sun.COM shost + len - 7);
6797836SJohn.Forte@Sun.COM } else
6807836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 30, "%+8s:", shost);
6817836SJohn.Forte@Sun.COM
6827836SJohn.Forte@Sun.COM if ((len = strlen(sfile)) > DISPLEN) {
6837836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 39, "...%-13s",
6847836SJohn.Forte@Sun.COM sfile + len - DISPLEN + 3);
6857836SJohn.Forte@Sun.COM } else
6867836SJohn.Forte@Sun.COM (void) mvprintw(4 + k, 39, "%-16s", sfile);
6877836SJohn.Forte@Sun.COM
6887836SJohn.Forte@Sun.COM k++;
6897836SJohn.Forte@Sun.COM }
6907836SJohn.Forte@Sun.COM
6917836SJohn.Forte@Sun.COM k += 5;
6927836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
6937836SJohn.Forte@Sun.COM for (i = 0; i < 80; i++)
6947836SJohn.Forte@Sun.COM (void) mvprintw(k, i, " ");
6957836SJohn.Forte@Sun.COM k += 2;
6967836SJohn.Forte@Sun.COM (void) mvprintw(k, 0, "partition");
6977836SJohn.Forte@Sun.COM (void) mvprintw(k, 16, "recovery needed");
6987836SJohn.Forte@Sun.COM (void) mvprintw(k, 48, "recovery completed");
6997836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
7007836SJohn.Forte@Sun.COM k += 2;
7017836SJohn.Forte@Sun.COM
7027836SJohn.Forte@Sun.COM for (rdcindex = 0; rdcindex < rdc_enabled_sets; rdcindex++) {
7037836SJohn.Forte@Sun.COM if (!(rdc_info[rdcindex].flags & RDC_ENABLED) ||
7047836SJohn.Forte@Sun.COM !dual_on_off[rdcindex])
7057836SJohn.Forte@Sun.COM continue;
7067836SJohn.Forte@Sun.COM
7077836SJohn.Forte@Sun.COM if (!(rdc_info[rdcindex].flags & RDC_PRIMARY)) {
7087836SJohn.Forte@Sun.COM continue;
7097836SJohn.Forte@Sun.COM }
7107836SJohn.Forte@Sun.COM if (!(rdc_info[rdcindex].flags & RDC_SLAVE) &&
7117836SJohn.Forte@Sun.COM !(rdc_info[rdcindex].flags & RDC_SYNCING) &&
7127836SJohn.Forte@Sun.COM !(rdc_info[rdcindex].flags & RDC_LOGGING)) {
7137836SJohn.Forte@Sun.COM continue;
7147836SJohn.Forte@Sun.COM }
7157836SJohn.Forte@Sun.COM
7167836SJohn.Forte@Sun.COM len = strlen(rdc_info[rdcindex].secondary.file);
7177836SJohn.Forte@Sun.COM if (len > 15) {
718*11576SSurya.Prakki@Sun.COM (void) strcpy(fn, "...");
719*11576SSurya.Prakki@Sun.COM (void) strcat(fn,
7207836SJohn.Forte@Sun.COM rdc_info[rdcindex].secondary.file + len - 12);
7217836SJohn.Forte@Sun.COM } else
722*11576SSurya.Prakki@Sun.COM (void) strcpy(fn, rdc_info[rdcindex].secondary.file);
7237836SJohn.Forte@Sun.COM (void) mvprintw(k, 0, "%-15s", fn);
7247836SJohn.Forte@Sun.COM
7257836SJohn.Forte@Sun.COM segs = FBA_TO_LOG_LEN(rdc_info[rdcindex].volume_size);
7267836SJohn.Forte@Sun.COM pct = segs ?
7277836SJohn.Forte@Sun.COM ((float)rdc_info[rdcindex].bits_set / (float)segs) : 0.0;
7287836SJohn.Forte@Sun.COM stars = (int)(pct * 20.0);
7297836SJohn.Forte@Sun.COM while (stars > 0) {
7307836SJohn.Forte@Sun.COM (void) mvprintw(k, 16 + stars, "*");
7317836SJohn.Forte@Sun.COM stars--;
7327836SJohn.Forte@Sun.COM }
7337836SJohn.Forte@Sun.COM (void) attron(A_BOLD);
7347836SJohn.Forte@Sun.COM (void) mvprintw(k, 16, "[");
7357836SJohn.Forte@Sun.COM (void) mvprintw(k, 37, "]");
7367836SJohn.Forte@Sun.COM (void) attroff(A_BOLD);
7377836SJohn.Forte@Sun.COM (void) mvprintw(k, 39, "%6.2f%%", pct * 100.0);
7387836SJohn.Forte@Sun.COM
7397836SJohn.Forte@Sun.COM if (rdc_info[rdcindex].flags & RDC_SYNCING)
7407836SJohn.Forte@Sun.COM pct = ((float)rdc_info[rdcindex].sync_pos /
7417836SJohn.Forte@Sun.COM (float)rdc_info[rdcindex].volume_size);
7427836SJohn.Forte@Sun.COM else
7437836SJohn.Forte@Sun.COM pct = 0.0;
7447836SJohn.Forte@Sun.COM stars = (int)(pct * 20.0);
7457836SJohn.Forte@Sun.COM while (stars > 0) {
7467836SJohn.Forte@Sun.COM (void) mvprintw(k, 48 + stars, "*");
7477836SJohn.Forte@Sun.COM stars--;
7487836SJohn.Forte@Sun.COM }
7497836SJohn.Forte@Sun.COM (void) attron(A_BOLD);
7507836SJohn.Forte@Sun.COM (void) mvprintw(k, 48, "[");
7517836SJohn.Forte@Sun.COM (void) mvprintw(k, 69, "]");
7527836SJohn.Forte@Sun.COM (void) attroff(A_BOLD);
7537836SJohn.Forte@Sun.COM (void) mvprintw(k, 70, "%6.2f%%", pct * 100.0);
7547836SJohn.Forte@Sun.COM k++;
7557836SJohn.Forte@Sun.COM }
7567836SJohn.Forte@Sun.COM bright = !bright;
7577836SJohn.Forte@Sun.COM return (0);
7587836SJohn.Forte@Sun.COM }
7597836SJohn.Forte@Sun.COM
7607836SJohn.Forte@Sun.COM /*
7617836SJohn.Forte@Sun.COM * Calculate a time interval in milliseconds using the
7627836SJohn.Forte@Sun.COM * micosecond counter
7637836SJohn.Forte@Sun.COM */
7647836SJohn.Forte@Sun.COM void
calc_time(void)7657836SJohn.Forte@Sun.COM calc_time(void)
7667836SJohn.Forte@Sun.COM {
7677836SJohn.Forte@Sun.COM unsigned int cur;
7687836SJohn.Forte@Sun.COM
7697836SJohn.Forte@Sun.COM cur = USEC_READ();
7707836SJohn.Forte@Sun.COM dc_delta_time = cur > dc_prev_time ? cur - dc_prev_time :
7717836SJohn.Forte@Sun.COM cur + 0xFFFFFFFF - dc_prev_time;
7727836SJohn.Forte@Sun.COM dc_delta_time /= 1000;
7737836SJohn.Forte@Sun.COM dc_prev_time = cur;
7747836SJohn.Forte@Sun.COM }
7757836SJohn.Forte@Sun.COM
7767836SJohn.Forte@Sun.COM /*
7777836SJohn.Forte@Sun.COM * Calculate estimated time of completion of resync
7787836SJohn.Forte@Sun.COM */
7797836SJohn.Forte@Sun.COM void
calc_completion(int cd,int updates_left,int l)7807836SJohn.Forte@Sun.COM calc_completion(int cd, int updates_left, int l)
7817836SJohn.Forte@Sun.COM {
7827836SJohn.Forte@Sun.COM int delta_done;
7837836SJohn.Forte@Sun.COM double rate;
7847836SJohn.Forte@Sun.COM long time_left;
7857836SJohn.Forte@Sun.COM long hours;
7867836SJohn.Forte@Sun.COM long minutes;
7877836SJohn.Forte@Sun.COM static int initted = 0;
7887836SJohn.Forte@Sun.COM
7897836SJohn.Forte@Sun.COM if (!initted) {
7907836SJohn.Forte@Sun.COM updates_prev[cd] = updates_left;
7917836SJohn.Forte@Sun.COM initted = 1;
7927836SJohn.Forte@Sun.COM return;
7937836SJohn.Forte@Sun.COM }
7947836SJohn.Forte@Sun.COM
7957836SJohn.Forte@Sun.COM /*
7967836SJohn.Forte@Sun.COM * Caclulate updates since last check
7977836SJohn.Forte@Sun.COM */
7987836SJohn.Forte@Sun.COM delta_done = updates_prev[cd] - updates_left;
7997836SJohn.Forte@Sun.COM updates_prev[cd] = updates_left;
8007836SJohn.Forte@Sun.COM
8017836SJohn.Forte@Sun.COM /*
8027836SJohn.Forte@Sun.COM * If no updates, don't bother estimating completion time
8037836SJohn.Forte@Sun.COM */
8047836SJohn.Forte@Sun.COM if (delta_done <= 0) {
8057836SJohn.Forte@Sun.COM samples[cd] = 0;
8067836SJohn.Forte@Sun.COM return;
8077836SJohn.Forte@Sun.COM }
8087836SJohn.Forte@Sun.COM
8097836SJohn.Forte@Sun.COM rate = delta_done * 1000.0 / dc_delta_time;
8107836SJohn.Forte@Sun.COM
8117836SJohn.Forte@Sun.COM /*
8127836SJohn.Forte@Sun.COM * Calculate rate of updates as a weighted average
8137836SJohn.Forte@Sun.COM * of previous and current rate
8147836SJohn.Forte@Sun.COM */
8157836SJohn.Forte@Sun.COM if (rate_prev[cd] && samples[cd] > SAMPLE_RATE)
8167836SJohn.Forte@Sun.COM rate = (rate_prev[cd] * 4.0 + rate) / 5.0;
8177836SJohn.Forte@Sun.COM rate_prev[cd] = rate;
8187836SJohn.Forte@Sun.COM samples[cd]++;
8197836SJohn.Forte@Sun.COM
8207836SJohn.Forte@Sun.COM /*
8217836SJohn.Forte@Sun.COM * Get enough samples before making estimate
8227836SJohn.Forte@Sun.COM */
8237836SJohn.Forte@Sun.COM if (samples[cd]++ < SAMPLE_RATE)
8247836SJohn.Forte@Sun.COM return;
8257836SJohn.Forte@Sun.COM
8267836SJohn.Forte@Sun.COM time_left = (long)(updates_left/rate); /* time left in seconds */
8277836SJohn.Forte@Sun.COM
8287836SJohn.Forte@Sun.COM if (time_left < 0)
8297836SJohn.Forte@Sun.COM return;
8307836SJohn.Forte@Sun.COM
8317836SJohn.Forte@Sun.COM hours = time_left / (60 * 60);
8327836SJohn.Forte@Sun.COM time_left -= hours * (60 * 60);
8337836SJohn.Forte@Sun.COM minutes = time_left / 60;
8347836SJohn.Forte@Sun.COM time_left -= minutes * 60;
8357836SJohn.Forte@Sun.COM (void) mvprintw(l, 67,
8367836SJohn.Forte@Sun.COM "time %02d:%02d:%02d \n", hours, minutes, time_left);
8377836SJohn.Forte@Sun.COM }
8387836SJohn.Forte@Sun.COM
8397836SJohn.Forte@Sun.COM void
disp_total_stats(void)8407836SJohn.Forte@Sun.COM disp_total_stats(void)
8417836SJohn.Forte@Sun.COM {
8427836SJohn.Forte@Sun.COM unsigned int read_s, write_s, access_s;
8437836SJohn.Forte@Sun.COM double readp, writep;
8447836SJohn.Forte@Sun.COM unsigned int rmiss_s, wmiss_s;
8457836SJohn.Forte@Sun.COM double kbps = 2.0;
8467836SJohn.Forte@Sun.COM int rtotal, wtotal, i, j;
8477836SJohn.Forte@Sun.COM unsigned int throughput = 0, rthroughput = 0, creads = 0, cwrites = 0;
8487836SJohn.Forte@Sun.COM char status_bit, down = 0;
8497836SJohn.Forte@Sun.COM int len;
8507836SJohn.Forte@Sun.COM char fn[19];
8517836SJohn.Forte@Sun.COM
8527836SJohn.Forte@Sun.COM read_s = cs_cur->st_rdhits;
8537836SJohn.Forte@Sun.COM write_s = cs_cur->st_wrhits;
8547836SJohn.Forte@Sun.COM rmiss_s = cs_cur->st_rdmiss;
8557836SJohn.Forte@Sun.COM wmiss_s = cs_cur->st_wrmiss;
8567836SJohn.Forte@Sun.COM access_s = (read_s + write_s + rmiss_s + wmiss_s);
8577836SJohn.Forte@Sun.COM
8587836SJohn.Forte@Sun.COM rtotal = cs_cur->st_rdhits + cs_cur->st_rdmiss;
8597836SJohn.Forte@Sun.COM wtotal = cs_cur->st_wrhits + cs_cur->st_wrmiss;
8607836SJohn.Forte@Sun.COM if (rtotal != 0)
8617836SJohn.Forte@Sun.COM readp = cs_cur->st_rdhits / (double)rtotal;
8627836SJohn.Forte@Sun.COM else
8637836SJohn.Forte@Sun.COM readp = 0.0;
8647836SJohn.Forte@Sun.COM
8657836SJohn.Forte@Sun.COM if (wtotal != 0)
8667836SJohn.Forte@Sun.COM writep = cs_cur->st_wrhits / (double)wtotal;
8677836SJohn.Forte@Sun.COM else
8687836SJohn.Forte@Sun.COM writep = 0.0;
8697836SJohn.Forte@Sun.COM
8707836SJohn.Forte@Sun.COM set_on_off();
8717836SJohn.Forte@Sun.COM (void) mvprintw(0, 14,
8727836SJohn.Forte@Sun.COM "****** Storage Cache (Cumulative) ******");
8737836SJohn.Forte@Sun.COM (void) mvprintw(2, 30, "disk_io cache");
8747836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
8757836SJohn.Forte@Sun.COM (void) mvprintw(3, 1,
8767836SJohn.Forte@Sun.COM " cd cached_partition reads writes reads writes");
8777836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
8787836SJohn.Forte@Sun.COM for (i = 0, j = 0; j < cs_cur->st_count; i++) {
8797836SJohn.Forte@Sun.COM if (i >= sdbc_max_devices)
8807836SJohn.Forte@Sun.COM break;
8817836SJohn.Forte@Sun.COM if (cs_cur->st_shared[i].sh_alloc) {
8827836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_disk_write /= kbps;
8837836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_disk_read /= kbps;
8847836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_cache_write /= kbps;
8857836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_cache_read /= kbps;
8867836SJohn.Forte@Sun.COM rthroughput += cs_cur->st_shared[i].sh_disk_read;
8877836SJohn.Forte@Sun.COM throughput += cs_cur->st_shared[i].sh_disk_write;
8887836SJohn.Forte@Sun.COM creads += cs_cur->st_shared[i].sh_cache_read;
8897836SJohn.Forte@Sun.COM cwrites += cs_cur->st_shared[i].sh_cache_write;
8907836SJohn.Forte@Sun.COM if (!down)
8917836SJohn.Forte@Sun.COM down = cs_cur->st_shared[i].sh_failed;
8927836SJohn.Forte@Sun.COM if (cs_cur->st_shared[i].sh_failed && bright)
8937836SJohn.Forte@Sun.COM status_bit = '*';
8947836SJohn.Forte@Sun.COM else
8957836SJohn.Forte@Sun.COM status_bit = ' ';
8967836SJohn.Forte@Sun.COM if ((len =
8977836SJohn.Forte@Sun.COM strlen(cs_cur->st_shared[i].sh_filename)) > 15) {
898*11576SSurya.Prakki@Sun.COM (void) strcpy(fn, "...");
899*11576SSurya.Prakki@Sun.COM (void) strcat(fn,
900*11576SSurya.Prakki@Sun.COM cs_cur->st_shared[i].sh_filename +
9017836SJohn.Forte@Sun.COM len - 12);
9027836SJohn.Forte@Sun.COM } else
903*11576SSurya.Prakki@Sun.COM (void) strcpy(fn,
904*11576SSurya.Prakki@Sun.COM cs_cur->st_shared[i].sh_filename);
9057836SJohn.Forte@Sun.COM
9067836SJohn.Forte@Sun.COM if (on_off[i]) {
9077836SJohn.Forte@Sun.COM (void) mvprintw(4 + j, 1,
9087836SJohn.Forte@Sun.COM "%3d %-15s%c %10u %10u %10u %10u",
9097836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_cd,
9107836SJohn.Forte@Sun.COM fn,
9117836SJohn.Forte@Sun.COM status_bit,
9127836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_disk_read,
9137836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_disk_write,
9147836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_cache_read,
9157836SJohn.Forte@Sun.COM cs_cur->st_shared[i].sh_cache_write);
9167836SJohn.Forte@Sun.COM j++;
9177836SJohn.Forte@Sun.COM }
9187836SJohn.Forte@Sun.COM }
9197836SJohn.Forte@Sun.COM }
9207836SJohn.Forte@Sun.COM bright = !bright;
9217836SJohn.Forte@Sun.COM
9227836SJohn.Forte@Sun.COM (void) mvprintw(4 + j, 22,
9237836SJohn.Forte@Sun.COM "---------- ---------- ---------- ----------");
9247836SJohn.Forte@Sun.COM (void) mvprintw(5 + j, 8, " Kbytes total:%10u %10u %10u %10u",
9257836SJohn.Forte@Sun.COM (int)rthroughput, (int)throughput,
9267836SJohn.Forte@Sun.COM (int)creads, (int)cwrites);
9277836SJohn.Forte@Sun.COM (void) mvprintw(7 + j, 1, " accesses");
9287836SJohn.Forte@Sun.COM (void) mvprintw(7 + j, 18, "read write %%readh %%writeh");
9297836SJohn.Forte@Sun.COM
9307836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
9317836SJohn.Forte@Sun.COM (void) mvprintw(8 + j, 1, " ");
9327836SJohn.Forte@Sun.COM (void) mvprintw(8 + j, 13,
9337836SJohn.Forte@Sun.COM " ");
9347836SJohn.Forte@Sun.COM (void) mvprintw(8 + j, 11, "( misses) ( misses)");
9357836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
9367836SJohn.Forte@Sun.COM
9377836SJohn.Forte@Sun.COM (void) mvprintw(9 + j, 0, "%10u %10u %10u %6.1f %6.1f",
9387836SJohn.Forte@Sun.COM access_s, read_s, write_s, readp*100.0, writep*100.0);
9397836SJohn.Forte@Sun.COM (void) mvprintw(10 + j, 0,
9407836SJohn.Forte@Sun.COM " (%10u) (%10u)\n\n", rmiss_s, wmiss_s);
9417836SJohn.Forte@Sun.COM
9427836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
9437836SJohn.Forte@Sun.COM (void) mvprintw(13 + j, 1, "cachesize blocksize");
9447836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
9457836SJohn.Forte@Sun.COM (void) mvprintw(14 + j, 1, "%8dK %10d", cs_cur->st_cachesize / 1024,
9467836SJohn.Forte@Sun.COM cs_cur->st_blksize);
9477836SJohn.Forte@Sun.COM
9487836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
9497836SJohn.Forte@Sun.COM (void) mvprintw(16 + j, 1, "Write blocks available:");
9507836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
9517836SJohn.Forte@Sun.COM (void) mvprintw(17 + j, 1, "Net 0: %6d", cs_cur->st_wlru_inq);
9527836SJohn.Forte@Sun.COM
9537836SJohn.Forte@Sun.COM (void) attron(A_UNDERLINE);
9547836SJohn.Forte@Sun.COM (void) mvprintw(19 + j, 1, "LRU stats: Blocks Requeued Optimized");
9557836SJohn.Forte@Sun.COM (void) attroff(A_UNDERLINE);
9567836SJohn.Forte@Sun.COM (void) mvprintw(20 + j, 7, "%12d %12u %12u", cs_cur->st_lru_blocks,
9577836SJohn.Forte@Sun.COM cs_cur->st_lru_req, cs_cur->st_lru_noreq);
9587836SJohn.Forte@Sun.COM
9597836SJohn.Forte@Sun.COM if (down)
9607836SJohn.Forte@Sun.COM (void) mvprintw(25 + j, 1, "* -- disk off-line");
9617836SJohn.Forte@Sun.COM }
962