diff --git a/notify.pl b/notify.pl index 849b03a..f97174e 100755 --- a/notify.pl +++ b/notify.pl @@ -161,14 +161,10 @@ my @files = glob "$conf{'conf'}{'VMS'}/*.txt"; if ($function =~ /notify/) { mailout(\%conf, \%vms); -} - -if ($function =~ /(msg|deployed)/ and $function_variable !~ /empty/) { +} elsif ($function =~ /(msg|deployed)/ and $function_variable !~ /empty/) { my %slice = %vms{$function_variable}; mailout(\%conf, \%slice); -} - -if ($function =~ /(renewal|subscription|deprovision)/) { +} elsif ($function =~ /(renewal|subscription|deprovision)/) { my $year = strftime("%Y", localtime); my $month = strftime("%m", localtime); for my $vm_name (sort keys %vms) { @@ -181,19 +177,14 @@ if ($function =~ /(renewal|subscription|deprovision)/) { if ($function =~ /subscription/) { if (defined $vms{$vm_name}{'subscription'} and $vms{$vm_name}{'subscription'} eq "") { delete $vms{$vm_name}; next; } } - } mailout(\%conf, \%vms); -} - -if ($function =~ /stopped/) { +} elsif ($function =~ /stopped/) { my @stopped_vms = qx(vmctl show | grep stopped | awk '{print \$9}'); for my $vm_name (sort keys %vms) { if (!grep(/$vm_name/, @stopped_vms)) { delete $vms{$vm_name}; next; } } mailout(\%conf, \%vms); -} - -if ($function =~ /empty/) { +} else { print "Specify function: deployed , stopped, renewal, notify, deprovision, msg \n"; }