运维自动化之使用PHP+MYSQL+SHELL打造私有监控系统(二)

本文涉及的产品
RDS AI 助手,专业版
RDS MySQL DuckDB 分析主实例,集群系列 4核8GB
RDS MySQL DuckDB 分析主实例,基础系列 4核8GB
简介:
现在开始介绍php+mysql+shell监控系统
1 、目的
       此监控系统主要是通过 php+mysql+shell的方式,通过shell脚本对各个机器的其各个服务进行监控,达到及时的了解其各个应用服务的状态(如果宕掉与启动),在检测应用服务宕掉时,记录在日志里与mysql数据库服务器里,同时进行服务宕掉的邮件提示,并自动启动宕掉的应用服务;在检测应该服务启动时,同时进行服务启动的邮件提示,所有的监控内容都能在php制作的web里进行浏览,同时能根据mysql里的数据,把资源监控数据视图化,在浏览数据的时候,更方便。
2 、实现的机制
       监控方式主要是通过 shell脚本的实现,针对应用服务运行的端口进行监控,如果其端口开启,则证明此服务运行,反之则此服务没有运行。
3 、监控的应用服务
       监控的应用服务有:
A、应用服务器的服务监控
web: http、yu_tomcat、tomcat 共3个
交换:  pas、ppas、mas、mmas、cas共5个
引擎: memcache、datastorageservice、http、dbstatserver共4个
B:应用服务器的资源监控
硬盘使用率、 cpu使用率、硬件启动信息错误、i/o使用率、15分钟内的负载、内存使用率(包括内存与swap)、日志错误信息、当前用户登录数
4 、已经监控的省份
       目前天津、广西、贵州、海南、河北、河南、湖北、湖南、宁夏、陕西、青海、西藏、新疆、包头、甘肃、江西都已经部署完成,经过 3个月的测试,没有发现问题。
