1fcf3ce44SJohn Forte /* 2fcf3ce44SJohn Forte * CDDL HEADER START 3fcf3ce44SJohn Forte * 4fcf3ce44SJohn Forte * The contents of this file are subject to the terms of the 5fcf3ce44SJohn Forte * Common Development and Distribution License (the "License"). 6fcf3ce44SJohn Forte * You may not use this file except in compliance with the License. 7fcf3ce44SJohn Forte * 8fcf3ce44SJohn Forte * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 9fcf3ce44SJohn Forte * or http://www.opensolaris.org/os/licensing. 10fcf3ce44SJohn Forte * See the License for the specific language governing permissions 11fcf3ce44SJohn Forte * and limitations under the License. 12fcf3ce44SJohn Forte * 13fcf3ce44SJohn Forte * When distributing Covered Code, include this CDDL HEADER in each 14fcf3ce44SJohn Forte * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 15fcf3ce44SJohn Forte * If applicable, add the following below this CDDL HEADER, with the 16fcf3ce44SJohn Forte * fields enclosed by brackets "[]" replaced with your own identifying 17fcf3ce44SJohn Forte * information: Portions Copyright [yyyy] [name of copyright owner] 18fcf3ce44SJohn Forte * 19fcf3ce44SJohn Forte * CDDL HEADER END 20fcf3ce44SJohn Forte */ 21fcf3ce44SJohn Forte /* 22*570de38fSSurya Prakki * Copyright 2010 Sun Microsystems, Inc. All rights reserved. 23fcf3ce44SJohn Forte * Use is subject to license terms. 24fcf3ce44SJohn Forte */ 25fcf3ce44SJohn Forte 26fcf3ce44SJohn Forte #include <stdio.h> 27fcf3ce44SJohn Forte #include <stdlib.h> 28fcf3ce44SJohn Forte #include <string.h> 29fcf3ce44SJohn Forte #include <unistd.h> 30fcf3ce44SJohn Forte #include <errno.h> 31fcf3ce44SJohn Forte #include <signal.h> 32fcf3ce44SJohn Forte #include <setjmp.h> 33fcf3ce44SJohn Forte 34fcf3ce44SJohn Forte #include <kstat.h> 35fcf3ce44SJohn Forte 36fcf3ce44SJohn Forte #include <sys/nsctl/rdc.h> 37fcf3ce44SJohn Forte #include <sys/nsctl/rdc_io.h> 38fcf3ce44SJohn Forte #include <sys/nsctl/rdc_bitmap.h> 39fcf3ce44SJohn Forte 40fcf3ce44SJohn Forte #include "sdbc_stats.h" 41fcf3ce44SJohn Forte #include "sndr_stats.h" 42fcf3ce44SJohn Forte 43fcf3ce44SJohn Forte #include "dsstat.h" 44fcf3ce44SJohn Forte #include "common.h" 45fcf3ce44SJohn Forte #include "report.h" 46fcf3ce44SJohn Forte 47fcf3ce44SJohn Forte static sndrstat_t *sndr_top; 48fcf3ce44SJohn Forte 49fcf3ce44SJohn Forte void sndr_add_stat(sndrstat_t *); 50fcf3ce44SJohn Forte sndrstat_t *sndr_del_stat(sndrstat_t *); 51fcf3ce44SJohn Forte 52fcf3ce44SJohn Forte int sndr_value_check(sndrstat_t *); 53fcf3ce44SJohn Forte int sndr_validate(kstat_t *); 54fcf3ce44SJohn Forte int sndr_strcmp(char *, char *); 55fcf3ce44SJohn Forte int sndr_vol_selected(kstat_t *); 56fcf3ce44SJohn Forte 57fcf3ce44SJohn Forte void getType(kstat_t *, char *); 58fcf3ce44SJohn Forte void getStat(kstat_t *, char *); 59fcf3ce44SJohn Forte void getQueue(kstat_t *, char *); 60fcf3ce44SJohn Forte void printQueueStats(int, kstat_t *); 61fcf3ce44SJohn Forte float getSyncNeeded(kstat_t *); 62fcf3ce44SJohn Forte 63fcf3ce44SJohn Forte static void update_sighandler(int); 64fcf3ce44SJohn Forte static void discover_sighandler(int); 65fcf3ce44SJohn Forte 66fcf3ce44SJohn Forte static sigjmp_buf update_env, discover_env; 67fcf3ce44SJohn Forte static sig_atomic_t sig_raised = 0; 68fcf3ce44SJohn Forte /* 69fcf3ce44SJohn Forte * sndr_discover() - looks for new statistics to be monitored. 70fcf3ce44SJohn Forte * Verifies that any statistics found are now already being 71fcf3ce44SJohn Forte * monitored. 72fcf3ce44SJohn Forte * 73fcf3ce44SJohn Forte */ 74fcf3ce44SJohn Forte int 75fcf3ce44SJohn Forte sndr_discover(kstat_ctl_t *kc) 76fcf3ce44SJohn Forte { 77fcf3ce44SJohn Forte static int validated = 0; 78fcf3ce44SJohn Forte struct sigaction segv_act; 79fcf3ce44SJohn Forte int rc = 0; 80fcf3ce44SJohn Forte kstat_t *ksp; 81fcf3ce44SJohn Forte 82fcf3ce44SJohn Forte 83fcf3ce44SJohn Forte (void) signal(SIGSEGV, discover_sighandler); 84fcf3ce44SJohn Forte (void) sigaction(SIGSEGV, NULL, &segv_act); 85fcf3ce44SJohn Forte 86fcf3ce44SJohn Forte /* Loop on all kstats */ 87fcf3ce44SJohn Forte for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) { 88fcf3ce44SJohn Forte int kinst; 89fcf3ce44SJohn Forte char kname[KSTAT_STRLEN + 1]; 90fcf3ce44SJohn Forte sndrstat_t *cur; 91fcf3ce44SJohn Forte sndrstat_t *sndrstat = NULL; 92fcf3ce44SJohn Forte kstat_t *bmp_ksp; 93fcf3ce44SJohn Forte kstat_t *sec_ksp; 94fcf3ce44SJohn Forte 95fcf3ce44SJohn Forte /* Serach for SNDR set */ 96fcf3ce44SJohn Forte if (strcmp(ksp->ks_module, RDC_KSTAT_MODULE) != 0 || 97fcf3ce44SJohn Forte strcmp(ksp->ks_name, RDC_KSTAT_INFO) != 0) { 98fcf3ce44SJohn Forte continue; 99fcf3ce44SJohn Forte } 100fcf3ce44SJohn Forte 101fcf3ce44SJohn Forte if (kstat_read(kc, ksp, NULL) == -1) 102fcf3ce44SJohn Forte continue; 103fcf3ce44SJohn Forte 104fcf3ce44SJohn Forte /* 105fcf3ce44SJohn Forte * Validate kstat structure 106fcf3ce44SJohn Forte */ 107fcf3ce44SJohn Forte if (! validated) { 108fcf3ce44SJohn Forte if (sndr_validate(ksp)) 109fcf3ce44SJohn Forte return (EINVAL); 110fcf3ce44SJohn Forte 111fcf3ce44SJohn Forte validated++; 112fcf3ce44SJohn Forte } 113fcf3ce44SJohn Forte 114fcf3ce44SJohn Forte /* 115fcf3ce44SJohn Forte * Duplicate check 116fcf3ce44SJohn Forte */ 117fcf3ce44SJohn Forte for (cur = sndr_top; cur != NULL; cur = cur->next) { 118fcf3ce44SJohn Forte char *cur_vname, *tst_vname; 119fcf3ce44SJohn Forte uint32_t cur_inst, tst_inst; 120fcf3ce44SJohn Forte 121fcf3ce44SJohn Forte cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE); 122fcf3ce44SJohn Forte cur_inst = cur->pre_set->ks_instance; 123fcf3ce44SJohn Forte 124fcf3ce44SJohn Forte tst_vname = kstat_value(ksp, RDC_IKSTAT_FILE); 125fcf3ce44SJohn Forte tst_inst = ksp->ks_instance; 126fcf3ce44SJohn Forte 127fcf3ce44SJohn Forte if (strcmp(cur_vname, tst_vname) == 0 && 128fcf3ce44SJohn Forte cur_inst == tst_inst) 129fcf3ce44SJohn Forte goto next; 130fcf3ce44SJohn Forte } 131fcf3ce44SJohn Forte 132fcf3ce44SJohn Forte /* 133fcf3ce44SJohn Forte * Initialize new record 134fcf3ce44SJohn Forte */ 135fcf3ce44SJohn Forte sndrstat = (sndrstat_t *)calloc(1, sizeof (sndrstat_t)); 136fcf3ce44SJohn Forte kinst = ksp->ks_instance; 137fcf3ce44SJohn Forte 138fcf3ce44SJohn Forte /* 139fcf3ce44SJohn Forte * Set kstat 140fcf3ce44SJohn Forte */ 141fcf3ce44SJohn Forte sndrstat->pre_set = kstat_retrieve(kc, ksp); 142fcf3ce44SJohn Forte 143fcf3ce44SJohn Forte if (sndrstat->pre_set == NULL) 144fcf3ce44SJohn Forte goto next; 145fcf3ce44SJohn Forte 146fcf3ce44SJohn Forte sndrstat->collected |= GOT_SET_KSTAT; 147fcf3ce44SJohn Forte 148fcf3ce44SJohn Forte /* 149fcf3ce44SJohn Forte * Bitmap kstat 150fcf3ce44SJohn Forte */ 151fcf3ce44SJohn Forte (void) sprintf(kname, "%s%d", RDC_KSTAT_BMPNAME, kinst); 152fcf3ce44SJohn Forte 153fcf3ce44SJohn Forte bmp_ksp = kstat_lookup(kc, RDC_KSTAT_BMPNAME, kinst, kname); 154fcf3ce44SJohn Forte sndrstat->pre_bmp = kstat_retrieve(kc, bmp_ksp); 155fcf3ce44SJohn Forte 156fcf3ce44SJohn Forte if (sndrstat->pre_bmp == NULL) 157fcf3ce44SJohn Forte goto next; 158fcf3ce44SJohn Forte 159fcf3ce44SJohn Forte sndrstat->collected |= GOT_BMP_KSTAT; 160fcf3ce44SJohn Forte 161fcf3ce44SJohn Forte /* 162fcf3ce44SJohn Forte * Secondary kstat 163fcf3ce44SJohn Forte */ 164fcf3ce44SJohn Forte (void) sprintf(kname, "%s%d", RDC_KSTAT_RDCNAME, kinst); 165fcf3ce44SJohn Forte 166fcf3ce44SJohn Forte sec_ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname); 167fcf3ce44SJohn Forte sndrstat->pre_sec = kstat_retrieve(kc, sec_ksp); 168fcf3ce44SJohn Forte 169fcf3ce44SJohn Forte if (sndrstat->pre_sec == NULL) 170fcf3ce44SJohn Forte goto next; 171fcf3ce44SJohn Forte 172fcf3ce44SJohn Forte sndrstat->collected |= GOT_SEC_KSTAT; 173fcf3ce44SJohn Forte 174fcf3ce44SJohn Forte next: 175fcf3ce44SJohn Forte /* 176fcf3ce44SJohn Forte * Check if we got a complete set of stats 177fcf3ce44SJohn Forte */ 178fcf3ce44SJohn Forte if (sndrstat == NULL) 179fcf3ce44SJohn Forte continue; 180fcf3ce44SJohn Forte 181fcf3ce44SJohn Forte if (SNDR_COMPLETE(sndrstat->collected)) { 182fcf3ce44SJohn Forte (void) sndr_del_stat(sndrstat); 183fcf3ce44SJohn Forte continue; 184fcf3ce44SJohn Forte } 185fcf3ce44SJohn Forte 186fcf3ce44SJohn Forte /* 187fcf3ce44SJohn Forte * Add to linked list 188fcf3ce44SJohn Forte */ 189fcf3ce44SJohn Forte sndr_add_stat(sndrstat); 190fcf3ce44SJohn Forte } 191fcf3ce44SJohn Forte 192fcf3ce44SJohn Forte (void) sigsetjmp(discover_env, 0); 193fcf3ce44SJohn Forte if (sig_raised) { 194fcf3ce44SJohn Forte sig_raised = 0; 195fcf3ce44SJohn Forte rc = -1; 196fcf3ce44SJohn Forte } 197fcf3ce44SJohn Forte (void) sigaction(SIGSEGV, &segv_act, NULL); 198fcf3ce44SJohn Forte 199fcf3ce44SJohn Forte return (rc); 200fcf3ce44SJohn Forte } 201fcf3ce44SJohn Forte 202fcf3ce44SJohn Forte void 203fcf3ce44SJohn Forte discover_sighandler(int sig) 204fcf3ce44SJohn Forte { 205fcf3ce44SJohn Forte switch (sig) { 206fcf3ce44SJohn Forte case SIGSEGV: 207fcf3ce44SJohn Forte sig_raised = 1; 208fcf3ce44SJohn Forte siglongjmp(discover_env, sig); 209fcf3ce44SJohn Forte default: 210fcf3ce44SJohn Forte exit(sig); 211fcf3ce44SJohn Forte } 212fcf3ce44SJohn Forte } 213fcf3ce44SJohn Forte 214fcf3ce44SJohn Forte void 215fcf3ce44SJohn Forte update_sighandler(int sig) 216fcf3ce44SJohn Forte { 217fcf3ce44SJohn Forte switch (sig) { 218fcf3ce44SJohn Forte case SIGSEGV: 219fcf3ce44SJohn Forte sig_raised = 1; 220fcf3ce44SJohn Forte siglongjmp(update_env, sig); 221fcf3ce44SJohn Forte default: 222fcf3ce44SJohn Forte exit(sig); 223fcf3ce44SJohn Forte } 224fcf3ce44SJohn Forte } 225fcf3ce44SJohn Forte 226fcf3ce44SJohn Forte /* 227fcf3ce44SJohn Forte * sndr_update() - updates all of the statistics currently being monitored. 228fcf3ce44SJohn Forte * 229fcf3ce44SJohn Forte */ 230fcf3ce44SJohn Forte int 231fcf3ce44SJohn Forte sndr_update(kstat_ctl_t *kc) 232fcf3ce44SJohn Forte { 233fcf3ce44SJohn Forte sndrstat_t *cur; 234fcf3ce44SJohn Forte struct sigaction segv_act; 235fcf3ce44SJohn Forte int rc = 0; 236fcf3ce44SJohn Forte 237fcf3ce44SJohn Forte (void) signal(SIGSEGV, update_sighandler); 238fcf3ce44SJohn Forte (void) sigaction(SIGSEGV, NULL, &segv_act); 239fcf3ce44SJohn Forte 240fcf3ce44SJohn Forte for (cur = sndr_top; cur != NULL; cur = cur->next) { 241fcf3ce44SJohn Forte int kinst; 242fcf3ce44SJohn Forte char kname[KSTAT_STRLEN + 1]; 243fcf3ce44SJohn Forte kstat_t *ksp = NULL; 244fcf3ce44SJohn Forte char *cur_vname, *tst_vname; 245fcf3ce44SJohn Forte 246fcf3ce44SJohn Forte cur->collected = 0; 247fcf3ce44SJohn Forte 248fcf3ce44SJohn Forte /* 249fcf3ce44SJohn Forte * Age off old stats 250fcf3ce44SJohn Forte */ 251fcf3ce44SJohn Forte if (cur->cur_set != NULL) { 252fcf3ce44SJohn Forte kstat_free(cur->pre_set); 253fcf3ce44SJohn Forte kstat_free(cur->pre_bmp); 254fcf3ce44SJohn Forte kstat_free(cur->pre_sec); 255fcf3ce44SJohn Forte 256fcf3ce44SJohn Forte cur->pre_set = cur->cur_set; 257fcf3ce44SJohn Forte cur->pre_bmp = cur->cur_bmp; 258fcf3ce44SJohn Forte cur->pre_sec = cur->cur_sec; 259fcf3ce44SJohn Forte } 260fcf3ce44SJohn Forte 261fcf3ce44SJohn Forte /* 262fcf3ce44SJohn Forte * Set kstat 263fcf3ce44SJohn Forte */ 264*570de38fSSurya Prakki (void) strncpy(kname, cur->pre_set->ks_name, KSTAT_STRLEN); 265fcf3ce44SJohn Forte kname[KSTAT_STRLEN] = '\0'; 266fcf3ce44SJohn Forte 267fcf3ce44SJohn Forte kinst = cur->pre_set->ks_instance; 268fcf3ce44SJohn Forte 269fcf3ce44SJohn Forte ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname); 270fcf3ce44SJohn Forte 271fcf3ce44SJohn Forte if ((cur->cur_set = kstat_retrieve(kc, ksp)) == NULL) 272fcf3ce44SJohn Forte continue; 273fcf3ce44SJohn Forte 274fcf3ce44SJohn Forte cur->collected |= GOT_SET_KSTAT; 275fcf3ce44SJohn Forte 276fcf3ce44SJohn Forte /* 277fcf3ce44SJohn Forte * Validate set 278fcf3ce44SJohn Forte */ 279fcf3ce44SJohn Forte cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE); 280fcf3ce44SJohn Forte tst_vname = kstat_value(cur->cur_set, RDC_IKSTAT_FILE); 281fcf3ce44SJohn Forte 282fcf3ce44SJohn Forte if (strcmp(cur_vname, tst_vname) != 0) 283fcf3ce44SJohn Forte continue; 284fcf3ce44SJohn Forte 285fcf3ce44SJohn Forte /* 286fcf3ce44SJohn Forte * Bitmap kstat 287fcf3ce44SJohn Forte */ 288fcf3ce44SJohn Forte (void) sprintf(kname, "%s%d", RDC_KSTAT_BMPNAME, kinst); 289fcf3ce44SJohn Forte 290fcf3ce44SJohn Forte ksp = kstat_lookup(kc, RDC_KSTAT_BMPNAME, kinst, kname); 291fcf3ce44SJohn Forte 292fcf3ce44SJohn Forte if ((cur->cur_bmp = kstat_retrieve(kc, ksp)) == NULL) 293fcf3ce44SJohn Forte continue; 294fcf3ce44SJohn Forte 295fcf3ce44SJohn Forte cur->collected |= GOT_BMP_KSTAT; 296fcf3ce44SJohn Forte 297fcf3ce44SJohn Forte /* 298fcf3ce44SJohn Forte * Secondary kstat 299fcf3ce44SJohn Forte */ 300fcf3ce44SJohn Forte (void) sprintf(kname, "%s%d", RDC_KSTAT_RDCNAME, kinst); 301fcf3ce44SJohn Forte 302fcf3ce44SJohn Forte ksp = kstat_lookup(kc, RDC_KSTAT_MODULE, kinst, kname); 303fcf3ce44SJohn Forte 304fcf3ce44SJohn Forte if ((cur->cur_sec = kstat_retrieve(kc, ksp)) == NULL) 305fcf3ce44SJohn Forte continue; 306fcf3ce44SJohn Forte 307fcf3ce44SJohn Forte cur->collected |= GOT_SEC_KSTAT; 308fcf3ce44SJohn Forte 309fcf3ce44SJohn Forte } 310fcf3ce44SJohn Forte 311fcf3ce44SJohn Forte (void) sigsetjmp(update_env, 0); 312fcf3ce44SJohn Forte if (sig_raised) { 313fcf3ce44SJohn Forte sig_raised = 0; 314fcf3ce44SJohn Forte rc = -1; 315fcf3ce44SJohn Forte } 316fcf3ce44SJohn Forte (void) sigaction(SIGSEGV, &segv_act, NULL); 317fcf3ce44SJohn Forte 318fcf3ce44SJohn Forte return (rc); 319fcf3ce44SJohn Forte } 320fcf3ce44SJohn Forte 321fcf3ce44SJohn Forte /* 322fcf3ce44SJohn Forte * sndr_report() - outputs statistics for the statistics currently being 323fcf3ce44SJohn Forte * monitored. Deletes statistics for volumes that have been disabled. 324fcf3ce44SJohn Forte * 325fcf3ce44SJohn Forte */ 326fcf3ce44SJohn Forte int 327fcf3ce44SJohn Forte sndr_report() 328fcf3ce44SJohn Forte { 329fcf3ce44SJohn Forte int padsz; 330fcf3ce44SJohn Forte char pad[20] = ""; 331fcf3ce44SJohn Forte sndrstat_t *cur, *pre = NULL; 332fcf3ce44SJohn Forte 333fcf3ce44SJohn Forte if (sndr_top == NULL) 334fcf3ce44SJohn Forte return (0); 335fcf3ce44SJohn Forte 336fcf3ce44SJohn Forte /* Create padding string for secondary report lines */ 337fcf3ce44SJohn Forte padsz = 0; 338fcf3ce44SJohn Forte if (dflags & FLAGS) { 339fcf3ce44SJohn Forte padsz += STAT_HDR_SIZE; 340fcf3ce44SJohn Forte padsz += STAT_HDR_SIZE; 341fcf3ce44SJohn Forte } 342fcf3ce44SJohn Forte 343fcf3ce44SJohn Forte if (dflags & ASYNC_QUEUE) 344fcf3ce44SJohn Forte padsz += STAT_HDR_SIZE; 345fcf3ce44SJohn Forte 346fcf3ce44SJohn Forte if (dflags & PCTS) 347fcf3ce44SJohn Forte padsz += PCT_HDR_SIZE; 348fcf3ce44SJohn Forte 349fcf3ce44SJohn Forte if (padsz) { 350fcf3ce44SJohn Forte char fmt[20]; 351*570de38fSSurya Prakki (void) sprintf(fmt, "%%%ds", padsz); 352*570de38fSSurya Prakki (void) sprintf(pad, fmt, " "); 353fcf3ce44SJohn Forte } 354fcf3ce44SJohn Forte 355fcf3ce44SJohn Forte for (cur = sndr_top; cur != NULL; ) { /*CSTYLED */ 356fcf3ce44SJohn Forte int first = 1; 357fcf3ce44SJohn Forte char data[20] = ""; 358fcf3ce44SJohn Forte 359fcf3ce44SJohn Forte /* Check to see if this is this a complete */ 360fcf3ce44SJohn Forte if (SNDR_COMPLETE(cur->collected)) { 361fcf3ce44SJohn Forte char *c; 362fcf3ce44SJohn Forte char vn[NSC_MAXPATH + 1]; 363fcf3ce44SJohn Forte sndrstat_t *next; 364fcf3ce44SJohn Forte 365fcf3ce44SJohn Forte /* notify user of set being disabled */ 366fcf3ce44SJohn Forte c = kstat_value(cur->pre_set, RDC_IKSTAT_SECFILE); 367*570de38fSSurya Prakki (void) strncpy(vn, c, NSC_MAXPATH); 368fcf3ce44SJohn Forte vn[NSC_MAXPATH] = '\0'; 369fcf3ce44SJohn Forte 370*570de38fSSurya Prakki (void) printf(DATA_C16, vn); 371*570de38fSSurya Prakki (void) printf(" %s\n", RDC_DISABLED); 372fcf3ce44SJohn Forte 373fcf3ce44SJohn Forte next = sndr_del_stat(cur); 374fcf3ce44SJohn Forte 375fcf3ce44SJohn Forte /* free memory and remove stat from list */ 376fcf3ce44SJohn Forte if (! pre) 377fcf3ce44SJohn Forte cur = sndr_top = next; 378fcf3ce44SJohn Forte else 379fcf3ce44SJohn Forte cur = pre->next = next; 380fcf3ce44SJohn Forte 381fcf3ce44SJohn Forte continue; 382fcf3ce44SJohn Forte } 383fcf3ce44SJohn Forte 384fcf3ce44SJohn Forte /* Check to see if the user specified this volume */ 385fcf3ce44SJohn Forte if (! sndr_vol_selected(cur->pre_set)) 386fcf3ce44SJohn Forte goto next; 387fcf3ce44SJohn Forte 388fcf3ce44SJohn Forte /* Check to see if zflag applies */ 389fcf3ce44SJohn Forte if (zflag && sndr_value_check(cur) == 0) 390fcf3ce44SJohn Forte goto next; 391fcf3ce44SJohn Forte 392fcf3ce44SJohn Forte /* Calculate flags */ 393fcf3ce44SJohn Forte if (dflags & FLAGS) { 394fcf3ce44SJohn Forte char c[STAT_HDR_SIZE]; 395fcf3ce44SJohn Forte char vtype[STAT_HDR_SIZE]; 396fcf3ce44SJohn Forte char vstat[STAT_HDR_SIZE]; 397fcf3ce44SJohn Forte 398fcf3ce44SJohn Forte getType(cur->cur_set, &c[0]); 399*570de38fSSurya Prakki (void) sprintf(vtype, DATA_C2, c); 400*570de38fSSurya Prakki (void) strcat(data, vtype); 401fcf3ce44SJohn Forte 402fcf3ce44SJohn Forte getStat(cur->cur_set, &c[0]); 403*570de38fSSurya Prakki (void) sprintf(vstat, DATA_C2, c); 404*570de38fSSurya Prakki (void) strcat(data, vstat); 405fcf3ce44SJohn Forte } 406fcf3ce44SJohn Forte 407fcf3ce44SJohn Forte /* Async. queue statistics */ 408fcf3ce44SJohn Forte if (dflags & ASYNC_QUEUE) { 409fcf3ce44SJohn Forte char c[STAT_HDR_SIZE]; 410fcf3ce44SJohn Forte char qtype[STAT_HDR_SIZE]; 411fcf3ce44SJohn Forte 412fcf3ce44SJohn Forte getQueue(cur->cur_set, &c[0]); 413*570de38fSSurya Prakki (void) sprintf(qtype, DATA_C2, c); 414*570de38fSSurya Prakki (void) strcat(data, qtype); 415fcf3ce44SJohn Forte } 416fcf3ce44SJohn Forte 417fcf3ce44SJohn Forte /* Calculate sync needed percentages */ 418fcf3ce44SJohn Forte if (dflags & PCTS) { 419fcf3ce44SJohn Forte char snpct[10]; 420fcf3ce44SJohn Forte 421*570de38fSSurya Prakki (void) sprintf(snpct, DATA_F62, 422*570de38fSSurya Prakki getSyncNeeded(cur->cur_set)); 423*570de38fSSurya Prakki (void) strcat(data, snpct); 424fcf3ce44SJohn Forte } 425fcf3ce44SJohn Forte 426fcf3ce44SJohn Forte /* Output */ 427fcf3ce44SJohn Forte if (rflags & SNDR_NET) { 428fcf3ce44SJohn Forte char *c; 429fcf3ce44SJohn Forte char type[STAT_HDR_SIZE]; 430fcf3ce44SJohn Forte char vn[NAMED_LEN + 1]; 431fcf3ce44SJohn Forte 432fcf3ce44SJohn Forte getType(cur->cur_set, &type[0]); 433fcf3ce44SJohn Forte 434fcf3ce44SJohn Forte if (type[0] == 'S') { 435fcf3ce44SJohn Forte c = kstat_value(cur->pre_set, 436fcf3ce44SJohn Forte RDC_IKSTAT_FILE); 437fcf3ce44SJohn Forte } else { 438fcf3ce44SJohn Forte c = kstat_value(cur->pre_set, 439fcf3ce44SJohn Forte RDC_IKSTAT_SECFILE); 440fcf3ce44SJohn Forte } 441fcf3ce44SJohn Forte 442fcf3ce44SJohn Forte /* Only print last 15 characters */ 443fcf3ce44SJohn Forte if (strlen(c) >= NAMED_LEN) { 444fcf3ce44SJohn Forte c += strlen(c) - NAMED_LEN; 445fcf3ce44SJohn Forte } 446*570de38fSSurya Prakki (void) strncpy(vn, c, NAMED_LEN); 447fcf3ce44SJohn Forte vn[NAMED_LEN] = '\0'; 448fcf3ce44SJohn Forte 449fcf3ce44SJohn Forte header(); 450*570de38fSSurya Prakki (void) printf(DATA_C16, vn); 451*570de38fSSurya Prakki (void) printf("%s", data); 452*570de38fSSurya Prakki (void) printf(ROLE_INF_FMT, RDC_SECONDARY); 453fcf3ce44SJohn Forte 454fcf3ce44SJohn Forte /* Async. queue statistics */ 455fcf3ce44SJohn Forte if (dflags & ASYNC_QUEUE) 456fcf3ce44SJohn Forte printQueueStats(first, cur->cur_set); 457fcf3ce44SJohn Forte 458e31df310SThomas Atkins io_report(cur->cur_sec, cur->pre_sec, 459fcf3ce44SJohn Forte sdbc_getstat(vn)); 460*570de38fSSurya Prakki (void) printf("\n"); 461fcf3ce44SJohn Forte 462fcf3ce44SJohn Forte if (first) { 463*570de38fSSurya Prakki (void) strcpy(data, strlen(pad) > 0 ? pad : ""); 464fcf3ce44SJohn Forte first = 0; 465fcf3ce44SJohn Forte } 466fcf3ce44SJohn Forte } 467fcf3ce44SJohn Forte 468fcf3ce44SJohn Forte if (rflags & SNDR_BMP) { 469fcf3ce44SJohn Forte char *c; 470fcf3ce44SJohn Forte char vn[16]; 471fcf3ce44SJohn Forte 472fcf3ce44SJohn Forte c = kstat_value(cur->pre_set, RDC_IKSTAT_BITMAP); 473fcf3ce44SJohn Forte 474fcf3ce44SJohn Forte /* Only print last 15 characters */ 475fcf3ce44SJohn Forte if (strlen(c) >= NAMED_LEN) { 476fcf3ce44SJohn Forte c += strlen(c) - NAMED_LEN; 477fcf3ce44SJohn Forte } 478*570de38fSSurya Prakki (void) strncpy(vn, c, NAMED_LEN); 479fcf3ce44SJohn Forte vn[NAMED_LEN] = '\0'; 480fcf3ce44SJohn Forte 481fcf3ce44SJohn Forte header(); 482*570de38fSSurya Prakki (void) printf(DATA_C16, vn); 483*570de38fSSurya Prakki (void) printf("%s", data); 484*570de38fSSurya Prakki (void) printf(ROLE_INF_FMT, RDC_BITMAP); 485fcf3ce44SJohn Forte 486fcf3ce44SJohn Forte /* Async. queue statistics */ 487fcf3ce44SJohn Forte if (dflags & ASYNC_QUEUE) 488fcf3ce44SJohn Forte printQueueStats(first, cur->cur_set); 489fcf3ce44SJohn Forte 490e31df310SThomas Atkins io_report(cur->cur_bmp, cur->pre_bmp, 491fcf3ce44SJohn Forte sdbc_getstat(vn)); 492*570de38fSSurya Prakki (void) printf("\n"); 493fcf3ce44SJohn Forte 494fcf3ce44SJohn Forte if (first) { 495*570de38fSSurya Prakki (void) strcpy(data, strlen(pad) > 0 ? pad : ""); 496fcf3ce44SJohn Forte first = 0; 497fcf3ce44SJohn Forte } 498fcf3ce44SJohn Forte } 499fcf3ce44SJohn Forte next: 500fcf3ce44SJohn Forte pre = cur; 501fcf3ce44SJohn Forte cur = cur->next; 502fcf3ce44SJohn Forte } 503fcf3ce44SJohn Forte 504fcf3ce44SJohn Forte return (0); 505fcf3ce44SJohn Forte } 506fcf3ce44SJohn Forte 507fcf3ce44SJohn Forte /* 508fcf3ce44SJohn Forte * sndr_add_stat() - adds a fully populated sndrstat_t structure 509fcf3ce44SJohn Forte * to the linked list of currently monitored kstats. The structure 510fcf3ce44SJohn Forte * will be added in alphabetical order, using the volume name as the 511fcf3ce44SJohn Forte * key. 512fcf3ce44SJohn Forte * 513fcf3ce44SJohn Forte * parameters 514fcf3ce44SJohn Forte * sndrstat_t *sndrstat - to be added to the list. 515fcf3ce44SJohn Forte * 516fcf3ce44SJohn Forte */ 517fcf3ce44SJohn Forte void 518fcf3ce44SJohn Forte sndr_add_stat(sndrstat_t *sndrstat) 519fcf3ce44SJohn Forte { 520fcf3ce44SJohn Forte 521fcf3ce44SJohn Forte sndrstat_t *cur; 522fcf3ce44SJohn Forte 523fcf3ce44SJohn Forte if (sndr_top == NULL) { 524fcf3ce44SJohn Forte sndr_top = sndrstat; 525fcf3ce44SJohn Forte return; 526fcf3ce44SJohn Forte } 527fcf3ce44SJohn Forte 528fcf3ce44SJohn Forte for (cur = sndr_top; cur != NULL; cur = cur->next) { 529fcf3ce44SJohn Forte char *cur_vname, *nxt_vname, *tst_vname; 530fcf3ce44SJohn Forte 531fcf3ce44SJohn Forte cur_vname = kstat_value(cur->pre_set, RDC_IKSTAT_FILE); 532fcf3ce44SJohn Forte tst_vname = kstat_value(sndrstat->pre_set, RDC_IKSTAT_FILE); 533fcf3ce44SJohn Forte 534fcf3ce44SJohn Forte if (strcmp(cur_vname, tst_vname) <= 0) { 535fcf3ce44SJohn Forte /* 536fcf3ce44SJohn Forte * If we get to the last item in the list, then just 537fcf3ce44SJohn Forte * add this one to the end 538fcf3ce44SJohn Forte */ 539fcf3ce44SJohn Forte if (cur->next == NULL) { 540fcf3ce44SJohn Forte cur->next = sndrstat; 541fcf3ce44SJohn Forte return; 542fcf3ce44SJohn Forte } 543fcf3ce44SJohn Forte 544fcf3ce44SJohn Forte nxt_vname = kstat_value(cur->next->pre_set, 545fcf3ce44SJohn Forte RDC_IKSTAT_FILE); 546fcf3ce44SJohn Forte 547fcf3ce44SJohn Forte if (strcmp(nxt_vname, tst_vname) > 0) { 548fcf3ce44SJohn Forte sndrstat->next = cur->next; 549fcf3ce44SJohn Forte cur->next = sndrstat; 550fcf3ce44SJohn Forte return; 551fcf3ce44SJohn Forte } 552fcf3ce44SJohn Forte } else { 553fcf3ce44SJohn Forte if (cur == sndr_top) 554fcf3ce44SJohn Forte sndr_top = sndrstat; 555fcf3ce44SJohn Forte 556fcf3ce44SJohn Forte sndrstat->next = cur; 557fcf3ce44SJohn Forte 558fcf3ce44SJohn Forte return; 559fcf3ce44SJohn Forte } 560fcf3ce44SJohn Forte } 561fcf3ce44SJohn Forte } 562fcf3ce44SJohn Forte 563fcf3ce44SJohn Forte /* 564fcf3ce44SJohn Forte * sndr_del_stat() - deallocate memory for the structure being 565fcf3ce44SJohn Forte * passed in. 566fcf3ce44SJohn Forte * 567fcf3ce44SJohn Forte * parameters 568fcf3ce44SJohn Forte * sndrstat_t *sndrstat - structure to be deallocated 569fcf3ce44SJohn Forte * 570fcf3ce44SJohn Forte * returns 571fcf3ce44SJohn Forte * sndrstat_t * - pointer to the "next" structures in the 572fcf3ce44SJohn Forte * linked list. May be NULL if we are removing the last 573fcf3ce44SJohn Forte * structure in the linked list. 574fcf3ce44SJohn Forte * 575fcf3ce44SJohn Forte */ 576fcf3ce44SJohn Forte sndrstat_t * 577fcf3ce44SJohn Forte sndr_del_stat(sndrstat_t *sndrstat) 578fcf3ce44SJohn Forte { 579fcf3ce44SJohn Forte 580fcf3ce44SJohn Forte sndrstat_t *next = sndrstat->next; 581fcf3ce44SJohn Forte 582fcf3ce44SJohn Forte kstat_free(sndrstat->pre_set); 583fcf3ce44SJohn Forte kstat_free(sndrstat->pre_bmp); 584fcf3ce44SJohn Forte kstat_free(sndrstat->pre_sec); 585fcf3ce44SJohn Forte kstat_free(sndrstat->cur_set); 586fcf3ce44SJohn Forte kstat_free(sndrstat->cur_bmp); 587fcf3ce44SJohn Forte kstat_free(sndrstat->cur_sec); 588fcf3ce44SJohn Forte 589fcf3ce44SJohn Forte free(sndrstat); 590fcf3ce44SJohn Forte 591fcf3ce44SJohn Forte return (next); 592fcf3ce44SJohn Forte } 593fcf3ce44SJohn Forte 594fcf3ce44SJohn Forte /* 595fcf3ce44SJohn Forte * sndr_value_check() - check to determine if any activity was registered 596fcf3ce44SJohn Forte * on this volume by checking the previous stats vs. the current stats. 597fcf3ce44SJohn Forte * 598fcf3ce44SJohn Forte * parameters 599fcf3ce44SJohn Forte * sndrstat_t *sndrstat - structure to be checked 600fcf3ce44SJohn Forte * 601fcf3ce44SJohn Forte * returns 602fcf3ce44SJohn Forte * 0 - no activity 603fcf3ce44SJohn Forte * 1 - activity 604fcf3ce44SJohn Forte */ 605fcf3ce44SJohn Forte int 606fcf3ce44SJohn Forte sndr_value_check(sndrstat_t *sndrstat) 607fcf3ce44SJohn Forte { 608fcf3ce44SJohn Forte if (SNDR_COMPLETE(sndrstat->collected)) 609fcf3ce44SJohn Forte return (1); 610fcf3ce44SJohn Forte 611fcf3ce44SJohn Forte if (io_value_check(sndrstat->pre_bmp->ks_data, 612fcf3ce44SJohn Forte sndrstat->cur_bmp->ks_data)) { 613fcf3ce44SJohn Forte return (1); 614fcf3ce44SJohn Forte } 615fcf3ce44SJohn Forte 616fcf3ce44SJohn Forte if (io_value_check(sndrstat->pre_sec->ks_data, 617fcf3ce44SJohn Forte sndrstat->cur_sec->ks_data)) { 618fcf3ce44SJohn Forte return (1); 619fcf3ce44SJohn Forte } 620fcf3ce44SJohn Forte 621fcf3ce44SJohn Forte return (0); 622fcf3ce44SJohn Forte } 623fcf3ce44SJohn Forte 624fcf3ce44SJohn Forte /* 625fcf3ce44SJohn Forte * sndr_validate() - validates the fields required by dsstat exist in 626fcf3ce44SJohn Forte * the kstat_t structure passed in. This check keeps dsstat from 627fcf3ce44SJohn Forte * core dumping if the kstat_named_t structures change in any of the 628fcf3ce44SJohn Forte * services that dsstat monitors. 629fcf3ce44SJohn Forte * 630fcf3ce44SJohn Forte * paramaters 631fcf3ce44SJohn Forte * kstat_t *ksp - kstat_t structure to check. The ks_data field 632fcf3ce44SJohn Forte * should have been populated with a call to kstat_read() 633fcf3ce44SJohn Forte * 634fcf3ce44SJohn Forte * returns 635fcf3ce44SJohn Forte * 0 - all fields are contained in the kstat 636fcf3ce44SJohn Forte * 1 - a field required by dsstat is not in the kstat 637fcf3ce44SJohn Forte */ 638fcf3ce44SJohn Forte int 639fcf3ce44SJohn Forte sndr_validate(kstat_t *ksp) 640fcf3ce44SJohn Forte { 641fcf3ce44SJohn Forte if (! kstat_value(ksp, RDC_IKSTAT_FILE) || 642fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_FLAGS) || 643fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_SYNCFLAGS) || 644fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_BMPFLAGS) || 645fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_VOLSIZE) || 646fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_BITSSET) || 647fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_QUEUE_TYPE) || 648fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_ASYNC_ITEMS) || 649fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_ASYNC_BLOCKS) || 650fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_ASYNC_ITEM_HWM) || 651fcf3ce44SJohn Forte ! kstat_value(ksp, RDC_IKSTAT_ASYNC_BLOCK_HWM)) 652fcf3ce44SJohn Forte return (1); 653fcf3ce44SJohn Forte 654fcf3ce44SJohn Forte return (0); 655fcf3ce44SJohn Forte } 656fcf3ce44SJohn Forte 657fcf3ce44SJohn Forte void 658fcf3ce44SJohn Forte getType(kstat_t *ksp, char *vtype) 659fcf3ce44SJohn Forte { 660fcf3ce44SJohn Forte uint32_t *set_flags; 661fcf3ce44SJohn Forte 662fcf3ce44SJohn Forte set_flags = kstat_value(ksp, RDC_IKSTAT_FLAGS); 663fcf3ce44SJohn Forte 664fcf3ce44SJohn Forte if (*set_flags & RDC_PRIMARY) 665fcf3ce44SJohn Forte (void) strcpy(vtype, "P"); 666fcf3ce44SJohn Forte else 667fcf3ce44SJohn Forte (void) strcpy(vtype, "S"); 668fcf3ce44SJohn Forte } 669fcf3ce44SJohn Forte 670fcf3ce44SJohn Forte void 671fcf3ce44SJohn Forte getStat(kstat_t *ksp, char *vstat) 672fcf3ce44SJohn Forte { 673fcf3ce44SJohn Forte uint32_t *set_flags; 674fcf3ce44SJohn Forte uint32_t *syn_flags; 675fcf3ce44SJohn Forte uint32_t *bmp_flags; 676fcf3ce44SJohn Forte 677fcf3ce44SJohn Forte set_flags = kstat_value(ksp, RDC_IKSTAT_FLAGS); 678fcf3ce44SJohn Forte syn_flags = kstat_value(ksp, RDC_IKSTAT_SYNCFLAGS); 679fcf3ce44SJohn Forte bmp_flags = kstat_value(ksp, RDC_IKSTAT_BMPFLAGS); 680fcf3ce44SJohn Forte 681fcf3ce44SJohn Forte (void) strcpy(vstat, "R"); 682fcf3ce44SJohn Forte 683fcf3ce44SJohn Forte if (*set_flags & RDC_SYNCING) { 684fcf3ce44SJohn Forte if (*set_flags & RDC_SLAVE) 685fcf3ce44SJohn Forte if (*set_flags & RDC_PRIMARY) 686fcf3ce44SJohn Forte (void) strcpy(vstat, "RS"); 687fcf3ce44SJohn Forte else 688fcf3ce44SJohn Forte (void) strcpy(vstat, "SY"); 689fcf3ce44SJohn Forte else 690fcf3ce44SJohn Forte if (*set_flags & RDC_PRIMARY) 691fcf3ce44SJohn Forte (void) strcpy(vstat, "SY"); 692fcf3ce44SJohn Forte else 693fcf3ce44SJohn Forte (void) strcpy(vstat, "RS"); 694fcf3ce44SJohn Forte } 695fcf3ce44SJohn Forte 696fcf3ce44SJohn Forte if (*set_flags & RDC_LOGGING) { 697fcf3ce44SJohn Forte (void) strcpy(vstat, "L"); 698fcf3ce44SJohn Forte 699fcf3ce44SJohn Forte if (*set_flags & RDC_QUEUING) 700fcf3ce44SJohn Forte (void) strcpy(vstat, "Q"); 701fcf3ce44SJohn Forte 702fcf3ce44SJohn Forte if (*set_flags & RDC_DISKQ_FAILED) 703fcf3ce44SJohn Forte (void) strcpy(vstat, "QF"); 704fcf3ce44SJohn Forte 705fcf3ce44SJohn Forte if (*syn_flags & RDC_SYNC_NEEDED) 706fcf3ce44SJohn Forte (void) strcpy(vstat, "SN"); 707fcf3ce44SJohn Forte 708fcf3ce44SJohn Forte if (*syn_flags & RDC_RSYNC_NEEDED) 709fcf3ce44SJohn Forte (void) strcpy(vstat, "RN"); 710fcf3ce44SJohn Forte } 711fcf3ce44SJohn Forte 712fcf3ce44SJohn Forte if (*syn_flags & RDC_FCAL_FAILED) 713fcf3ce44SJohn Forte (void) strcpy(vstat, "FF"); 714fcf3ce44SJohn Forte 715fcf3ce44SJohn Forte if (*bmp_flags & RDC_BMP_FAILED) 716fcf3ce44SJohn Forte (void) strcpy(vstat, "BF"); 717fcf3ce44SJohn Forte 718fcf3ce44SJohn Forte if (*syn_flags & RDC_VOL_FAILED) 719fcf3ce44SJohn Forte (void) strcpy(vstat, "VF"); 720fcf3ce44SJohn Forte } 721fcf3ce44SJohn Forte 722fcf3ce44SJohn Forte void 723fcf3ce44SJohn Forte getQueue(kstat_t *ksp, char *vqueue) 724fcf3ce44SJohn Forte { 725fcf3ce44SJohn Forte char *qtype; 726fcf3ce44SJohn Forte 727fcf3ce44SJohn Forte (void) strcpy(vqueue, "-"); 728fcf3ce44SJohn Forte 729fcf3ce44SJohn Forte qtype = kstat_value(ksp, RDC_IKSTAT_QUEUE_TYPE); 730fcf3ce44SJohn Forte 731fcf3ce44SJohn Forte if (strcmp(qtype, "memory") == 0) 732fcf3ce44SJohn Forte (void) strcpy(vqueue, "M"); 733fcf3ce44SJohn Forte 734fcf3ce44SJohn Forte if (strcmp(qtype, "disk") == 0) 735fcf3ce44SJohn Forte (void) strcpy(vqueue, "D"); 736fcf3ce44SJohn Forte } 737fcf3ce44SJohn Forte 738fcf3ce44SJohn Forte float 739fcf3ce44SJohn Forte getSyncNeeded(kstat_t *ksp) 740fcf3ce44SJohn Forte { 741fcf3ce44SJohn Forte uint32_t *volsize, *bitsset; 742fcf3ce44SJohn Forte uint32_t bits, segs; 743fcf3ce44SJohn Forte float pct; 744fcf3ce44SJohn Forte 745fcf3ce44SJohn Forte volsize = kstat_value(ksp, RDC_IKSTAT_VOLSIZE); 746fcf3ce44SJohn Forte bitsset = kstat_value(ksp, RDC_IKSTAT_BITSSET); 747fcf3ce44SJohn Forte 748fcf3ce44SJohn Forte segs = FBA_TO_LOG_LEN(*volsize); 749fcf3ce44SJohn Forte bits = *bitsset > 0 ? *bitsset : 0; 750fcf3ce44SJohn Forte 751fcf3ce44SJohn Forte pct = segs ? ((float)bits/(float)segs) : 0.0; 752fcf3ce44SJohn Forte pct *= 100; 753fcf3ce44SJohn Forte 754fcf3ce44SJohn Forte return (pct); 755fcf3ce44SJohn Forte } 756fcf3ce44SJohn Forte 757fcf3ce44SJohn Forte /* 758fcf3ce44SJohn Forte * Special handling for compatibility. 759fcf3ce44SJohn Forte * "dsstat -s <set>" allows set name to be the last 15 chars, 760fcf3ce44SJohn Forte * due to 15 characters limit of old kstat information. 761fcf3ce44SJohn Forte * 762fcf3ce44SJohn Forte * return 0 if: 763fcf3ce44SJohn Forte * 1) full and partial are same 764fcf3ce44SJohn Forte * 2) partial is the last 15 chars of full 765fcf3ce44SJohn Forte */ 766fcf3ce44SJohn Forte int 767fcf3ce44SJohn Forte sndr_strcmp(char *full, char *partial) 768fcf3ce44SJohn Forte { 769fcf3ce44SJohn Forte char *f = full; 770fcf3ce44SJohn Forte int rc; 771fcf3ce44SJohn Forte 772fcf3ce44SJohn Forte rc = strcmp(full, partial); 773fcf3ce44SJohn Forte 774fcf3ce44SJohn Forte if (rc != 0 && 775fcf3ce44SJohn Forte (strlen(partial) == NAMED_LEN) && 776fcf3ce44SJohn Forte (strlen(full) > NAMED_LEN)) { 777fcf3ce44SJohn Forte f += strlen(full) - NAMED_LEN; 778fcf3ce44SJohn Forte rc = strncmp(f, partial, NAMED_LEN); 779fcf3ce44SJohn Forte } 780fcf3ce44SJohn Forte 781fcf3ce44SJohn Forte return (rc); 782fcf3ce44SJohn Forte } 783fcf3ce44SJohn Forte 784fcf3ce44SJohn Forte int 785fcf3ce44SJohn Forte sndr_vol_selected(kstat_t *ksp) 786fcf3ce44SJohn Forte { 787fcf3ce44SJohn Forte vslist_t *vslist = vs_top; 788fcf3ce44SJohn Forte 789fcf3ce44SJohn Forte for (vslist = vs_top; vslist != NULL; vslist = vslist->next) { 790fcf3ce44SJohn Forte char *vn; 791fcf3ce44SJohn Forte char *vh; 792fcf3ce44SJohn Forte 793fcf3ce44SJohn Forte /* If no host specified, check local only */ 794fcf3ce44SJohn Forte if (vslist->volhost == NULL) { 795fcf3ce44SJohn Forte vn = kstat_value(ksp, RDC_IKSTAT_FILE); 796fcf3ce44SJohn Forte 797fcf3ce44SJohn Forte if (sndr_strcmp(vn, vslist->volname)) 798fcf3ce44SJohn Forte continue; 799fcf3ce44SJohn Forte else 800fcf3ce44SJohn Forte break; 801fcf3ce44SJohn Forte } 802fcf3ce44SJohn Forte 803fcf3ce44SJohn Forte /* Check primary */ 804fcf3ce44SJohn Forte vn = kstat_value(ksp, RDC_IKSTAT_FILE); 805fcf3ce44SJohn Forte vh = kstat_value(ksp, RDC_IKSTAT_PRIMARY_HOST); 806fcf3ce44SJohn Forte 807fcf3ce44SJohn Forte if (sndr_strcmp(vn, vslist->volname) == 0 && 808fcf3ce44SJohn Forte sndr_strcmp(vh, vslist->volhost) == 0) 809fcf3ce44SJohn Forte break; 810fcf3ce44SJohn Forte 811fcf3ce44SJohn Forte /* Check secondary */ 812fcf3ce44SJohn Forte vn = kstat_value(ksp, RDC_IKSTAT_SECFILE); 813fcf3ce44SJohn Forte vh = kstat_value(ksp, RDC_IKSTAT_SECONDARY_HOST); 814fcf3ce44SJohn Forte 815fcf3ce44SJohn Forte if (sndr_strcmp(vn, vslist->volname) == 0 && 816fcf3ce44SJohn Forte sndr_strcmp(vh, vslist->volhost) == 0) 817fcf3ce44SJohn Forte break; 818fcf3ce44SJohn Forte } 819fcf3ce44SJohn Forte 820fcf3ce44SJohn Forte if (vs_top != NULL && vslist == NULL) 821fcf3ce44SJohn Forte return (0); 822fcf3ce44SJohn Forte 823fcf3ce44SJohn Forte return (1); 824fcf3ce44SJohn Forte } 825fcf3ce44SJohn Forte 826fcf3ce44SJohn Forte void 827fcf3ce44SJohn Forte printQueueStats(int first, kstat_t *cur_set) 828fcf3ce44SJohn Forte { 829fcf3ce44SJohn Forte uint32_t *val; 830fcf3ce44SJohn Forte 831fcf3ce44SJohn Forte if (! first) { 832fcf3ce44SJohn Forte /* Filler for async. queue fields */ 833*570de38fSSurya Prakki (void) printf(TPS_HDR_FMT, NO_INFO); 834*570de38fSSurya Prakki (void) printf(KPS_HDR_FMT, NO_INFO); 835*570de38fSSurya Prakki (void) printf(TPS_HDR_FMT, NO_INFO); 836*570de38fSSurya Prakki (void) printf(KPS_HDR_FMT, NO_INFO); 837fcf3ce44SJohn Forte 838fcf3ce44SJohn Forte return; 839fcf3ce44SJohn Forte } 840fcf3ce44SJohn Forte 841fcf3ce44SJohn Forte val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_ITEMS); 842*570de38fSSurya Prakki (void) printf(TPS_INF_FMT, *val); 843fcf3ce44SJohn Forte 844fcf3ce44SJohn Forte val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_BLOCKS); 845*570de38fSSurya Prakki (void) printf(KPS_INF_FMT, (float)(*val / 2)); 846fcf3ce44SJohn Forte 847fcf3ce44SJohn Forte val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_ITEM_HWM); 848*570de38fSSurya Prakki (void) printf(TPS_INF_FMT, *val); 849fcf3ce44SJohn Forte 850fcf3ce44SJohn Forte val = (uint32_t *)kstat_value(cur_set, RDC_IKSTAT_ASYNC_BLOCK_HWM); 851*570de38fSSurya Prakki (void) printf(KPS_INF_FMT, (float)(*val / 2)); 852fcf3ce44SJohn Forte } 853