improvements

This commit is contained in:
Grzegorz Surmann 2024-07-19 01:48:56 +00:00
parent cbc2ce2610
commit 2b8111cb3e

View File

@ -1,12 +1,14 @@
#!/usr/bin/php #!/usr/bin/php
<?php <?php
if ( !file_exists("/opt/bgpblist/etc/config.ini") ) { $mypath="/opt/bgpblist";
$myurl="https://hosts.funil.de/custom/";
if ( !file_exists($mypath."/etc/config.ini") ) {
echo "ERROR: no config file\n"; echo "ERROR: no config file\n";
copy("/opt/bgpblist/etc/default/config.ini","/opt/bgpblist/etc/config.ini"); copy($mypath."/etc/default/config.ini",$mypath."/etc/config.ini");
echo "INFO: file created, edit it before next start\n"; echo "INFO: file created, edit it before next start\n";
die(); die();
} }
$conf=parse_ini_file("/opt/bgpblist/etc/config.ini",TRUE); $conf=parse_ini_file($mypath."/etc/config.ini",TRUE);
$customer=$conf["customer"]["cust_uuid"]; $customer=$conf["customer"]["cust_uuid"];
$logfile=$conf["syslog"]["logfile"]; $logfile=$conf["syslog"]["logfile"];
declare(ticks = 1); declare(ticks = 1);
@ -15,17 +17,27 @@ pcntl_signal(SIGINT,"sig_handler");
pcntl_signal(SIGTERM,"sig_handler"); pcntl_signal(SIGTERM,"sig_handler");
pcntl_signal(SIGHUP,"sig_handler"); pcntl_signal(SIGHUP,"sig_handler");
$prev_bad=array(); $prev_bad=array();
$file_size=0;
$full_url=$myurl.$customer.'/csubscr_aggr.txt';
clean_routes(); clean_routes();
while(TRUE) { while(TRUE) {
$cycle_beg=microtime(TRUE); $cycle_beg=microtime(TRUE);
logtofile("CYCLE_BEG"); logtofile("CYCLE_BEG");
$raw=@file_get_contents('https://hosts.funil.de/custom/'.$customer.'/csubscr_aggr.txt'); $raw=@file_get_contents($full_url);
$prev_size=$file_size;
$file_size=strlen($raw);
if ( strlen($raw) == 0 ) { if ( strlen($raw) == 0 ) {
logtofile("EMPTY_REM"); logtofile("EMPTY_REM");
$sleeptime=10; $sleeptime=10;
logtofile("SLEEP: ".$sleeptime."s"); logtofile("SLEEP: ".$sleeptime."s");
sleep($sleeptime); sleep($sleeptime);
continue; continue;
} elseif ( $file_size == $prev_size ) {
logtofile("NO_CHANGE ".$prev_size);
$sleeptime=10;
logtofile("SLEEP: ".$sleeptime."s");
sleep($sleeptime);
continue;
} }
$tmp=explode("\n",$raw); $tmp=explode("\n",$raw);
$bad_nets=array(); $bad_nets=array();