Collecting System Statistics on Ubuntu using serverstats
For the analysis of operating system statistics, there are numerous opportunities. For a rough analysis, it is enough to take a closer look at the most important components. The rrd-used tool serverstats offers a fast and easy access to statistics and graphs about load, processes, memory and hard drive. In the following article, it is described how to install and configure serverstats on Ubuntu 14.04 LTS.
Installation
The package serverstats is located in the Ubuntu repos and is therefore installed via [1]
$ sudo apt-get install serverstats [...] The following extra packages will be installed: libapache2-mod-php5 libc-client2007e libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libmcrypt4 libmysqlclient18 libperl5.18 libsensors4 libsnmp-base libsnmp30 libtiff5 libvpx1 libxpm4 mlock mysql-common php5 php5-cli php5-common php5-gd php5-imap php5-json php5-mcrypt php5-mysql php5-readline php5-snmp rrdtool [...] The following NEW packages will be installed: libapache2-mod-php5 libc-client2007e libgd3 libjbig0 libjpeg-turbo8 libjpeg8 libmcrypt4 libmysqlclient18 libperl5.18 libsensors4 libsnmp-base libsnmp30 libtiff5 libvpx1 libxpm4 mlock mysql-common php5 php5-cli php5-common php5-gd php5-imap php5-json php5-mcrypt php5-mysql php5-readline php5-snmp rrdtool serverstats 0 upgraded, 29 newly installed, 0 to remove and 0 not upgraded. Need to get 8,686 kB of archives. After this operation, 35.6 MB of additional disk space will be used. [...]
Configuration
Useful information on serverstats can be found in the /usr/share/doc/serverstats/ directory:
:/usr/share/doc/serverstats$ ls
changelog.Debian.gz examples graph-config.txt.gz simple-config.txt
copyright faq.txt README.Debian sources.txt.gz
To make the interface accessible via web-browser, the example configuration for Apache is copied and activated in the corresponding /etc-directory:
:/usr/share/doc/serverstats# cp examples/apache.conf /etc/apache2/sites-available/serverstats.conf # a2ensite serverstats.conf # service apache2 reload
In principle, this completes an initial, simple configuration. The web interface displays the graphs generated from the rrd data:
Add components
The main configuration file for serverstats is located at:
$ ls /etc/serverstats/
graph.php log.php main.php monitor.php rra.php simple.php sources.php
By default, basic configuration is provided via the simple.php file. In this file, additional components are now configured. In the following example, the hard drive /dev/sda (the “disk” section already exists, but used is set to true):
$ cd /etc/serverstats/
$ sudo vi simple.php
'disk' => array(
'used' => true,
'disks' => array('sda'),
'graphs' => array(
'iorate' => array('used' => true, 'title' => 'IO-Rate (%s)')
)
),
You can check whether the configuration was successful by verifying whether rrd data has been generated:
$ cd /var/lib/serverstats/rrd
:/var/lib/serverstats/rrd$ ls
cpu.rrd disk_sda.rrd load.rrd memory.rrd traffic_proc_eth0.rrd users.rrd
The new graphs appear automatically in the web interface because a cron job calls "update.php" every minute:
$ cat /etc/cron.d/serverstats
$ Update the serverstatistic every minute.
* * * * * nobody if [ -x /usr/bin/php5 ] && [ -f /usr/share/serverstats/update.php ]; then /usr/bin/php5 /usr/share/serverstats/update.php > /dev/null; fi
The structure of the rrd data can be determined from the plugins. In case of a disk plugin, it is /proc/diskstats:
$ grep diskstats /usr/share/serverstats/sources/disk.php
public function __construct($disk, $withpartitions = false, $sector_size = 512, $path_stat = '/proc/diskstats')
References
- ↑ Ubuntu Package serverstats (packages.ubuntu.com)
Author: Georg Schönberger
|
Translator: Alina Ranzinger Alina has been working at Thomas-Krenn.AG since 2024. After her training as multilingual business assistant, she got her job as assistant of the Product Management and is responsible for the translation of texts and for the organisation of the department.
|
