added monsetting table, use disable column to indicate if a plugin module is activated or not in the monitoring table. added getDesctiption for monitoring plugins.
git-svn-id: https://svn.code.sf.net/p/xcat/code/xcat-core/trunk@676 8638fb3e-16cb-4fca-ae20-7b5d299a9bcd
This commit is contained in:
parent
48d331cd32
commit
e1bfc4a591
@ -93,14 +93,26 @@ mac => {
|
||||
},
|
||||
},
|
||||
monitoring => {
|
||||
cols => [qw(name nodestatmon settings comments disable)],
|
||||
cols => [qw(name nodestatmon comments disable)],
|
||||
keys => [qw(name)],
|
||||
required => [qw(name)],
|
||||
table_desc => 'Controls what external monitoring tools xCAT sets up and uses. Entries should be added and removed from this table using the provided xCAT commands startmon and stopmon.',
|
||||
descriptions => {
|
||||
name => "The name of the mornitoring plug-in module. The plug-in must be put in $ENV{XCATROOT}/lib/perl/xCAT_monitoring/. See the man page for startmon for details.",
|
||||
nodestatmon => 'Specifies if the monitoring plug-in is used to feed the node status to the xCAT cluster. Any one of the following values indicates "yes": y, Y, yes, Yes, YES, 1. Any other value or blank (default), indicates "no".',
|
||||
settings => 'Specifies the plug-in specific settings. These settings will be used by the plug-in to customize certain entities for the plug-in or the third party monitoring software. It is a comma separated item=value pairs. e.g. mon_interval=10,toggle=1',
|
||||
comments => 'Any user-written notes.',
|
||||
disable => "Set to 'yes' or '1' to comment out this row.",
|
||||
},
|
||||
},
|
||||
monsetting => {
|
||||
cols => [qw(name key value comments disable)],
|
||||
keys => [qw(name key)],
|
||||
required => [qw(name key)],
|
||||
table_desc => 'Specifies the monitoring plug-in specific settings. These settings will be used by the monitoring plug-in to customize the behavior such as event filter, sample interval, responses etc. Entries should be added, removed or modified by chtab command. Entries can also be added or modified by the startmon command when a monitoring plug-in is brought up.',
|
||||
descriptions => {
|
||||
name => "The name of the mornitoring plug-in module. The plug-in must be put in $ENV{XCATROOT}/lib/perl/xCAT_monitoring/. See the man page for startmon for details.",
|
||||
key => 'Specifies the name of the attribute. The valid values are specified by each monitoring plug-in. Use "lsmon name -d" to get a list of valid keys.',
|
||||
value => 'Specifies the value of the attribute.',
|
||||
comments => 'Any user-written notes.',
|
||||
disable => "Set to 'yes' or '1' to comment out this row.",
|
||||
},
|
||||
@ -1178,10 +1190,6 @@ push(@{$defspec{group}->{'attrs'}}, @nodeattrs);
|
||||
tabentry => 'monitoring.nodestatmon',
|
||||
access_tabentry => 'monitoring.name=attr:name',
|
||||
},
|
||||
{attr_name => 'settings',
|
||||
tabentry => 'monitoring.settings',
|
||||
access_tabentry => 'monitoring.name=attr:name',
|
||||
},
|
||||
{attr_name => 'comments',
|
||||
tabentry => 'monitoring.comments',
|
||||
access_tabentry => 'monitoring.name=attr:name',
|
||||
|
@ -527,3 +527,33 @@ sub removeNodes_noChecking {
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 processSettingChanges
|
||||
This function gets called when the setting for this monitoring plugin
|
||||
has been changed in the monsetting table.
|
||||
Arguments:
|
||||
none.
|
||||
Returns:
|
||||
0 for successful.
|
||||
non-0 for not successful.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub processSettingChanges {
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getDiscription
|
||||
This function returns the detailed description of the plugin inluding the
|
||||
valid values for its settings in the monsetting tabel.
|
||||
Arguments:
|
||||
none
|
||||
Returns:
|
||||
The description.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getDescription {
|
||||
return "rmcmon .....
|
||||
Settings:
|
||||
key:\t value.\n";
|
||||
}
|
||||
|
@ -16,9 +16,9 @@ use xCAT::Client;
|
||||
use xCAT_plugin::notification;
|
||||
use xCAT_monitoring::montbhandler;
|
||||
|
||||
#the list store the names of the monitoring plug-in and the file name and module names.
|
||||
#the list stores the names of the monitoring plug-in and the file name and module names.
|
||||
#the names are stored in the "name" column of the monitoring table.
|
||||
#the format is: (name=>[filename, modulename, settings], ...)
|
||||
#the format is: (name=>[filename, modulename], ...)
|
||||
%PRODUCT_LIST;
|
||||
|
||||
#stores the module name and the method that is used for the node status monitoring
|
||||
@ -343,11 +343,10 @@ sub startMonitoring {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
if ($aRef) {
|
||||
my $module_name=$aRef->[1];
|
||||
my $settings=$aRef->[2];
|
||||
|
||||
undef $SIG{CHLD};
|
||||
#initialize and start monitoring
|
||||
my @ret1 = ${$module_name."::"}{start}->($monservers, $settings);
|
||||
my @ret1 = ${$module_name."::"}{start}->($monservers);
|
||||
$ret{$_}=\@ret1;
|
||||
} else {
|
||||
$ret{$_}=[1, "Monitoring plug-in module $_ is not registered."];
|
||||
@ -384,13 +383,12 @@ sub startNodeStatusMonitoring {
|
||||
my $aRef=$PRODUCT_LIST{$pname};
|
||||
if ($aRef) {
|
||||
my $module_name=$aRef->[1];
|
||||
my $settings=$aRef->[2];
|
||||
undef $SIG{CHLD};
|
||||
my $method = ${$module_name."::"}{supportNodeStatusMon}->();
|
||||
# return value 0 means not support. 1 means yes.
|
||||
if ($method > 0) {
|
||||
#start nodes tatus monitoring
|
||||
my @ret2 = ${$module_name."::"}{startNodeStatusMon}->(getMonHierarchy(), $settings);
|
||||
my @ret2 = ${$module_name."::"}{startNodeStatusMon}->(getMonHierarchy());
|
||||
return @ret2;
|
||||
}
|
||||
else {
|
||||
@ -662,10 +660,64 @@ sub processNodelistTableChanges {
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub processMonitoringTableChanges {
|
||||
|
||||
#print "monitorctrl::procesMonitoringTableChanges \n";
|
||||
my $action=shift;
|
||||
if ($action =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$action=shift;
|
||||
}
|
||||
my $tablename=shift;
|
||||
|
||||
if ($tablename eq "monitoring") { sendMonSignal(); return 0; }
|
||||
|
||||
# if nothing is being monitored, do not care.
|
||||
if (!$masterpid) { refreshProductList();}
|
||||
if (keys(%PRODUCT_LIST) ==0) { return 0; }
|
||||
|
||||
my $old_data=shift;
|
||||
my $new_data=shift;
|
||||
|
||||
#foreach (keys %$new_data) {
|
||||
# print "new_data{$_}=$new_data->{$_}\n";
|
||||
#}
|
||||
|
||||
#for (my $j=0; $j<@$old_data; ++$j) {
|
||||
# my $tmp=$old_data->[$j];
|
||||
# print "old_data[". $j . "]= @$tmp \n";
|
||||
#}
|
||||
|
||||
my %namelist=(); #contains the plugin names that get affected by the setting change
|
||||
if ($action eq "a") {
|
||||
if ($new_data) {
|
||||
if (exists($new_data->{name})) {$namelist{$new_data->{name}}=1;}
|
||||
}
|
||||
}
|
||||
elsif (($action eq "d") || (($action eq "u"))) {
|
||||
#find out the index of "node" column
|
||||
if ($old_data->[0]) {
|
||||
$colnames=$old_data->[0];
|
||||
my $name_i=-1;
|
||||
for ($i=0; $i<@$colnames; ++$i) {
|
||||
if ($colnames->[$i] eq "name") {
|
||||
$name_i=$i;
|
||||
last;
|
||||
}
|
||||
}
|
||||
|
||||
for (my $j=1; $j<@$old_data; ++$j) {
|
||||
$namelist{$old_data->[$j]->[$name_i]}=1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print "plugin module setting changed:" . keys(%namelist) . "\n";
|
||||
foreach(keys %namelist) {
|
||||
if (exists($PRODUCT_LIST{$_})) {
|
||||
my $aRef=$PRODUCT_LIST{$_};
|
||||
my $module_name=$aRef->[1];
|
||||
${$module_name."::"}{processSettingChanges}->();
|
||||
}
|
||||
}
|
||||
|
||||
sendMonSignal();
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -774,7 +826,7 @@ sub refreshProductList {
|
||||
#get the monitoring plug-in list from the monitoring table
|
||||
my $table=xCAT::Table->new("monitoring", -create =>1);
|
||||
if ($table) {
|
||||
my @tmp1=$table->getAllAttribs(('name','nodestatmon', 'settings'));
|
||||
my @tmp1=$table->getAllAttribs(('name','nodestatmon'));
|
||||
if (defined(@tmp1) && (@tmp1 > 0)) {
|
||||
foreach(@tmp1) {
|
||||
my $pname=$_->{name};
|
||||
@ -788,14 +840,13 @@ sub refreshProductList {
|
||||
#find out the monitoring plugin file and module name for the product
|
||||
my $file_name="$::XCATROOT/lib/perl/xCAT_monitoring/$pname.pm";
|
||||
my $module_name="xCAT_monitoring::$pname";
|
||||
my $settings=$_->{settings};
|
||||
#load the module in memory
|
||||
eval {require($file_name)};
|
||||
if ($@) {
|
||||
print "The file $file_name cannot be located or has compiling errors.\n";
|
||||
}
|
||||
else {
|
||||
my @a=($file_name, $module_name, $settings);
|
||||
my @a=($file_name, $module_name);
|
||||
$PRODUCT_LIST{$pname}=\@a;
|
||||
}
|
||||
}
|
||||
@ -813,6 +864,42 @@ sub refreshProductList {
|
||||
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getPluginSettings
|
||||
This function goes to the monsetting table to get the settings for a given
|
||||
monitoring plug-in.
|
||||
|
||||
Arguments:
|
||||
name the name of the monitoring plug-in module. such as snmpmon, rmcmon etc.
|
||||
Returns:
|
||||
A hash table containing the key and values of the settings.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getPluginSettings {
|
||||
my $name=shift;
|
||||
if ($name =~ /xCAT_monitoring::monitorctrl/) {
|
||||
$name=shift;
|
||||
}
|
||||
|
||||
%settings=();
|
||||
|
||||
#get the monitoring plug-in list from the monitoring table
|
||||
my $table=xCAT::Table->new("monsetting", -create =>1);
|
||||
if ($table) {
|
||||
my @tmp1=$table->getAllAttribsWhere("name in (\'$name\')", 'key','value');
|
||||
if (defined(@tmp1) && (@tmp1 > 0)) {
|
||||
foreach(@tmp1) {
|
||||
if ($_->{key}) {
|
||||
$settings{$_->{key}}=$_->{value};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return %settings;
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getMonHierarchy
|
||||
It gets the monnitoring server node for all the nodes within nodelist table.
|
||||
@ -997,3 +1084,4 @@ sub nodeStatMonName {
|
||||
|
||||
|
||||
|
||||
|
||||
|
@ -54,7 +54,7 @@ sub regMonitoringNotif {
|
||||
}
|
||||
|
||||
if (!$regged) {
|
||||
xCAT_plugin::notification::regNotification([qw(montbhandler.pm monitoring -o a,u,d)]);
|
||||
xCAT_plugin::notification::regNotification([qw(montbhandler.pm monitoring,monsetting -o a,u,d)]);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -36,7 +36,6 @@ package xCAT_monitoring::templatemon;
|
||||
and each value is a ref to an array of [nodes, nodetype, status] arrays
|
||||
monitored by the server. So the format is:
|
||||
{monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...}
|
||||
settings -- ping-interval=x, x is in number of minutes
|
||||
Returns:
|
||||
(return code, message)
|
||||
=cut
|
||||
@ -46,7 +45,6 @@ sub start {
|
||||
if ($monservers =~ /xCAT_monitoring::templatemon/) {
|
||||
$monservers=shift;
|
||||
}
|
||||
my $setting=shift;
|
||||
|
||||
#demo how you can parse the input. you may commnet it out.
|
||||
my $monservers=shift;
|
||||
@ -116,7 +114,6 @@ sub supportNodeStatusMon {
|
||||
and each value is a ref to an array of [nodes, nodetype, status] arrays
|
||||
monitored by the server. So the format is:
|
||||
{monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...}
|
||||
settings -- ping-interval=x, x is in number of minutes
|
||||
Returns:
|
||||
(return code, message)
|
||||
|
||||
@ -127,7 +124,6 @@ sub startNodeStatusMon {
|
||||
if ($monservers =~ /xCAT_monitoring::templatemon/) {
|
||||
$monservers=shift;
|
||||
}
|
||||
my $setting=shift;
|
||||
|
||||
#demo how you can parse the input. you may commnet it out.
|
||||
my $monservers=shift;
|
||||
@ -229,3 +225,35 @@ sub removeNodes {
|
||||
}
|
||||
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 processSettingChanges
|
||||
This function gets called when the setting for this monitoring plugin
|
||||
has been changed in the monsetting table.
|
||||
Arguments:
|
||||
none.
|
||||
Returns:
|
||||
0 for successful.
|
||||
non-0 for not successful.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub processSettingChanges {
|
||||
#get latest settings for this plugin and do something about it
|
||||
my %settings=xCAT_monitoring::monitorctrl->getPluginSettings("xcatmon");
|
||||
return 0;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getDiscription
|
||||
This function returns the detailed description of the plugin inluding the
|
||||
valid values for its settings in the monsetting tabel.
|
||||
Arguments:
|
||||
none
|
||||
Returns:
|
||||
The description.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getDescription {
|
||||
return "templatemon description goes here.
|
||||
Settings:
|
||||
key: \texlaination. default value etc.\n";
|
||||
}
|
||||
|
@ -294,3 +294,34 @@ sub removeNodes {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 processSettingChanges
|
||||
This function gets called when the setting for this monitoring plugin
|
||||
has been changed in the monsetting table.
|
||||
Arguments:
|
||||
none.
|
||||
Returns:
|
||||
0 for successful.
|
||||
non-0 for not successful.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub processSettingChanges {
|
||||
return 0;
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getDiscription
|
||||
This function returns the detailed description of the plugin inluding the
|
||||
valid values for its settings in the monsetting tabel.
|
||||
Arguments:
|
||||
none
|
||||
Returns:
|
||||
The description.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getDescription {
|
||||
return "snmpmon sets up the snmptrapd on the management server to receive SNMP traps for different nodes. It also sets the trap destination for Blade Center Managment Module, RSA II, IPMIs that are managed by the xCAT cluster. By default, the xCAT trap handler will log all events in the syslog and only email the critial and the warning events to the mail aliance called 'alerts'. You can use the settings to override the default behavior. Use command 'startmon snmpmon' to star monitoring and 'stopmon snmpmon' to stop it. The SNMP trap handler is disabled on the service node.
|
||||
Settings:
|
||||
ignore:\t specifies the events that will be ignored. It's a comma separated pairs of oid=value. For example, BLADESPPALT-MIB::spTrapAppType=4,BLADESPPALT-MIB::spTrapAppType=4.
|
||||
emailrsp:\t specifies the events that will get email notification.\n"
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ use Sys::Hostname;
|
||||
and each value is a ref to an array of [nodes, nodetype, status] arrays
|
||||
monitored by the server. So the format is:
|
||||
{monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...}
|
||||
settings -- ping-interval=x, x is in number of minutes
|
||||
Returns:
|
||||
(return code, message)
|
||||
=cut
|
||||
@ -90,7 +89,6 @@ sub supportNodeStatusMon {
|
||||
and each value is a ref to an array of [nodes, nodetype, status] arrays
|
||||
monitored by the server. So the format is:
|
||||
{monserver1=>[['node1', 'osi', 'active'], ['node2', 'switch', 'booting']...], ...}
|
||||
settings -- ping-interval=x, x is in number of minutes
|
||||
Returns:
|
||||
(return code, message)
|
||||
|
||||
@ -101,7 +99,6 @@ sub startNodeStatusMon {
|
||||
if ($temp =~ /xCAT_monitoring::xcatmon/) {
|
||||
$temp=shift;
|
||||
}
|
||||
my $setting=shift;
|
||||
|
||||
#print "xcatmon.startNodeStatusMon\n";
|
||||
|
||||
@ -113,12 +110,16 @@ sub startNodeStatusMon {
|
||||
#}
|
||||
|
||||
#figure out the ping-intercal setting
|
||||
my $value=3;
|
||||
if ($setting) {
|
||||
if ($setting =~ /ping-interval=(\d+)/) { $value= ($1>0) ? $1 : 3; }
|
||||
}
|
||||
my $value=3; #default
|
||||
my %settings=xCAT_monitoring::monitorctrl->getPluginSettings("xcatmon");
|
||||
|
||||
|
||||
#print "settings for xcatmon:\n";
|
||||
#foreach (keys(%settings)) {
|
||||
# print "key=$_, value=$settings{$_}\n";
|
||||
#}
|
||||
my $reading=$settings{'ping-interval'};
|
||||
if ($reading>0) { $value=$reading;}
|
||||
|
||||
#create the cron job, it will run the command every 3 minutes.
|
||||
my $newentry="*/$value * * * * XCATROOT=$::XCATROOT $cmd";
|
||||
my ($code, $msg)=xCAT::Utils::add_cron_job($newentry);
|
||||
@ -249,3 +250,36 @@ sub processNodeStatusChanges {
|
||||
}
|
||||
return xCAT_monitoring::monitorctrl->processNodeStatusChanges($temp);
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 processSettingChanges
|
||||
This function gets called when the setting for this monitoring plugin
|
||||
has been changed in the monsetting table.
|
||||
Arguments:
|
||||
none.
|
||||
Returns:
|
||||
0 for successful.
|
||||
non-0 for not successful.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub processSettingChanges {
|
||||
#restart the cron job
|
||||
xCAT_monitoring::xcatmon->stopNodeStatusMon();
|
||||
xCAT_monitoring::xcatmon->startNodeStatusMon();
|
||||
}
|
||||
|
||||
#--------------------------------------------------------------------------------
|
||||
=head3 getDiscription
|
||||
This function returns the detailed description of the plugin inluding the
|
||||
valid values for its settings in the mon setting tabel.
|
||||
Arguments:
|
||||
none
|
||||
Returns:
|
||||
The description.
|
||||
=cut
|
||||
#--------------------------------------------------------------------------------
|
||||
sub getDescription {
|
||||
return "xcatmon uses fping to report the node liveness status and update the nodelist.status column. Use command 'startmon xcatmon -n' to start monitoring.
|
||||
Settings:
|
||||
ping-interval\t the number of minutes between each fping operation. The default value is 3.";
|
||||
}
|
||||
|
@ -224,7 +224,7 @@ sub startmon {
|
||||
if ($::NODESTATMON) {
|
||||
$nstat='Y';
|
||||
}
|
||||
my %tb_cols=(nodestatmon=>$nstat);
|
||||
my %tb_cols=(nodestatmon=>$nstat, disable=>"0");
|
||||
if ($settings) {
|
||||
$tb_cols{settings}=$settings;
|
||||
}
|
||||
@ -337,13 +337,15 @@ sub stopmon {
|
||||
(my $ref) = $table->getAttribs({name => $pname}, name);
|
||||
if ($ref and $ref->{name}) {
|
||||
my %key_col = (name=>$pname);
|
||||
$table->delEntries(\%key_col);
|
||||
}
|
||||
my %tb_cols=(disable=>"1");
|
||||
$table->setAttribs(\%key_col, \%tb_cols);
|
||||
}
|
||||
else {
|
||||
my %rsp;
|
||||
$rsp->{data}->[0]="$pname is not registered in the monitoring table.";
|
||||
$rsp->{data}->[0]="$pname was not registered or not enabled.";
|
||||
$callback->($rsp);
|
||||
}
|
||||
}
|
||||
$table->close();
|
||||
}
|
||||
|
||||
my %rsp1;
|
||||
|
Loading…
Reference in New Issue
Block a user