summaryrefslogtreecommitdiff
path: root/system/std.zusatz/1.8.7/src/eumelmeter
blob: ba9247649ad92a22482e1ecc3f180225b763c017 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
                                              (* Author: J.Liedtke*)
PACKET eumelmeter DEFINES                     (* Stand:  11.10.83 *)
 
     init log ,
     log :
 
 
LET snapshot interval = 590.0 ;

REAL VAR next snapshot time ,
         time        , timex ,
         paging wait , paging wait x ,
         paging busy , paging busy x ,
         fore cpu    , fore cpu x ,
         back cpu    , back cpu x ,
         system cpu  , system cpu x ,
         delta t ;
INT VAR storage max, used ;
TEXT VAR record ;

PROC init log :

  time        := clock (1) ;
  paging wait := clock (2) ;
  paging busy := clock (3) ;
  fore cpu    := clock (4) ;
  back cpu    := clock (5) ;
  system cpu  := clock (6) ;
  next snapshot time := time + snapshot interval

ENDPROC init log ;

PROC log (INT CONST active terminals, active background) :

  new snapshot time if was clock reset ;
  IF clock (1) >= next snapshot time
    THEN save values ;
         get new values ;
         create stat record ;
         put log (record) ;
         define next snapshot time
  FI .

new snapshot time if was clock reset :
  IF clock (1) < next snapshot time - snapshot interval 
    THEN next snapshot time := clock (1)
  FI .

save values :
  time x := time ;
  paging wait x := paging wait ;
  paging busy x := paging busy ;
  fore cpu x    := fore cpu ;
  back cpu x    := back cpu ;
  system cpu x  := system cpu .

get new values :
  time := clock (1) ;
  paging wait := clock (2) ;
  paging busy := clock (3) ;
  fore cpu    := clock (4) ;
  back cpu    := clock (5) ;
  system cpu  := clock (6) ;
  storage (storage max, used) .

create stat record :
  record :=  text (used, 5) ;
  record CAT text (active terminals,3) ;
  record CAT text (active background,3) ;
  delta t := (time - time x) ;
  percent (paging wait, paging wait x) ;
  percent (paging busy, paging busy x) ;
  percent (fore cpu, fore cpu x) ;
  percent (back cpu, back cpu x) ;
  percent (system cpu, system cpu x) ;
  percent (last, 0.0) ;
  percent (nutz, 0.0) .

last :   paging wait  + paging busy  + fore cpu  + back cpu  + system cpu
       - paging waitx - paging busyx - fore cpux - back cpux - system cpux .

nutz :   time  - paging wait  - system cpu
       - timex + paging waitx + system cpux .

define next snapshot time :
  next snapshot time := time + snapshot interval .
 
ENDPROC log ;

PROC percent (REAL CONST neu, alt ) :

  record CAT text ( (neu-alt) / delta t * 100.0, 6,1) + "%"

ENDPROC percent ;

ENDPACKET eumelmeter ;
 
INT VAR active terminals , active background ;

task password ("-") ;
break ;
command dialogue (FALSE) ;
forget ("eumelmeter") ;
init log ;
REP
  pause (6000) ;
  count active processes (active terminals, active background) ;
  log (active terminals, active background)
PER ;

PROC count active processes (INT VAR active terminals, active background) :
 
  active terminals := 0 ;
  active background := 0 ;
  TASK VAR process := myself ;
  REP
    next active (process) ;
    IF user process 
      THEN IF process at terminal
             THEN active terminals INCR 1
             ELSE active background INCR 1
           FI
    FI
  UNTIL process = myself PER .

user process :         NOT (process < supervisor) .

process at terminal :  channel (process) >= 0 .

ENDPROC count active processes ;