pfsense-nagios-checks/check_pf_version

37 lines
1.2 KiB
Plaintext
Raw Permalink Normal View History

2017-12-15 18:18:33 +01:00
#!/usr/local/bin/php -f
<?
# This check pulls the version from the website and compares it
# to the installed version.
# Many thanks to Atadilo for fixing the code and simplifying it.
# Created 15 Dec 2017
2020-05-12 23:00:15 +02:00
# Modified 12 May 2020
2019-03-11 11:27:48 +01:00
require_once("pkg-utils.inc");
global $g;
if (file_exists("{$g['varrun_path']}/pkg.dirty")) {
$system_pkg_version = get_system_pkg_version(false,false);
} else {
shell_exec("sudo touch "."{$g['varrun_path']}/pkg.dirty");
$system_pkg_version = get_system_pkg_version(false,false);
shell_exec("sudo rm " . "{$g['varrun_path']}/pkg.dirty");
}
2017-12-15 18:18:33 +01:00
$current_installed_buildtime = trim(file_get_contents("/etc/version.buildtime"));
2019-03-11 11:27:48 +01:00
if ( $system_pkg_version['installed_version'] !== $system_pkg_version['version']) {
$additional_info = "WARNING - new version available\n" ; $exitcode = 1;
} else {
$additional_info = "OK - already at latest version\n" ; $exitcode = 0;
2017-12-15 18:18:33 +01:00
}
2019-03-11 11:27:48 +01:00
$additional_info .= "Current version: ".$system_pkg_version['installed_version']."\n";
$additional_info .= "Built on: ".$current_installed_buildtime."\n";
$additional_info .= "Remote version: ".$system_pkg_version['version']."\n";
2017-12-15 18:18:33 +01:00
echo $additional_info;
exit ($exitcode);
?>