4、监控视图

主要是通过shell脚本进行收集mysql的数据,然后同gnuplot软件进行数据视图化,然后php加载这些图片到web里显示,用到的php文件为view.php
day.php、month.php、year.php、gansu_day_view.php、gansu_day_web.php(各省安装服务器类型有各自的,比如甘肃当天的备用的程序为gansu_day_beiyong.php)、gansu_month_view.php 、gansu_month_web.php、gansu_year_view.php 、gansu_year_web.php.
详细的php程序描述
A、add.php
  1. <?php
  2. include("conn.php");
  3. include("head.php");
  4. include("head_device.php");
  5. ?>
主要有3个表,分别的作用为:
conn.php是连接数据库的
head.php是php的head文件
head_device.php是设备的head文件
B、add_device.php
  1. <?php
  2. include("conn.php");
  3. include("head.php");
  4. if($_POST['submit']){
  5. $sql="insert into device values ('','$_POST[name]','$_POST[ip]','$_POST[mac]','$_POST[type]','$_POST[jifang_name]','$_POST[raw_name]','$_POST[raw_location]','$_POST[assets_code]','$_POST[state]','$_POST[price]')";
  6. mysql_query($sql);
  7. echo "<script language=\"javascript\">alert('添加成功');history.go(-1)</script>";
  8. }
  9. ##点击完提交后,就进行添加并返回添加成功按键
  10. include("head_device.php");
  11. ?>
  12. <SCRIPT language=javascript>
  13. function CheckPost()
  14. {
  15. if (myform.name.value=="")
  16. {
  17. alert("请填写设备名称");
  18. myform.name.focus();
  19. return false;
  20. }
  21. if (myform.ip.value.length<5)
  22. {
  23. alert("设备ip不能少于5个字符");
  24. myform.ip.focus();
  25. return false;
  26. }
  27. if (myform.mac.value.length<23)
  28. {
  29. alert("设备mac不能少于23位");
  30. myform.mac.focus();
  31. return false;
  32. }
  33. if (myform.type.value=="")
  34. {
  35. alert("请填写设备类型");
  36. myform.type.focus();
  37. return false;
  38. }
  39. if (myform.jifang_name.value=="")
  40. {
  41. alert("请填写机房名称");
  42. myform.jifang_name.focus();
  43. return false;
  44. }
  45. if (myform.raw_name.value=="")
  46. {
  47. alert("请填写机架名称");
  48. myform.raw_name.focus();
  49. return false;
  50. }
  51. if (myform.raw_location.value=="")
  52. {
  53. alert("请填写设备位置");
  54. myform.raw_location.focus();
  55. return false;
  56. }
  57. if (myform.assets_code.value=="")
  58. {
  59. alert("请填写财产编号");
  60. myform.assets_code.focus();
  61. return false;
  62. }
  63. if (myform.state.value=="")
  64. {
  65. alert("请填写设备状态");
  66. myform.state.focus();
  67. return false;
  68. }
  69. if (myform.price.value=="")
  70. {
  71. alert("请填写设备价格");
  72. myform.price.focus();
  73. return false;
  74. }
  75. }
  76. </SCRIPT>
  77. ##使用javascript方式进行约束各自的值
  78. <form action="add_device.php" method="post" name="myform" onsubmit="return CheckPost();">
  79. 设备名称:<input type="text" size="10" name="name" /><br>
  80. 设备I P: <input type="text" size="10" name="ip" /><br/>
  81. 设备MAC: <input type="text" size="10" name="mac" /><br/>
  82. 设备类型:<input type="text" size="10" name="type" /><br/>
  83. 机房名称:<input type="text" size="10" name="jifang_name" /><br/>
  84. 机架名称:<input type="text" size="10" name="raw_name" /><br/>
  85. 机架位置:<input type="text" size="10" name="raw_location" /><br/>
  86. 财产编号:<input type="text" size="10" name="assets_code" /><br/>
  87. 设备状态:<input type="text" size="10"name="state" /><br/>
  88. 设备价格:<input type="text" size="10" name="price" /><br/>
  89. <input type="submit" name="submit" value="新增"/>
  90. <input name="reset" type="reset" value="重置" />
  91. </form>
  92. ##使用html表单
