Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!uunet!seismo!mcvax!ukc!its63b!csnjr From: csnjr@its63b.ed.ac.uk (Nick Rothwell) Newsgroups: comp.windows.x Subject: re: xrload - another bug fix Message-ID: <596@its63b.ed.ac.uk> Date: Thu, 20-Aug-87 06:23:16 EDT Article-I.D.: its63b.596 Posted: Thu Aug 20 06:23:16 1987 Date-Received: Sat, 22-Aug-87 18:17:25 EDT References: <8708172307.AA05897@decwrl.dec.com> Reply-To: nick%lfcs@its63b.ed.ac.uk (Nick Rothwell) Distribution: world Organization: LFCS, University of Edinburgh Lines: 33 Summary: Fixed to handle `down' status properly Another problem with the recently posted xrload program - it gets confused if hosts are down, since it always reads a complete line of information from ruptime, and there isn't one there if "down". This fix, to get-stats.c, cuts short the read if necessary. Perhaps fscanf works differently on other systems (stopping on '\n' for example), in which case this fix isn't necessary. 38,43c38,48 < nf = fscanf (pfile, "%s %s %s %d %s load %f, %f, %f", < stats[nh].sys_name, hstatus, stats[nh].how_long, < &stats[nh].users, junk, < &stats[nh].load_average[0], < &stats[nh].load_average[1], < &stats[nh].load_average[2]); --- > /* Read first part of line: */ > nf = fscanf (pfile, "%s %s %s", > stats[nh].sys_name, hstatus, stats[nh].how_long); > /* only read second part if "up" */ > if (!strcmp(hstatus, "up")) > nf += fscanf (pfile, " %d %s load %f, %f, %f", > &stats[nh].users, junk, > &stats[nh].load_average[0], > &stats[nh].load_average[1], > &stats[nh].load_average[2]); > -- Nick Rothwell, Laboratory for Foundations of Computer Science, Edinburgh. nick%lfcs.ed.ac.uk@cs.ucl.ac.uk !mcvax!ukc!lfcs!nick ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ ~~ "Nothing's forgotten. Nothing is ever forgotten." - Herne