5 shell监控脚本内容与解释
1)web服务器(以甘肃web为例)
 
   
  1. #!/bin/bash  
  2. #ip  
  3. web_ip=$(/sbin/ifconfig eth0|grep "inet addr"|cut -d : -f 2|awk '{print $1}')  
  4. ##eth0网卡的ip  
  5. #name  
  6. web_name=$(hostname)  
  7. ##web主机名  
  8. monitor_name=web 
  9. ##监控的服务器是什么类型  
  10. here='gansu' 
  11. ##监控的省份  
  12. #mysql info  
  13. mysql_ip='1.1.1.1' 
  14. ##数据库的ip  
  15. mysql_username='root' 
  16. ##数据库的用户  
  17. mysql_passwd='****' 
  18. #数据库的密码  
  19. mysql_database='monitor' 
  20. ##选择的数据库  
  21. memory_table=''$here'_memory'  
  22. load_table=''$here'_load'  
  23. io_table=''$here'_io'  
  24. hardware_table=''$here'_hardware'  
  25. message_table=''$here'_message'  
  26. user_table=''$here'_user'  
  27. disk_table=''$here'_disk'  
  28. cpu_table=''$here'_cpu'  
  29. service_table=''$here'_service'  
  30. ##想数据库里写入的表  
  31. #date and log  
  32. day="$(date +%Y%m%d)" 
  33. worklog='/usr/local/monitor/logs/all_work_log' 
  34. downlog='/usr/local/monitor/logs/all_down_log' 
  35. ##日志与实际  
  36. now="$(date +%Y-%m-%d-%T)" 
  37. #web service  
  38. tomcat="$(netstat -antl|grep 8080|wc -l)" 
  39. web_http="$(ps -ef|grep httpd|grep -v grep|wc -l)" 
  40. yz_tomcat="$(netstat -antl|grep 8081|wc -l)" 
  41. ##通过端口与服务在后头的运行情况监控其运行状态  
  42. #cpu service  
  43. alert_cpu='80' 
  44. ##cpu的报警阀值  
  45. web_cpu_idle="$(top -b -n 1 | grep Cpu | awk '{print $5}' | cut -f 1 -d .)" 
  46. web_cpu="$(echo 100 - $web_cpu_idle|/usr/bin/bc)" 
  47. ##监控cpu的使用率  
  48. #memory service  
  49. alert_mem='100' 
  50. ##内存的报警阀值  
  51. web_mem="$(/usr/bin/free -m|grep Mem|awk '{print $4}')" 
  52. web_swap="$(/usr/bin/free -m|grep Swap|awk '{print $3}')" 
  53. ##memory与swap的使用率  
  54. alert_swap='0' 
  55. ##swap的报警阀值  
  56. #memory log  
  57. memory_worklog='/usr/local/monitor/logs/mem_work_log' 
  58. memory_downlog='/usr/local/monitor/logs/mem_down_log' 
  59. #load service  
  60. cpu_count="$(grep -c 'model name' /proc/cpuinfo)" 
  61. alert_load="$(echo $cpu_count/2|/usr/bin/bc)" 
  62. web_load="$(uptime|awk '{print $NF}'|cut -f 1 -d .)" 
  63. web_load_15="$(uptime|awk '{print $NF}')" 
  64. #监控负载的使用率  
  65. #load log  
  66. load_worklog='/usr/local/monitor/logs/load_work_log' 
  67. load_downlog='/usr/local/monitor/logs/load_down_log' 
  68. #io service  
  69. alert_io='80' 
  70. web_io_idle_back="$(/usr/bin/iostat|awk 'NR==4{print $NF}'|cut -f 1 -d .)" 
  71. web_io_idle="$(echo 100 - $web_io_idle_back|/usr/bin/bc)" 
  72. ##io的使用值  
  73. #io log  
  74. io_worklog='/usr/local/monitor/logs/io_work_log' 
  75. io_downlog='/usr/local/monitor/logs/io_down_log' 
  76. #hardware service  
  77. web_hardware_error="$(dmesg|grep -i error|wc -l)" 
  78. web_info_error="$(dmesg|grep -i error)" 
  79. ##开机启动的错误信息  
  80. #hardware error log  
  81. hard_worklog='/usr/local/monitor/logs/hard_work_log' 
  82. hard_downlog='/usr/local/monitor/logs/hard_down_log' 
  83. #message service  
  84. web_message_error_count="$(awk '/"$(date +%Y%m%d)"/' /var/log/messages|grep -i error|wc -l)"  
  85. web_message_error="$(awk '/"$(date +%Y%m%d)"/' /var/log/messages|grep -i error)"  
  86. ##日志的错误信息  
  87. #message error log  
  88. message_worklog='/usr/local/monitor/logs/message_work_log' 
  89. message_downlog='/usr/local/monitor/logs/message_down_log' 
  90. #user service  
  91. web_user_count="$(/usr/bin/who|wc -l)" 
  92. web_user_info="$(/usr/bin/who)" 
  93. ##当前登录的用户值  
  94. #user  log  
  95. user_worklog='/usr/local/monitor/logs/user_work_log' 
  96. user_downlog='/usr/local/monitor/logs/user_down_log' 
  97. #disk service  
  98. alert_disk='80' 
  99. web_disk="$(/bin/df -H|sort -k5nr|grep -vE 'Filesystem|tmpfs|cdrom'|awk '{print $5 " " $1}')"  
  100. web_disk_use=$(echo $web_disk|awk '{print $1}'|cut -d '%' -f1)  
  101. web_disk_partition=$(echo $web_disk|awk '{print $2}')  
  102. #硬盘使用率  
  103. #disk log  
  104. disk_worklog='/usr/local/monitor/logs/disk_work_log' 
  105. disk_downlog='/usr/local/monitor/logs/disk_down_log' 
  106. #cpu log  
  107. cpu_worklog='/usr/local/monitor/logs/cpu_work_log' 
  108. cpu_downlog='/usr/local/monitor/logs/cpu_down_log' 
  109. #notification mail  
  110. email='denglei@ctfo.com' 
  111. ##报警的接收人  
  112. #monitor  
  113. if [ ! -d "$loghere" ];then  
  114.     mkdir $loghere  
  115. fi  
  116. #check web service  
  117. if [ $web_http -ge 1 ];then  
  118.     echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: http Monitor_Server: $monitor_name is working" >> $worklog-$day  
  119.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','web_http','working',now())";  
  120. else  
  121.     /etc/init.d/httpd start  
  122.     echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: http Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service:  http  was a problem" $email  
  123.     echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: http Monitor_Server: $montior_name is down" >> $downlog-$day  
  124.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','web_http','downing',now())";  
  125. fi  
  126.  
  127. if [ $tomcat -ge 1 ];then  
  128.     echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: tomcat Monitor_Server: $monitor_name is working" >> $worklog-$day  
  129.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','tomcat','working',now())";  
  130. else  
  131.     /usr/local/monitor/shell/web_tomcat.sh  
  132.   echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: tomcat Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service:  tomcat  was a problem" $email   
  133.   echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: tomcat Monitor_Server: $montior_name is down" >> $downlog-$day  
  134.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','tomcat','downing',now())";  
  135. fi  
  136. if [ $yz_tomcat -ge 1 ];then  
  137.     echo "$now ShengFen: $here Server: $web_name Service: Ip: $web_ip yz_tomcat Monitor_Server: $monitor_name is working" >> $worklog-$day  
  138.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','yz_tomcat','working',now())";  
  139. else  
  140.     /usr/local/monitor/shell/web_yz_tomcat.sh  
  141.   echo "$now ShengFen: $here Server: $web_name Service: Ip: $web_ip yz_tomcat Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service:  yz_tomcat  was a problem" $email   
  142.   echo "$now ShengFen: $here Server: $web_name Service: Ip: $web_ip yz_tomcat Monitor_Server: $montior_name is down" >> $downlog-$day  
  143.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$web_name','$web_ip','$monitor_name','yz_tomcat','downing',now())";  
  144. fi  
  145. #check cpu_idle  
  146. if [ $web_cpu -ge $alert_cpu ];then  
  147.     echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $web_cpu"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: cpu_use  was Exceed Threshold value: 80%" $email  
  148.     echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $web_cpu" >> $cpu_downlog-$day  
  149.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $cpu_table values ('','$here','$web_name','$web_ip','$monitor_name','cpu_use','$alert_cpu','$web_cpu','abnormal',now())";  
  150. else  
  151.     echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $web_cpu" >> $cpu_worklog-$day  
  152.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $cpu_table values ('','$here','$web_name','$web_ip','$monitor_name','cpu_use','$alert_cpu','$web_cpu','normal',now())";  
  153. fi  
  154. #check memory  
  155. if [ $web_mem -le $alert_mem ];then  
  156.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: memory Monitor_Server: $monitor_name Free_mem: $web_mem"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: memory  was Exceed Threshold value" $email  
  157.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: memory Monitor_Server: $monitor_name Free_mem: $web_mem" >> $memory_downlog-$day  
  158.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$web_name','$web_ip','$monitor_name','memory','$alert_mem','$web_mem','abnormal',now())";  
  159. else  
  160.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: memory Monitor_Server: $monitor_name Free_mem: $web_mem" >> $memory_worklog-$day  
  161.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$web_name','$web_ip','$monitor_name','memory','$alert_mem','$web_mem','normal',now())";  
  162. fi  
  163. #check swap  
  164. if [ $web_swap -gt $alert_swap ];then  
  165.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: swap Monitor_Server: $monitor_name Swap_web: $web_swap"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: swap Ip: $web_ip was Exceed Threshold value" $email  
  166.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: swap Monitor_Server: $monitor_name Swap_web: $web_swap" >> $memory_downlog-$day  
  167.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database  -e "insert into $memory_table values ('','$here','$web_name','$web_ip','$monitor_name','swap','$alert_swap','$web_swap','abnormal',now())";  
  168. else  
  169.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: swap Monitor_Server: $monitor_name Swap_web: $web_swap" >> $memory_worklog-$day  
  170.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$web_name','$web_ip','$monitor_name','swap','$alert_swap','$web_swap','normal',now())";  
  171. fi  
  172. #check load_15  
  173. if [ $web_load -ge $alert_load ];then  
  174.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: load_15 Monitor_Server: $monitor_name Load_use: $web_load_15"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: load_15 Ip: $web_ip was Exceed Threshold value" $email  
  175.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: load_15 Monitor_Server: $monitor_name Load_use: $web_load_15" >> $load_downlog-$day  
  176.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $load_table values ('','$here','$web_name','$web_ip','$monitor_name','load_15','$alert_load','$web_load_15','abnormal',now())";  
  177. else  
  178.         echo "$now ShengFen: $here Server: $server Ip: $ip Service: load Monitor_Server: $monitor_name Load_use: $web_load_15" >> $load_worklog-$day  
  179.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $load_table values ('','$here','$web_name','$web_ip','$monitor_name','load_15','$alert_load','$web_load_15','normal',now())";  
  180. fi  
  181. #check io_idle  
  182. if [ $web_io_idle -ge $alert_io ];then  
  183.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $web_io_idle"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: io_use  was Exceed Threshold value: 80%" $email  
  184.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $web_io_idle" >> $io_downlog-$day  
  185.         /usr/bin/mysql  -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $io_table values ('','$here','$web_name','$web_ip','$monitor_name','io_use','$alert_io','$web_io_idle','abnormal',now())";  
  186. else  
  187.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $web_io_idle" >> $io_worklog-$day  
  188.         /usr/bin/mysql  -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $io_table values ('','$here','$web_name','$web_ip','$monitor_name','io_use','$alert_io','$web_io_idle','normal',now())";  
  189. fi  
  190. #check hareware error info  
  191. if [ $web_hardware_error -gt 0 ];then  
  192.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: hardware_error Monitor_Server: $monitor_name Error: $web_info_error"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: hardware_error  were some hardware imformation error" $email  
  193.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: hardware_error Monitor_Server: $monitor_name Error: $web_info_error" >> $hard_downlog-$day  
  194.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $hardware_table values ('','$here','$web_name','$web_ip','$monitor_name','hardware_error','0','$web_hardware_error','abnormal',now())";  
  195. else  
  196.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: hardware_error Monitor_Server: $monitor_name Error: Nothing" >> $hard_worklog-$day  
  197.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $hardware_table values ('','$here','$web_name','$web_ip','$monitor_name','hardware_error','0','$web_hardware_error','normal',now())";  
  198. fi  
  199. #check message error  
  200. if [ $web_message_error_count -ge 1 ];then  
  201.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: message_error Monitor_Server: $monitor_name Message_error: $web_message_error"|/bin/mail -s "Notification ShengFen: $here Server: $web_name Service: message_error  were some message imformation error" $email  
  202.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: message_error Monitor_Server: $monitor_name Message_error: $web_message_error" >> $message_downlog-$day  
  203.         /usr/bin/mysql-h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $message_table values ('','$here','$web_name','$web_ip','$monitor_name','message_error','1','$web_message_error_count','abnormal',now())";  
  204. else  
  205.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: message_error Monitor_Server: $monitor_name Message_error: Nothing" >> $message_worklog-$day  
  206.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database  -e "insert into $message_table values ('','$here','$web_name','$web_ip','$monitor_name','message_error','1','$web_message_error_count','normal',now())";  
  207. fi  
  208. #check user  
  209. if [ $web_user_count -ge 3 ];then  
  210.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: user Monitor_Server: $monitor_name User: $web_user_info"|/bin/mail -s "Notification ShengFen: $here Server: $web_name  Service: user  was Exceed Threshold value: 3" $email  
  211.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: user Monitor_Server: $monitor_name User: $web_user_info" >> $user_downlog-$day  
  212.         /usr/bin/mysql  -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $user_table values ('','$here','$web_name','$web_ip','$monitor_name','user','3','$web_user_count','abnormal',now())";  
  213. else  
  214.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: user Monitor_Server: $monitor_name User: normal" >> $user_worklog-$day  
  215.         /usr/bin/mysql  -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $user_table values ('','$here','$web_name','$web_ip','$monitor_name','user','3','$web_user_count','normal',now())";  
  216. fi  
  217. #check disk  
  218. if [ $web_disk_use -ge $alert_disk ];then  
  219.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $web_disk_partition ($web_disk_use%)"|/bin/mail -s "Warning!!! $here Server: $web_name Service: disk_use  was Exceed Threshold value : $alert_disk% " $email  
  220.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $web_disk_partion ($web_disk_use%)" >> $disk_downlog-$day  
  221.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database  -e "insert into $disk_table values ('','$here','$web_name','$web_ip','$monitor_name','disk_use','$alert_disk','$web_disk_partition','$web_disk_use','abnormal',now())";  
  222. else  
  223.         echo "$now ShengFen: $here Server: $web_name Ip: $web_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $web_disk_partition ($web_disk_use%)" >> $disk_worklog-$day  
  224.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database  -e "insert into $disk_table values ('','$here','$web_name','$web_ip','$monitor_name','disk_use','$alert_disk','$web_disk_partition','$web_disk_use','normal',now())";  
  225. fi  
