Expat-IT Tech Bits

Home

Contact

Links

Search this site:

Categories:

/ (287)
  Admin/ (122)
    Apache/ (10)
      HTTPS-SSL/ (4)
      PHP/ (3)
      performance/ (2)
    Cherokee/ (1)
    LAN/ (4)
    LVM/ (6)
    Monitoring/ (2)
      munin/ (2)
    SSH/ (6)
    SSL/ (1)
    Samba/ (1)
    VPN-options/ (6)
      OpenVPN/ (1)
      SSH-Proxy/ (3)
      Tinc/ (1)
      sshuttle/ (1)
    backups/ (17)
      SpiderOak/ (1)
      backuppc/ (5)
      dirvish/ (1)
      misc/ (6)
      rdiff-backup/ (1)
      rsync/ (1)
      unison/ (2)
    commandLine/ (24)
      files/ (8)
      misc/ (10)
      network/ (6)
    crontab/ (1)
    databases/ (15)
      MSSQL/ (2)
      MySQL/ (8)
      Oracle/ (3)
      PostgreSQL/ (1)
    dynamicDNS/ (2)
    email/ (11)
      Dovecot/ (1)
      deliverability/ (1)
      misc/ (1)
      postfix/ (7)
      puppet/ (1)
    iptables/ (3)
    tripwire/ (1)
    virtualization/ (9)
      VMware/ (1)
      virtualBox/ (8)
  Coding/ (14)
    bash/ (1)
    gdb/ (1)
    git/ (3)
    php/ (5)
    python/ (4)
      Django/ (2)
  Education/ (1)
  Hosting/ (27)
    Amazon/ (18)
      EBS/ (3)
      EC2/ (10)
      S3/ (1)
      commandline/ (4)
    Godaddy/ (2)
    NearlyFreeSpeech/ (3)
    Rackspace/ (1)
    vpslink/ (3)
  Linux/ (30)
    Android/ (1)
    Awesome/ (3)
    CPUfreq/ (1)
    China/ (2)
    Debian/ (8)
      APT/ (3)
      WPA/ (1)
    audio/ (1)
    encryption/ (3)
    fonts/ (1)
    misc/ (6)
    remoteDesktop/ (1)
    router-bridge/ (3)
  SW/ (45)
    Micro$soft/ (1)
    browser/ (2)
      Chrome/ (1)
      Firefox/ (1)
    business/ (28)
      Drupal/ (9)
      KnowledgeTree/ (6)
      Redmine/ (2)
      SugarCRM/ (7)
      WebERP/ (2)
      WordPress/ (1)
      eGroupware/ (1)
    chat/ (1)
    email/ (1)
    fileSharing/ (2)
      btsync/ (1)
      mldonkey/ (1)
    graphics/ (2)
    research/ (2)
    website/ (6)
      blog/ (6)
        blosxom/ (3)
        rss2email/ (1)
        webgen/ (1)
  Security/ (15)
    IMchat/ (2)
    circumvention/ (2)
    cryptoCurrency/ (1)
    e-mail/ (4)
    greatFirewall/ (1)
    hacking/ (1)
    password/ (1)
    privacy/ (2)
    skype/ (1)
  Services/ (1)
    fileSharing/ (1)
  TechWriting/ (1)
  xHW/ (14)
    Lenovo/ (1)
    Motorola_A1200/ (2)
    Thinkpad_600e/ (1)
    Thinkpad_a21m/ (3)
    Thinkpad_i1300/ (1)
    Thinkpad_x24/ (1)
    USB_audio/ (1)
    scanner/ (1)
    wirelessCards/ (2)
  xLife/ (17)
    China/ (9)
      Beijing/ (5)
        OpenSource/ (3)
    Expatriation/ (1)
    Vietnam/ (7)