C、conn.php
  1. <?php
  2. $conn = @ mysql_connect("1.1.1.1", "root", "****") or die("数据库链接错误");
  3. mysql_select_db("monitor", $conn);
  4. mysql_query("set names 'GBK'"); //使用GBK中文编码;
  5. ##连接的数据库ip、用户名与密码,如果连接不成功,就返回数据库连接错误
  6. #function htmtocode($content) {
  7. #   $content = str_replace("\n", "<br>", str_replace(" ", "&nbsp;", $content));
  8. #   return $content;
  9. #}
  10. function htmtocode($status) {
  11. str_replace("working", "test", $status);
  12. return $status;
  13. }
  14. #function
  15. //$content=str_replace("'","‘",$content);
  16. //htmlspecialchars();
  17. ?>
D、gansu.php
  1. <?php
  2. include("conn.php");
  3. include("head.php");
  4. include("province.php");
  5. ?>
  6. <font size="3" color="red"><B>应用服务</B></font>
  7. <table border="1" cellspacing="0" >
  8. <tr>
  9. <th width="55">编号</th>
  10. <th width="55">省份</th>
  11. <th width="160">被监控服务器</th>
  12. <th width="100">IP</th>
  13. <th width="100">监控服务器</th>
  14. <th width="130">监控服务</th>
  15. <th width="70">当前状态</th>
  16. <th width="100">监控时间</th>
  17. </tr>
  18. </table>
  19. <?
  20. $SQL="SELECT * FROM `gansu_service` order by date desc limit 0,13";
  21. $query=mysql_query($SQL);
  22. while($row=mysql_fetch_array($query)){
  23. ?>
  24. <table border="1" cellspacing="0" cellpadding="0">
  25. <tr>
  26. <td width="55"><?=$row[id]?> </td>
  27. <td width="55"><?=$row[province]?></td>
  28. <td width="160"><?=$row[server]?> </td>
  29. <td width="100"><?=$row[ip]?></td>
  30. <td width="100"><?=$row[monitor_server]?></td>
  31. <td width="130"><?=$row[service]?></td>
  32. <td width="70"><?=$row[status]?></td>
  33. <td width="100"><?=$row[date]?></td>
  34. </tr>
  35. </table>
  36. <?
  37. }
  38. ?>
  39. <font size="3" color="red"><B>硬盘使用率</B></font>
  40. <table border="1" cellspacing="0" >
  41. <tr>
  42. <th width="55">编号</th>
  43. <th width="55">省份</th>
  44. <th width="160">被监控服务器</th>
  45. <th width="100">IP</th>
  46. <th width="100">监控服务器</th>
  47. <th width="130">监控服务</th>
  48. <th width="70">阀值</th>
  49. <th width="90">当期分区</th>
  50. <th width="70">当前值</th>
  51. <th width="70">当前状态</th>
  52. <th width="100">监控时间</th>
  53. </tr>
  54. </table>
  55. <?
  56. $SQL="SELECT * FROM `gansu_disk` order by date desc limit 0,5";
  57. $query=mysql_query($SQL);
  58. while($row=mysql_fetch_array($query)){
  59. ?>
  60. <table border="1" cellspacing="0" cellpadding="0">
  61. <tr>
  62. <td width="55"><?=$row[id]?> </td>
  63. <td width="55"><?=$row[province]?></td>
  64. <td width="160"><?=$row[server]?> </td>
  65. <td width="100"><?=$row[ip]?></td>
  66. <td width="100"><?=$row[monitor_server]?></td>
  67. <td width="130"><?=$row[service]?></td>
  68. <td width="70"><?=$row[alert]?></td>
  69. <td width="90"><?=$row[partition]?></td>
  70. <td width="70"><?=$row[value]?></td>
  71. <td width="70"><?=$row[status]?></td>
  72. <td width="100"><?=$row[date]?></td>
  73. </tr>
  74. </table>
  75. <?
  76. }
  77. ?>
  78. <font size="3" color="red"><B>CPU使用率</B></font>
  79. <table border="1" cellspacing="0" >
  80. <tr>
  81. <th width="55">编号</th>
  82. <th width="55">省份</th>
  83. <th width="160">被监控服务器</th>
  84. <th width="100">IP</th>
  85. <th width="100">监控服务器</th>
  86. <th width="130">监控服务</th>
  87. <th width="70">阀值</th>
  88. <th width="70">当前值</th>
  89. <th width="70">当前状态</th>
  90. <th width="100">监控时间</th>
  91. </tr>
  92. </table>
  93. <?
  94. $SQL="SELECT * FROM `gansu_cpu` order by date desc limit 0,5";
  95. $query=mysql_query($SQL);
  96. while($row=mysql_fetch_array($query)){
  97. ?>
  98. <table border="1" cellspacing="0" cellpadding="0">
  99. <tr>
  100. <td width="55"><?=$row[id]?> </td>
  101. <td width="55"><?=$row[province]?></td>
  102. <td width="160"><?=$row[server]?> </td>
  103. <td width="100"><?=$row[ip]?></td>
  104. <td width="100"><?=$row[monitor_server]?></td>
  105. <td width="130"><?=$row[service]?></td>
  106. <td width="70"><?=$row[alert]?></td>
  107. <td width="70"><?=$row[value]?></td>
  108. <td width="70"><?=$row[status]?></td>
  109. <td width="100"><?=$row[date]?></td>
  110. </tr>
  111. </table>
  112. <?
  113. }
  114. ?>
  115. <font size="3" color="red"><B>硬件错误信息</B></font>
  116. <table border="1" cellspacing="0" >
  117. <tr>
  118. <th width="55">编号</th>
  119. <th width="55">省份</th>
  120. <th width="160">被监控服务器</th>
  121. <th width="100">IP</th>
  122. <th width="100">监控服务器</th>
  123. <th width="130">监控服务</th>
  124. <th width="70">阀值</th>
  125. <th width="70">当前值</th>
  126. <th width="70">当前状态</th>
  127. <th width="100">监控时间</th>
  128. </tr>
  129. </table>
  130. <?
  131. $SQL="SELECT * FROM `gansu_hardware` order by date desc limit 0,5";
  132. $query=mysql_query($SQL);
  133. while($row=mysql_fetch_array($query)){
  134. ?>
  135. <table border="1" cellspacing="0" cellpadding="0">
  136. <tr>
  137. <td width="55"><?=$row[id]?> </td>
  138. <td width="55"><?=$row[province]?></td>
  139. <td width="160"><?=$row[server]?> </td>
  140. <td width="100"><?=$row[ip]?></td>
  141. <td width="100"><?=$row[monitor_server]?></td>
  142. <td width="130"><?=$row[service]?></td>
  143. <td width="70"><?=$row[alert]?></td>
  144. <td width="70"><?=$row[value]?></td>
  145. <td width="70"><?=$row[status]?></td>
  146. <td width="100"><?=$row[date]?></td>
  147. </tr>
  148. </table>
  149. <?
  150. }
  151. ?>
  152. <font size="3" color="red"><B>I/O使用率</B></font>
  153. <table border="1" cellspacing="0" >
  154. <tr>
  155. <th width="55">编号</th>
  156. <th width="55">省份</th>
  157. <th width="160">被监控服务器</th>
  158. <th width="100">IP</th>
  159. <th width="100">监控服务器</th>
  160. <th width="130">监控服务</th>
  161. <th width="70">阀值</th>
  162. <th width="70">当前值</th>
  163. <th width="70">当前状态</th>
  164. <th width="100">监控时间</th>
  165. </tr>
  166. </table>
  167. <?
  168. $SQL="SELECT * FROM `gansu_io` order by date desc limit 0,5";
  169. $query=mysql_query($SQL);
  170. while($row=mysql_fetch_array($query)){
  171. ?>
  172. <table border="1" cellspacing="0" cellpadding="0">
  173. <tr>
  174. <td width="55"><?=$row[id]?> </td>
  175. <td width="55"><?=$row[province]?></td>
  176. <td width="160"><?=$row[server]?> </td>
  177. <td width="100"><?=$row[ip]?></td>
  178. <td width="100"><?=$row[monitor_server]?></td>
  179. <td width="130"><?=$row[service]?></td>
  180. <td width="70"><?=$row[alert]?></td>
  181. <td width="70"><?=$row[value]?></td>
  182. <td width="70"><?=$row[status]?></td>
  183. <td width="100"><?=$row[date]?></td>
  184. </tr>
  185. </table>
  186. <?
  187. }
  188. ?>
  189. <font size="3" color="red"><B>15分钟内的负载</B></font>
  190. <table border="1" cellspacing="0" >
  191. <tr>
  192. <th width="55">编号</th>
  193. <th width="55">省份</th>
  194. <th width="160">被监控服务器</th>
  195. <th width="100">IP</th>
  196. <th width="100">监控服务器</th>
  197. <th width="130">监控服务</th>
  198. <th width="70">阀值</th>
  199. <th width="70">当前值</th>
  200. <th width="70">当前状态</th>
  201. <th width="100">监控时间</th>
  202. </tr>
  203. </table>
  204. <?
  205. $SQL="SELECT * FROM `gansu_load` order by date desc limit 0,5";
  206. $query=mysql_query($SQL);
  207. while($row=mysql_fetch_array($query)){
  208. ?>
  209. <table border="1" cellspacing="0" cellpadding="0">
  210. <tr>
  211. <td width="55"><?=$row[id]?> </td>
  212. <td width="55"><?=$row[province]?></td>
  213. <td width="160"><?=$row[server]?> </td>
  214. <td width="100"><?=$row[ip]?></td>
  215. <td width="100"><?=$row[monitor_server]?></td>
  216. <td width="130"><?=$row[service]?></td>
  217. <td width="70"><?=$row[alert]?></td>
  218. <td width="70"><?=$row[value]?></td>
  219. <td width="70"><?=$row[status]?></td>
  220. <td width="100"><?=$row[date]?></td>
  221. </tr>
  222. </table>
  223. <?
  224. }
  225. ?>
  226. <font size="3" color="red"><B>内存使用率</B></font>
  227. <table border="1" cellspacing="0" >
  228. <tr>
  229. <th width="55">编号</th>
  230. <th width="55">省份</th>
  231. <th width="160">被监控服务器</th>
  232. <th width="100">IP</th>
  233. <th width="100">监控服务器</th>
  234. <th width="130">监控服务</th>
  235. <th width="70">阀值</th>
  236. <th width="70">当前值</th>
  237. <th width="70">当前状态</th>
  238. <th width="100">监控时间</th>
  239. </tr>
  240. </table>
  241. <?
  242. $SQL="SELECT * FROM `gansu_memory` order by date desc limit 0,10";
  243. $query=mysql_query($SQL);
  244. while($row=mysql_fetch_array($query)){
  245. ?>
  246. <table border="1" cellspacing="0" cellpadding="0">
  247. <tr>
  248. <td width="55"><?=$row[id]?> </td>
  249. <td width="55"><?=$row[province]?></td>
  250. <td width="160"><?=$row[server]?> </td>
  251. <td width="100"><?=$row[ip]?></td>
  252. <td width="100"><?=$row[monitor_server]?></td>
  253. <td width="130"><?=$row[service]?></td>
  254. <td width="70"><?=$row[alert]?></td>
  255. <td width="70"><?=$row[value]?></td>
  256. <td width="70"><?=$row[status]?></td>
  257. <td width="100"><?=$row[date]?></td>
  258. </tr>
  259. </table>
  260. <?
  261. }
  262. ?>
  263. <font size="3" color="red"><B>日志错误信息</B></font>
  264. <table border="1" cellspacing="0" >
  265. <tr>
  266. <th width="55">编号</th>
  267. <th width="55">省份</th>
  268. <th width="160">被监控服务器</th>
  269. <th width="100">IP</th>
  270. <th width="100">监控服务器</th>
  271. <th width="130">监控服务</th>
  272. <th width="70">阀值</th>
  273. <th width="70">当前值</th>
  274. <th width="70">当前状态</th>
  275. <th width="100">监控时间</th>
  276. </tr>
  277. </table>
  278. <?
  279. $SQL="SELECT * FROM `gansu_message` order by date desc limit 0,5";
  280. $query=mysql_query($SQL);
  281. while($row=mysql_fetch_array($query)){
  282. ?>
  283. <table border="1" cellspacing="0" cellpadding="0">
  284. <tr>
  285. <td width="55"><?=$row[id]?> </td>
  286. <td width="55"><?=$row[province]?></td>
  287. <td width="160"><?=$row[server]?> </td>
  288. <td width="100"><?=$row[ip]?></td>
  289. <td width="100"><?=$row[monitor_server]?></td>
  290. <td width="130"><?=$row[service]?></td>
  291. <td width="70"><?=$row[alert]?></td>
  292. <td width="70"><?=$row[value]?></td>
  293. <td width="70"><?=$row[status]?></td>
  294. <td width="100"><?=$row[date]?></td>
  295. </tr>
  296. </table>
  297. <?
  298. }
  299. ?>
  300. <font size="3" color="red"><B>用户登录数</B></font>
  301. <table border="1" cellspacing="0" >
  302. <tr>
  303. <th width="55">编号</th>
  304. <th width="55">省份</th>
  305. <th width="160">被监控服务器</th>
  306. <th width="100">IP</th>
  307. <th width="100">监控服务器</th>
  308. <th width="130">监控服务</th>
  309. <th width="70">阀值</th>
  310. <th width="70">当前值</th>
  311. <th width="70">当前状态</th>
  312. <th width="100">监控时间</th>
  313. </tr>
  314. </table>
  315. <?
  316. $SQL="SELECT * FROM `gansu_user` order by date desc limit 0,5";
  317. $query=mysql_query($SQL);
  318. while($row=mysql_fetch_array($query)){
  319. ?>
  320. <table border="1" cellspacing="0" cellpadding="0">
  321. <tr>
  322. <td width="55"><?=$row[id]?> </td>
  323. <td width="55"><?=$row[province]?></td>
  324. <td width="160"><?=$row[server]?> </td>
  325. <td width="100"><?=$row[ip]?></td>
  326. <td width="100"><?=$row[monitor_server]?></td>
  327. <td width="130"><?=$row[service]?></td>
  328. <td width="70"><?=$row[alert]?></td>
  329. <td width="70"><?=$row[value]?></td>
  330. <td width="70"><?=$row[status]?></td>
  331. <td width="100"><?=$row[date]?></td>
  332. </tr>
  333. </table>
  334. <?
  335. }
  336. ?>

