Sharing A Powerful Tool For Application Auto Monitor, sharingpowerful

Source: Internet
Author: User

Sharing A Powerful Tool For Application Auto Monitor, sharingpowerful

This application monitoring tool shared in this article is a windows service that I developed and implemented more than five years ago. It sounds better. Yes, this application is a windows service that monitors windows Services at the beginning.

I remember the direct reason for writing this program at the time was that there were too many background scheduled windows tasks such as data statistics, carry-over, migration, and backup. due to historical reasons, no one was aware of the failure of the service, in the end, user complaints will occur, but it takes a long time for the feedback to the development side, or the user does not complain at all, but the log system does not do well (it can be considered none ), it is likely that some applications have encountered problems.

The disadvantage of this tool is also obvious. I have seen a powerful O & M Monitoring System in the background of a company, various detailed parameters and indicators, a large number of logs and a complete log analysis system, you can directly locate the problem to a server in a cluster and the management background of the visual data monitoring platform... It must be acknowledged that this tool cannot do anything about a company's unified monitoring platform system.

Later, as the demand changes, the monitoring types become more and more mature. In this process, we also considered adding the internal business monitoring logic of many special applications. However, the development team found that the unified monitoring platform is not so easy to implement. Abstract improvements make the monitoring universal have to unify the application framework. However, at that time, we were not very good at hand, so we had to simply and rudely implement the most easy general logic, it is gradually transformed into a simple heartbeat check for http-based applications. Currently, the main types of applications supported include windows Services, web services, web pages, wcf, and web APIs.

In some special business scenarios, this artifact can repeat the sky and take a place.

Currently, this application supports two forms: 1. winform Program 2. windows Service

It is easy to transform winform into a windows service. You only need to make slight modifications to the Program files:

Programusing System; using System. serviceProcess; using System. threading; using System. windows. forms; namespace ServiceMonitor {using PowerServiceMonitor. util; static class Program {// <summary> // Main entry of the Application /// </summary> [STAThread] static void Main () {Application. enableVisualStyles (); Application. setCompatibleTextRenderingDefault (false); MonitorConfig. initMonitorConfig (); // initialize the monitoring configuration file /// convert it to the winform program // var isCreate = false; // var mutex = new Mutex (true, "powerservicemonitor ", out isCreate); // if (isCreate = true) // {// Application. run (new MainForm (); // transformed to windows Service var ServicesToRun = new ServiceBase [] {new MonitorService ()}; ServiceBase. run (ServicesToRun );}}}

Finally, I will introduce the dynamic installation of windowsservice (installutil.exe), which can directly install the monitoring service.

 

The following describes the main functional modules of the monitoring system.

I. Application Monitoring Management Module

This module is the core of this application.

It mainly implements monitoring parameter configuration, metric item definition, and business logic.

The biggest highlight is the support for dynamic monitoring project configuration. You can adjust the monitoring metrics and redefine the time interval in a timely manner through the tool interface. It can also control the maximum, minimum, and hidden values, support manual pause and startup, and support timely viewing of logs.

Through this tool, we used to rely on guesses for coincidental programming. We often need code farmers to manually troubleshoot windows logs one by one. Now we can directly locate online problems through tool logs.

In addition, this applet can easily implement windows service monitoring and try to automatically fix the vulnerability to reduce manual intervention. In case of problems, it will send emails and/or text messages to relevant personnel according to the configuration. Of course, the logic of sending emails and text messages depends on you, such as the black/white list function and priority of sending. Do you want to automatically include the Server IP address and control the sending frequency.

1. Monitoring main panel

2. Monitoring item Configuration

MonitorItemInfousing System; namespace PowerServiceMonitor. model {/// <summary> /// project information to be monitored /// </summary> [Serializable] public sealed class MonitorItemInfo {// <summary> /// application Type // </summary> public string AppType {get; set ;}//< summary> /// Monitored project name /// </summary> public string SvcName {get; set ;} /// <summary> /// the value of the monitored project. For example, for windows Services, the process name web Service corresponds to a url. /// </summary> public string SvcValue {get; set ;}//< summary> /// whether to enable /// </summary> public bool IsEnabled {get; set ;} /// <summary> /// whether to send an email reminder /// </summary> public bool IsSendEmail {get; set ;} /// <summary> /// whether to send an SMS reminder /// </summary> public bool IsSendSMS {get; set ;}}}

If you have experienced multiple new applications going online at the same time every day, you must know how important these abstractions are.

In fact, if there are few applications and the application type is very simple, we can define a set of general monitoring policies, instead of having to have a configuration for each application.

However, changes are the eternal theme. different applications of different subsystems certainly have different monitoring business logic. Here, do not think it is overly-designed. Instead, I think at least two abstractions are missing, scheduled time policy and callback notification alarm interface.

The monitored application type can also be dynamically expanded. The monitoring interface has been defined in the applet.IServiceMonitor, Implement the logic according to your own business requirements, and then add the configuration.

IServiceMonitorusing System. collections. generic; namespace PowerServiceMonitor. contract {using PowerServiceMonitor. model; /// <summary> /// service monitoring interface /// </summary> public interface IServiceMonitor {// <summary> // start monitoring and processing /// </ summary> /// <param name = "monitorConfigPath"> address of the configuration file to be monitored </param> /// <returns> </returns> IList <MonitorResultInfo> Start (string monitorConfigPath );}}

In fact, the biggest two shortcomings of this tool so far are:

(1) The Monitoring scheduling cycle is not flexible

At present, the time interval definition of each Metric item is consistent. In fact, the timing policy of the metric item can be transformed into a scheduled task scheduling like quartz (cron expression, each metric item has its own unique time policy.

It is best to set the time interval for monitoring for a type of application or application separately.

(2) Hot swapping is not supported

Although this tool supports real-time changes to metric items and scheduled configurations, it does not support dynamic plug-in monitoring mode of metric items.

Ideally, a new monitoring project is developed to create a new dll to a folder. Of course, you may need to add a configuration file and then monitor the system dynamically without restarting it.

Although I have developed a plug-in file processing system before, I still gave up the plug-in design idea considering that the monitoring program should be easy to use.

 

Ii. Administrator Module

A simple administrator function module is defined to meet login and password modification requirements. The sample code is changed to role-based permission control (RBAC) for demonstration purposes) service (AdminUserService ).

Admin 

Password:123456

 

3. Log Management Module

As you know, the more advanced the monitoring system is, the more detailed the monitoring parameters are, the more dependent logs are.

This tool defines the unified log interface ILog. In this example, logs of the text, database, and NoSQL types are simulated.

However, it is far from enough. The actual monitoring platform also needs to share a large number of web Request Response logs and OS logs.

The log module can be dynamically managed through configuration.

Admin 

Password:123456

 

Demo address: PowerServiceMonitor

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.