Rev 69 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 69 | Rev 71 | ||
---|---|---|---|
Line 1... | Line 1... | ||
1 | <?php /* <ViaThinkSoftSignature> |
1 | <?php /* <ViaThinkSoftSignature> |
2 | jq/ej1RUUthsz1FZirM8duHgne60T2KTbQhO51DfGBEjFOFE85A87oHVBm2AuqjwL |
2 | Tc+nyWiSG99g+rn5Kxz4Qq1U8OIq3W83DIzZN42wndPJit2lZMknPYjt/OUTmtTcv |
3 | 5FpCdrGNPxR0bSOOrVg5Sa7sgg/L2x/c/XltvFiWd5PCp3xX7mH5Q2g3G3IZtRoYB |
3 | u/8ef2+7k7VFr6pzqlVi2lfG9FcRwSl0BSXfs+b5Aw0y4YVdM3k0IE+XJlOmJKhuO |
4 | aNOxv4dadjGHr4tqw2y211Nb9/dsSm0K7+zRXu5jJGki7T6mrVSc0FnYNE+1IL56A |
4 | TrNHq6OCIoA4bJlSOgJ02PSy2LCReAsEQfwfCsQy+j1WAm0Pno8PB/PbBhxGUoO3c |
5 | Pz55VEuqzIhGfpe9W80mzx7j8naQTk9l50sF5MrYNhe7sypVpaqPzdWuvCe2xJ3x2 |
5 | f1O/DbJh17NfcQNzfulUBFYwGx3mBnNg5JqE4H435y/A5irelloX4GgZJjq6YJu8p |
6 | ui1Z1hZ0tNHcGpyqtB2SYj20E7du9q8ApCS530YSLjvOlttnDQOM8FCEiBJMaqo3K |
6 | rzgLCHgaDdAlbypK3YFxlQWmMI8yfUwaaX3DDT276lBeA7TjSj0iwQu1VnSux4vmb |
7 | ZAjRgUeiS8WRwfyIg5FaT+4fojL/zYxW/bbpFeA/5s5IFIGCY6zIt24eaUbryd8tr |
7 | AjHGkoexDa6JG7qHoNGG8LF5JTQ+35f4hcTwUWwkWts5N3yQ+xOP6MzBoL0oFtQZS |
8 | EDa2uj5yDS6Hbg7p+W71kZ393OH8YKcHUEdY3i9ZigkognQfpU427IzqbG8AyQVNc |
8 | s3amlKui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i3pjh2C3kHGe9jUKaBHqjA6CXwmgb+6GccXDuxgeA49UOYEaR8VOU |
16 | 94fg0z0+5mgve7AEQaieINSlDkJAARaYQVQvRrYryMmhjjSYQCXuMjXYu2ZOTvtgy |
17 | QJDK/FN/PsM+lnG5l9IZKuYHbDFvyF6dcwmJCh4ssfhLBuYY5nkmFDlUNCicJnd7t |
17 | wbNfOWPT6EKAyxRiL8X2R6L5kSozABxonkKycrXX6uEel+MwVNs6ymS0czt8skInk |
18 | HOyDK82jw7Eixyx5n7BpB6lSFa2sfTJb6XEDj4mmH7ZdV2z2HZ9qS9BFCz9/BE+Lp |
18 | 8+Q2KxH6PDjYU4iRxtSpCRhwCBC9vgrHGNi+sgx+EN7aU7/bgCN/7ZjxFJYPYn0mR |
19 | pp3dPr/rBMX+r3c4ou/PMuDC+eiGbUy8v53wqUoUdDDJxM1q46fhbrv5zqA64W8OY |
19 | 2rezG9g0sWospPHhMetHf170FQXdS4OCLxIfcqwrGXEIb7nNQl1hXrw2Gg1cFEGtN |
20 | PyEpOkvGBGBLi+yRoclqYAk3mxr/AOyLj2fsUyOavj/i1I7k/F7kuAbHmmEToxsQU |
20 | XJOOeTSszuPBH70JvqH+dRaZB44pyF0pMbcyWD3lJi6DIckzgHQQg/DiIgjLLRX5v |
21 | 78DzGjFPNrLvWoqi2EIsaSJuw+9OhJSUFgBikRiT4TP0OIInaZaDzCvEq4X78x+IK |
21 | g+E81ICL86W+q3sEhbtFc0XEFpOBdB4TRxS02vAZP0pyUPTX1P3YIcguS12E+yzwT |
22 | ICn+us9G5Ay/qnfHeBM1CA8/S+Qc38YTAvA/AHVUEqAgX8yXJG1f6YE8RHM3GHBb9 |
22 | VkeVK2fFuhi03QuBiJIMnBlP7g5MwtMyxjuLcT8P7BTH5GnlLrv0idVO00maYnv9Z |
23 | Q== |
23 | g== |
24 | </ViaThinkSoftSignature> */ ?> |
24 | </ViaThinkSoftSignature> */ ?> |
25 | <?php |
25 | <?php |
26 | 26 | ||
27 | /* |
27 | /* |
28 | * VNag - Nagios Framework for PHP |
28 | * VNag - Nagios Framework for PHP |
29 | * Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com> |
29 | * Developed by Daniel Marschall, ViaThinkSoft <www.viathinksoft.com> |
30 | * Licensed under the terms of the Apache 2.0 license |
30 | * Licensed under the terms of the Apache 2.0 license |
31 | * |
31 | * |
32 | * Revision 2023-09-13 |
32 | * Revision 2023-09-14 |
33 | * |
33 | * |
34 | * Changelog: |
34 | * Changelog: |
35 | * 2023-09-13 1.0 Initial release |
35 | * 2023-09-13 1.0 Initial release |
- | 36 | * 2023-09-14 1.0.1 Executable path is now configurable |
|
36 | */ |
37 | */ |
37 | 38 | ||
38 | declare(ticks=1); |
39 | declare(ticks=1); |
39 | 40 | ||
40 | class MegaRaidCheck extends VNag { |
41 | class MegaRaidCheck extends VNag { |
41 | private $executable = '/opt/MegaRAID/MegaCli/MegaCli64'; // TODO: make configurable (Also with sudo?) |
42 | private $argCmd = null; |
42 | 43 | ||
43 | public function __construct() { |
44 | public function __construct() { |
44 | parent::__construct(); |
45 | parent::__construct(); |
45 | 46 | ||
46 | if ($this->is_http_mode()) { |
47 | if ($this->is_http_mode()) { |
Line 48... | Line 49... | ||
48 | $this->registerExpectedStandardArguments(''); |
49 | $this->registerExpectedStandardArguments(''); |
49 | } else { |
50 | } else { |
50 | $this->registerExpectedStandardArguments('Vhtv'); |
51 | $this->registerExpectedStandardArguments('Vhtv'); |
51 | } |
52 | } |
52 | 53 | ||
- | 54 | $this->addExpectedArgument($this->argCmd = new VNagArgument('E', 'executable', VNagArgument::VALUE_OPTIONAL, 'executable', 'The path to the MegaCli64 executable.', '/opt/MegaRAID/MegaCli/MegaCli64')); |
|
- | 55 | ||
53 | $this->getHelpManager()->setPluginName('vnag_megaraid'); |
56 | $this->getHelpManager()->setPluginName('vnag_megaraid'); |
54 | $this->getHelpManager()->setVersion('1.0'); |
57 | $this->getHelpManager()->setVersion('1.0'); |
55 | $this->getHelpManager()->setShortDescription('This plugin checks the controller and disk status of a MegaRAID controller (using MegaCli64).'); |
58 | $this->getHelpManager()->setShortDescription('This plugin checks the controller and disk status of a MegaRAID controller (using MegaCli64).'); |
56 | $this->getHelpManager()->setCopyright('Copyright (C) 2011-$CURYEAR$ Daniel Marschall, ViaThinkSoft.'); |
59 | $this->getHelpManager()->setCopyright('Copyright (C) 2011-$CURYEAR$ Daniel Marschall, ViaThinkSoft.'); |
57 | $this->getHelpManager()->setSyntax('$SCRIPTNAME$'); |
60 | $this->getHelpManager()->setSyntax('$SCRIPTNAME$'); |
Line 62... | Line 65... | ||
62 | $mock_file = __DIR__.'/status_ld.mock'; |
65 | $mock_file = __DIR__.'/status_ld.mock'; |
63 | 66 | ||
64 | if (file_exists($mock_file)) { |
67 | if (file_exists($mock_file)) { |
65 | $out = explode("\n", file_get_contents($mock_file)); |
68 | $out = explode("\n", file_get_contents($mock_file)); |
66 | } else { |
69 | } else { |
67 | $cmd = escapeshellcmd($this->executable).' -LDInfo -Lall '.escapeshellarg('-a'.$adapter).' -NoLog'; |
70 | $cmd = escapeshellcmd($this->argCmd->getValue()).' -LDInfo -Lall '.escapeshellarg('-a'.$adapter).' -NoLog'; |
68 | $out = array(); |
71 | $out = array(); |
69 | exec($cmd, $out, $ec); |
72 | exec($cmd, $out, $ec); |
70 | 73 | ||
71 | // DEBUG: file_put_contents($mock_file, implode("\n", $out)); |
74 | // DEBUG: file_put_contents($mock_file, implode("\n", $out)); |
72 | } |
75 | } |
Line 112... | Line 115... | ||
112 | $mock_file = __DIR__.'/status_pd.mock'; |
115 | $mock_file = __DIR__.'/status_pd.mock'; |
113 | 116 | ||
114 | if (file_exists($mock_file)) { |
117 | if (file_exists($mock_file)) { |
115 | $out = explode("\n", file_get_contents($mock_file)); |
118 | $out = explode("\n", file_get_contents($mock_file)); |
116 | } else { |
119 | } else { |
117 | $cmd = escapeshellcmd($this->executable).' -PDList '.escapeshellarg('-a'.$adapter).' -NoLog'; |
120 | $cmd = escapeshellcmd($this->argCmd->getValue()).' -PDList '.escapeshellarg('-a'.$adapter).' -NoLog'; |
118 | $out = array(); |
121 | $out = array(); |
119 | exec($cmd, $out, $ec); |
122 | exec($cmd, $out, $ec); |
120 | 123 | ||
121 | // DEBUG: file_put_contents($mock_file, implode("\n", $out)); |
124 | // DEBUG: file_put_contents($mock_file, implode("\n", $out)); |
122 | } |
125 | } |
Line 154... | Line 157... | ||
154 | $mock_file = __DIR__.'/status_battery.mock'; |
157 | $mock_file = __DIR__.'/status_battery.mock'; |
155 | 158 | ||
156 | if (file_exists($mock_file)) { |
159 | if (file_exists($mock_file)) { |
157 | $out = explode("\n", file_get_contents($mock_file)); |
160 | $out = explode("\n", file_get_contents($mock_file)); |
158 | } else { |
161 | } else { |
159 | $cmd = escapeshellcmd($this->executable).' -AdpBbuCmd '.escapeshellarg('-a'.$adapter).' -NoLog'; |
162 | $cmd = escapeshellcmd($this->argCmd->getValue()).' -AdpBbuCmd '.escapeshellarg('-a'.$adapter).' -NoLog'; |
160 | $out = array(); |
163 | $out = array(); |
161 | exec($cmd, $out, $ec); |
164 | exec($cmd, $out, $ec); |
162 | 165 | ||
163 | // DEBUG: file_put_contents($mock_file, implode("\n", $out)); |
166 | // DEBUG: file_put_contents($mock_file, implode("\n", $out)); |
164 | } |
167 | } |