此页面主要是各省展示自己的监控服务与资源详情的页面。

主要是通过从mysql里获取各自表的数据,插入到我设定好的表单里,在web里显示,这些表单的格式都是通过css进行控制的。
E、css.css
  1. td {
  2. line-height: 16pt;
  3. font-size: 10pt;
  4. font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
  5. }
  6. a:link {
  7. text-decoration: none;
  8. color: #000000;
  9. }
  10. a:visited {
  11. text-decoration: none;
  12. color: #000000;
  13. }
  14. a:hover {
  15. text-decoration: underline;
  16. color: #FF3333;
  17. }
  18. body {
  19. font-size: 10pt;
  20. line-height: 13pt;
  21. background-color: #ECF5FF;
  22. }
  23. .border {
  24. border: 1px solid #1D5892;
  25. }
  26. textarea {
  27. font-size: 8pt;
  28. font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
  29. border: 1px solid #999999;
  30. padding: 5px;
  31. }
  32. select {
  33. font-size: 8pt;
  34. padding: 1px;
  35. font-family: "Tahoma";
  36. }
  37. .a1:link {
  38. color: #FFFFFF;
  39. }
  40. .a1:visited {
  41. color: #FFFFFF;
  42. }
  43. .a1:hover {
  44. color: #FF9900;
  45. }
  46. .font14 {
  47. font-size: 14px;
  48. font-family: "Tahoma";
  49. }
  50. form {
  51. margin: 0px;
  52. padding: 0px;
  53. }
  54. .alpha {
  55. filter: Alpha(Opacity=20);
  56. }
  57. .filearea {
  58. font-size: 9pt;
  59. }
  60. .textdrow {
  61. color:#666666;
  62. filter: DropShadow(Color=white, OffX=1, OffY=1, Positive=1);
  63. }
  64. .font18 {
  65. font-size: 19px;
  66. }
  67. .p {
  68. text-indent: 24px;
  69. }
  70. .font16 {
  71. font-size: 16px;
  72. }
  73. .border2 {
  74. border: 1px solid #D5E4F4;
  75. }
  76. .xborder {
  77. border: 2px dotted #EBF5FE;
  78. }
  79. table {
  80. width: 1100px;
  81. }
  82. td {
  83. text-align:center;
  84. }
