docker run --network=host --privileged -v /proc:/mnt/proc:ro -v $PWD/collectd.conf:/etc/collectd/collectd.conf --name collectd fr3nd/collectd
docker run --rm influxdb:1.0 influxd config > influxdb.conf
#启用influxdb中的collectd配置
docker cp collectd:/usr/share/collectd/types.db .
docker run -d \
--name influxdb \
-p 8086:8086 \
-p 8083:8083 \
-p 25826:25826/udp \
-e INFLUXDB_ADMIN_ENABLED=true \
-e INFLUXDB_DB=collectd \
-e INFLUXDB_ADMIN_USER=root \
-e INFLUXDB_ADMIN_PASSWORD=root \
-e INFLUXDB_USER=hogwarts -e INFLUXDB_USER_PASSWORD=hogwarts \
-v $PWD/influxdb.conf:/etc/influxdb/influxdb.conf:ro \
-v $PWD/types.db:/usr/share/collectd/types.db:ro \
-v $PWD/influxdb:/var/lib/influxdb \
influxdb:1.0
docker run -d --name=grafana -p 9100:3000 grafana/grafana
function parallel(){
cmd=$1
p=$2
range=$3
for index in $range;
do
while (($(jobs -l | grep Running | wc -l ) > $p ));do sleep 1;done;
{ eval $cmd &} ;
done
}
parallel "sleep 1" 100 "$(seq 5000)"