Projet

Général

Profil

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

root / plugins / system / openbsd-memory @ ff1c67d5

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

1 8a481afc northox
#!/bin/sh
2
if [ "$1" = "config" ]; then
3
  echo "graph_title Memory usage (in MB)"
4
  echo 'graph_category system'
5 9ae7e3a9 northox
  echo "acti.label Active"
6
  echo "used.label Used"
7
  echo "total.label Total"
8
  echo "free.label Free"
9 8a481afc northox
  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 7a05e29c northox
  if (v ~ /G$/) { sub("G", "", v);v *= 1024 }
17 8a481afc northox
  else if (v ~ /M$/) sub("M", "", v)
18 7a05e29c northox
  else if (v ~ /K$/) { sub("K", "", v);v /= 1024 }
19 8a481afc northox
  else v /= 1024 * 1024;
20
  return v;
21
}
22
function spliter(v, i) {
23 7a05e29c northox
  split(v, a, "/");
24 8a481afc northox
  return(a[i]);
25
}
26
/^Memory/ {
27
  acti  = scale(spliter($3,1));
28 9ae7e3a9 northox
  used  = scale(spliter($3,2));
29 8a481afc northox
  free  = scale($6);
30 9ae7e3a9 northox
  total = used + free;
31 8a481afc northox
32
  print "acti.value", acti
33 9ae7e3a9 northox
  print "used.value", used
34 8a481afc northox
  print "total.value", total
35
  print "free.value", free
36
}'