2)交换服务器(以甘肃交换为例,解释内容参照甘肃web)
 
  1. #!/bin/bash  
  2. #ip  
  3. jh_ip=$(/sbin/ifconfig eth0|grep "inet addr"|cut -d : -f 2|awk '{print $1}')  
  4. #name  
  5. jh_name=$(hostname)  
  6. monitor_name=jiaohuan 
  7. here='gansu' 
  8. #mysql info  
  9. mysql_ip='1.1.1.1' 
  10. mysql_username='root' 
  11. mysql_passwd='****' 
  12. mysql_database='monitor' 
  13. memory_table=''$here'_memory'  
  14. load_table=''$here'_load'  
  15. io_table=''$here'_io'  
  16. hardware_table=''$here'_hardware'  
  17. message_table=''$here'_message'  
  18. user_table=''$here'_user'  
  19. disk_table=''$here'_disk'  
  20. cpu_table=''$here'_cpu'  
  21. service_table=''$here'_service'  
  22. #date and log  
  23. day="$(date +%Y%m%d)" 
  24. worklog='/usr/local/monitor/logs/all_work_log' 
  25. downlog='/usr/local/monitor/logs/all_down_log' 
  26. now="$(date +%Y-%m-%d-%T)" 
  27. loghere='/usr/local/monitor/logs' 
  28. #jiaohuan service  
  29. pas="$(ps -ef|grep pas|grep -v grep|grep -v ppas|wc -l)" 
  30. ppas="$(ps -ef|grep ppas|grep -v grep|wc -l)" 
  31. cas="$(ps -ef|grep cas|grep -v grep|wc -l)" 
  32. mas="$(ps -ef|grep mas|grep -v grep|grep -v mmas|wc -l)" 
  33. mmas="$(ps -ef|grep mmas|grep -v grep|wc -l)" 
  34. #cpu service  
  35. alert_cpu='80' 
  36. jh_cpu_idle="$(top -b -n 1 | grep Cpu | awk '{print $5}' | cut -f 1 -d .)" 
  37. jh_cpu="$(echo 100 - $jh_cpu_idle|/usr/bin/bc)" 
  38. #memory service  
  39. alert_mem='100' 
  40. jh_mem="$(/usr/bin/free -m|grep Mem|awk '{print $4}')" 
  41. jh_swap="$(/usr/bin/free -m|grep Swap|awk '{print $3}')" 
  42. alert_swap='0' 
  43. #memory log  
  44. memory_worklog='/usr/local/monitor/logs/mem_work_log' 
  45. memory_downlog='/usr/local/monitor/logs/mem_down_log' 
  46. #load service  
  47. cpu_count="$(grep -c 'model name' /proc/cpuinfo)" 
  48. alert_load="$(echo $cpu_count/2|/usr/bin/bc)" 
  49. jh_load="$(uptime|awk '{print $NF}'|cut -f 1 -d .)" 
  50. jh_load_15="$(uptime|awk '{print $NF}')" 
  51. #load log  
  52. load_worklog='/usr/local/monitor/logs/load_work_log' 
  53. load_downlog='/usr/local/monitor/logs/load_down_log' 
  54. #io service  
  55. alert_io='80' 
  56. jh_io_idle_back="$(/usr/bin/iostat|awk 'NR==4{print $NF}'|cut -f 1 -d .)" 
  57. jh_io_idle="$(echo 100 - $jh_io_idle_back|/usr/bin/bc)" 
  58. #io log  
  59. io_worklog='/usr/local/monitor/logs/io_work_log' 
  60. io_downlog='/usr/local/monitor/logs/io_down_log' 
  61. #hardware service  
  62. jh_hardware_error="$(dmesg|grep -i error|wc -l)" 
  63. jh_info_error="$(dmesg|grep -i error)" 
  64. #hardware error log  
  65. hard_worklog='/usr/local/monitor/logs/hard_work_log' 
  66. hard_downlog='/usr/local/monitor/logs/hard_down_log' 
  67. #message service  
  68. jh_message_error_count="$(awk '/"$(date +%Y%m%d)"/' /var/log/messages|grep -i error|wc -l)"  
  69. jh_message_error="$(awk '/"$(date +%Y%m%d)"/' /var/log/messages|grep -i error)"  
  70. #message error log  
  71. message_worklog='/usr/local/monitor/logs/message_work_log' 
  72. message_downlog='/usr/local/monitor/logs/message_down_log' 
  73. #user service  
  74. jh_user_count="$(/usr/bin/who|wc -l)" 
  75. jh_user_info="$(/usr/bin/who)" 
  76. #user  log  
  77. user_worklog='/usr/local/monitor/logs/user_work_log' 
  78. user_downlog='/usr/local/monitor/logs/user_down_log' 
  79. #disk service  
  80. alert_disk='80' 
  81. jh_disk="$(/bin/df -H|sort -k5nr|grep -vE 'Filesystem|tmpfs|cdrom'|awk '{print $5 " " $1}')"  
  82. jh_disk_use=$(echo $jh_disk|awk '{print $1}'|cut -d '%' -f1)  
  83. jh_disk_partition=$(echo $jh_disk|awk '{print $2}')  
  84. #disk log  
  85. disk_worklog='/usr/local/monitor/logs/disk_work_log' 
  86. disk_downlog='/usr/local/monitor/logs/disk_down_log' 
  87. #cpu log  
  88. cpu_worklog='/usr/local/monitor/logs/cpu_work_log' 
  89. cpu_downlog='/usr/local/monitor/logs/cpu_down_log' 
  90. #notification mail  
  91. email='denglei@ctfo.com' 
  92. #monitor  
  93. if [ ! -d "$loghere" ];then  
  94.     mkdir $loghere  
  95. fi  
  96. #monitor  
  97. #jiaohuan check  
  98. if [ $pas -ge 1 ];then  
  99.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: pas Monitor_Server: $monitor_name is working" >> $worklog-$day  
  100.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','pas','working',now())";  
  101. else  
  102.                 /usr/local/lbs/bin4.0.7.7/pas -daemon  
  103.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: pas Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service:  pas  was a problem" $email  
  104.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: pas Monitor_Server: $montior_name is down" >> $downlog-$day  
  105.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','pas','downing',now())";  
  106. fi  
  107. if [ $ppas -ge 1 ];then  
  108.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: ppas Monitor_Server: $monitor_name is working" >> $worklog-$day  
  109.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','ppas','working',now())";  
  110. else  
  111.                 /usr/local/lbs/bin4.0.7.7/ppas -daemon  
  112.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: ppas Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service:  ppas  was a problem" $email  
  113.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: ppas Monitor_Server: $montior_name is down" >> $downlog-$day  
  114.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','ppas','downing',now())";  
  115. fi  
  116. if [ $mas -ge 1 ];then  
  117.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: mas Monitor_Server: $monitor_name is working" >> $worklog-$day  
  118.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','mas','working',now())";  
  119. else  
  120.                 /usr/local/lbs/bin4.0.7.7/mas -daemon  
  121.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: mas Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service:  mas  was a problem" $email  
  122.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: mas Monitor_Server: $montior_name is down" >> $downlog-$day  
  123.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','mas','downing',now())";  
  124. fi  
  125. if [ $mmas -ge 1 ];then  
  126.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: mmas Monitor_Server: $monitor_name is working" >> $worklog-$day  
  127.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','mmas','working',now())";  
  128. else  
  129.                 /usr/local/lbs/bin4.0.7.7/mmas -daemon  
  130.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: mmas Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service:  mmas  was a problem" $email  
  131.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: mmas Monitor_Server: $montior_name is down" >> $downlog-$day  
  132.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','mmas','downing',now())";  
  133. fi  
  134. if [ $cas -ge 1 ];then  
  135.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: cas Monitor_Server: $monitor_name is working" >> $worklog-$day  
  136.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','cas','working',now())";  
  137. else  
  138.                 /usr/local/lbs/bin4.0.7.7/cas -daemon  
  139.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: cas Monitor_Server: $monitor_name is down"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service:  cas  was a problem" $email  
  140.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: cas Monitor_Server: $montior_name is down" >> $downlog-$day  
  141.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $service_table values ('','$here','$jh_name','$jh_ip','$monitor_name','cas','downing',now())";  
  142. fi  
  143. #check cpu_idle  
  144. if [ $jh_cpu -ge $alert_cpu ];then  
  145.     echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $jh_cpu"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service: cpu_use  was Exceed Threshold value: 80%" $email  
  146.     echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $jh_cpu" >> $cpu_downlog-$day  
  147.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $cpu_table values ('','$here','$jh_name','$jh_ip','$monitor_name','cpu_use','$alert_cpu','$jh_cpu','abnormal',now())";  
  148. else  
  149.     echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: cpu_idle Monitor_Server: $monitor_name Cpu_use: $jh_cpu" >> $cpu_worklog-$day  
  150.     /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $cpu_table values ('','$here','$jh_name','$jh_ip','$monitor_name','cpu_use','$alert_cpu','$jh_cpu','normal',now())";  
  151. fi  
  152. #check memory  
  153. if [ $jh_mem -le $alert_mem ];then  
  154.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: memory Monitor_Server: $monitor_name Free_mem: $jh_mem"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service: memory  was Exceed Threshold value" $email  
  155.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: memory Monitor_Server: $monitor_name Free_mem: $jh_mem" >> $memory_downlog-$day  
  156.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$jh_name','$jh_ip','$monitor_name','memory','$alert_mem','$jh_mem','abnormal',now())";  
  157. else  
  158.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: memory Monitor_Server: $monitor_name Free_mem: $jh_mem" >> $memory_worklog-$day  
  159.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$jh_name','$jh_ip','$monitor_name','memory','$alert_mem','$jh_mem','normal',now())";  
  160. fi  
  161. #check swap  
  162. if [ $jh_swap -gt $alert_swap ];then  
  163.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: swap Monitor_Server: $monitor_name Swap_jh: $jh_swap"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service: swap Ip: $jh_ip was Exceed Threshold value" $email  
  164.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: swap Monitor_Server: $monitor_name Swap_jh: $jh_swap" >> $memory_downlog-$day  
  165.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database  -e "insert into $memory_table values ('','$here','$jh_name','$jh_ip','$monitor_name','swap','$alert_swap','$jh_swap','abnormal',now())";  
  166. else  
  167.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: swap Monitor_Server: $monitor_name Swap_jh: $jh_swap" >> $memory_worklog-$day  
  168.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $memory_table values ('','$here','$jh_name','$jh_ip','$monitor_name','swap','$alert_swap','$jh_swap','normal',now())";  
  169. fi  
  170. #check load_15  
  171. if [ $jh_load -ge $alert_load ];then  
  172.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: load_15 Monitor_Server: $monitor_name Load_use: $jh_load_15"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service: load_15 Ip: $jh_ip was Exceed Threshold value" $email   
  173.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: load_15 Monitor_Server: $monitor_name Load_use: $jh_load_15" >> $load_downlog-$day  
  174.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $load_table values ('','$here','$jh_name','$jh_ip','$monitor_name','load_15','$alert_load','$jh_load_15','abnormal',now())";  
  175. else  
  176.         echo "$now ShengFen: $here Server: $server Ip: $ip Service: load Monitor_Server: $monitor_name Load_use: $jh_load_15" >> $load_worklog-$day  
  177.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $load_table values ('','$here','$jh_name','$jh_ip','$monitor_name','load_15','$alert_load','$jh_load_15','normal',now())";  
  178. fi  
  179. #check io_idle  
  180. if [ $jh_io_idle -ge $alert_io ];then  
  181.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $jh_io_idle"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service: io_use  was Exceed Threshold value: 80%" $email  
  182.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $jh_io_idle" >> $io_downlog-$day  
  183.         /usr/bin/mysql  -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $io_table values ('','$here','$jh_name','$jh_ip','$monitor_name','io_use','$alert_io','$jh_io_idle','abnormal',now())";  
  184. else  
  185.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: io_idle Monitor_Server: $monitor_name Io_use: $jh_io_idle" >> $io_worklog-$day  
  186.         /usr/bin/mysql  -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $io_table values ('','$here','$jh_name','$jh_ip','$monitor_name','io_use','$alert_io','$jh_io_idle','normal',now())";  
  187. fi  
  188. #check hareware error info  
  189. if [ $jh_hardware_error -gt 0 ];then  
  190.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: hardware_error Monitor_Server: $monitor_name Error: $jh_info_error"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service: hardware_error  were some hardware imformation error" $email  
  191.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: hardware_error Monitor_Server: $monitor_name Error: $jh_info_error" >> $hard_downlog-$day  
  192.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $hardware_table values ('','$here','$jh_name','$jh_ip','$monitor_name','hardware_error','0','$jh_hardware_error','abnormal',now())";  
  193. else  
  194.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: hardware_error Monitor_Server: $monitor_name Error: Nothing" >> $hard_worklog-$day  
  195.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $hardware_table values ('','$here','$jh_name','$jh_ip','$monitor_name','hardware_error','0','$jh_hardware_error','normal',now())";  
  196. fi  
  197. #check message error  
  198. if [ $jh_message_error_count -ge 1 ];then  
  199.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: message_error Monitor_Server: $monitor_name Message_error: $jh_message_error"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name Service: message_error  were some message imformation error" $email  
  200.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: message_error Monitor_Server: $monitor_name Message_error: $jh_message_error" >> $message_downlog-$day  
  201.         /usr/bin/mysql-h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $message_table values ('','$here','$jh_name','$jh_ip','$monitor_name','message_error','1','$jh_message_error_count','abnormal',now())";  
  202. else  
  203.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: message_error Monitor_Server: $monitor_name Message_error: Nothing" >> $message_worklog-$day  
  204.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database  -e "insert into $message_table values ('','$here','$jh_name','$jh_ip','$monitor_name','message_error','1','$jh_message_error_count','normal',now())";  
  205. fi  
  206. #check user  
  207. if [ $jh_user_count -ge 3 ];then  
  208.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: user Monitor_Server: $monitor_name User: $jh_user_info"|/bin/mail -s "Notification ShengFen: $here Server: $jh_name  Service: user  was Exceed Threshold value: 3" $email  
  209.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: user Monitor_Server: $monitor_name User: $jh_user_info" >> $user_downlog-$day  
  210.         /usr/bin/mysql  -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $user_table values ('','$here','$jh_name','$jh_ip','$monitor_name','user','3','$jh_user_count','abnormal',now())";  
  211. else  
  212.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: user Monitor_Server: $monitor_name User: normal" >> $user_worklog-$day  
  213.         /usr/bin/mysql  -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database -e "insert into $user_table values ('','$here','$jh_name','$jh_ip','$monitor_name','user','3','$jh_user_count','normal',now())";  
  214. fi  
  215. #check disk  
  216. if [ $jh_disk_use -ge $alert_disk ];then  
  217.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $jh_disk_partition ($jh_disk_use%)"|/bin/mail -s "Warning!!! $here Server: $jh_name Service: disk_use  was Exceed Threshold value : $alert_disk% " $email  
  218.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $jh_disk_partion ($jh_disk_use%)" >> $disk_downlog-$day  
  219.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database  -e "insert into $disk_table values ('','$here','$jh_name','$jh_ip','$monitor_name','disk_use','$alert_disk','$jh_disk_partition','$jh_disk_use','abnormal',now())";  
  220. else  
  221.         echo "$now ShengFen: $here Server: $jh_name Ip: $jh_ip Service: disk_use Monitor_Server: $monitor_name Disk_use: $jh_disk_partition ($jh_disk_use%)" >> $disk_worklog-$day  
  222.         /usr/bin/mysql -h $mysql_ip -u$mysql_username -p$mysql_passwd $mysql_database  -e "insert into $disk_table values ('','$here','$jh_name','$jh_ip','$monitor_name','disk_use','$alert_disk','$jh_disk_partition','$jh_disk_use','normal',now())";  
  223. fi  





 本文转自 reinxu 51CTO博客,原文链接:http://blog.51cto.com/dl528888/1035131,如需转载请自行联系原作者


