Skip to content

Commit

Permalink
Merge pull request #784 from rems117/pinghosts_edit
Browse files Browse the repository at this point in the history
pinghosts edit
  • Loading branch information
sergejey committed Nov 18, 2020
2 parents 0e824bc + a6e3b23 commit 862705d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
13 changes: 7 additions & 6 deletions modules/pinghosts/pinghosts.class.php
Expand Up @@ -233,25 +233,26 @@ function checkAllHosts($limit=1000) {

$old_status=$host['STATUS'];

if ($host['COUNTER_REQUIRED']) {
if ($host['COUNTER_REQUIRED'] and $new_status!=1) {
$old_status_expected=$host['STATUS_EXPECTED'];
$host['STATUS_EXPECTED']=$new_status;
if ($old_status_expected!=$host['STATUS_EXPECTED']) {
$host['COUNTER_CURRENT']=0;
$host['LOG']=date('Y-m-d H:i:s').' tries counter reset (status: '.$host['STATUS_EXPECTED'].')'."\n".$host['LOG'];
$host['LOG']=date('Y-m-d H:i:s').' tries counter reset (status: '.str_replace('2', 'offline', $host['STATUS_EXPECTED']).')'."\n".$host['LOG'];
} elseif ($host['STATUS']!=$host['STATUS_EXPECTED']) {
$host['COUNTER_CURRENT']++;
$host['LOG']=date('Y-m-d H:i:s').' tries counter increased to '.$host['COUNTER_CURRENT'].' (status: '.$host['STATUS_EXPECTED'].')'."\n".$host['LOG'];
$host['LOG']=date('Y-m-d H:i:s').' tries counter increased to '.$host['COUNTER_CURRENT'].' (status: '.str_replace('2', 'offline', $host['STATUS_EXPECTED']).')'."\n".$host['LOG'];
}
if ($host['COUNTER_CURRENT']>=$host['COUNTER_REQUIRED']) {
$host['STATUS']=$host['STATUS_EXPECTED'];
$host['COUNTER_CURRENT']=0;
} elseif ($old_status!=$new_status) {
$interval=min($online_interval, $offline_interval, 20);
$online_interval=$interval;
$offline_interval=$interval;
$online_interval=min($online_interval, 20);
}
} else {
if ($host['COUNTER_REQUIRED'] and $old_status==1 and $host['STATUS_EXPECTED']==2 and $new_status==1) {
$host['LOG']=date('Y-m-d H:i:s').' Host is still online'."\n".$host['LOG'];
}
$host['STATUS']=$new_status;
$host['STATUS_EXPECTED']=$host['STATUS'];
$host['COUNTER_CURRENT']=0;
Expand Down
4 changes: 2 additions & 2 deletions templates/pinghosts/pinghosts_edit.html
Expand Up @@ -143,10 +143,10 @@

<div class="form-group ">
<label class="col-lg-4 control-label" for="inputTitle">
<#LANG_COUNTER_REQUIRED#>:
<#LANG_COUNTER_REQUIRED#> (only for switching from Online to Offline):
</label>
<div class="col-lg-5">
<input type="text" name="counter_required" class="form-control" value="[#COUNTER_REQUIRED#]" size="10" class="span1"> <#LANG_COUNTER_REQUIRED_COMMENT#>
<input type="text" name="counter_required" class="form-control" value="[#COUNTER_REQUIRED#]" size="10" class="span1"> <#LANG_COUNTER_REQUIRED_COMMENT#> (the interval between these attempts will be 20 sec if the set value is greater)
</div>
</div>

Expand Down

0 comments on commit 862705d

Please sign in to comment.