Skip to content

Commit

Permalink
v1.25.0
Browse files Browse the repository at this point in the history
Do not send -1 when Job is scheduled
  • Loading branch information
Vitexus committed Jan 19, 2025
1 parent 3e207f6 commit 1173be0
Show file tree
Hide file tree
Showing 9 changed files with 106 additions and 71 deletions.
10 changes: 8 additions & 2 deletions debian/changelog
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
multiflexi (1.24.0) UNRELEASED; urgency=medium
multiflexi (1.25.0) UNRELEASED; urgency=medium

* new cli tool

-- vitex <[email protected]> Sun, 19 Jan 2025 20:03:39 +0100

multiflexi (1.24.0) jammy; urgency=medium

* api@debian works now

-- vitex <[email protected]> Fri, 17 Jan 2025 04:11:44 +0100
-- vitex <[email protected]> Sun, 19 Jan 2025 20:03:19 +0100

multiflexi (1.23.0) jammy; urgency=medium

Expand Down
4 changes: 1 addition & 3 deletions src/MultiFlexi/Command/AppStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@

namespace MultiFlexi\Command;

use Ease\Shared;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Ease\Shared;

/**
* Description of Status.
Expand All @@ -39,8 +39,6 @@ protected function configure(): void

protected function execute(InputInterface $input, OutputInterface $output): int
{


$format = $input->getOption('format');

$engine = new \MultiFlexi\Engine();
Expand Down
22 changes: 14 additions & 8 deletions src/MultiFlexi/Command/Application.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
<?php

declare(strict_types=1);

/**
* MultiFlexi -
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* @author Vítězslav Dvořák <[email protected]>
* @copyright 2020 Vitex Software
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Description of Application
* Description of Application.
*
* @author Vitex <[email protected]>
* @author Vitex <[email protected]>
*/
class Application extends Command {
class Application extends Command
{
protected function configure(): void
{
$this
Expand Down
22 changes: 14 additions & 8 deletions src/MultiFlexi/Command/Company.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
<?php

declare(strict_types=1);

/**
* MultiFlexi -
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* @author Vítězslav Dvořák <[email protected]>
* @copyright 2020 Vitex Software
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Description of Company
* Description of Company.
*
* @author Vitex <[email protected]>
* @author Vitex <[email protected]>
*/
class Company extends Command{
class Company extends Command
{
protected function configure(): void
{
$this
Expand Down
22 changes: 14 additions & 8 deletions src/MultiFlexi/Command/CredentialType.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
<?php

declare(strict_types=1);

/**
* MultiFlexi -
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* @author Vítězslav Dvořák <[email protected]>
* @copyright 2020 Vitex Software
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Description of CredentialType
* Description of CredentialType.
*
* @author Vitex <[email protected]>
* @author Vitex <[email protected]>
*/
class CredentialType extends Command {
class CredentialType extends Command
{
protected function configure(): void
{
$this
Expand Down
22 changes: 14 additions & 8 deletions src/MultiFlexi/Command/Job.php
Original file line number Diff line number Diff line change
@@ -1,24 +1,30 @@
<?php

declare(strict_types=1);

/**
* MultiFlexi -
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* @author Vítězslav Dvořák <[email protected]>
* @copyright 2020 Vitex Software
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Description of Job
* Description of Job.
*
* @author Vitex <[email protected]>
* @author Vitex <[email protected]>
*/
class Job extends Command {
class Job extends Command
{
protected function configure(): void
{
$this
Expand Down
27 changes: 14 additions & 13 deletions src/MultiFlexi/Command/JobStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,31 @@
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Ease\Shared;

/**
* Description of Status.
*
* @author Vitex <[email protected]>
*/
class JobStatus extends Command {

protected function configure(): void {
class JobStatus extends Command
{
protected function configure(): void
{
$this
->setName('jobstatus')
->setDescription('Prints Jobs Status')
->addOption('--format', '-f', InputOption::VALUE_OPTIONAL, 'The output format: text or json. Defaults to text.', 'text')
->setHelp('This command prints status of jobs and its schedule');
->setName('jobstatus')
->setDescription('Prints Jobs Status')
->addOption('--format', '-f', InputOption::VALUE_OPTIONAL, 'The output format: text or json. Defaults to text.', 'text')
->setHelp('This command prints status of jobs and its schedule');
}

// 09 implementing the execute method
protected function execute(InputInterface $input, OutputInterface $output): int {
protected function execute(InputInterface $input, OutputInterface $output): int
{
$engine = new \MultiFlexi\Engine();
$pdo = $engine->getPdo();
$database = $pdo->getAttribute(\PDO::ATTR_DRIVER_NAME) . ' ' .
$pdo->getAttribute(\PDO::ATTR_CONNECTION_STATUS) . ' ' .
$pdo->getAttribute(\PDO::ATTR_SERVER_INFO) . ' ' .
$database = $pdo->getAttribute(\PDO::ATTR_DRIVER_NAME).' '.
$pdo->getAttribute(\PDO::ATTR_CONNECTION_STATUS).' '.
$pdo->getAttribute(\PDO::ATTR_SERVER_INFO).' '.
$pdo->getAttribute(\PDO::ATTR_SERVER_VERSION);

$queeLength = (new \MultiFlexi\Scheduler())->listingQuery()->count();
Expand Down Expand Up @@ -78,7 +79,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int
$output->writeln(json_encode($status, \JSON_PRETTY_PRINT));
} else {
foreach ($status as $key => $value) {
$output->writeln(str_replace('_', ' ', $key) . ': ' . $value);
$output->writeln(str_replace('_', ' ', $key).': '.$value);
}
}

Expand Down
42 changes: 24 additions & 18 deletions src/MultiFlexi/Command/RunTemplate.php
Original file line number Diff line number Diff line change
@@ -1,35 +1,42 @@
<?php

declare(strict_types=1);

/**
* MultiFlexi -
* This file is part of the MultiFlexi package
*
* https://multiflexi.eu/
*
* @author Vítězslav Dvořák <[email protected]>
* @copyright 2020 Vitex Software
* (c) Vítězslav Dvořák <http://vitexsoftware.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

namespace MultiFlexi\Command;

use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Output\OutputInterface;

/**
* Description of RunTemplate
* Description of RunTemplate.
*
* @author Vitex <[email protected]>
* @author Vitex <[email protected]>
*/
class RunTemplate extends Command {

protected function configure(): void {
class RunTemplate extends Command
{
protected function configure(): void
{
$this
->setName('runtemplate')
->setDescription('Runtemplate operations')
->addOption('--format', '-f', InputOption::VALUE_OPTIONAL, 'The output format: text or json. Defaults to text.', 'text')
->addArgument('operation', InputArgument::REQUIRED, 'what to do with RunTemplate')
->addArgument('id', InputArgument::OPTIONAL, 'which RunTemplate ?')
->setHelp(<<<EOT
->setName('runtemplate')
->setDescription('Runtemplate operations')
->addOption('--format', '-f', InputOption::VALUE_OPTIONAL, 'The output format: text or json. Defaults to text.', 'text')
->addArgument('operation', InputArgument::REQUIRED, 'what to do with RunTemplate')
->addArgument('id', InputArgument::OPTIONAL, 'which RunTemplate ?')
->setHelp(<<<'EOT'
The <info>runtemplate</info> command mangafe runtemplate
<info>multilflexi-cli runtemplate trigger 220</info>
Expand All @@ -38,8 +45,8 @@ protected function configure(): void {
EOT);
}

protected function execute(InputInterface $input, OutputInterface $output): int {

protected function execute(InputInterface $input, OutputInterface $output): int
{
$runTemplate = new \MultiFlexi\RunTemplate(is_numeric($input->getArgument('id')) ? (int) $input->getArgument('id') : $input->getArgument('id'));

switch ($input->getArgument('operation')) {
Expand All @@ -57,7 +64,6 @@ protected function execute(InputInterface $input, OutputInterface $output): int
break;
}


return Command::SUCCESS;
}
}
6 changes: 3 additions & 3 deletions src/MultiFlexi/Job.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ public function prepareJob(int $runTemplateId, array $envOverride, \DateTime $sc
$this->setZabbixValue('company_name', $this->company->getDataValue('name'));
$this->setZabbixValue('company_code', $this->company->getDataValue('code'));
$this->setZabbixValue('runtemplate_id', $runTemplateId);
$this->setZabbixValue('exitcode', -1);
$this->setZabbixValue('exitcode', null);
$this->setZabbixValue('stdout', null);
$this->setZabbixValue('stderr', null);
$this->setZabbixValue('executor', $executor);
Expand Down Expand Up @@ -418,8 +418,8 @@ public function reportToZabbix(array $messageData): bool
$itemKey = 'job-['.$this->company->getDataValue('code').'-'.$this->application->getDataValue('code').'-'.$this->runTemplate->getMyKey().']';
$packet->addMetric((new ZabbixMetric($itemKey, json_encode($this->zabbixMessageData)))->withHostname($hostname));

file_put_contents('/tmp/zabbix-' . $this->getMyKey().'-'. time().'.json' , json_encode($this->zabbixMessageData));
// file_put_contents('/tmp/zabbix-' . $this->zabbixMessageData['phase'] .'-'. $this->getMyKey().'-'. time().'.json' , json_encode($this->zabbixMessageData));

try {
$result = $this->zabbixSender->send($packet);

Expand Down

0 comments on commit 1173be0

Please sign in to comment.