<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>LiveAverage &#187; Coding</title>
	<atom:link href="http://liveaverage.com/category/features/coding/feed/" rel="self" type="application/rss+xml" />
	<link>http://liveaverage.com</link>
	<description>I can&#039;t afford to live any other way.</description>
	<lastBuildDate>Tue, 08 May 2012 21:40:12 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Nagios Plugin: Windows Server DHCP Scopes Usage Monitoring</title>
		<link>http://liveaverage.com/news/nagios-plugin-windows-server-dhcp-scopes-usage-monitoring/</link>
		<comments>http://liveaverage.com/news/nagios-plugin-windows-server-dhcp-scopes-usage-monitoring/#comments</comments>
		<pubDate>Fri, 13 Apr 2012 16:03:59 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Infrastructure Management]]></category>
		<category><![CDATA[News]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=460</guid>
		<description><![CDATA[<p>I&#8217;ve stumbled on a <a title="Link to original check_dhcp_pool plug-in from Lars Michelsen" href="http://nagios.larsmichelsen.com/check_dhcp_pool/" target="_blank">useful plug-in from Lars Michelsen</a> that easily monitors a single Windows Server DHCP scope for usage using SNMPv2, but found this fell short of what I needed for monitoring several scopes at once. I&#8217;ve modified Lars&#8217; original plugin/script to accommodate all [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;ve stumbled on a <a title="Link to original check_dhcp_pool plug-in from Lars Michelsen" href="http://nagios.larsmichelsen.com/check_dhcp_pool/" target="_blank">useful plug-in from Lars Michelsen</a> that easily monitors a single Windows Server DHCP scope for usage using SNMPv2, but found this fell short of what I needed for monitoring several scopes at once. I&#8217;ve modified Lars&#8217; original plugin/script to accommodate all available DHCP scopes on your monitored Windows server. You no longer need to add separate service definitions to monitor all available scopes. It&#8217;s worth noting a couple of important details:</p>
<ul>
<li>Nagios 3.x or above is <strong>required</strong> for the multi-line output generated by this command.</li>
<li>This service check will alarm if<strong> any</strong> scope is nearing the critical or warning threshold(s) specified command call.</li>
<ul>
<li>If you require per-scope or per-pool alarm configuration, you should use the original plugin created by Lars Michelsen.</li>
</ul>
<li>Performance Data has been commented out, but is available if you&#8217;d like to add it.</li>
<li>Scopes that exist but are not in use (e.g. scopes exclusively used for reservations) are left out of this check. There is a conditional statement commented below that can report these scopes as being available, but with zero (0) free or used addresses, equaling zero (0) MAX available amount of addresses. This information isn&#8217;t really relevant, so I omitted it from being returned; however,  there is a count returned of configured and shown scopes (located at the bottom).</li>
</ul>
<p>Feel free to use, reuse, or modify the script the suit your needs. There are other, similar plugins to accomplish the same thing, but most of these rely on NRPE, NSClient++, and netsh.</p>
<pre class="brush: bash; title: ; notranslate">
#! /bin/bash
# ##############################################################################
# check_dhcp_all_pools.sh - Nagios plugin
#
# This script querys a MS Windows DHCP-Server via SNMP v2 to fetch information about ALL available DHCP-Pools.
#
# Copyright (C) 2006, 2007 Lars Michelsen &lt;lars@vertical-visions.de&gt;,
# Modified 2012 by JRM
#
# 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., 59 Temple Place - Suite 330, Boston, MA  02111-1307,
#
# GNU General Public License: http://www.gnu.org/licenses/gpl-2.0.txt
#
# Report bugs to: lars@vertical-visions.de
#
# 2006-07-05 Version 0.2
# 2007-10-27 Version 0.3
#
# ##############################################################################

if [ $# -lt 2 ]; then
echo &quot;check_dhcp_all_pools&quot;
echo &quot;Usage: $0 &lt;host&gt; &lt;community&gt; [&lt;warn=10&gt;] [&lt;crit=5&gt;]&quot;
exit 3
fi

IP=&quot;$1&quot;
COMMUNITY=&quot;$2&quot;
WARN=&quot;$4&quot;
CRIT=&quot;$5&quot;
RET=0
RETW=0
RETC=0
STAT=( )
i=0

if [ ${#WARN} -lt 1 ]
then
WARN=10
fi

if [ ${#CRIT} -lt 1 ]
then
CRIT=5
fi

#Get the list of all scopes/subnets from the server:
TEMP=($( snmpwalk -c $COMMUNITY $IP .1.3.6.1.4.1.311.1.3.2.1.1.1 | cut -d &quot; &quot; -f4 ))

#Traverse array and get usage information per scope:
for i  in ${!TEMP[*]};do

POOL=${TEMP[$i]}

FREEOID=&quot;.1.3.6.1.4.1.311.1.3.2.1.1.3.$POOL&quot;
USEDOID=&quot;.1.3.6.1.4.1.311.1.3.2.1.1.2.$POOL&quot;

SNMP_RESULT=`snmpget -v 2c -c $COMMUNITY $IP $FREEOID`
FREE=`echo $SNMP_RESULT|cut -d &quot; &quot; -f4`

SNMP_RESULT=`snmpget -v 2c -c $COMMUNITY $IP $USEDOID`
USED=`echo $SNMP_RESULT|cut -d &quot; &quot; -f4`

MAX=`echo &quot;$FREE+$USED&quot; |bc`

if [ &quot;$MAX&quot; -ne 0 ]; then

PERCFREE=`echo &quot;$FREE*100/$MAX&quot; |bc`
PERCUSED=`echo &quot;$USED*100/$MAX&quot; |bc`

#DEBUG: echo &quot;FREE: $FREE USED: $USED MAX: $MAX PERC: $PERCFREE,$PERCUSED&quot;

if [ &quot;$FREE&quot; -le &quot;$WARN&quot; -a &quot;$FREE&quot; -gt &quot;$CRIT&quot; ]; then
STAT=( &quot;${STAT[@]}&quot; &quot;Warning:\t$POOL - $PERCFREE free&quot; )
RETW+=1
elif [ &quot;$FREE&quot; -le &quot;$CRIT&quot; ]; then
STAT=( &quot;${STAT[@]}&quot; &quot;Critical:\t$POOL - $PERCFREE free&quot; )
RETC+=2
else
STAT=( &quot;${STAT[@]}&quot; &quot;OK:\t$POOL\t$PERCUSED% used&quot; )
RET+=0
fi

#elif [ &quot;$MAX&quot; -eq 0 ]; then

#Debug for detecting 100% excluded ranges (reservations only):
#STAT=( &quot;${STAT[@]}&quot; &quot;OK:\t$POOL\tNothing used, could be excluded&quot; )

fi

# Performance-Data
#echo &quot; | 'Scope Usage'=$PERCUSED%;$WARN;$CRIT;0;$MAX&quot;
#echo -e &quot; | $POOL OK - Usage: $PERCUSED% ($FREE Addresses of $MAX in pool free) \n&quot;

done

#Evaluate return code:

if [ &quot;$RET&quot; -eq 0 ]; then
RET=0
echo -e &quot;OK:\tAll scopes fine&quot;
elif [ &quot;$RETC&quot; -gt 0 ]; then
RET=2
echo  -e &quot;Critical: One or more scopes is nearing capacity&quot;
elif [ &quot;$RETW&quot; -gt 0 ]; then
RET=1
echo -e &quot;Warning: One or more scopes is nearing capacity&quot;
fi

###### Second loop for long service output:

for I in ${!STAT[*]};do
echo -e ${STAT[$I]}
done

#Echo the total amount of scopes available vs those shown:
echo -e &quot;\nShowing ${#STAT[@]} of ${#TEMP[@]} configured scopes&quot;

exit $RET
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/news/nagios-plugin-windows-server-dhcp-scopes-usage-monitoring/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Managing backup retention&#8230; with one line of Powershell</title>
		<link>http://liveaverage.com/features/coding/managing-backup-retention-with-one-line-of-powershell/</link>
		<comments>http://liveaverage.com/features/coding/managing-backup-retention-with-one-line-of-powershell/#comments</comments>
		<pubDate>Wed, 30 Nov 2011 18:09:08 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=401</guid>
		<description><![CDATA[<p>Ok, I used four lines, but my needs for retention might be a bit more complex than most. I also spaced each pipeline command, so it looks longer than it should, but readability is important. Additionally, there&#8217;s a good half-page of comments in the script than can safely be ignored, unless you want to know [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, I used four lines, but my needs for retention might be a bit more complex than most. I also spaced each pipeline command, so it looks longer than it should, but readability is important. Additionally, there&#8217;s a good half-page of comments in the script than can safely be ignored, unless you <em>want</em> to know what was going through my mind. Most of these related directly to my desired retention periods.</p>
<p>For testing purposes, the last two &#8220;lines&#8221; only print out the listing of files that would be deleted.</p>
<p><span id="more-401"></span></p>
<pre class="brush: bash; title: ; notranslate">
Param ($backupDir)

######
# Handle 30-day backup recyclables first (no directory recursion since each backup is in its own directory)
# The current backup schedule performs weekly configuration backups with 1-month retention.
######

Get-ChildItem &quot;$backupDir\backup_data&quot; | `
`
Where-Object {(($_.FullName -match &quot;configuration_isxpr01_&quot;) -and ( $_.CreationTime -lt ((Get-Date).AddMonths(-1)) ) )} | `
`
ForEach-Object {`
                    Out-File -filepath &quot;$backupDir\log&quot; -inputobject $((Get-Date -format g) + &quot;Removing &quot; + $_.FullName + &quot; from &quot; + $_.CreationTime) -append`
                    Remove-Item $_.FullName -recurse}

######
# Handle 7-day backup recyclables next (no directory recursion since each backup is in its own directory)
# The current backup schedule performs weekly configuration backups with 1-week retention.
# No &quot;overwrite option available, so this script manages removal
######

Get-ChildItem &quot;$backupDir\backup_data&quot; | `
`
Where-Object {(($_.FullName -match &quot;backup_isxpr01_&quot;) -and ( $_.CreationTime -lt ((Get-Date).AddDays(-7)) ) )} | `
`
ForEach-Object {(Remove-Item $_.FullName -recurse)}

######
# Handle daily trend data recyclables next (use recursion parameter).
# The current daily trend export schedule requires 1-month retention for 24-hr trend data.
######

Get-ChildItem -include *.zip -recurse -path &quot;$backupDir\trend_data_export&quot; | `
`
Where-Object {(($_.FullName -match &quot;24-hr&quot;) -and ( $_.CreationTime -lt ((Get-Date).AddMonths(-1)) ) )} | `
`
ForEach-Object {($_.FullName)}

######
# Handle monthly trend data recyclables next (use recursion parameter).
# The current monthly trend export schedule requires 5-year retention for 30-day trend data.
######

Get-ChildItem -include *.zip -recurse -path &quot;$backupDir\trend_data_export&quot; | `
`
Where-Object {(($_.FullName -match &quot;30-day&quot;) -and ( $_.CreationTime -lt ((Get-Date).AddYears(-5)) ) )} | `
`
ForEach-Object {($_.FullName)}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/managing-backup-retention-with-one-line-of-powershell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>OpenFiler errors that only I seemed to experience&#8230;</title>
		<link>http://liveaverage.com/features/coding/openfiler-errors-that-only-i-seemed-to-experience/</link>
		<comments>http://liveaverage.com/features/coding/openfiler-errors-that-only-i-seemed-to-experience/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 16:51:03 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[Infrastructure Management]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=378</guid>
		<description><![CDATA[<p>Well, I&#8217;ve finally deployed some production Openfiler ESA 2.99.1 machines as home-brew iSCSI boxes, primarily used for backups or low-stress virtual storage. Yes, they&#8217;re great &#8212; my basic write speeds on a Core 2 Duo box (recycled Dell Precision 390 workstation with 2GB of RAM and a single 1TB drive *no* RAID):</p> <p>I&#8217;m pretty happy with [...]]]></description>
			<content:encoded><![CDATA[<p>Well, I&#8217;ve finally deployed some production Openfiler ESA 2.99.1 machines as home-brew iSCSI boxes, primarily used for backups or low-stress virtual storage. Yes, they&#8217;re great &#8212; my basic write speeds on a Core 2 Duo box (recycled Dell Precision 390 workstation with 2GB of RAM and a single 1TB drive *no* RAID):</p>
<pre class="brush: bash; title: ; notranslate">
administrator@mail:/backup-iscsi$ sudo dd if=/dev/zero of=garbage bs=131072 count=20000
20000+0 records in
20000+0 records out
2621440000 bytes (2.6 GB) copied, 40.8493 s, 64.2 MB/s
</pre>
<p>I&#8217;m pretty happy with that. What I&#8217;m not please with is a 56MB log (/var/log/secure) filled with strange messages:</p>
<pre class="brush: bash; title: ; notranslate">Jul 26 12:25:46 e0-002 sudo: openfiler : TTY=unknown ; PWD=/opt/openfiler/var/www/htdocs ; USER=root ; COMMAND=/usr/bin/uptime
Jul 26 12:25:46 e0-002 sudo: PAM unable to dlopen(/lib64/security/pam_gnome_keyring.so)
Jul 26 12:25:46 e0-002 sudo: PAM [error: /lib64/security/pam_gnome_keyring.so: cannot open shared object file: No such file or directory]
Jul 26 12:25:46 e0-002 sudo: PAM adding faulty module: /lib64/security/pam_gnome_keyring.so</pre>
<p>Okay, so the first message isn&#8217;t strange. In fact, it&#8217;s normal. But I couldn&#8217;t figure out why a non-GUI (yes, it has a web interface, but no default window manager) distro was trying to load the Gnome keyring shared object. I still don&#8217;t know why. What I do know is how to get rid of this message:</p>
<ol>
<li>Verify which PAM files reference this shared object:</li>
<ol>
<li>
<pre class="brush: bash; title: ; notranslate">[root@e0-002 pam.d]# cd /etc/pam.d/
[root@e0-002 pam.d]# grep -i -n 'pam_gnome_keyring.so' *
system-auth:5:# FL: Have (patched) pam_gnome_keyring.so grab the password before pam_unix.so
system-auth:6:auth        optional      pam_gnome_keyring.so
system-auth:16:password    optional      pam_gnome_keyring.so</pre>
</li>
</ol>
<li>In this instance, the &#8216;system-auth&#8217; file contained these troublesome pam_gnome_keyring.so entries.</li>
<li>Fire-up your favorite text editor and comment those lines.</li>
<li>Reboot &amp; enjoy a log without an absurd amount of irrelevant errors.</li>
</ol>
<div><a title="The original thread mentioning the problem." href="https://lists.openfiler.com/viewtopic.php?id=6228" target="_blank">I found this referenced <em>once</em> on the OpenFiler forums</a>, but no answer or explanation. I hope this helps someone else that might experience a similar problem.</div>
<div>I&#8217;ll also be doing a write-up related to OpenFiler volume backups with LVM snapshots.</div>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/openfiler-errors-that-only-i-seemed-to-experience/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Add &#8216;Submitted Tickets&#8217; Listing Page for Joomla! RSTickets</title>
		<link>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/</link>
		<comments>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/#comments</comments>
		<pubDate>Fri, 10 Jul 2009 17:15:21 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=202</guid>
		<description><![CDATA[<p></p> <p>If you haven&#8217;t heard, <a title="Check out the RSTickets! extension from RSJoomla!" href="http://www.rsjoomla.com/joomla-components/rstickets.html" target="_blank">RSTickets!</a> is an advanced Joomla! Help Desk ticketing system that allows you (or a team of yous) to manage and keep track of your clients&#8217; issues. It&#8217;s actually one of the few effective, useful Help Desk systems available for the Joomla! [...]]]></description>
			<content:encoded><![CDATA[<p><img class="alignright" title="Joomla!" src="http://cdn.joomla.org/images/logo.png" alt="" width="235" height="46" /></p>
<p>If you haven&#8217;t heard, <a title="Check out the RSTickets! extension from RSJoomla!" href="http://www.rsjoomla.com/joomla-components/rstickets.html" target="_blank">RSTickets!</a> is an advanced Joomla! Help Desk ticketing system that allows you (or a team of yous) to manage and keep track of your clients&#8217; issues. It&#8217;s actually one of the few effective, useful Help Desk systems available for the Joomla! 1.5+ framework that I would personally recommend. Unfortunately, it&#8217;s still under development and lacks certain features that one may desire, such as a read-only listing page that displays tickets already submitted to you or your department.</p>
<p><span id="more-202"></span><strong>My Problem:</strong></p>
<p>I noticed internal network clients were submitting several duplicate tickets related to a shared problem (i.e. printer trouble, network outages, etc.). I couldn&#8217;t blame them since they couldn&#8217;t view previously submitted tickets, so I decided to create a quick + dirty page that pulls <em>&#8220;open,&#8221; </em>or <em>&#8220;on-hold,&#8221;</em> tickets from a specific department&#8217;s table of submitted [active] tickets and displays them on a Joomla! article page (using the Sourcerer plug-in to execute custom PHP with {source} tags). Pasting this code into an article without the Sourcerer plug-in [or some sort of plug-in for executing PHP] <em>will do nothing. </em>Also note the <em>include</em> file for making a raw connection to your MySQL database. This is required (and should be stored in a directory with the appropriate permissions to prevent outside read access).</p>
<p>If you&#8217;d like to simply list the number (amount) of tickets (open, closed, on-hold) for <em>all</em> departments, you might want to <a title="Try RSJoomla!'s RSTicket Module for a quick count of all tickets." href="http://www.rsjoomla.com/customer-support/forum/38-rstickets/7805-joomla-module-for-rstickets.html" target="_blank">check the unreleased version of RSJoomla!&#8217;s RSTicket Module.</a></p>
<pre class="brush: php; title: ; notranslate">
{source}
&lt;?php

include (&quot;includes/connect_custom.php&quot;);

$result2 = mysql_query(&quot;SELECT * FROM jos_rstickets_tickets WHERE DepartmentId=3 AND (TicketStatus='open' OR TicketStatus='on-hold') ORDER BY TicketTime ASC&quot;) or die(mysql_error());

echo '&lt;br /&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;padding-bottom: 10px;&quot; colspan=&quot;6&quot;&gt;Please check the open, pending, or on-hold tickets listed below before submitting a support ticket. The list below can be utilized as an informal gauge for IT response times. If a duplicate support ticket is submitted, you may cancel it yourself or it will be deleted by the IT Department upon review. Thank you for your cooperation.&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;font-size: 16px;font-weight: bold;padding-bottom: 10px;&quot; colspan=&quot;6&quot;&gt;SUBMITTED SUPPORT TICKETS:&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;tr&gt;&lt;td style=&quot;text-align:left; padding-bottom:7px;&quot;&gt;&lt;strong&gt;Submitted:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Username:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Ticket Code:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Subject:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Status:&lt;/strong&gt;&lt;/td&gt;&lt;td style=&quot;padding-bottom:7px;&quot;&gt;&lt;strong&gt;Priority:&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;';

while($row = mysql_fetch_array($result2))

{

$custid =  $row['CustomerId'];
$userquery= mysql_query(&quot;SELECT name FROM jos_users WHERE id=$custid&quot;) or die(mysql_error());

$username = mysql_fetch_array($userquery);

echo '&lt;tr style=&quot;font-size: 10px;vertical-align:top;&quot;&gt;&lt;td style=&quot;width: 102px; overflow: hidden;padding: 3px -10px 3px 3px;&quot;&gt;' . date(&quot;Y-m-d H:m&quot;, $row['TicketTime']) .  '&lt;/td&gt;&lt;td&gt;' . $username['name'] . '&lt;/td&gt;&lt;td&gt;' . $row['TicketCode'] . '&lt;/td&gt;&lt;td style=&quot;width: 235px; overflow: hidden;&quot;&gt;' . $row['TicketSubject'] . '&lt;/td&gt;&lt;td&gt;' . strtoupper($row['TicketStatus']) . '&lt;/td&gt;';

if ($row['TicketPriority']=='high'){

echo '&lt;td style=&quot;background-color: red; color: white; font-weight: bold;padding-left: 5px;&quot;&gt;';

} else if ($row['TicketPriority']=='normal'){

echo '&lt;td style=&quot;background-color: blue; color: white; font-weight: bold;padding-left: 5px;&quot;&gt;';

} else if ($row['TicketPriority']=='low'){

echo '&lt;td style=&quot;background-color: yellow; font-color: black; font-weight: bold;padding-left: 5px;&quot;&gt;';}

echo strtoupper($row['TicketPriority']) . '&lt;/td&gt;&lt;/tr&gt;';

}

echo '&lt;tr&gt;&lt;td style=&quot;font-size:16px; padding-top: 20px; padding-bottom: 20px&quot; colspan=&quot;6&quot;&gt;&lt;strong&gt;&lt;a href=&quot;index.php?option=com_rstickets&amp;Itemid=59&quot;&gt;&lt;img src=&quot;images/M_images/onsite_support1.jpg&quot;&gt;&lt;/a&gt;&lt;br /&gt;&lt;a href=&quot;index.php?option=com_rstickets&amp;Itemid=59&quot;&gt;SUBMIT A NEW SUPPORT TICKET&lt;/a&gt;&lt;/strong&gt;&lt;/td&gt;&lt;/tr&gt;';

echo '&lt;br /&gt;';

?&gt;
{/source}
</pre>
<p><strong>connect_custom.php :</strong></p>
<pre class="brush: php; title: ; notranslate">
&lt;?php

// Script:	connect_custom.php
// Author:	JR
// Date:	20080218
// Use:	    Utilized for custom DB connections to our current database for Fabrik Forms + Joomla 1.5

$hostname=&quot;localhost&quot;;
$mysql_login=&quot;thedude&quot;;
$mysql_password=&quot;sumpasswordhere&quot;;
$database=&quot;datablah&quot;;

if (!($db = mysql_pconnect($hostname, $mysql_login , $mysql_password))){
die(&quot;Can't connect to database server.&quot;);
}else{
if (!(mysql_select_db(&quot;$database&quot;,$db))){
die(&quot;Can't connect to database.&quot;);
}
}
?&gt;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/add-submitted-tickets-listing-page-for-joomla-rstickets/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Altermime, Postfix/Zimbra, and Headaches</title>
		<link>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/</link>
		<comments>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/#comments</comments>
		<pubDate>Wed, 24 Jun 2009 19:43:11 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=109</guid>
		<description><![CDATA[<p>EDIT: I have since removed altermime after installing a MailScanner spam relay for our Zimbra server to use. Because, by default, MailScanner appends a default signature to all outbound email, it was very simple to modify the signature rules to accomodate our mandatory disclaimers for different domains.</p> <p>I had the pleasure of applying mandatory disclaimers [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p><em>EDIT: I have since removed altermime after installing a MailScanner spam relay for our Zimbra server to use. Because, by default, MailScanner appends a default signature to all outbound email, it was very simple to modify the signature rules to accomodate our mandatory disclaimers for different domains.</em></p></blockquote>
<p>I had the pleasure of applying mandatory disclaimers to all [outbound] emails at my workplace today&#8230; ~Joy~ &#8230; I had the assumption it&#8217;d be rather easy, but Altermime and Postfix were a bit finicky to work with. After editing the <strong>master.cf</strong> I ended up customizing my own &#8216;disclaimer&#8217; shell script.</p>
<p><span id="more-109"></span></p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh
INSPECT_DIR=/var/spool/filter
SENDMAIL=/opt/zimbra/postfix/sbin/sendmail

# Exit codes from
EX_TEMPFAIL=75
EX_UNAVAILABLE=69

# Clean up when done or when aborting.
trap &quot;rm -f in.$$&quot; 0 1 2 3 15

# Start processing.
cd $INSPECT_DIR || { echo $INSPECT_DIR does not exist; exit $EX_TEMPFAIL; }

cat &gt; in.$$ || { echo Cannot save mail to file; exit $EX_TEMPFAIL; }

# Verify this mail is not incoming or internal-only
# We don't need disclaimers for either one of these cases.

# Debug:
#echo &quot;output: $from_address&quot; &gt;&gt; /tmp/tempoutput.txt

#Grab the from address:

from_address=`grep -m 1 &quot;From:&quot; in.$$ | cut -d &quot;&lt;&quot; -f 2 | cut -d &quot;&gt;&quot; -f 1`

#Verify whether your domain is in the from address.
#If it is, proceed to distinguish WHICH domain is sending outgoing mail and tag it appropriately:
#If not, then that would be incoming mail, so leave it alone:

#Additional (else if) conditional checks will be added to determine if the email is inner-office comm:
# to_address= `grep -m 1 &quot;To:&quot; in.$$ | cut -d &quot;&lt;&quot; -f 2 | cut -d &quot;&gt;&quot; -f 1`
# if [[ $from_address == *domain* &amp;&amp; to_address == *domain* ]]; then ....
#
# This additional condition requires more debugging...

if [[ $from_address == *domain* ]]; then

# Debug:
#echo
#echo &quot;FROM: $from_address&quot; &gt;&gt; /tmp/tempoutput.txt
#echo &quot;THIS GETS ALTERMIMED&quot; &gt;&gt; /tmp/tempoutput.txt
#echo

#Check to see which domain is sending outgoing email,
#then tag it with the appropriate disclaimer:

if [[ $from_address == *subdomain.domain* ]]; then

# Debug		echo &quot;THIS GETS APDD&quot; &gt;&gt; /tmp/tempoutput.txt
/usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/apd-disclaimer.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/apd-disclaimer.txt \
--xheader=&quot;X-Public-Record:&quot; || { echo Message content rejected; exit $EX_UNAVAILABLE; }
else
# Debug		echo &quot;THIS GETS COAD&quot; &gt;&gt; /tmp/tempoutput.txt
/usr/bin/altermime --input=in.$$ \
--disclaimer=/opt/zimbra/postfix/conf/disclaimers/coa-disclaimer.txt \
--disclaimer-html=/opt/zimbra/postfix/conf/disclaimers/coa-disclaimer.txt \
--xheader=&quot;X-Public-Record:&quot; || { echo Message content rejected; exit $EX_UNAVAILABLE; }

fi
fi

# Might need to remove -i switch for truncation problems depending on your MTA version...

$SENDMAIL -i &quot;$@&quot; &lt; in.$$

exit $?
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/altermime-postfixzimbra-and-headaches/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bashing MySQL Dumps</title>
		<link>http://liveaverage.com/features/coding/bashing-mysql-dumps/</link>
		<comments>http://liveaverage.com/features/coding/bashing-mysql-dumps/#comments</comments>
		<pubDate>Tue, 29 Jul 2008 14:45:14 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[backup]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[dumps]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=9</guid>
		<description><![CDATA[A quick set of scripts to dump specified databases from MySQL and mail a copy of the log to a specified e-mail address (requires Per]]></description>
			<content:encoded><![CDATA[<p>A quick set of batch scripts I wrote up (two of the three scripts, anyway) for dumping all of my (specified) MySQL databases into an archive for backup. The log mailing (<strong>emailsql.pl</strong>)requires Perl and the MIME:Lite module to correctly function. I&#8217;ve also utilized a wrapper script so the log outputs to a separate file [to be mailed]. There&#8217;s also a &#8216;dummy&#8217; log file I use in my crontab file, though this isn&#8217;t really necessary:</p>
<p><span id="more-9"></span></p>
<p><span style="color: #800000;"><strong>mysqlbackupwrapper.sh</strong></span></p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/bash
#Wrapper script used to call the primary backup script and output to a specified file
sh /home/administrator/scripts/mysqlbackups &gt; /home/administrator/scripts/sql.backup.log 2&gt;&amp;1
</pre>
<p><span style="color: #800000;"><strong>mysqlbackup.sh</strong></span>:</p>
<pre class="brush: bash; title: ; notranslate">
#!/bin/sh
#Timestamp for your logs:
date

#Dump the databases - Make sure to specify your root or user password following the -p switch:
mysqldump -uroot -p --opt intraforum &gt; /home/administrator/scripts/sqldata/intra_apdforum.sql
mysqldump -uroot -p --opt joomla_intranet &gt; /home/administrator/scripts/sqldata/intra_intranet.sql
mysqldump -uroot -p --opt mysql &gt; /home/administrator/scripts/sqldata/intra_mysql.sql
tar -zcvf /home/administrator/scripts/sqldata.tgz /home/administrator/scripts/sqldata/*.sql
echo
echo &quot;Backup completed successfully for: &quot;
echo
echo &quot;MySQL - PHPbb3 Forum&quot;
echo &quot;MySQL - Joomla 1.0.X Intranet&quot;
echo &quot;MySQL - Intranet MySQL Tables&quot;
echo
echo &quot;Copying to SERVER.yourdomain.local . . . .&quot;
echo

#Use SCP to transfer to file so you can verify successful backups -- Make sure to use identity/keys for SCP instead of a password:
scp -v -i /home/administrator/identity /home/administrator/scripts/sqldata.tgz administrator@this.host:/backup/sqldata_backup.tgz

perl /home/administrator/scripts/emailsql.pl
</pre>
<p><span style="color: #800000;"><strong>emailsql.pl (I did not write this one)</strong></span>:</p>
<p>Instead of just sending the text of the log file, this script attaches the file and sends the message:</p>
<pre class="brush: bash; title: ; notranslate">

#!/usr/bin/perl -w
use MIME::Lite;

$msg = MIME::Lite-&gt;new(
From    =&gt; 'Backup Log',
To      =&gt; 'liveaverage@yourdomain.org',
Subject =&gt; 'MySQL Data Backup - Intranets',
Type    =&gt; 'text/plain',
Data    =&gt; &quot;See the attached log for details on the most recent MySQL Database Dumps.&quot;);

$msg-&gt;attach(
Type       =&gt;'text/plain',
Path       =&gt;'/home/administrator/scripts/sql.backup.log',
Filename   =&gt;'sql.backup.log',
Disposition        =&gt;'attachment');

$msg-&gt;send;
</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/bashing-mysql-dumps/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Perl my way to happiness</title>
		<link>http://liveaverage.com/features/coding/perl-my-way-to-happiness/</link>
		<comments>http://liveaverage.com/features/coding/perl-my-way-to-happiness/#comments</comments>
		<pubDate>Fri, 25 Apr 2008 19:00:49 +0000</pubDate>
		<dc:creator>JR</dc:creator>
				<category><![CDATA[Coding]]></category>
		<category><![CDATA[perl zimbra zmprov provisioning]]></category>

		<guid isPermaLink="false">http://liveaverage.com/?p=4</guid>
		<description><![CDATA[<p>If only everything was as easy &#38; straight-forward as account provisioning in Zimbra:</p>]]></description>
			<content:encoded><![CDATA[<p>If only everything was as easy &amp; straight-forward as account provisioning in Zimbra:</p>
<pre class="brush: bash; title: ; notranslate">!/usr/bin/perl

# ZCS IMPORT SCRIPT
#       Provided by : ZCS Wiki
#       Modified by : J.R.
#       Last Change : 2008.04.09
#
# Lookup the valid COS (Class of Service) ID in the interface or like this
my $cosid = `su - zimbra -c 'zmprov gc apd |grep zimbraId:'`;
$cosid =~ s/zimbraId:\s*|\s*$//g;

while (&lt;&gt;) {
chomp;

# CHANGE ME: To the actual fields you use in your CSV file
my ($email, $password, $first, $last) = split(/\,/, $_, 4);

my ($uid, $domain) = split(/@/, $email, 2);

print qq{ca $uid\@$domain $password\n};
print qq{ma $uid\@$domain zimbraCOSid &quot;$cosid&quot;\n};
print qq{ma $uid\@$domain givenName &quot;$first&quot;\n};
print qq{ma $uid\@$domain sn &quot;$last&quot;\n};
print qq{ma $uid\@$domain cn &quot;$uid&quot;\n};
print qq{ma $uid\@$domain displayName &quot;$first $last&quot;\n};

#Set the user's reply or canonical address
print qq{ma $uid\@$domain zimbraMailCanonicalAddress $uid\@cityof*****.org\n};

#Add e-mail account alias for multiple domains
#Verify domain is correctly working for provisioning aliases

print qq{aaa $uid\@$domain $uid\@cityof*****.com\n};

#Add all users to a general distribution list and terminate
#Add multiple distro-lists if desired
print qq{adlm dept.all\@cityof*****.org $uid\@cityof*****.org\n};
print qq{\n};

}</pre>
]]></content:encoded>
			<wfw:commentRss>http://liveaverage.com/features/coding/perl-my-way-to-happiness/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

