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.
[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. We will show only how to graph memory usage.
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.
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.
useradd -u 0 -o -s /usr/local/sbin/vserver-stat -m vs-stat
ssh-keygen -t dsa -f ~/.ssh/vs-stat
mkdir ~vs-stat/.ssh scp root@cacti.dom.tld:.ssh/vs-stat.pub ~vs-stat/.ssh/authorized_keys
ssh -i vs-stat vs-stat@vs-host.dom.tld
mkdir ~apache/.ssh cp ~root/.ssh/{vs-stat*,known_keys} ~apache/.ssh/ chown -R apache ~apache/.ssh/
Now we can begin the real hard part :-) You must be connected as an administrator on cacti web interface.
Go on Data Template -> New
Click on the Create button. Again, go to the Data Source Item part.
Click on Save
Go on Graph Template -> New
Click on the Create button. Go to Graph Template Items -> Add
Click on the Create button. Again, go to Graph Template Items -> Add
Click on the Create button. Again, go to Graph Template Items -> Add
Click on the Create button. Again, go to Graph Template Items -> Add
You can also add items to gprint the average, min or max values.
Click on Save
Create the file :
<query> <name>VServer stat</name> <description>Retrieve vserver-stat output.</description> <arg_prepend>|host_hostname|</arg_prepend> <script_path>bash |path_cacti|/scripts/vs-stat.sh</script_path> <arg_index>index</arg_index> <arg_query>query</arg_query> <arg_get>get</arg_get> <arg_num_indexes>num_indexes</arg_num_indexes> <output_delimeter>:</output_delimeter> <index_order>vsName</index_order> <index_order_type>alphabetic</index_order_type> <index_title_format>|chosen_order_field|</index_title_format> <fields> <vsName> <name>vserver name</name> <direction>input</direction> <query_name>vsName</query_name> </vsName> <vsCtx> <name>Context number</name> <direction>input</direction> <query_name>vsCtx</query_name> </vsCtx> <vsProc> <name>Number of processes</name> <direction>output</direction> <query_name>vsProc</query_name> </vsProc> <vsVsz> <name>Virtual memory used</name> <direction>output</direction> <query_name>vsVsz</query_name> </vsVsz> <vsRss> <name>Real memory used</name> <direction>output</direction> <query_name>vsRss</query_name> </vsRss> <vsUserTime> <name>CPU user time</name> <direction>output</direction> <query_name>vsUserTime</query_name> </vsUserTime> <vsSysTime> <name>CPU system time</name> <direction>output</direction> <query_name>vsSysTime</query_name> </vsSysTime> </fields> </query>
Go to Data Query -> Add
Click on Create
Select the newly created query template vs-stat and go to Associated Graph Templates -> Add
Click on Save