1
1
#!/usr/bin/env python
2
- import optparse
2
+ import argparse
3
3
import zulip
4
4
5
5
from typing import List , Text , Dict , Any
@@ -8,14 +8,14 @@ VERSION = "0.9"
8
8
# Nagios passes the notification details as command line options.
9
9
# In Nagios, "output" means "first line of output", and "long
10
10
# output" means "other lines of output".
11
- parser = optparse . OptionParser () # type: optparse.OptionParser
12
- parser .add_option ('--output' , default = '' )
13
- parser .add_option ('--long-output' , default = '' )
14
- parser .add_option ('--stream' , default = 'nagios' )
15
- parser .add_option ('--config' , default = '/etc/nagios3/zuliprc' )
11
+ parser = zulip . add_default_arguments ( argparse . ArgumentParser ()) # type: argparse.ArgumentParser
12
+ parser .add_argument ('--output' , default = '' )
13
+ parser .add_argument ('--long-output' , default = '' )
14
+ parser .add_argument ('--stream' , default = 'nagios' )
15
+ parser .add_argument ('--config' , default = '/etc/nagios3/zuliprc' )
16
16
for opt in ('type' , 'host' , 'service' , 'state' ):
17
- parser .add_option ('--' + opt )
18
- ( opts , args ) = parser .parse_args () # type: Any, List[Text]
17
+ parser .add_argument ('--' + opt )
18
+ opts = parser .parse_args ()
19
19
20
20
client = zulip .Client (config_file = opts .config ,
21
21
client = "ZulipNagios/" + VERSION ) # type: zulip.Client
0 commit comments