Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,7 @@ def initialize():
from os import path
from sys import modules, path as python_path

import platform

module_dir = path.dirname(path.realpath(__file__))
system = platform.system()

for packages in path.join(module_dir, 'packages'), path.join(path.join(module_dir, 'packages', system)):
if not path.isdir(packages):
break
python_path.insert(0, path.join(packages))

configuration_file = path.join(module_dir, '_pydebug_conf.py')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
# under the License.


import os
import sys

splunkhome = os.environ['SPLUNK_HOME']
sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib'))
from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators

try:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,8 @@
# under the License.


import os
import sys

splunkhome = os.environ['SPLUNK_HOME']
sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib'))
from splunklib.searchcommands import dispatch, EventingCommand, Configuration, Option


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,9 @@
# under the License.


import os
import sys
import time

splunkhome = os.environ['SPLUNK_HOME']
sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib'))
from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.

import os
import sys
import time

splunkhome = os.environ['SPLUNK_HOME']
sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib'))
from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,10 @@


import csv
import os
import random
import sys
import time

splunkhome = os.environ['SPLUNK_HOME']
sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib'))
from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.

import os
import sys

splunkhome = os.environ['SPLUNK_HOME']
sys.path.append(os.path.join(splunkhome, 'etc', 'apps', 'customsearchcommands_app', 'lib'))
from splunklib.searchcommands import dispatch, ReportingCommand, Configuration, Option, validators


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.

import os, sys
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import dispatch, EventingCommand, Configuration, Option, validators
from splunklib.searchcommands import dispatch, EventingCommand, Configuration, Option


@Configuration()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.

import os, sys
import sys
import time

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import dispatch, GeneratingCommand, Configuration, Option, validators


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@
# License for the specific language governing permissions and limitations
# under the License.

import os, sys
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import dispatch, ReportingCommand, Configuration, Option, validators


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,9 @@
# License for the specific language governing permissions and limitations
# under the License.

import os, sys
import sys

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import dispatch, StreamingCommand, Configuration, Option, validators
from splunklib.searchcommands import dispatch, StreamingCommand, Configuration


@Configuration()
Expand Down
22 changes: 11 additions & 11 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,50 +14,50 @@ services:
volumes:
# Weather App
- ./setup_pages/weather_app_example:/opt/splunk/etc/apps/weather_app_example
- ./lib:/opt/splunk/etc/apps/weather_app_example/vendor
- ./lib/splunklib:/opt/splunk/etc/apps/weather_app_example/bin/splunklib

# Dependency checking app example
- ./setup_pages/dependency_checking_app_example:/opt/splunk/etc/apps/dependency_checking_app_example
- ./lib:/opt/splunk/etc/apps/dependency_checking_app_example/vendor
- ./lib/splunklib:/opt/splunk/etc/apps/dependency_checking_app_example/bin/splunklib

# Setup page simple
- ./setup_pages/setup_page_simple:/opt/splunk/etc/apps/setup_page_simple

# Custom search commands app
- ./custom_search_commands/python/customsearchcommands_app:/opt/splunk/etc/apps/customsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/customsearchcommands_app/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/customsearchcommands_app/bin/splunklib

# Eventing commands app
- ./custom_search_commands/python/eventingsearchcommands_app:/opt/splunk/etc/apps/eventingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/eventingsearchcommands_app/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/eventingsearchcommands_app/bin/splunklib

# Generating commands app
- ./custom_search_commands/python/generatingsearchcommands_app:/opt/splunk/etc/apps/generatingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/generatingsearchcommands_app/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/generatingsearchcommands_app/bin/splunklib

# Reporting commands app
- ./custom_search_commands/python/reportingsearchcommands_app:/opt/splunk/etc/apps/reportingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/reportingsearchcommands_app/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/reportingsearchcommands_app/bin/splunklib

# Streaming commands app
- ./custom_search_commands/python/streamingsearchcommands_app:/opt/splunk/etc/apps/streamingsearchcommands_app
- ./lib/splunklib:/opt/splunk/etc/apps/streamingsearchcommands_app/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/streamingsearchcommands_app/bin/splunklib

# GitHub commits
- ./modularinputs/python/github_commits:/opt/splunk/etc/apps/github_commits
- ./lib/splunklib:/opt/splunk/etc/apps/github_commits/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/github_commits/bin/splunklib

# GitHub forks
- ./modularinputs/python/github_forks:/opt/splunk/etc/apps/github_forks
- ./lib/splunklib:/opt/splunk/etc/apps/github_forks/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/github_forks/bin/splunklib

