Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

glpi / Vigilo / VigiloTestSoftware.php @ b204adb9

History | View | Annotate | Download (3.98 KB)

1 a5c9df40 Thibault Louet
<?php
2
3
include 'VigiloSoftwareList.php';
4
5
class VigiloTestSoftware
6
{
7
    protected $testTable;
8
    protected $softwareBase;
9
    protected $computer;
10
    protected $addedTests;
11
12
    public function __construct($computer)
13
    {
14
        $this->computer=$computer;
15
        $this->softwareBase = getSoftwareList($this->computer);
16
        $this->testTable=array();
17
        $this->addedTests=array();
18
    }
19
20
    public function getTable()
21
    {
22
        return $this->testTable;
23
    }
24
25
    public function addRelevantTestWith($softwareName)
26
    {
27 b204adb9 Romain CHOLLET
        if (strstr($softwareName, "vigilo-test"))
28 0e0753c8 Romain CHOLLET
        {
29
            $functionArray=array("addCustomTest", array($softwareName));
30
        }
31
        else 
32
        {
33
            $functionArray=$this->softwareBase[$softwareName];
34
        }
35 a5c9df40 Thibault Louet
        $this->testTable[]=call_user_func_array(array($this,$functionArray[0]), $functionArray[1]);
36
    }
37
38 0e0753c8 Romain CHOLLET
    protected function addCustomTest($softwareName)
39
    {
40 b204adb9 Romain CHOLLET
        $software_name = str_replace('vigilo-test-', '', $softwareName);
41
        $explode_software_name = explode('-', $software_name, 2);
42
        $args=array();
43
        switch($explode_software_name[0])
44
        {
45
            case "process": $args[]=new VigiloArg('processname', $explode_software_name[1]); break;
46
            case "service": $args[]=new VigiloArg('svcname', $explode_software_name[1]); break;
47
            default: return;
48
        }
49
50
        return new VigiloTest(ucfirst($explode_software_name[0]), $args);
51 0e0753c8 Romain CHOLLET
    }
52
53 a5c9df40 Thibault Louet
    protected function addNTPTest()
54
    {
55 0e0753c8 Romain CHOLLET
        $args=array();
56 a5c9df40 Thibault Louet
        //$address=0;
57
        //$args[]=new VigiloArg('address',$address);
58
        $args[]=new VigiloArg('crit', 0);
59
        $args[]=new VigiloArg('warn', 0);
60
        return new VigiloTest('NTP', $args);
61
    }
62
63
    protected function addNTPqTest()
64
    {
65
        $args=array();
66 0e0753c8 Romain CHOLLET
        $args[]=new VigiloArg('crit', 2000);
67
        $args[]=new VigiloArg('warn', 5000);
68 a5c9df40 Thibault Louet
        return new VigiloTest('NTPq', $args);
69
    }
70
71 0e0753c8 Romain CHOLLET
    protected function addNTPSyncTest() // OK
72 a5c9df40 Thibault Louet
    {
73
        return new VigiloTest('NTPSync');
74
    }
75
76 0e0753c8 Romain CHOLLET
    protected function addHTTPTest() // OK
77 a5c9df40 Thibault Louet
    {
78
        return new VigiloTest('HTTP');
79
    }
80
81
    protected function addMemcachedTest($computer)
82
    {
83
        $args=array();
84 0e0753c8 Romain CHOLLET
        $args[]=new VigiloArg('port', 11211);
85 a5c9df40 Thibault Louet
        return new VigiloTest('Memcached', $args);
86
    }
87
88
    protected function addNagiosTest()
89
    {
90
        return new VigiloTest('Nagios');
91
    }
92
93
    protected function addPGSQLTest($computer)
94
    {
95 0e0753c8 Romain CHOLLET
        $args=array();
96
        $args[]=new VigiloArg('database',"postgres");
97
        $args[]=new VigiloArg('port',5432);
98
        $args[]=new VigiloArg('user',"postgres");
99
        return new VigiloTest('PostgreSQLConnection',$args);
100 a5c9df40 Thibault Louet
    }
101
102
    protected function addProxyTest()
103
    {
104 0e0753c8 Romain CHOLLET
        $args=array();
105
        $args[]=new VigiloArg('auth',"False");
106
        $args[]=new VigiloArg('port',8080);
107
        $args[]=new VigiloArg('url',"http://www.google.fr");
108
        return new VigiloTest('Proxy',$args);
109 a5c9df40 Thibault Louet
    }
110
111
    protected function addRRDcachedTest($computer)
112
    {
113 0e0753c8 Romain CHOLLET
        $path="/var/lib/vigilo/connector-metro/rrdcached.sock";
114
        $args=array();
115
        $args[]=new VigiloArg('crit',0);
116
        $args[]=new VigiloArg('path',$path);
117
        $args[]=new VigiloArg('warn',0);
118
        return new VigiloTest('RRDcached',$args);
119 a5c9df40 Thibault Louet
    }
120
121
    protected function addSSHTest()
122
    {
123
        return new VigiloTest('SSH');
124
    }
125
126
    protected function addVigiloConnectorTest($type)
127
    {
128
        $args=array();
129
        $args[]=new VigiloArg('type', $type);
130
        return new VigiloTest('VigiloConnector', $args);
131
    }
132
133
    protected function addVigiloCorrelatorTest()
134
    {
135 0e0753c8 Romain CHOLLET
        $args=array();
136
        //$args[]=new VigiloArg('rules','');
137
        $args[]=new VigiloArg('servicename','vigilo-correlator');
138
        return new VigiloTest('VigiloCorrelator',$args);
139 a5c9df40 Thibault Louet
    }
140
141 b204adb9 Romain CHOLLET
    protected function addTestService($computer, $service)
142 a5c9df40 Thibault Louet
    {
143 0e0753c8 Romain CHOLLET
        $args=array();
144
        $args[]=new VigiloArg('svcname',$service);
145
        return new VigiloTest('Service',$args);
146 a5c9df40 Thibault Louet
    }
147
148
    public function __toString()
149
    {
150
        return $this->child;
151
    }
152
}