ジョブ投入状況を確認するwebページを作ってみた
手始めに日付とその日に発行したqueueの数の推移
2019y11m20d_002145872.png

dhtmlx

作成はdhtmlxにて行った。

<!DOCUMENT html><html lang="ja"><head><title>qsub usage</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
<link rel="stylesheet" type="text/css" href="codebase/dhtmlx.css"/>
<script src="codebase/dhtmlx.js"></script>
<script>
var timeQueue;
function doOnLoad() {
        timeQueue = new dhtmlXChart({
                        view:"bar",
                        container:"time-queue",
                        value:"#count#",
                        gradient:"falling",
                        color:"#b9a8f9",
                        radius:0,
                        alpha:0.5,
                        border:true,
                        width:70,
                        xAxis:{
                                template:"#day#"
                        },
                        yAxis:{
                                start:0,
                                end:100,
                                step:10,
                                template:function(obj){
                                        return (obj%20?"":obj)
                        }
                        }
        });
        timeQueue.load("timeQueue.php","json");
}
</script>
<body onload="doOnLoad();">
time-queue:
<div id="time-queue" style="width:600px;height:250px;margin:20px;border:1px solid #c0c0c0"></div>
</body></html>

「timeQueue.php」はこんな感じ

<?php
$dsn = 'pgsql:dbname=pbs_datastore host=xxxxxxxxxxxxxxxxx  port=15007';
$user = 'pbspro';
$password = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
 
$dbh = new PDO($dsn, $user, $password);
 
$sql ="SELECT count(ji_jobid) as count,to_char(ji_creattm,'DDTMDy') as day FROM job_hist ";
$sql.="WHERE ji_creattm >= now() - interval '15 day' ";
$sql.="GROUP BY to_char(ji_creattm,'DDTMDy') order by to_char(ji_creattm,'DDTMDy')";
 
$sth = $dbh->prepare($sql);
$sth->execute();
$res = $sth->fetchAll(PDO::FETCH_ASSOC);
 
$result = [];
foreach ( $res as $row ){
    $result[] = $row;
}
 
echo json_encode($result);
?>

queueの利用状況

基本的に job_hist テーブルは、縦型のテーブルで、

queue | count | day |
------+-------+-----+
bio   |     3 | 16土|
chem  |    10 | 16土|

となる。これをdhtmlxのchartでスタック型で表示するには、この縦型を横にするひつようがある。

bio queue| chem queue | day |
---------+------------+-----+
        3|         10 | 16土|

な感じに。

SELECT DAY ,
       SUM(CASE queue when 'bio' then count else NULL END) as "bio queue",
       SUM(CASE queue when 'chem' then count else NULL END) as "chem queue"
FROM
 (SELECT queue,count(queue) as count, to_char(ji_creattm,'DD TMDy') as DAY from job_hist group by queue,to_char(ji_creattm,'DD TMDy')) A
GROUP BY DAY ORDER BY DAY

トップ   編集 添付 複製 名前変更     ヘルプ   最終更新のRSS
Last-modified: 2019-11-27 (水) 02:14:32 (53d)