Logging incoming connections (TCP, Linux)

On a server that I am running MRTG showed me some spikes in incoming connections. It seems that about 800 incoming tcp connections were made within a few minutes. Nagios reported that there were so many connections that no further connections could be created. To examine the problem I wanted to log all incoming TCP … Continue reading “Logging incoming connections (TCP, Linux)”

On a server that I am running MRTG showed me some spikes in incoming connections. It seems that about 800 incoming tcp connections were made within a few minutes. Nagios reported that there were so many connections that no further connections could be created. To examine the problem I wanted to log all incoming TCP connections. This can be done with a single command:

iptables -I INPUT -p tcp --syn -j LOG --log-prefix='[tcpconnections] '

It temporarily adds a rule to the firewall’s INPUT chain to write all incoming TCP packets that have the SYN flag set, i.e. that try to initiate a connection, into the system’s log with the prefix “[tcpconnections] “. Afterward you can see the connections e.g. in /var/log/syslog.

However now the syslog is quickly filled with entries if your server has a lot of TCP traffic. To separate these entries and write them into a different log, add a file “tcpconnections.conf” to “/etc/rsyslog.d“:

:msg,contains,"[tcpconnections] " /var/log/tcpconnections.log
& ~

The first line copies the matching entries into the file /var/log/tcpconnections.log. The second line discards the same entries so that they are not additionally copied into the main syslog. The ampersand means that another action should be applied to the filter in the previous line. A good overview of these parameters can be found in the RedHat documentation here:

Basic configuration of rsyslog

To activate the changes, restart rsyslog:

/etc/init.d/rsyslog restart

Now all connections are logged to tcpconnections.log but the file can get large. So it should be rotated. To do this create a file “tcpconnections” in /etc/logrotate.d and write this into it:

/var/log/tcpconnections.log {
	daily
	rotate 12
	compress
        missingok
}

It will create a new log each day and keep the last 12 logs.

Copying PDF files from the desktop onto iPhones/Android phones

I often find PDF files in the Internet that I would like to read later. And often the best way to read them is on my iPhone/Android phone during times where I have to wait for something. The easiest way to achieve this that I have found is the Amazon Kindle app. Just install the Kindle … Continue reading “Copying PDF files from the desktop onto iPhones/Android phones”

I often find PDF files in the Internet that I would like to read later. And often the best way to read them is on my iPhone/Android phone during times where I have to wait for something. The easiest way to achieve this that I have found is the Amazon Kindle app. Just install the Kindle app on your iPhone/Android phone. Then install one of the Amazon’s desktop clients. They allow you to easily copy PDF files via drag&drop from your computer into your Kindle app. You just need a free Amazon account.

Text messages (SMS) for Nagios

If you would like to get Nagios warnings as SMS on your phone you can simply let Nagios send warning emails to an SMS gateway like MessageBird. They offer accounts with no monthly fee so you have to pay only for the SMS messages that you send. Just do the following: Create an account on MessageBird. Add … Continue reading “Text messages (SMS) for Nagios”

If you would like to get Nagios warnings as SMS on your phone you can simply let Nagios send warning emails to an SMS gateway like MessageBird. They offer accounts with no monthly fee so you have to pay only for the SMS messages that you send. Just do the following:

  1. Create an account on MessageBird.
  2. Add a new contact in Nagios’ contacts_nagios2.cfg file that sends an email to yourphonenumber@sms.messagebird.com (where you replace yourphonenumber with your mobile phone number e.g. 123456789@sms.messagebird.com). Add the new contact also to a contactgroup so that it receives warnings.
  3. Sign in to MessageBird, click on Products > Email to SMS. Add the sender email Nagios will use so that MessageBird knows that this email address is allowed to send SMS through your account.
  4. Test if it works correctly e.g. by adding a Nagios service that fails.

Then you should get your Nagios warnings directly as SMS onto your phone.

Currently the first 9 SMS are free at MessageBird so if your server doesn’t fail too often, this might already last a while. 🙂

Backup without using the cloud

If you don’t like all your important business or personal data to be saved on a server accessible via the Internet, there is an easy and cheap alternative. Just buy multiple hard drives, copy your data onto them at a regular interval and lock them up in a safe-deposit box at a bank. This has several … Continue reading “Backup without using the cloud”

