sndr_stats.c revision 570de38f63910201fdd77246630b7aa8f9dc5661
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License (the "License").
* You may not use this file except in compliance with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <errno.h>
#include <signal.h>
#include <setjmp.h>
#include <kstat.h>
#include "sdbc_stats.h"
#include "sndr_stats.h"
#include "dsstat.h"
#include "common.h"
#include "report.h"
static sndrstat_t *sndr_top;
void sndr_add_stat(sndrstat_t *);
int sndr_value_check(sndrstat_t *);
int sndr_validate(kstat_t *);
int sndr_strcmp(char *, char *);
int sndr_vol_selected(kstat_t *);
void printQueueStats(int, kstat_t *);
float getSyncNeeded(kstat_t *);
static void update_sighandler(int);
static void discover_sighandler(int);
static sig_atomic_t sig_raised = 0;
/*
* sndr_discover() - looks for new statistics to be monitored.
* Verifies that any statistics found are now already being
* monitored.
*
*/
int
{
static int validated = 0;
int rc = 0;
/* Loop on all kstats */
int kinst;
/* Serach for SNDR set */
continue;
}
continue;
/*
* Validate kstat structure
*/
if (! validated) {
if (sndr_validate(ksp))
return (EINVAL);
validated++;
}
/*
* Duplicate check
*/
goto next;
}
/*
* Initialize new record
*/
/*
* Set kstat
*/
goto next;
/*
* Bitmap kstat
*/
goto next;
/*
* Secondary kstat
*/
goto next;
next:
/*
* Check if we got a complete set of stats
*/
continue;
(void) sndr_del_stat(sndrstat);
continue;
}
/*
* Add to linked list
*/
}
(void) sigsetjmp(discover_env, 0);
if (sig_raised) {
sig_raised = 0;
rc = -1;
}
return (rc);
}
void
discover_sighandler(int sig)
{
switch (sig) {
case SIGSEGV:
sig_raised = 1;
default:
}
}
void
update_sighandler(int sig)
{
switch (sig) {
case SIGSEGV:
sig_raised = 1;
default:
}
}
/*
* sndr_update() - updates all of the statistics currently being monitored.
*
*/
int
{
int rc = 0;
int kinst;
/*
* Age off old stats
*/
}
/*
* Set kstat
*/
continue;
/*
* Validate set
*/
continue;
/*
* Bitmap kstat
*/
continue;
/*
* Secondary kstat
*/
continue;
}
(void) sigsetjmp(update_env, 0);
if (sig_raised) {
sig_raised = 0;
rc = -1;
}
return (rc);
}
/*
* sndr_report() - outputs statistics for the statistics currently being
* monitored. Deletes statistics for volumes that have been disabled.
*
*/
int
{
int padsz;
return (0);
/* Create padding string for secondary report lines */
padsz = 0;
padsz += STAT_HDR_SIZE;
padsz += STAT_HDR_SIZE;
}
if (dflags & ASYNC_QUEUE)
padsz += STAT_HDR_SIZE;
padsz += PCT_HDR_SIZE;
if (padsz) {
char fmt[20];
}
int first = 1;
/* Check to see if this is this a complete */
char *c;
/* notify user of set being disabled */
/* free memory and remove stat from list */
if (! pre)
else
continue;
}
/* Check to see if the user specified this volume */
goto next;
/* Check to see if zflag applies */
goto next;
/* Calculate flags */
char c[STAT_HDR_SIZE];
char vtype[STAT_HDR_SIZE];
char vstat[STAT_HDR_SIZE];
}
/* Async. queue statistics */
if (dflags & ASYNC_QUEUE) {
char c[STAT_HDR_SIZE];
char qtype[STAT_HDR_SIZE];
}
/* Calculate sync needed percentages */
char snpct[10];
}
/* Output */
char *c;
char type[STAT_HDR_SIZE];
if (type[0] == 'S') {
} else {
}
/* Only print last 15 characters */
}
header();
/* Async. queue statistics */
if (dflags & ASYNC_QUEUE)
sdbc_getstat(vn));
(void) printf("\n");
if (first) {
first = 0;
}
}
char *c;
char vn[16];
/* Only print last 15 characters */
}
header();
/* Async. queue statistics */
if (dflags & ASYNC_QUEUE)
sdbc_getstat(vn));
(void) printf("\n");
if (first) {
first = 0;
}
}
next:
}
return (0);
}
/*
* sndr_add_stat() - adds a fully populated sndrstat_t structure
* to the linked list of currently monitored kstats. The structure
* will be added in alphabetical order, using the volume name as the
* key.
*
* parameters
* sndrstat_t *sndrstat - to be added to the list.
*
*/
void
{
return;
}
/*
* If we get to the last item in the list, then just
* add this one to the end
*/
return;
}
return;
}
} else {
return;
}
}
}
/*
* sndr_del_stat() - deallocate memory for the structure being
* passed in.
*
* parameters
* sndrstat_t *sndrstat - structure to be deallocated
*
* returns
* sndrstat_t * - pointer to the "next" structures in the
* linked list. May be NULL if we are removing the last
* structure in the linked list.
*
*/
{
return (next);
}
/*
* sndr_value_check() - check to determine if any activity was registered
* on this volume by checking the previous stats vs. the current stats.
*
* parameters
* sndrstat_t *sndrstat - structure to be checked
*
* returns
* 0 - no activity
* 1 - activity
*/
int
{
return (1);
return (1);
}
return (1);
}
return (0);
}
/*
* sndr_validate() - validates the fields required by dsstat exist in
* the kstat_t structure passed in. This check keeps dsstat from
* core dumping if the kstat_named_t structures change in any of the
* services that dsstat monitors.
*
* paramaters
* kstat_t *ksp - kstat_t structure to check. The ks_data field
* should have been populated with a call to kstat_read()
*
* returns
* 0 - all fields are contained in the kstat
* 1 - a field required by dsstat is not in the kstat
*/
int
{
return (1);
return (0);
}
void
{
if (*set_flags & RDC_PRIMARY)
else
}
void
{
if (*set_flags & RDC_SYNCING) {
if (*set_flags & RDC_PRIMARY)
else
else
if (*set_flags & RDC_PRIMARY)
else
}
if (*set_flags & RDC_LOGGING) {
if (*set_flags & RDC_QUEUING)
if (*set_flags & RDC_DISKQ_FAILED)
if (*syn_flags & RDC_SYNC_NEEDED)
if (*syn_flags & RDC_RSYNC_NEEDED)
}
if (*syn_flags & RDC_FCAL_FAILED)
if (*bmp_flags & RDC_BMP_FAILED)
if (*syn_flags & RDC_VOL_FAILED)
}
void
{
char *qtype;
}
float
{
float pct;
pct *= 100;
return (pct);
}
/*
* Special handling for compatibility.
* "dsstat -s <set>" allows set name to be the last 15 chars,
* due to 15 characters limit of old kstat information.
*
* return 0 if:
* 1) full and partial are same
* 2) partial is the last 15 chars of full
*/
int
{
char *f = full;
int rc;
if (rc != 0 &&
}
return (rc);
}
int
{
char *vn;
char *vh;
/* If no host specified, check local only */
continue;
else
break;
}
/* Check primary */
break;
/* Check secondary */
break;
}
return (0);
return (1);
}
void
{
if (! first) {
/* Filler for async. queue fields */
return;
}
}