Skip to content

Commit

Permalink
Send Job Output to job-[{COMPANY_CODE}-{APP_CODE}-{RUNTEMPLATE_ID}-data]
Browse files Browse the repository at this point in the history
  • Loading branch information
Vítězslav Dvořák committed Apr 4, 2024
1 parent 0be36e3 commit 7066c5b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 3 additions & 0 deletions doc/zabbix.md
@@ -0,0 +1,3 @@
job-[{COMPANY_CODE}-{APP_CODE}-{RUNTEMPLATE_ID}-interval]
job-[{COMPANY_CODE}-{APP_CODE}-{RUNTEMPLATE_ID}-interval_seconds]
job-[{COMPANY_CODE}-{APP_CODE}-{RUNTEMPLATE_ID}-data]
5 changes: 3 additions & 2 deletions src/MultiFlexi/Action/Zabbix.php
Expand Up @@ -58,6 +58,7 @@ public static function usableForApp($app): bool
*/
public function perform()
{
$zabbixKey = (empty($this->getDataValue('key'))||($this->getDataValue('key') == 'job-[{COMPANY_CODE}-{APP_CODE}-{RUNTEMPLATE_ID}-data]')) ? 'job-['.$this->job->company->getDataValue('code').'-'.$this->job->application->getDataValue('code').'-'.$this->job->runTemplate->getMyKey().'-data]' : $this->getDataValue('key');
$dataForZabbix = null;
$metricsfile = $this->getDataValue('metricsfile');
if (empty($metricsfile)) {
Expand All @@ -71,7 +72,7 @@ public function perform()
}
if ($dataForZabbix) {
$packet = new \MultiFlexi\Zabbix\Request\Packet();
$packet->addMetric((new \MultiFlexi\Zabbix\Request\Metric($this->getDataValue('key'), $dataForZabbix))->withHostname($this->getDataValue('hostname')));
$packet->addMetric((new \MultiFlexi\Zabbix\Request\Metric($zabbixKey, $dataForZabbix))->withHostname($this->getDataValue('hostname')));
$zabbixSender = new \MultiFlexi\ZabbixSender($this->getDataValue('server'));
$zabbixSender->send($packet);
} else {
Expand All @@ -87,7 +88,7 @@ public function perform()
public static function inputs(string $prefix)
{
return [
new \Ease\TWB4\FormGroup(_('Zabbix key'), new \Ease\Html\InputTextTag($prefix . '[Zabbix][key]'), 'custom.key', _('Zabbix Item key')),
new \Ease\TWB4\FormGroup(_('Zabbix key'), new \Ease\Html\InputTextTag($prefix . '[Zabbix][key]'), 'job-[{COMPANY_CODE}-{APP_CODE}-{RUNTEMPLATE_ID}-data]', _('Zabbix Item key')),
new \Ease\TWB4\FormGroup(_('Metrics file'), new \Ease\Html\InputTextTag($prefix . '[Zabbix][metricsfile]'), '/tmp/metrics.json', _('File with metrics. Leave empty to send stdout'))
];
}
Expand Down

0 comments on commit 7066c5b

Please sign in to comment.