MySQL Forums
Forum List  »  Newbie

Re: How convert lines in collums
Posted by: Phillip Ward
Date: June 08, 2016 05:51AM

This is derivable data. Don't store it; calculate it as required.
You should hold a "Warning" threshold and a "Critical" threshold and derive the state of the disk based on those. These thresholds might be held against each record (if they change a lot) or might be held in another, reference table; YMMV.

select  id 
, disk_timestamp ts 
, hostname host 
, diskname disk 
, disk_status stat 
, warning_threshold w_level 
, critical_threshold c_level 

, case 
  when disk_status >= critical_threshold 
  then 'Critical' 
  else 
    case 
    when disk_status >= warning_threshold 
    then 'Warning' 
    else 'OK' 
    end  
  end described 

from tb_disco_windows
order by disk_timestamp ; 

+----+----------+---------+------+------+---------+---------+-----------+ 
| id | ts       | host    | disk | stat | w_level | c_level | described | 
+----+----------+---------+------+------+---------+---------+-----------+ 
|  1 | 00:00:00 | server1 | C    |   40 |      70 |      85 | OK        | 
|  2 | 01:00:00 | server1 | C    |   50 |      70 |      85 | OK        | 
|  3 | 02:00:00 | server1 | C    |   60 |      70 |      85 | OK        | 
|  4 | 03:00:00 | server1 | C    |   70 |      70 |      85 | Warning   | 
|  5 | 04:00:00 | server1 | C    |   80 |      70 |      85 | Warning   | 
|  6 | 05:00:00 | server1 | C    |   90 |      70 |      85 | Critical  | 
|  7 | 06:00:00 | server1 | C    |  100 |      70 |      85 | Critical  | 
+----+----------+---------+------+------+---------+---------+-----------+

Regards, Phill W.

Options: ReplyQuote


Subject
Written By
Posted
Re: How convert lines in collums
June 08, 2016 05:51AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.