Apache Prompts to Download PHP

I had just run some simple patching on a test webserver and had some issues with PHP. Ran a few more commands and the problem went away. Until I decided to patch a production server as well.

Basically the update included an apache update, which wrecked the php modules. How do I know this?

Running Ubuntu 10.04.03 LTS
apt-get update
apt-get dist-upgrade
Load website and it prompts to download/save the PHP file instead of displaying the PHP file. Great.

Check if the PHP5 module is activated:
a2enmod php5
apache2ctl restart

Only the restart yielded this:

apache2: Syntax error on line 204 of /etc/apache2/apache2.conf: Syntax error on line 1 of /etc/apache2/mods-enabled/php5.load: Cannot load /usr/lib/apache2/modules/libphp5.so into server: /usr/lib/apache2/modules/libphp5.so: cannot open shared object file: No such file or directory

So just install the module libraries for PHP5:
apt-get install libapache2-mod-php5

This should automatically restart apache, but just for good measure you can do it again to verify there are no more errors:
apache2ctl restart

Proxmox 1.9 Stopped Backing Up

Proxmox 1.9 – not fully updated (1.9 build 6542)
Had backups set to backup snapshots of machines every day starting at 2AM. They generally took about 3 hours and would finish by 5AM.

Little did I realize that I was no longer receiving the emails saying “backup successful”. Last one was 4 weeks ago. Whoops doesn’t even start to cover that.

Checking it out it looks like the backup stalled on one of the virtual machines.
ps auxww |grep vzdump
Then just kill any PID that looks like vzdump is running.

Re-run the command to backup either from the GUI or from the command line:
vzdump --quiet --snapshot --storage STORAGE --maxfiles 5 --mailto admin 101 102 103 etc

Check Database Sizes with PowerShell

Exchange 2007 check the database size with a powershell ps command.

I found this from Mike Pfeiffer’s Blog – thanks Mike.

