/*
*
* U.S. Government Rights - Commercial software. Government users are subject
* to the Sun Microsystems, Inc. standard license agreement and applicable
* provisions of the FAR and its supplements.
*
*
* This distribution may include materials developed by third parties. Sun,
* Sun Microsystems, the Sun logo and Solaris are trademarks or registered
* trademarks of Sun Microsystems, Inc. in the U.S. and other countries.
*
*/
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
#include <ctype.h>
#include <unistd.h>
#include <memory.h>
#include <string.h>
#include <fcntl.h>
#include <errno.h>
#include <signal.h>
#include <kstat.h>
#include <stropts.h>
#include <poll.h>
typedef struct cpuinfo {
} cpuinfo_t;
/*
* Name and print priority of each supported ks_class.
*/
#define IO_CLASS_DISK 0
#define IO_CLASS_PARTITION 0
struct io_class {
char *class_name;
int class_priority;
};
/*ARGSUSED*/
/*ARGSUSED*/
static int reentrant = 0;
/*
* I've had some strange behavior with "refreshMode = async".
*/
#define REENTRANT_BEGIN() { \
if (reentrant != 0) \
reentrant++; \
}
#define REENTRANT_END() { \
reentrant--; \
}
{ "disk", IO_CLASS_DISK},
{ "partition", IO_CLASS_PARTITION},
{ NULL, 0}
};
struct diskinfo {
int selected;
int class;
char *device_name;
};
extern void *build_disk_list(void *);
extern char *lookup_ks_name(char *, void *);
static int refreshDiskdetail=0;
static int refreshDisksrv=0;
(void) printf(" %3.0f %4.0f",\
(void) printf(" %2.0f %2.0f %2.0f %2.0f", \
static int do_disk = 0;
static int do_cpu = 0;
static int do_interval = 0;
/* no per-device stats for disks */
static int ndrives = 0;
struct disk_selection {
};
static void show_disk(struct diskinfo *disk, double *rps, double *wps, double *tps, double *krps, double *kwps, double *kps, double *avw, double *avr, double *w_pct, double *r_pct, double *wserv, double *rserv, double *serv);
static void cpu_stat_init(void);
static int cpu_stat_load(int);
static void fail(int, char *, ...);
static void safe_zalloc(void **, int, int);
static void init_disks(void);
static void select_disks(void);
static int diskinfo_load(void);
static void init_disk_errors(void);
/* static struct diskinfo *disk; */
void
{
return;
do_conversions = 1;
do_cpu = 1;
{
/*
* Choose drives to be displayed. Priority
* goes to (in order) drives supplied as arguments,
* then any other active drives that fit.
*/
}
init_disks();
#if 0
}
#endif
/* disk = firstdisk; */
first_time = 0;
}
{
int ret;
if (ret == 0) { /* no change */
return 0;
} else if (ret > 0) { /* changed */
init_disks();
if (cpu_stat_load(cpu_save_old_flag)) {
return -1;
};
if (diskinfo_load()) {
return -1;
};
return 0;
} else { /* error */
return -1;
}
}
/* Get Adaptive mutex summary and number of cpus for the system */
int
{
etime = 0;
mutex = 0;
if ((first_time) || (!kc))
/* while (kstat_chain_update(kc) || cpu_stat_load(1)) {
(void) cpu_stat_init();
}
*/
for (c = 0; c < ncpus; c++) {
ticks = 0;
for (i = 0; i < CPU_STATES; i++)
if (etime == 0.0)
etime = 1.0;
}
return 0;
}
int
{
if ((first_time) || (!kc))
while (update_kstat_chain(0) == -1) {
/* DPRINTF("ERROR: kstat_chain_update \n");
DFFLUSH(stdout);*/
}
*cpus = cpu_stat_data;
return 0;
}
/* returns 0 if more disks remain, 1 if the last disk, < 0 on error */
int
krgetdiskdetail(char *name, char *alias, double *rps, double *wps, double *tps, double *krps, double *kwps, double *kps, double *avw, double *avr)
{
if ((first_time) || (!kc)) {
}
if (refreshDiskdetail) {
}
while (update_kstat_chain(0) == -1) {
/* DPRINTF("ERROR: diskdetail - kstat_chain_update \n");
DFFLUSH(stdout);*/
}
}
if (disk) {
else
}
else {
}
}
return 1;
}
return(0);
}
/* returns 0 if more disks remain, 1 if the last disk, < 0 on error */
int
krgetdisksrv(char *name, char *alias, double *w_pct, double *r_pct, double *wserv, double *rserv, double *serv)
{
if (refreshDisksrv) {
}
if (disk) {
show_disk(disk, &rps, &wps, &tps, &krps, &kwps, &kps, &avw, &avr, w_pct, r_pct, wserv, rserv, serv);
else
}
else {
/*ddlPrintf(DDL_ERROR, "krgetdisksrv - skipping %s\n", disk->device_name ? disk->device_name : disk->ks->ks_name);*/
}
}
return 1;
}
return(0);
}
static void
show_disk(struct diskinfo *disk, double *Rps, double *Wps, double *Tps, double *Krps, double *Kwps, double *Kps, double *Avw, double *Avr, double *W_pct, double *R_pct, double *Wserv, double *Rserv, double *Serv)
{
if (hr_etime == 0.0)
/* reads per second */
/* writes per second */
/* transactions per second */
/*
*/
if (!do_megabytes) {
iosize = 1024.0;
} else {
iosize = 1048576.0;
}
/* block reads per second */
/* blocks written per second */
/* blocks transferred per second */
/* average number of transactions waiting */
/* average number of transactions running */
/* average wait service time in milliseconds */
/* average run service time in milliseconds */
/* average service time in milliseconds */
/* % of time there is a transaction waiting for service */
/* % of time there is a transaction running */
if (do_interval) {
}
}
/*
* Get list of cpu_stat KIDs for subsequent cpu_stat_load operations.
*/
static void
cpu_stat_init(void)
{
int tmp_ncpus;
int i;
int nb_cpus;
tmp_ncpus = 0;
tmp_ncpus++;
/* ddlPrintf(DDL_ERROR, "cpu_stat_init - kstat_read() failed for cpu:%s\n", ksp->ks_name);*/
}
}
}
ncpus = 0;
nb_cpus = 0;
} else {
/* ddlPrintf(DDL_ERROR, "cpu_stat_init - kstat_read() failed for cpu:%s\n", ksp->ks_name); */
}
}
continue;
/*
* insertion sort by CPU id
*/
for (i = nb_cpus - 1; i >= 0; i--) {
break;
}
nb_cpus++;
}
/* ddlPrintf(DDL_ERROR, "cpu_stat_init - kstat_read() for some cpu failed, Passed :ncpus=%d Total :tmp_ncpus=%d\n", ncpus, tmp_ncpus); */
}
}
static int
{
int i, j;
if (save_old_flag)
/* Sum across all cpus */
for (i = 0; i < ncpus; i++) {
return (1);
/* ddlPrintf(DDL_ERROR, "cpu_stat_load - kstat_read() failed for cpu:%s\n", cpu_stat_list[i]->ks_name); */
return (1);
}
for (j = 0; j < sizeof (cpu_sysinfo_t); j += sizeof (uint_t))
for (j = 0; j < sizeof (cpu_vminfo_t); j += sizeof (uint_t))
}
return (0);
}
static void
{
if (do_perror)
exit(2);
}
static void
{
}
/*
* Sort based on ks_class, ks_module, ks_instance, ks_name
*/
static int
{
int cmp;
if (cmp != 0)
return (cmp);
if (cmp != 0)
return (cmp);
if (cmp != 0)
return (cmp);
else
}
static void
init_disks(void)
{
if (do_conversions)
if(first) {
first = 0;
}
/*
* Patch the snip in the diskinfo list (see below)
*/
if (snip)
int i;
continue;
break;
}
continue;
if (do_partitions_only &&
continue;
if (!do_partitions && !do_partitions_only &&
continue;
continue;
else {
sizeof (struct diskinfo), 0);
}
if (do_conversions && dl) {
disk->device_name =
} else {
disk->device_name = (char *)0;
}
/*
* Insertion sort on (ks_class, ks_module, ks_instance, ks_name)
*/
}
}
/*
* Put a snip in the linked list of diskinfos. The idea:
* If there was a state change such that now there are fewer
* disks, we snip the list and retain the tail, rather than
* freeing it. At the next state change, we clip the tail back on.
*/
select_disks();
if (do_disk & DISK_ERROR_MASK)
}
static void
select_disks(void)
{
ndrives = 0;
ndrives++;
break;
}
}
}
continue;
break;
ndrives++;
}
}
static int
diskinfo_load(void)
{
return (1);
return (1);
}
}
}
}
return (0);
}
static void
{
}
}
}
static void
{
while (*ename != ',') {
dname++;
ename++;
}
*dname = '\0';
return;
}
}
}
}