How to Install Web VMStat on centOS 6


Web VMStat Install on centos 6

Web-Vmstat it’s a small application written in Java and HTML which displays live Linux system statistics, such as Memory, CPU, I/O, Processes, etc. taken over vmstat monitoring command line in a pretty Web page with charts (SmoothieCharts) and diagrams through WebSocket streams using websocketd program.

Step 1: Install Web-Vmstat

# yum install wget nano unzip -y

Step 2. Now go to Veb-Vmstat official web page at and download the latest version

# wget https://github.com/joewalnes/web-vmstats/archive/master.zip

Step 3. Extract the downloaded master.zip

# unzip master.zip
# cd web-vmstats-master

Step 4. Web directory holds the HTML and Java files needed for the application to run in a Web environment. Create a directory under your system where you want to host the Web files and move all web content to that directory.

# mkdir /opt/web_vmstats
# cp -r web/* /opt/web_vmstats/

Step 5. Download and install websocketd streaming program.

# wget https://github.com/joewalnes/websocketd/releases/download/v0.2.9/websocketd-0.2.9-linux_386.zip (for 32 bit)
# wget https://github.com/joewalnes/websocketd/releases/download/v0.2.9/websocketd-0.2.9-linux_amd64.zip (for 64 bit)

Step 6. Extract the WebSocket.

# unzip websocketd-0.2.9-linux_amd64.zip
# cp websocketd /usr/local/bin/

Step 7. Now you can test it by running websocketd.

# websocketd --port=8080 --staticdir=/opt/web_vmstats/ /usr/bin/vmstat -n 1

Step 8. This step is optional and only works with init script supported systems.

# vi /etc/init.d/web-vmstats

Add the following content.

#!/bin/sh
# source function library
. /etc/rc.d/init.d/functions
start() {
                echo "Starting webvmstats process..."

/usr/local/bin/websocketd --port=8080 --staticdir=/opt/web_vmstats/ /usr/bin/vmstat -n 1 &
}

stop() {
                echo "Stopping webvmstats process..."
                killall websocketd
}

case "$1" in
    start)
       start
        ;;
    stop)
       stop
        ;;
    *)
        echo "Usage: stop start"
        ;;
esac

------ save and quit (:wq) ------

# chmod +x /etc/init.d/web-vmstats
# /etc/init.d/web-vmstats start

Step 9. Open a browser and use the following URL to display Vmstats system statistics.

http://ip:8080

Step 10. To display name, version and other details about your current machine and the operating system running on it. Go to Web-Vmstat files path and run the following commands.

# cd /opt/web_vmstats
# cat /etc/issue.net | head -1 > version.txt
# cat /proc/version >> version.txt

Step 11. Then open index.html file and add the following javascript code before <main id=”charts”> line.

# vi index.html

Use the following JavaScript code.

<div align='center'><h3><pre id="contents"></pre></h3></div>
<script>
function populatePre(url) {
    var xhr = new XMLHttpRequest();
    xhr.onload = function () {
        document.getElementById('contents').textContent = this.responseText;
    };
    xhr.open('GET', url);
    xhr.send();
}
populatePre('version.txt');
                </script>

------ save and quit (:wq) -------

Step 12. To view the final result refresh http://system_IP:8080

---- DONE,Thanks ----