|
[x]
Posted via EE Mobile
|
||
Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again. |
||
| Question |
|
[x]
Attachment Details
|
||
|
[x]
The Solution Rating System
|
||
With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.
Your Input Matters If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support. Thank you! |
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: 62: 63: 64: 65: 66: 67: 68: 69: 70: 71: 72: 73: 74: 75: 76: 77: 78: 79: 80: 81: 82: 83: 84: 85: 86: 87: 88: 89: 90: 91: 92: 93: 94: 95: 96: 97: 98: 99: 100: 101: 102: 103: 104: 105: 106: 107: 108: 109: 110: 111: 112: 113: 114: 115: 116: 117: 118: 119: 120: 121: 122: 123: 124: 125: 126: 127: 128: 129: 130: 131: 132: 133: 134: 135: 136: 137: 138: 139: 140: 141: 142: 143: 144: 145: 146: 147: 148: 149: 150: 151: 152: 153: 154: 155: 156: 157: 158: 159: 160: 161: 162: 163: 164: 165: 166: 167: 168: 169: 170: 171: 172: 173: 174: 175: 176: 177: 178: 179: 180: 181: 182: 183: 184: 185: 186: 187: 188: 189: 190: 191: 192: 193: 194: 195: 196: 197: 198: 199: 200: 201: 202: 203: 204: 205: 206: 207: 208: 209: 210: 211: 212: 213: 214: 215: 216: 217: 218: 219: 220: 221: 222: 223: 224: 225: 226: 227: 228: 229: 230: 231: 232: 233: 234: 235: 236: 237: 238: 239: 240: 241: 242: 243: 244: 245: 246: 247: 248: 249: 250: 251: 252: 253: 254: 255: 256: 257: 258: 259: 260: 261: 262: 263: 264: 265: 266: 267: 268: 269: 270: 271: 272: 273: 274: 275: 276: 277: 278: 279: 280: 281: 282: 283: 284: 285: |
CODE FOR POSTEVENT.PL
#!/lcl/bin/perl -d
use Env;
use strict;
use Sys::Hostname;
use Getopt::Std;
my ($rtn, $help);
my %flags = ('t' => '', # Event class
's' => '', # Severity
'h' => hostname(), # hostname
'p' => '', # Program
'b' => '', # Business System
'm' => '', # Message
'g' => '', # on-call group
'i' => '', # instructions
'n' => 'Shell_API',
'c' => '', # confirm an event with an email to the on-call team.
'd' => '', # debug mode
'u' => '', # specify a specific URL to post events
'?' => '' # help
);
getopts('t:s:h:p:b:m:g:i:n:c:d:u', \%flags);
## Make sure GFS::Event is setup on this system
##
my $rtn = eval { require GFS::Event };
my $event = eval { return GFS::Event->new() };
if ($flags{'u'}) { $event->setURL($flags{'u'}); }
if ($help) { help();exit; }
&debug("Command line parameters: ", join (",", @ARGV)) if $flags{'d'};
&debug("Beginning $0, ", join (",", @ARGV)) if $flags{'d'};
my $event = GFS::Event->new();
if (! defined $event) {
&error("Could not create event object, $@");
}
if ($flags{'c'}) { $event->setConfirmEventOn(); }
$event->postEvent(
errorType => $flags{'t'},
errorSeverity => $flags{'s'},
errorGroup => $flags{'g'},
errorProgram => $flags{'p'},
errorSystem => $flags{'b'},
errorMessage => "$flags{'m'}",
errorHost => $flags{'h'},
errorInstructions => $flags{'i'},
errorNumber => "$flags{'n'}",
errorSubsource => "$0",
errorSource => "$0"
);
if ($event->isSuccess()) {
&info("Message sent to Tivoli, $flags{'m'}");
} else {
&error("Problems sending message to Tivoli, ", $event->getStatusMsg);
}
sub help {
my $usage = "Mandatory, these command line options must be specified.\n";
$usage .= "\t-t <Error Type>\n";
$usage .= "\t-s <Severity Code>\n";
$usage .= "\t-g <On-Call Group>\n";
$usage .= "\t-m <Message>\n\n";
$usage .= "\t-i <Operator's Instruction>\n";
$usage .= "\t-n <errorNumber>\n";
$usage .= "\t-c, no parameter. If specified, an email notification will be generated in addition to the Tivoli post.\n";
$usage .= "\t-p <Program>\n";
$usage .= "\t-b <Business_System>\n";
$usage .= "\t-d, no parameter. If specified, set log level to debug.\n";
&info($usage);
return;
}
sub debug {
if (! $flags{'d'}) { return }
my $field;
print STDOUT "[" . localtime() . "] [DEBUG] ";
foreach $field (@_) { print STDOUT $field }
print "\n";
}
sub info {
my $field;
print STDOUT "[" . localtime() . "] [INFO] ";
foreach $field (@_) { print STDOUT $field }
print "\n";
}
sub warn {
my $field;
print STDOUT "[" . localtime() . "] [WARN] ";
foreach $field (@_) { print STDOUT $field }
print "\n";
}
sub error {
my $field;
print STDOUT "[" . localtime() . "] [ERROR] ";
foreach $field (@_) { print STDOUT $field }
print "\n";
exit 5;
}
CODE FOR EVENT.PM
package GFS::Event;
our $VERSION = '1.1.0';
## Core
use strict;
use Sys::Hostname;
use Date::Format;
## Location of postzmsg
use constant POSTZ_HOME => "/lcl/apps/esm/bin";
## Config file for postzmsg
use constant POSTZ_CONFIG => "/lcl/apps/esm/bin/eif.conf";
sub new {
my $this = {};
my $proto = shift;
my $class = ref($proto) || $proto;
bless $this, $class;
my %args = @_;
$this->{'STATUS'} = "";
$this->{'POSTZ_HOME'} = $args{'postz'} || POSTZ_HOME;
$this->{'POSTZ_CONFIG'} = $args{'postz_config'} || POSTZ_CONFIG;
return $this;
}
sub postEvent {
my $this = shift;
my %parms = @_;
my $severity = $parms{'errorSeverity'} || $parms{'err_severity'} || '';
my $message = $parms{'errorMessage'} || $parms{'err_msg'} || '';
# Removes all front white space
$message =~ s/^\s+//;
# Replaces sequence of white space with a single space
$message =~ s/\s+/ /g;
# Removes all end white space
$message =~ s/\s+$//;
# Remove carriage returns anywhere in the string
$message =~ s/^M$//;
# Remove Line Feeds
$message =~ s/\n//g;
my $type = $parms{'errorType'} || $parms{'err_type'} || '';
my $source = $parms{'errorSource'} || $parms{'err_source'} || '';
my $group = $parms{'errorGroup'} || $parms{'err_group'} || '';
my $instructions = $parms{'errorInstructions'} || $parms{'err_inst'};
if (! $instructions) { $instructions= "Please call ${group} as appropriate for severity (${severity})."; }
# Removes all front white space
$instructions =~ s/^\s+//;
# Replaces sequence of white space with a single space
$instructions =~ s/\s+/ /g;
# Removes all end white space
$instructions =~ s/\s+$//;
# Remove carriage returns anywhere in the string
$instructions =~ s/^M$//;
# Remove Line Feeds
$instructions =~ s/\n//g;
my $host = $parms{'errorHost'} || $parms{'err_host'} || '';
my $system = $parms{'errorSystem'} || $parms{'err_system'} || '';
my $subSource = $parms{'errorSubSource'} || $parms{'err_subsource'} || '';
my $program = $parms{'errorProgram'} || $parms{'err_prog'} || '';
$this->{'STATUS'} = system ("clear");
print "#################################################################################################### #################################### \n";
print "\n";
print "Output being sent to postzmsg....";
print "\n";
print ("$this->{'POSTZ_HOME'}/postzmsg -f $this->{'POSTZ_CONFIG'} -r ${severity} -m '${message}' OnCallGroup=${group} ISOC_Instructions='${instructions}' Node=${host} SubSource=${subSource} System=${system}
Program=${program} ${type} ${source} ");
print "\n";
print "#################################################################################################### #################################### \n";
print "\n";
$this->{'STATUS'} = system("$this->{'POSTZ_HOME'}/postzmsg -f $this->{'POSTZ_CONFIG'} -r ${severity} -m '${message}' OnCallGroup=${group} ISOC_Instructions='${instructions}' Node=${host} SubSource=${subS
ource} System=${system} Program=${program} ${type} ${source}");
return $this->{'STATUS'};
}
## Mostly legacy getters/setters for backwards compatibility
sub setLogFile { my $this = shift; $this->{'log_file'} = shift; }
sub setStatus { my $this = shift; $this->{'STATUS'} = shift; }
sub setStatusMsg { my $this = shift; $this->{'STATUS_MSG'} = shift; }
sub setConfirmEventOn { my $this = shift; $this->{'confirm_event'} = "TRUE"; }
sub setConfirmEventOff { my $this = shift; $this->{'confirm_event'} = ""; }
sub confirmEvent { my $this = shift; return $this->{'confirm_event'}; }
sub getLogFile { my $this = shift; return $this->{'log_file'}; }
sub getStatus { my $this = shift; return $this->{'STATUS'}; }
sub getStatusMsg { my $this = shift; return $this->{'STATUS_MSG'}; }
sub getContentMsg { my $this = shift; return $this->{'CONTENT_MSG'}; }
sub getFromAddr { my $this=shift; return $this->{'email_from_addr'}; }
sub getSuppDistList { my $this=shift; return $this->{'email_distribution_list'}; }
sub getOncallGrp { my $this=shift; return $this->{'default_oncall_group'}; }
sub getURL { my $this=shift; return $this->{'URL'} }
sub setURL { my $this=shift; $this->{'URL'} = shift;}
sub printURL { my $this=shift; return join ("\n", split /\|/, $this->{'URL'}) }
sub isSuccess { my $this = shift; return $this->{'STATUS'} }
## -----------------------------sendErrortoTivoli-------------------------------- ##
## Legacy method used to reformat a hashmap into the postEvent call.
##
sub sendError2Tivoli {
my $class = shift;
my $postEvent = shift;
my %tivEvent = %{$postEvent};
my $event = GFS::Event->new();
$event->setConfirmEventOff();
if (! $tivEvent{'err_host'}) { $tivEvent{'err_host'} = hostname(); }
$event->postEvent(
errorType => $tivEvent{'err_type'},
errorSeverity => $tivEvent{'err_severity'},
errorGroup => $tivEvent{'err_group'},
errorProgram => $tivEvent{'err_prog'},
errorSystem => $tivEvent{'err_system'},
err_msg => $tivEvent{'err_msg'},
errorHost => $tivEvent{'err_host'},
errorInstructions => $tivEvent{'err_inst'},
errorNumber => "$tivEvent{err_n}",
errorSubsource => $tivEvent{'subsource'}
);
return $event->getStatusMsg();
}
1;
##
sub sendError2Tivoli {
my $class = shift;
my $postEvent = shift;
my %tivEvent = %{$postEvent};
my $event = GFS::Event->new();
$event->setConfirmEventOff();
if (! $tivEvent{'err_host'}) { $tivEvent{'err_host'} = hostname(); }
$event->postEvent(
errorType => $tivEvent{'err_type'},
errorSeverity => $tivEvent{'err_severity'},
errorGroup => $tivEvent{'err_group'},
errorProgram => $tivEvent{'err_prog'},
errorSystem => $tivEvent{'err_system'},
err_msg => $tivEvent{'err_msg'},
errorHost => $tivEvent{'err_host'},
errorInstructions => $tivEvent{'err_inst'},
errorNumber => "$tivEvent{err_n}",
errorSubsource => $tivEvent{'subsource'}
);
return $event->getStatusMsg();
}
1;
__END__
# Documentation...
|
Advertisement
| Hall of Fame |