logo
members lotus pics linux hacks links
How to show PHP source code | Ninan stats in Conky from RSS | ADSL Fix

How to show PHP source code
To format PHP code to be shown via HTML run php -s -q source.php > output.html. Handy!


Quick Conky status for Ninan
A quick one liner to add to your .conkyrc to get your Ninan download stats into
Conky
${execi 30 curl -s -S http://ninan-host:9090/ninan/rssfeed?XXX=YYY| grep "title" | sed -e "s/<title>//g" -e "s/<\/title>//g" |dos2unix} 
Output:
Ninan Status:
      Ninan is running @ 0 KB/s
      Total time remaining:
      Total size: 0 KB

Fixing my ADSL Line
Another quick little scrip that I've knocked up. For some reason, known only by BT, my ADSL connection randomly loses sync and the ADSL service needs to be restarted. This is a bit tricky when I'm not at home, so I made a script that's run regualrly from cron. It checks that the line is in sync, if it isn't then it automatically restarts the necessary services .
<?
$status_tabbed 
exec("/usr/bin/cnxadslstatus | grep NO | wc -l");
$status =  trim($status_tabbed);
//echo $status;
if ($status){
    echo(
exec ("date +\"%T %a %D\""));
    echo 
"\nADSL Line Lost Sync, killing pppd...";
    
exec("kill `ps -ef | grep ppp[d] | awk '{print $2}'`");
    echo 
"\npppd killed, stopping ADSL service...";
    
sleep(10);
    
exec("/sbin/service cnxadslctl stop");
    echo 
"\nADSL service stopped, restarting now...";
    
exec("/sbin/service cnxadslctl start");
    echo 
"\nADSL service restarted, restarting network";
    
exec ("/sbin/service network restart");
    echo 
"\nNetwork back online, reconfiguring firewall...";
        
exec ("/sbin/service shorewall restart");
    echo 
"\nADSL should be back online, woohoo!\n";
    echo(
exec ("date +\"%T %a %D\""));
    die();
}
?>

potchin [v]: To alter excessively or needlessly
  Server up 1 days 10 hrs 51 mins