<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Jobs | Splunk SDK for PHP Examples</title> <link rel="stylesheet" type="text/css" href="shared/style.css" /> </head> <body> <?php require 'shared/navbar.php'; ?> <h2>Jobs</h2> <?php $service = new Splunk_Service($SplunkExamples_connectArguments); // (NOTE: Can throw HTTP 401 if bad credentials) $service->login(); // Get all jobs $jobs = $service->getJobs()->items(array('namespace' => Splunk_Namespace::createUser(NULL, NULL))); ?> <table class="table table-bordered table-striped"> <thead> <tr> <th>Search Expression</th> <th>Owner</th> <th>App</th> <th>Status</th> <th>Actions</th> </tr> </thead> <?php foreach ($jobs as $job) { echo '<tr><td>';
public function testGetNamespaceOfWildcardedReference() { $service = $this->loginToRealService(); $requestNamespace = Splunk_Namespace::createUser(NULL, NULL); $this->assertFalse($requestNamespace->isExact()); $index = $service->getIndexes()->getReference("_internal", $requestNamespace); $actualNamespace = $index->getNamespace(); $this->assertTrue($actualNamespace !== NULL); $this->assertTrue($actualNamespace !== $requestNamespace); $this->assertTrue($actualNamespace->isExact()); }
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Saved Searches | Splunk SDK for PHP Examples</title> <link rel="stylesheet" type="text/css" href="shared/style.css" /> </head> <body> <?php require 'shared/navbar.php'; ?> <h2>Saved Searches</h2> <?php $service = new Splunk_Service($SplunkExamples_connectArguments); // (NOTE: Can throw HTTP 401 if bad credentials) $service->login(); // Get all saved searches $savedSearches = $service->getSavedSearches()->items(array('namespace' => Splunk_Namespace::createUser(NULL, NULL))); ?> <table class="table table-bordered table-striped"> <thead> <tr> <th>Name</th> <th>Actions</th> </tr> </thead> <?php foreach ($savedSearches as $savedSearch) { echo '<tr><td>'; echo htmlspecialchars($savedSearch->getName()); echo '</td><td>'; echo '<a href="saved_search.php?action=run&id=' . urlencode($savedSearch->getName()) . '">Run</a>';
public function testControlInCustomNamespace() { $service = $this->loginToRealService(); // Setup $job = $service->getJobs()->create('search index=_internal | head 1', array('namespace' => Splunk_Namespace::createUser('admin', 'launcher'))); // Test & Teardown // (Ensure this doesn't throw HTTP 404) $job->cancel(); }
<?php require_once '../Splunk.php'; require_once 'settings.php'; $method = $_SERVER['REQUEST_METHOD']; $action = array_key_exists('action', $_REQUEST) ? $_REQUEST['action'] : 'help'; $id = array_key_exists('id', $_REQUEST) ? $_REQUEST['id'] : ''; $service = new Splunk_Service($SplunkExamples_connectArguments); // (NOTE: Can throw HTTP 401 if bad credentials) $service->login(); if ($id !== '') { $savedSearch = $service->getSavedSearches()->get($id, Splunk_Namespace::createUser(NULL, NULL)); } if ($method === 'POST') { $search = $_POST['search']; if ($action === 'create') { $name = $_POST['name']; $service->getSavedSearches()->create($name, array('search' => $search)); header('Location: list_saved_searches.php'); exit; } else { if ($action === 'edit') { $savedSearch->update(array('search' => $search)); header('Location: list_saved_searches.php'); exit; } else { die('Unrecognized action.'); } } } else { if ($method === 'GET') {
<?php require_once '../Splunk.php'; require_once 'settings.php'; $method = $_SERVER['REQUEST_METHOD']; $action = array_key_exists('action', $_REQUEST) ? $_REQUEST['action'] : 'help'; $id = array_key_exists('id', $_REQUEST) ? $_REQUEST['id'] : ''; $service = new Splunk_Service($SplunkExamples_connectArguments); // (NOTE: Can throw HTTP 401 if bad credentials) $service->login(); if ($id !== '') { $job = $service->getJobs()->get($id, Splunk_Namespace::createUser(NULL, NULL)); } if ($method === 'GET') { if ($action === 'help') { header('Location: list_jobs.php'); exit; } else { if ($action === 'view') { // (continue) } else { if ($action === 'pause') { $job->pause(); header('Location: list_jobs.php'); exit; } else { if ($action === 'unpause') { $job->unpause(); header('Location: list_jobs.php'); exit; } else {
/** * @expectedException PHPUnit_Framework_Error */ public function testCreateUserWithTooFewArguments() { Splunk_Namespace::createUser('theowner'); }