主要是观察最后2项,是控制表的宽度与表里单元格的内容显示方法。
F、gansu_warn.php
  1. <?php
  2. include ("conn.php");
  3. include ("head.php");
  4. include("warn_province.php");
  5. ?>
  6. <?
  7. /*检测服务报警
  8. *
  9. */
  10. $SQL="select * from gansu_service where 1=1 AND DATE_FORMAT(gansu_service.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='downing'";
  11. $query=mysql_query($SQL);
  12. $result=mysql_fetch_row($query);
  13. if($result==''){
  14. echo '<font size="3" color="red"><B>甘肃省份今天没有发现服务报警</B></font><br>';
  15. }
  16. else {
  17. echo '<font size="3" color="red"><B>甘肃省份今天的服务报警为:</B></font><br>';
  18. include ("service_warning.php");
  19. }
  20. ?>
  21. <?
  22. /*检测磁盘报警
  23. *
  24. */
  25. $SQL="select * from gansu_disk where 1=1 AND DATE_FORMAT(gansu_disk.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='abnormal'";
  26. $query=mysql_query($SQL);
  27. $result=mysql_fetch_row($query);
  28. if($result==''){
  29. echo '<font size="3" color="red"><B>甘肃省份今天没有发现磁盘报警</B></font><br>';
  30. }
  31. else {
  32. echo '<font size="3" color="red"><B>甘肃省份今天的磁盘报警为:</B></font><br>';
  33. include ("disk_warning.php");
  34. }
  35. ?>
  36. <?
  37. /*检测CPU报警
  38. *
  39. */
  40. $SQL="select * from gansu_cpu where 1=1 AND DATE_FORMAT(gansu_cpu.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='abnormal'";
  41. $query=mysql_query($SQL);
  42. $result=mysql_fetch_row($query);
  43. if($result==''){
  44. echo '<font size="3" color="red"><B>甘肃省份今天没有发现CPU报警</B></font><br>';
  45. }
  46. else {
  47. echo '<font size="3" color="red"><B>甘肃省份今天的CPU报警为:</B></font><br>';
  48. include ("resource_warning.php");
  49. }
  50. ?>
  51. <?
  52. /*检测硬件信息错误报警
  53. *
  54. */
  55. $SQL="select * from gansu_hardware where 1=1 AND DATE_FORMAT(gansu_hardware.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='abnormal'";
  56. $query=mysql_query($SQL);
  57. $result=mysql_fetch_row($query);
  58. if($result==''){
  59. echo '<font size="3" color="red"><B>甘肃省份今天没有发现硬件信息错误(hardware)报警</B></font><br>';
  60. }
  61. else {
  62. echo '<font size="3" color="red"><B>甘肃省份今天的硬件信息错误(hardware)报警为:</B></font><br>';
  63. include ("resource_warning.php");
  64. }
  65. ?>
  66. <?
  67. /*检测I/O报警
  68. *
  69. */
  70. $SQL="select * from gansu_io where 1=1 AND DATE_FORMAT(gansu_io.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='abnormal'";
  71. $query=mysql_query($SQL);
  72. $result=mysql_fetch_row($query);
  73. if($result==''){
  74. echo '<font size="3" color="red"><B>甘肃省份今天没有发现I/O报警</B></font><br>';
  75. }
  76. else {
  77. echo '<font size="3" color="red"><B>甘肃省份今天的I/O报警为:</B></font><br>';
  78. include ("resource_warning.php");
  79. }
  80. ?>
  81. <?
  82. /*检测load报警
  83. *
  84. */
  85. $SQL="select * from gansu_load where 1=1 AND DATE_FORMAT(gansu_load.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='abnormal';";
  86. $query=mysql_query($SQL);
  87. $result=mysql_fetch_row($query);
  88. if($result==''){
  89. echo '<font size="3" color="red"><B>甘肃省份今天没有发现负载(load)报警</B></font><br>';
  90. }
  91. else{
  92. echo '<font size="3" color="red"><B>甘肃省份今天的负载(load)报警为:</B></font><br>';
  93. include ("resource_warning.php");
  94. }
  95. ?>
  96. <?
  97. /*检测内存报警
  98. *
  99. */
  100. $SQL="select * from gansu_memory where 1=1 AND DATE_FORMAT(gansu_memory.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='abnormal'";
  101. $query=mysql_query($SQL);
  102. $result=mysql_fetch_row($query);
  103. if($result==''){
  104. echo '<font size="3" color="red"><B>甘肃省份今天没有发现内存(memory)报警</B></font><br>';
  105. }
  106. else {
  107. echo '<font size="3" color="red"><B>甘肃省份今天的内存(memory)报警为:</B></font><br>';
  108. include ("resource_warning.php");
  109. }
  110. ?>
  111. <?
  112. /*检测日志信息报警
  113. *
  114. */
  115. $SQL="select * from gansu_message where 1=1 AND DATE_FORMAT(gansu_message.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='abnormal'";
  116. $query=mysql_query($SQL);
  117. $result=mysql_fetch_row($query);
  118. if($result==''){
  119. echo '<font size="3" color="red"><B>甘肃省份今天没有发现日志信息(message)报警</B></font><br>';
  120. }
  121. else {
  122. echo '<font size="3" color="red"><B>甘肃省份今天的日志信息(message)报警为:</B></font><br>';
  123. include ("resource_warning.php");
  124. }
  125. ?>
  126. <?
  127. /*检测用户报警
  128. *
  129. */
  130. $SQL="select * from gansu_user where 1=1 AND DATE_FORMAT(gansu_user.date,'%Y-%m-%d') = DATE_FORMAT(NOW(),'%Y-%m-%d') AND status='abnormal'";
  131. $query=mysql_query($SQL);
  132. $result=mysql_fetch_row($query);
  133. if($result==''){
  134. echo '<font size="3" color="red"><B>甘肃省份今天没有发现用户登录数(user)报警</B></font><br>';
  135. }
  136. else {
  137. echo '<font size="3" color="red"><B>甘肃省份今天的用户登录数(user)报警为:</B></font><br>';
  138. include ("resource_warning.php");
  139. }
  140. ?>

