FreePBX: Receive a daily e-mail of the Call Detail Report for the previous day

If you use FreePBX you might have wished that you could get a daily report of call activity e-mailed to you, if only to remind you to check for suspicious activity, so that you don’t get hacked and not know about it for weeks because you fell out of the habit of checking the log. It turns out that there is a fairly easy way to do it, as explained in a post by user Boolah in this thread in the PBX in a Flash forum:

EDIT (December, 2017): The method shown at that link and below doesn’t work at all in newer versions of FreePBX. It seems like every new version requires some tweaking. This is the line that works in FreePBX 14:

/usr/bin/mysql -u freepbxuser -ppassword -e "select calldate AS Timestamp, clid AS CallerID, did AS DID, dst AS Destination, disposition AS Disposition, duration AS Duration, userfield AS Userfield from cdr where calldate > date_sub(now(), interval 24 HOUR)" -H asteriskcdrdb | mail -a "From: PBX <asterisk@youraddress.com>" -a "Content-Type: text/html" -s "Custom Call Report" you@youremail.com

The above is all one long line. You must replace the above values:

-u freepbxuser -ppassword (that’s not a typo – there really is NO SPACE after the -p) – replace freepbxuser and password with the correct values for YOUR system. You will usually find these in one of two places. You can look in /etc/amportal.conf and look for the variables AMPDBUSER and AMPDBPASS — these will usually be near the bottom of the file in newer installs, in a “— CATEGORY: Bootstrapped or Legacy Settings —” section, but they can be anywhere in the file.

Another place they may be found is in the file /etc/freepbx.conf — in that file, look for lines similar to:

$amp_conf[‘AMPDBUSER’] = ‘freepbxuser’;
$amp_conf[‘AMPDBPASS’] = ‘password’;

Those will give you the values to use to replace freepbxuser and password

-a “From: PBX <asterisk@youraddress.com>” – replace asterisk@youraddress.com with a valid outgoing email address for your system. If you have a Dynamic DNS address, you may be able to use that after the @ in the email address. It mostly depends on how you send outgoing email from your system. Note that using “root” before the @ sign may not work, particularly if you are routing mail through an ISP’s mail servers – one major ISP now appears to silently drop any email that appears to originate from root@anything, so use “asterisk” or “pbx” or something else other than “root”.

-s “Custom Call Report” you@youremail.com – replace you@youremail.com with the address you want the reports emailed to.

What follows is the rest of the original article. The mysql line shown there probably will not work, unless perhaps you are running a very old version of FreePBX (end of edit).

This is very basic, but should get you the info you need. Add it as a cron to run once a day and it will email the date/time of the call along with the CNAM and CID for all incoming calls for the previous day:

mysql -u root -ppassw0rd asteriskcdrdb -e 'SELECT calldate, clid FROM cdr WHERE DATE(calldate) = SUBDATE(CURDATE(), 1) AND did <> ""' | mail -s "Yesterday's Calls" you@youremail.com

Replace the you@youremail.com with your actual email address.

When copying the above, note that it’s all one single line, even though it wraps in this blog post, and also beware that WordPress likes to change single and double quotation marks into the “prettified” versions, so make sure you change those characters back to the plain old ASCII versions or it won’t work correctly. Or, you could just visit the thread mentioned above and copy the line from there.

Link: How to watch Netflix (Watch Instantly) in Linux

EDIT: After publishing this article we learned of another article that gives additional information on what is probably the easiest method so far:

Yesterday, developer and programmer extraordinaire Erich Hoover and I spent several hours working out all of the Netflix Desktop kinks. Most users will have no problems with installation now.

Here is how to install the Netflix Desktop App on Ubuntu. …

Full details here:
PPA for Netflix Desktop App (iheartubuntu)

Should you have problems getting it to work, see:
Report Netflix App Bugs on Launchpad (iheartubuntu)

What follows is the original text of this post, which also mentions this method as one of the two choices:

Running Netflix is entirely possible in Ubuntu Linux 12.04 (and most likely any other modern distribution). See the section below “Running with Wine”.

Until recently there was no simple solution to watching streaming movies via Netflix (Watch Instantly) in Linux for any Linux distros besides Android based computers. Netflix has not released a player that will install natively in any of the others.

Read the full article here:
How to watch Netflix (Watch Instantly) in Linux (How To Wiki)

Link: Build Your Own Raspberry Pi Case from Cardboard or Cardstock

From a company that sells Raspberry Pi’s in North America comes this:

One of our top selling accessories for the Raspberry Pi is the case. Cases for the Pi come in a multitude of styles, sizes and colors, but if you’re like us, you’re the type of person who loves to build it yourself. Today we’re going to build a bare-bones case out of cardboard with supplies you may already have laying around the house.

Read the rest of the article here:
Build Your Own Raspberry Pi Case from Cardboard or Cardstock (MCM Electronics)

In case you are wondering, the finished enclosure looks something like like this (depending on what you make it out of). Just be sure to use a non-conductive material:

An alternative way to power a Raspberry Pi

Did you know that you can use a $20 USB hub (but not just any old USB hub) to power a Raspberry Pi AND use the SAME hub to add additional USB ports to the Pi? Well, you can, as demonstrated in this video:

 

