{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}

-- Derived from AWS service descriptions, licensed under Apache 2.0.

-- |
-- Module      : Amazonka.ElasticBeanstalk.Types.CPUUtilization
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.ElasticBeanstalk.Types.CPUUtilization where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude

-- | CPU utilization metrics for an instance.
--
-- /See:/ 'newCPUUtilization' smart constructor.
data CPUUtilization = CPUUtilization'
  { -- | Available on Linux environments only.
    --
    -- Percentage of time that the CPU has spent in the @SoftIRQ@ state over
    -- the last 10 seconds.
    CPUUtilization -> Maybe Double
softIRQ :: Prelude.Maybe Prelude.Double,
    -- | Percentage of time that the CPU has spent in the @Idle@ state over the
    -- last 10 seconds.
    CPUUtilization -> Maybe Double
idle :: Prelude.Maybe Prelude.Double,
    -- | Available on Linux environments only.
    --
    -- Percentage of time that the CPU has spent in the @IRQ@ state over the
    -- last 10 seconds.
    CPUUtilization -> Maybe Double
irq :: Prelude.Maybe Prelude.Double,
    -- | Available on Linux environments only.
    --
    -- Percentage of time that the CPU has spent in the @System@ state over the
    -- last 10 seconds.
    CPUUtilization -> Maybe Double
system :: Prelude.Maybe Prelude.Double,
    -- | Available on Windows environments only.
    --
    -- Percentage of time that the CPU has spent in the @Privileged@ state over
    -- the last 10 seconds.
    CPUUtilization -> Maybe Double
privileged :: Prelude.Maybe Prelude.Double,
    -- | Percentage of time that the CPU has spent in the @User@ state over the
    -- last 10 seconds.
    CPUUtilization -> Maybe Double
user :: Prelude.Maybe Prelude.Double,
    -- | Available on Linux environments only.
    --
    -- Percentage of time that the CPU has spent in the @I\/O Wait@ state over
    -- the last 10 seconds.
    CPUUtilization -> Maybe Double
iOWait :: Prelude.Maybe Prelude.Double,
    -- | Available on Linux environments only.
    --
    -- Percentage of time that the CPU has spent in the @Nice@ state over the
    -- last 10 seconds.
    CPUUtilization -> Maybe Double
nice :: Prelude.Maybe Prelude.Double
  }
  deriving (CPUUtilization -> CPUUtilization -> Bool
(CPUUtilization -> CPUUtilization -> Bool)
-> (CPUUtilization -> CPUUtilization -> Bool) -> Eq CPUUtilization
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: CPUUtilization -> CPUUtilization -> Bool
$c/= :: CPUUtilization -> CPUUtilization -> Bool
== :: CPUUtilization -> CPUUtilization -> Bool
$c== :: CPUUtilization -> CPUUtilization -> Bool
Prelude.Eq, ReadPrec [CPUUtilization]
ReadPrec CPUUtilization
Int -> ReadS CPUUtilization
ReadS [CPUUtilization]
(Int -> ReadS CPUUtilization)
-> ReadS [CPUUtilization]
-> ReadPrec CPUUtilization
-> ReadPrec [CPUUtilization]
-> Read CPUUtilization
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [CPUUtilization]
$creadListPrec :: ReadPrec [CPUUtilization]
readPrec :: ReadPrec CPUUtilization
$creadPrec :: ReadPrec CPUUtilization
readList :: ReadS [CPUUtilization]
$creadList :: ReadS [CPUUtilization]
readsPrec :: Int -> ReadS CPUUtilization
$creadsPrec :: Int -> ReadS CPUUtilization
Prelude.Read, Int -> CPUUtilization -> ShowS
[CPUUtilization] -> ShowS
CPUUtilization -> String
(Int -> CPUUtilization -> ShowS)
-> (CPUUtilization -> String)
-> ([CPUUtilization] -> ShowS)
-> Show CPUUtilization
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [CPUUtilization] -> ShowS
$cshowList :: [CPUUtilization] -> ShowS
show :: CPUUtilization -> String
$cshow :: CPUUtilization -> String
showsPrec :: Int -> CPUUtilization -> ShowS
$cshowsPrec :: Int -> CPUUtilization -> ShowS
Prelude.Show, (forall x. CPUUtilization -> Rep CPUUtilization x)
-> (forall x. Rep CPUUtilization x -> CPUUtilization)
-> Generic CPUUtilization
forall x. Rep CPUUtilization x -> CPUUtilization
forall x. CPUUtilization -> Rep CPUUtilization x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x. Rep CPUUtilization x -> CPUUtilization
$cfrom :: forall x. CPUUtilization -> Rep CPUUtilization x
Prelude.Generic)

