Retourner au contenu associé (entrée de forum : Plomberie unixienne)
Posté par Marotte ⛧ le 27 février 2017 à 23:30. En réponse au message Plomberie unixienne. Évalué à 6.
#!/usr/bin/env bash PERIOD=1 RRD_TPL='vmstat_rrd' RRD_DB='vmstat.rrd' test -f "${RRD_DB}" || rrdtool create "${RRD_DB}" --start $(date +%s) -s ${PERIOD} $(tr '\n' ' ' < "${RRD_TPL}") vmstat -n ${PERIOD} \ | awk '{ if (NR>3) { printf "%s", strftime("%s"); for (i=1; i<18; i++) { printf ":%i", $i; } print "000円"; fflush(); } }' \ | xargs -0 -n 1 rrdupdate ${RRD_DB} &
Le fichier vmstat_rrd contient la définition de la base RRD :
DS:r:GAUGE:60:0:32768 DS:b:GAUGE:60:0:32768 DS:swapd:GAUGE:60:0:1073741824 DS:free:GAUGE:60:0:1073741824 DS:buff:GAUGE:60:0:1073741824 DS:cache:GAUGE:60:0:1073741824 DS:si:GAUGE:60:0:1073741824 DS:so:GAUGE:60:0:1073741824 DS:bi:GAUGE:60:0:1073741824 DS:bo:GAUGE:60:0:1073741824 DS:in:GAUGE:60:0:1073741824 DS:cs:GAUGE:60:0:1073741824 DS:us:GAUGE:60:0:100 DS:sy:GAUGE:60:0:100 DS:id:GAUGE:60:0:100 DS:wa:GAUGE:60:0:100 DS:st:GAUGE:60:0:100 RRA:AVERAGE:0.5:1:60 RRA:AVERAGE:0.5:1m:60 RRA:AVERAGE:0.5:1h:24 RRA:AVERAGE:0.5:24h:7 RRA:AVERAGE:0.5:7d:520
La base se remplit au fur et à mesure (toute les secondes).
On peut facilement faire un graphique, défini dans un fichier vmstat_rrdgraph :
DEF:id=vmstat.rrd:id:AVERAGE DEF:us=vmstat.rrd:us:AVERAGE DEF:sy=vmstat.rrd:sy:AVERAGE DEF:wa=vmstat.rrd:wa:AVERAGE DEF:st=vmstat.rrd:st:AVERAGE CDEF:usage=100,id,- LINE1:usage#0000FF:Total LINE2:us#DD0044:User LINE3:sy#DD4400:System LINE4:wa#00DE40:Wait LINE5:st#40DE00:Stolen
Pour grapher la dernière heure :
$ rrdtool graph vmstat.png -w800 -h600 -t "CPU Usage" --start end-1h --end now $(tr '\n' ' ' < vmstat_rrdgraph)
Exemple
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
# Du coup je poste mon bousin
Posté par Marotte ⛧ . En réponse au message Plomberie unixienne. Évalué à 6.
Le fichier vmstat_rrd contient la définition de la base RRD :
La base se remplit au fur et à mesure (toute les secondes).
On peut facilement faire un graphique, défini dans un fichier vmstat_rrdgraph :
Pour grapher la dernière heure :
Exemple