Hello all,
I am in the process of writing some code that generates a chart. I can probably figure this out, but I though someone might have some ideas on an easy way to do this and want to poke at some code on a Sunday. The chart needs to look like this:
I need to count all the severities of tickets for each device type in an array. The array looks like this called @type_chart that contains the type (ex, router) and the severity (ex, normal) for each ticket:
Here is the code I have so far:
Here is the output I am getting. (I threw some routers in the array above):
I was getting ready to create another foreach loop for the normal and warning tickets, and thought there may be a better way.
Thanks
I got a Biz Degree! How the h*ll did I get here?
I am in the process of writing some code that generates a chart. I can probably figure this out, but I though someone might have some ideas on an easy way to do this and want to poke at some code on a Sunday. The chart needs to look like this:
Code:
troubleNumber chart:
devType, critical, warning, normal
router, 27, 2, 3
switch, 3, 5, 7,
I need to count all the severities of tickets for each device type in an array. The array looks like this called @type_chart that contains the type (ex, router) and the severity (ex, normal) for each ticket:
Code:
server,normal
server,normal
server,normal
server,normal
server,normal
pc,normal
server,warning
server,normal
server,normal
server,normal
pc,normal
server,normal
server,normal
server,normal
pc,normal
server,critical
server,normal
server,normal
server,normal
router,normal
router,normal
server,normal
server,normal
server,normal
server,normal
server,normal
router,critical
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,critical
server,normal
server,warning
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
pc,normal
pc,normal
pc,normal
server,normal
server,normal
pc,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,critical
server,normal
server,normal
server,normal
server,normal
pc,normal
server,normal
server,warning
pc,normal
server,normal
server,warning
server,normal
server,normal
server,normal
server,normal
router,normal
server,normal
server,normal
router,normal
server,normal
server,warning
server,normal
server,normal
router,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,critical
server,normal
pc,warning
server,normal
server,normal
server,normal
pc,warning
server,warning
server,normal
server,normal
server,critical
server,normal
pc,normal
server,normal
server,normal
pc,normal
server,normal
server,normal
server,normal
server,normal
pc,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,warning
server,normal
server,warning
server,normal
pc,normal
server,critical
pc,normal
server,normal
server,normal
server,normal
server,normal
pc,normal
server,normal
server,normal
server,warning
server,normal
server,normal
pc,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,critical
pc,warning
server,normal
server,normal
server,normal
pc,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,normal
server,warning
server,normal
server,normal
server,warning
server,warning
server,normal
server,critical
server,normal
server,normal
server,normal
server,critical
pc,normal
server,normal
server,normal
Here is the code I have so far:
Code:
push (@type_chart, join (',',$type,$severity_code);
my %prob_type =();
my @type_critical = ();
my @type_warning = ();
my @type_normal = ();
foreach (@type_chart) {
my ($typ,$cri) = split (/,/);
#print "$_\n";
if ($_ =~ /critical/i) { push (@type_critical, $_);}
if ($_ =~ /warning/i) { push (@type_warning, $_);}
if ($_ =~ /normal/i) { push (@type_normal, $_);}
}
foreach $type_new (@types_new) {
foreach $var1 (@type_critical) {
next unless $var1 =~ /$type_new/;
$prob_type{$var1}++;
}
}
# print records to file
print LOG "Problem Types and counts\n";
foreach ( keys %prob_type ) {
print LOG "$_ $prob_type{$_}\n";
}
Here is the output I am getting. (I threw some routers in the array above):
Code:
Problem Types and counts
server,critical 310960
pc,critical 2535
I was getting ready to create another foreach loop for the normal and warning tickets, and thought there may be a better way.
Thanks
I got a Biz Degree! How the h*ll did I get here?