/* * Print a running summary of interface statistics. * Repeat display every interval seconds, showing statistics * collected over that interval. Assumes that interval is non-zero. * First line printed is cumulative. */ static void intpr(void) { int line = 0; sigset_t oldmask, mask; char *bunit; int ratef = 0; struct ppp_stats cur, old; struct ppp_comp_stats ccs, ocs; memset(&old, 0, sizeof(old)); memset(&ocs, 0, sizeof(ocs)); while (1) { get_ppp_stats(&cur); if (zflag || rflag) get_ppp_cstats(&ccs); signal(SIGALRM, catchalarm); signalled = 0; alarm(interval); if ((line % 20) == 0) { if (zflag) { printf("IN: COMPRESSED INCOMPRESSIBLE COMP | "); printf("OUT: COMPRESSED INCOMPRESSIBLE COMP\n"); bunit = dflag? "KB/S": "BYTE"; printf(" %s PACK %s PACK RATIO | ", bunit, bunit); printf(" %s PACK %s PACK RATIO", bunit, bunit); } else { printf("%8.8s %6.6s %6.6s", "IN", "PACK", "VJCOMP"); if (!rflag) printf(" %6.6s %6.6s", "VJUNC", "VJERR"); if (vflag) printf(" %6.6s %6.6s", "VJTOSS", "NON-VJ"); if (rflag) printf(" %6.6s %6.6s", "RATIO", "UBYTE"); printf(" | %8.8s %6.6s %6.6s", "OUT", "PACK", "VJCOMP"); if (!rflag) printf(" %6.6s %6.6s", "VJUNC", "NON-VJ"); if (vflag) printf(" %6.6s %6.6s", "VJSRCH", "VJMISS"); if (rflag) printf(" %6.6s %6.6s", "RATIO", "UBYTE"); } putchar('\n'); } if (zflag) { if (ratef) { printf("%8.3f %6u %8.3f %6u %6.2f", KBPS(W(d.comp_bytes)), W(d.comp_packets), KBPS(W(d.inc_bytes)), W(d.inc_packets), ccs.d.ratio / 256.0); printf(" | %8.3f %6u %8.3f %6u %6.2f", KBPS(W(c.comp_bytes)), W(c.comp_packets), KBPS(W(c.inc_bytes)), W(c.inc_packets), ccs.c.ratio / 256.0); } else { printf("%8u %6u %8u %6u %6.2f", W(d.comp_bytes), W(d.comp_packets), W(d.inc_bytes), W(d.inc_packets), ccs.d.ratio / 256.0); printf(" | %8u %6u %8u %6u %6.2f", W(c.comp_bytes), W(c.comp_packets), W(c.inc_bytes), W(c.inc_packets), ccs.c.ratio / 256.0); } } else { if (ratef) printf("%8.3f", KBPS(V(p.ppp_ibytes))); else printf("%8u", V(p.ppp_ibytes)); printf(" %6u %6u", V(p.ppp_ipackets), V(vj.vjs_compressedin)); if (!rflag) printf(" %6u %6u", V(vj.vjs_uncompressedin), V(vj.vjs_errorin)); if (vflag) printf(" %6u %6u", V(vj.vjs_tossed), V(p.ppp_ipackets) - V(vj.vjs_compressedin) - V(vj.vjs_uncompressedin) - V(vj.vjs_errorin)); if (rflag) { printf(" %6.2f ", CRATE(d)); if (ratef) printf("%6.2f", KBPS(W(d.unc_bytes))); else printf("%6u", W(d.unc_bytes)); } if (ratef) printf(" | %8.3f", KBPS(V(p.ppp_obytes))); else printf(" | %8u", V(p.ppp_obytes)); printf(" %6u %6u", V(p.ppp_opackets), V(vj.vjs_compressed)); if (!rflag) printf(" %6u %6u", V(vj.vjs_packets) - V(vj.vjs_compressed), V(p.ppp_opackets) - V(vj.vjs_packets)); if (vflag) printf(" %6u %6u", V(vj.vjs_searches), V(vj.vjs_misses)); if (rflag) { printf(" %6.2f ", CRATE(c)); if (ratef) printf("%6.2f", KBPS(W(c.unc_bytes))); else printf("%6u", W(c.unc_bytes)); } } putchar('\n'); fflush(stdout); line++; count--; if (!infinite && !count) break; sigemptyset(&mask); sigaddset(&mask, SIGALRM); sigprocmask(SIG_BLOCK, &mask, &oldmask); if (!signalled) { sigemptyset(&mask); sigsuspend(&mask); } sigprocmask(SIG_SETMASK, &oldmask, NULL); signalled = 0; alarm(interval); if (!aflag) { old = cur; ocs = ccs; ratef = dflag; } } }
#include "midas_macro.h" name(Sample Frontend) display(3) /**************************************/ hv_driver_begin driver(lrs2415, 1) hv_driver_end equipment_begin equipment_trigger(1, POLLED, CRATE(0)) equipment_periodic(scaler, 2, 10) equipment_hv(3, 60) equipment_end /**************************************/ /* define CAMAC slots */ constant(IO506, 10) constant(ADC, 12) constant(SCALER, 13) /**************************************/ init_begin camac_init camac_inhibit_clear camac_crate_zinit control(IO506, 1, 26) /* enable auto mode */ control(IO506, 2, 16) /* NIM level, int. clock */ control(IO506, 0, 26) /* enable LAM Flip-Flop */ control(IO506, 0, 10) /* clear LAM Flip-Flop */ /* reset LAM logic */ write(IO506, 1, 16, 2) write(IO506, 1, 16, 3) write(IO506, 1, 16, 2) write(IO506, 1, 16, 0) init_end exit_begin exit_end begin_run begin_run_end end_run end_run_end pause_run pause_run_end resume_run resume_run_end
/* * Print a running summary of interface statistics. * Repeat display every interval seconds, showing statistics * collected over that interval. Assumes that interval is non-zero. * First line printed at top of screen is always cumulative. */ void intpr(void) { register int line = 0; sigset_t oldmask, mask; struct ppp_stats cur, old; struct ppp_comp_stats ccs, ocs; memset(&old, 0, sizeof(old)); memset(&ocs, 0, sizeof(ocs)); while (1) { get_ppp_stats(&cur); if (cflag || rflag) get_ppp_cstats(&ccs); (void)signal(SIGALRM, catchalarm); signalled = 0; (void)alarm(interval); if ((line % 20) == 0) { if (line > 0) putchar('\n'); if (cflag) { printf("%6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s", "ubyte", "upack", "cbyte", "cpack", "ibyte", "ipack", "ratio"); printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s %6.6s", "ubyte", "upack", "cbyte", "cpack", "ibyte", "ipack", "ratio"); putchar('\n'); } else { printf("%6.6s %6.6s %6.6s %6.6s %6.6s", "in", "pack", "comp", "uncomp", "err"); if (vflag) printf(" %6.6s %6.6s", "toss", "ip"); if (rflag) printf(" %6.6s %6.6s", "ratio", "ubyte"); printf(" | %6.6s %6.6s %6.6s %6.6s %6.6s", "out", "pack", "comp", "uncomp", "ip"); if (vflag) printf(" %6.6s %6.6s", "search", "miss"); if(rflag) printf(" %6.6s %6.6s", "ratio", "ubyte"); putchar('\n'); } memset(&old, 0, sizeof(old)); memset(&ocs, 0, sizeof(ocs)); } if (cflag) { printf("%6d %6d %6d %6d %6d %6d %6.2f", W(d.unc_bytes), W(d.unc_packets), W(d.comp_bytes), W(d.comp_packets), W(d.inc_bytes), W(d.inc_packets), W(d.ratio) == 0? 0.0: 1 - 1.0 / W(d.ratio) * 256.0); printf(" | %6d %6d %6d %6d %6d %6d %6.2f", W(c.unc_bytes), W(c.unc_packets), W(c.comp_bytes), W(c.comp_packets), W(c.inc_bytes), W(c.inc_packets), W(d.ratio) == 0? 0.0: 1 - 1.0 / W(d.ratio) * 256.0); putchar('\n'); } else { printf("%6d %6d %6d %6d %6d", V(p.ppp_ibytes), V(p.ppp_ipackets), V(vj.vjs_compressedin), V(vj.vjs_uncompressedin), V(vj.vjs_errorin)); if (vflag) printf(" %6d %6d", V(vj.vjs_tossed), V(p.ppp_ipackets) - V(vj.vjs_compressedin) - V(vj.vjs_uncompressedin) - V(vj.vjs_errorin)); if (rflag) printf(" %6.2f %6d", CRATE(W(d.comp_bytes), W(d.unc_bytes), W(d.unc_bytes)), W(d.unc_bytes)); printf(" | %6d %6d %6d %6d %6d", V(p.ppp_obytes), V(p.ppp_opackets), V(vj.vjs_compressed), V(vj.vjs_packets) - V(vj.vjs_compressed), V(p.ppp_opackets) - V(vj.vjs_packets)); if (vflag) printf(" %6d %6d", V(vj.vjs_searches), V(vj.vjs_misses)); if (rflag) printf(" %6.2f %6d", CRATE(W(d.comp_bytes), W(d.unc_bytes), W(d.unc_bytes)), W(c.unc_bytes)); putchar('\n'); } fflush(stdout); line++; if (interval == 0) exit(0); sigemptyset(&mask); sigaddset(&mask, SIGALRM); sigprocmask(SIG_BLOCK, &mask, &oldmask); if (! signalled) { sigemptyset(&mask); sigsuspend(&mask); } sigprocmask(SIG_SETMASK, &oldmask, NULL); signalled = 0; (void)alarm(interval); if (aflag==0) { old = cur; ocs = ccs; } } }