Showing posts with label how-to. Show all posts
Showing posts with label how-to. Show all posts

Saturday, April 13, 2013

Server monitoring - Uptime Robot


I had mentioned in one of my posts that I wanted to be able to monitor the uptime of my teapot.
Thanks to a comment from Peter (one of the few readers of this blog :-) I found the service UptimeRobot.


There are other services offering availability to monitor servers uptime... but most of them expect that a Web server returns a "200" code. As I worked hard to return a "418" code, most software sees my server as an anomaly. I can not use either TCP or ping controls because my router answers instead of the server if it is disconnected.

UptimeRobot service has the particularity to propose to monitor the presence of a keyword. So I can verify the presence of the text "error 418" to control the operation of my server and receive an alert when he is down.

Saturday, February 23, 2013

Lighttpd - Access log

Lighttpd have an access log, but it's disabled by default.

Activate access log
To actite it you have to modify the configuration file:
"/etc/lighttpd/lighttpd.conf"

Where you have to activate the mod_accesslog module:

server.modules = (
...
"mod_accesslog"
...
)

And define the access log path, exemple: 
accesslog.filename             = "/var/log/lighttpd/access.log"

Reading the log
The log will be written in the defined file. Every week, the file will be saved as "access.log.2.gz" and a new "access.log" file will be created.

Log Format
Log lines are defined like that by default:
address of remote-host adress of the server user timestamp "request" status code bytes sent "Referer adress" "User-Agent"

1?.6?.1?.1? www.htcpcp.net - 23/Jan/2013:07:13:56 +0000 "GET / HTTP/1.1" 200 1371 "http://www.error418.fr/" "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0)"

When I decided to check of my server log, I didn't thought to find something interesting in it. But reading this log was much more exciting than I thought, making me discover a universe populated by Agents Robots, Nerds and Pirates who will the topic of future posts.

Sunday, January 20, 2013

A bug on the teapot - Firefox Debugging tools



I received an email from a visitor telling me there is a bug on the site of my teapot.
In summary, he told me that the debugger says him that my teapot it returns him a code 200 instead of a 418 code.

But how to check the presence of this bug by myself? I explored the development tools in the Firefox menu to find the option "Web Developer / Web Console".




This tool displays some technical informations about the current page in a banner that appears at the bottom (remember to refresh the page if nothing is displayed)




Indeed, the return code 200 is the code sent after a HTTP request accepted by the server. My teapot hosting a web server, it returns this return code when you visit my page.

It is also noticed traces of my usage of Google Analytics with this tool.

Now that I'm aware of this failure, I'll try to find a way to return a true 418 code in a future post.

Monday, December 3, 2012

How to control the Raspberry Pi from Windows: Tight Vnc

TightVNC Home If the SSH console is not enough user friendly for you and if you want to remote control your Raspeberry Pi using a graphical user interface, VNC may be an good solution.

Install TightVNCServer
http://www.tightvnc.com/

TightVNCServer is a free and lightweight remote control software compatible with standard VNC software
The command to install it is:
"sudo apt-get install tightvncserver"

Start VNC server
To start the VNC Server from the Linux System, you have to execute this command:
"tightvncserver"

The system will ask you for a password (at least 6 caracters)

"You will require a password to access your desktops.

Password:
Verify:"


After that the software will ask you for an view-only password.
"Would you like to enter a view-only password (y/n)?"
You should answer no ("n") if you only need to control your system.

After that, your VNC will give you an X session number.
"New 'X' desktop is raspberrypi:1

Starting applications specified in /root/.vnc/xstartup
Log file is /root/.vnc/raspberrypi:1.log"


Install TightVNCClient
You may use any VNC client, but why not continue with TightVNC?
You can download it here: http://www.tightvnc.com/download.php

When you install VNC, it may be a good idea to chose a custom installation if you don't need an VNC Server on your windows computer.




Use the VNC client 

To use VNC, you need to type the server adress and the session number.

The VNC client will ask for the password.

 Now you can use your Raspberry with the X interface.

Sunday, November 18, 2012

How to install a web server on Raspberry Pi - Lighttpd


http://www.lighttpd.net/Lighttpd (http://www.lighttpd.net/) is an open source webserver which has reputation of being very light. Therefore it looks perfect for an Raspberry Pi. Here are the commands I used to install it


Lighttpd installation
sudo apt-get install lighttpd





The directory containing the web pages is:
 /var/www"


The "pi" user does not have write permission to this directory.
You can give these rights with the following set of commands:

sudo chown www-data:www-data /var/www (to make the www-data owner of the directory)

sudo chmod 777 /var/www (to have full right to this directory)
sudo usermod -a -G www-data pi (to had the pi user to the www-data group)


You can now had your html file to the "/var/www" directory.

The configuration file is:
/etc/lighttpd/lighttpd.conf

The error log is:
/var/log/lighttpd/error.log

The command to restart the server:
sudo /etc/init.d/lighttpd restart

The command to reload the configuration
sudo service lighttpd force-reload

The server is ready. It is possible to use PHP and other services with Lighttpd, but I didn't do it so I can't explain it here.

Wednesday, November 14, 2012

How to exchange files between Windows and Raspberry Pi - WinSCP

In addition to be able to control the Raspberry from a Windows PC, you sometimes need to exchange files between the two systems. There are two protocols based on SSH for this, SCP (Secure CoPy) and SFTP (SSH file transfer protocol). These protocols are used to exchange files securely with a system using SSH and are equivalent, though SFTP is more recent..

WinSCP can use both protocols from Windows.

WinSCP
http://sourceforge.net/projects/winscp/
In the main interface you can choose between SFTP and SCP protocols, specify the IP address of the Raspberry Pi, the user "pi" and the password.



Once connected, you can browse in the Windows system on the left side and in the Linux system on the right side and exchange files between them by drag and drop.


Sunday, November 11, 2012

How to control the Raspberry Pi from Windows: SSHputty

Sometime your Raspberry Pi (or another Linux computer) is not physically accessible and that you can't connect any keyboard or screen. It may occurs when it is enclosed in a teapot.

It is necessary in this situation to find tools to drive it from another computer, connected in the same network.

I therefore suggest you to use the SSH (Secure Shell) service with the client software SSHputty

Activate SSH
To use this tool, the SSH  service should be active. It is activated by default in Raspbian. But if necessary it is very easy to turn it on, just call the command "sudo Raspi-config"

The following menu appears and then allows to enable the SSH service.


SSHputty
http://www.putty.org/



This is an SSH client that allows you to control any system compatible with SSH command line from a Windows PC.

After installing and running it, just chose the Raspberry Pi with its IP address (and port 22) and click on "Open" button

A command line interface will appear and ask for the username and password.

You can then control the Raspberry Pi with the command line interface, but not start the GUI.

Wednesday, November 7, 2012

How to wire an ethernet patch cable

To connect my Raspberry Pi to the network, from the teapot, I had wire my own cable. (Because the RJ45 connector didn't fit in the spout of the teapot)

Erevy time I had to do a cable, I ask for the same questions, so I decided to write an small tutorial here for "straight-through" cables.

What do we need?

  • patch cable
  • RJ-45 connector
  • boots
  • RJ458 crimper








1-Strip off the cable with the crimper.


2-Insert the boot, and untwist the pairs.

3-Align the wires in the right order and cut them to the same size.
The order is this one for T568B cable:
1-white/orange
2-orange
3-white/green
4-blue
5-white/blue
6-green
7-white/brown
8-brown



 4-Put the wires into the connector, and check they are still in the right order.

5-Be sure the wires are fully insered into the connector.

 6-Crimp the cable.
 

7-Just slide the boot.

The second connector is wired with the same order.

Just plug and enjoy!