Get the App
SLTechnology News&Howtos  ›  Database  › 

Sqlserver stored procedures generate and send HTML monitoring reports

Shulou Source: shulou.com Published: 2022-06-01 18:31:39 10月02日 Update

Background

Scheduled tasks are processed in the early hours of each morning, a process that normally takes about 6-7 hours. Before 9 o'clock every day, you need to make sure that all the data is processed, which is a deadline. If it is not completed, it means that an accident occurred in the operation and maintenance on the same day, which affected the customer.

In the initial stage, if a database data processing fails, an alarm email will be sent. When there are more alarm emails, it is undoubtedly difficult to confirm which database processing failed from the email.

So by writing stored procedures, we can monitor all the DB data processing, and send a report in html format every day, so that we can know the data processing status quickly and accurately.

The final effect is a list of database servers in the figure below. A database server can create multiple databases, and each Profile is a DB.

Mode of realization

The result in the table above depends on a table ProcessDurationReport in the operation and maintenance database. The record in this table is that the program writes the processing time when dealing with each database. We calculate and summarize the information in the table through SQL, and finally assemble it into a html page and send it through Sqlserver's mail service.

The table structure is as follows

The relevant stored procedures are as follows

The related stored procedure links are written at the end.

The realization of this function means that the operation and maintenance operation is simplified, and the data processing status can be determined by viewing the report every day.

You can also continue to improve on this basis and turn it into a small website that displays the processing status in real time.

Other functions can also be added to display the historical data processing status.

Tags: Data processing database data processing process status mail storage situation service report function server table interior alarm monitoring difficulty picture above picture below things Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL Huawei Redmi Apple