_cpu.c

tmi2_fluffos_v2/lib/cmds/xtra/_cpu.c · 642 B

From the archive tmi2_fluffos_v2.zip

Download the archive   « Back to the archive contents

 
//	File	:  /cmds/xtra/_cpu.c
//	Creator	:  Truilkan@Portals
//
//	This command determines the percentage of cpu usage presently
//	taken by the mud's gamedriver.
 
#include <mudlib.h>
 
inherit DAEMON;

#define SCALE	(1.0/10.0)
#define SYNTAX	"Syntax: cpu\n"

int cmd_cpu() {
   float value;
   mapping r;
   
   r = rusage();
   value = SCALE * (r["utime"] + r["stime"]) / uptime();
 
   printf("%s is presently using a CPU load of %f%%\n",
	  capitalize(mud_name()), value);

return 1; }
 
int help() {

   write( SYNTAX + "\n" +
     "This command displays the present cpu load level of the mud's" +
     " driver.\n");
 
return 1; }
 

Site Stats

Snippets: 1791
Codebases: 571