Get-MailboxDatabase | foreach-object {add-member -inputobject $_ -membertype noteproperty -name mailboxdbsizeinGB -value ([math]::Round(([int64](get-wmiobject cim_datafile -computername $_.server -filter ('name=''' + $_.edbfilepath.pathname.replace("\","\\") + '''')).filesize / 1GB),2)) -passthru} | Sort-Object mailboxdbsizeinGB -Descending | format-table identity,mailboxdbsizeinGB

Syslog Log ASA VPN AnyConnect

I was recently tasked with logging when users would connect and disconnect from the VPN – I believe the intent is to keep track of hours, but it was proposed as a way to keep track of users in terms of security violations. Either way I needed to come up with a solution.

Here was the setup and results:
ASA5510 with anyconnect VPN licensing
Windows RADIUS (via ISA Services) for authentication
All ASA connect requests were logged via the eventviewer on the Windows RADIUS server
Disconnects or timeouts were not logged on the server

So I had half of the equation, just needed to capture and log the disconnects as well.

Unfortunately, the RADIUS only requires authentication. There was no “hey please give me permission to disconnect” going on. Lucky for me I also have a kiwi syslog server running on the premises. Kiwi free, in case you’re wondering.

So just set the ASA to send syslog data to your syslog server, and parse out the following Message IDs (for your anyconnect client. Other clients including ipsec will have different numbers)
722022: Connect
722023: Disconnect

Exchange 2007 Error Updating Free/Busy Information

Exchange 2007 server was getting error eventID 8207:

Error updating public folder with free/busy information on virtual machine SERVERNAME. The error number is 0x80004005.

This is generally caused when you upgraded from 2000/2003 and didn’t put in replicas for the old email groups.
You can find out by opening the powershell and running the following:
Get-PublicFolder -Identity "\NON_IPM_SUBTREE\SCHEDULE+ FREE BUSY" -Recurse | fl name,Replicas

In my case I got

Well I had my Back-End Admins group (the one from exchange 2003) had a Replicas {} listed. The screen shot shows what it *should* look like.

To fix, just copy the FB information to your current public folder database:
Set-PublicFolder -Identity "\NON_IPM_SUBTREE\SCHEDULE+ FREE BUSY\EX:/o=lkj/ou=Back-End Admins" -replicas "EXCHANGESERVER\Second Storage Group\Public Folder Database"

And then, if you’re not a patient person, run outlook via the following:
outlook.exe /cleanfreebusy

Exmerge Exchange 2007

I know it’s 2012 and I’m writing about a server from 2007. It’s still fairly relevant. Exchange 2010 has some different functionality, so keep that in mind. I also know that we don’t use exmerge in post-2003 exchange environments. But I like the terminology.

Basically I had a user delete all of their calendar items and they were not showing up in the recover deleted items section of outlook. Good thing I had a backup. Bad thing was the database their email was on grew to 81GB. Worse thing was the email server and the backup server were connected by a measly 20mbps pipe.

Fast forward 11 hours and I had a copy of my EDB file on my exchange server. So now what?

Create a folder called C:\exch_recovery (or anything you want, just be sure to change the directories in the following commands)
Open the Exchange PowerShell. PowerShell is required as a recovery database is not visible by general users. It helps if you’re an exchange/domain/enterprise admin in this case.

Create the storage group for recovery
New-StorageGroup -Server SERVERNAME -LogFolderPath c:\exch_recovery -SystemFolderPath C:\exch_recovery -Name rsg -Recovery

I’m assuming you’re trying to recover something from your original Mailbox Database, otherwise change the mailbox name as appropriate.
Copy your BACKUP edb into the C:\exch_recovery\ directory.

Make sure that the database is in “clean shutdown” mode.
eseutil /mh path/to/edb/file.edb

If not in a clean shutdown mode, and you have the log files required, run the following (assuming the log files start with E01):
eseutil /r "e01" /l C:\path\to\log\files\directory /d C:\path\to\edb\file\directory

Now tell Exchange about this database
New-MailboxDatabase -MailboxDatabaseToRecover "Mailbox Database" -StorageGroup SERVERNAME\rsg -EdbFilePath "C:\exch_recovery\Mailbox Database.edb"

Allow your database to be restored
Set-MailboxDatabase -Identity "SERVERNAME\rsg\Mailbox Database" -AllowFileRestore:$TRUE

As this database is still hidden, run the following to mount it
Mount-Database -Identity "SERVERNAME\rsg\mailbox database"

The restore-mailbox command will merge the mail from the recovery database into the current database automatically. If the user does not exist, there will obviously be no merge and only a copy will occur
Restore-Mailbox -Identity "JOHN SMITH" -RsgDatabase "SERVERNAME\rsg\mailbox database"

Optional Cleanup
Remove-MailboxDatabase -Identity "SERVERNAME\rsg\mailbox database"
Remove-Storagegroup -Identity "SERVERNAME\rsg"

Is this the best way? Probably not, but it worked for me. The user now has their calendar items again and lost NO MAIL.

SNMP Daemon Ubuntu

Ubuntu 10.04.3 LTS x32 fully patched.

I needed to install SNMP so my cacti installation could work with graphing. And I thought I had already installed SNMP on the server I was testing against.

Testing from cacti:
snmpwalk -v 1 -c public IPOFSERVER

Timeout: No Response from IPOFSERVER

OK, so let me see if the process is running:
ps aux | grep snmp

root 439193 0.0 0.0 3884 616 pts/0 S+ 09:59 0:00 grep snmp

Well, looks like I need to install it:
apt-get install snmpd

The installation auto-starts the snmpd service with the default configuration file. I verified it was working with ps aux again, and the snmpd service is running under the snmp user.
On the local machine I could now run snmpwalk:
snmpwalk -v 1 -c public localhost
Which retrieved the information I wanted. Unfortunately I still could not run snmpwalk from the cacti server. Doh!

Edit the snmpd.conf file if you want a different community or RO/RW rights:
nano /etc/snmp/snmpd.conf

Otherwise, just edit the default snmpd configuration:
nano /etc/default/snmpd
Change the following line:

SNMPDOPTS=’-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1′

To:

SNMPDOPTS=’-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf’

Save and quit

Restart the snmpd service:
/etc/init.d/snmpd restart

Test again:
snmpwalk -v 1 -c public IPOFSERVER

Profit.

Ramblings Of An IT Person