标签:kvm
(1) 安装Redis 服务器并确保它能正常的响应请求root@kvm:~# apt-get install -y redis-server
...
root@kvm:~# redis-cli ping
PONG
root@kvm:~# apt-get install -y rabbitmq-server
...
root@kvm:~# rabbitmqctl add_vhost /sensu
Creating vhost "/sensu" ...
...done.
root@kvm:~# rabbitmqctl add_user sensu secret
Creating user "sensu" ...
...done.
root@kvm:~# rabbitmqctl set_permissions -p /sensu sensu ".*" ".*" ".*"
Setting permissions for user "sensu" in vhost "/sensu" ...
...done.
root@kvm:~# wget -q https://sensu.global.ssl.fastly.net/apt/pubkey.gpg -O- | apt-key add -
OK
root@kvm:~# echo "deb https://sensu.global.ssl.fastly.net/apt sensu main" | tee /etc/apt/sources.list.d/sensu.list
deb https://sensu.global.ssl.fastly.net/apt sensu main
root@kvm:~# apt-get update
...
root@kvm:~# apt-get install -y sensu
...
root@kvm:/etc/sensu/conf.d# cat api.json
{
"api": {
"host": "localhost",
"bind": "0.0.0.0",
"port": 4567
}
}
root@kvm:/etc/sensu/conf.d# cat transport.json
{
"transport": {
"name": "rabbitmq",
"reconnect_on_error": true
}
}
root@kvm:/etc/sensu/conf.d# cat rabbitmq.json
{
"rabbitmq": {
"host": "0.0.0.0",
"port": 5672,
"vhost": "/sensu",
"user": "sensu",
"password": "secret"
}
}
root@kvm:/etc/sensu/conf.d# cat redis.json
{
"redis": {
"host": "localhost",
"port": 6379
}
}
root@kvm:/etc/sensu/conf.d# cat client.json
{
"client": {
"name": "ubuntu",
"address": "127.0.0.1",
"subscriptions": [
"base"
],
"socket": {
"bind": "127.0.0.1",
"port": 3030
}
}
}
root@kvm:/etc/sensu/conf.d# apt-get install -y uchiwa
...
root@kvm:/etc/sensu/conf.d# cat /etc/sensu/uchiwa.json
{
"sensu": [
{
"name": "KVM guests",
"host": "localhost",
"ssl": false,
"port": 4567,
"path": "",
"timeout": 5000
}
],
"uchiwa": {
"port": 3000,
"stats": 10,
"refresh": 10000
}
}
root@kvm:/etc/sensu/conf.d# /etc/init.d/sensu-server start
* Starting sensu-server [ OK ]
root@kvm:/etc/sensu/conf.d# /etc/init.d/sensu-api start
* Starting sensu-api [ OK ]
root@kvm:/etc/sensu/conf.d# /etc/init.d/sensu-client start
* Starting sensu-client [ OK ]
root@kvm:/etc/sensu/conf.d# /etc/init.d/uchiwa restart
uchiwa started.
* Starting sensu-server [ OK ]
root@kvm:/etc/sensu/conf.d# /etc/init.d/sensu-api start
* Starting sensu-api [ OK ]
root@kvm:/etc/sensu/conf.d# /etc/init.d/sensu-client start
* Starting sensu-client [ OK ]
root@kvm:/etc/sensu/conf.d# /etc/init.d/uchiwa restart
uchiwa started.
root@debian:/etc/sensu/conf.d# /etc/init.d/sensu-client start
Starting sensu-client:.
root@debian:/etc/sensu/conf.d# apt install rubygems
...
root@debian:/etc/sensu/conf.d# gem search sensu | grep plugins | grep memory
sensu-plugins-memory (0.0.2)
sensu-plugins-memory-checks (2.1.0)
root@debian:/etc/sensu/conf.d#
root@debian:/etc/sensu/conf.d# gem install sensu-plugins-memory-checks
...
root@debian:/etc/sensu/conf.d# /etc/init.d/sensu-client restart
configuration is valid
Stopping sensu-client:.
Starting sensu-client:.
oot@debian:/etc/sensu/conf.d# /usr/local/bin/check-memory-percent.rb -w 80 -c 9
MEM OK - system memory usage: 11%
root@debian:/etc/sensu/conf.d#
)
root@kvm:/etc/sensu/conf.d# cat check_memory.json
{
"checks": {
"memory_check": {
"command": "/usr/local/bin/check-memory-percent.rb -w 80 -c 90",
"subscribers": ["base"],
"handlers": ["default"],
"interval": 300
}
}
}
root@kvm:/etc/sensu/conf.d# /etc/init.d/uchiwa restart
Killing uchiwa (pid 15350) with SIGTERM
Waiting uchiwa (pid 15350) to die...
Waiting uchiwa (pid 15350) to die...
uchiwa stopped.
uchiwa started.
root@kvm:/etc/sensu/conf.d# /etc/init.d/sensu-server restart
configuration is valid
* Stopping sensu-server [ OK ]
* Starting sensu-server [ OK ]
root@kvm:/etc/sensu/conf.d# /etc/init.d/sensu-api restart
configuration is valid
* Stopping sensu-api [ OK ]
* Starting sensu-api [ OK ]
(19)现在在Uchiwa的dashboard中,能够显示memory_check。
标签:kvm
原文地址:http://blog.51cto.com/aishangwei/2124622