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
-
<?
php
- include("conn.php");
- include("head.php");
- include("head_device.php");
?>
主要有
3个表,分别的作用为:
conn.php是连接数据库的
head.php是
php的head文件
head_device.php是设备的
head文件
B、
add_device.php
-
<?
php
- include("conn.php");
- include("head.php");
- if($_POST['submit']){
$
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]')"
;
- mysql_query($sql);
echo "
<
script
language
="javascript"
alert('添加成功');history.go(-1)
</
script
";
- }
- ##点击完提交后,就进行添加并返回添加成功按键
- include("head_device.php");
?>
1.
<
SCRIPT
language
javascript
- function CheckPost()
- {
if (
myform.name.value
=="")
- {
- alert("请填写设备名称");
- myform.name.focus();
- return false;
- }
if (myform.ip.value.length
<
5
)
- {
- alert("设备ip不能少于5个字符");
- myform.ip.focus();
- return false;
- }
if (myform.mac.value.length
<
23
)
- {
- alert("设备mac不能少于23位");
- myform.mac.focus();
- return false;
- }
if (
myform.type.value
=="")
- {
- alert("请填写设备类型");
- myform.type.focus();
- return false;
- }
if (
myform.jifang_name.value
=="")
- {
- alert("请填写机房名称");
- myform.jifang_name.focus();
- return false;
- }
if (
myform.raw_name.value
=="")
- {
- alert("请填写机架名称");
- myform.raw_name.focus();
- return false;
- }
if (
myform.raw_location.value
=="")
- {
- alert("请填写设备位置");
- myform.raw_location.focus();
- return false;
- }
if (
myform.assets_code.value
=="")
- {
- alert("请填写财产编号");
- myform.assets_code.focus();
- return false;
- }
if (
myform.state.value
=="")
- {
- alert("请填写设备状态");
- myform.state.focus();
- return false;
- }
if (
myform.price.value
=="")
- {
- alert("请填写设备价格");
- myform.price.focus();
- return false;
- }
- }
</
SCRIPT
- ##使用javascript方式进行约束各自的值
<
form
action
"add_device.php"
method
"post"
name
"myform"
onsubmit
"return CheckPost();"
1.
设备名称:
<
input
type
"text"
size
"10"
name
"name"
/>
<
br
1.
设备I P:
<
input
type
"text"
size
"10"
name
"ip"
/>
<
br
/>
1.
设备MAC:
<
input
type
"text"
size
"10"
name
"mac"
/>
<
br
/>
1.
设备类型:
<
input
type
"text"
size
"10"
name
"type"
/>
<
br
/>
1.
机房名称:
<
input
type
"text"
size
"10"
name
"jifang_name"
/>
<
br
/>
1.
机架名称:
<
input
type
"text"
size
"10"
name
"raw_name"
/>
<
br
/>
1.
机架位置:
<
input
type
"text"
size
"10"
name
"raw_location"
/>
<
br
/>
1.
财产编号:
<
input
type
"text"
size
"10"
name
"assets_code"
/>
<
br
/>
1.
设备状态:
<
input
type
"text"
size
="10"
name
="state"
/>
<
br
/>
1.
设备价格:
<
input
type
"text"
size
"10"
name
"price"
/>
<
br
/>
1.
<
input
type
"submit"
name
"submit"
value
"新增"
/>
1.
<
input
name
"reset"
type
"reset"
value
"重置"
/>
1.
</
form
- ##使用html表单
C、
conn.php
-
<?
php
1.
$
conn
= @ mysql_connect("1.1.1.1", "root", "****") or die("数据库链接错误");
- mysql_select_db("monitor", $conn);
- mysql_query("set names 'GBK'"); //使用GBK中文编码;
- ##连接的数据库ip、用户名与密码,如果连接不成功,就返回数据库连接错误
- #function htmtocode($content) {
# $
content
=
str_replace
("\n", "
<
br
", str_replace(" ", " ", $content));
- # return $content;
- #}
- function htmtocode($status) {
- str_replace("working", "test", $status);
- return $status;
- }
- #function
//$
content
str_replace
("'","‘",$content);
- //htmlspecialchars();
?>
D、
gansu.php
-
<?php
include(
"conn.php"
);
1.
include(
"head.php"
);
1.
include(
"province.php"
);
- ?>
<font size=
"3"
color=
"red"
<B>应用服务</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_service
1 | 1` |
order by date desc limit 0,13"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
<font size=
"3"
color=
"red"
<B>硬盘使用率</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
阀值</th>
<th width=
"90"
当期分区</th>
<th width=
"70"
当前值</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_disk
1 | 1` |
order by date desc limit 0,5"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[alert]?></td>
<td width=
"90"
<?=$row[partition]?></td>
<td width=
"70"
<?=$row[value]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
<font size=
"3"
color=
"red"
<B>CPU使用率</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
阀值</th>
<th width=
"70"
当前值</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_cpu
1 | 1` |
order by date desc limit 0,5"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[alert]?></td>
<td width=
"70"
<?=$row[value]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
<font size=
"3"
color=
"red"
<B>硬件错误信息</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
阀值</th>
<th width=
"70"
当前值</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_hardware
1 | 1` |
order by date desc limit 0,5"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[alert]?></td>
<td width=
"70"
<?=$row[value]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
<font size=
"3"
color=
"red"
<B>I/O使用率</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
阀值</th>
<th width=
"70"
当前值</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_io
1 | 1` |
order by date desc limit 0,5"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[alert]?></td>
<td width=
"70"
<?=$row[value]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
<font size=
"3"
color=
"red"
<B>15分钟内的负载</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
阀值</th>
<th width=
"70"
当前值</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_load
1 | 1` |
order by date desc limit 0,5"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[alert]?></td>
<td width=
"70"
<?=$row[value]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
<font size=
"3"
color=
"red"
<B>内存使用率</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
阀值</th>
<th width=
"70"
当前值</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_memory
1 | 1` |
order by date desc limit 0,10"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[alert]?></td>
<td width=
"70"
<?=$row[value]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
<font size=
"3"
color=
"red"
<B>日志错误信息</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
阀值</th>
<th width=
"70"
当前值</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_message
1 | 1` |
order by date desc limit 0,5"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[alert]?></td>
<td width=
"70"
<?=$row[value]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
<font size=
"3"
color=
"red"
<B>用户登录数</B></font>
<table border=
"1"
cellspacing=
"0"
>
- <tr>
<th width=
"55"
编号</th>
<th width=
"55"
省份</th>
<th width=
"160"
被监控服务器</th>
<th width=
"100"
IP</th>
<th width=
"100"
监控服务器</th>
<th width=
"130"
监控服务</th>
<th width=
"70"
阀值</th>
<th width=
"70"
当前值</th>
<th width=
"70"
当前状态</th>
<th width=
"100"
监控时间</th>
- </tr>
- </table>
-
<?
$SQL=
"SELECT * FROM
1 | 1` |
gansu_user
1 | 1` |
order by date desc limit 0,5"
;
- $query=mysql_query($SQL);
while
($row=mysql_fetch_array($query)){
- ?>
<table border=
"1"
cellspacing=
"0"
cellpadding=
"0"
- <tr>
<td width=
"55"
<?=$row[id]?> </td>
<td width=
"55"
<?=$row[province]?></td>
<td width=
"160"
<?=$row[server]?> </td>
<td width=
"100"
<?=$row[ip]?></td>
<td width=
"100"
<?=$row[monitor_server]?></td>
<td width=
"130"
<?=$row[service]?></td>
<td width=
"70"
<?=$row[alert]?></td>
<td width=
"70"
<?=$row[value]?></td>
<td width=
"70"
<?=$row[status]?></td>
<td width=
"100"
<?=$row[date]?></td>
- </tr>
- </table>
-
<?
- }
- ?>
此页面主要是各省展示自己的监控服务与资源详情的页面。
主要是通过从
mysql里获取各自表的数据,插入到我设定好的表单里,在web里显示,这些表单的格式都是通过css进行控制的。
E、
css.css
- td {
- line-height: 16pt;
- font-size: 10pt;
- font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
- }
- a:link {
- text-decoration: none;
- color: #000000;
- }
- a:visited {
- text-decoration: none;
- color: #000000;
- }
- a:hover {
- text-decoration: underline;
- color: #FF3333;
- }
- body {
- font-size: 10pt;
- line-height: 13pt;
- background-color: #ECF5FF;
- }
- .border {
- border: 1px solid #1D5892;
- }
- textarea {
- font-size: 8pt;
- font-family: "Verdana", "Arial", "Helvetica", "sans-serif";
- border: 1px solid #999999;
- padding: 5px;
- }
- select {
- font-size: 8pt;
- padding: 1px;
- font-family: "Tahoma";
- }
- .a1:link {
- color: #FFFFFF;
- }
- .a1:visited {
- color: #FFFFFF;
- }
- .a1:hover {
- color: #FF9900;
- }
- .font14 {
- font-size: 14px;
- font-family: "Tahoma";
- }
- form {
- margin: 0px;
- padding: 0px;
- }
- .alpha {
filter: Alpha(
Opacity
20
);
- }
- .filearea {
- font-size: 9pt;
- }
- .textdrow {
- color:#666666;
filter: DropShadow(
Color
white
,
OffX
1
,
OffY
1
,
Positive
1
);
- }
- .font18 {
- font-size: 19px;
- }
- .p {
- text-indent: 24px;
- }
- .font16 {
- font-size: 16px;
- }
- .border2 {
- border: 1px solid #D5E4F4;
- }
- .xborder {
- border: 2px dotted #EBF5FE;
- }
- table {
- width: 1100px;
- }
- td {
- text-align:center;
- }
主要是观察最后
2项,是控制表的宽度与表里单元格的内容显示方法。
F、
gansu_warn.php
-
<?
php
- include ("conn.php");
- include ("head.php");
- include("warn_province.php");
?>
1.
<?
1. /\*检测服务报警
1. \*
1. \*/
1.
$
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'"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现服务报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else {
1.
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的服务报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("service_warning.php");
1. }
1.
?>
1.
<?
1. /\*检测磁盘报警
1. \*
1. \*/
1.
$
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'"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现磁盘报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else {
1.
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的磁盘报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("disk_warning.php");
1. }
1.
?>
1.
<?
1. /\*检测CPU报警
1. \*
1. \*/
1.
$
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'"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现CPU报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else {
1.
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的CPU报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("resource_warning.php");
1. }
1.
?>
1.
<?
1. /\*检测硬件信息错误报警
1. \*
1. \*/
1.
$
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'"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现硬件信息错误(hardware)报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else {
1.
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的硬件信息错误(hardware)报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("resource_warning.php");
1. }
1.
?>
1.
<?
1. /\*检测I/O报警
1. \*
1. \*/
1.
$
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'"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现I/O报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else {
1.
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的I/O报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("resource_warning.php");
1. }
1.
?>
1.
<?
1. /\*检测load报警
1. \*
1. \*/
1.
$
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';"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现负载(load)报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else{
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的负载(load)报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("resource_warning.php");
1. }
1.
?>
1.
<?
1. /\*检测内存报警
1. \*
1. \*/
1.
$
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'"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现内存(memory)报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else {
1.
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的内存(memory)报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("resource_warning.php");
1. }
1.
?>
1.
<?
1. /\*检测日志信息报警
1. \*
1. \*/
1.
$
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'"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现日志信息(message)报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else {
1.
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的日志信息(message)报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("resource_warning.php");
1. }
1.
?>
1.
<?
1. /\*检测用户报警
1. \*
1. \*/
1.
$
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'"
;
1.
$
query
=
mysql_query
($SQL);
1.
1.
1.
$
result
=
mysql_fetch_row
($query);
1.
if($
result
==''){
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天没有发现用户登录数(user)报警
</
B
>
</
font
>
<
br
>
';
1. }
1. else {
1.
1.
echo '
<
font
size
=
"3"
color
=
"red"
>
<
B
>
甘肃省份今天的用户登录数(user)报警为:
</
B
>
</
font
>
<
br
>
';
1. include ("resource_warning.php");
1. }
1.
?>
此页面主要是展现甘肃省当日的服务与资源的报警。
下一篇文章地址:
运维自动化之使用PHP+MYSQL+SHELL打造私有监控系统(六)
http://dl528888.blog.51cto.com/2382721/1035297
本文转自 reinxu 51CTO博客,原文链接:http://blog.51cto.com/dl528888/1035252
,如需转载请自行联系原作者