Orabbix sends graphical reports in combination with Python

Source: Internet
Author: User

Orabbix sends graphical reports in combination with Python

In the database O & M work, if there is a feeling of strategizing, one of the ways is to read reports, such as slowly turning on the computer over coffee, dozens of machines, the load details of hundreds of machines are all in the eyes. If an exception or obvious jitter occurs somewhere, the report can be clearly displayed.

At present, this situation is still very difficult to implement, but we can create it. The monitoring methods of zabbix + orabbix have also been analyzed in previous blog posts, and there are still many highlights, the monitoring and customization functions are indeed very powerful, and the gc function itself is very powerful, but the expansion is relatively difficult.

First, let's show an overview chart. This is our goal. For example, we have dozens of DB servers. Before starting work, we can see that this report will definitely make your work more targeted. Which of the following should be important and which may be potential problems, which problems need to be solved urgently.

For example, if we have received the following email, which describes the waiting events of four DBS in the past 24 hours, is it relatively clear, of course, we can also extend other metrics.

It is not easy to achieve this effect.
I have also obtained various materials from various parties, and I have finally seen a glimmer of light in my failed experiences.
First, we need to get this image through zabbix. The general principle is as follows:
To get a basic graph, in addition to specifying the length and width, the main attributes are graphid and screenid.

Orabbix will pass the data obtained through Jdbc to the mysql table in zabbix. When you need to obtain the corresponding data information, you still need to rely on screenid and graphid in a graphical manner, data changes in the corresponding table.

After understanding the basic principles, we need to send emails as attachments to meet the requirement of embedding images in emails.
There are several things that must be done according to this idea,
1. Understand the association between screenid and graphid and mysql tables.
2. Use screenid and graphid to obtain the corresponding report image.
3. store images in a temporary directory
4. Send the image as an attachment.

Step 5 also gets some basic information from the network. If you want more details, it seems that resources are limited. From my experiment, there are still some differences between the table association relationship and the network. At last, I compared the data of several associated tables repeatedly. Finally, I found the rule. Next I will detail the details of the table association relationship.
In step 2, Use screenid and graphid to obtain the corresponding report image. This step is based on Step 2. We can perform a basic test to get the url format of the image, and then put some non-mandatory fields, for example, you can specify a default value for the length and width.
In step 5, you need to download images and store them in a temporary directory. This process still needs to be completed by using scripts. In this regard, the powerful web functions of python come in handy. You can download images based on URLs and put the images in the default path of the web server, such as/var/www/zabbix/reports.
Step 1 is to use the email sending function to put the image into the attachment. This part is still done using python. The functions in step 3 and Step 4 are all set to their respective function points.
It seems that all functions are closely related, but we can split them up. For example, we can directly implement step 1 to simulate the scenario where we have received the image.
Obtain the graphid and screenid parts of the image. We can view the attributes in the existing monitoring chart to obtain a url sample, and then modify and customize it according to the format.
If the implementation is almost done, it is not too late to go back to the first step to parse the data dictionary. The ability to parse data dictionaries is a bit confusing than even associations. There are no detailed documents such as datamodel at all. Fortunately, the table structure of open-source projects is still very clear, and the meaning of fields and table names can be basically seen, it is clear, and I am lucky to parse the association.

For detailed steps, read the highlights on the next page:

You may also like the following article about Python:

Python: Search for files that meet the conditions in a specified directory

Python2.7.7 source code analysis

Directly run Python code without the need for the operating system

Install Python3.4 on CentOS source code

Python core programming version 2. (Wesley J. Chun). [Chinese version of hd pdf]

Python development technology details. (Zhou Wei, Zong Jie). [hd PDF scan version + book guide video + code]

Obtain Linux information using a Python script

Build a desktop algorithm transaction research environment using Python in Ubuntu

A Brief History of Python Development

  • 1
  • 2
  • Next Page

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.