Skip to content

Commit 5010af2

Browse files
generating_app for CSC tests
1 parent c049e61 commit 5010af2

File tree

4 files changed

+106
-0
lines changed

4 files changed

+106
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
#!/usr/bin/env python
2+
# coding=utf-8
3+
#
4+
# Copyright © 2011-2015 Splunk, Inc.
5+
#
6+
# Licensed under the Apache License, Version 2.0 (the "License"): you may
7+
# not use this file except in compliance with the License. You may obtain
8+
# a copy of the License at
9+
#
10+
# http://www.apache.org/licenses/LICENSE-2.0
11+
#
12+
# Unless required by applicable law or agreed to in writing, software
13+
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
15+
# License for the specific language governing permissions and limitations
16+
# under the License.
17+
18+
import os, sys
19+
import time
20+
21+
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
22+
from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators
23+
24+
25+
@Configuration()
26+
class GeneratingCSC(GeneratingCommand):
27+
"""
28+
The generatingapp command generates a specific number of records.
29+
30+
Example:
31+
32+
``| generatingcsc count=4``
33+
34+
Returns a 4 records having text 'Test Event'.
35+
"""
36+
37+
count = Option(require=True, validate=validators.Integer(0))
38+
39+
def generate(self):
40+
self.logger.debug("Generating %s events" % self.count)
41+
for i in range(1, self.count + 1):
42+
text = f'Test Event {i}'
43+
yield {'_time': time.time(), 'event_no': i, '_raw': text}
44+
45+
46+
dispatch(GeneratingCSC, sys.argv, sys.stdin, sys.stdout, __name__)
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#
2+
# Splunk app configuration file
3+
#
4+
5+
[install]
6+
is_configured = 0
7+
8+
[ui]
9+
is_visible = 1
10+
label = Generating App
11+
12+
[launcher]
13+
description = Generating custom search commands example
14+
version = 1.0.0
15+
author = Splunk
16+
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[generatingcsc]
2+
filename = generatingcsc.py
3+
chunked = true
4+
python.version = python3
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
2+
# Application-level permissions
3+
4+
[]
5+
access = read : [ * ], write : [ admin, power ]
6+
7+
### EVENT TYPES
8+
9+
[eventtypes]
10+
export = system
11+
12+
13+
### PROPS
14+
15+
[props]
16+
export = system
17+
18+
19+
### TRANSFORMS
20+
21+
[transforms]
22+
export = system
23+
24+
25+
### LOOKUPS
26+
27+
[lookups]
28+
export = system
29+
30+
31+
### VIEWSTATES: even normal users should be able to create shared viewstates
32+
33+
[viewstates]
34+
access = read : [ * ], write : [ * ]
35+
export = system
36+
37+
[commands/generatingcsc]
38+
access = read : [ * ], write : [ * ]
39+
export = system
40+
owner = nobody

0 commit comments

Comments
 (0)