Skip to content

Instantly share code, notes, and snippets.

@Tampa
Created March 28, 2019 04:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tampa/467e1bb2618a9afab096df2ddf190b56 to your computer and use it in GitHub Desktop.
Save Tampa/467e1bb2618a9afab096df2ddf190b56 to your computer and use it in GitHub Desktop.

Installation collectd, cgp, nginx, php7

Make available graphs using cgp on nginx with collectd.

Task Command
Install nginx: apt-get install nginx
Install php7: apt-get install php7.0-fpm
Set nginx.conf: server_tokens off;
gzip off;
Add collectd deb to sources: echo "deb http://pkg.ci.collectd.org/deb xenial collectd-5.6" >> /etc/apt/sources.list
Import the keys: gpg --recv-keys 3994D24FB8543576
gpg --export -a 3994D24FB8543576 | apt-key add -
Import the repos: apt-get update
Install collectd: apt-get install collectd
Download CGP: wget https://github.com/pommi/CGP/archive/master.zip
Unzip to the webserver: unzip master.zip -d /var/www/html/
Rename to graphs: mv /var/www/html/CGP-master /var/www/html/graphs
Open the collectd config: nano /etc/collectd/collectd.conf
Only enable plugins: LoadPlugin cpu
LoadPlugin df
LoadPlugin disk
LoadPlugin interface
LoadPlugin irq
LoadPlugin memory
LoadPlugin mysql
LoadPlugin network
LoadPlugin ping
LoadPlugin processes
LoadPlugin rrdtool
LoadPlugin swap
LoadPlugin vmem
Set interval to 10: Interval 10
Remove existing collectd data: rm -R /var/lib/collectd/rrd/*
Reload the service: service collectd restart
Open the CGP config: nano /var/www/html/grahps/conf/config.php
Set default time for CGP to 6 hours: $CONFIG['default'] = 21600;
Cut term array down to: $CONFIG['term'] = array(
'6hour' => 3600 * 6,
);
Set graph sizes: # default width/height of the graphs
$CONFIG['width'] = 500;
$CONFIG['height'] = 150;
# default width/height of detailed graphs
$CONFIG['detail-width'] = 1600;
$CONFIG['detail-height'] = 450;
Delete default config for nginx: rm /etc/nginx/sites-available/default
rm /etc/nginx/sites-enabled/default
Make new config for graphs location: touch /etc/nginx/sites-available/graphs
ln -s /etc/nginx/sites-available/graphs /etc/nginx/sites-enabled/graphs
Open the new config: nano /etc/nginx/sites-available/graphs
Paste making sure to set hostname: server {

listen 80 default_server;
listen [::]:80 default_server;

root /var/www/html;

index index.php;

server_name hostname;

location ~ .php$ {
include snippets/fastcgi-php.conf;
fastcgi_pass unix:/run/php/php7.0-fpm.sock;
}
}
Restart nginx: service nginx restart
Check url: http://hostname/graphs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment