Skip to content

Commit

Permalink
Updated README and usage
Browse files Browse the repository at this point in the history
  • Loading branch information
mikeder committed Mar 1, 2015
1 parent 25a81c7 commit b2ad7b3
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ Shinken Ticketer

* Resolves incidents and removes ticket info from database when alarm clears.

* Doesn't actually work yet.

Installation:

Clone repo to Shinken installation directory:
Expand All @@ -29,5 +31,5 @@ define command {
command_name ticketer
command_line /usr/bin/ticketer --type $NOTIFICATIONTYPE$ --host
$HOSTNAME$ --addr $HOSTADDRESS$ --srvc $SERVICEDESC --output
$SERVICEOUTPUT$
$SERVICEOUTPUT$ --state $SERVICESTATE$
}
21 changes: 13 additions & 8 deletions ticketer.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,17 @@

def main(argv):
# Initialize/Preallocate list to hold alarm details
alarm = ['type','host','addr','srvc','output','desc']
alarm = ['type','host','addr','srvc','output','state']

try:
opts, args = getopt.getopt(argv,"h", ["help", "type=", "host=", "addr=",
"srvc=", "output=", "desc=", "initdb"])
"srvc=", "output=", "state=", "initdb"])
except getopt.GetoptError as err:
print(err)
usage()
sys.exit(2)

if not args:
usage()
# Handle all the options and arguments passed in
for opt, arg in opts:
if opt in ("-h", "--help"):
Expand All @@ -42,12 +43,10 @@ def main(argv):
alarm[2] = arg
elif opt == '--srvc':
alarm[3] = arg
elif opt == '--desc':
alarm[4] = arg
elif opt == '--output':
alarm[5] = arg
alarm[4] = arg
elif opt == '--state':
srvcState = arg
alarm[5] = arg
elif opt == '--initdb':
initdb()
# Generate new ticket if this is a new alarm
Expand All @@ -59,7 +58,13 @@ def main(argv):

# Print usage, even though this is called by a daemon?
def usage():
print("Usage: ticketer.py --host --addr --service --output --desc")
print("Usage: ticketer.py --type --host --addr --srvc --output --state")
print("--type $NOTIFICATIONTYPE$")
print("--host $HOSTNAME$")
print("--addr $HOSTADDRESS$")
print("--srvc $SERVICEDESC$")
print("--output $SERVICEOUTPUT$")
print("--state $SERVICESTATE$")

# Setup sqlite database
def initdb():
Expand Down

0 comments on commit b2ad7b3

Please sign in to comment.