';
$moreinfo = true;
$menucol = (!empty($heading)?count($heading):0) - 1;
// SQL statement
$sql = "SELECT SQL_CALC_FOUND_ROWS p.id,
'app->Conf->WFconf['defaulttheme']}/images/details_open.png class=details>' AS open,
p.bezeichnung, p.art,
p.periode,
IF(p.recommended_period >0 AND p.art='periodisch', p.recommended_period,'-'),
if(p.aktiv,'ja','-') as aktiviert, if(p.mutex,
CONCAT(
'ja',if(p.mutexcounter > 0,concat(' (Anzahl Versuche ',p.mutexcounter,')'),'')
),'-')
as laeuft, date_format(p.letzteausfuerhung, '%d.%m.%Y %H:%i:%s') as 'letzte Ausführung',
p.typ, p.parameter,concat(p.status_zeit,' ',p.status), p.id
FROM `prozessstarter` AS `p` ";
$where = ' p.id > 0 ';
$more_data1 = $this->app->Secure->GetGET('more_data1');
if ($more_data1 == 1) {
$subwhere[] = ' p.aktiv=1 ';
}
if(!empty($subwhere)){
$tmp = implode(' AND ', $subwhere);
}
if($tmp!=''){
$where .= " AND ($tmp)";
}
//$groupby=" GROUP by z.adresse_abrechnung ";
// gesamt anzahl
$count = "SELECT COUNT(id) FROM prozessstarter p WHERE $where";
break;
}
$erg = array();
foreach($erlaubtevars as $k => $v)
{
if(isset($$v)){
$erg[$v] = $$v;
}
}
return $erg;
}
/**
* Prozessstarter constructor.
*
* @param Application $app
* @param bool $intern
*/
public function __construct($app, $intern = false) {
$this->app=$app;
if($intern) {
return;
}
$this->app->ActionHandlerInit($this);
$this->app->ActionHandler("create","ProzessstarterCreate");
$this->app->ActionHandler("edit","ProzessstarterEdit");
$this->app->ActionHandler("list","ProzessstarterList");
$this->app->ActionHandler("delete","ProzessstarterDelete");
$this->app->ActionHandler("reset","ProzessstarterReset");
$this->app->ActionHandler("chart","ProzessstarterChart");
$this->app->ActionHandler("minidetail","ProzessstarterMinidetail");
$this->app->ActionHandlerListen($app);
}
public function Install() {
$this->app->erp->CheckTable('cronjob_log');
$this->app->erp->CheckColumn('parent_id','INT(11)','cronjob_log','DEFAULT 0 NOT NULL');
$this->app->erp->CheckColumn('cronjob_id','INT(11)','cronjob_log','DEFAULT 0 NOT NULL');
$this->app->erp->CheckColumn('memory_usage','INT(11)','cronjob_log','DEFAULT 0 NOT NULL');
$this->app->erp->CheckColumn('memory_peak','INT(11)','cronjob_log','DEFAULT 0 NOT NULL');
$this->app->erp->CheckColumn('cronjob_name','varchar(255)','cronjob_log','DEFAULT "" NOT NULL');
$this->app->erp->CheckColumn('change_time','timestamp','cronjob_log','DEFAULT CURRENT_TIMESTAMP NOT NULL');
$this->app->erp->CheckColumn('status','varchar(32)','cronjob_log','DEFAULT "" NOT NULL');
$this->app->erp->CheckIndex('cronjob_log', ['cronjob_id','change_time']);
$this->app->erp->RegisterHook('ajax_filter_hook1','prozessstarter','ProzessstarterAjaxFilter');
$this->app->erp->RegisterHook('systemhealth_fill_entries','prozessstarter','ProzessstarterSystemhealthFillEntries');
$this->app->erp->CheckTable('cronjob_starter_running');
$this->app->erp->CheckColumn('uid','VARCHAR(23)','cronjob_starter_running','NOT NULL');
$this->app->erp->CheckColumn('active','TINYINT(1)','cronjob_starter_running','DEFAULT 0 NOT NULL');
$this->app->erp->CheckColumn('type','VARCHAR(10)','cronjob_starter_running','NOT NULL');
$this->app->erp->CheckColumn('task_id','INT(11)','cronjob_starter_running','DEFAULT 0 NOT NULL');
$this->app->erp->CheckColumn('last_time','TIMESTAMP','cronjob_starter_running','DEFAULT CURRENT_TIMESTAMP NOT NULL');
$this->app->erp->CheckIndex('cronjob_starter_running',['uid','type']);
if(!$this->app->erp->GetKonfiguration('prozessstarter_log_repair2')) {
$cronjobLogs = $this->app->DB->Query('SELECT * FROM cronjob_log WHERE cronjob_id > 0 ORDER BY cronjob_id, change_time, id');
$cronjobId = 0;
$parentId = 0;
while($cronjobLog = $this->app->DB->Fetch_Assoc($cronjobLogs)) {
if($cronjobId !== $cronjobLog['cronjob_id']) {
$cronjobId = $cronjobLog['cronjob_id'];
$parentId = 0;
}
if($cronjobLog['status'] === 'start' || $cronjobLog['status'] === 'gestartet') {
$parentId = $cronjobLog['id'];
}
elseif($parentId != $cronjobLog['parent_id']) {
$this->app->DB->Update(
sprintf(
'UPDATE cronjob_log SET parent_id = %d WHERE id = %d',
$parentId, $cronjobLog['id']
)
);
}
}
$this->app->erp->SetKonfigurationValue('prozessstarter_log_repair2', 1);
}
$this->removeKilledCronjobs();
}
/**
* @return array
*/
public function getToFrequentlyCronjobs()
{
return $this->app->DB->SelectFirstCols(
sprintf(
"SELECT DISTINCT `parameter`
FROM `prozessstarter`
WHERE `aktiv` = 1 AND `art` = 'periodisch' AND `periode` < `recommended_period` AND `recommended_period` > 0"
)
);
}
/**
* @param array $parmeterList
*
* @return string
*/
public function getFrequentlyMessage($parmeterList)
{
if(empty($parmeterList)) {
return '';
}
if((!empty($parmeterList)?count($parmeterList):0) === 1) {
return 'Der Prozessstarter '
.implode(', ', $parmeterList).' läuft häufiger als empfohlen';
}
return 'Die Prozessstarter '
.implode(', ', $parmeterList).' laufen häufiger als empfohlen';
}
/**
* @param int $id
*
* @return bool
*/
public function resetPeriode($id = 0)
{
$this->app->DB->Update(
sprintf(
"UPDATE `prozessstarter`
SET `periode` = `recommended_period`
WHERE `aktiv` = 1 AND `art` = 'periodisch' AND `periode` < `recommended_period` AND `recommended_period` > 0
AND (%d = 0 OR `id` = %d)",
$id, $id
)
);
$ret = $this->app->DB->affected_rows() > 0;
if($ret) {
$this->ProzessstarterSystemhealthFillEntries();
}
return $ret;
}
public function ProzessstarterSystemhealthFillEntries()
{
$countToFrequently = $this->getToFrequentlyCronjobs();
$message = $this->getFrequentlyMessage($countToFrequently);
if(!empty($message)) {
$message = ''.$message.'';
}
/** @var Systemhealth $systemhealth */
$systemhealth = $this->app->loadModule('systemhealth');
$systemhealth->changeStatus('cronjobs', 'frequently', empty($message)?'OK':'warning', $message);
}
/**
* @param string $filtername
* @param array $newarr
* @param string $term
* @param string $term2
* @param string $term3
*/
public function ProzessstarterAjaxFilter($filtername, &$newarr, $term, $term2, $term3)
{
if($filtername === 'prozessstarter_aktiv'){
$arr = $this->app->DB->SelectArr(
"SELECT DISTINCT CONCAT(parameter,' ',bezeichnung) as `name`
FROM prozessstarter
WHERE parameter LIKE '%$term%' OR bezeichnung = '%$term%'
ORDER BY parameter"
);
if(empty($arr)) {
return;
}
foreach($arr as $row) {
$newarr[] = $row['name'];
}
}
}
/**
* @param string $date
* @param int $roundMinutes
*
* @return string
*/
protected function roundDate($date, $roundMinutes = 15) {
$return = substr($date,0,14);
$minutes = substr($date,14,2);
$minutes = floor($minutes / $roundMinutes) * $roundMinutes;
if(strlen($minutes) === 1) {
$minutes = '0'.$minutes;
}
return $return.$minutes.':00';
}
/**
* @param array $data
* @param string $field
*
* @return array
*/
protected function seperateData($data, $field) {
$ret = [];
foreach($data as $row) {
$ret['K'.$row[$field]][] = $row;
}
return $ret;
}
/**
* @param array $data
* @param string $fieldValue
* @param string $dateField
* @param DateInterval $interval
*
* @return array
*/
protected function roundDataDates($data, $fieldValue, $dateField, $interval) {
$return = [];
if(empty($data)) {
return [];
}
$seconds = 60 * $interval->i;
foreach($data as $key => $arr) {
$cronjobIntervals = [];
foreach($arr as $rowIndex => $row) {
if($row[$fieldValue] > 0) {
if(empty($cronjobIntervals) || empty($cronjobIntervals[(!empty($cronjobIntervals)?count($cronjobIntervals):0) - 1])) {
$cronjobIntervals[] = ['start' => $this->roundDate($row[$dateField]), 'startexact'=>$row[$dateField]];
}
$cronjobIntervals[(!empty($cronjobIntervals)?count($cronjobIntervals):0) - 1]['end'] = $this->roundDate($row[$dateField], $interval->i);
$cronjobIntervals[(!empty($cronjobIntervals)?count($cronjobIntervals):0) - 1]['endexact'] = $row[$dateField];
}
else {
if(empty($cronjobIntervals)) {
continue;
}
if(!empty($cronjobIntervals[(!empty($cronjobIntervals)?count($cronjobIntervals):0) - 1])) {
$cronjobIntervals[(!empty($cronjobIntervals)?count($cronjobIntervals):0) - 1]['end'] = $this->roundDate($row[$dateField], $interval->i);
$cronjobIntervals[(!empty($cronjobIntervals)?count($cronjobIntervals):0) - 1]['endexact'] = $row[$dateField];
}
$cronjobIntervals[] = [];
}
}
$return[$key] = [];
$dateToKeys = [];
foreach($cronjobIntervals as $cronjobInterval) {
if(empty($cronjobInterval)) {
continue;
}
$start = new DateTime($cronjobInterval['start']);
$end = new DateTime($cronjobInterval['end']);
$val = 100* (
(strtotime($cronjobInterval['endexact']) - strtotime($cronjobInterval['startexact'])+0.1) /
(strtotime($cronjobInterval['start']==$cronjobInterval['end']?$cronjobInterval['start']+$seconds:$cronjobInterval['end'])
-strtotime($cronjobInterval['start']))
);
if($val > 100) {
$val = 100;
}
$dateFielValue = $start->format('d.m.Y H:i:s');
if(isset($dateToKeys[$dateFielValue])) {
$return[$key][$dateToKeys[$dateFielValue]][$fieldValue] += $val;
if($return[$key][$dateToKeys[$dateFielValue]][$fieldValue] > 100) {
$return[$key][$dateToKeys[$dateFielValue]][$fieldValue] = 100;
}
}
else {
$return[$key][] = [$dateField => $dateFielValue, $fieldValue => $val];
$dateToKeys[$dateFielValue] = count($return[$key])-1;
}
while(strtotime($start->format('Y-m-d H:i:s')) < strtotime($end->format('Y-m-d H:i:s'))) {
$start->add($interval);
$dateFielValue = $start->format('d.m.Y H:i:s');
if(isset($dateToKeys[$dateFielValue])) {
$return[$key][$dateToKeys[$dateFielValue]][$fieldValue] += $val;
}
else {
$return[$key][] = [$dateField => $dateFielValue, $fieldValue => $val];
$dateToKeys[$dateFielValue] = count($return[$key])-1;
}
}
}
}
return $return;
}
/**
* @param array $data
* @param string $field
* @param string $nameField
*
* @return mixed
*/
protected function formatData($data, $field = 'running',$nameField = 'bezeichnung') {
if(empty($data)) {
return $data;
}
foreach($data as $key => $arr) {
if(empty($arr)) {
continue;
}
foreach($arr as $rowIndex => $row) {
$data[$key][$rowIndex][$row[$nameField]] = $row[$field]?round($row[$field],2):0;//sqrt
}
}
return $data;
}
/**
* @param string $formelementDate
* @param string $formelementTime
* @param bool $from
*
* @return array
*/
public function getDatesFromForm($formelementDate, $formelementTime, $from = false) {
$last12h = $this->app->Secure->GetPOST('last12h');
$last6h = $this->app->Secure->GetPOST('last6h');
if(!empty($last12h) || !empty($last6h)) {
$diff = 12;
if(!empty($last6h)) {
$diff = 6;
}
if($from) {
list($date, $time) = explode(' ', (new DateTime())->add(new DateInterval('PT5M'))->sub(new DateInterval('PT'.$diff.'H'))->format('d.m.Y H:i'),2);
}
else {
list($date, $time) = explode(' ', (new DateTime())->add(new DateInterval('PT5M'))->format('d.m.Y H:i'),2);
}
}
else{
if(!empty($formelementDate)) {
$date = $this->app->Secure->GetPOST($formelementDate);
}
else{
$date = '';
}
if(!empty($formelementTime)) {
$time = $this->app->Secure->GetPOST($formelementTime);
}
else{
$time = '';
}
}
if(empty($time)) {
$time = '00:00:00';
}
else {
$time = substr($time,0,5). ':00';
}
if(empty($date)) {
$date = new DateTime();
if($from) {
$date->sub(new DateInterval('P1D'));
}
$dateFormated = $date->format('d.m.Y');
$timeFormated = $date->format('H:i');
$date = $date->format('Y-m-d H:i:s');
}
elseif(strpos($date,'.') !== false) {
$dateFormated = substr($date,0, 10);
$date = $this->app->String->Convert($dateFormated,'%1.%2.%3','%3-%2-%1').' '.$time;
$timeFormated = substr($time,0,5);
}
else {
$dateFormated = $this->app->String->Convert($date,'%3-%2-%1','%1.%2.%3').' '.$time;
$timeFormated = substr($time,0,5);
}
$date = $this->roundDate($date);
return [$date, $dateFormated, $timeFormated];
}
/**
* @param string $dateFrom
* @param string $dateTo
* @param int $cronjobId
* @param int $limit
*
* @return string
*/
protected function getChart($dateFrom, $dateTo, $cronjobId = 0, $limit = 0) {
$extra = '';
if($cronjobId > 0) {
$extra = sprintf(' AND p.id = %d ',$cronjobId);
}
/*$sql = sprintf(
'
SELECT DATE_FORMAT(cl2.change_time, \'%%d.%%m.%%Y %%H:%%i\') as `date`,
IF(cl2.status <> \'abgeschlossen\' AND SUBSTRING(cl2.status,1,5) != \'mutex\' ,1,0) as `running` ,cl2.status,cl2.cronjob_id,p.bezeichnung
FROM (
SELECT change_time, id ,cronjob_id
FROM cronjob_log
WHERE status = \'start\'
) AS cl1
INNER JOIN (
SELECT change_time, id, status, parent_id ,cronjob_id
FROM cronjob_log
) AS cl2 ON (cl1.id = cl2.parent_id OR cl1.id = cl2.id) AND cl1.cronjob_id = cl2.cronjob_id
INNER JOIN prozessstarter AS p ON cl1.cronjob_id = p.id AND p.aktiv = 1
WHERE (cl2.change_time >= \'%s\' OR cl1.change_time >= \'%s\')
AND (cl2.change_time <= \'%s\' OR cl1.change_time <= \'%s\')
%s
ORDER BY cl2.cronjob_id,cl2.change_time, cl2.id
', $dateFrom, $dateFrom,$dateTo,$dateTo, $extra
);*/
$sql = sprintf(
'
SELECT DATE_FORMAT(cl.change_time, \'%%d.%%m.%%Y %%H:%%i\') as `date`,
IF(cl.status <> \'abgeschlossen\' AND SUBSTRING(cl.status,1,5) != \'mutex\' ,1,0) as `running` ,
cl.status,cl.cronjob_id,p.bezeichnung
FROM cronjob_log as cl
INNER JOIN prozessstarter AS p ON cl.cronjob_id = p.id AND p.aktiv = 1
WHERE cl.change_time >= \'%s\'
AND cl.change_time <= \'%s\'
%s
ORDER BY cl.cronjob_id,cl.change_time, cl.id
', (new DateTime($dateFrom))->sub(new DateInterval( 'P1D'))->format('Y-m-d H:i:s') ,
$dateTo, $extra
);
$cronjobArr = $this->app->DB->SelectArr($sql);
$begin = new DateTime($dateFrom);
if($dateFrom === $dateTo) {
$dateTo = new DateTime($dateFrom);
$dateTo = $dateTo->add(new DateInterval( 'P1D'))->format('Y-m-d H:i:s');
}
$end = new DateTime($dateTo);
list($months, $days, $hours) = explode(' ',$end->diff($begin)->format('%m %d %h'));
$days += $months * 30;
if($days === 0) {
$interval = new DateInterval('PT1M');
}
elseif($days <= 1) {
$interval = new DateInterval('PT5M');
}
else {
$interval = new DateInterval('PT15M');
}
foreach($cronjobArr as $row) {
$cronjobIdToName['K'.$row['cronjob_id']] = $row['bezeichnung'];
}
$seperated = $this->seperateData($cronjobArr, 'cronjob_id');
$seperated = $this->roundDataDates($seperated, 'running','date', $interval);
foreach($seperated as $cronjobIdKey => $rows) {
foreach($rows as $rowKey => $row) {
$seperated[$cronjobIdKey][$rowKey]['bezeichnung'] = $cronjobIdToName[$cronjobIdKey];
}
}
$seperated = $this->formatData($seperated,'running');
$sorted = [];
foreach($seperated as $cronjobIdKey => $rows) {
$maxValue = 0;
foreach($rows as $element) {
if($element['running'] > $maxValue) {
$maxValue = $element['running'];
}
}
$sorted[$cronjobIdKey] = $maxValue;
}
array_multisort($sorted,SORT_DESC,$seperated);
$matchedDatas = [];
$period = new PeriodMatcher($begin, $end, $interval, 'd.m.Y H:i:s');
$maxCronjobs = $limit === 0?999999:$limit;
foreach($seperated as $cronjobIdKey => $cronjobRow) {
$maxCronjobs--;
if($maxCronjobs < 0) {
unset($seperated[$cronjobIdKey]);
continue;
}
$matchedDatas[$cronjobIdKey] = $period->matchData(
$cronjobRow,
'date'
,$cronjobIdToName[$cronjobIdKey]
);
}
$labels = $period->getDates();
$options = [];
$chart = new Chart('line',[],[],$options);
$chart->addLabels($labels);
$first = true;
foreach($seperated as $cronjobIdKey => $matchedData) {
if($first) {
$first = false;
$chart->addDatasetAsYAxis(
new Dataset($cronjobIdToName[$cronjobIdKey],
$matchedDatas[$cronjobIdKey]), 'left' );//,'logarithmic'
}
else {
$chart->addDataset(new Dataset($cronjobIdToName[$cronjobIdKey], $matchedDatas[$cronjobIdKey]));
}
}
$chartRenderer = new HtmlRenderer($chart, 'Laufzeiten', 400, 150);
return $chartRenderer->render();
}
public function ProzessstarterChart() {
$this->ProzessstarterMenu();
list($dateFrom, $dateFromTpl, $dateFromTime) =
$this->getDatesFromForm('prozessstarter_chart_from','prozessstarter_chart_fromtime',true);
list($dateTo, $dateToTpl, $dateToTime) =
$this->getDatesFromForm('prozessstarter_chart_to','prozessstarter_chart_totime',false);
$cronjobFilter = $this->app->Secure->GetPOST('prozessstarter_chart_cronjob');
$this->app->Tpl->Set('PROZESSSTARTER_CHART_FROM',$dateFromTpl);
$this->app->Tpl->Set('PROZESSSTARTER_CHART_TO',$dateToTpl);
$this->app->Tpl->Set('PROZESSSTARTER_CHART_FROMTIME',$dateFromTime);
$this->app->Tpl->Set('PROZESSSTARTER_CHART_TOTIME',$dateToTime);
$this->app->Tpl->Set('PROZESSSTARTER_CHART_CRONJOB',$cronjobFilter);
if(!empty($cronjobFilter)) {
$cronjobFilter = $this->app->DB->Select(
sprintf(
'SELECT id FROM prozessstarter WHERE parameter = \'%s\''
,$cronjobFilter
)
);
}
$limit = $this->app->Secure->GetPOST('prozessstarter_chart_limit')?4:0;
if($limit > 0) {
$this->app->Tpl->Set('PROZESSSTARTER_CHART_LIMIT',' checked="checked" ');
}
$this->app->Tpl->Set('TAB1', $this->getChart($dateFrom, $dateTo, $cronjobFilter, $limit));
$this->app->YUI->DatePicker('prozessstarter_chart_from');
$this->app->YUI->DatePicker('prozessstarter_chart_to');
$this->app->YUI->TimePicker('prozessstarter_chart_fromtime');
$this->app->YUI->TimePicker('prozessstarter_chart_totime');
$this->app->YUI->AutoComplete('prozessstarter_chart_cronjob','prozessstarter_aktiv',1);
$this->app->Tpl->Parse('PAGE','prozessstarter_chart.tpl');
}
public function ProzessstarterMinidetail() {
$cronjobId = (int)$this->app->Secure->GetGET('id');
$dateFrom = $this->getDatesFromForm('','',true);
$dateFrom = reset($dateFrom);
$dateTo = $this->getDatesFromForm('','',false);
$dateTo = reset($dateTo);
echo $this->getChart($dateFrom, $dateTo, $cronjobId);
echo '';
$lastCronjobLogs = $this->app->DB->SelectFirstCols(
sprintf(
'SELECT `id` FROM `cronjob_log` WHERE `cronjob_id` = %d AND `parent_id` = 0 ORDER BY `id` DESC LIMIT 5',
$cronjobId
)
);
if(!empty($lastCronjobLogs)) {
$table = new EasyTable($this->app);
$sql = sprintf(
"SELECT DATE_FORMAT(cl2.`change_time`,'%%d.%%m.%%Y %%H:%%i:%%s') AS `Datum`,
IF(cl.id=cl2.id,CONCAT('',cl2.status,''), cl2.`status`) AS `Status`
FROM `cronjob_log` AS `cl`
INNER JOIN `cronjob_log` AS `cl2` ON (cl.id = cl2.parent_id AND cl2.parent_id IN (%s))
OR (cl.id = cl2.id AND cl2.id IN (%s))
WHERE cl.`id` IN (%s)
ORDER BY cl.`id` DESC, cl2.id",
implode(',', $lastCronjobLogs),
implode(',', $lastCronjobLogs),
implode(',', $lastCronjobLogs)
);
$table->Query($sql);
$table->width_headings = ['20%'];
echo $table->DisplayNew('return','Status','noAction');
}
$this->app->erp->ExitWawi();
}
/**
* @param string $status
* @param null|int $prozessstarter
*/
public function setCronjobStatus($status, $prozessstarter = null)
{
if($prozessstarter !== null) {
$this->currentCronjobId = $prozessstarter;
if(emptY($this->currentCronjobId)) {
$this->parentId = 0;
$this->currentCronjobName = '';
}
}
if(!$this->currentCronjobId){
return;
}
if($status === 'gestartet' || $status === 'start') {
$this->currentCronjobName = $this->app->DB->Select(
sprintf(
'SELECT `parameter` FROM `prozessstarter` WHERE `id` = %d LIMIT 1',
$this->currentCronjobId
)
);
$this->app->DB->Insert(
sprintf(
"INSERT INTO `cronjob_log`
(`cronjob_id`, `cronjob_name`, `status`,`change_time`,`memory_usage`,`memory_peak`)
VALUES (%d, '%s', 'start',now(),%d,%d)",
$this->currentCronjobId, $this->currentCronjobName,
memory_get_usage()/1024, memory_get_peak_usage()/1024
)
);
$this->parentId = $this->app->DB->GetInsertID();
}
else {
if(empty($this->currentCronjobName)) {
$this->currentCronjobName = $this->app->DB->Select(
sprintf(
'SELECT `parameter` FROM `prozessstarter` WHERE `id` = %d LIMIT 1',
$this->currentCronjobId
)
);
}
if(empty($this->parentId)) {
$this->parentId = (int)$this->app->DB->Select(
sprintf(
'SELECT `id`
FROM `cronjob_log`
WHERE status = \'start\' AND `cronjob_id` = %d
ORDER BY `change_time` DESC, `id` DESC
LIMIT 1',
$this->currentCronjobId
)
);
}
$this->app->DB->Insert(
sprintf(
"INSERT INTO `cronjob_log`
(`parent_id`, `cronjob_id`, `cronjob_name`,`status`,`change_time`,`memory_usage`,`memory_peak`)
VALUES (%d, %d, '%s', '%s',now(),%d,%d)",
$this->parentId, $this->currentCronjobId, $this->currentCronjobName, $status,
memory_get_usage()/1024, memory_get_peak_usage()/1024
)
);
}
$this->app->DB->Update(
sprintf(
"UPDATE `prozessstarter` SET `status` = '%s',
`status_zeit` = now() WHERE `id` = %d LIMIT 1",
$this->app->DB->real_escape_string($status), $this->currentCronjobId
)
);
}
public function ProzessstarterReset(){
$id = (int)$this->app->Secure->GetGET('id');
if($id > 0){
$this->app->DB->Update(
sprintf('UPDATE prozessstarter SET letzteausfuerhung=\'0000-00-00 00:00:00\' WHERE id = %s', $id)
);
}
$data = ['success' => true];
echo json_encode($data);
$this->app->ExitXentral();
}
public function ProzessstarterDelete()
{
$id = (int)$this->app->Secure->GetGET('id');
if($id > 0){
$this->app->DB->Delete(
sprintf(
'DELETE FROM `prozessstarter` WHERE `id` = %d LIMIT 1',
$id
)
);
$this->app->DB->Update(
sprintf(
'UPDATE cronjob_starter_running SET `active` = -1 WHERE `task_id` = %d AND `active` = 1 ',
$id
)
);
$this->ProzessstarterSystemhealthFillEntries();
}
$this->app->Location->execute('index.php?module=prozessstarter&action=list');
}
public function ProzessstarterCreate()
{
$this->ProzessstarterMenu();
parent::ProzessstarterCreate();
}
public function ProzessstarterList()
{
if($this->app->Secure->GetPOST('resetperiode')) {
$this->resetPeriode();
$this->app->Location->execute('index.php?module=prozessstarter&action=list');
}
if($this->app->Secure->GetPOST('resetcronjob')) {
$this->resetCronjobs(60);
}
$this->ProzessstarterMenu();
$letzteraufruf = $this->app->erp->GetKonfiguration('prozessstarter_letzteraufruf');
$diff = time() - strtotime($letzteraufruf);
if($diff > 60*5+1) // mit sicherheitsabstand :-)
{
$this->app->Tpl->Set('MESSAGE','
Es sieht so aus, als ob der Prozessstarter Cronjob nicht regelmäßig ausgeführt wird! Bitte aktivieren Sie diesen (Link zu Helpdesk)!
');
}
if($this->app->DB->Select(
"SELECT id FROM prozessstarter WHERE aktiv = 1 AND parameter = 'autoversand' LIMIT 1"
)) {
if($this->app->DB->Select(
"SELECT id FROM prozessstarter WHERE aktiv = 1 AND parameter = 'autoversand' AND periode < 30 AND art = 'periodisch' LIMIT 1"
))
{
$this->app->Tpl->Add(
'MESSAGE',
'
Der Prozess Autoversand ist auf eine Periodendauer von unter 30 Minuten eingestellt. Deshalb wird er nicht ausgeführt. Eine zu niedrige Einstellung verursacht eine zu hohe Serverlast
'
);
}
else {
$this->app->Tpl->Add(
'MESSAGE',
'
Der Prozess Autoversand kann eine hohe Serverlast verursachen. Es ist ratsam die Art auf Uhrzeit oder die Periode auf eine hohe Zahl zu stellen.
Es steht zu wenig Arbeitsspeicher zur Verfügung ('.(round($system_cronjob_memory_limit / 1024 / 1024)).' MB). Dies kann zu Problemen bei den Prozessstartern führen. Technische Info: Bitte passen Sie für den PHP CLI Prozess den Arbeitsspeicher an (z.B. 256 MB oder 512 MB).