此页面主要是展现甘肃省当日的服务与资源的报警。

下一篇文章地址:

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

http://dl528888.blog.51cto.com/2382721/1035297

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

运维自动化之使用PHP+MYSQL+SHELL打造私有监控系统(五)相关推荐

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

    现在开始介绍php+mysql+shell监控系统 1.目的 此监控系统主要是通过php+mysql+shell的方式,通过shell脚本对各个机器的其各个服务进行监控,达到及时的了解其各个应用服务的 ...

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

    前言 记得刚来这家公司的时候,我部门就我一个运维工程师,然后就是经理,刚开始公司平台什么监控都没有,在我与经理的努力下,先搭建nagios+cacti监控平台,后来随着公司业务的增加,平台的功能与服务 ...

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

    (5)数据库服务器(以甘肃数据库为例,脚本解释参照甘肃web) #!/bin/bash #ip db_ip=$(/sbin/ifconfig eth0|grep "inet addr&quo ...

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

    转载来自:http://dl528888.blog.51cto.com/2382721/1034992 前言 记得刚来这家公司的时候,我部门就我一个运维工程师,然后就是经理,刚开始公司平台什么监控都没 ...

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

    X.create_province.sh脚本内容 #!binbash LANG="zh_CN.UTF-8" LANG=C #mysql info mysql_ip='1.1.1.1 ...

  6. php自动运维,运维自动化之使用PHP+MYSQL+SHELL打造私有监控系统(五)

    include("conn.php"); include("head.php"); include("province.php"); ?&g ...

  7. linux运维自动化脚本,linux运维自动化shell脚本小工具

    linux运维shell 脚本小工具,如要分享此文章,请注明文章出处,以下脚本仅供参考,若放置在服务器上出错,后果请自负 1.检测cpu剩余百分比 #!/bin/bash #Inspect CPU # ...

  8. Servicehot和你说说运维自动化的那些事儿

    2019独角兽企业重金招聘Python工程师标准>>> 运维管理兜兜转转十几余载,大家的运维管理再也不是小米加步枪.人工费力拉线扛服务器的传统时代,如你所知,这些年大家张口闭口谈的都 ...

  9. 舍本求末的运维自动化技术热潮

    运维自动化是2010年开始炒得很热的一个概念,也让很多工程师.用人单位瞎激动了很久,我也跟风学过puppet和python,求职双方也经常在面试时花大量时间谈运维自动化. 但冷静下来想想,所谓自动化, ...

