void dvb_mux_nicefreq(char *buf, size_t size, th_dvb_mux_instance_t *tdmi) { char freq[50]; if(tdmi->tdmi_adapter->tda_type == FE_QPSK) { nicenum(freq, sizeof(freq), tdmi->tdmi_conf.dmc_fe_params.frequency); snprintf(buf, size, "%s kHz", freq); } else { nicenum(freq, sizeof(freq), tdmi->tdmi_conf.dmc_fe_params.frequency / 1000); snprintf(buf, size, "%s kHz", freq); } }
static void print_fmt_nodes(const char *be_name, enum be_fmt be_fmt, boolean_t parsable, struct hdr_info *hdr, be_node_list_t *nodes) { char buf[64]; char datetime[DT_BUF_LEN]; be_node_list_t *cur_be; for (cur_be = nodes; cur_be != NULL; cur_be = cur_be->be_next_node) { char active[3] = "-\0"; int ai = 0; const char *datetime_fmt = "%F %R"; const char *name = cur_be->be_node_name; const char *mntpt = cur_be->be_mntpt; uint64_t used = cur_be->be_space_used; time_t creation = cur_be->be_node_creation; struct tm *tm; if (be_name != NULL && strcmp(be_name, name) != 0) continue; if (!parsable) (void) printf("%-s\n", name); else active[0] = '\0'; tm = localtime(&creation); (void) strftime(datetime, DT_BUF_LEN, datetime_fmt, tm); if (cur_be->be_active) active[ai++] = 'N'; if (cur_be->be_active_on_boot) active[ai] = 'R'; nicenum(used, buf, sizeof (buf)); if (be_fmt & BE_FMT_DATASET) if (parsable) (void) printf("%s;%s;%s;%s;%llu;%s;%ld\n", cur_be->be_node_name, cur_be->be_root_ds, active, (cur_be->be_mounted ? mntpt: ""), used, cur_be->be_policy_type, creation); else (void) printf(" %-*s %-*s %-*s %-*s %-*s " "%-*s\n", hdr->cols[0].width-3, cur_be->be_root_ds, hdr->cols[1].width, active, hdr->cols[2].width, (cur_be->be_mounted ? mntpt: "-"), hdr->cols[3].width, buf, hdr->cols[4].width, cur_be->be_policy_type, hdr->cols[5].width, datetime); if (be_fmt & BE_FMT_SNAPSHOT) print_be_snapshots(cur_be, hdr, parsable); } }
void dvb_mux_nicename(char *buf, size_t size, th_dvb_mux_instance_t *tdmi) { char freq[50]; const char *n = tdmi->tdmi_network; if(tdmi->tdmi_adapter->tda_type == FE_QPSK) { nicenum(freq, sizeof(freq), tdmi->tdmi_conf.dmc_fe_params.frequency); snprintf(buf, size, "%s%s%s kHz %s (%s)", n?:"", n ? ": ":"", freq, dvb_polarisation_to_str_long(tdmi->tdmi_conf.dmc_polarisation), tdmi->tdmi_conf.dmc_satconf ? tdmi->tdmi_conf.dmc_satconf->sc_name : "No satconf"); } else {
static void print_be_snapshots(be_node_list_t *be, struct hdr_info *hdr, boolean_t parsable) { char buf[64]; char datetime[DT_BUF_LEN]; be_snapshot_list_t *snap = NULL; for (snap = be->be_node_snapshots; snap != NULL; snap = snap->be_next_snapshot) { char name[ZFS_MAX_DATASET_NAME_LEN + 1]; const char *datetime_fmt = "%F %R"; const char *be_name = be->be_node_name; const char *root_ds = be->be_root_ds; const char *snap_name = snap->be_snapshot_name; char *pos; uint64_t used = snap->be_snapshot_space_used; time_t creation = snap->be_snapshot_creation; struct tm *tm = localtime(&creation); (void) strncpy(name, root_ds, sizeof (name)); pos = strstr(name, be_name); (void) strcpy(pos, snap_name); (void) strftime(datetime, DT_BUF_LEN, datetime_fmt, tm); nicenum(used, buf, sizeof (buf)); if (parsable) if (hdr->cols[1].width != 0) (void) printf("%s;%s;%s;%s;%llu;%s;%ld\n", be_name, snap_name, "", "", used, be->be_policy_type, creation); else (void) printf("%s;%s;%llu;%s;%ld\n", be_name, snap_name, used, be->be_policy_type, creation); else if (hdr->cols[1].width != 0) (void) printf(" %-*s %-*s %-*s %-*s %-*s " "%-*s\n", hdr->cols[0].width-3, name, hdr->cols[1].width, "-", hdr->cols[2].width, "-", hdr->cols[3].width, buf, hdr->cols[4].width, be->be_policy_type, hdr->cols[5].width, datetime); else (void) printf(" %-*s %-*s %-*s %-*s\n", hdr->cols[0].width-3, snap_name, hdr->cols[3].width, buf, hdr->cols[4].width, be->be_policy_type, hdr->cols[5].width, datetime); } }
static void print_be_nodes(const char *be_name, boolean_t parsable, struct hdr_info *hdr, be_node_list_t *nodes) { char buf[64]; char datetime[DT_BUF_LEN]; be_node_list_t *cur_be; for (cur_be = nodes; cur_be != NULL; cur_be = cur_be->be_next_node) { char active[3] = "-\0"; int ai = 0; const char *datetime_fmt = "%F %R"; const char *name = cur_be->be_node_name; const char *mntpt = cur_be->be_mntpt; const char *uuid_str = cur_be->be_uuid_str; be_snapshot_list_t *snap = NULL; uint64_t used = cur_be->be_space_used; time_t creation = cur_be->be_node_creation; struct tm *tm; if (be_name != NULL && strcmp(be_name, name) != 0) continue; if (parsable) active[0] = '\0'; tm = localtime(&creation); (void) strftime(datetime, DT_BUF_LEN, datetime_fmt, tm); for (snap = cur_be->be_node_snapshots; snap != NULL; snap = snap->be_next_snapshot) used += snap->be_snapshot_space_used; if (!cur_be->be_global_active) active[ai++] = 'x'; if (cur_be->be_active) active[ai++] = 'N'; if (cur_be->be_active_on_boot) { if (!cur_be->be_global_active) active[ai] = 'b'; else active[ai] = 'R'; } nicenum(used, buf, sizeof (buf)); if (parsable) (void) printf("%s;%s;%s;%s;%llu;%s;%ld\n", name, (uuid_str != NULL ? uuid_str: ""), active, (cur_be->be_mounted ? mntpt: ""), used, cur_be->be_policy_type, creation); else (void) printf("%-*s %-*s %-*s %-*s %-*s %-*s\n", hdr->cols[0].width, name, hdr->cols[1].width, active, hdr->cols[2].width, (cur_be->be_mounted ? mntpt: "-"), hdr->cols[3].width, buf, hdr->cols[4].width, cur_be->be_policy_type, hdr->cols[5].width, datetime); } }
static void count_widths(enum be_fmt be_fmt, struct hdr_info *hdr, be_node_list_t *be_nodes) { size_t len[NUM_COLS]; char buf[DT_BUF_LEN]; int i; be_node_list_t *cur_be; for (i = 0; i < NUM_COLS; i++) len[i] = hdr->cols[i].width; for (cur_be = be_nodes; cur_be != NULL; cur_be = cur_be->be_next_node) { char name[ZFS_MAX_DATASET_NAME_LEN + 1]; const char *be_name = cur_be->be_node_name; const char *root_ds = cur_be->be_root_ds; char *pos; size_t node_name_len = strlen(cur_be->be_node_name); size_t root_ds_len = strlen(cur_be->be_root_ds); size_t mntpt_len = 0; size_t policy_len = 0; size_t used_len; uint64_t used = cur_be->be_space_used; be_snapshot_list_t *snap = NULL; if (cur_be->be_mntpt != NULL) mntpt_len = strlen(cur_be->be_mntpt); if (cur_be->be_policy_type != NULL) policy_len = strlen(cur_be->be_policy_type); (void) strlcpy(name, root_ds, sizeof (name)); pos = strstr(name, be_name); if (be_fmt == BE_FMT_DEFAULT) { if (node_name_len > len[0]) len[0] = node_name_len; } else { if (root_ds_len + 3 > len[0]) len[0] = root_ds_len + 3; } if (mntpt_len > len[2]) len[2] = mntpt_len; if (policy_len > len[4]) len[4] = policy_len; for (snap = cur_be->be_node_snapshots; snap != NULL; snap = snap->be_next_snapshot) { uint64_t snap_used = snap->be_snapshot_space_used; const char *snap_name = snap->be_snapshot_name; (void) strcpy(pos, snap_name); if (be_fmt == BE_FMT_DEFAULT) used += snap_used; else if (be_fmt & BE_FMT_SNAPSHOT) { int snap_len = strlen(name) + 3; if (be_fmt == BE_FMT_SNAPSHOT) snap_len -= pos - name; if (snap_len > len[0]) len[0] = snap_len; nicenum(snap_used, buf, sizeof (buf)); used_len = strlen(buf); if (used_len > len[3]) len[3] = used_len; } } if (be_fmt == BE_FMT_DEFAULT) { int used_len; nicenum(used, buf, sizeof (buf)); used_len = strlen(buf); if (used_len > len[3]) len[3] = used_len; } nicenum(used, buf, sizeof (buf)); } for (i = 0; i < NUM_COLS; i++) hdr->cols[i].width = len[i]; }
/* Scale_Axis: A simple Axis Scaler */ void gtk_graph_axis_scale_axis(GtkGraph *graph, gint user_width, gint user_height) { GtkGraphTrace *t; gfloat global_X_max = -1E99, global_Y_max= -1E99, global_X_min=1E99, global_Y_min=1E99; gint i; /* --- Do error checking --- */ g_return_if_fail (graph != NULL); g_return_if_fail (GTK_IS_GRAPH (graph)); t = graph->traces; if (graph->independant->autoscale_limits || graph->dependant->autoscale_limits) { for (i = 0 ; i < graph->num_traces ; i++) { if (t->xmax > global_X_max) global_X_max = t->xmax; if (t->xmin < global_X_min) global_X_min = t->xmin; if (t->ymax > global_Y_max) global_Y_max = t->ymax; if (t->ymin < global_Y_min) global_Y_min = t->ymin; t = t->next; } } switch (graph->graph_type) { case XY: if (graph->independant->autoscale_limits) /* we're autoscaling the independant axis limits*/ { graph->independant->axis_max = nicenum(global_X_max, 0); graph->independant->axis_min = nicenum(global_X_min, 0); } if (graph->independant->autoscale_tick) /* we're autoscaling the independant axis ticks*/ { graph->independant->n_maj_tick = 10; graph->independant->n_min_tick = 5; graph->independant->maj_tick = (graph->independant->axis_max - graph->independant->axis_min) / graph->independant->n_maj_tick; graph->independant->min_tick = graph->independant->maj_tick/ graph->independant->n_min_tick; } else { graph->independant->n_maj_tick = ceil((graph->independant->axis_max - graph->independant->axis_min) / (float) graph->independant->maj_tick); graph->independant->n_min_tick = graph->independant->maj_tick / graph->independant->min_tick; } if (graph->dependant->autoscale_limits) /* we're autoscaling the dependant axis limits*/ { graph->dependant->axis_max = nicenum(global_Y_max, 0); graph->dependant->axis_min = nicenum(global_Y_min, 0); } if (graph->dependant->autoscale_tick) /* we're autoscaling the dependant axis ticks*/ { graph->dependant->n_maj_tick = 10; graph->dependant->n_min_tick = 5; graph->dependant->maj_tick = (graph->dependant->axis_max - graph->dependant->axis_min) / graph->dependant->n_maj_tick; graph->dependant->min_tick = graph->dependant->maj_tick/ graph->dependant->n_min_tick; } else { graph->dependant->n_maj_tick = ceil((graph->dependant->axis_max - graph->dependant->axis_min) / (float)graph->dependant->maj_tick); graph->dependant->n_min_tick = graph->dependant->maj_tick / graph->dependant->min_tick; } graph->independant->pxls_per_maj_tick = user_width / graph->independant->n_maj_tick; graph->independant->scale_factor = (gfloat) (graph->independant->pxls_per_maj_tick) / graph->independant->maj_tick; graph->dependant->pxls_per_maj_tick = user_height / graph->dependant->n_maj_tick; graph->dependant->scale_factor = (gfloat) (graph->dependant->pxls_per_maj_tick) / graph->dependant->maj_tick; break; case POLAR: if (graph->dependant->autoscale_limits) /* we're autoscaling the dependant axis limits*/ { graph->dependant->axis_max = nicenum(global_Y_max, 0); graph->dependant->axis_min = nicenum(global_Y_min, 0); } if (graph->dependant->autoscale_tick) /* we're autoscaling the dependant axis ticks*/ { graph->dependant->n_maj_tick = 10; graph->dependant->n_min_tick = 5; graph->dependant->maj_tick = (graph->dependant->axis_max - graph->dependant->axis_min) / graph->dependant->n_maj_tick; graph->dependant->min_tick = graph->dependant->maj_tick/ graph->dependant->n_min_tick; } else { graph->dependant->n_maj_tick = ceil((graph->dependant->axis_max - graph->dependant->axis_min) / (float)graph->dependant->maj_tick); graph->dependant->n_min_tick = graph->dependant->maj_tick / graph->dependant->min_tick; } switch(graph->polar_format.type) { case DEGREES_SYMMETRIC: graph->independant->axis_min = -180.0; graph->independant->axis_max = 179.9; break; case DEGREES_ANTISYMMETRIC: graph->independant->axis_min = 0.0; graph->independant->axis_max = 359.9; break; case RADIANS_SYMMETRIC: graph->independant->axis_min = -3.141592654; graph->independant->axis_max = 3.141592654; break; case RADIANS_ANTISYMMETRIC: graph->independant->axis_min = 0.0; graph->independant->axis_max = 2*3.141592654; break; } graph->dependant->pxls_per_maj_tick = user_height / (2.0 * graph->dependant->n_maj_tick); graph->dependant->scale_factor = (gfloat) (graph->dependant->pxls_per_maj_tick) / graph->dependant->maj_tick; break; case SMITH: graph->dependant->n_maj_tick = 1.0; graph->dependant->maj_tick = 1.0; graph->dependant->pxls_per_maj_tick = user_height / (2.0 * graph->dependant->n_maj_tick); graph->dependant->scale_factor = (gfloat) (graph->dependant->pxls_per_maj_tick) / graph->dependant->maj_tick; break; } }
static void round_axis_limits(double *amin, double *amax, int scale) { double smin, smax; int nrange; if (*amin == *amax) { switch (sign(*amin)) { case 0: *amin = -1.0; *amax = +1.0; break; case 1: *amin /= 2.0; *amax *= 2.0; break; case -1: *amin *= 2.0; *amax /= 2.0; break; } } if (scale == SCALE_LOG) { if (*amax <= 0.0) { errmsg("Can't autoscale a log axis by non-positive data"); *amax = 10.0; *amin = 1.0; return; } else if (*amin <= 0.0) { errmsg("Data have non-positive values"); *amin = *amax/1.0e3; } smin = log10(*amin); smax = log10(*amax); } else if (scale == SCALE_LOGIT) { if (*amax <= 0.0) { errmsg("Can't autoscale a logit axis by non-positive data"); *amax = 0.9; *amin = 0.1; return; } else if (*amin <= 0.0) { errmsg("Data have non-positive values"); *amin = 0.1; } smin = log(*amin/(1-*amin)); smax = log(*amax/(1-*amax)); } else { smin = *amin; smax = *amax; } if (sign(smin) == sign(smax)) { nrange = -rint(log10(fabs(2*(smax - smin)/(smax + smin)))); nrange = MAX2(0, nrange); } else { nrange = 0; } smin = nicenum(smin, nrange, NICE_FLOOR); smax = nicenum(smax, nrange, NICE_CEIL); if (sign(smin) == sign(smax)) { if (smax/smin > 5.0) { smin = 0.0; } else if (smin/smax > 5.0) { smax = 0.0; } } if (scale == SCALE_LOG) { *amin = pow(10.0, smin); *amax = pow(10.0, smax); } else if (scale == SCALE_LOGIT) { *amin = exp(smin)/(1.0 + exp(smin)); *amax = exp(smax)/(1.0 + exp(smax)); } else { *amin = smin; *amax = smax; } }
void default_ticks(int gno, int axis, double *gmin, double *gmax) { tickmarks t; double range, d, tmpmax = *gmax, tmpmin = *gmin; get_graph_tickmarks(gno, &t, axis); if (axis % 2 && (g[gno].type == LOGY || g[gno].type == LOGXY)) { tmpmax = ceil(log10(tmpmax)); tmpmin = floor(log10(tmpmin)); } else if ((axis % 2 == 0) && (g[gno].type == LOGX || g[gno].type == LOGXY)) { tmpmax = ceil(log10(tmpmax)); tmpmin = floor(log10(tmpmin)); } range = nicenum(tmpmax - tmpmin, 0); d = nicenum(range / (t.t_num - 1), 1); tmpmin = floor(tmpmin / d) * d; tmpmax = ceil(tmpmax / d) * d; if (axis % 2 && (g[gno].type == LOGY || g[gno].type == LOGXY)) { *gmax = pow(10.0, tmpmax); *gmin = pow(10.0, tmpmin); t.tmajor = (int)d; if (t.tmajor == 0.0) { t.tmajor = 1.0; } if ((int)t.tmajor < 2) { t.tminor = 1.0; } else { t.tminor = 0.0; } if (fabs(tmpmax) > 6.0 || fabs(tmpmin) > 6.0) { t.tl_format = POWER; t.tl_prec = 0; } else { t.tl_format = DECIMAL; t.tl_prec = 0; } } else if ((axis % 2 == 0) && (g[gno].type == LOGX || g[gno].type == LOGXY)) { *gmax = pow(10.0, tmpmax); *gmin = pow(10.0, tmpmin); t.tmajor = (int)d; if (t.tmajor == 0.0) { t.tmajor = 1.0; } if (fabs(tmpmax) > 6.0 || fabs(tmpmin) > 6.0) { t.tl_format = POWER; t.tl_prec = 0; } else { t.tl_format = DECIMAL; t.tl_prec = 0; } if ((int)t.tmajor < 2) { t.tminor = 1.0; } else { t.tminor = 0.0; } } else { *gmax = tmpmax; *gmin = tmpmin; t.tmajor = d; t.tminor = d * 0.5; } set_graph_tickmarks(gno, &t, axis); }
static void show_vdev_stats(const char *desc, const char *ctype, nvlist_t *nv, int indent) { vdev_stat_t *vs; vdev_stat_t *v0 = { 0 }; uint64_t sec; uint64_t is_log = 0; nvlist_t **child; uint_t c, children; char used[6], avail[6]; char rops[6], wops[6], rbytes[6], wbytes[6], rerr[6], werr[6], cerr[6]; v0 = umem_zalloc(sizeof (*v0), UMEM_NOFAIL); if (indent == 0 && desc != NULL) { (void) printf(" " " capacity operations bandwidth ---- errors ----\n"); (void) printf("description " "used avail read write read write read write cksum\n"); } if (desc != NULL) { char *suffix = "", *bias = NULL; char bias_suffix[32]; (void) nvlist_lookup_uint64(nv, ZPOOL_CONFIG_IS_LOG, &is_log); (void) nvlist_lookup_string(nv, ZPOOL_CONFIG_ALLOCATION_BIAS, &bias); if (nvlist_lookup_uint64_array(nv, ZPOOL_CONFIG_VDEV_STATS, (uint64_t **)&vs, &c) != 0) vs = v0; if (bias != NULL) { (void) snprintf(bias_suffix, sizeof (bias_suffix), " (%s)", bias); suffix = bias_suffix; } else if (is_log) { suffix = " (log)"; } sec = MAX(1, vs->vs_timestamp / NANOSEC); nicenum(vs->vs_alloc, used, sizeof (used)); nicenum(vs->vs_space - vs->vs_alloc, avail, sizeof (avail)); nicenum(vs->vs_ops[ZIO_TYPE_READ] / sec, rops, sizeof (rops)); nicenum(vs->vs_ops[ZIO_TYPE_WRITE] / sec, wops, sizeof (wops)); nicenum(vs->vs_bytes[ZIO_TYPE_READ] / sec, rbytes, sizeof (rbytes)); nicenum(vs->vs_bytes[ZIO_TYPE_WRITE] / sec, wbytes, sizeof (wbytes)); nicenum(vs->vs_read_errors, rerr, sizeof (rerr)); nicenum(vs->vs_write_errors, werr, sizeof (werr)); nicenum(vs->vs_checksum_errors, cerr, sizeof (cerr)); (void) printf("%*s%s%*s%*s%*s %5s %5s %5s %5s %5s %5s %5s\n", indent, "", desc, (int)(indent+strlen(desc)-25-(vs->vs_space ? 0 : 12)), suffix, vs->vs_space ? 6 : 0, vs->vs_space ? used : "", vs->vs_space ? 6 : 0, vs->vs_space ? avail : "", rops, wops, rbytes, wbytes, rerr, werr, cerr); } free(v0); if (nvlist_lookup_nvlist_array(nv, ctype, &child, &children) != 0) return; for (c = 0; c < children; c++) { nvlist_t *cnv = child[c]; char *cname = NULL, *tname; uint64_t np; int len; if (nvlist_lookup_string(cnv, ZPOOL_CONFIG_PATH, &cname) && nvlist_lookup_string(cnv, ZPOOL_CONFIG_TYPE, &cname)) cname = "<unknown>"; len = strlen(cname) + 2; tname = umem_zalloc(len, UMEM_NOFAIL); (void) strlcpy(tname, cname, len); if (nvlist_lookup_uint64(cnv, ZPOOL_CONFIG_NPARITY, &np) == 0) tname[strlen(tname)] = '0' + np; show_vdev_stats(tname, ctype, cnv, indent + 2); free(tname); } }