Project

General

Profile

Statistics
| Branch: | Tag: | Revision:

glpi / Vigilo / VigiloTestSoftware.php @ b204adb9

History | View | Annotate | Download (3.98 KB)

1
<?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
        if (strstr($softwareName, "vigilo-test"))
28
        {
29
            $functionArray=array("addCustomTest", array($softwareName));
30
        }
31
        else 
32
        {
33
            $functionArray=$this->softwareBase[$softwareName];
34
        }
35
        $this->testTable[]=call_user_func_array(array($this,$functionArray[0]), $functionArray[1]);
36
    }
37

    
38
    protected function addCustomTest($softwareName)
39
    {
40
        $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
    }
52

    
53
    protected function addNTPTest()
54
    {
55
        $args=array();
56
        //$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
        $args[]=new VigiloArg('crit', 2000);
67
        $args[]=new VigiloArg('warn', 5000);
68
        return new VigiloTest('NTPq', $args);
69
    }
70

    
71
    protected function addNTPSyncTest() // OK
72
    {
73
        return new VigiloTest('NTPSync');
74
    }
75

    
76
    protected function addHTTPTest() // OK
77
    {
78
        return new VigiloTest('HTTP');
79
    }
80

    
81
    protected function addMemcachedTest($computer)
82
    {
83
        $args=array();
84
        $args[]=new VigiloArg('port', 11211);
85
        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
        $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
    }
101

    
102
    protected function addProxyTest()
103
    {
104
        $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
    }
110

    
111
    protected function addRRDcachedTest($computer)
112
    {
113
        $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
    }
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
        $args=array();
136
        //$args[]=new VigiloArg('rules','');
137
        $args[]=new VigiloArg('servicename','vigilo-correlator');
138
        return new VigiloTest('VigiloCorrelator',$args);
139
    }
140

    
141
    protected function addTestService($computer, $service)
142
    {
143
        $args=array();
144
        $args[]=new VigiloArg('svcname',$service);
145
        return new VigiloTest('Service',$args);
146
    }
147

    
148
    public function __toString()
149
    {
150
        return $this->child;
151
    }
152
}