<s> import random , sys <EOL> from splunklib . modularinput import * <EOL> class MyScript ( Script ) : <EOL> """<STR_LIT>""" <EOL> def get_scheme ( self ) : <EOL> """<STR_LIT>""" <EOL> scheme = Scheme ( "<STR_LIT>" ) <EOL> scheme . description = "<STR_LIT>" <EOL> scheme . use_external_validation = True <EOL> scheme . use_single_instance = True <EOL> min_argument = Argument ( "<STR_LIT>" ) <EOL> min_argument . title = "<STR_LIT>" <EOL> min_argument . data_type = Argument . data_type_number <EOL> min_argument . description = "<STR_LIT>" <EOL> min_argument . required_on_create = True <EOL> scheme . add_argument ( min_argument ) <EOL> max_argument = Argument ( "<STR_LIT>" ) <EOL> max_argument . title = "<STR_LIT>" <EOL> max_argument . data_type = Argument . data_type_number <EOL> max_argument . description = "<STR_LIT>" <EOL> max_argument . required_on_create = True <EOL> scheme . add_argument ( max_argument ) <EOL> return scheme <EOL> def validate_input ( self , validation_definition ) : <EOL> """<STR_LIT>""" <EOL> minimum = float ( validation_definition . parameters [ "<STR_LIT>" ] ) <EOL> maximum = float ( validation_definition . parameters [ "<STR_LIT>" ] ) <EOL> if minimum >= maximum : <EOL> raise ValueError ( "<STR_LIT>" % minimum , maximum ) <EOL> def stream_events ( self , inputs , ew ) : <EOL> """<STR_LIT>""" <EOL> for input_name , input_item in inputs . inputs . iteritems ( ) : <EOL> minimum = float ( input_item [ "<STR_LIT>" ] ) <EOL> maximum = float ( input_item [ "<STR_LIT>" ] ) <EOL> event = Event ( ) <EOL> event . stanza = input_name <EOL> event . data = "<STR_LIT>" % str ( random . uniform ( minimum , maximum ) ) <EOL> ew . write_event ( event ) <EOL> if __name__ == "<STR_LIT:__main__>" : <EOL> sys . exit ( MyScript ( ) . run ( sys . argv ) ) </s>