-- |
-- Create a value of 'CPUUtilization' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'softIRQ', 'cPUUtilization_softIRQ' - Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @SoftIRQ@ state over
-- the last 10 seconds.
--
-- 'idle', 'cPUUtilization_idle' - Percentage of time that the CPU has spent in the @Idle@ state over the
-- last 10 seconds.
--
-- 'irq', 'cPUUtilization_irq' - Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @IRQ@ state over the
-- last 10 seconds.
--
-- 'system', 'cPUUtilization_system' - Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @System@ state over the
-- last 10 seconds.
--
-- 'privileged', 'cPUUtilization_privileged' - Available on Windows environments only.
--
-- Percentage of time that the CPU has spent in the @Privileged@ state over
-- the last 10 seconds.
--
-- 'user', 'cPUUtilization_user' - Percentage of time that the CPU has spent in the @User@ state over the
-- last 10 seconds.
--
-- 'iOWait', 'cPUUtilization_iOWait' - Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @I\/O Wait@ state over
-- the last 10 seconds.
--
-- 'nice', 'cPUUtilization_nice' - Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @Nice@ state over the
-- last 10 seconds.
newCPUUtilization ::
  CPUUtilization
newCPUUtilization :: CPUUtilization
newCPUUtilization =
  CPUUtilization' :: Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> CPUUtilization
CPUUtilization'
    { $sel:softIRQ:CPUUtilization' :: Maybe Double
softIRQ = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:idle:CPUUtilization' :: Maybe Double
idle = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:irq:CPUUtilization' :: Maybe Double
irq = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:system:CPUUtilization' :: Maybe Double
system = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:privileged:CPUUtilization' :: Maybe Double
privileged = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:user:CPUUtilization' :: Maybe Double
user = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:iOWait:CPUUtilization' :: Maybe Double
iOWait = Maybe Double
forall a. Maybe a
Prelude.Nothing,
      $sel:nice:CPUUtilization' :: Maybe Double
nice = Maybe Double
forall a. Maybe a
Prelude.Nothing
    }

-- | Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @SoftIRQ@ state over
-- the last 10 seconds.
cPUUtilization_softIRQ :: Lens.Lens' CPUUtilization (Prelude.Maybe Prelude.Double)
cPUUtilization_softIRQ :: (Maybe Double -> f (Maybe Double))
-> CPUUtilization -> f CPUUtilization
cPUUtilization_softIRQ = (CPUUtilization -> Maybe Double)
-> (CPUUtilization -> Maybe Double -> CPUUtilization)
-> Lens CPUUtilization CPUUtilization (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPUUtilization' {Maybe Double
softIRQ :: Maybe Double
$sel:softIRQ:CPUUtilization' :: CPUUtilization -> Maybe Double
softIRQ} -> Maybe Double
softIRQ) (\s :: CPUUtilization
s@CPUUtilization' {} Maybe Double
a -> CPUUtilization
s {$sel:softIRQ:CPUUtilization' :: Maybe Double
softIRQ = Maybe Double
a} :: CPUUtilization)

-- | Percentage of time that the CPU has spent in the @Idle@ state over the
-- last 10 seconds.
cPUUtilization_idle :: Lens.Lens' CPUUtilization (Prelude.Maybe Prelude.Double)
cPUUtilization_idle :: (Maybe Double -> f (Maybe Double))
-> CPUUtilization -> f CPUUtilization
cPUUtilization_idle = (CPUUtilization -> Maybe Double)
-> (CPUUtilization -> Maybe Double -> CPUUtilization)
-> Lens CPUUtilization CPUUtilization (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPUUtilization' {Maybe Double
idle :: Maybe Double
$sel:idle:CPUUtilization' :: CPUUtilization -> Maybe Double
idle} -> Maybe Double
idle) (\s :: CPUUtilization
s@CPUUtilization' {} Maybe Double
a -> CPUUtilization
s {$sel:idle:CPUUtilization' :: Maybe Double
idle = Maybe Double
a} :: CPUUtilization)

-- | Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @IRQ@ state over the
-- last 10 seconds.
cPUUtilization_irq :: Lens.Lens' CPUUtilization (Prelude.Maybe Prelude.Double)
cPUUtilization_irq :: (Maybe Double -> f (Maybe Double))
-> CPUUtilization -> f CPUUtilization
cPUUtilization_irq = (CPUUtilization -> Maybe Double)
-> (CPUUtilization -> Maybe Double -> CPUUtilization)
-> Lens CPUUtilization CPUUtilization (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPUUtilization' {Maybe Double
irq :: Maybe Double
$sel:irq:CPUUtilization' :: CPUUtilization -> Maybe Double
irq} -> Maybe Double
irq) (\s :: CPUUtilization
s@CPUUtilization' {} Maybe Double
a -> CPUUtilization
s {$sel:irq:CPUUtilization' :: Maybe Double
irq = Maybe Double
a} :: CPUUtilization)

-- | Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @System@ state over the
-- last 10 seconds.
cPUUtilization_system :: Lens.Lens' CPUUtilization (Prelude.Maybe Prelude.Double)
cPUUtilization_system :: (Maybe Double -> f (Maybe Double))
-> CPUUtilization -> f CPUUtilization
cPUUtilization_system = (CPUUtilization -> Maybe Double)
-> (CPUUtilization -> Maybe Double -> CPUUtilization)
-> Lens CPUUtilization CPUUtilization (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPUUtilization' {Maybe Double
system :: Maybe Double
$sel:system:CPUUtilization' :: CPUUtilization -> Maybe Double
system} -> Maybe Double
system) (\s :: CPUUtilization
s@CPUUtilization' {} Maybe Double
a -> CPUUtilization
s {$sel:system:CPUUtilization' :: Maybe Double
system = Maybe Double
a} :: CPUUtilization)

-- | Available on Windows environments only.
--
-- Percentage of time that the CPU has spent in the @Privileged@ state over
-- the last 10 seconds.
cPUUtilization_privileged :: Lens.Lens' CPUUtilization (Prelude.Maybe Prelude.Double)
cPUUtilization_privileged :: (Maybe Double -> f (Maybe Double))
-> CPUUtilization -> f CPUUtilization
cPUUtilization_privileged = (CPUUtilization -> Maybe Double)
-> (CPUUtilization -> Maybe Double -> CPUUtilization)
-> Lens CPUUtilization CPUUtilization (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPUUtilization' {Maybe Double
privileged :: Maybe Double
$sel:privileged:CPUUtilization' :: CPUUtilization -> Maybe Double
privileged} -> Maybe Double
privileged) (\s :: CPUUtilization
s@CPUUtilization' {} Maybe Double
a -> CPUUtilization
s {$sel:privileged:CPUUtilization' :: Maybe Double
privileged = Maybe Double
a} :: CPUUtilization)

-- | Percentage of time that the CPU has spent in the @User@ state over the
-- last 10 seconds.
cPUUtilization_user :: Lens.Lens' CPUUtilization (Prelude.Maybe Prelude.Double)
cPUUtilization_user :: (Maybe Double -> f (Maybe Double))
-> CPUUtilization -> f CPUUtilization
cPUUtilization_user = (CPUUtilization -> Maybe Double)
-> (CPUUtilization -> Maybe Double -> CPUUtilization)
-> Lens CPUUtilization CPUUtilization (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPUUtilization' {Maybe Double
user :: Maybe Double
$sel:user:CPUUtilization' :: CPUUtilization -> Maybe Double
user} -> Maybe Double
user) (\s :: CPUUtilization
s@CPUUtilization' {} Maybe Double
a -> CPUUtilization
s {$sel:user:CPUUtilization' :: Maybe Double
user = Maybe Double
a} :: CPUUtilization)

-- | Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @I\/O Wait@ state over
-- the last 10 seconds.
cPUUtilization_iOWait :: Lens.Lens' CPUUtilization (Prelude.Maybe Prelude.Double)
cPUUtilization_iOWait :: (Maybe Double -> f (Maybe Double))
-> CPUUtilization -> f CPUUtilization
cPUUtilization_iOWait = (CPUUtilization -> Maybe Double)
-> (CPUUtilization -> Maybe Double -> CPUUtilization)
-> Lens CPUUtilization CPUUtilization (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPUUtilization' {Maybe Double
iOWait :: Maybe Double
$sel:iOWait:CPUUtilization' :: CPUUtilization -> Maybe Double
iOWait} -> Maybe Double
iOWait) (\s :: CPUUtilization
s@CPUUtilization' {} Maybe Double
a -> CPUUtilization
s {$sel:iOWait:CPUUtilization' :: Maybe Double
iOWait = Maybe Double
a} :: CPUUtilization)

-- | Available on Linux environments only.
--
-- Percentage of time that the CPU has spent in the @Nice@ state over the
-- last 10 seconds.
cPUUtilization_nice :: Lens.Lens' CPUUtilization (Prelude.Maybe Prelude.Double)
cPUUtilization_nice :: (Maybe Double -> f (Maybe Double))
-> CPUUtilization -> f CPUUtilization
cPUUtilization_nice = (CPUUtilization -> Maybe Double)
-> (CPUUtilization -> Maybe Double -> CPUUtilization)
-> Lens CPUUtilization CPUUtilization (Maybe Double) (Maybe Double)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\CPUUtilization' {Maybe Double
nice :: Maybe Double
$sel:nice:CPUUtilization' :: CPUUtilization -> Maybe Double
nice} -> Maybe Double
nice) (\s :: CPUUtilization
s@CPUUtilization' {} Maybe Double
a -> CPUUtilization
s {$sel:nice:CPUUtilization' :: Maybe Double
nice = Maybe Double
a} :: CPUUtilization)

instance Core.FromXML CPUUtilization where
  parseXML :: [Node] -> Either String CPUUtilization
parseXML [Node]
x =
    Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> Maybe Double
-> CPUUtilization
CPUUtilization'
      (Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> Maybe Double
 -> CPUUtilization)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> CPUUtilization)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"SoftIRQ")
      Either
  String
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> CPUUtilization)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> CPUUtilization)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Idle")
      Either
  String
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> CPUUtilization)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> Maybe Double
      -> CPUUtilization)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IRQ")
      Either
  String
  (Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> Maybe Double
   -> CPUUtilization)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double
      -> Maybe Double -> Maybe Double -> Maybe Double -> CPUUtilization)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"System")
      Either
  String
  (Maybe Double
   -> Maybe Double -> Maybe Double -> Maybe Double -> CPUUtilization)
-> Either String (Maybe Double)
-> Either
     String
     (Maybe Double -> Maybe Double -> Maybe Double -> CPUUtilization)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Privileged")
      Either
  String
  (Maybe Double -> Maybe Double -> Maybe Double -> CPUUtilization)
-> Either String (Maybe Double)
-> Either String (Maybe Double -> Maybe Double -> CPUUtilization)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"User")
      Either String (Maybe Double -> Maybe Double -> CPUUtilization)
-> Either String (Maybe Double)
-> Either String (Maybe Double -> CPUUtilization)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"IOWait")
      Either String (Maybe Double -> CPUUtilization)
-> Either String (Maybe Double) -> Either String CPUUtilization
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ([Node]
x [Node] -> Text -> Either String (Maybe Double)
forall a. FromXML a => [Node] -> Text -> Either String (Maybe a)
Core..@? Text
"Nice")

instance Prelude.Hashable CPUUtilization

instance Prelude.NFData CPUUtilization