Direct YouTube Link

Apparently not all USB hubs will work, because many only put out something close to the 500 mA that is the specification for USB 2.0, whereas the Raspberry Pi Model B requires 700 mA. So, the hub has to put out a bit of extra current or it won’t power the Raspberry Pi properly.

There is a list of USB hubs that will work with the Raspberry Pi, but pay special attention to the comments in the rightmost column. Only a few of the USB hubs shown are known to be able to power the Raspberry Pi reliably. The one shown in the video is the Plugable 7 Port High Speed USB Hub, model USB2-HUB-AG7 (Amazon affiliate link – we make a small commission if you click on it and purchase a unit).

EDIT: A few weeks after we originally posted this article, the device described in the following article was released:

PiHub from Cyntech and Pimoroni – a new powered USB Hub for the Raspberry Pi

Unless you really don’t need that many USB ports, and you absolutely fall in love with the Raspberry-shaped case of the PiHub, we suggest you stick with the Plugable 7 Port hub mentioned above. Not only are you getting more USB ports, and a hefty 3 Amp power supply, but if you’re in the U.S.A. or Canada it’s actually available here and has mostly 4 and 5 star reviews on Amazon. And if you go with the PiHub, by the time you do the currency conversion (and let your credit card company take a small bite on the exchange rate), and pay for the shipping, you’ll be paying more and getting less (only four ports rather than the seven offered in the Plugable unit). But, you will be getting that lovely Raspberry-shaped case, so there’s that.

Video: Turning the Raspberry Pi into an FM transmitter with PiFM

Direct link to YouTube video

Link to page that describes how it’s done: Turning the Raspberry Pi Into an FM Transmitter

The interesting thing about this: Other than the Raspberry Pi and its power supply, the only external hardware required is a piece of wire to act as an antenna, and a way to connect it to the correct pin on the device!

Notes on setting up Raspbmc on a Raspberry Pi

A couple of days ago we published Notes on setting up OpenELEC on a Raspberry Pi. One thing we found a bit frustrating about OpenELEC was touched upon in that article:

OpenELEC is very fast but much of the file system is read only, and even if you SSH in as root you cannot edit many of the configuration files as you could on a normal Linux system. Sometimes there are ways around that.

Now if you are setting up a system for your grandparents, maybe not having a writable file system, nor access to tools like apt-get for installing additional software won’t bother you. But we found it did bother us. For example, we missed having access to Midnight Commander. While there is an unofficial way to install it on on OpenELEC, the developers apparently would prefer you don’t do that. Well, sorry, but that kind of thinking is not acceptable to us. It’s our system, and we want to be able to control it. In fact, it kind of goes against the whole spirit in which the Raspberry Pi was created to make an “untinkerable” distribution, although we can certainly understand why some people like it. Different strokes for different folks*, and all that.

So we decided to again try Raspbmc. We had tried it once before, but found the interface a bit slow and clunky. However, just a few days ago a new version was released, and reports were that it was faster. So, we decided to give it another try. This time, we installed it using the instructions found here, which are for users that will be writing to the SD card using an OS X or Linux system. If you were using Windows for this task, you’d use these instructions instead. This only writes an installer to the card, and when you place the card into the Raspberry Pi and boot it up it will complete the installation. You must have an active Internet connection for the installation to complete.

The interface in the new version of Raspbmc does seem faster than in the previous version we’d tried. Some things may still be a bit slower than in OpenELEC – we particularly noticed that it took a bit longer for fanart to appear after we’d made a selection.

One thing that had bothered us about OpenELEC was that you could not change the Samba password. In Raspbmc it is easy, you simply SSH into the device (as user pi, default password raspberry) and enter:

sudo smbpasswd -a pi

Also if you want to change the SSH password, which we highly recommend, you simply do:

sudo passwd pi

In either case you will be prompted for the new password.

You can install Midnight Commander in the normal way, using apt-get install mc and it seems to work fine. Another thing we had an issue with in OpenELEC was changing the Samba share name. It’s easier to do this in Raspbmc, but still perhaps a bit non-obvious. The easiest way to do it is simply edit /etc/hostname and change name in that file – this is also picked up by Samba, though you may need to reboot and wait some time before the new share name appears and the old one disappears – it took about 20 minutes on our systems.

One thing we noticed about Raspbmc is that XBMC’s RSS feed is turned off by default. This was a major contributor to high CPU usage in OpenELEC. Not that higher CPU usage is really all that bad, but some people like to see a lower figure. Note that you cannot get an accurate reading from the XBMC GUI – to see an accurate representation of CPU usage you must SSH into the system and use the top command.

Speaking of SSH, one weird thing about RaspBMC is that the first time you SSH into the device, you’ll be asked to select a language and timezone. Always select at least the UTF-8 version of your preferred language – that is probably the only one you need. That’s the first time we’ve ever seen this information requested on an initial SSH login to a system.

* A line from “Everyday People” by Sly and the Family Stone (1968)

Notes on setting up OpenELEC on a Raspberry Pi

