Example #1
0
$identifier = $argv[4];
$tool = $argv[5];
$message = $argv[6];
if (!file_exists($xUnitFile)) {
    die("\n   File not found: " . $xUnitFile . "\n\n");
}
// XML PROCESSING
$doc = new DOMDocument();
$doc->load($xUnitFile);
$xpath = new DOMXPath($doc);
$query = '//testsuites/testsuite/testcase/failure';
$failures = $xpath->query($query);
$incidents = array();
$message .= "<ul>";
$errorOccured = false;
foreach ($failures as $failure) {
    $message .= '<li>Type: ' . $failure->getAttribute('type') . ' - ' . $failure->nodeValue . '</li>';
    $errorOccured = true;
}
$message .= "</ul>";
// PREPARE REPORT
if (!$errorOccured) {
    $status = \Koalamon\Client\Reporter\Event::STATUS_SUCCESS;
    $message = '';
} else {
    $status = \Koalamon\Client\Reporter\Event::STATUS_FAILURE;
}
$reporter = new \Koalamon\Client\Reporter\Reporter('', $projectApiKey, new GuzzleHttp\Client());
$event = new \Koalamon\Client\Reporter\Event($identifier, $system, $status, $tool, $message, count($failures));
$reporter->sendEvent($event);
die("\n   Incidents send to koalamon.\n\n");
 private function doReport($system, $status, $message, $identifier)
 {
     $reporter = new \Koalamon\Client\Reporter\Reporter('', $this->apiKey, new Client(), $this->server);
     $event = new Event($identifier, $system, $status, 'missingRequest', $message);
     $reporter->sendEvent($event);
 }
Example #3
0
        }
    }
}
if (array_key_exists(5, $argv)) {
    $koalamonServer = $argv[5];
} else {
    $koalamonServer = null;
}
if (array_key_exists(6, $argv)) {
    $component_id = $argv[6];
} else {
    $component_id = null;
}
$guzzle = new \GuzzleHttp\Client();
$res = $guzzle->request('GET', $url);
$koalamonReporter = new \Koalamon\Client\Reporter\Reporter('', $projectApiKey, $guzzle, $koalamonServer);
try {
    $document = new \whm\Html\Document((string) $res->getBody());
} catch (\Exception $e) {
    echo "Error: " . $e->getMessage() . "\n\n";
    exit(1);
}
$dependencies = $document->getDependencies(new \GuzzleHttp\Psr7\Uri($url), false);
$totalSize = 0;
$bigFiles = 0;
$bigFileNames = [];
foreach ($dependencies as $dependency) {
    try {
        $response = $guzzle->request('GET', (string) $dependency);
        $responseSize = strlen($response->getBody());
        $known = false;