Usually, you do not need to setup an email server under Linux. Most GUI email clients support Gmail POP3 and IMAP configurations. But, how do you send mail via the standard /usr/bin/mail user agents in a shell script? Programs such as sendmail / postfix / exim can be configured as a gmail smarthost but they are largely overkill for this use. The ssmtp program is a neat utility that does just that for you via gmail.
It would appear that gigabit LAN is not! In fact it often runs at the same speed as 100Mbps LAN. Let's look at why exactly.
After configuring your network you can use the ifconfig command to see what speeds the LAN is connected. Even though 1000Mbps is reported by the card, the reality is that the overall throughtput may well be ~100Mpbs. You can try copying a large file using scp to demonstrate this.
As it turns out, in order to use a gigabit LAN you need to use CAT6 cables. CAT5 and CAT5E are not good enough. End result, the ethernet cards throttle back the speed to reduce dropped packets and errors.
You can find a good article here titled Squeeze Your Gigabit NIC for Top Performance. After tuning up the TCP parameters i found that it made no dfifference. The principal reasons behind low gigabit ethernet performance can be summed up as follows.
- Need to use CAT6 cables
- Slow Disk speed
- Limitations of the PCI bus which the gigabit ethernet cards use
You can get an idea about the disk speed using the hdparm command:
Display the disk partitions and choose the main linux partition which has the / filesystem.
# fdisk -l
Then get disk cache and disk read statistics:
# hdparm -Tt /dev/sda0
On my desktop system the sata disk perfomance is a limiting factor. These were the results:
/dev/sda1:
Timing cached reads: 9984 MB in 2.00 seconds = 4996.41 MB/sec
Timing buffered disk reads: 84 MB in 3.13 seconds = 58.49 MB/sec
Well, that equates to a raw disk read speed of 58.49 * 8 = 467Mbps which is half the speed of a gigabit LAN.
So.. NAS storage with lots of memory looks to be the way to go... If you use the right cables!
In this article Barry Mavin, CEO and Chief Software Architect for Recital details how to Build C Extension Libraries to use with Recital.
Overview
It is possible to extend the functionaliy of Recital products using "Extension libraries" that can be written in C. These extension libraries, written using the Recital/SDK API, are dynamically loadable from all Recital 9 products. This includes:
- Recital
- Recital Server
- Recital Web
Building C Extension Libraries
You can create C wrappers for virtually any native operating system function and access these from the Recital 4GL. Unlike traditional APIs which only handle the development of C functions that are callable from the 4GL, the Recital/SDK allows you to build Classes that are accessible from all Recital products. e.g. You could create a GUI framework for Linux that handles VFP system classes!
To deploy your C Extension Libraries, copy them to the following location:
Windows:
\Program Files\Recital\extensions
Linux/Unix:
/opt/recital/extensions
Please see the Recital/SDK API Reference documentation for further details.
Sample code
Listed below is the complete example of a C Extension Library.:
//////////////////////////////////////////////////////////////////////////////// #include "mirage_demo.h" //////////////////////////////////////////////////////////////////////////////// // Declare your functions and classes below as follows: // // Recital Function Name, C Function Name, Type (Function or Class) // #define MAX_ELEMENTS 7 static struct API_SHARED_FUNCTION_TABLE api_function_table[MAX_ELEMENTS] = { {"schar", "fnSamplesCharacter", API_FUNCTION}, {"stype", "fnSamplesType", API_FUNCTION}, {"slog", "fnSamplesLogical", API_FUNCTION}, {"snum", "fnSamplesNumeric", API_FUNCTION}, {"sopen", "fnSamplesOpen", API_FUNCTION}, {"myclass", "clsMyClass", API_CLASS}, {NULL, NULL, -1} }; //////////////////////////////////////////////////////////////////////////////// // Recital API initialization. This should be in only ONE of your C files // **IT SHOULD NEVER BE EDITED OR REMOVED** INIT_API; /////////////////////////////////////////////////////////////////////// // This is an example of passing a character parameter and returning one. RECITAL_FUNCTION fnSamplesCharacter(void) { char *arg1; if (!_parse_parameters(PCOUNT, "C", &arg1)) { ERROR(-1, "Incorrect parameters"); } _retc(arg1); } /////////////////////////////////////////////////////////////////////// // This is an example of passing a numeric parameter and returning one. RECITAL_FUNCTION fnSamplesNumeric(void) { int arg1; if (!_parse_parameters(PCOUNT, "N", &arg1)) { ERROR(-1, "Incorrect parameters"); } _retni(arg1); } /////////////////////////////////////////////////////////////////////// // This is an example returns the data type of the parameter passed. RECITAL_FUNCTION fnSamplesType(void) { char result[10]; if (PCOUNT != 1) { ERROR(-1, "Incorrect parameters"); } switch (_parinfo(1)) { case API_CTYPE: strcpy(result, "Character"); break; case API_NTYPE: strcpy(result, "Numeric"); break; case API_LTYPE: strcpy(result, "Logical"); break; case API_DTYPE: strcpy(result, "Date"); break; case API_TTYPE: strcpy(result, "DateTime"); break; case API_YTYPE: strcpy(result, "Currency"); break; case API_ATYPE: strcpy(result, "Array"); break; default: strcpy(result, "Unkown"); break; } _retc(result); } /////////////////////////////////////////////////////////////////////// // This is an example returns "True" or False. RECITAL_FUNCTION fnSamplesLogical(void) { char result[10]; int arg1; if (!_parse_parameters(PCOUNT, "L", &arg1)) { ERROR(-1, "Incorrect parameters"); } if (arg1) strcpy(result, "True"); else strcpy(result, "False"); _retc(result); } /////////////////////////////////////////////////////////////////////// // This example opens a table. RECITAL_FUNCTION fnSamplesOpen(void) { char *arg1; if (!_parse_parameters(PCOUNT, "C", &arg1)) { ERROR(-1, "Incorrect parameters"); } if (_parinfo(1) == API_CTYPE) { _retni(COMMAND(arg1)); } else { _retni(-1); } } /////////////////////////////////////////////////////////////////////// // Define the MyClass CLASS using the API macros /////////////////////////////////////////////////////////////////////// RECITAL_EXPORT int DEFINE_CLASS(clsMyClass) { /*-------------------------------------*/ /* Dispatch factory methods and return */ /*-------------------------------------*/ DISPATCH_FACTORY(); /*---------------------------------*/ /* Dispatch constructor and return */ /*---------------------------------*/ DISPATCH_METHOD(clsMyClass, Constructor); /*--------------------------------*/ /* Dispatch destructor and return */ /*--------------------------------*/ DISPATCH_METHOD(clsMyClass, Destructor); /*-----------------------------------*/ /* Dispatch DEFINE method and return */ /*-----------------------------------*/ DISPATCH_METHOD(clsMyClass, Define); /*------------------------------*/ /* Dispatch SET or GET PROPERTY */ /* method for property NumValue */ /* then return. */ /*------------------------------*/ DISPATCH_PROPSET(clsMyClass, NumValue); DISPATCH_PROPGET(clsMyClass, NumValue); /*------------------------------*/ /* Dispatch SET or GET PROPERTY */ /* method for property LogValue */ /* then return. */ /*------------------------------*/ DISPATCH_PROPSET(clsMyClass, LogValue); DISPATCH_PROPGET(clsMyClass, LogValue); /*-------------------------------*/ /* Dispatch SET or GET PROPERTY */ /* method for property DateValue */ /* then return. */ /*-------------------------------*/ DISPATCH_PROPSET(clsMyClass, DateValue); DISPATCH_PROPGET(clsMyClass, DateValue); /*-------------------------------*/ /* Dispatch SET or GET PROPERTY */ /* method for property TimeValue */ /* then return. */ /*-------------------------------*/ DISPATCH_PROPSET(clsMyClass, TimeValue); DISPATCH_PROPGET(clsMyClass, TimeValue); /*-------------------------------*/ /* Dispatch SET or GET PROPERTY */ /* method for property CurrValue */ /* then return. */ /*-------------------------------*/ DISPATCH_PROPSET(clsMyClass, CurrValue); DISPATCH_PROPGET(clsMyClass, CurrValue); /*-------------------------------*/ /* Dispatch SET or GET PROPERTY */ /* method for property CharValue */ /* then return. */ /*-------------------------------*/ DISPATCH_PROPSET(clsMyClass, CharValue); DISPATCH_PROPGET(clsMyClass, CharValue); /*------------------------------*/ /* Dispatch SET or GET PROPERTY */ /* method for property ObjValue */ /* then return. */ /*------------------------------*/ DISPATCH_PROPSET(clsMyClass, ObjValue); DISPATCH_PROPGET(clsMyClass, ObjValue); /*-----------------------------------*/ /* If message not found return error */ /*-----------------------------------*/ OBJECT_RETERROR("Unknown message type"); } //////////////////////////////////////////////////////////////////////////////// // Define METHOD handlers //////////////////////////////////////////////////////////////////////////////// DEFINE_METHOD(clsMyClass, Constructor) { struct example_data *objectDataArea; /* Allocate memory for objects objectData area */ objectDataArea = (struct example_data *) malloc(sizeof(struct example_data)); if (objectDataArea == NULL) return(-1); /* Assign the default property values */ strcpy(objectDataArea->prop_charvalue, "Test API object"); objectDataArea->prop_numvalue = 15.2827; objectDataArea->prop_logvalue = 'F'; strcpy(objectDataArea->prop_datevalue, DATE_DATE()); strcpy(objectDataArea->prop_timevalue, DATE_DATETIME()); strcpy(objectDataArea->prop_currvalue, "15.2827"); strcpy(objectDataArea->object_name, "APIobject"); objectDataArea->prop_objvalue = OBJECT_NEW(objectDataArea->object_name, "exception", NULL); /* Set the object objectData area */ OBJECT_SETDATA((char *)objectDataArea); return(0); } DEFINE_METHOD(clsMyClass, Destructor) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); if (objectData != NULL) { if (objectData->prop_objvalue != NULL) OBJECT_DELETE(objectData->prop_objvalue); free(objectData); objectData = NULL; } return(0); } DEFINE_METHOD(clsMyClass, Define) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); struct API_EXPRESSION result; char buffer[512]; int rc; /* Check the object class */ OBJECT_GETPROPERTY(objectData->prop_objvalue, "class", buffer); rc = OBJECT_GETARG(buffer, &result); if (result.errno == 0 && result.type == 'C' && strcmp(result.character, "Exception") == 0) { switch (OBJECT_GETARGC()) { case 1: rc = OBJECT_GETPARAMETER(1, &result); if (result.errno == 0 && result.type == 'C') { OBJECT_SETARG(buffer, &result); rc = OBJECT_SETPROPERTY(objectData->prop_objvalue, "message", buffer); } break; case 2: rc = OBJECT_GETPARAMETER(2, &result); if (result.errno == 0 && result.type == 'N') { OBJECT_SETARG(buffer, &result); rc = OBJECT_SETPROPERTY(objectData->prop_objvalue, "errorno", buffer); } } } result.type = 'L'; result.logical = (rc == 0 ? 'T' : 'F'); OBJECT_RETRESULT(&result); } //////////////////////////////////////////////////////////////////////////////// // Define GET property handlers //////////////////////////////////////////////////////////////////////////////// DEFINE_PROPERTYGET(clsMyClass, NumValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); if (objectData == NULL) return(-1); OBJECT_RETPROPERTY('N', objectData->prop_numvalue); } DEFINE_PROPERTYGET(clsMyClass, LogValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); if (objectData == NULL) return(-1); OBJECT_RETPROPERTY('L', objectData->prop_logvalue); } DEFINE_PROPERTYGET(clsMyClass, DateValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); if (objectData == NULL) return(-1); OBJECT_RETPROPERTY('D', objectData->prop_datevalue); } DEFINE_PROPERTYGET(clsMyClass, TimeValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); if (objectData == NULL) return(-1); OBJECT_RETPROPERTY('T', objectData->prop_timevalue); } DEFINE_PROPERTYGET(clsMyClass, CurrValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); if (objectData == NULL) return(-1); OBJECT_RETPROPERTY('Y', objectData->prop_currvalue); } DEFINE_PROPERTYGET(clsMyClass, CharValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); if (objectData == NULL) return(-1); OBJECT_RETPROPERTY('C', objectData->prop_charvalue); } DEFINE_PROPERTYGET(clsMyClass, ObjValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); if (objectData == NULL) return(-1); OBJECT_RETPROPERTY('O', objectData->prop_objvalue); } //////////////////////////////////////////////////////////////////////////////// // Define SET property handlers //////////////////////////////////////////////////////////////////////////////// DEFINE_PROPERTYSET(clsMyClass, NumValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); struct API_EXPRESSION result; int rc = OBJECT_ERROR; OBJECT_GETVALUE(&result); if (result.errno == 0 && result.type == 'N') { objectData->prop_numvalue = result.number; rc = OBJECT_SUCCESS; } return(rc); } DEFINE_PROPERTYSET(clsMyClass, LogValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); struct API_EXPRESSION result; int rc = OBJECT_ERROR; OBJECT_GETVALUE(&result); if (result.errno == 0 && result.type == 'L') { objectData->prop_logvalue = result.logical; rc = OBJECT_SUCCESS; } return(rc); } DEFINE_PROPERTYSET(clsMyClass, DateValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); struct API_EXPRESSION result; int rc = OBJECT_ERROR; OBJECT_GETVALUE(&result); if (result.errno == 0 && result.type == 'D') { strcpy(objectData->prop_datevalue, DATE_DTOS(result.date)); rc = OBJECT_SUCCESS; } return(rc); } DEFINE_PROPERTYSET(clsMyClass, TimeValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); struct API_EXPRESSION result; int rc = OBJECT_ERROR; OBJECT_GETVALUE(&result); if (result.errno == 0 && result.type == 'T') { strcpy(objectData->prop_timevalue, DATE_TTOS(result.datetime)); rc = OBJECT_SUCCESS; } return(rc); } DEFINE_PROPERTYSET(clsMyClass, CurrValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); struct API_EXPRESSION result; int rc = OBJECT_ERROR; OBJECT_GETVALUE(&result); if (result.errno == 0 && result.type == 'Y') { strcpy(objectData->prop_currvalue, CURR_YTOS(result.currency)); rc = OBJECT_SUCCESS; } return(rc); } DEFINE_PROPERTYSET(clsMyClass, CharValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); struct API_EXPRESSION result; int rc = OBJECT_ERROR; OBJECT_GETVALUE(&result); if (result.errno == 0 && result.type == 'C') { strcpy(objectData->prop_currvalue, result.character); rc = OBJECT_SUCCESS; } return(rc); } DEFINE_PROPERTYSET(clsMyClass, ObjValue) { struct example_data *objectData = (struct example_data *)OBJECT_GETDATA(); OBJECT objvalue; int rc = OBJECT_ERROR; if (OBJECT_GETTYPE() == 'O') { objvalue = OBJECT_GETOBJECT(); objectData->prop_objvalue = OBJECT_ASSIGN(objvalue, objectData->object_name); rc = OBJECT_SUCCESS; } return(rc); }
If when your attempt to create device meta-data fails this is drbd preventing you from corrupting a file system present on the target partition.
$ drbdadm create-md drbd0
v08 Magic number not found
md_offset 30005817344
al_offset 30005784576
bm_offset 30004867072
Found ext2 filesystem which uses 190804004 kB
current configuration leaves usable 29301628 kB
Device size would be truncated, which
would corrupt data and result in
'access beyond end of device' errors.
You need to either
* use external meta data (recommended)
* shrink that filesystem first
* zero out the device (destroy the filesystem)
Operation refused.
Command 'drbdmeta /dev/drbd0 v08 /dev/sda4 internal create-md' terminated with exit code 40
drbdadm aborting
Once you have confirmed that the file system present on the target partition is no longer required at the prompt type the following:
Replace /dev/sdaX with the block device you are targeting.
dd if=/dev/zero of=/dev/sdaX bs=1M count=128
Once this has completed the drbdadm create-md drbd0 command will complete with a "success."
$ drbdadm create-md drbd0
v08 Magic number not found
v07 Magic number not found
v07 Magic number not found
v08 Magic number not found
Writing meta data...
initialising activity log
NOT initialized bitmap
New drbd meta data block successfully created.
success
$
In this article Yvonne Milne looks at the use of the Recital Remote Data Connectivity Functions with Recital Database Gateways.
The Openfiler NAS/SAN Appliance (NSA) is a Storage Management Operating System / NAS Appliance distribution. It is powered by the Linux 2.6 kernel and Open Source applications such as Apache, Samba, LVM2, ext3, Linux NFS and iSCSI Enterprise Target. Openfiler combines these ubiquitous technologies into a small, easy to manage solution fronted by a powerful web-based management interface. Openfiler allows you to build a Network Attached Storage (NAS) and/or Storage Area Network (SAN) appliance, using industry-standard hardware, in less than 10 minutes of installation time.
Building upon the popularity of server virtualization technologies such as VMware, Virtual Iron, and Xen, Openfiler can also be deployed as a virtual machine instance or on a bare metal machine.
This deployment flexibility of Openfiler ensures that storage administrators are able to make the best use of system performance and storage capacity resources when allocating and managing networked storage in a multi-platform environment.
Openfiler is ideally suited for use with High Availability Recital applications as it incorporates:
- Heartbeat cluster manager
- drbd disk replication
- CIFS
- NFS
- Software and hardware RAID
- FTP
- rsync
- HTTP/DAV
- iSCSI
- LVM2
- Multiple NIC bonding for High Availability
- Powerful web-based GUI
In this article Barry Mavin, CEO and Chief Software Architect for Recital, details Working with Stored Procedures in the Recital Database Server.
Overview
Stored procedures and user-defined functions are collections of SQL statements and optional control-of-flow statements written in the Recital 4GL (compatible with VFP) stored under a name and saved in a Database. Both stored procedures and user-defined functions are just-in-time compiled by the Recital database engine. Using the Database Administrator in Recital Enterprise Studio, you can easily create, view, modify, and test Stored Procedures, Triggers, and user-defined functions
Creating and Editing Stored Procedures
To create a new Stored Procedure, right-click the Procedures node in the Databases tree of the Project Explorer and choose Create. To modify an existing stored procedure select the Stored Procedure in the Databases Tree in the Project Explorer by double-clicking on it or selecting Modify from the context menu . By convertion we recommend that you name your Stored Procedures beginning with "sp_xxx_", user-defined functions with "f_xxx_", and Triggers with "dt_xxx_", where xxx is the name of the table that they are associated with.
Testing the Procedure
To test run the Stored Procedure, select the Stored Procedure in the Databases Tree in the Project Explorer by double-clicking on it. Once the Database Administrator is displayed, click the Run button to run the procedure.
Getting return values
Example Stored Procedure called "sp_myproc":
parameter arg1, arg2 return arg1 + arg2
Example calling the Stored Procedure from C# .NET:
//////////////////////////////////////////////////////////////////////// // include the references below using System.Data; using Recital.Data; //////////////////////////////////////////////////////////////////////// // sample code to call a Stored Procedure that adds to numeric values together public int CallStoredProcedure() { RecitalConnection conn = new RecitalConnection("Data Source=localhost;Database=southwind;uid=?;pwd=?"); RecitalCommand cmd = new RecitalCommand(); cmd.Connection = conn; cmd.CommandText = "sp_myproc(@arg1, @arg2)"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters["@arg1"].Value = 10; cmd.Parameters["@arg2"].Value = 20; conn.Open(); cmd.ExecuteNonQuery(); int result = (int)(cmd.Parameters["retvalue"].Value); // get the return value from the sp conn.Close(); return result; }
Writing Stored Procedures that return a Resultset
If you want to write a Stored Procedure that returns a ResultSet, you use the SETRESULTSET() function of the 4GL. Using the Universal .NET Data Provider, you can then execute the 4GL Stored Procedure and return the ResultSet to the client application for processing. ResultSets that are returned from Stored Procedures are read-only.
Example Stored Procedure called "sp_myproc":
parameter query select * from customers &query into cursor "mydata" return setresultset("mydata")
Example calling the Stored Procedure from C# .NET:
//////////////////////////////////////////////////////////////////////// // include the references below using System.Data; using Recital.Data; //////////////////////////////////////////////////////////////////////// // sample code to call a stored procedure that returns a ResultSet public void CallStoredProcedure() { RecitalConnection conn = new RecitalConnection("Data Source=localhost;Database=southwind;uid=?;pwd=?"); RecitalCommand cmd = new RecitalCommand(); cmd.Connection = conn; cmd.CommandText = "sp_myproc(@query)"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters["@query"].Value = "where not deleted()"; conn.Open(); RecitalDataReader dreader = cmd.ExecuteReader(); int sqlcnt = (int)(cmd.Parameters["sqlcnt"].Value); // returns number of affected rows while (dreader.Read()) { // read and process the data } dreader.Close(); conn.Close(); }
For systems that do not have the xterm libraries installed, please install these to use xterm, or set the DB_TERM environment variable to start Recital from a terminal:
DB_TERM=gnome-terminal; export DB_TERM
This setting can be added to the /opt/recital/conf/recital.conf (text) file to make it available system-wide.
Please note that the Recital ODBC Driver for Linux requires a 32 bit ODBC Driver Manager.
Centos 6:
sudo yum install zlib-devel.i686 pam-devel.i686(and accept dependencies)
Then run the installer in text mode
sudo ./recital-10.0.3-linux32.bin --mode textRun Recital with sudo the first time, to set the system filetype compatiblity settings.
sudo recitalAfter saving the compatibility settings, quit to exit, then run Recital as your preferred user.
> quit
$ recital
RedHat / Fedora family:
sudo yum install zlib-devel.i686 pam.i686(and accept dependencies)
Then run the installer in text mode
sudo ./recital-10.0.3-linux32.bin --mode textRun Recital with sudo the first time, to set the system filetype compatiblity settings.
sudo recitalAfter saving the compatibility settings, quit to exit, then run Recital as your preferred user.
> quit
$ recital
Ubuntu family:
sudo apt-get install ia32-libsIn later versions of Ubuntu, ia32-libs is obsolete. The following package should be installed:
sudo apt-get install lib32z1Ubuntu 12.04 and above also require the following:
sudo apt-get install libpam0g:i386Then run the installer in text mode
sudo ./recital-10.0.3-linux32.bin --mode textRun Recital with sudo the first time, to set the system filetype compatiblity settings.
sudo recitalAfter saving the compatibility settings, quit to exit, then run Recital as your preferred user.
> quit
$ recital