|
@@ -49,14 +49,15 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
|
|
|
|
$times = array();
|
|
$times = array();
|
|
$now = date("d-m-Y H:i:s");
|
|
$now = date("d-m-Y H:i:s");
|
|
- $content = PHP_EOL . "# NO EDITAR este archivo, se autogenera con el comando stats:crontab:remote. Generado {$now}." . PHP_EOL;
|
|
|
|
|
|
+ $content = "SHELL=/bin/bash".PHP_EOL."BASH_ENV=/container.env".PHP_EOL;
|
|
|
|
+ $content .= PHP_EOL . "# NO EDITAR este archivo, se autogenera con el comando stats:crontab:remote. Generado {$now}." . PHP_EOL;
|
|
|
|
|
|
$doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
|
|
$doctrine = $this->getContainer()->get('doctrine.orm.entity_manager');
|
|
|
|
|
|
if (is_null($pathApp)) {
|
|
if (is_null($pathApp)) {
|
|
$pathApp = $this->getContainer()->getParameter('app_path');
|
|
$pathApp = $this->getContainer()->getParameter('app_path');
|
|
}
|
|
}
|
|
- $pathConsole = "root $(which php) {$pathApp}/bin/console";
|
|
|
|
|
|
+ $pathConsole = "{$pathApp}/bin/console";
|
|
|
|
|
|
$serverDevices = $doctrine->getRepository('\StatsBundle\Entity\DeviceServer')->findAll();
|
|
$serverDevices = $doctrine->getRepository('\StatsBundle\Entity\DeviceServer')->findAll();
|
|
|
|
|
|
@@ -78,7 +79,7 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
$routing_key = "--route={$routing_key}";
|
|
$routing_key = "--route={$routing_key}";
|
|
}
|
|
}
|
|
|
|
|
|
- $content .= "*/5 * * * * {$pathConsole} stats:crontab:remote" . PHP_EOL;
|
|
|
|
|
|
+ $content .= "/5 * * * * {$pathConsole} stats:crontab:remote >> /var/log/cron.log 2>&1" . PHP_EOL;
|
|
|
|
|
|
foreach ($serverDevices as $server) {
|
|
foreach ($serverDevices as $server) {
|
|
|
|
|
|
@@ -125,28 +126,28 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
if ($amqp)
|
|
if ($amqp)
|
|
$params = "--args=--olt-ip:{$deviceIp} --args=--olt-community:{$snmpCommunity} --args=--olt-snmp-library:{$library} --args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
|
|
$params = "--args=--olt-ip:{$deviceIp} --args=--olt-community:{$snmpCommunity} --args=--olt-snmp-library:{$library} --args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
|
|
|
|
|
|
- $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:scan {$params}";
|
|
|
|
- $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:scan {$params}";
|
|
|
|
- $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:olt:scan {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:scan {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
+ $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:scan {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
+ $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:olt:scan {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
if ($amqp) {
|
|
if ($amqp) {
|
|
$params .= " --args=--save-historic:{$saveHistoric}";
|
|
$params .= " --args=--save-historic:{$saveHistoric}";
|
|
} else {
|
|
} else {
|
|
$params .= " --save-historic={$saveHistoric}";
|
|
$params .= " --save-historic={$saveHistoric}";
|
|
}
|
|
}
|
|
- $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:stats {$params}";
|
|
|
|
- $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:stats {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:stats {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
+ $commands[] = "*/{$timePonStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:stats {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
if($mark == "huawei")
|
|
if($mark == "huawei")
|
|
- $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:octets {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:onu:octets {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
- $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:octets {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeOltOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} {$mark}:pon:octets {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
$params = "--olt-device-id={$deviceId} --olt-server-id={$serverId}";
|
|
$params = "--olt-device-id={$deviceId} --olt-server-id={$serverId}";
|
|
if ($amqp) $params = "--args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
|
|
if ($amqp) $params = "--args=--olt-device-id:{$deviceId} --args=--olt-server-id:{$serverId}";
|
|
|
|
|
|
- $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:onu {$params}";
|
|
|
|
- $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:ponport {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:onu {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
+ $commands[] = "*/{$timeOnuStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:ponport {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
$content .= PHP_EOL . "# OLT {$oltName} ({$deviceIp})" . PHP_EOL;
|
|
$content .= PHP_EOL . "# OLT {$oltName} ({$deviceIp})" . PHP_EOL;
|
|
|
|
|
|
@@ -162,8 +163,8 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
if ($amqp) $params = "--args=--olt-server-id:{$serverId}";
|
|
if ($amqp) $params = "--args=--olt-server-id:{$serverId}";
|
|
|
|
|
|
$commands = array();
|
|
$commands = array();
|
|
- $commands[] = "*/5 * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:onu:geo {$params}";
|
|
|
|
- $commands[] = "*/10 * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:ponport:geo {$params}";
|
|
|
|
|
|
+ $commands[] = "*/5 * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:onu:geo {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
+ $commands[] = "*/10 * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:ponport:geo {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
$content .= implode(PHP_EOL, $commands);
|
|
$content .= implode(PHP_EOL, $commands);
|
|
$content .= PHP_EOL . PHP_EOL;
|
|
$content .= PHP_EOL . PHP_EOL;
|
|
@@ -200,7 +201,7 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
if ($amqp)
|
|
if ($amqp)
|
|
$params = "--args=--nas-ip:{$deviceIp} --args=--nas-community:{$snmpCommunity} --args=--nas-snmp-library:{$library} --args=--nas-device-id:{$deviceId} --args=--nas-server-id:{$serverId} --args=--save-historic:1";
|
|
$params = "--args=--nas-ip:{$deviceIp} --args=--nas-community:{$snmpCommunity} --args=--nas-snmp-library:{$library} --args=--nas-device-id:{$deviceId} --args=--nas-server-id:{$serverId} --args=--save-historic:1";
|
|
|
|
|
|
- $commands[] = "*/10 * * * * {$pathConsole} {$amqpRemote} {$routing_key} nas:onu:octets {$params}";
|
|
|
|
|
|
+ $commands[] = "*/10 * * * * {$pathConsole} {$amqpRemote} {$routing_key} nas:onu:octets {$params} >> /var/log/cron.log 2>&1";
|
|
$content .= PHP_EOL . "# NAS {$description} ({$deviceIp})" . PHP_EOL;
|
|
$content .= PHP_EOL . "# NAS {$description} ({$deviceIp})" . PHP_EOL;
|
|
|
|
|
|
$content .= implode(PHP_EOL, $commands);
|
|
$content .= implode(PHP_EOL, $commands);
|
|
@@ -244,8 +245,8 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
if ($amqp)
|
|
if ($amqp)
|
|
$params = "--args=--cmts-ip:{$deviceIp} --args=--cmts-community:{$snmpCommunity} --args=--cmts-snmp-library:{$library} --args=--cmts-device-id:{$deviceId} --args=--cmts-server-id:{$serverId}";
|
|
$params = "--args=--cmts-ip:{$deviceIp} --args=--cmts-community:{$snmpCommunity} --args=--cmts-snmp-library:{$library} --args=--cmts-device-id:{$deviceId} --args=--cmts-server-id:{$serverId}";
|
|
|
|
|
|
- $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:cm:scan {$params}";
|
|
|
|
- $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:scan {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:cm:scan {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
+ $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:scan {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
if ($amqp) {
|
|
if ($amqp) {
|
|
$params .= " --args=--save-historic:{$saveHistoric}";
|
|
$params .= " --args=--save-historic:{$saveHistoric}";
|
|
@@ -253,29 +254,29 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
$params .= " --save-historic={$saveHistoric}";
|
|
$params .= " --save-historic={$saveHistoric}";
|
|
}
|
|
}
|
|
|
|
|
|
- $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:stats {$params}";
|
|
|
|
- $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:description {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:stats {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
+ $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:interface:description {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
if ($amqp) {
|
|
if ($amqp) {
|
|
$params .= " --args=--cmts-docs:{$docsVersion}";
|
|
$params .= " --args=--cmts-docs:{$docsVersion}";
|
|
} else {
|
|
} else {
|
|
$params .= " --cmts-docs={$docsVersion}";
|
|
$params .= " --cmts-docs={$docsVersion}";
|
|
}
|
|
}
|
|
- $commands[] = "*/{$timeOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:octets {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeOctets} * * * * {$pathConsole} {$amqpRemote} {$routing_key} cmts:octets {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
if ($amqp) {
|
|
if ($amqp) {
|
|
$params = "--args=--cmts-device-id:{$deviceId} --args=--cmts-server-id:{$serverId}";
|
|
$params = "--args=--cmts-device-id:{$deviceId} --args=--cmts-server-id:{$serverId}";
|
|
} else {
|
|
} else {
|
|
$params = "--cmts-device-id={$deviceId} --cmts-server-id={$serverId}";
|
|
$params = "--cmts-device-id={$deviceId} --cmts-server-id={$serverId}";
|
|
}
|
|
}
|
|
- $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:interface {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeScan} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:interface {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
if ($amqp) {
|
|
if ($amqp) {
|
|
$params .= " --args=--generate-remote-commands:1";
|
|
$params .= " --args=--generate-remote-commands:1";
|
|
} else {
|
|
} else {
|
|
$params .= " --generate-remote-commands=1";
|
|
$params .= " --generate-remote-commands=1";
|
|
}
|
|
}
|
|
- $commands[] = "*/{$timeCmStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:cm {$params}";
|
|
|
|
|
|
+ $commands[] = "*/{$timeCmStats} * * * * {$pathConsole} {$amqpRemote} {$routing_key} stats:cm {$params} >> /var/log/cron.log 2>&1";
|
|
|
|
|
|
$content .= PHP_EOL . "# CMTS {$description} ({$deviceIp})" . PHP_EOL;
|
|
$content .= PHP_EOL . "# CMTS {$description} ({$deviceIp})" . PHP_EOL;
|
|
|
|
|
|
@@ -287,9 +288,9 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
|
|
|
|
$content .= PHP_EOL."#END ".PHP_EOL.PHP_EOL;
|
|
$content .= PHP_EOL."#END ".PHP_EOL.PHP_EOL;
|
|
file_put_contents($fileCrontab, $content);
|
|
file_put_contents($fileCrontab, $content);
|
|
-
|
|
|
|
- //print_r(shell_exec("/etc/init.d/cron reload"));
|
|
|
|
- print_r(shell_exec("supervisorctl -uiksop -pqueRini6 restart cron"));
|
|
|
|
|
|
+ sleep(5);
|
|
|
|
+ print_r(shell_exec("/usr/bin/crontab /etc/cron.d/fd3_stats"));
|
|
|
|
+ print_r(shell_exec("/usr/local/bin/supervisorctl -uiksop -pqueRini6 restart cron"));
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|