コード例 #1
0
 public function clients($client = null)
 {
     $start = Input::get('start', Date::now()->sub('1 day'));
     $end = Input::get('end', Date::now());
     $clientselected = Input::get('Client', $client);
     $client = Client::where('clientid', '=', $clientselected)->first();
     $user = Sentry::getUser();
     // Get Clients to fill the Client Select Box And Select Values From Permissions
     $permissions = Userspermissions::where('id', '=', $user->id)->remember(10)->first();
     if ($permissions !== null) {
         $permissions = unserialize($permissions->clients);
         $clients = Client::wherein('clientid', $permissions)->remember(10)->get();
         $clientSelectBox = Client::clientSelectBox($clients->toArray());
     } else {
         $clientSelectBox = Client::clientSelectBox();
     }
     ///// End Permissions
     if ($client == Null) {
         $platform = "";
         $fileretension = "";
         $jobretension = "";
         $autoprune = "";
         $terminatedJobs = "0";
         $cancelJobs = "0";
         $runningJobs = "0";
         $wattingJobs = "0";
         $errorJobs = "0";
         // Indicates Failed and Okay Jobs
         $nTransBytes = "0";
         $nTransFiles = "0";
         $graphOkJob = "0";
         $graphFailedJob = "0";
     } else {
         $platform = $client->Uname;
         $autoprune = $client->AutoPrune;
         /* Calculate the Retension Period */
         $to = Date::now();
         $text = " Days";
         /* 86400  -> equal to seconds in i day*/
         $fileretension = $client->fileretention / 86400 . $text;
         if ($fileretension >= 365) {
             $type = ' Year';
             $fileretension = intval($fileretension / 31536000) . $type;
         }
         /* 86400  -> equal to seconds in i day*/
         $jobretension = $client->jobretention / 86400 . $text;
         if ($jobretension >= 365) {
             $type = ' Year';
             $jobretension = intval($jobretension / 31536000) . $type;
         }
         /* Get Terminated Jobs */
         $tjobs = Job::where('jobstatus', '=', 'T')->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('clientid', '=', $client->clientid)->remember(10)->get();
         // Number Terminate Jobs
         $terminatedJobs = count($tjobs);
         /* Get Canceled Jobs */
         $canceledJobs = Job::where('jobstatus', '=', 'A')->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('clientid', '=', $client->ClientId)->remember(10)->get();
         // Number Terminate Jobs
         $cancelJobs = count($canceledJobs);
         /* Get Canceled Jobs */
         $canceledJobs = Job::where('jobstatus', '=', 'A')->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('clientid', '=', $client->ClientId)->remember(10)->get();
         // Number Terminate Jobs
         $cancelJobs = count($canceledJobs);
         /* Get Running Jobs */
         $runJobs = Job::where('jobstatus', '=', 'R')->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('clientid', '=', $client->ClientId)->remember(10)->get();
         // Number Running Jobs
         $runningJobs = count($runJobs);
         /* Get Watting Jobs */
         $wateJobs = Job::wherein('jobstatus', array('c', 'F', 'j', 'M', 'm', 'p', 's', 't'))->where('endtime', '<=', $end)->where('starttime', '>=', $start)->where('clientid', '=', $client->ClientId)->remember(10)->get();
         // Number Watting Jobs
         $wattingJobs = count($wateJobs);
         /* Get Error Jobs */
         $errJobs = Job::wherein('jobstatus', array('e', 'f', 'E'))->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('clientid', '=', $client->ClientId)->remember(10)->get();
         // Number Error Jobs
         $errorJobs = count($errJobs);
         $nTransBytes = 0;
         $nTransFiles = 0;
         $terminatedJobs = count($tjobs);
         /* Calculate Jobs and Bytes */
         $tjobs = $tjobs->toArray();
         $nTransFiles = array_sum(array_fetch($tjobs, 'jobfiles'));
         $nTransBytes = array_sum(array_fetch($tjobs, 'jobbytes'));
         // Value for The Graphs
         $graphOkJob = $terminatedJobs != 0 ? $terminatedJobs / ($terminatedJobs + $errorJobs) * 100 : 0;
         $graphFailedJob = $errorJobs != 0 ? $errorJobs / ($errorJobs + $terminatedJobs) * 100 : 0;
         $nTransFiles = preg_replace("/(?<=\\d)(?=(\\d{3})+(?!\\d))/", ",", $nTransFiles);
         $nTransBytes = $this->byte_format($nTransBytes);
     }
     /* Draws Files Graph */
     $graphFiles = DB::table($this->tables['job'])->where('clientid', '=', $clientselected)->where('starttime', '>=', $start)->where('endtime', '<=', $end)->orderby('starttime', 'asc')->remember(10)->get(array(DB::raw('date(' . $this->tables['job'] . '.starttime) as date'), DB::raw('jobfiles as files')));
     $graphFiles = json_encode((array) $graphFiles);
     /* Draws Bytes Graph */
     $graphBytes = DB::table($this->tables['job'])->where('clientid', '=', $clientselected)->where('starttime', '>=', $start)->where('endtime', '<=', $end)->orderby('starttime', 'asc')->remember(10)->get(array(DB::raw('date(' . $this->tables['job'] . '.starttime) as date'), DB::raw('jobbytes as bytes')));
     $graphBytes = json_encode((array) $graphBytes);
     Former::populate(array('date' => $start . ' - ' . $end), array('Client' => $clientselected));
     return View::make('clients', array('terminatedJobs' => $terminatedJobs, 'nTransFiles' => $nTransFiles, 'cancelJobs' => $cancelJobs, 'runningJobs' => $runningJobs, 'wattingJobs' => $wattingJobs, 'errorJobs' => $errorJobs, 'nTransBytes' => $nTransBytes, 'start' => $start, 'end' => $end, 'type' => 'terminated', 'clientSelected' => $clientselected, 'graphOkJob' => $graphOkJob, 'graphFailedJob' => $graphFailedJob, 'platform' => $platform, 'fileretension' => $fileretension, 'jobretension' => $jobretension, 'autoprune' => $autoprune, 'clientSelectBox' => $clientSelectBox, 'graphFiles' => $graphFiles, 'graphBytes' => $graphBytes));
 }