最新文章

  1. 前端学习(2951):上午回顾
  2. 草稿 9206 1128需处理
  3. docker 网络设置
  4. Quote Form OnLoad Implement Add Leftnav, count Activities
  5. oracle常用网址
  6. 冷知识 —— 计算机科学及编程
  7. Java Socket编程(一)TCP/IP简介
  8. 如何成为一个技术全面的架构师
  9. 5.UML2 软件建模入门与提高 --- 类图
  10. matlab特定等值线,从Matlab轮廓函数中选择等值线
  11. 查看WLC的SFP模块信息
  12. 五点差分法求解偏微分方程(PDE)
  13. java中英文排序_Java 中英文数字排序
  14. OpenWrt mesh组网设置
  15. 【Matlab生物电信号】生物电信号仿真【含GUI源码 684期】
  16. 介绍一个关于小米Zigbee的开源项目
  17. 使用seq2seq模型进行机器翻译的方法不同
  18. 深度剖析淘宝天猫搜索逻辑
  19. Java常用的Dos命令
  20. DW如何设置计算机管理,《Dreamweaver网页设计》网页设计技巧

热门文章

  1. spark BlockManager如何实现Broadcast广播
  2. php %3ch1%3e字体,phpWebSite搜索模块跨站脚本执行漏洞
  3. 代码质量 重构 代码鸡汤
  4. group by的用法原理
  5. thinkphp增删改查
  6. msg_p!=(void*) 0 --消息邮箱(点滴学习)
  7. Go 语言泛型,简明入门教程
  8. Laravel 5.4: 特殊字段太长报错 420000 字段太长
  9. 算法-两最长回文子串
  10. Android ProgressBar手动控制开始和停止