Deploying the Lightweight os_monitor Tool for Real‑Time OS Metrics and Alerts
This guide explains how to install, configure, and use the open‑source os_monitor tool to collect CPU, memory, and disk metrics, store them in MySQL, and trigger email or WeChat alerts through a web dashboard with simple SQL‑based setup.
Introduction : os_monitor is a lightweight OS visualization monitoring tool that collects CPU idle, CPU load, memory usage, and disk space usage metrics.
Workflow : The Agent reads system‑threshold values from the Server's os_status_info table, gathers client host resource data, writes it to the database, and triggers alerts. The Server checks SSH availability of agents, displays the dashboard, and supports WeChat and email notifications.
Installation and Configuration Steps :
Download the tool from https://github.com/hcymysql/os_monitor/ and unzip it to /var/www/html/.
Set executable permissions for the alert scripts:
# chmod 755 ./mail/sendEmail
# chmod 755 ./weixin/wechat.pyThese scripts are third‑party utilities used for email and WeChat alerts.
Import the database schema into a MySQL database named os_monitor_db:
# mysql -uroot -p123456 < os_monitor_schema.sqlInsert monitored host information into os_status_info. Example:
INSERT INTO os_status_info(host,ssh_port,tag,monitor,send_mail,send_mail_to_list,send_weixin,send_weixin_to_list,threshold_alarm_cpu_idle,threshold_alarm_cpu_load,threshold_alarm_memory_usage,threshold_alarm_disk_free)
VALUES ('127.0.0.1',22,'test',1,1,'[email protected],[email protected]',1,'hechunyang',60,6,80,85);The table fields are explained later.
Edit conn.php with the correct MySQL connection parameters, e.g.:
$conn = mysqli_connect("127.0.0.1","admin","your_password","os_monitor_db","3306") or die("Database connection error" . PHP_EOL . mysqli_connect_error());Modify the email alert script mail.php to use your sender address and credentials:
system("./mail/sendEmail -f [email protected] -t '{$this->send_mail_to_list}' -s smtp.domain.com:25 -u '{$this->alarm_subject}' -o message-charset=utf8 -o message-content-type=html -m 'Alert info: {$this->alarm_info}' -xu [email protected] -xp 'your_password' -o tls=no");Configure WeChat alerts by editing weixin/wechat.py according to the tutorial at
https://github.com/X-Mars/Zabbix-Alert-WeChat/blob/master/README.md.
Add crontab entries to run the server checks every minute:
*/1 * * * * cd /var/www/html/os_monitor/; /usr/bin/php check_os_server.php > /dev/null 2>&1
*/1 * * * * cd /var/www/html/os_monitor/; /usr/bin/php check_os_agent.php > /dev/null 2>&1Optionally change the dashboard auto‑refresh interval (default 600 seconds) by editing os_status_monitor.php and modifying the meta refresh tag.
Access the dashboard at http://yourIP/os_monitor/os_status_monitor.php.
os_status_info Table Fields : host: IP address of the monitored host. ssh_port: SSH port of the host. tag: Human‑readable name of the host. monitor: 0 = disable monitoring, 1 = enable. send_mail: 0 = disable email alerts, 1 = enable. send_mail_to_list: Comma‑separated list of email recipients. send_weixin: 0 = disable WeChat alerts, 1 = enable. send_weixin_to_list: WeChat identifier for alerts. threshold_alarm_cpu_idle: CPU idle usage threshold. threshold_alarm_cpu_load: CPU load usage threshold. threshold_alarm_memory_usage: Memory usage threshold. threshold_alarm_disk_free: Disk free‑space threshold.
The tool also includes an Agent component ( check_os_agent.php) that must be deployed on each monitored host with matching conn.php settings and scheduled via crontab, e.g.:
*/1 * * * * cd /usr/local/os_monitor_agent/; /usr/bin/php check_os_agent.php > /dev/null 2>&1Download links: https://github.com/hcymysql/os_monitor/ (GitHub repository) and additional documentation at http://dbaplus.cn/list-142-1.html.
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
dbaplus Community
Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