# Random numbers
- ./modularinputs/python/random_numbers:/opt/splunk/etc/apps/random_numbers
- ./lib/splunklib:/opt/splunk/etc/apps/random_numbers/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/random_numbers/bin/splunklib

# Twitted
- ./python/twitted/twitted:/opt/splunk/etc/apps/twitted
- ./lib/splunklib:/opt/splunk/etc/apps/twitted/lib/splunklib
- ./lib/splunklib:/opt/splunk/etc/apps/twitted/bin/splunklib

healthcheck:
test: ['CMD', 'curl', '-f', 'http://localhost:8000']
Expand Down
9 changes: 4 additions & 5 deletions modularinputs/python/github_commits/bin/github_commits.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,11 @@
from http import client
from datetime import datetime

# NOTE: splunklib must exist within github_commits/lib/splunklib for this
# example to run! To run this locally use `SPLUNK_VERSION=latest docker compose up -d`
# from the root of this repo which mounts this example and the latest splunklib
# code together at /opt/splunk/etc/apps/github_commits
# NOTE: splunklib must exist within github_commits/bin for this example to run!
# To run this locally run `make up` from the root of this repo which mounts
# this example and the latest splunklib code together at /opt/splunk/etc/apps/github_commits


sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.modularinput import *


Expand Down
9 changes: 3 additions & 6 deletions modularinputs/python/github_forks/bin/github_forks.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,13 @@
# License for the specific language governing permissions and limitations
# under the License.

import os
import sys
import json
from http import client

# NOTE: splunklib must exist within github_forks/lib/splunklib for this
# example to run! To run this locally use `SPLUNK_VERSION=latest docker compose up -d`
# from the root of this repo which mounts this example and the latest splunklib
# code together at /opt/splunk/etc/apps/github_forks
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
# NOTE: splunklib must exist within github_forks/bin for this example to run!
# To run this locally run `make up` from the root of this repo which mounts
# this example and the latest splunklib code together at /opt/splunk/etc/apps/github_forks

from splunklib.modularinput import *

Expand Down
10 changes: 4 additions & 6 deletions modularinputs/python/random_numbers/bin/random_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,11 @@

import random
import sys
import os

# NOTE: splunklib must exist within random_numbers/lib/splunklib for this
# example to run! To run this locally use `SPLUNK_VERSION=latest docker compose up -d`
# from the root of this repo which mounts this example and the latest splunklib
# code together at /opt/splunk/etc/apps/random_numbers
sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
# NOTE: splunklib must exist within random_numbers/bin for this example to run!
# To run this locally run `make up` from the root of this repo which mounts
# this example and the latest splunklib code together at /opt/splunk/etc/apps/random_numbers


from splunklib.modularinput import *

Expand Down
6 changes: 1 addition & 5 deletions python/twitted/twitted/bin/hashtags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,10 @@
# under the License.


import os
import sys
import json
from collections import Counter

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import dispatch, ReportingCommand, Configuration, Option, validators
from splunklib.searchcommands import splunklib_logger
from splunklib.searchcommands import dispatch, ReportingCommand, Configuration


@Configuration(requires_preop=True)
Expand Down
3 changes: 0 additions & 3 deletions python/twitted/twitted/bin/tophashtags.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,11 @@
# under the License.


import os
import sys
import json
from collections import Counter

sys.path.insert(0, os.path.join(os.path.dirname(__file__), "..", "lib"))
from splunklib.searchcommands import dispatch, ReportingCommand, Configuration, Option, validators
from splunklib.searchcommands import splunklib_logger


@Configuration(requires_preop=True)
Expand Down
7 changes: 1 addition & 6 deletions setup_pages/dependency_checking_app_example/bin/weather.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import os, sys
import sys
import requests
from urllib.parse import urljoin, urlencode

# Library-loading boilerplate
APP_NAME = 'dependency_checking_app_example'
splunkhome = os.environ['SPLUNK_HOME']
apphome = os.path.join(splunkhome, 'etc', 'apps', APP_NAME)
sys.path.append(os.path.join(apphome, 'vendor'))

# Enterprise SDK imports
import splunklib.client as client
Expand Down
7 changes: 1 addition & 6 deletions setup_pages/weather_app_example/bin/weather.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import os, sys
import sys
import requests
from urllib.parse import urljoin, urlencode

# Library-loading boilerplate
APP_NAME = 'weather_app_example'
splunkhome = os.environ['SPLUNK_HOME']
apphome = os.path.join(splunkhome, 'etc', 'apps', APP_NAME)
sys.path.append(os.path.join(apphome, 'vendor'))

# Enterprise SDK imports
import splunklib.client as client
Expand Down