We currently migrate to MediaWiki from our old installation, but not all content has been migrated yet. Take a look at the Wiki Team page for instructions how to help or browse through our new wiki at wiki.linux-vserver.org to find the information already migrated.

HowTo graph vserver activity with cacti through vserver-stat output

Introduction

[Cacti] is a tool to graph values, based on [RRDTool]. It's a bit like [MRTG] or [cricket].

This document is a HOWTO describing a way to graph vservers activity through the output of the vserver-stat command. This command shows the number of processes, the memory (RSS et VSZ) usage and CPU (system and user) consumption of the vservers hosted on a physical system.

The network

We assume cacti is already installed, on a host called cacti.dom.tld. This document is based on cacti version 0.8.6g. The machine hosting the vservers is vs-host.dom.tld.

Getting vserver-stat output

To graph values, cacti needs to be able to fetch theses values. The "classical" way to do that is by SNMP. In our case, this is not possible. So we must find a way to get on cacti.dom.tld the output of the vserver-stat command, executed on vs-host.dom.tld.

Many solutions are possible. Here is one possible solution, that is as secure as possible.

  1. On vs-host.dom.tld, create a user account called vs-stat. This account must be unusable : the connexion only show the output of the vserver-stat command
useradd -u 0 -o -s /usr/local/sbin/vserver-stat -m vs-stat
  1. On cacti.dom.tld, create ssh keys pair under the root account, with an empty passphrase
ssh-keygen -t dsa -f ~/.ssh/vs-stat
  1. On vs-host.dom.tld, put the public key in the authorized keys
mkdir ~vs-stat/.ssh
scp root@cacti.dom.tld:.ssh/vs-stat.pub ~vs-stat/.ssh/authorized_keys
  1. On cacti.dom.tld, test the connection (at this point, you should see the output of vserver-stat)
ssh -i vs-stat vs-stat@vs-host.dom.tld
  1. On vs-host.dom.tld, copy the keys in the user account used by your web server, typically apache or httpd
mkdir ~apache/.ssh
cp ~root/.ssh/{vs-stat*,known_keys} ~apache/.ssh/
chown -R apache ~apache/.ssh/

Cacti configuration

Now we can begin the real hard part :-)

Creating a new Data Template

On