@@ -87,8 +87,7 @@ discard block |
||
| 87 | 87 | } |
| 88 | 88 | $this->logging->log('Trap updated : '.$this->oidDesc['name'] . ' / OID : '.$this->oidDesc['oid'],DEBUG ); |
| 89 | 89 | return 1; |
| 90 | - } |
|
| 91 | - else |
|
| 90 | + } else |
|
| 92 | 91 | { |
| 93 | 92 | $this->logging->log('Trap unchanged : '.$this->oidDesc['name'] . ' / OID : '.$this->oidDesc['oid'],DEBUG ); |
| 94 | 93 | return 0; |
@@ -104,7 +103,9 @@ discard block |
||
| 104 | 103 | 'values (:oid, :name , :type ,:mib ,:tc , :display_hint'. |
| 105 | 104 | ', :syntax, :type_enum, :description )'; |
| 106 | 105 | |
| 107 | - if ($this->trapsDB->trapDBType == 'pgsql') $sql .= 'RETURNING id'; |
|
| 106 | + if ($this->trapsDB->trapDBType == 'pgsql') { |
|
| 107 | + $sql .= 'RETURNING id'; |
|
| 108 | + } |
|
| 108 | 109 | |
| 109 | 110 | $sqlQuery=$db_conn->prepare($sql); |
| 110 | 111 | |
@@ -144,7 +145,9 @@ discard block |
||
| 144 | 145 | } |
| 145 | 146 | |
| 146 | 147 | $inserted_id=$ret_code->fetch(PDO::FETCH_ASSOC)['LAST_INSERT_ID()']; |
| 147 | - if ($inserted_id==false) throw new Exception("Weird SQL error : last_insert_id returned false : open issue"); |
|
| 148 | + if ($inserted_id==false) { |
|
| 149 | + throw new Exception("Weird SQL error : last_insert_id returned false : open issue"); |
|
| 150 | + } |
|
| 148 | 151 | $this->dbOidIndex[$this->oidDesc['oid']]['id']=$inserted_id; |
| 149 | 152 | break; |
| 150 | 153 | default: |
@@ -302,7 +305,10 @@ discard block |
||
| 302 | 305 | $this->reset_oidDesc(); |
| 303 | 306 | |
| 304 | 307 | $snmptrans=$this->get_object_details($object, $trapmib); // Get object mib & details |
| 305 | - if ($snmptrans === null) continue; // object not found |
|
| 308 | + if ($snmptrans === null) { |
|
| 309 | + continue; |
|
| 310 | + } |
|
| 311 | + // object not found |
|
| 306 | 312 | |
| 307 | 313 | $this->parse_object($snmptrans); |
| 308 | 314 | |
@@ -453,12 +459,14 @@ discard block |
||
| 453 | 459 | $this->oidDesc['name']=$match[1]; // Name |
| 454 | 460 | $this->oidDesc['type']=$match[2]; // type (21=trap, 0: may be trap, else : not trap |
| 455 | 461 | |
| 456 | - if ($this->oidDesc['type']==0) // object type=0 : check if v1 trap |
|
| 462 | + if ($this->oidDesc['type']==0) { |
|
| 463 | + // object type=0 : check if v1 trap |
|
| 457 | 464 | { |
| 458 | 465 | // Check if next is suboid -> in that case is cannot be a trap |
| 459 | 466 | if (preg_match("/^".$this->oidDesc['oid']."/",$this->objectsAll[$curElement+1])) |
| 460 | 467 | { |
| 461 | 468 | $this->timing['type0_check_time'] += microtime(true) - $this->timing['base_time']; |
| 469 | + } |
|
| 462 | 470 | $this->timing['type0_check_num']++; |
| 463 | 471 | return true; |
| 464 | 472 | } |
@@ -476,9 +484,11 @@ discard block |
||
| 476 | 484 | // Force as trap. |
| 477 | 485 | $this->oidDesc['type']=21; |
| 478 | 486 | } |
| 479 | - if ($onlyTraps===true && $this->oidDesc['type']!=21) // if only traps and not a trap, continue |
|
| 487 | + if ($onlyTraps===true && $this->oidDesc['type']!=21) { |
|
| 488 | + // if only traps and not a trap, continue |
|
| 480 | 489 | { |
| 481 | 490 | $this->timing['nottrap_time'] += microtime(true) - $this->timing['base_time']; |
| 491 | + } |
|
| 482 | 492 | $this->timing['nottrap_num']++; |
| 483 | 493 | return true; |
| 484 | 494 | } |
@@ -503,7 +513,9 @@ discard block |
||
| 503 | 513 | $this->oidDesc['mib']=$match[1]; |
| 504 | 514 | |
| 505 | 515 | $numLine=1; |
| 506 | - while (isset($snmptrans[$numLine]) && !preg_match('/^[\t ]+DESCRIPTION[\t ]+"(.*)/',$snmptrans[$numLine],$match)) $numLine++; |
|
| 516 | + while (isset($snmptrans[$numLine]) && !preg_match('/^[\t ]+DESCRIPTION[\t ]+"(.*)/',$snmptrans[$numLine],$match)) { |
|
| 517 | + $numLine++; |
|
| 518 | + } |
|
| 507 | 519 | if (isset($snmptrans[$numLine])) |
| 508 | 520 | { |
| 509 | 521 | $snmptrans[$numLine] = preg_replace('/^[\t ]+DESCRIPTION[\t ]+"/','',$snmptrans[$numLine]); |
@@ -607,7 +619,10 @@ discard block |
||
| 607 | 619 | $this->timing['num_traps']++; |
| 608 | 620 | |
| 609 | 621 | $this->logging->log('Found trap : '.$this->oidDesc['name'] . ' / OID : '.$this->oidDesc['oid'],INFO ); |
| 610 | - if ($display_progress) echo '#'; // echo a # when trap found |
|
| 622 | + if ($display_progress) { |
|
| 623 | + echo '#'; |
|
| 624 | + } |
|
| 625 | + // echo a # when trap found |
|
| 611 | 626 | |
| 612 | 627 | // get trap objects & source MIB |
| 613 | 628 | |
@@ -624,7 +639,9 @@ discard block |
||
| 624 | 639 | if (($update==0) && ($check_change===false)) |
| 625 | 640 | { // Trapd didn't change & force check disabled |
| 626 | 641 | $this->timing['objects_time'] += microtime(true) - $this->timing['base_time']; |
| 627 | - if ($display_progress) echo "C"; |
|
| 642 | + if ($display_progress) { |
|
| 643 | + echo "C"; |
|
| 644 | + } |
|
| 628 | 645 | continue; |
| 629 | 646 | } |
| 630 | 647 | |
@@ -64,8 +64,7 @@ discard block |
||
| 64 | 64 | if ($pid == 1) |
| 65 | 65 | { |
| 66 | 66 | $trap->setLogging($logLevel,'display'); |
| 67 | - } |
|
| 68 | - else |
|
| 67 | + } else |
|
| 69 | 68 | { // use default display TODO : if default is 'display' son process will be killed at first output.... |
| 70 | 69 | if ($pid != 0) |
| 71 | 70 | { |
@@ -74,8 +73,7 @@ discard block |
||
| 74 | 73 | fclose($file); |
| 75 | 74 | echo "OK : process $pid in bckground"; |
| 76 | 75 | return 0; |
| 77 | - } |
|
| 78 | - else |
|
| 76 | + } else |
|
| 79 | 77 | { // son process : close all file descriptors and go to a new session |
| 80 | 78 | fclose($file); |
| 81 | 79 | // $sid = posix_setsid(); |
@@ -85,8 +83,7 @@ discard block |
||
| 85 | 83 | try |
| 86 | 84 | { |
| 87 | 85 | $trap->mibClass->update_mib_database(false,$forceCheck); |
| 88 | - } |
|
| 89 | - catch (Exception $e) |
|
| 86 | + } catch (Exception $e) |
|
| 90 | 87 | { |
| 91 | 88 | $trap->trapLog('Error in updating : ' . $e->getMessage(),2); |
| 92 | 89 | } |
@@ -103,8 +100,7 @@ discard block |
||
| 103 | 100 | $trap->mibClass->update_mib_database(true,$forceCheck); |
| 104 | 101 | echo "Done\n"; |
| 105 | 102 | |
| 106 | - } |
|
| 107 | - catch (Exception $e) |
|
| 103 | + } catch (Exception $e) |
|
| 108 | 104 | { |
| 109 | 105 | echo 'Error in updating : ' . $e->getMessage(); |
| 110 | 106 | } |
@@ -147,8 +143,7 @@ discard block |
||
| 147 | 143 | $Config->getMIBCacheTableName(), |
| 148 | 144 | 'id>0'); |
| 149 | 145 | echo 'Deleted '. $query . " traps and objects\n"; |
| 150 | - } |
|
| 151 | - catch (Exception $e) |
|
| 146 | + } catch (Exception $e) |
|
| 152 | 147 | { |
| 153 | 148 | echo 'Error in DB : ' . $e->getMessage(); |
| 154 | 149 | } |