Add alert modules, queue and status

This commit is contained in:
felix.suarez 2023-09-04 08:46:24 -06:00
parent d006028ce9
commit 85462b3aae
3 changed files with 66 additions and 0 deletions

View File

@ -316,6 +316,8 @@ class Diagnostics extends Wizard
* Graph of the Free Disk Spool Dir module.
* Graph of the Free RAM module.
* Graph of the Queued Modules module.
* Graph of the Queued_Alerts.
* Graph of the Alert_Server_Status.
* Graph of the Status module.
* Graph of the System Load AVG module.
* Graph of the Execution Time module.
@ -366,6 +368,20 @@ class Diagnostics extends Wizard
'nameModule' => 'Queued_Modules',
'idAgent' => $agentIdMasterServer,
],
'chartQueuedAlerts' => [
'title' => __(
'Graph of the Queued Alerts total.'
),
'nameModule' => 'Queued_Alerts',
'idAgent' => $agentIdMasterServer,
],
'chartAlertServerStatus' => [
'title' => __(
'Graph of the Alert Server Status.'
),
'nameModule' => 'Alert_Server_Status',
'idAgent' => $agentIdMasterServer,
],
'chartStatus' => [
'title' => __('Graph of the Status module.'),
'nameModule' => 'Status',

View File

@ -8,6 +8,7 @@ use POSIX qw(strftime);
use PandoraFMS::DB;
use constant DATASERVER => 0;
use constant ALERTSERVER => 21;
use Scalar::Util qw(looks_like_number);
@ -159,6 +160,18 @@ sub pandora_self_monitoring ($$) {
if (!defined($queued_modules)) {
$queued_modules = 0;
}
my $queued_alerts = get_db_value ($dbh, "SELECT count(id) FROM talert_execution_queue");
if (!defined($queued_alerts)) {
$queued_alerts = 0;
}
my $alert_server_status = get_db_value ($dbh, "SELECT status FROM tserver WHERE server_type = ?", ALERTSERVER);
if (!defined($alert_server_status || $alert_server_status eq "") ) {
$alert_server_status = 0;
}
my $dbmaintance;
if ($RDBMS eq 'postgresql') {
@ -193,7 +206,19 @@ sub pandora_self_monitoring ($$) {
$xml_output .=" <type>generic_data</type>\n";
$xml_output .=" <data>$queued_modules</data>\n";
$xml_output .=" </module>\n";
$xml_output .=" <module>\n";
$xml_output .=" <name>Queued_Alerts</name>\n";
$xml_output .=" <type>generic_data</type>\n";
$xml_output .=" <data>$queued_alerts</data>\n";
$xml_output .=" </module>\n";
$xml_output .=" <module>\n";
$xml_output .=" <name>Alert_Server_Status</name>\n";
$xml_output .=" <type>generic_proc</type>\n";
$xml_output .=" <data>$alert_server_status</data>\n";
$xml_output .=" </module>\n";
$xml_output .=" <module>\n";
$xml_output .=" <name>Agents_Unknown</name>\n";
$xml_output .=" <type>generic_data</type>\n";

View File

@ -127,6 +127,7 @@ use JSON qw(decode_json encode_json);
use MIME::Base64;
use Text::ParseWords;
use Math::Trig; # Math functions
use constant ALERTSERVER => 21;
# Debugging
#use Data::Dumper;
@ -6126,6 +6127,18 @@ sub pandora_self_monitoring ($$) {
if (!defined($queued_modules)) {
$queued_modules = 0;
}
my $queued_alerts = get_db_value ($dbh, "SELECT count(id) FROM talert_execution_queue");
if (!defined($queued_alerts)) {
$queued_alerts = 0;
}
my $alert_server_status = get_db_value ($dbh, "SELECT status FROM tserver WHERE server_type = ?", ALERTSERVER);
if (!defined($alert_server_status) || $alert_server_status eq "") {
$alert_server_status = 0;
}
my $pandoradb = 0;
my $pandoradb_tstamp = get_db_value ($dbh, "SELECT `value` FROM tconfig WHERE token = 'db_maintance'");
@ -6152,6 +6165,18 @@ sub pandora_self_monitoring ($$) {
$xml_output .=" <type>generic_data</type>";
$xml_output .=" <data>$queued_modules</data>";
$xml_output .=" </module>";
$xml_output .=" <module>\n";
$xml_output .=" <name>Queued_Alerts</name>\n";
$xml_output .=" <type>generic_data</type>\n";
$xml_output .=" <data>$queued_alerts</data>\n";
$xml_output .=" </module>\n";
$xml_output .=" <module>\n";
$xml_output .=" <name>Alert_Server_Status</name>\n";
$xml_output .=" <type>generic_proc</type>\n";
$xml_output .=" <data>$alert_server_status</data>\n";
$xml_output .=" </module>\n";
$xml_output .=" <module>";
$xml_output .=" <name>Agents_Unknown</name>";