From: Eric Bollengier Date: Thu, 17 Aug 2006 17:42:43 +0000 (+0000) Subject: ebl Add volume/pool usage X-Git-Tag: Release-2.0.0~609 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=1603b0b6468a4f1629cba46a09049eb76e8d9eed;p=bacula%2Fbacula ebl Add volume/pool usage git-svn-id: https://bacula.svn.sourceforge.net/svnroot/bacula/trunk@3296 91ce42f0-d328-0410-95d8-f526ca767f89 --- diff --git a/gui/bweb/html/bweb.css b/gui/bweb/html/bweb.css index 72abfc7d0c..3864a62b81 100644 --- a/gui/bweb/html/bweb.css +++ b/gui/bweb/html/bweb.css @@ -11,7 +11,10 @@ button.formulaire { border: 0px; font-size: 9; background-color: transparent; } td.joberr { background-color: red; font-color: white;} -.pSlice, .pSliceFull, .pSliceError, .pSliceAppend, .pSlicePurged, .pSliceRecycle, pSliceArchive, pSliceUsed, pSliceRead_Only, pSliceDisabled { +.pSlice, .pSliceFull, .pSliceError, .pSliceAppend, .pSlicePurged, .pSliceRecycle, +.pSliceArchive, .pSliceUsed, .pSliceRead_Only, .pSliceDisabled, +.pSliceOk,.pSliceWarn,.pSliceCrit,.pSliceEmpty + { width: 2px; height: 9px; margin-right: 1px; @@ -20,7 +23,8 @@ td.joberr { background-color: red; font-color: white;} background-color: #E6E6E6; } -.pSliceFull, pSliceRead_Only,pSliceArchive, pSliceUsed, pSliceDisabled { +.pSliceFull, .pSliceRead_Only,.pSliceArchive, .pSliceUsed, .pSliceDisabled, +.pSliceCrit { border: solid 1px #BD0C10; background-color: #FF3029; } @@ -30,12 +34,12 @@ td.joberr { background-color: red; font-color: white;} background-color: #020202; } -.pSliceAppend { +.pSliceAppend, .pSliceWarn { border: solid 1px #CD6500; background-color: #FFCE00; } -.pSlicePurged, .pSliceRecycle { +.pSlicePurged, .pSliceRecycle, .pSliceOk { border: solid 1px #009900; background-color: #00FF00; } diff --git a/gui/bweb/html/bweb.js b/gui/bweb/html/bweb.js index e92340ccf9..80edc562c9 100644 --- a/gui/bweb/html/bweb.js +++ b/gui/bweb/html/bweb.js @@ -74,11 +74,18 @@ function percent_get_img(type) return img; } -function percent_display(parent, hash_values) +var percent_display_nb_slice = 20; +var percent_usage_nb_slice = 5; + +function percent_display(hash_values, parent) { - var nb_elt=20; + var nb_elt=percent_display_nb_slice; var tips= ""; + if (!parent) { + parent = document.createElement('DIV'); + } + if (typeof parent != "object") { parent = document.getElementById(parent); } @@ -122,4 +129,53 @@ function percent_display(parent, hash_values) parent.title = tips; + return parent; +} + +function percent_usage(value, parent) +{ + var nb_elt=percent_usage_nb_slice; + var type; + + if (!parent) { + parent = document.createElement('DIV'); + } + + if (typeof parent != "object") { + parent = document.getElementById(parent); + } + + if (!parent) { + alert("E : display_percent(): Can't find parent " + parent); + return; + } + + if (value <= 0) { + type = "Empty"; + value = 0; + } else if (value <= 40) { + type = "Ok"; + } else if (value <= 75) { + type = "Warn"; + } else if (value <= 85) { + type = "Crit"; + } else { + type = "Crit"; + } + + var nb = parseInt(value*nb_elt/100, 10); + parent.title = parseInt(value*100,10)/100 + "% used (approximate)"; + + for(var i=0; iget_limit(%arg); my $query = " -SELECT - (SELECT count(Pool.PoolId) FROM Pool) AS nb_pool, - (SELECT count(Media.MediaId) FROM Media) AS nb_media, +SELECT + (SELECT count(Pool.PoolId) FROM Pool) AS nb_pool, + (SELECT count(Media.MediaId) FROM Media) AS nb_media, (SELECT count(Job.JobId) FROM Job) AS nb_job, (SELECT sum(VolBytes) FROM Media) AS nb_bytes, - (SELECT count(Job.JobId) + (SELECT count(Job.JobId) FROM Job WHERE Job.JobStatus IN ('E','e','f','A') $limit - ) AS nb_err, + ) AS nb_err, (SELECT count(Client.ClientId) FROM Client) AS nb_client "; @@ -1895,19 +1895,28 @@ sub display_media } my $query=" -SELECT Media.VolumeName AS volumename, - Media.VolBytes AS volbytes, - Media.VolStatus AS volstatus, - Media.MediaType AS mediatype, - Media.InChanger AS online, +SELECT Media.VolumeName AS volumename, + Media.VolBytes AS volbytes, + Media.VolStatus AS volstatus, + Media.MediaType AS mediatype, + Media.InChanger AS online, Media.LastWritten AS lastwritten, Location.Location AS location, + (volbytes*100/COALESCE(media_avg_size.size,-1)) AS volusage, Pool.Name AS poolname, $self->{sql}->{FROM_UNIXTIME}( $self->{sql}->{UNIX_TIMESTAMP}(Media.LastWritten) + $self->{sql}->{TO_SEC}(Media.VolRetention) ) AS expire -FROM Pool, Media LEFT JOIN Location ON (Media.LocationId = Location.LocationId) +FROM Pool, Media +LEFT JOIN Location ON (Media.LocationId = Location.LocationId) +LEFT JOIN (SELECT avg(Media.VolBytes) AS size, + Media.MediaType AS MediaType + FROM Media + WHERE Media.VolStatus = 'Full' + GROUP BY Media.MediaType + ) AS media_avg_size ON (Media.MediaType = media_avg_size.MediaType) + WHERE Media.PoolId=Pool.PoolId $where "; @@ -1963,6 +1972,8 @@ SELECT InChanger AS online, Media.Recycle AS recycle, Media.VolRetention AS volretention, Media.LastWritten AS lastwritten, + Media.VolReadTime/100000 AS volreadtime, + Media.VolWriteTime/100000 AS volwritetime, $self->{sql}->{FROM_UNIXTIME}( $self->{sql}->{UNIX_TIMESTAMP}(Media.LastWritten) + $self->{sql}->{TO_SEC}(Media.VolRetention) @@ -1979,6 +1990,8 @@ SELECT InChanger AS online, $media->{nb_bytes} = human_size($media->{nb_bytes}) ; $media->{voluseduration} = human_sec($media->{voluseduration}); $media->{volretention} = human_sec($media->{volretention}); + $media->{volreadtime} = human_sec($media->{volreadtime}); + $media->{volwritetime} = human_sec($media->{volwritetime}); my $mq = $self->dbh_quote($media->{volumename}); $query = " @@ -2128,6 +2141,25 @@ sub update_location "update_location.tpl"); } +sub get_media_max_size +{ + my ($self, $type) = @_; + my $query = +"SELECT avg(VolBytes) AS size + FROM Media + WHERE Media.VolStatus = 'Full' + AND Media.MediaType = '$type' +"; + + my $res = $self->selectrow_hashref($query); + + if ($res) { + return $res->{size}; + } else { + return 0; + } +} + sub do_update_media { my ($self) = @_ ; @@ -2354,34 +2386,56 @@ sub display_pool # TODO : afficher les tailles et les dates my $query = " -SELECT Pool.Name AS name, - Pool.Recycle AS recycle, - Pool.VolRetention AS volretention, +SELECT sum(subq.volmax) AS volmax, + sum(subq.volnum) AS volnum, + sum(subq.voltotal) AS voltotal, + Pool.Name AS name, + Pool.Recycle AS recycle, + Pool.VolRetention AS volretention, Pool.VolUseDuration AS voluseduration, - Pool.MaxVolJobs AS maxvoljobs, - Pool.MaxVolFiles AS maxvolfiles, - Pool.MaxVolBytes AS maxvolbytes, - Pool.PoolId AS poolid, - (SELECT count(Media.MediaId) - FROM Media - WHERE Media.PoolId = Pool.PoolId - ) AS volnum - FROM Pool -"; + Pool.MaxVolJobs AS maxvoljobs, + Pool.MaxVolFiles AS maxvolfiles, + Pool.MaxVolBytes AS maxvolbytes, + subq.PoolId AS PoolId +FROM + ( + SELECT COALESCE(media_avg_size.volavg,0) * count(Media.MediaId) AS volmax, + count(Media.MediaId) AS volnum, + sum(Media.VolBytes) AS voltotal, + Media.PoolId AS PoolId, + Media.MediaType AS MediaType + FROM Media + LEFT JOIN (SELECT avg(Media.VolBytes) AS volavg, + Media.MediaType AS MediaType + FROM Media + WHERE Media.VolStatus = 'Full' + GROUP BY Media.MediaType + ) AS media_avg_size ON (Media.MediaType = media_avg_size.MediaType) + GROUP BY Media.MediaType, Media.PoolId + ) AS subq +INNER JOIN Pool ON (Pool.PoolId = subq.PoolId) +GROUP BY subq.PoolId +"; my $all = $self->dbh_selectall_hashref($query, 'name') ; + foreach my $p (values %$all) { $p->{maxvolbytes} = human_size($p->{maxvolbytes}) ; $p->{volretention} = human_sec($p->{volretention}) ; $p->{voluseduration} = human_sec($p->{voluseduration}) ; + if ($p->{volmax}) { + $p->{poolusage} = sprintf('%.2f', $p->{voltotal} * 100/ $p->{volmax}) ; + } else { + $p->{poolusage} = 0; + } + $query = " - SELECT VolStatus AS volstatus, count(MediaId) AS nb + SELECT VolStatus AS volstatus, count(MediaId) AS nb FROM Media WHERE PoolId=$p->{poolid} GROUP BY VolStatus "; - my $content = $self->dbh_selectall_hashref($query, 'volstatus'); foreach my $t (values %$content) { $p->{"nb_" . $t->{volstatus}} = $t->{nb} ; diff --git a/gui/bweb/tpl/display_media.tpl b/gui/bweb/tpl/display_media.tpl index c99db5febd..16aca4ff9a 100644 --- a/gui/bweb/tpl/display_media.tpl +++ b/gui/bweb/tpl/display_media.tpl @@ -34,15 +34,18 @@ Location :