|
@@ -170,6 +170,44 @@ class GenerateRemoteCrontabCommand extends ContainerAwareCommand
|
|
|
$content .= implode(PHP_EOL, $commands);
|
|
|
$content .= PHP_EOL;
|
|
|
}
|
|
|
+
|
|
|
+ $nasDevices = $doctrine->getRepository('\StatsBundle\Entity\Device')->findBy(array('deviceType' => 'RadiusBundle\Entity\NAS', 'deviceServer' => $server));
|
|
|
+
|
|
|
+ foreach ($nasDevices as $device) {
|
|
|
+ $commands = array();
|
|
|
+ $data = $device->jsonExtraData();
|
|
|
+ $deviceId = $device->getDeviceId();
|
|
|
+
|
|
|
+ if (is_null($data['radiusPassword']) || empty($data['radiusPassword'])){
|
|
|
+ $content .= PHP_EOL . PHP_EOL . "# Device(NAS) {$deviceId} skiped, radiusPassword is null or empty" . PHP_EOL;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ if (!in_array($data['library'], array('OIDSBase'))){
|
|
|
+ $content .= PHP_EOL . PHP_EOL . "# Device(NAS) {$deviceId} skiped, library not exist" . PHP_EOL;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!$saveHistoric){
|
|
|
+ $content .= PHP_EOL . PHP_EOL . "# Device {$deviceId} skiped, because saveHistoric is 0, set Server options in Stats". PHP_EOL;
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ $library = $data['library'];
|
|
|
+ $snmpCommunity = $data['radiusPassword'];
|
|
|
+ $description = $data['description'];
|
|
|
+ $deviceIp = $device->getIp();
|
|
|
+
|
|
|
+ $params = "--nas-ip={$deviceIp} --nas-community={$snmpCommunity} --nas-snmp-library={$library} --nas-device-id={$deviceId} --nas-server-id={$serverId} --save-historic=1";
|
|
|
+ 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";
|
|
|
+ }
|
|
|
+
|
|
|
+ $commands[] = "*/10 * * * * {$pathConsole} {$amqpRemote} {$routing_key} nas:onu:octets {$params}";
|
|
|
+ $content .= PHP_EOL . "# NAS {$description} ({$deviceIp})" . PHP_EOL;
|
|
|
+
|
|
|
+ $content .= implode(PHP_EOL, $commands);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
file_put_contents($fileCrontab, $content);
|
|
|
|