Usenet comp.sys.dec (1990-2013)
 help / color / mirror / Atom feed
From: bin@primate.wisc.edu (Brain in Neutral)
Subject: Re: average load statistics on DS300?
Date: 3 Mar 90 17:19:47 GMT	[thread overview]
Message-ID: <1819@uakari.primate.wisc.edu> (raw)
In-Reply-To: 797@shodha.dec.com

Something I have used to get load average out of a MIPS M/120.  Might
be useful on a DECstation as well... strip out the irrelevant junk...

/*
	RISC/os 4.0 version

	xloadback - back end for xload for machines with no X server.
	Just sends load average to stdout every now and then.  Should
	attach over network to xloadfront process on machine with X
	server that reads it and displays it a la regular xload.

	Sends the load*100 as a 32-bit quantity in network byte order.

	12 July 1989	Paul DuBois	dubois@rhesus.primate.wisc.edu
*/

# include	<stdio.h>
# include	<nlist.h>
# include	<sys/fixpoint.h>
# include	<sys/file.h>


# define	UNIX		"/unix"
# define	KMEM_FILE	"/dev/kmem"
# define	KMEM_ERROR	"cannot open /dev/kmem"


# define	LOADAV	0

struct nlist namelist[] = {		    /* namelist for vmunix grubbing */
	{"avenrun"},
	{0}
};

char	hostname[256];


main ()
{
register	int kmem;		/* kmem pointer */
long		lavgSeek;		/* offset to load average in kmem */

ufix	tmpLoad;	/* system load info */
long	iLoad;

	if (gethostname (hostname, sizeof (hostname)))
		smerror ("don't know hostname");

	/* Get name list. Then open kmem so we can seek for information */

	nlist(UNIX, namelist);
	if (namelist[LOADAV].n_type == 0)
		smerror("cannot get name list");
	lavgSeek = namelist[LOADAV].n_value;
	kmem = open(KMEM_FILE, O_RDONLY);
	if (kmem < 0)
		smerror(KMEM_ERROR);
	write (1, hostname, strlen (hostname) + 1);
	for (;;)
	{
		sleep (5);
		lseek(kmem, lavgSeek, 0);
		read(kmem, (char *) &tmpLoad, sizeof (tmpLoad));
		iLoad = (long) (FIX_TO_DBL (tmpLoad) * 100.0);
		iLoad = htonl (iLoad);
printf ("%d %d %g\n", iLoad, ntohl (iLoad), FIX_TO_DBL (tmpLoad));
		/*write(1, (char *) &iLoad, sizeof (iLoad));*/
		fflush (stdout);
	}
}



/* Diagnostic printer - Print message and exit */

smerror(message)
char	*message;
{
	fprintf (stderr, "%s\n", message);
	exit(1);
}


  reply	other threads:[~1990-03-03 17:19 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1990-03-02 20:09 average load statistics on DS300? Robert Macomber
1990-03-03  0:13 `  Alan's Home for Wayward Notes File.
1990-03-03 17:19   ` Brain in Neutral [this message]
1990-03-07  0:55   ` Mark Litwack
read-only archive

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox