Friday, May 18, 2012

FTP and OS X

Just ran into something I haven't seen before. I was attempting to upload information to an ftp site. I opened Finder, entered ftp://sitename, and a connection was made and a new finder window opened. Tried to rsync in a terminal over to the /Volume/sitename but was told it was read-only. Same result when dragging and dropping in Finder.
Ran ftp sitename from a Terminal and it all worked. I was able to put files on the server.
Guess I need to lookup up and figure out what in the heck Finder does different than command line ftp.

UPDATE: Ok, after some searching I learned Finder mounts FTP as read-only. Don't know why but at least I now know.

Wednesday, May 2, 2012

Show running queries on Postgresql/Greenplum

I've got some queries that run for a long time. Sometimes longer than others. I wanted to see how long active queries have been running. Here's a view to consistently do that:

CREATE VIEW public.view_activequeries AS ( SELECT age(query_start, backend_start) AS queryage,* FROM pg_stat_activity WHERE current_query NOT LIKE '%IDLE%' ORDER BY queryage DESC);

Then you just run:

select * from public.view_activequeries;

You get a list of all active queries in descending order of how long they have been running, i.e. longest running queries listed first.

ssh-agent start upon login to RHEL 5 machine

---> All credit goes here <---

In case that ever disappears:

place in .bash_profile
####SSHagent settings####
SSH_ENV="$HOME/.ssh/environment"
function start_agent {
     echo "Initializing new SSH agent..."
     /usr/bin/ssh-agent | sed 's/^echo/#echo/' > "${SSH_ENV}"
     echo succeeded
     chmod 600 "${SSH_ENV}"
     . "${SSH_ENV}" > /dev/null
     /usr/bin/ssh-add;
}
# Source SSH settings, if applicable
if [ -f "${SSH_ENV}" ]; then
     . "${SSH_ENV}" > /dev/null
     ps -ef | grep ${SSH_AGENT_PID} | grep ssh-agent$ > /dev/null || {
         start_agent;
     }
else
     start_agent;
fi