Merge branch '3000-lost-in-stash' into 'develop'
ondemand pluginTools, pandora_df inodes, cde functions_api cluster options See merge request artica/pandorafms!1919
This commit is contained in:
commit
62b27284aa
|
@ -25,12 +25,33 @@
|
|||
###############################################################################
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
# Retrieve information from all filesystems
|
||||
my $all_filesystems = 0;
|
||||
|
||||
# Regex flag
|
||||
my $regex_mode = 0;
|
||||
my $inode_mode = 0;
|
||||
|
||||
# Exclusion
|
||||
my @exclude_fs = ();
|
||||
my $cmd = undef;
|
||||
|
||||
|
||||
sub in_array {
|
||||
my ($array, $value) = @_;
|
||||
|
||||
if (!defined($value)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
my %params = map { $_ => 1 } @{$array};
|
||||
if (exists($params{$value})) {
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
sub check_re($$){
|
||||
my $item = shift;
|
||||
|
@ -65,10 +86,24 @@ if ($#ARGV < 0) {
|
|||
$all_filesystems = 1;
|
||||
}
|
||||
|
||||
# Check if regex mode is enabled
|
||||
if ($ARGV[0] eq "-r") {
|
||||
$regex_mode = 1;
|
||||
shift @ARGV;
|
||||
while ($#ARGV >= 0) {
|
||||
my $param = shift @ARGV;
|
||||
if ($param eq '-r') {
|
||||
$regex_mode = 1;
|
||||
shift @ARGV;
|
||||
}
|
||||
elsif ($param eq '-i') {
|
||||
$inode_mode = 1;
|
||||
}
|
||||
elsif ($param eq '-exclude_fs') {
|
||||
my $_tmp = shift @ARGV;
|
||||
chomp ($_tmp);
|
||||
@exclude_fs = split /,/, $_tmp;
|
||||
}
|
||||
elsif ($param eq '-custom_cmd') {
|
||||
$cmd = shift @ARGV;
|
||||
chomp ($cmd);
|
||||
}
|
||||
}
|
||||
|
||||
# Parse command line parameters
|
||||
|
@ -90,7 +125,15 @@ if ($onlyexclude) {
|
|||
|
||||
# Retrieve filesystem information
|
||||
# -P use the POSIX output format for portability
|
||||
my @df = `df -P`;
|
||||
|
||||
|
||||
$cmd = 'df -PT' unless defined($cmd);
|
||||
|
||||
if ($inode_mode > 0) {
|
||||
$cmd = 'df -PTi';
|
||||
}
|
||||
|
||||
my @df = `$cmd`;
|
||||
shift (@df);
|
||||
|
||||
# No filesystems? Something went wrong.
|
||||
|
@ -102,9 +145,13 @@ my %out;
|
|||
# Parse filesystem usage
|
||||
foreach my $row (@df) {
|
||||
my @columns = split (' ', $row);
|
||||
exit 1 if ($#columns < 4);
|
||||
if (check_in (\%filesystems,$columns[0]) || ($all_filesystems == 1 && !check_in(\%excluded_filesystems,$columns[0]) )) {
|
||||
$out{$columns[0]} = $columns[4] ;
|
||||
exit 1 if ($#columns < 5);
|
||||
|
||||
next if (in_array(\@exclude_fs, $columns[1]) > 0);
|
||||
|
||||
if (check_in (\%filesystems,$columns[0])
|
||||
|| ($all_filesystems == 1 && !check_in(\%excluded_filesystems,$columns[0])) ){
|
||||
$out{$columns[0]} = $columns[5] ;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -115,7 +162,7 @@ while (my ($filesystem, $use) = each (%out)) {
|
|||
|
||||
# Print module output
|
||||
print "<module>\n";
|
||||
print "<name><![CDATA[" . $filesystem . "]]></name>\n";
|
||||
print "<name><![CDATA[" . ($inode_mode > 0 ? 'Inodes:' : '') . $filesystem . "]]></name>\n";
|
||||
print "<type><![CDATA[generic_data]]></type>\n";
|
||||
print "<data><![CDATA[" . $use . "]]></data>\n";
|
||||
print "<description><![CDATA[% of usage in this volume]]></description>\n";
|
||||
|
|
|
@ -10869,12 +10869,17 @@ function api_set_new_cluster($thrash1, $thrash2, $other, $thrash3) {
|
|||
else
|
||||
db_pandora_audit("Report management", "Failed to create cluster agent $name");
|
||||
|
||||
returnData('string',
|
||||
array('type' => 'string', 'data' => (int)$id_cluster));
|
||||
if ($id_cluster !== false)
|
||||
returnData('string',
|
||||
array('type' => 'string', 'data' => (int)$id_cluster));
|
||||
else
|
||||
returnError('error_set_new_cluster', __('Failed to create cluster.'));
|
||||
} else {
|
||||
returnError('error_set_new_cluster', __('Agent name cannot be empty.'));
|
||||
return;
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
function api_set_add_cluster_agent($thrash1, $thrash2, $other, $thrash3) {
|
||||
|
|
|
@ -1917,16 +1917,18 @@ sub snmp_walk {
|
|||
$timeout = $snmp->{timeout};
|
||||
}
|
||||
|
||||
$snmp->{extra} = '' unless defined $snmp->{extra};
|
||||
|
||||
if ( defined ($snmp->{version} )
|
||||
&& (($snmp->{version} eq "1")
|
||||
|| ($snmp->{version} eq "2")
|
||||
|| ($snmp->{version} eq "2c"))) {
|
||||
|
||||
if (defined $snmp->{port}){
|
||||
$cmd = "snmpwalk -t $timeout -On -v $snmp->{version} -c $snmp->{community} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
$cmd = "snmpwalk -t $timeout $snmp->{extra} -On -v $snmp->{version} -c $snmp->{community} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
}
|
||||
else {
|
||||
$cmd = "snmpwalk -t $timeout -On -v $snmp->{version} -c $snmp->{community} $snmp->{host} $snmp->{oid}";
|
||||
$cmd = "snmpwalk -t $timeout $snmp->{extra} -On -v $snmp->{version} -c $snmp->{community} $snmp->{host} $snmp->{oid}";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1937,42 +1939,42 @@ sub snmp_walk {
|
|||
# $securityLevel = (noAuthNoPriv|authNoPriv|authPriv);
|
||||
|
||||
# unauthenticated request
|
||||
# Ex. snmpwalk -t $timeout -On -v 3 -n "" -u noAuthUser -l noAuthNoPriv test.net-snmp.org sysUpTime
|
||||
# Ex. snmpwalk -t $timeout $snmp->{extra} -On -v 3 -n "" -u noAuthUser -l noAuthNoPriv test.net-snmp.org sysUpTime
|
||||
|
||||
# authenticated request
|
||||
# Ex. snmpwalk -t $timeout -On -v 3 -n "" -u MD5User -a MD5 -A "The Net-SNMP Demo Password" -l authNoPriv test.net-snmp.org sysUpTime
|
||||
# Ex. snmpwalk -t $timeout $snmp->{extra} -On -v 3 -n "" -u MD5User -a MD5 -A "The Net-SNMP Demo Password" -l authNoPriv test.net-snmp.org sysUpTime
|
||||
|
||||
# authenticated and encrypted request
|
||||
# Ex. snmpwalk -t $timeout -On -v 3 -n "" -u MD5DESUser -a MD5 -A "The Net-SNMP Demo Password" -x DES -X "The Net-SNMP Demo Password" -l authPriv test.net-snmp.org system
|
||||
# Ex. snmpwalk -t $timeout $snmp->{extra} -On -v 3 -n "" -u MD5DESUser -a MD5 -A "The Net-SNMP Demo Password" -x DES -X "The Net-SNMP Demo Password" -l authPriv test.net-snmp.org system
|
||||
|
||||
if ($snmp->{securityLevel} =~ /^noAuthNoPriv$/i){
|
||||
# Unauthenticated request
|
||||
|
||||
if (defined $snmp->{port}){
|
||||
$cmd = "snmpwalk -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -l $snmp->{securityLevel} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
$cmd = "snmpwalk -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -l $snmp->{securityLevel} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
}
|
||||
else {
|
||||
$cmd = "snmpwalk -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -l $snmp->{securityLevel} $snmp->{host} $snmp->{oid}";
|
||||
$cmd = "snmpwalk -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -l $snmp->{securityLevel} $snmp->{host} $snmp->{oid}";
|
||||
}
|
||||
}
|
||||
elsif ($snmp->{securityLevel} =~ /^authNoPriv$/i){
|
||||
# Authenticated request
|
||||
|
||||
if (defined $snmp->{port}){
|
||||
$cmd = "snmpwalk -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -a $snmp->{authProtocol} -A $snmp->{authKey} -l $snmp->{securityLevel} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
$cmd = "snmpwalk -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -a $snmp->{authProtocol} -A $snmp->{authKey} -l $snmp->{securityLevel} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
}
|
||||
else {
|
||||
$cmd = "snmpwalk -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -a $snmp->{authProtocol} -A $snmp->{authKey} -l $snmp->{securityLevel} $snmp->{host} $snmp->{oid}";
|
||||
$cmd = "snmpwalk -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -a $snmp->{authProtocol} -A $snmp->{authKey} -l $snmp->{securityLevel} $snmp->{host} $snmp->{oid}";
|
||||
}
|
||||
}
|
||||
elsif ($snmp->{securityLevel} =~ /^authPriv$/i){
|
||||
# Authenticated and encrypted request
|
||||
|
||||
if (defined $snmp->{port}){
|
||||
$cmd = "snmpwalk -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -l $snmp->{securityLevel} -a $snmp->{authProtocol} -A $snmp->{authKey} -x $snmp->{privProtocol} -X $snmp->{privKey} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
$cmd = "snmpwalk -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -l $snmp->{securityLevel} -a $snmp->{authProtocol} -A $snmp->{authKey} -x $snmp->{privProtocol} -X $snmp->{privKey} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
}
|
||||
else {
|
||||
$cmd = "snmpwalk -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -l $snmp->{securityLevel} -a $snmp->{authProtocol} -A $snmp->{authKey} -x $snmp->{privProtocol} -X $snmp->{privKey} $snmp->{host} $snmp->{oid}";
|
||||
$cmd = "snmpwalk -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -l $snmp->{securityLevel} -a $snmp->{authProtocol} -A $snmp->{authKey} -x $snmp->{privProtocol} -X $snmp->{privKey} $snmp->{host} $snmp->{oid}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2028,16 +2030,18 @@ sub snmp_get {
|
|||
$timeout = $snmp->{timeout};
|
||||
}
|
||||
|
||||
$snmp->{extra} = '' unless defined $snmp->{extra};
|
||||
|
||||
if ( defined ($snmp->{version} )
|
||||
&& (($snmp->{version} eq "1")
|
||||
|| ($snmp->{version} eq "2")
|
||||
|| ($snmp->{version} eq "2c"))) {
|
||||
|
||||
if (defined $snmp->{port}){
|
||||
$cmd = "snmpget -r $retries -t $timeout -On -v $snmp->{version} -c $snmp->{community} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
$cmd = "snmpget -r $retries -t $timeout $snmp->{extra} -On -v $snmp->{version} -c $snmp->{community} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
}
|
||||
else {
|
||||
$cmd = "snmpget -r $retries -t $timeout -On -v $snmp->{version} -c $snmp->{community} $snmp->{host} $snmp->{oid}";
|
||||
$cmd = "snmpget -r $retries -t $timeout $snmp->{extra} -On -v $snmp->{version} -c $snmp->{community} $snmp->{host} $snmp->{oid}";
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -2048,42 +2052,42 @@ sub snmp_get {
|
|||
# $securityLevel = (noAuthNoPriv|authNoPriv|authPriv);
|
||||
|
||||
# unauthenticated request
|
||||
# Ex. snmpget -r $retries -t $timeout -On -v 3 -n "" -u noAuthUser -l noAuthNoPriv test.net-snmp.org sysUpTime
|
||||
# Ex. snmpget -r $retries -t $timeout $snmp->{extra} -On -v 3 -n "" -u noAuthUser -l noAuthNoPriv test.net-snmp.org sysUpTime
|
||||
|
||||
# authenticated request
|
||||
# Ex. snmpget -r $retries -t $timeout -On -v 3 -n "" -u MD5User -a MD5 -A "The Net-SNMP Demo Password" -l authNoPriv test.net-snmp.org sysUpTime
|
||||
# Ex. snmpget -r $retries -t $timeout $snmp->{extra} -On -v 3 -n "" -u MD5User -a MD5 -A "The Net-SNMP Demo Password" -l authNoPriv test.net-snmp.org sysUpTime
|
||||
|
||||
# authenticated and encrypted request
|
||||
# Ex. snmpget -r $retries -t $timeout -On -v 3 -n "" -u MD5DESUser -a MD5 -A "The Net-SNMP Demo Password" -x DES -X "The Net-SNMP Demo Password" -l authPriv test.net-snmp.org system
|
||||
# Ex. snmpget -r $retries -t $timeout $snmp->{extra} -On -v 3 -n "" -u MD5DESUser -a MD5 -A "The Net-SNMP Demo Password" -x DES -X "The Net-SNMP Demo Password" -l authPriv test.net-snmp.org system
|
||||
|
||||
if ($snmp->{securityLevel} =~ /^noAuthNoPriv$/i){
|
||||
# Unauthenticated request
|
||||
|
||||
if (defined $snmp->{port}){
|
||||
$cmd = "snmpget -r $retries -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -l $snmp->{securityLevel} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
$cmd = "snmpget -r $retries -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -l $snmp->{securityLevel} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
}
|
||||
else {
|
||||
$cmd = "snmpget -r $retries -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -l $snmp->{securityLevel} $snmp->{host} $snmp->{oid}";
|
||||
$cmd = "snmpget -r $retries -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -l $snmp->{securityLevel} $snmp->{host} $snmp->{oid}";
|
||||
}
|
||||
}
|
||||
elsif ($snmp->{securityLevel} =~ /^authNoPriv$/i){
|
||||
# Authenticated request
|
||||
|
||||
if (defined $snmp->{port}){
|
||||
$cmd = "snmpget -r $retries -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -a $snmp->{authProtocol} -A $snmp->{authKey} -l $snmp->{securityLevel} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
$cmd = "snmpget -r $retries -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -a $snmp->{authProtocol} -A $snmp->{authKey} -l $snmp->{securityLevel} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
}
|
||||
else {
|
||||
$cmd = "snmpget -r $retries -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -a $snmp->{authProtocol} -A $snmp->{authKey} -l $snmp->{securityLevel} $snmp->{host} $snmp->{oid}";
|
||||
$cmd = "snmpget -r $retries -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -a $snmp->{authProtocol} -A $snmp->{authKey} -l $snmp->{securityLevel} $snmp->{host} $snmp->{oid}";
|
||||
}
|
||||
}
|
||||
elsif ($snmp->{securityLevel} =~ /^authPriv$/i){
|
||||
# Authenticated and encrypted request
|
||||
|
||||
if (defined $snmp->{port}){
|
||||
$cmd = "snmpget -r $retries -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -l $snmp->{securityLevel} -a $snmp->{authProtocol} -A $snmp->{authKey} -x $snmp->{privProtocol} -X $snmp->{privKey} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
$cmd = "snmpget -r $retries -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -l $snmp->{securityLevel} -a $snmp->{authProtocol} -A $snmp->{authKey} -x $snmp->{privProtocol} -X $snmp->{privKey} $snmp->{host}:$snmp->{port} $snmp->{oid}";
|
||||
}
|
||||
else {
|
||||
$cmd = "snmpget -r $retries -t $timeout -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -l $snmp->{securityLevel} -a $snmp->{authProtocol} -A $snmp->{authKey} -x $snmp->{privProtocol} -X $snmp->{privKey} $snmp->{host} $snmp->{oid}";
|
||||
$cmd = "snmpget -r $retries -t $timeout $snmp->{extra} -On -v $snmp->{version} -n \"$snmp->{context}\" -u $snmp->{securityName} -l $snmp->{securityLevel} -a $snmp->{authProtocol} -A $snmp->{authKey} -x $snmp->{privProtocol} -X $snmp->{privKey} $snmp->{host} $snmp->{oid}";
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue