Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / plugins / system / openbsd-memory @ e5ce7492

Historique | Voir | Annoter | Télécharger (805 octets)

1
#!/bin/sh
2
if [ "$1" = "config" ]; then
3
  echo "graph_title Memory usage (in MB)"
4
  echo 'graph_category system'
5
  echo "acti.label Active"
6
  echo "used.label Used"
7
  echo "total.label Total"
8
  echo "free.label Free"
9
  exit 0
10
fi
11

    
12
# Memory: Real: 14M/69M act/tot  Free: 173M  Swap: 0K/612M used/tot
13

    
14
top -un | nawk '
15
function scale(v) {
16
  if (v ~ /G$/) { sub("G", "", v);v *= 1024 }
17
  else if (v ~ /M$/) sub("M", "", v)
18
  else if (v ~ /K$/) { sub("K", "", v);v /= 1024 }
19
  else v /= 1024 * 1024;
20
  return v;
21
}
22
function spliter(v, i) {
23
  split(v, a, "/");
24
  return(a[i]);
25
}
26
/^Memory/ {
27
  acti  = scale(spliter($3,1));
28
  used  = scale(spliter($3,2));
29
  free  = scale($6);
30
  total = used + free;
31

    
32
  print "acti.value", acti
33
  print "used.value", used
34
  print "total.value", total
35
  print "free.value", free
36
}'