internet & kittens
Anyway. It is currently being tested, and the downloads look like they are coming down at full speed. So I am happy about that.
So, I come home today, and everybody is in my bed.
Tags: computing
*******************************************************************************/
/***********************************
* Configuration *
* ------------- *
* All fields in this section must *
* be altered to match your local *
* network settings. *
***********************************/
/*
* Pick the predefined TCP/IP configuration for this sample. See
* LIBRARIESTCP_IPTCP_CONFIG.LIB for instructions on how to set the
* configuration.
*/
#define TCPCONFIG 1
/** Remote interface to send PING to (passed to resolve()): **/
/* Undefine to retrieve default gateway and ping that. */
#define PING_WHO "mike.creuzer.com"
#define FROM "ServerMonitor@creuzer.com"
#define TO "ServerMonitor@creuzer.com"
#define SUBJECT "Monitor Update"
#define DOWNBODY "Server is down."
#define UPBODY "Server is back up."
/*
* The SMTP_SERVER macro tells DCRTCP where your mail server is. This
* mail server MUST be configured to relay mail for your controller.
*
* This value can be the name or the IP address.
*/
/*
* The SMTP_SERVER macro tells DCRTCP where your mail server is. This
* mail server MUST be configured to relay mail for your controller.
*
* This value can be the name or the IP address.
*/
#define SMTP_SERVER "smtp-server.tampabay.rr.com"
/*
* The SMTP_DOMAIN should be the name of your controller. i.e.
* "somecontroller.somewhere.com" Many SMTP servers ignore this
* value, but some SMTP servers use this field. If you have
* problems, turn on the SMTP_DEBUG macro and see were it is
* bombing out. If it is in the HELO command consult the
* person in charge of the mail server for the appropriate value
* for SMTP_DOMAIN. If you do not define this macro it defaults
* to the value in MY_IP_ADDRESS.
*
*/
#define SMTP_DOMAIN "aquaria.serveblog.com"
/*
* The SMTP_VERBOSE macro logs the communications between the mail
* server and your controller. Uncomment this define to begin
* logging
*/
// #define SMTP_VERBOSE
/********************************
* End of configuration section *
********************************/
#use dcrtcp.lib
#use smtp.lib
int main()
{
longword seq,lastpingrecieved,ping_who,tmp_seq,time_out;
char buffer[100];
int down, sentdown, sentup;
sock_init();
// Wait for the interface to come up
while (ifpending(IF_DEFAULT) == IF_COMING_UP) {
tcp_tick(NULL);
}
/* Print who we are... */
printf( "My IP address is %snn", inet_ntoa(buffer, gethostid()) );
/*
* Get the binary ip address for the target of our
* pinging.
*/
#ifdef PING_WHO
/* Ping a specific IP addr: */
ping_who=resolve(PING_WHO);
if(ping_who==0) {
printf("ERROR: unable to resolve %sn",PING_WHO);
return 1;
}
#else
/* Examine our configuration, and ping the default router: */
tmp_seq = ifconfig( IF_ANY, IFG_ROUTER_DEFAULT, & ping_who, IFS_END );
if( tmp_seq != 0 ) {
printf( "ERROR: ifconfig() failed --> %dn", (int) tmp_seq );
return 1;
}
if(ping_who==0) {
printf("ERROR: unable to resolve IF_ROUTER_DEFAULTn");
return 1;
}
#endif
seq=0;
lastpingrecieved = 0;
down = 0;
sentdown = 0;
sentup = 0;
for(;;) {
/*
* It is important to call tcp_tick here because
* ping packets will not get processed otherwise.
*/
tcp_tick(NULL);
/*
* Send one ping per second.
*/
costate {
//waitfor(DelaySec(1));
waitfor(DelaySec(60));
_ping(ping_who,seq++);
}
/*
* Has a ping come in? time_out!=0xfffffff->yes.
*/
time_out=_chk_ping(ping_who,&tmp_seq);
if(time_out!=0xffffffff){
if(down == 1){
printf("Service has been restored. n");
down = 0;
smtp_sendmail(TO, FROM, SUBJECT, UPBODY);
while(smtp_mailtick()==SMTP_PENDING)
continue;
if(smtp_status()==SMTP_SUCCESS)
printf("Message sentn");
else
printf("Error sending messagen");
}
printf("Received Ping: %ld %ldn", tmp_seq, time_out);
lastpingrecieved = tmp_seq;
sentdown = 0;
}else
{
if (seq - lastpingrecieved >= 5 && sentdown == 0){
printf("Host Unavailable. n");
down = 1;
sentdown = 1;
smtp_sendmail(TO, FROM, SUBJECT, DOWNBODY);
while(smtp_mailtick()==SMTP_PENDING)
continue;
if(smtp_status()==SMTP_SUCCESS)
printf("Message sentn");
else
printf("Error sending messagen");
}
}
} // end FOR
}
Tags: computing
Tags: computing
/* Output Buffer
* We are doing something a bit odd here. The home page is the most hit page on the site. There are a LOT of calls on the home page to database, etc.
*
* In an attempt to make the server load go down, this index.php file will write out an index.html file as a static file
* This takes advantage of the fact that apache is looking for index.html before index.php
* running index.php will create index.html
* removing index.html will cause index.php to run and create index.html
*
* A cronjob removes index.html hourly
* Admin tools that modify data that could be displayed on the homepage should cause to have deleted index.html
*
* You can manually force an update to index.html by loading www.r-world.com/index.php (a clever way is to have the webmaster bookmark index.php as his start page.)
*
*/
function callback($buffer)
{
// lets write this page out to index.html.
$indexbufferfilename = 'index.html';
$indexbuffererror = '';
if (!$handle = fopen($indexbufferfilename, 'w')){
$indexbuffererror .= "Cannot open file ($indexbufferfilename)n";
exit;
}
if (fwrite($handle, $buffer) === FALSE) {
$indexbuffererror.= "Cannot write to file ($indexbufferfilename)n";
exit;
}
//echo "Success, wrote ($somecontent) to file($indexbufferfilename)";
fclose($handle);
if(!empty($indexbuffererror))
{
mail('webmaster@r-world.com', "Error in creating homepage", $indexbuffererror);
}
// send the page to the browser
return $buffer;
}
ob_start("callback");
ob_end_flush(); as the very last line of code on the page.
Directory Index index.html index.php
RewriteEngine On
RewriteCond %{REQUEST_FILENAME} !-s
RewriteRule ^index.html$ index.php [L]
Tags: computing
Tags: computing
Tags: computing

Tags: computing
Tags: computing
Tags: computing
Well, here it is... a video of the automatic fish feeder in action. Sorry it is dark, blurry, grainy, and jerks around a bit, but it is the best I could do considering how excited I am. The Rabbitcore is currently running the servo-stop locater program that I wrote to find out how far each of my servos will run stop to stop, and what numerics I need to use for programming each individual servo. The two buttons I am pushing just moves the servo from one setting to the other. This program works well to check the functionality of the embedded microcontroller controlled automatic fish feeder.
Tags: computing
Build an idiot proof computer system, and they will build a better idiot.Happy Coding!
Tags: computing