mirror of
https://github.com/librenms/librenms.git
synced 2024-10-07 16:52:45 +00:00
Email Transport: embed graphs by default (#14270)
* Email embed graphs * Allow attachment for non-html Add setting to webui Correct $auth setting * Cleanups, throw RrdGraphException instead of returning an error image. Generate the error image later, giving more control. Reduce code duplication a little * Style and lint fixes Change to flags * Add baseline for lint errors I don't know how to resolve * oopsie, changed the code after generating the baseline * Tiny cleanups. Make set DeviceCache primary, it is free. * Docs. * email_html note * Allow control of graph embed at the email transport level to override the global config. * Allow control of graph embed at the email transport level to override the global config. * Add INLINE_BASE64 to make it easier to create inline image tags
This commit is contained in:
@@ -559,7 +559,6 @@ class Rrd extends BaseDatastore
|
||||
* @param string $options
|
||||
* @return string
|
||||
*
|
||||
* @throws \LibreNMS\Exceptions\FileExistsException
|
||||
* @throws \LibreNMS\Exceptions\RrdGraphException
|
||||
*/
|
||||
public function graph(string $options): string
|
||||
@@ -568,9 +567,13 @@ class Rrd extends BaseDatastore
|
||||
$process->setTimeout(300);
|
||||
$process->setIdleTimeout(300);
|
||||
|
||||
$command = $this->buildCommand('graph', '-', $options);
|
||||
$process->setInput($command . "\nquit");
|
||||
$process->run();
|
||||
try {
|
||||
$command = $this->buildCommand('graph', '-', $options);
|
||||
$process->setInput($command . "\nquit");
|
||||
$process->run();
|
||||
} catch (FileExistsException $e) {
|
||||
throw new RrdGraphException($e->getMessage(), 'File Exists');
|
||||
}
|
||||
|
||||
$feedback_position = strrpos($process->getOutput(), 'OK ');
|
||||
if ($feedback_position !== false) {
|
||||
@@ -584,6 +587,9 @@ class Rrd extends BaseDatastore
|
||||
$position += strlen($search);
|
||||
throw new RrdGraphException(
|
||||
substr($process->getOutput(), $position),
|
||||
null,
|
||||
null,
|
||||
null,
|
||||
$process->getExitCode(),
|
||||
substr($process->getOutput(), 0, $position)
|
||||
);
|
||||
@@ -591,7 +597,7 @@ class Rrd extends BaseDatastore
|
||||
|
||||
// only error text was returned
|
||||
$error = trim($process->getOutput() . PHP_EOL . $process->getErrorOutput());
|
||||
throw new RrdGraphException($error, $process->getExitCode(), '');
|
||||
throw new RrdGraphException($error, null, null, null, $process->getExitCode());
|
||||
}
|
||||
|
||||
private function getImageEnd(string $type): string
|
||||
|
Reference in New Issue
Block a user