相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。   相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情: https://www.aliyun.com/product/rds/mysql 
相关文章
|
9月前
|
人工智能 运维 关系型数据库
数据库运维:mysql 数据库迁移方法-mysqldump
本文介绍了MySQL数据库迁移的方法与技巧,重点探讨了数据量大小对迁移方式的影响。对于10GB以下的小型数据库,推荐使用mysqldump进行逻辑导出和source导入;10GB以上可考虑mydumper与myloader工具;100GB以上则建议物理迁移。文中还提供了统计数据库及表空间大小的SQL语句,并讲解了如何使用mysqldump导出存储过程、函数和数据结构。通过结合实际应用场景选择合适的工具与方法,可实现高效的数据迁移。
1485 1
|
6月前
|
关系型数据库 MySQL PHP
PHP和Mysql前后端交互效果实现
本文介绍了使用PHP连接MySQL数据库的基本函数及其实现案例。内容涵盖数据库连接、选择数据库、执行查询、获取结果等常用操作,并通过用户登录和修改密码的功能实例,展示了PHP与MySQL的交互过程及代码实现。
410 0
PHP和Mysql前后端交互效果实现
|
5月前
|
存储 监控 算法
基于 PHP 布隆过滤器的局域网监控管理工具异常行为检测算法研究
布隆过滤器以其高效的空间利用率和毫秒级查询性能,为局域网监控管理工具提供轻量化异常设备检测方案。相比传统数据库,显著降低延迟与资源消耗,适配边缘设备部署需求,提升网络安全实时防护能力。(238字)
228 0
|
12月前
|
关系型数据库 MySQL Shell
MySQL 备份 Shell 脚本:支持远程同步与阿里云 OSS 备份
一款自动化 MySQL 备份 Shell 脚本,支持本地存储、远程服务器同步(SSH+rsync)、阿里云 OSS 备份,并自动清理过期备份。适用于数据库管理员和开发者,帮助确保数据安全。
|
10月前
|
监控 算法 安全
基于 PHP 的员工电脑桌面监控软件中图像差分算法的设计与实现研究
本文探讨了一种基于PHP语言开发的图像差分算法,用于员工计算机操作行为监控系统。算法通过分块比较策略和动态阈值机制,高效检测屏幕画面变化,显著降低计算复杂度与内存占用。实验表明,相比传统像素级差分算法,该方法将处理时间缩短88%,峰值内存使用量减少70%。文章还介绍了算法在工作效率优化、信息安全防护等方面的应用价值,并分析了数据隐私保护、算法准确性及资源消耗等挑战。未来可通过融合深度学习等技术进一步提升系统智能化水平。
156 2
|
11月前
|
关系型数据库 MySQL Linux
查看Linux、Apache、MySQL、PHP版本的技巧
以上就是查看Linux、Apache、MySQL、PHP版本信息的方法。希望这些信息能帮助你更好地理解和使用你的LAMP技术栈。
516 17
|
11月前
|
SQL Oracle 关系型数据库
在MySQL Shell里 重启MySQL 8.4实例
在MySQL Shell里 重启MySQL 8.4实例
397 2
|
关系型数据库 MySQL PHP
源码编译安装LAMP(HTTP服务,MYSQL ,PHP,以及bbs论坛)
通过以上步骤,你可以成功地在一台Linux服务器上从源码编译并安装LAMP环境,并配置一个BBS论坛(Discuz!)。这些步骤涵盖了从安装依赖、下载源代码、配置编译到安装完成的所有细节。每个命令的解释确保了过程的透明度,使即使是非专业人士也能够理解整个流程。
351 18
|
11月前
|
存储 监控 算法
单位电脑监控软件中 PHP 哈希表算法的深度剖析与理论探究
数字化办公的时代背景下,单位电脑监控软件已成为企业维护信息安全、提升工作效率的关键工具。此类软件可全面监测员工的电脑操作行为,收集海量数据,故而高效管理和处理这些数据显得尤为重要。数据结构与算法在此过程中发挥着核心作用。本文将聚焦于哈希表这一在单位电脑监控软件中广泛应用的数据结构,并通过 PHP 语言实现相关功能,为优化单位电脑监控软件提供技术支持。
190 3
|
11月前
|
存储 监控 算法
论内网电脑监控软件中 PHP 哈希表算法的深度剖析与探究
当代企业网络管理体系中,内网电脑监控软件占据着关键地位。其功能涵盖对员工电脑操作行为的实时监测,以此维护企业信息安全,同时助力企业优化网络资源配置,提升整体工作效能。在构建内网电脑监控软件的诸多技术中,数据结构与算法构成了核心支撑体系。本文聚焦于哈希表这一重要数据结构,深入剖析其在 PHP 语言环境下,如何为内网电脑监控软件的高效运作提供助力,并通过详实的代码示例予以阐释。
188 3

推荐镜像

更多