Rev 89 | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 89 | Rev 90 | ||
---|---|---|---|
Line 19... | Line 19... | ||
19 | 19 | ||
20 | More information on how to develop your plugin, see doc/Plugin_Development.md |
20 | More information on how to develop your plugin, see doc/Plugin_Development.md |
21 | 21 | ||
22 | ****************************************************************************************************/ |
22 | ****************************************************************************************************/ |
23 | 23 | ||
- | 24 | // https://nagios-plugins.org/doc/guidelines.html |
|
- | 25 | // Detected substantial changes between documents of copyright years 2013 and 2018 (HTML fetched on 17 December 2023): |
|
- | 26 | // Section "Performance data": |
|
- | 27 | // 2013: "UOM (unit of measurement) is one of: [s/us/ms, %, B/KB/MB/TB, c]" |
|
- | 28 | // 2018: "UOM (unit of measurement) is a string of zero or more characters, NOT including numbers, semicolons, or quotes. Some examples: [s/us/ms, %, B/KB/MB/TB, c]" |
|
- | 29 | // Section "Perl Plugins": |
|
- | 30 | // 2013: "(these simply do not compile under ePN)." |
|
- | 31 | // 2018: "(these simply do not compile under ePNP." (introduced a typo!) |
|
- | 32 | // Section "Plugin Options": |
|
- | 33 | // 2013: "Code and output should try to respect the 80x25 size of a crt (remember when fixing stuff in the server room!)" |
|
- | 34 | // 2018: "Code and output should try to respect the 80x25 size of a standard terminal." |
|
- | 35 | // Various internal stuff like SourceForge, GitHub, etc., which is not relevant for the plugin interface. |
|
- | 36 | ||
24 | if (!VNag::is_http_mode()) error_reporting(E_ALL); |
37 | if (!VNag::is_http_mode()) error_reporting(E_ALL); |
25 | 38 | ||
26 | # If you want to use -t/--timeout with your module, you must add following line in your module code: |
39 | # If you want to use -t/--timeout with your module, you must add following line in your module code: |
27 | // WONTFIX: declare(ticks=1) is deprecated? http://www.hackingwithphp.com/4/21/0/the-declare-function-and-ticks |
40 | // WONTFIX: declare(ticks=1) is deprecated? http://www.hackingwithphp.com/4/21/0/the-declare-function-and-ticks |
28 | // WONTFIX: check is the main script used declare(ticks=1). (Not possible in PHP) |
41 | // WONTFIX: check is the main script used declare(ticks=1). (Not possible in PHP) |
Line 30... | Line 43... | ||
30 | 43 | ||
31 | # Attention: The -t/--timeout parameter does not respect the built-in set_time_limit() of PHP. |
44 | # Attention: The -t/--timeout parameter does not respect the built-in set_time_limit() of PHP. |
32 | # PHP should set this time limit to infinite. |
45 | # PHP should set this time limit to infinite. |
33 | set_time_limit(0); |
46 | set_time_limit(0); |
34 | 47 | ||
35 | define('VNAG_JSONDATA_V1', 'oid:1.3.6.1.4.1.37476.2.3.1.1'); // {iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 37476 products(2) vnag(3) jsondata(1) v1(1)} |
48 | // {iso(1) identified-organization(3) dod(6) internet(1) private(4) enterprise(1) 37476 products(2) vnag(3) jsondata(1) v1(1)} |
- | 49 | define('VNAG_JSONDATA_V1', 'oid:1.3.6.1.4.1.37476.2.3.1.1'); |
|
36 | 50 | ||
37 | // Set this to an array to overwrite getopt() and $_REQUEST[], respectively. |
51 | // Set this to an array to overwrite getopt() and $_REQUEST[], respectively. |
38 | // Useful for mock tests. |
52 | // Useful for mock tests. |
39 | $OVERWRITE_ARGUMENTS = null; |
53 | $OVERWRITE_ARGUMENTS = null; |
40 | 54 | ||
Line 1029... | Line 1043... | ||
1029 | $try = "/tmp/vnag/cache"; |
1043 | $try = "/tmp/vnag/cache"; |
1030 | if (is_dir($try)) return $try; |
1044 | if (is_dir($try)) return $try; |
1031 | if (@mkdir($try,0777,true)) return $try; |
1045 | if (@mkdir($try,0777,true)) return $try; |
1032 | } |
1046 | } |
1033 | 1047 | ||
1034 | throw new VNagException("Cannot get cache dir"); // TODO: translate and own exception type |
1048 | throw new VNagException(VNagLang::$cannotGetCacheDir); |
1035 | } |
1049 | } |
1036 | 1050 | ||
1037 | // This is not used by the framework itself, but can be useful for a lot of plugins |
1051 | // This is not used by the framework itself, but can be useful for a lot of plugins |
1038 | protected function url_get_contents($url, $max_cache_time=1*60*60, $context=null) { |
1052 | protected function url_get_contents($url, $max_cache_time=1*60*60, $context=null) { |
1039 | $cache_file = $this->get_cache_dir().'/'.hash('sha256',$url); |
1053 | $cache_file = $this->get_cache_dir().'/'.hash('sha256',$url); |
Line 1651... | Line 1665... | ||
1651 | } |
1665 | } |
1652 | 1666 | ||
1653 | public static function isKnownUOM(string $uom) { |
1667 | public static function isKnownUOM(string $uom) { |
1654 | // see https://nagios-plugins.org/doc/guidelines.html#AEN200 |
1668 | // see https://nagios-plugins.org/doc/guidelines.html#AEN200 |
1655 | // 10. UOM (unit of measurement) |
1669 | // 10. UOM (unit of measurement) |
1656 | // Previous definition: |
1670 | // Definition as of 2013: |
1657 | // "[UOM] is one of": (none), s, us, ms, %, B, KB, MB, TB, c |
1671 | // "UOM (unit of measurement) is one of: [s/us/ms, %, B/KB/MB/TB, c]" |
1658 | // New definition, introduced somewhere in 2019: |
1672 | // New definition since 2018: |
1659 | // "[UOM] is one of" was replaced with "Some examples" |
1673 | // "UOM (unit of measurement) is a string of zero or more characters, NOT including numbers, semicolons, or quotes. Some examples: [s/us/ms, %, B/KB/MB/TB, c]" |
1660 | // Added 17 Dec 2023: d, m, h, ns, PB, EB, ZB, YB |
1674 | // Added to VNag on 17 Dec 2023: d, m, h, ns, PB, EB, ZB, YB |
1661 | 1675 | ||
1662 | // no unit specified - assume a number (int or float) of things (eg, users, processes, load averages) |
1676 | // no unit specified - assume a number (int or float) of things (eg, users, processes, load averages) |
1663 | $no_unit = ($uom === ''); |
1677 | $no_unit = ($uom === ''); |
1664 | // s - seconds (also us, ms) |
1678 | // s - seconds (also us, ms) |
1665 | $seconds = ($uom === 'd') || ($uom === 'h') || ($uom === 'm') || ($uom === 's') || ($uom === 'ms') || ($uom === 'us') || ($uom === 'ns'); |
1679 | $seconds = ($uom === 'd') || ($uom === 'h') || ($uom === 'm') || ($uom === 's') || ($uom === 'ms') || ($uom === 'us') || ($uom === 'ns'); |
Line 2251... | Line 2265... | ||
2251 | static $wrong_password = 'This resource is protected with a password. You have provided the wrong password, or it was changed.'; |
2265 | static $wrong_password = 'This resource is protected with a password. You have provided the wrong password, or it was changed.'; |
2252 | static $convert_x_y_error = 'Cannot convert from UOM %s to UOM %s.'; |
2266 | static $convert_x_y_error = 'Cannot convert from UOM %s to UOM %s.'; |
2253 | static $php_error = 'PHP has detected an error in the plugin. Please contact the plugin author.'; |
2267 | static $php_error = 'PHP has detected an error in the plugin. Please contact the plugin author.'; |
2254 | static $output_level_lowered = "Output Buffer level lowered during cbRun(). Please contact the plugin author."; |
2268 | static $output_level_lowered = "Output Buffer level lowered during cbRun(). Please contact the plugin author."; |
2255 | static $openssl_missing = "OpenSSL is missing. Therefore, encryption and signatures are not available."; |
2269 | static $openssl_missing = "OpenSSL is missing. Therefore, encryption and signatures are not available."; |
- | 2270 | static $cannotGetCacheDir = "Cannot get cache dir."; |
|
2256 | 2271 | ||
2257 | // Help texts |
2272 | // Help texts |
2258 | static $warning_range = 'Warning range'; |
2273 | static $warning_range = 'Warning range'; |
2259 | static $critical_range = 'Critical range'; |
2274 | static $critical_range = 'Critical range'; |
2260 | static $prints_version = 'Prints version'; |
2275 | static $prints_version = 'Prints version'; |