Project

General

Profile

Revision ea2027b6

IDea2027b62f03e2d4d5cca84c1a6198f23311fc71
Parent 8d255750
Child 7101a8d8

Added by Francois POIROTTE about 7 years ago

Diverses corrections + seuils pour les HLS

Définit les seuils warning/critical pour les HLS de sorte que chaque HLS
représente effectivement le pire état parmi ses dépendances.

Change-Id: Iac6093a2c41c3cb27ec158aaea6af6b86b10e788
Reviewed-on: https://vigilo-dev.si.c-s.fr/review/2401
Tested-by: Build system <>
Reviewed-by: Francois POIROTTE <>

View differences:

src/plugins/vigilo/Vigilo/VigiloDepends.php
4 4
{
5 5
    protected $host;
6 6
    protected $service;
7
    protected $weight;
8
    protected $warningWeight;
7 9

  
8
    public function __construct($host = null, $service = null)
10
    public function __construct($host = null, $service = null, $weight = 1, $warningWeight = null)
9 11
    {
10 12
        if (null === $host && null === $service) {
11 13
            throw new Exception('Invalid dependency');
12 14
        }
13 15

  
14
        if ('' === $host || '' === $service || !is_string($host) || !is_string($service)) {
16
        if ('' === $host || '' === $service) {
15 17
            throw new Exception('Invalid dependency');
16 18
        }
17 19

  
18
        $this->host     = $host;
19
        $this->service  = $service;
20
        if ((null !== $host && !is_string($host)) ||
21
            (null !== $service && !is_string($service))) {
22
            throw new Exception('Invalid dependency');
23
        }
24

  
25
        if (null !== $host && null !== $warningWeight) {
26
            // L'état "warning" n'existe pas pour les hôtes.
27
            throw new Exception('Invalid dependency');
28
        }
29

  
30
        if (null === $warningWeight) {
31
            $warningWeight = $weight;
32
        }
33

  
34
        $this->host             = $host;
35
        $this->service          = $service;
36
        $this->weight           = (int) $weight;
37
        $this->warningWeight    = (int) $warningWeight;
20 38
    }
21 39

  
22 40
    public function __toString()
23 41
    {
24 42
        if (null === $this->host) {
25
            return "<depends service=\"{$this->service}\"/>";
43
            return  "<depends service=\"{$this->service}\" " .
44
                    "weight=\"{$this->weight}\" " .
45
                    "warning_weight=\"{$this->warningWeight}\"/>";
26 46
        }
27 47

  
28 48
        if (null === $this->service) {
29
            return "<depends host=\"{$this->host}\"/>";
49
            return "<depends host=\"{$this->host}\" weight=\"{$this->weight}\"/>";
30 50
        }
31 51

  
32
        return "<depends host=\"{$this->host}\" service=\"{$this->service}\"/>";
52
        return  "<depends host=\"{$this->host}\" " .
53
                "service=\"{$this->service}\" " .
54
                "weight=\"{$this->weight}\" " .
55
                "warning_weight=\"{$this->warningWeight}\"/>";
33 56
    }
34 57
}

Also available in: Unified diff