Skip to content

Commit

Permalink
SCTASK0050554 Merge pull request #115 from veorlo/master
Browse files Browse the repository at this point in the history
SCTASK0050554 New bugfix version for Cisco CPU collections
  • Loading branch information
veorlo authored Jun 3, 2020
2 parents face730 + ac60138 commit 1c31109
Show file tree
Hide file tree
Showing 11 changed files with 180 additions and 33 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ dist/*
# Editor tempfiles
~*
*~
*.bak
*.swp
redis_config.xml
conf/redis_config.xml
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME=simp
VERSION=1.4.1
VERSION=1.4.2

.PHONY: dist

Expand Down
2 changes: 1 addition & 1 deletion conf/comp/composite.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<!-- "${}" is required in the definition -->
<xsd:pattern value=".*$\{\}.*" />
<xsd:pattern value=".*$\{.*\}.*" />
</xsd:restriction>
</xsd:simpleType>
</xsd:attribute>
Expand Down
18 changes: 18 additions & 0 deletions conf/debug-logging.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
log4perl.rootLogger = DEBUG, SYSLOG, STDOUT

log4perl.appender.SYSLOG = Log::Dispatch::Syslog
log4perl.appender.SYSLOG.min_level = info
log4perl.appender.SYSLOG.facility = LOCAL0
log4perl.appender.SYSLOG.layout = PatternLayout
log4perl.appender.SYSLOG.layout.ConversionPattern = [%d] %F %L %c - %m%n

log4perl.appender.STDOUT = Log::Log4perl::Appender::Screen
log4perl.appender.STDOUT.min_level = debug
log4perl.appender.STDOUT.ident = $YOUR_APPLICATION_NAME
log4perl.appender.STDOUT.facility = LOCAL0
log4perl.appender.STDOUT.layout = PatternLayout
log4perl.appender.STDOUT.layout.ConversionPattern = [%d] %L %c - %m%n

log4perl.filter.RMQ = sub{ !/(on_response_[bcd]{2})|(Pending Responses)|(RabbitMQ)|(Method Name:)|(Binding Simp)|(QoS)|(Topic: Simp)|(Correlation ID:)|(Moving on\.\.\.)|(Running name)|(total time:)|(Params: \$VAR1 \=)/}

log4perl.appender.STDOUT.Filter = RMQ
106 changes: 80 additions & 26 deletions lib/GRNOC/Simp/Comp/Worker.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1040,37 +1040,31 @@ sub _get_data
# val hash under its val ID
my $val_key = $results->{'var_map'}->{$elem->{'source'}};

if ($val_key)
{
$self->logger->debug(
"Getting data for source $elem->{'source'} from the $val_key values"
);
for my $host (@$hosts) {

for my $host (@$hosts)
{
# Assign oid node values to the data name
if (
exists $results->{'scan_vals'}{$host}
{$elem->{'source'}})
{
my $suffix_data =
$results->{'scan_vals'}{$host}{$elem->{'source'}};
# Assign the OID suffixes as the value
if ( exists $results->{'scan_vals'}{$host}{$elem->{'source'}}) {

for my $key (keys %$suffix_data)
{
$results->{'data'}{$host}{$elem->{'name'}}
{$key}{'value'} =
$suffix_data->{$key}{'suffix'};
}
}
$self->logger->debug("Getting data for source $elem->{'source'} from OID suffixes");

# Assign retrieved values from the scan to the data name
if (exists $results->{'scan_vals'}{$host}{$val_key})
{
$results->{'data'}{$host}{$elem->{'name'}} =
$results->{'scan_vals'}{$host}{$val_key};
my $suffix_data = $results->{'scan_vals'}{$host}{$elem->{'source'}};

for my $key (keys %$suffix_data) {
$results->{'data'}{$host}{$elem->{'name'}}{$key}{'value'} = $suffix_data->{$key}{'suffix'};
}
}

# Assign the poll_value as the value
elsif ($val_key && exists $results->{'scan_vals'}{$host}{$val_key}) {

$self->logger->debug("Getting data for source $elem->{'source'} from the $val_key values");

$results->{'data'}{$host}{$elem->{'name'}} = $results->{'scan_vals'}{$host}{$val_key};
}

else {
$self->logger->error("The data source $elem->{'source'} did not have any data for assignment!");
}
}
}
}
Expand Down Expand Up @@ -2124,6 +2118,66 @@ sub _bool_to_int
push @$stack, _bool_to_int($res);
},

# a b => (Is string A equal to string B? (or both undef))
'eq' => sub {
my $stack = shift;
my $b = pop @$stack;
my $a = pop @$stack;
my $res =
(defined($a) && defined($b)) ? ($a eq $b)
: (!defined($a) && !defined($b)) ? 1
: 0;
push @$stack, _bool_to_int($res);
},

# a b => (Is string A unequal to string B?)
'ne' => sub {
my $stack = shift;
my $b = pop @$stack;
my $a = pop @$stack;
my $res =
(defined($a) && defined($b)) ? ($a ne $b)
: (!defined($a) && !defined($b)) ? 0
: 1;
push @$stack, _bool_to_int($res);
},

# a b => (Is string A less than string B?)
'lt' => sub {
my $stack = shift;
my $b = pop @$stack;
my $a = pop @$stack;
my $res = (defined($a) && defined($b)) ? ($a lt $b) : 0;
push @$stack, _bool_to_int($res);
},

# a b => (Is string A less than or equal to string B?)
'le' => sub {
my $stack = shift;
my $b = pop @$stack;
my $a = pop @$stack;
my $res = (defined($a) && defined($b)) ? ($a le $b) : 0;
push @$stack, _bool_to_int($res);
},

# a b => (Is string A greater than string B?)
'gt' => sub {
my $stack = shift;
my $b = pop @$stack;
my $a = pop @$stack;
my $res = (defined($a) && defined($b)) ? ($a gt $b) : 0;
push @$stack, _bool_to_int($res);
},

# a b => (Is string A greater than or equal to string B?)
'ge' => sub {
my $stack = shift;
my $b = pop @$stack;
my $a = pop @$stack;
my $res = (defined($a) && defined($b)) ? ($a ge $b) : 0;
push @$stack, _bool_to_int($res);
},

# a b => (a AND b)
'and' => sub {
my $stack = shift;
Expand Down
74 changes: 74 additions & 0 deletions scripts/test-composite.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
#!/usr/bin/perl

use strict;
use warnings;

use Time::HiRes qw(usleep gettimeofday tv_interval);
use Data::Dumper;
use GRNOC::RabbitMQ::Client;
use AnyEvent;
use Getopt::Long;

# Command line usage and parameters
sub usage {
my $text = <<"EOM";
Usage: $0 [--composite <composite_name>] [--hosts <host names comma-separated] [--iter <iterations>]
EOM
print $text;
exit( 1 );
}

my $composite;
my $hosts;
my $iter;
my $help;
GetOptions(
'composite|c=s' => \$composite,
'hosts=s' => \$hosts,
'iter|i=s' => \$iter,
'help|h|?' => \$help
) or usage();

usage() if $help;

# RabbitMQ Client Setup
my $client = GRNOC::RabbitMQ::Client->new(
host => "RabbitMQ HOST IP",
port => 5672,
user => "RabbitMQ USERNAME",
pass => "RabbitMQ PASSWORD",
exchange => 'Simp',
timeout => 60,
debug => 1,
topic => 'Simp.Comp'
);

# An array of hosts to request data for
my @nodes = (
'hostname1',
'hostname2'
);

# Continue to request data from Simp.Comp on "interval" seconds
my $timer = AnyEvent->timer(
interval => 30,
cb => sub { get(\@nodes); }
);

AnyEvent->condvar->recv;

sub get {

my $nodes = shift;

# Request data for each node
foreach my $node (@{$nodes}) {

# Send RabbitMQ request for Simp.Comp to compute data for COMPOSITE_NAME
my $data = $client->COMPOSITE_NAME(
node => $node,
period => 30,
async_callback => sub { warn Dumper(shift); }
);
}
}
2 changes: 1 addition & 1 deletion simp-comp.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary: A system for fetching data from simp and compiling the data into a composite
Name: simp-comp
Version: 1.4.1
Version: 1.4.2
Release: 1%{dist}
License: GRNOC
Group: GRNOC
Expand Down
2 changes: 1 addition & 1 deletion simp-data.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary: A small system for fetching SNMP data from redis and returning it via RabbitMQ
Name: simp-data
Version: 1.4.1
Version: 1.4.2
Release: 1%{dist}
License: GRNOC
Group: GRNOC
Expand Down
2 changes: 1 addition & 1 deletion simp-monitor.spec
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Name: simp-monitor
Version: 1.4.1
Version: 1.4.2
Release: 1%{?dist}
Summary: A functionality to monitor SIMP
License: GRNOC
Expand Down
2 changes: 1 addition & 1 deletion simp-poller.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary: A small system for gathering large amounts of SNMP data and pushing them into redis
Name: simp-poller
Version: 1.4.1
Version: 1.4.2
Release: 1%{dist}
License: GRNOC
Group: GRNOC
Expand Down
2 changes: 1 addition & 1 deletion simp-tsds.spec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Summary: SIMP TSDS Collector
Name: simp-tsds
Version: 1.4.1
Version: 1.4.2
Release: 1%{dist}
License: APL 2.0
Group: Network
Expand Down

0 comments on commit 1c31109

Please sign in to comment.