整理月平均效能資料
整理月平均效能資料
35::
在centreon_storage庫中建立關係表test1
CREATE TABLE test1 AS SELECT
index_data.host_name,
index_data.service_description,
metrics.metric_id,
metrics.metric_name
FROM
index_data,
metrics
WHERE
index_data.id = metrics.index_id;
把data_bin,test1 表的資料轉移到172.25.128.77上面。放到bigdata資料庫中。
cd /var/lib/mysql/centreon_storage
scp -p data_bin.* test1.* 172.*.*.77:/mysql/bigdata
77:
[root@nagiosdb log]# mysql -u root -p123456 --socket=/var/lib/mysql/mysql.sock
要指定一下socket登陸。
drop database bigdata;
create database bigdata;
use bigdata;
repair table test1;
repair table data_bin;
因為是直接複製資料檔案,需要repair表。data_bin需要時間較長。
效能資料:
CREATE TABLE http_time AS SELECT
b.host_name,
b.service_description,
b.metric_name,
a.VALUE,
a.id_metric,
b.metric_id
FROM
data_bin a,
test1 b
WHERE
a.id_metric = b.metric_id
AND a.ctime >= unix_timestamp('2016-04-01')
AND a.ctime < unix_timestamp('2016-05-01')
/*
AND b.metric_name = 'time';
AND b.metric_name = 'CpuUser';
AND b.metric_name = 'phyUsed';
AND b.metric_name LIKE '/%';
*/
AND b.metric_name = 'time';
資料取值調整:
CREATE TABLE http_time_1 AS SELECT
host_name,
service_description,
metric_name,
ROUND(AVG(VALUE)*1000,2) as avg,
ROUND(MAX(VALUE)*1000,2) as max,
ROUND(MIN(VALUE)*1000,2) as min
FROM
http_time
GROUP BY
host_name
drop table cpu_user_1;
flush tables;
CREATE TABLE cpu_user_1 AS SELECT
host_name,
service_description,
metric_name,
ROUND(AVG(VALUE),2) as avg,
MAX(VALUE) as max,
MIN(VALUE) as min
FROM
cpu_user
GROUP BY
host_name
舊資料取值調整:
CREATE TABLE cpuuser_1 AS SELECT
host_name,
service_description,
metric_name,
AVG(VALUE) as avg,
MAX(VALUE) as max,
MIN(VALUE) as min
FROM
cpuuser
GROUP BY
host_name
SELECT
a.host_name,
b.host_name,
a.service_description,
a.metric_name,
round(a.avg,2),
a.max,
a.min,
b.service_description,
b.metric_name,
round(b.avg*1000,2),
round(b.max*1000,2),
round(b.min*1000,2)
FROM
cpuuser_1 a,
httptime_1 b
where a.host_name = b.host_name
35::
在centreon_storage庫中建立關係表test1
CREATE TABLE test1 AS SELECT
index_data.host_name,
index_data.service_description,
metrics.metric_id,
metrics.metric_name
FROM
index_data,
metrics
WHERE
index_data.id = metrics.index_id;
把data_bin,test1 表的資料轉移到172.25.128.77上面。放到bigdata資料庫中。
cd /var/lib/mysql/centreon_storage
scp -p data_bin.* test1.* 172.*.*.77:/mysql/bigdata
77:
[root@nagiosdb log]# mysql -u root -p123456 --socket=/var/lib/mysql/mysql.sock
要指定一下socket登陸。
drop database bigdata;
create database bigdata;
use bigdata;
repair table test1;
repair table data_bin;
因為是直接複製資料檔案,需要repair表。data_bin需要時間較長。
效能資料:
CREATE TABLE http_time AS SELECT
b.host_name,
b.service_description,
b.metric_name,
a.VALUE,
a.id_metric,
b.metric_id
FROM
data_bin a,
test1 b
WHERE
a.id_metric = b.metric_id
AND a.ctime >= unix_timestamp('2016-04-01')
AND a.ctime < unix_timestamp('2016-05-01')
/*
AND b.metric_name = 'time';
AND b.metric_name = 'CpuUser';
AND b.metric_name = 'phyUsed';
AND b.metric_name LIKE '/%';
*/
AND b.metric_name = 'time';
資料取值調整:
CREATE TABLE http_time_1 AS SELECT
host_name,
service_description,
metric_name,
ROUND(AVG(VALUE)*1000,2) as avg,
ROUND(MAX(VALUE)*1000,2) as max,
ROUND(MIN(VALUE)*1000,2) as min
FROM
http_time
GROUP BY
host_name
drop table cpu_user_1;
flush tables;
CREATE TABLE cpu_user_1 AS SELECT
host_name,
service_description,
metric_name,
ROUND(AVG(VALUE),2) as avg,
MAX(VALUE) as max,
MIN(VALUE) as min
FROM
cpu_user
GROUP BY
host_name
舊資料取值調整:
CREATE TABLE cpuuser_1 AS SELECT
host_name,
service_description,
metric_name,
AVG(VALUE) as avg,
MAX(VALUE) as max,
MIN(VALUE) as min
FROM
cpuuser
GROUP BY
host_name
SELECT
a.host_name,
b.host_name,
a.service_description,
a.metric_name,
round(a.avg,2),
a.max,
a.min,
b.service_description,
b.metric_name,
round(b.avg*1000,2),
round(b.max*1000,2),
round(b.min*1000,2)
FROM
cpuuser_1 a,
httptime_1 b
where a.host_name = b.host_name
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/30936525/viewspace-2097966/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 監控Oracle資料庫效能的指令碼段整理Oracle資料庫指令碼
- 資料庫資料整理資料庫
- 資料庫整理資料庫
- 專案資料整理
- docker 文件資料整理Docker
- HSQLDB資料庫整理SQL資料庫
- JSON資料整理JSON
- BigCouch資料整理GC
- LOCK的整理資料
- Go 學習資料整理Go
- Oracle資料表碎片整理Oracle
- 【java基礎資料整理】Java
- 資料庫事務整理資料庫
- ArcGIS參考資料整理
- iOS 學習資料整理iOS
- swift學習資料整理Swift
- Oracle 資料庫碎片整理Oracle資料庫
- Oracle資料庫碎片整理Oracle資料庫
- 前端效能優化整理前端優化
- 硬碟效能資料硬碟
- Java 資料庫知識整理Java資料庫
- 【整理】資料結構——題目資料結構
- Oracle資料庫表碎片整理Oracle資料庫
- SLAM(一)----學習資料整理SLAM
- STF,docker學習資料整理Docker
- POI3的資料整理
- python迭代器資料整理Python
- SOA相關資料整理分享
- 3.3 資料整理的原則
- iOS 學習資料整理(上)iOS
- 【整理】Hadoop學習資料Hadoop
- Proguard整理一些資料
- Oracle 資料庫碎片整理(zt)Oracle資料庫
- MySQLslowquery[慢查詢]資料整理MySql
- Oracle資料庫碎片整理(轉)Oracle資料庫
- 資料庫升級-物理重新整理資料字典資料庫
- UCI資料集整理(附論文常用資料集)
- SQLServer效能資料解析SQLServer