コード例 #2
0
ファイル: JobsController.php プロジェクト: acrixl/Reportula
 public function jobs($job = null)
 {
     Asset::container('footer')->add('amcharts', 'assets/js/amcharts.js');
     Asset::container('footer')->add('jobs', 'assets/js/jobs.js');
     $start = Input::get('start', Date::now()->sub('1 day'));
     $end = Input::get('end', Date::now());
     $jobselected = Input::get('Job', $job);
     if (empty($jobselected)) {
         $jobselected = 0;
     } else {
         $jobselected = Job::select('name')->where('jobid', '=', $jobselected)->remember(10)->get();
         $jobselected = $jobselected->first()->name;
         /* Array Search for Get Id and set the select box when passing url id of job*/
         $job = array_search($jobselected, Job::jobSelectBox());
     }
     $user = Sentry::getUser();
     // Get Clients to fill the Client Select Box And Select Values From Permissions
     $permissions = Userspermissions::where('id', '=', $user->id)->first();
     if ($permissions !== null) {
         $permissions = unserialize($permissions->jobs);
         $jobs = Job::wherein('jobid', $permissions)->remember(10)->get();
         $jobsSelectBox = Job::jobSelectBox($jobs->toArray());
     } else {
         $jobsSelectBox = Job::jobSelectBox();
     }
     ///// End Permissions
     /* Get Included Files & Excluded Files Configuration */
     $cfgjob = "";
     //cfgJob::wherename($jobselected)->first();
     if ($cfgjob != "") {
         $cfgfileset = cfgFileset::wherename($cfgjob->fileset)->remember(10)->first();
         $fileinclude = cfgFileset::find($cfgfileset->id)->filesinclude()->remember(10)->get();
         $fileexclude = cfgFileset::find($cfgfileset->id)->filesexclude()->remember(10)->get();
     } else {
         $fileinclude = "";
         $fileexclude = "";
     }
     ///////////////////////////
     /* Get Terminated Jobs */
     $tjobs = Job::where('jobstatus', '=', 'T')->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('name', '=', $jobselected)->remember(10)->get();
     //dd ($tjobs);
     // Number Terminate Jobs
     $terminatedJobs = count($tjobs);
     /* Get Canceled Jobs */
     $canceledJobs = Job::where('jobstatus', '=', 'A')->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('name', '=', $jobselected)->remember(10)->get();
     // Number Terminate Jobs
     $cancelJobs = count($canceledJobs);
     /* Get Running Jobs */
     $runJobs = Job::where('jobstatus', '=', 'R')->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('name', '=', $jobselected)->remember(10)->get();
     // Number Running Jobs
     $runningJobs = count($runJobs);
     /* Get Watting Jobs */
     $wateJobs = Job::wherein('jobstatus', array('c', 'F', 'j', 'M', 'm', 'p', 's', 't'))->where('endtime', '<=', $end)->where('starttime', '>=', $start)->where('name', '=', $jobselected)->remember(10)->get();
     // Number Watting Jobs
     $wattingJobs = count($wateJobs);
     /* Get Error Jobs */
     $errJobs = Job::wherein('jobstatus', array('e', 'f', 'E'))->where('starttime', '>=', $start)->where('endtime', '<=', $end)->where('name', '=', $jobselected)->remember(10)->get();
     // Number Error Jobs
     $errorJobs = count($errJobs);
     // Indicates Failed and Okay Jobs
     $nTransBytes = 0;
     $nTransFiles = 0;
     $terminatedJobs = count($tjobs);
     /* Calculate Jobs and Bytes */
     $tjobs = $tjobs->toArray();
     if (Config::get('database.default') == 'pgsql') {
         $nTransFiles = array_sum(array_fetch($tjobs, 'jobfiles'));
         $nTransBytes = array_sum(array_fetch($tjobs, 'jobbytes'));
     } else {
         $nTransFiles = array_sum(array_fetch($tjobs, 'JobFiles'));
         $nTransBytes = array_sum(array_fetch($tjobs, 'JobBytes'));
     }
     /* Draw GRaphs */
     $graphBytes = DB::table($this->tables['job'])->where('name', '=', $jobselected)->where('starttime', '>=', $start)->where('endtime', '<=', $end)->orderby('starttime', 'asc')->remember(10)->get(array(DB::raw('date(' . $this->tables['job'] . '.starttime) as date'), DB::raw('jobbytes as bytes')));
     $graphBytes = json_encode((array) $graphBytes);
     $graphFiles = DB::table($this->tables['job'])->where('name', '=', $jobselected)->where('starttime', '>=', $start)->where('endtime', '<=', $end)->orderby('starttime', 'asc')->remember(10)->get(array(DB::raw('date(' . $this->tables['job'] . '.starttime) as date'), DB::raw('jobfiles as files')));
     $graphFiles = json_encode((array) $graphFiles);
     // var_dump($graphFiles);
     Former::populate(array('date' => $start . ' - ' . $end));
     //array('Job' => $jobselected) );
     return View::make('jobs', array('terminatedJobs' => $terminatedJobs, 'nTransFiles' => preg_replace("/(?<=\\d)(?=(\\d{3})+(?!\\d))/", ",", $nTransFiles), 'cancelJobs' => $cancelJobs, 'runningJobs' => $runningJobs, 'wattingJobs' => $wattingJobs, 'errorJobs' => $errorJobs, 'nTransBytes' => $this->byte_format($nTransBytes), 'start' => $start, 'end' => $end, 'job' => $job, 'type' => 'terminated', 'graphOkJob' => $terminatedJobs != 0 ? $terminatedJobs / ($terminatedJobs + $errorJobs) * 100 : 0, 'graphFailedJob' => $errorJobs != 0 ? $errorJobs / ($errorJobs + $terminatedJobs) * 100 : 0, 'filesinclude' => $fileinclude, 'filesexclude' => $fileexclude, 'jobSelectBox' => $jobsSelectBox, 'graphBytes' => $graphBytes, 'graphFiles' => $graphFiles));
 }