Archives:

  • 2016/07
  • 2016/05
  • 2016/02
  • 2016/01
  • 2015/12
  • 2015/11
  • 2015/06
  • 2015/01
  • 2014/12
  • 2014/11
  • 2014/10
  • 2014/09
  • 2014/07
  • 2014/04
  • 2014/02
  • 2014/01
  • 2013/12
  • 2013/10
  • 2013/08
  • 2013/07
  • 2013/06
  • 2013/05
  • 2013/04
  • 2013/02
  • 2013/01
  • 2012/12
  • 2012/10
  • 2012/09
  • 2012/08
  • 2012/07
  • 2012/06
  • 2012/05
  • 2012/04
  • 2012/03
  • 2012/01
  • 2011/12
  • 2011/11
  • 2011/10
  • 2011/09
  • 2011/08
  • 2011/07
  • 2011/06
  • 2011/05
  • 2011/04
  • 2011/02
  • 2010/12
  • 2010/11
  • 2010/10
  • 2010/09
  • 2010/08
  • 2010/07
  • 2010/06
  • 2010/05
  • 2010/04
  • 2010/03
  • 2010/02
  • 2010/01
  • 2009/12
  • 2009/11
  • 2009/10
  • 2009/09
  • 2009/08
  • 2009/07
  • 2009/06
  • 2009/05
  • 2009/04
  • 2009/03
  • 2009/02
  • 2009/01
  • 2008/12
  • 2008/11
  • 2008/10
  • 2008/09
  • Subscribe XML RSS Feed

    Creative Commons License
    This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.
    PyBlosxom

    This site has no ads. To help with hosting, crypto donations are accepted:
    Bitcoin: 1JErV8ga9UY7wE8Bbf1KYsA5bkdh8n1Bxc
    Zcash: zcLYqtXYFEWHFtEfM6wg5eCV8frxWtZYkT8WyxvevzNC6SBgmqPS3tkg6nBarmzRzWYAurgs4ThkpkD5QgiSwxqoB7xrCxs

    Wed, 19 Aug 2009


    /xHW/Thinkpad_a21m: Motherboard is Dying

    In recent days this poor suffering Thinkpad a21m (running pretty much all day, every day for the past four years) has taken to locking-up periodically, and then sometimes refusing to start afterwards. When it does the latter, it cannot seem to find the hardrive. However, swapping in a second hardrive brings no improvement. This behavior really resembles a fan / overheating problem. However, I can sometimes clearly hear the fan on, and what I can see from periodically monitoring the temperature would indicate this is not a temperature problem. I even went to the trouble of disassembling the whole machine and physically examining the fan. I also found a software means of forcing the fan to run continuously at high speed. All to no avail, the machine still dies.

    Conclusion: motherboard is toast. Which on such an old (PIII 800 MHz) machine means retirement, as the cost of a whole new machine of similar vintage (just over US$100 in a local market) would be not a lot more then the cost of another motherboard. Time to go shopping....

    For posterity, I will record how I went about controlling the fan, per this fine document[1], using kernel 2.6.30:

    Unload the relevant module should it already be loaded:

    rmmod thinkpad-acpi
    Now reload the module with fan control turned on:
    modprobe thinkpad-acpi fan_control=1
    Inspect the state of the fan controls thusly:
    cat /proc/acpi/ibm/fan
    And crank up the fan to full speed:
    echo level full-speed > /proc/acpi/ibm/fan

    You should get instant auditory feedback from the last action. At least on an a21m, full speed is REALLY LOUD. I have never heard it run that hard in all the years I have owned the machine, so fearing for the safety of the fan I toned the speed down to level 7. Still loud, but not outrageously so.

    [1] http://www.thinkwiki.org/wiki/How_to_control_fan_speed

    posted at: 08:18 | path: /xHW/Thinkpad_a21m | permanent link to this entry

    Fri, 14 Aug 2009


    /Hosting/Amazon/EC2: How to Snapshot an Amazon EC2 Server to S3

    This is actually a script that will do the job automatically, if called periodically from cron:

    #!/usr/bin/env python print "Snapshot Amazon server:" import time bucketName = "server-" + time.strftime("%Y%m%d") print "First create the bundle:" import os os.system("ec2-bundle-vol -k /mnt/pk-xxx.pem -c /mnt/cert-xxx.pem -u {Amazon_user_id} -d /mnt --arch i386") print "Create an S3 bucket named " + bucketName command = "s3cmd mb s3://" + bucketName os.system(command) print "Now upload the server image to the bucket" command = "ec2-upload-bundle -b " + bucketName + " -m /mnt/image.manifest.xml -a {aws-access-key-id} -s {aws-secret-access-key-id}" os.system(command) # boto required here because "ec2-register" does not exist on the server print "Now register the image as an official (private) AMI" from boto.ec2.connection import EC2Connection conn = EC2Connection('<aws_access_key_id>', '<aws_secret_access_key>') manifest = bucketName + "/image.manifest.xml" response = conn.register_image(manifest) print response print "cleanup /mnt (otherwise next server snapshot will break)" os.system("rm -r /mnt/im*")

    Note that /mnt/pk-xxx.pem & /mnt/cert-xxx.pem are your Amazon account keys, which need to be uploaded to the server. Other keys are embedded in this script. Make your file permissions restrictive. In the end, this is a Python script only because of the

    response = conn.register_image(manifest)

    line. I am using a Debian AMI published by alestic.com[1] and it comes equipped with a small set of Ruby tools capable of bundling a server and uploading it to S3. And it is those tools that my script is calling up to the point of the above line. However, these Ruby tools do not have the capability of registering the uploaded bundle as an AMI, which is necessary to have it show up ready for activation in the MyAMIs list of ElasticFox, for instance.

    My script does not as yet weed out old backup images. I will probably continue to do that manually, as I only plan on snapshotting the server once or twice a month (volatile data is all stored in an EBS volume which is backed-up daily, as it should be). There is a wee bit of a gotcha in the process of deleting an old AMI: one cannot delete an S3 bucket that is not empty. and the s3cmd delete command used to delete bucket contents does not seem to accept wild cards. The solution is not well documented:

    s3cmd del --recursive --force s3://bucket-name/
    s3cmd rb s3://bucket-name/

    and the AMI named "bucket-name" is gone forever.

    [1] http://alestic.com/

    posted at: 05:09 | path: /Hosting/Amazon/EC2 | permanent link to this entry

    Tue, 04 Aug 2009


    /Coding/php: A Simple SugarCRM API Class

    This should give anyone needing to use the SugarCRM API a quickstart:

    <?php /* * class_sugarconnect.php * * Copyright 2009 Clayton Koenig <ckoeni@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ ?> <?php class sugarapi{ // connection variables var $client; // soap client var $session_id; // identifier for this login session var $user_id; // of logged in user // connection settings for SOAP var $options = array( "location" => 'https://url.of.your.sugarcrm.installation.com/sugarcrm/soap.php', "uri" => 'http://www.sugarcrm.com/sugarcrm', "trace" => 1 ); //user authentication array (version is SOAP version) private $user_auth = array(); function __construct() { // must use constructor b/c of MD5 function call $this->user_auth = array( "user_name" => 'sugaruserid', "password" => MD5('yourpasswd'), "version" => '.01' ); } // arrays for input into sugarCRM modules var $contact = array(); var $account = array(); function login() { $this->client = new SoapClient(NULL, $this->options); $response = $this->client->login($this->user_auth); // var_dump($response); // just in case you need it $this->session_id = $response->id; printf("<p></p>session id = ". $this->session_id); $this->user_id = $this->client->get_user_id($this->session_id); printf("<p>" . $this->user_auth['user_name'] . ' has a GUID of ' . $this->user_id . "<p>"); } function getModules() { $response = $this->client->get_available_modules($this->session_id); foreach ($response->modules as $i => $value) { printf($response->modules[$i] . "<br>"); } } function getModuleFields($module) { $response = $this->client->get_module_fields($this->session_id, $module); printf("<p>Module " . $response->module_name .' has the following fields:' . "<p>"); printf("<table><tr>" . "<td><u>Name</td><td><u>Type</td><td><u>Label</td>" . "<td><u>Required</td><td><u>Options</td>" . "</tr>"); foreach ($response->module_fields as $i => $value) { printf('<tr><td>' . $response->module_fields[$i]->name . '</td>' . '<td>' . $response->module_fields[$i]->type . '</td>' . '<td>' . $response->module_fields[$i]->label . '</td>' . '<td>' . $response->module_fields[$i]->required . '</td>' . '<td>' . $response->module_fields[$i]->options . '</td></tr>'); } printf('</table>'); } function setContactField($fieldname, $fieldvalue) { $this->contact[] = array("name" => $fieldname,"value" => $fieldvalue); } function storeContact() { // into sugar's Contacts database $response = $this->client->set_entry($this->session_id, 'Contacts', $this->contact); var_dump($response); } } ?>

    And the following is a simple example of how to use the above class to create a simple contact record with a name and an e-mail address, and store it in Sugar's Contacts database.

    <?php include("class_sugarapi.php"); $sugar = new sugarapi(); $sugar->login(); // populate the contact array $sugar->setContactField('last_name', 'Bloke2'); $sugar->setContactField('email1', 'xyz@wxy.net'); // var_dump($sugar->contact); $sugar->storeContact(); // to Contacts database ?>

    To find out all the possible fields in the Contacts database, use this script:

    <?php include("class_sugarapi.php"); $sugar = new sugarapi(); $sugar->login(); // look what modules sugar exposes $sugar->getModules(); // look in more detail at the fields in a module $sugar->getModuleFields('Accounts'); ?>

    Many thanks to this post[1] for getting me on my way.

    [1] http://systemsconsciousness.com/2009/04/10/sugarcrm-soap-examples/

    posted at: 04:14 | path: /Coding/php | permanent link to this entry


    /SW/business/SugarCRM: A Simple SugarCRM API Class

    This should give anyone needing to use the SugarCRM API a quickstart:

    <?php /* * class_sugarconnect.php * * Copyright 2009 Clayton Koenig <ckoeni@gmail.com> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, * MA 02110-1301, USA. */ ?> <?php class sugarapi{ // connection variables var $client; // soap client var $session_id; // identifier for this login session var $user_id; // of logged in user // connection settings for SOAP var $options = array( "location" => 'https://url.of.your.sugarcrm.installation.com/sugarcrm/soap.php', "uri" => 'http://www.sugarcrm.com/sugarcrm', "trace" => 1 ); //user authentication array (version is SOAP version) private $user_auth = array(); function __construct() { // must use constructor b/c of MD5 function call $this->user_auth = array( "user_name" => 'sugaruserid', "password" => MD5('yourpasswd'), "version" => '.01' ); } // arrays for input into sugarCRM modules var $contact = array(); var $account = array(); function login() { $this->client = new SoapClient(NULL, $this->options); $response = $this->client->login($this->user_auth); // var_dump($response); // just in case you need it $this->session_id = $response->id; printf("<p></p>session id = ". $this->session_id); $this->user_id = $this->client->get_user_id($this->session_id); printf("<p>" . $this->user_auth['user_name'] . ' has a GUID of ' . $this->user_id . "<p>"); } function getModules() { $response = $this->client->get_available_modules($this->session_id); foreach ($response->modules as $i => $value) { printf($response->modules[$i] . "<br>"); } } function getModuleFields($module) { $response = $this->client->get_module_fields($this->session_id, $module); printf("<p>Module " . $response->module_name .' has the following fields:' . "<p>"); printf("<table><tr>" . "<td><u>Name</td><td><u>Type</td><td><u>Label</td>" . "<td><u>Required</td><td><u>Options</td>" . "</tr>"); foreach ($response->module_fields as $i => $value) { printf('<tr><td>' . $response->module_fields[$i]->name . '</td>' . '<td>' . $response->module_fields[$i]->type . '</td>' . '<td>' . $response->module_fields[$i]->label . '</td>' . '<td>' . $response->module_fields[$i]->required . '</td>' . '<td>' . $response->module_fields[$i]->options . '</td></tr>'); } printf('</table>'); } function setContactField($fieldname, $fieldvalue) { $this->contact[] = array("name" => $fieldname,"value" => $fieldvalue); } function storeContact() { // into sugar's Contacts database $response = $this->client->set_entry($this->session_id, 'Contacts', $this->contact); var_dump($response); } } ?>

    And the following is a simple example of how to use the above class to create a simple contact record with a name and an e-mail address, and store it in Sugar's Contacts database.

    <?php include("class_sugarapi.php"); $sugar = new sugarapi(); $sugar->login(); // populate the contact array $sugar->setContactField('last_name', 'Bloke2'); $sugar->setContactField('email1', 'xyz@wxy.net'); // var_dump($sugar->contact); $sugar->storeContact(); // to Contacts database ?>

    To find out all the possible fields in the Contacts database, use this script:

    <?php include("class_sugarapi.php"); $sugar = new sugarapi(); $sugar->login(); // look what modules sugar exposes $sugar->getModules(); // look in more detail at the fields in a module $sugar->getModuleFields('Accounts'); ?>

    Many thanks to this post[1] for getting me on my way.

    [1] http://systemsconsciousness.com/2009/04/10/sugarcrm-soap-examples/

    posted at: 04:14 | path: /SW/business/SugarCRM | permanent link to this entry