First, before you go out an buy a Raspberry Pi for this purpose, keep in mind that it does not have any type of digital audio output (such as a TOSLINK connector), other than the HDMI output – see discussion here. This may or may not be an issue in your installation, but you should be aware of that going into the project.

While you could use NOOBS to set up OpenELEC, you may not get the latest version. You are better off using these installation instructions and downloading the latest build.

OpenELEC is very fast but much of the file system is read only, and even if you SSH in as root you cannot edit many of the configuration files as you could on a normal Linux system. Sometimes there are ways around that. For example, Samba by default is controlled by the file /etc/samba/smb.conf. But you can’t edit that file. However, if you navigate to the /storage/.config directory you will find a file called samba.conf.sample. If you copy or rename that file to samba.conf in the same directory, then that becomes the file that controls Samba, and you can edit that file. For example, you can change the share name by editing the line server string = OpenELEC and changing OpenELEC to something else, and then find the line netbios name = %h and change the %h to the same thing you used as the value for the server string.

Also if you don’t want your Raspberry Pi acting as a Master Browser for your local network, you can comment out the following lines in samba.conf, as shown here:

# domain master = yes
# local master = yes
# preferred master = yes

When you are in XBMC you may notice that the CPU usage seems high. This is apparently because of two things. First, the act of measuring the usage in XBMC and drawing the usage bar on the GUI actually consumes significant CPU power. You can confirm this by using SSH and then the top command to view actual actual usage. When you are on screens that are completely static, with nothing being continually redrawn, the CPU usage will be lower. But also, if you go into XBMC’s settings (System | Appearance | Skins) and turn off the RSS feed, your CPU usage will drop considerably. Note that actually playing video content actually causes CPU usage to decrease since the work of drawing the screen is transferred to the GPU. On the other hand, leaving the XBMC GUI parked on certain pages may cause CPU usage to increase – for example, we found that if we went to a page that displayed large size thumbnails and fanart, the CPU usage shot up considerably.

To get a PVR plugin to work, you must first enable Live TV. Only then will you be given the option to pick a PVR frontend, But note that even if you set it up properly, you might get audio only and no video. As best I can determine, the reason is that neither the Raspberry Pi nor OpenELEC contains a license to play MPEG2 video. The Raspberry Pi folks will be happy to sell you a license, but we didn’t bite so have no idea if it works or not, and we have read where others have had mixed results. Keep in mind that MythTV, and probably other PVR backends, have the ability to transcode recorded programs to another format that does not require a license, so if all you want to do is watch previously recorded content and not actual live TV, you could just set up the backend to transcode everything to a format that the Raspberry Pi will play after it is recorded.

OpenELEC and the Raspberry Pi will output 1080p, however it appears that on some TV’s you need to go into XBMC’s setting and explicitly specify playback at 1080p, otherwise it will default to 720p. This happened for us on one TV set but not on another.

One question remains, some older TV’s need a “CVT reduced blank” signal before they will offer a Dot-by-Dot mode that has no overscan issues. In normal systems you can change this by using specific software, or in Linux, a specific ModeLine in the xorg.conf file. But it appears that OpenELEC has no support for this. This might make OpenELEC a poor choice for those users. Fortunately, you can also try other distributions for the Pi, such as Raspbmc, XBian, or GeeXboX.

Some people are gluttons for Pi: Mounting multiple Raspberry Pi devices

Some fans of the Raspberry Pi just can’t get enough, it seems, and have devised various ways to mount multiple Pis. In fact, when this idea occurred to us, we thought we had the perfect name for such a device – the Pi Rack – until we found out that name was taken by hydroponic growing systems that are sometimes used to grow medical marijuana, and other types of plants. So, guess that idea was only half-baked.

(We’ll pause a moment while you groan at that bad pun, realizing it works two ways. You know, baked pi(e), and baked from… do we really need to spell it out?)

Anyway, we came across this clever way to mount multiple Raspberry Pis, using a block of plywood and the audio and video jacks as mounts:

DSC04761

For more photos, and details on construction and the components used, see this article and the comments underneath:
Simple Pi Rack (raspberrypi.org)

(2020 Edit:) If you happen to stumble across this old article, note there have been several newer ways to mount multiple Pi’s developed since it was written. Some are homemade and some commercial. Some require a 3D printer, such as this one:

3D Printed Raspberry Pi Server Serves Up Fourteen Slices of Pi (Tom’s Hardware)

Useful SSH How-Tos

These are from an interesting site called Make Tech Easier, listed in order from oldest to newest:

Link: MythTV: Use All Buttons of Your Remote Control – Without LIRC

It can be really frustrating to get a remote control to work properly under Linux with LIRC and programs like MythTV, mplayer or XMBC. This article shows how to avoid using LIRC altogether: Treat the remote like any other keyboard, then change the keyboard mapping to use the application’s key shortcuts. Because we do this before the keypresses reach X11, it avoids the dreaded problem of keys with codes >255 not working.

Full article here:
Link: MythTV: Use All Buttons of Your Remote Control – Without LIRC (Richard Atterer)

Recent Posts

Recent Comments

Archives

Categories

Meta

GiottoPress by Enrique Chavez