Article title: use Perl for system service monitoring and alarms. Linux is a technology channel of the IT lab in China. Includes basic categories such as desktop applications, Linux system management, kernel research, embedded systems, and open source.
Generally, Web sites include many services and applications. we cannot know whether the system is running normally in real time, especially when the server goes down or the application goes down at night, this will affect business and user access. at this time, a set of system monitoring errors must be appropriate. At present, there are many software monitoring notifications and alarm services, and there are charges and free of charge, you can choose.
We will try to implement a service monitoring and alarm notification program by ourselves, so that we can use a very small price, and also make our services highly available and highly reliable.
[Monitoring principle]
Remote Service
For remote machines, we can have a monitoring server, or simply find a server that cannot be down as a monitoring server, so that we can monitor the services on other servers, remote monitoring is a much-needed method. Generally, remote monitoring monitors whether servers and ports are open. for example, Apache of our Web service usually opens port 80, then, we can access port 80 of the server to determine whether Apache is working normally. if the connection fails, the service will be stopped.
Local service
For the local machine, monitoring processes and log files are feasible. generally, services that work frequently for a long time, such as Apache, will record the access information to the access log file after each access, if the file has not been updated for a long time, you can suspect that the service has stopped (of course, it is not ruled out that no one has accessed the file during this period of time ). In addition, the local machine can easily view the process status. for MySQL and other servers, the Daemon process is always open for a long time. if you find that the MySQL daemon process is not in the current system, you can also confirm that the MySQL service has stopped.
Alarm Notification
When the service is stopped, the system maintenance personnel must be notified. In general, the system is notified by email or text message, which is the best, but frequent text messages also make the maintenance personnel very depressed, this is called the Message Bomb, so the Mail may be a simple and practical method. configuring Outlook/Foxmail regular reception and notification methods locally is also quick, but after going home at night, generally, no email can be received. Therefore, the reasonable method is to send a notification via email during the day, and send a notification via SMS at night or on weekends.
[1] [2] Next page