For the analysis of operating system statistics, there are numerous possibilities, but for a rough analysis, it is sufficient in many cases to take the most important components under the microscope. The rrd-using tool serverstats provides quick and easy access to statistics and graphs about load, processes, memory and hard disk.

 

installation

The serverstats package is located in the Ubuntu repos and is therefore installed via apt: 

$ 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 about serverstats can be found above all in the directory /usr/share/doc/serverstats/:

: / usr / share / doc / serverstats $ ls
changelog.Debian.gz examples graph-config.txt.gz simple-config.txt
copyright faq.txt README.Debian sources.txt.gz

In order to make the interface accessible via the web browser, we /etccopied the example configuration for Apache to the appropriate directory and activated it:

: / usr / share / doc / serverstats # cp examples / apache.conf /etc/apache2/sites-available/serverstats.conf
# a2ensite serverstats.conf
# service apache2 reload

In principle, this is a first, simple configuration is already completed. The web interface displays the graphs generated from the rrd data to:

Ubuntu serverstats-graph1.png

Add components

The main configuration directory for serverstats is located at:

$ ls / etc / serverstats /
graph.php log.php main.php monitor.php rra.php simple.php sources.php

By default, a basic configuration is provided through the simple.php file . In this file we will now configure further components, in the following example the hard disk / dev / sda (the section disk 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)' ) 
                ) 
        ) ,

If the configuration was successful, you can check if you have created rrd data:

$ 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

In the web interface, the new graphs appear automatically because a cronjob update.php calls 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 basis on which the rrd data is built up can be extracted from the plugins. In the case of the disk plugin this is /proc/diskstats:

$ grep diskstats /usr/share/serverstats/sources/disk.php
	public function __construct ( $ d isk, $ withpartitions  = false, $ sector_size  = 512, $ path_stat  =  '/ proc / diskstats' )

Ubuntu serverstats-graph2.png

Categories: Tutorials

0 Comments

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: