Click here to Skip to main content
14,980,680 members
Articles / Web Development / HTML
Article
Posted 5 Oct 2016

Stats

13.3K views
465 downloads
4 bookmarked

Uechi APM Web is an APM (Application Performance Management) Open Source Server Performance Monitor

Rate me:
Please Sign up or sign in to vote.
5.00/5 (3 votes)
7 Oct 2016Apache3 min read
Uechi APM Web is an APM (Application Performance Management) Open Source Server Performance Monitor written and developed in Java and C # for all Linux and Windows platforms. The Uechi.APM.Web offers a complete resource for unlimited monitoring servers in real time. Have full control of the CPU cons

 

Introduction

Uechi APM Web is an APM (Application Performance Management) Open Source Server Performance Monitor written and developed in Java and C # for all Linux and Windows platforms. The Uechi.APM.Web offers a complete resource for unlimited monitoring servers in real time. Have full control of the CPU consumption, memory, disk and network traffic. Communication is done via TCP Protocol Socket connection.

Background

Overview:

All features are available in the demo simulated operating in http://vm.uechi.com.br/Uechi.APM.Web/ address.

img003ue

img004ue

img002ue

img001ue

Architecture:

Below is a flow chart of the general operation of the structure:

uechiapmfluxus

Structure:

Uechi.APM.Web Monitoring Web project developed in JSP on the Java platform 1.8 and 1.7 compatible, running on Glassfish Web 4.0 and Tomcat 8.0 server.

Linux version Uechi.APM.Services.Socket.Server Customer Service Project Socket in Java 1.8 compatible with Linux platforms.

Windows version Uechi.APM.Services.Socket.Server Customer Service Project Socket developed in VS.NET Framework 4.0 supports Windows platforms.

Supported modules:

. Glassfish 4+

. Tomcat 8+

. JDK 1.7 +

. Framework 4.0

Tested and Approved in:

Linux CentOS x86_64 versions 6 and 7.

Ubuntu x86_64 versions 12 and 14.

Windows Windows 2003 Advanced Server

Windows Server 2008 R2

Windows Server 2012 R2

Using the code

Uechi.APM.Web

Communicates with the server through socket with TCP making an authenticated request by a Hash Key Encrypted MD5 and requested option, Uechi.APM.Service.Socket.Server makes validation and consultation request requested from the server returning the information to the Uechi.APM.Web.

The configuration of Uechi.APM.Web and made by custom parameters such as time, amount of display servers screen, better resolution setting. The design is responsive, thus be viewed in different types of resolution to other devices such as tablets and phones. The security key settings must be made through a Hash Key Encryption with MD5 128 bits of your choice, then following the communication port and the servers will be done communication, separated by ',' comma. You also has a medium-warning alerts configuration severe being distinguished by yellow and red colors, which can be configured according to your CPU consumption suggestion, Memory, Disk and Network traffic.

Source Code Servlet monitor.java

Java
package br.com.uechi.monitor;

import br.com.uechi.util.tratar;
import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

/**
 *
 * @author paulo.uechi
 */
@WebServlet(name = "monitor", urlPatterns = {"/monitor"})
public class monitor extends HttpServlet {

    protected void doLoad(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        HttpSession session = request.getSession();
        String strConta;
        int intConta;
        try {
            strConta = request.getParameter("c");
            if (strConta == null){
                intConta = 0;
            } else {
                intConta = tratar.ToIntDBNull(strConta);
            }
        } catch (Exception e) {
            intConta = 0;
        }
        try {
            communicator objCOM = new communicator();
            //Teste Simulado
            request.setAttribute("customDOMMonitor", objCOM.SimulatorMountScreen(intConta));
            //Conecta Servidores
            //request.setAttribute("customDOMMonitor", objCOM.MountScreen(intConta));
        } catch (Exception e) {
            session.invalidate();
        } finally {
        }
    }


    /**
     * Processes requests for both HTTP <code>GET</code> and <code>POST</code>
     * methods.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    protected void processRequest(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        doLoad(request, response);
        security.goPostBack(request, response);
    }

    /**
     * Handles the HTTP <code>GET</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Handles the HTTP <code>POST</code> method.
     *
     * @param request servlet request
     * @param response servlet response
     * @throws ServletException if a servlet-specific error occurs
     * @throws IOException if an I/O error occurs
     */
    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        processRequest(request, response);
    }

    /**
     * Returns a short description of the servlet.
     *
     * @return a String containing servlet description
     */
    @Override
    public String getServletInfo() {
        return "Short description";
    }


}

Uechi.APM.Services.Socket.Server

Linux version is a Client Open Source server performance monitor for Linux, which responds to requests made by Uechi.APM.Web.

Source Code Service load.java

Java
package br.com.uechi.services.socket.server.apm;

import br.com.uechi.util.arquivos;
import br.com.uechi.util.propriedades;
import br.com.uechi.util.tempo;
import br.com.uechi.util.tratar;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

/**
 *
 * @author paulo.uechi
 */
public class load {
    private Socket objSocket;
    private String strParameter;
    private propriedades objPrp = new propriedades();

    public boolean start() {
        boolean booRet = true;
        try {
            String strReturn = null;
            int intOption = 0;
            int port = tratar.ToIntDBNull(objPrp.configuracao(0, "Porta"));
            ServerSocket objServerSocket = new ServerSocket(port);
            System.out.println("[" + tempo.pegaDataHora24H() + "] - Uechi.Server.Monitor inicializado na porta: " + String.valueOf(port));
            while (true) {
                objSocket = objServerSocket.accept();
                InputStream objStm = objSocket.getInputStream();
                InputStreamReader objStr = new InputStreamReader(objStm);
                BufferedReader objBfr = new BufferedReader(objStr);
                String strParameter = objBfr.readLine();
                try {
                    intOption = options(strParameter);
                    System.out.println("[" + tempo.pegaDataHora24H() + "] - Uechi.Server.Monitor Parametro recebido: " + strParameter);
                    strReturn = parameters(intOption, strParameter) + "\n";
                } catch (NumberFormatException e) {
                    strReturn = "Error parameters.\n";
                    System.out.println("[" + tempo.pegaDataHora24H() + "] - Uechi.Server.Monitor Erro Parametro: " + e.getMessage());
                }
                OutputStream objOts = objSocket.getOutputStream();
                OutputStreamWriter objOtw = new OutputStreamWriter(objOts);
                BufferedWriter objBfw = new BufferedWriter(objOtw);
                objBfw.write(strReturn);
                System.out.println("[" + tempo.pegaDataHora24H() + "] - Uechi.Server.Monitor Retorno enviado: " + strReturn);
                objBfw.flush();
            }
        } catch (Exception e) {
            System.out.println("[" + tempo.pegaDataHora24H() + "] - Uechi.Server.Monitor Erro: " + e.getMessage());
        } finally {
            try {
                objSocket.close();
            } catch (Exception e) {
                System.out.println("[" + tempo.pegaDataHora24H() + "] - Uechi.Server.Monitor Socket Erro: " + e.getMessage());
            }
        }

        return booRet;
    }

    private String parameters(int intOpt, String strParameter) {
        String strRet = null;
        try {
            if (strParameter != null && strParameter.length() > 0) {
                if (validate(strParameter)) {
                    strRet = command(intOpt);
                }
            }
        } catch (Exception e) {
            strRet = null;
        }
        return strRet;
    }

    private boolean validate(String strParameter) {
        boolean booVal = false;
        String strChave;
        String strValida;
        try {
            if (strParameter != null && strParameter.length() > 0) {
                strChave = strParameter.substring(0, 32);
                strValida = objPrp.configuracao(0, "Chave");
                if (strValida.length() > 0) {
                    if (strChave.toLowerCase().equals(strValida.toLowerCase())) {
                        booVal = true;
                    }
                }
            }
        } catch (Exception e) {
            booVal = false;
        }
        return booVal;
    }

    private int options(String strParameter) {
        int intRet = 0;
        String strSubParameter;
        try {
            if (strParameter != null && strParameter.length() > 0) {
                strSubParameter = strParameter.substring(32, 33);
                intRet = tratar.ToIntDBNull(strSubParameter);
            }
        } catch (Exception e) {
            intRet = 0;
        }
        return intRet;
    }

    private String command(int intOpt) {

        String strOut = "";
        String strCmd = null;
        String strLine = null;
        boolean boocmd = true;
        try {
            if (intOpt == 1) {
                // CPU
                // strCmd = "iostat";
                // strCmd = "sar -f 1 1";
                strCmd = arquivos.diretorioRaiz("uechi.command.sh") + " " + intOpt;
            } else if (intOpt == 2) {
                // Memory
                //strCmd = "free -m | awk 'NR==2{printf \"Memory Usage: %s/%sMB (%.2f%%)\\n\", $3,$2,$3*100/$2 }'";
                strCmd = arquivos.diretorioRaiz("uechi.command.sh") + " " + intOpt;
            } else if (intOpt == 3) {
                // Disk
                //strCmd = "df -h | awk '$NF==\"/\"{printf \"Disk Usage: %d/%dGB (%s)\\n\", $3,$2,$5}'";
                strCmd = arquivos.diretorioRaiz("uechi.command.sh") + " " + intOpt;
            } else if (intOpt == 4) {
                // Network
                //strCmd = "sar -f -n DEV 1 1";
                strCmd = arquivos.diretorioRaiz("uechi.command.sh") + " " + intOpt;
            } else if (intOpt == 9) {
                // All
                strCmd = arquivos.diretorioRaiz("uechi.monitor.sh");
            } else {
                boocmd = false;
            }
            if (boocmd) {
                Process objProcess = Runtime.getRuntime().exec(strCmd);
                BufferedReader objBfr = new BufferedReader(new InputStreamReader(objProcess.getInputStream()));
                while ((strLine = objBfr.readLine()) != null) {
                    strOut += strLine + ";";
                }
                objProcess.destroy();
            }
        } catch (Exception e) {
            strOut = e.getMessage();
        }
        return strOut;
    }
   
}

Uechi.APM.Services.Socket.Server

Windows version is a Client Open Source server performance monitor for Windows, which responds to requests made by Uechi.APM.Web.

Source Code Service service.cs

C#
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Diagnostics;
using System.Linq;
using System.ServiceProcess;
using System.Text;
using System.Timers;
using Uechi.Socket.Library;

namespace Uechi.APM.Services.Socket.Server
{
    public partial class Service : ServiceBase
    {
        protected string strOutMsg;

        Timer objTimer = new Timer();
        Boolean booLog = SocketUtil.Tratar.ToBooleanDBNull(SocketUtil.Parameters.GetAppKey("log"));


        public Service()
        {
            InitializeComponent();
            try
            {
                SocketUtil.Show.Mensagens("Inicialização do Serviço " + SocketUtil.Parameters.GetAppKey("sistema") + ".", booLog);
                objTimer.Interval = Convert.ToInt64(SocketUtil.Tratar.ToInt64DBNull(SocketUtil.Parameters.GetAppKey("intervalo")));
            }
            catch (Exception ex)
            {
                SocketUtil.Show.Mensagens("Erro na inicialização do serviço " + SocketUtil.Parameters.GetAppKey("sistema") + ": " + ex.Message.ToString(), booLog);
            }
            finally
            {
            }
        }

        protected void objTimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            try
            {
                objTimer.Enabled = false;
                SocketServer objSock = new SocketServer();
                objSock.Iniciar(booLog);
                objTimer.Enabled = true;
            }
            catch (Exception ex)
            {
                SocketUtil.Show.Mensagens("Falha na inicialização do serviço " + SocketUtil.Parameters.GetAppKey("sistema") + ": " + ex.Message.ToString(), booLog);
            }
        }

        protected override void OnStart(string[] args)
        {
            objTimer.Elapsed += new ElapsedEventHandler(objTimer_Elapsed);
            objTimer.Enabled = true;
        }

        protected override void OnPause()
        {
            objTimer.Enabled = false;
            SocketUtil.Show.Mensagens("Serviço " + SocketUtil.Parameters.GetAppKey("sistema") + " finalizado.", booLog);
        }

        protected override void OnContinue()
        {
            objTimer.Enabled = true;
            SocketUtil.Show.Mensagens("Serviço " + SocketUtil.Parameters.GetAppKey("sistema") + " finalizado.", booLog);
        }

        protected override void OnStop()
        {
            objTimer.Enabled = false;
            SocketUtil.Show.Mensagens("Serviço " + SocketUtil.Parameters.GetAppKey("sistema") + " finalizado.", booLog);
        }
    }
}    

 

Points of Interest

Uechi.APM.Web is a real-time performance monitor servers for Linux and Windows Open Source platforms.

History

IT professionals always need tools that help keep all your structures in good working order.

Most companies do not have real-time monitoring of your servers and process, has only features offered by providers.

Needed urgent a real-time server performance monitor with detailed information platform, CPU, memory, disk and network traffic.

After an arduous search for APM tools (application performance management) some things appeared Open Source, but none with the main features I needed. I found many powerful tools but they all paid without exception and to make matters worse, most with very complex configurations.

Solution develop itself (APM), some weekends and a few evenings Uechi.APM.Web and now born with the help of my sister finally approved and published.

I am sharing this story because I'm sure that will help many other developers and companies that need such a tool but provides no money and no resource to have.

License

This article, along with any associated source code and files, is licensed under The Apache License, Version 2.0

Share

About the Author

Paulo Uechi
Architect Uechi.com.br
Brazil Brazil
Resume:

Architect specialist technology company, 20 years of experience in software development, working on various technology platforms, high languages and low-level, structured and oriented.

Specializations:

(JAVA/C#/C++/VB.NET/VB 6.0/ ASP.NET / HTML5 / jQuery / MVC / RIA / WCF / WPF / XNA / JSP/ Servlets/ Struts/ Struts2/ JDBC/ SOA /PHP / LUA / Ruby / XML / ASP 3.0 / Silverlight / Frameworks 1.0/1.1/2.0/.3.5/4.0/4.5)
(VS.NET 2003/2005/2008/2010/2012/2013 MS E Blend/VS 6-5/VSS/TFS/SVN/ Eclipse / Netbeans / Rational)
(PL-SQL / DTS / LINQ / SQL Server / Sybase / Oracle / MySQL / Postrgree / Informix / CrystalReports / MS Reporting Service)

Comments and Discussions

 
QuestionPorting to ASP.NET Pin
Laurentiu LAZAR7-Oct-16 1:07
MemberLaurentiu LAZAR7-Oct-16 1:07 
AnswerRe: Porting to ASP.NET Pin
Paulo Uechi7-Oct-16 5:51
MemberPaulo Uechi7-Oct-16 5:51 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.