anchor.diff:    catch _:_ -> []
     end.
   
  -cpu() ->
  -  try 
  -    {_,L1,L2,_} = cpu_sup:util([detailed]),
  -    L1++L2
  -  catch _:_ -> []
  -  end.
  -
  -smem() ->
  -  try
  -    {PhysMem, FreeMem, _} = memsup:get_memory_data(),
  -    [{physmem, PhysMem},{freemem, FreeMem}]
  -  catch _:_ -> []
  -  end.
  -
   %% /proc/self/stat
   %% [pid,comm,state,ppid,pgrp,session,tty_nr,tpgid,flags,
   %%  minflt,cminflt,majflt,cmajflt,utime,stime,cutime,cstime,
   %%  priority,nice,0,itrealvalue,starttime,vsize,rss|_]
  -get_beam({unix,linux}, FD) -> 
  +get_beam(#cst{beam={linux, FD}}) -> %% FD is /proc/self/stat
     {ok,PSI} = file:pread(FD,0,2000),
     [_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,_,BS|_] = string:tokens(PSI," "),
     [{beamsize,list_to_integer(BS)}];
  -get_beam({unix,sunos}, FD) -> %% FD is /proc/self/psinfo
  +get_beam(#cst{beam={sunos, FD}}) -> %% FD is /proc/self/psinfo
     {ok,PSI} = file:pread(FD,0,2000),
     <<_:44/binary,Vsz:32,_/binary>> = PSI,
     [{beamsize, Vsz*1024}];
  -get_beam({unix,_}, {Port, Cmd}) when port(Port) ->
  +get_beam(#cst{beam={unix, Port, Cmd}}) when port(Port) ->
     Port ! {self(), {command, Cmd}},
     receive
       {Port, {data, Data}} -> 
  
positive.code:   after 
      500 -> []
    end;
  get_beam(_, _) -> [].
  
  get_beam({unix,linux}) -> %% FD is /proc/self/psinfo
    {ok, FD} = file:open("/proc/self/stat", [read]),
    FD;
  get_beam({unix,sunos}) -> %% FD is /proc/self/psinfo
    {ok, FD} = file:open("/proc/self/psinfo", [read,raw,binary]), 
    FD;
  get_beam({unix,_}) ->
    {open_port({spawn,"sh -s prfSys 2>&1"},[stream]),
     "ps -o 'vsz' -p "++os:getpid()++" | tail -1\n"};
  get_beam(_) -> no.
  
  get_load({{unix,linux},{2,SubV,_}}) when SubV >= 6 ->
    {ok,FD} = file:open("/proc/stat", [read,raw]),
    get_load(FD);
  get_load(FD) when element(1,FD)==file_descriptor ->
    {ok,3} = file:position(FD, 3),
    {ok,Str} = file:read(FD, 100),
    {ok,[User,Nice,Kern,Idle,IoWt],_} = io_lib:fread("~d~d~d~d~d", Str),
    {FD,[User,Nice,Kern,Idle,IoWt]}.
  
negative.code: 
  -export([collect/1,config/2]).
  
  -record(cst,{beam, load, os={os:type(),os:version()}, node=node()}).
  
  -define(LOG(T), prf:log(process_info(self()),T)).
  
  %%% returns {State, Data}
  collect(init) ->
    Cst = #cst{},
    collect(Cst#cst{beam = init_get_beam(Cst), load=init_get_load(Cst)});
  collect(Cst) ->
    {Cst, {?MODULE, [{node, Cst#cst.node}, {now, now()}|data(Cst)]}}.
  
  config(State,_ConfigData) -> State.
  
  data(Cst) ->
    sysi()++stat()++mem()++get_beam(Cst)++get_load(Cst).
  
  -define(SIS,[allocated_areas,process_count,system_version,system_architecture]).
  sysi() -> sysi(?SIS,[]).
  