Jesin's Blog

Welcome to the Portal of Technology

  • Facebook
  • GitHub
  • Google+
  • RSS
  • Twitter
  • Home
  • Categories
    • Domains
    • Linux
    • Networking
    • PHP
    • Virtualization
    • Web Design
    • Web Servers
    • Windows
  • WordPress Plugins
    • Custom Error Pages
    • HTTP Digest Authentication
    • Mailgun Email Validator
  • Toolbox
    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool
  • About Me
  • Contact Me
  • Sitemap
Home ›
Linux ›
How to configure Linode Longview on ServerPilot

How to configure Linode Longview on ServerPilot

December 29, 2015 Linux Jesin A 6 Comments

linode logo

Longview is a system statistics graphing service by Linode. The statistics for CPU, memory, network, Disk I/O, MySQL, Apache and Nginx are collected by an agent program and are graphed in the Linode control panel. This service can also be used on servers that are not hosted on Linode. This article will show you how to setup Longview for monitoring a ServerPilot stack.

Add a Longview client

Login to the Linode manager, navigate to the Longview tab and click “Add Client”. The following popup appears:

longview add client

Click go back and click the ‘i’ button:

longview settings icon

Note down the API key, we’ll be using this in the next step.

Install Longview agent

We’re going to install Longview manually, so follow the instructions below to add the Longview APT repository.

sudo bash -c 'echo "deb http://apt-longview.linode.com/ trusty main" > /etc/apt/sources.list.d/longview.list'
curl -s https://apt-longview.linode.com/linode.gpg | sudo apt-key add -

Create a directory for the Longview API and configuration files.

sudo mkdir /etc/linode
sudo bash -c 'echo "<API KEY>" > /etc/linode/longview.key'

Install Longview:

sudo apt-get update
sudo apt-get install linode-longview -y

Configure Apache

Create and edit the following file:

/etc/apache-sp/conf.d/status.conf
<IfModule mod_status.c>
    ExtendedStatus On
    <Location /server-status>
    <IfModule security2_module> 
    SecRuleEngine Off
    </IfModule>
    <IfModule mod_rewrite.c>
    RewriteEngine Off
    </IfModule>
    SetHandler server-status
    Require ip 127.0.0.1
    </Location>
</IfModule>

The <IfModule security2_module> block is not required if mod_security is not installed. Do a configuration test and restart Apache:

sudo /opt/sp/apache/bin/apachectl -t
sudo service apache-sp restart

Access the Apache status URL using curl:

curl -v http://127.0.0.1:81/server-status?auto

This should display statistics on Apache processes, threads and workers.

Edit the Apache file in the Longview directory

sudo bash -c 'echo "location http://127.0.0.1:81/server-status?auto" > /etc/linode/longview.d/Apache.conf'

Restart the Longview service.

sudo service longview restart

Configure Nginx

Create a conf.d directory for Nginx:

sudo mkdir /etc/nginx-sp/conf.d/

Create the following file and paste the contents below it:

/etc/nginx-sp/conf.d/status.conf
server {
    listen 127.0.0.1:80;
    server_name 127.0.0.1;
    location /nginx_status {
        stub_status on;
        allow 127.0.0.1;
        deny all;
    }
}

Do a configtest for Nginx and reload if there are no errors:

sudo service nginx-sp configtest
sudo service nginx-sp reload

Test if the Nginx status URL displays connection information:

curl -v http://127.0.0.1/nginx_status
sudo bash -c 'echo "location http://127.0.0.1/nginx_status" > /etc/linode/longview.d/Nginx.conf'

Restart longview

sudo service longview restart

Wait for atleast 30 minutes for the Longview dashboard to be populated with statistics. No configuration is required for MySQL as the root password is saved in the /root/.my.cnf file. ServerPilot also comes configured with slow query logging so checkout Longview’s MySQL tab for this data.

Related posts:

modsecurity serverpilotHow to setup mod_security with ServerPilot How to setup AutoSSL on a free ServerPilot plan linux category thumbnailConfigure Apache Web Server Load Balancing wordpress custom 403 error pageCustom 403 and 401 error pages in WordPress Default ThumbnailBlocking Google Analytics and Statcounter

Tags: serverpilot

Comments

  1. Bradley says

    May 9, 2017 at 8:51 pm

    Hi, when I tried install longview I get this error messages. ı was install serverpilot before longview :/

    E: Could not get lock /var/lib/dpkg/lock – open (11: Resource temporarily unavailable)
    E: Unable to lock the administration directory (/var/lib/dpkg/), is another process using it?

    Reply
    • Jesin A says

      May 9, 2017 at 10:04 pm

      Hi Bradley,

      First restart your server and then try these commands, if they still don’t work execute the following and then try again.

      sudo rm /var/lib/apt/lists/lock
      sudo rm /var/cache/apt/archives/lock
      sudo rm /var/lib/dpkg/lock
      Reply
  2. Andy says

    July 16, 2017 at 1:07 pm

    Thanks for this guide – super helpful!

    Reply
  3. Mathew says

    July 30, 2017 at 6:40 pm

    I tried this, but for apache now I am getting the below error:

    403 Forbidden (for the server-status)

    Reply
  4. Steve Mitchell says

    January 5, 2018 at 11:11 am

    Thanks for your clear guide and steps. Worked perfectly for me!

    Reply
  5. Sam says

    February 23, 2019 at 11:24 pm

    Looking at this in February 2019. Are these instructions still all good to attempt?

    Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Get a wealth of information delivered to your inbox. Subscribe and never miss a single article.

  • Tutorials and howtos
  • Code, scripts and commands
  • Online Tools

* No spam, unsubscribe anytime

Hire Me

  • SSL installation and hardening (A+ on Qualys SSL test)
  • Apache & Nginx configuration
  • Email deliverability improvement (10/10 on Mail Tester & MailGenius)
  • WordPress customization, optimization and migration
  • and much more…

    Tools

    • DNS Lookup Tool
    • htdigest Generator Tool Online
    • htpasswd Generator Tool Online
    • HTTP Headers Lookup Tool
    • MD5 Encryption Tool
    • Open Port Check Tool
    • SHA-1 Encryption Tool
    • URL Encoding/Decoding Tool

    Nav

    • Home
    • About Me
    • Contact Me
    • Privacy Policy
    • Sitemap
    Vultr SSD VPS

    Creative Commons License
    Jesin's Blog by Jesin A is licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 4.0 International License.
    Based on a work at websistent.com.