Implementation of nagios grouping and plotting code [2]
Introduction,
In the previous section, we have implemented the group selection function in section 4.1. The group follows the default value of nagios. On this basis, the check box is added to implement the select of machines in the same group and the service category drop-down menu function. In this section, we need to complete the service plotting function for machines in the same group:
4.2 grouping and plotting
Taking the FastDFS machine that provides the distributed storage function as an example, to plot data, you must first select the machine group and service.
Figure 5 FastDFS distributed storage Machine Group
The check boxes in the first column of the machine group are all selected. The service diagram to be viewed is a traffic, that is, the traffic diagram of the two servers, what we need to do next is to click the "View" button. What actions will be triggered after the button is clicked? Come with me
Have you seen it? Click the View button to trigger the graphview. php file in the pnp4nagios directory. The implementation of plotting is actually completed in this PHP file. We still use nagios's rrdtool for plotting. The principle we stick to is to avoid repeating the wheel while meeting the requirements. After all, it takes time, the company will not give us so much time. Similarly, the rrdtool is used for plotting. What should I do with the specific plotting code? Reuse, of course. The key is how to reuse it?
Our plotting time range is tentatively set to 24 hours. This time period is now available in the default plot of pnp4nagios. You will not forget what nagios is so familiar? 6
Figure 6 pnp4nagios traffic Diagram
Suddenly, now that our predecessors have helped me achieve this, we just need to thank you and borrow it,
The plot link in the above Code is called by default by pnp4nagios. The for loop implements the arrangement of the plot by one or more rows and two columns. The final result is 7.
Figure 7 distributed storage fastDFS traffic Diagram
Now, the nagios host service group plotting has been completed. If you have any questions during the study, you can leave a message. In the future, we will improve the batch addition function of the nagios host, so stay tuned.