Wednesday, 17 September 2014

Amazon RDS - System Upgrade Notification for MySQL and PostgreSQL

Amazon AWS sent official mailling this morning, all AWS RDS instances will receive mendatory upgrade next month. Further information below:

-------------------------------------------------

Dear Amazon RDS Customer,

All Amazon RDS for MySQL and PostgreSQL database instances have been scheduled to receive mandatory system upgrade as per the schedule below during the maintenance window you defined for them. For example, if you have chosen Thursday 16:00 UTC with a duration of 30min as the maintenance window for your database instance in the US West (N. California) Region, it will receive the system upgrade on 16 October 2014 (Thursday) between 16:00 UTC and 16:30 UTC.

Please note that while the upgrade completes, your DB Instance will have an availability impact for a few minutes during your maintenance window (even if you chose “No” for the “Auto Minor Version Upgrade” option). Therefore, please cross check your maintenance window settings to ensure that they are set as per your needs using the schedule above. For Multi-AZ deployments, upgrade first occurs on your standby node, followed by a failover, limiting your availability impact to typically 60 - 120 seconds. You can subscribe to Event Notifications ( http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/USER_Events.html ) for the “Maintenance” Category to receive notifications when your instance gets upgraded.

Note that this maintenance schedule is only applicable for MySQL and PostgreSQL database instances. Also, any MySQL or PostgreSQL database instance created after 29 Sep 2014 00:00 UTC will already have this upgrade and will not be impacted by this maintenance. Lastly, if you are using MySQL 5.6, you may want to evaluate turning on InnoDB Cache Warming ( http://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/CHAP_MySQL.html#MySQL.Concepts.InnoDBCacheWarming ) and dumping the buffer pool before the upgrade to improve read latency after your instance restarts.

Should you have any questions or concerns, the AWS Support Team is available on the community forums and via AWS Support Portal.

https://forums.aws.amazon.com/forum.jspa?forumID=60

http://aws.amazon.com/support

Asia Pacific (Sydney)
+++++++++++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 8 Oct 2014 22:00 UTC
Maintenance Schedule End Date: 15 Oct 2014 21:59 UTC

Asia Pacific (Singapore)
++++++++++++++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 13 Oct 2014 00:00 UTC
Maintenance Schedule End Date: 19 Oct 2014 23:59 UTC

South America (São Paulo)
++++++++++++++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 13 Oct 2014 11:00 UTC
Maintenance Schedule End Date: 20 Oct 2014 10:59 UTC

US West (N. California)
++++++++++++++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 13 Oct 2014 15:00 UTC
Maintenance Schedule End Date: 20 Oct 2014 14:59 UTC

US West (Oregon)
++++++++++++++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 15 Oct 2014 15:00 UTC
Maintenance Schedule End Date: 22 Oct 2014 14:59 UTC

Asia Pacific (Tokyo) Region
++++++++++++++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 15 Oct 2014 23:00 UTC
Maintenance Schedule End Date: 22 Oct 2014 22:59 UTC

EU (Ireland)
++++++++++++++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 16 Oct 2014 07:00 UTC
Maintenance Schedule End Date: 23 Oct 2014 06:59 UTC

US East (N. Virginia): MySQL 5.1/5.5
++++++++++++++++++++++++++++++
+++++++
Engine/Version Affected: MySQL 5.1/5.5
Maintenance Schedule Start Date: 16 Oct 2014 12:00 UTC
Maintenance Schedule End Date: 23 Oct 2014 11:59 UTC

US East (N. Virginia): MySQL 5.6/PostgreSQL
+++++++++++++++++++++++++++++++++++++
Engine/Version Affected: MySQL 5.6/PostgreSQL
Maintenance Schedule Start Date: 21 Oct 2014 12:00 UTC
Maintenance Schedule End Date: 28 Oct 2014 11:59 UTC

China (Beijing)
++++++++++++++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 21 Oct 2014 00:00 UTC
Maintenance Schedule End Date: 27 Oct 2014 23:59 UTC

GovCloud (US)
+++++++++++++
Engine/Version Affected: All MySQL/PostgreSQL
Maintenance Schedule Start Date: 21 Oct 2014 15:00 UTC
Maintenance Schedule End Date: 28 Oct 2014 14:59 UTC

Sincerely,
Amazon Web Services

Amazon Web Services, Inc. is a subsidiary of Amazon.com, Inc. Amazon.com is a registered trademark of Amazon.com, Inc. This message was produced and distributed by Amazon Web Services Inc., 410 Terry Ave. North, Seattle, WA 98109-5210

Thursday, 18 October 2012

nagios script to watch linux log file

This is an example nagios (nrpe) script that will watch /var/log/secure log file, and respond with exit code 0 (OK) or exit code 2 (critical) if "Invalid user" string is found (GREPSTRING variable, this can be easily changed). Few tricky bits, first is how to compare two timestamps in bash, so I choose to convert hour and minute and use timestamp, i.e. number of hours * 60 gives the number of minutes + actual minute. Then it's just simple sub to calculate time difference in minutes between event and current time. Second trick is how to add current minute to our timestamp, because bash doesn't like to add values that has zero (0), so when current minute is 08 (as an example, same for 09 as well), it throw error: "value too great for base (error token is '08')". Solution is quite simple (if you know it, heh), use 10# before 0X minute, i.e. 10#`date +%M` did the trick. It's pretty flexible script, as you can use it to watch any linux log file that has usual linux format, and you can search (or grep, if you prefer to call it that way) for any string you want. And here's the script:


#!/bin/bash

LOGDIR="/var/log"
LOGFILE="secure"
#GREPSTRING="that what you're searching for"
GREPSTRING="Invalid user"
TIMENOW=$((`date +%H` * 60 + 10#`date +%M`))
DATENOW=`date +%b" "%d`
LASTRUN=`grep "${GREPSTRING}" ${LOGDIR}/${LOGFILE} | grep "${DATENOW}" | tail -1 | cut -d" " -f3`
TIMELASTHOUR=`echo ${LASTRUN} | cut -d":" -f1`
TIMELASTMINUTE=`echo ${LASTRUN} | cut -d":" -f2`
TIMELAST=$((${TIMELASTHOUR}*60+${TIMELASTMINUTE}))

TIMEDIFF=$((${TIMENOW}-${TIMELAST}))

if [ ${TIMEDIFF} -le 1 ]
then
          echo "CRITICAL: last ${GREPSTRING} occurs in log ${LOGFILE} about ${TIMEDIFF} minutes ago"
          exit 2
else
          echo "OK: no ${GREPSTRING} in log ${LOGFILE} in last minute"
          exit 0
fi

Saturday, 1 September 2012

bash script - move content from one directory to another

Here's a script that move content from one directory to another, as soon as soon some new files arrive in source directory.


#!/bin/bash
SOURCE="/home/ftp/dropzone"
DEST="/home/backup/ftp_files_storage"
if [ `find ${SOURCE} -type f` ]
then
        echo Files found in ${SOURCE}
        echo Moving files to ${DEST}
        find ${SOURCE} -type f -ls
        mv -f ${SOURCE}/* ${DEST}/
else
        echo ${SOURCE} is empty, nothing to do...
fi


and finally crontab entry to run script every minute:
* * * * * /usr/bin/movefiles.sh > /var/log/movefiles.log 2>&1

Friday, 27 July 2012

Bash script - curl and analyse http response code

Basic bash script that use curl and analyse http response code. Script returns 0 (ok) or error (1) bash exit code status, so that it can be used / called from another, more complicated script.
script code name: curl-head.sh

# -----------------------------------------

#!/bin/bash
CURL_URL=$1
DTIME=`date +%Y%m%d%M%S`
CURL_TMP="/tmp/curl-head-bash-script-${DTIME}.tmp"

curl -I -s ${CURL_URL} > ${CURL_TMP}
CURL_TST=`cat ${CURL_TMP} | grep -c "200 OK"`

if [ ${CURL_TST} -eq 1 ]
then
        STATUS=0
else
        STATUS=1        # http header response non 200, error
fi

if [ -f ${CURL_TMP} ]; then
        rm -f ${CURL_TMP}
fi

exit ${STATUS}

# -----------------------------------------

Saturday, 9 June 2012

how to test PHP 5 compilation with sybase 15

While back I had to recompile PHP 5.x with Sybase 15 support. It wasn't difficult, but after compilation was finished, I had to test it somehow... and here's a small and basic piece of PHP code to test connection from PHP 5 to ASE 15 (Adaptive Server Enterprise).

----------

<?php
$db = sybase_connect("SERVER", "username", "password") or die("Could not connect !");
echo "Connected successfully<br>";
echo "handler: $db<br>";
$res = sybase_query("select column from table", $db);
 if($res)
 {
         echo "rows: sybase_num_rows($res)";
         while ($data = sybase_fetch_array($res)) {
          print("db: $data[0]\n");
         }
 sybase_free_result($res);
 } else  {
         echo "<br><br>false<br><br>";
         }
 echo "<br><br>last message from server:<br>";
 echo sybase_get_last_message();
 sybase_close($db);
?>