Implementation of nagios grouping and plotting code [1]

Source: Internet
Author: User

Implementation of nagios grouping and plotting code [1]

I. background

In view of the Service grouping and Image Presentation functions of zabbix and cacti, the company's leaders aim to maximize business stability and propose the "real-time display of monitoring systems by service grouping" function to the O & M department, the O & M Department belongs to the technical support department of the company and can only be Yes to meet reasonable requirements.

Ii. Requirements

Monitoring System displays data in real time by Service Group

Iii. Software Environment


[Root @ nagios ~] # Cat/etc/redhat-release

CentOS release 6.7 (Final)

[Root @ nagios ~] # Uname-r

2.6.32-573. el6.x86 _ 64

Shows the software versions of lamp environment and nagios basic environment:


Figure 1 Software Version Used in the nagios Basic Environment

Iv. Requirement Analysis and Implementation

4.1 grouping

The monitoring system we use now is nagios. As we all know, nagios uses the hosts and servers grouping functions by default, for example:


Figure 2 default nagios group Function


The default version of the group menu is slightly different from that of nagios4.1.1. This interface is a modified style. If you are interested, try it out.

Host group 3.


Figure 3 nagios host Group

As shown in figure 3, the group we see is a better choice than the one previously modified (choice). How to add this column is explained in detail next.

The nagios Host group page and service group page are composed of status. cgi page control, so to add a selection column, you must modify the nagios source code package and find the status. c file, modify and re-compile, and overwrite the existing status. cgi.

4.1.1 modify the ngios4.1.1 source code package

[Root @ nagios nagios-4.1.1] # ls cgi/status. c

Cgi/status. c

[Root @ nagios nagios-4.1.1] # vimcgi/status. c + 3598 # modify 3598 behavior as follows

/* Choice add by xuekun 2016-12-23 */

Printf ("choice");/* This column is newly added, check box column */

Printf ("HostStatus ");

Printf ("ServicesActions \ n ");

[Root@nagiosnagios-4.1.1] # vim cgi/status. c + 3628 # check box select all code, service drop-down menu code


/* Choice all Begin by xuekun 2016-12-23 */

The code above is mainly used to solve the problem of adding check box columns and service drop-down menus. Next, we need to use jquery to select all check boxes, the implementation of the Code follows the web design rules in the document_footer function of Line 3 and puts js at the end of the page to improve the page loading speed.

Void document_footer (void ){

If (embedded = TRUE)

Return;

/* Include user SSI footer */

Include_ssi_files (STATUS_CGI, SSI_FOOTER );

Printf ("\ n ");


Printf ("function check_all (obj, flag) \ n ");

Printf ("{var is_checked = obj. checked; \ n ");

Printf ("var checkboxs = $ (\" input [flag = '\ "+ flag + \"'] \ "); \ n ");

Printf ("console. log (is_checked); \ n ");

Printf ("checkboxs. each (function () {\ n ");

Printf ("var cur_box = $ (this); \ n ");

Printf ("cur_box.prop (\" checked \ ", is_checked); \ n ");

Printf ("}) ;}\ n ");

Printf ("\ n ");

Printf ("\ n ");

Return;

}

After the above Code is modified, the next step is to re-compile nagios. The command is as follows:

[Root @ nagios nagios-4.1.1] # make all # execute the make all command to re-compile nagios

After nagios compilation is complete, we need to compile the status. cgi replaces the status of the/usr/local/nagios/sbin/directory. stop nagios before replacing it with cgi. The specific operation is as follows:

[Root @ nagios nagios-4.1.1] #/etc/init. d/nagiosstop # Stop nagios

[Root@nagiosnagios-4.1.1] # cp/usr/local/nagios/sbin/status. cgi/home/xuekun/status. cgi_bak # back up the original file

[Root @ nagios nagios-4.1.1] #/bin/cpcgi/status. cgi/usr/local/nagios/sbin/status. cgi # replace the original status. cgi

After executing the preceding command, F5 refresh the nagios access page and click "hostgroup" to connect to the page to see if any new discoveries have occurred !!!

Good luck!



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.