If you don’t like all your important business or personal data to be saved on a server accessible via the Internet, there is an easy and cheap alternative. Just buy multiple hard drives, copy your data onto them at a regular interval and lock them up in a safe-deposit box at a bank. This has several advantages:

  • It is much cheaper for large amounts of data than most cloud services.
  • It is much faster to copy large amounts of data into it (however it is slower for small amounts because you have to bring the hard drive to the bank.
  • It is as secure as the safe-deposit box (if the hard drive doesn’t fail). Additionally you can encrypt the data.

For Mac computers you can use SuperDuper or CarbonCopyCloner. They can clone the complete internal hard drive of your computer onto a bootable USB hard drive. That means if your internal hard drive is damaged or lost, you can just connect the USB hard drive that contains the backup to your computer and boot from it. So you can immediately continue your work.

usb backup

I use SuperDuper but as far as I know CarbonCopyCloner can do the same. SuperDuper can quickly update an existing backup by only copying the files that were changed. So if you have several hard drives in your safe-deposit box you can just take the one with the oldest backup, update it with SuperDuper and put it back. Or you just keep one hard drive at home, update it, bring it to the bank and take the one with the oldest backup back with you. This way several backups are at the bank and one backup is at home.

To encrypt the backup just format it with an encrypted file system using the Mac’s “Disk Utility” program before using SuperDuper.

Instead of using USB hard drives you could certainly also use USB sticks if they are large enough. However when backing up a complete internal hard drive it is usually cheaper to copy it onto an USB hard drive instead of an USB stick.

Mobile Wi-Fi router, power bank and NAS: HooToo TripMate

The HooToo TripMate combines three devices into one: A mobile Wi-Fi router than can take a Wi-Fi or LAN connection and allow up to five devices to use it. Might be useful e.g. to use a Hotel Wi-Fi with multiple devices. A 6000mAh power bank to charge your phone or tablet. A NAS (network attached … Continue reading “Mobile Wi-Fi router, power bank and NAS: HooToo TripMate”

The HooToo TripMate combines three devices into one:

  1. A mobile Wi-Fi router than can take a Wi-Fi or LAN connection and allow up to five devices to use it. Might be useful e.g. to use a Hotel Wi-Fi with multiple devices.
  2. A 6000mAh power bank to charge your phone or tablet.
  3. A NAS (network attached storage) that can share the contents of an USB stick with up to five devices via Wi-Fi. An Android and iOS app is available to allow these devices to access and play multimedia files saved on the USB stick via Wi-Fi.

It is currently sold for $29.99 on Amazon.com which seems to be a very good price. I tested all three functions at home and it worked well. It can be configured directly from the app, e.g. to enter the Wi-Fi configuration of the hotel’s Wi-Fi.

I have also tested in a hotel with a sign in page and it worked well, too. Just connect a phone or computer to the TripMate and try to open a web page. The sign in page will appear and you can enter e.g. the code that you got from the hotel. After signing in once this way you can use it with other devices that you connect to the TripMate without signing in again. It even continues to work when turning the TripMate off and on again.

When it is charged it can operate as Wi-Fi bridge for multiple hours.

When you don’t use it you shouldn’t leave an USB stick connected, because the power bank feature will try to “charge” it, which means it will get power (as if it was connected to a computer) until the power bank is empty. When thinking about it, it is logical that it works this way but one should keep it in mind.

Accessing the SolarLog data

If you have a SolarLog computer to monitor a photovoltaik system and would like to access the current power consumption or power production from an own app (e.g. to display it on a widget on your computer), you can simply download http://[IP of SolarLog computer]/min_cur.js?nocache and look for a row “var PacArr= [[971], [0]];”. It contains … Continue reading “Accessing the SolarLog data”

If you have a SolarLog computer to monitor a photovoltaik system and would like to access the current power consumption or power production from an own app (e.g. to display it on a widget on your computer), you can simply download

http://[IP of SolarLog computer]/min_cur.js?nocache

and look for a row “var PacArr= [[971], [0]];”.

It contains the current power consumption in watt (971) and the current production in watt (0).

Power usage USB sticks

When I bought a new 64GB Sandisk UltraFit USB stick and used it, it got very hot, even when it was not used. I compared it to a 32GB Transcend JetFlash USB stick, which didn’t get so hot. So I began to measure the power consumption: Power consumption according to MacOS: Sandisk: 896 mA Transcend: … Continue reading “Power usage USB sticks”

When I bought a new 64GB Sandisk UltraFit USB stick and used it, it got very hot, even when it was not used. I compared it to a 32GB Transcend JetFlash USB stick, which didn’t get so hot. So I began to measure the power consumption:

Power consumption according to MacOS:

Sandisk: 896 mA
Transcend: 304 mA

Power consumption according to a Brennerstuhl ammeter by plugging the sticks into a charger and measuring the consumption:

Sandisk: 0.07W
Transcend: 0.02W

[visualizer id=”40″]

So the power consumption of the Sandisk USB stick is significant higher. E.g. according to these values a powerbank with 6000 mAh would be drained in about seven hours only by powering the USB stick without reading or writing anything. That was a little bit unexpected to me and will reduce the time one can use it with a notebook while running on battery power.

Transferring a domain

Recently I transferred a domain from one provider to another (Server4You) and found it to be very fast and simple. After canceling the contract with the old provider it provided an AuthInfo Code that I had to give to the new provider (I had to enter it on their website). Afterward the transfer was automatically performed … Continue reading “Transferring a domain”

Recently I transferred a domain from one provider to another (Server4You) and found it to be very fast and simple. After canceling the contract with the old provider it provided an AuthInfo Code that I had to give to the new provider (I had to enter it on their website). Afterward the transfer was automatically performed in less than two hours without any interruption. I had already set the new IP for that domain when using the old provider so the IP stayed the same during the transfer.

Home automation with KNX

Using KNX it is possible to build a flexible way to control lights and shutters of a house. This will give a short exemplary overview what is necessary to build and program such a system. Hardware To build a working KNX system you need at least a power supply with a choke, an actuator, a touch … Continue reading “Home automation with KNX”

Using KNX it is possible to build a flexible way to control lights and shutters of a house. This will give a short exemplary overview what is necessary to build and program such a system.

Hardware

To build a working KNX system you need at least a power supply with a choke, an actuator, a touch sensor and a way to program it, e.g. using the Wiregate computer and a USB-KNX interface. Then you can extend this system using further actuators and touch sensors.

In this example a lot of MDT devices are used because they are cheap and flexible. But you can also choose from a broad variety of manufacturers because the KNX standard makes the devices compatible to each other. Here is an example list:

Power supply e.g. from Eibmarkt

Power supply and choke
Power supply, choke and line coupler

Switch actuator for switching lights, e.g. MDT AKK-1616.02 for 16 lights.

Switch actuator
Switch actuator MDT AKK-1616.01

Touch sensors e.g. from Berker.

Computer for programming the KNX system and for performing time dependent tasks. E.g. the Wiregate computer with a USB-KNX interface.

Windows PC with ETS software. It is needed to assign addresses and actions to the KNX devices. You can get the Lite version (which supports up to 20 KNX devices in each project) for free by completing the ETS eCampus online course.

 

That’s all what is needed to build a very small but working KNX network. Just connect the power supply, switch actuator and touch sensors to each other as documented and as you have learned in the ETS eCampus online course. Then connect the Windows PC and the Wiregate computer to the same network. Start the ETS and connect it to the Wiregate. Load the MDT and Berker product databases into the ETS software so that it knows which parameters your devices support.

Then assign addresses to your devices and configure them to communicate with each other. Everything you need to know was explained in the ETS eCampus online course. I will provide some screenshots here later.

When you tap one of the touch sensors, it will send a group address onto the KNX bus. The switch actuator will listen to that group address and switch the light on or off. That means after everything has been programmed, no computer is necessary for these simple tasks. Only for more complex tasks like turning the lights off or on at a certain time you need a computer. The Wiregate computer makes it easy to build your own automation solutions by providing a web interface that allows you to create small Perl scripts that react on group addresses or that are automatically started at a regular interval.