Raspberry-pi and CAM

Posted in RaspBerry-Pi with tags , , on May 10, 2013 by kiranopatil

Setup a webcam security system with Raspberry-pi

What you need:

•           Raspberry Pi with an OS installed

index

•           One or more USB web cameras

176-85-LOCC110

What you can do:

•           Motion detection – record video/and or frames if there is motion.

•           Taking snapshots of movement

•           Snapshot intervals – take time interval snapshots regardless of motion detection.

•           Live video IP stream in mjpeg format.

•           Watch multiple video devices at the same time using Google Chrome Extension

https://chrome.google.com/webstore/detail/cctv-view/oajmcmcpiboagipoflploplebgicaadj/reviews/

•           Specify recorded video to be saved in your choice mpeg, avi, flv, swf format.

Steps:

1.  Plugin your webcam.

For me, Logitech Webcam C110 worked fine.

Please ensuring that you have the latest software and drivers installed on pi by running

# sudo apt-get update

# sudo apt-get upgrade

2.  Install Motion and also following applications

# sudo apt-get install motion

#sudo apt-get install mplayer

#sudo apt-get install ffmpeg

#sudo apt-get install motion

#sudo apt-get install feh     (image viewer)

#sudo apt-get install screen

3. Plug in web cam

pi@raspberrypi ~ $ lsusb

Bus 001 Device 005: ID 046d:0829 Logitech, Inc.

4. Configure Motion

# vi /etc/motion/motion.conf

##########################START######################

daemon=on

norm=3

input=8

auto_brightness=on

framerate=5

height=240width=320

jpeg_filename=motion/%Y%m%d/%v-%H%M%S-%q

noise_tune=on

output_all=off

output_motion=on

output_normal=on

quality=1000

snapshot_interval=500

target_dir=/home/pi/motion

text_left=(c) Kiran

text_right=%d %b %Y\n%k:%M:%S

threshold=500

v4l2_palette=6

videodevice=/dev/video0

webcam_localhost=off

webcam_maxrate=50

webcam_port=8080

wecam_quality=100

##########################END######################

# sudo  /etc/init.d/motion restart

  1. Create a directory

# /home/pi/.motion.

In this directory, create the configuration file motion.conf for motion. When started with this configuration file, the webcam creates JPG images and AVI video, and start a web server on port 8080.

Setup the internal network to forward requests on a specific external port to the Raspberry Pi’s webcam port.

View the camera on the Pi through the web interface

to check it, visit http://PI_ip:8080 and you are able get a stream.

Rasp_Cam

Nagios Installation on FreeBSD-9.0

Posted in FreeBSD on June 19, 2012 by kiranopatil

Nagios installation on FreeBSD-9.0

 

Install Mysql Server 5.5 from ports

 # cd /usr/ports/databases/mysql55-server

# make

# make install clean

 
 

To start mysql service, Add the below line to /etc/rc.conf

mysql_enable=”YES”

# ee /etc/rc.conf

Start mysql server using below mentioned command

#/usr/local/etc/rc.d/mysql-server start

Make mysql admin password

Set the mysql admin password as “nagios”

# mysqladmin -u root -p password nagios

(mysqladmin -u root password “newpassword”)

Log in to mysql console to check if the password was set proprely using below mentioned command

# mysql –u root –p

Type the password

You can exit from the prompt by typing “exit” command

Install  Apache  from ports

# cd /usr/ports/www/apache22

# make

# make install clean

Enable mysql-support in the blue screen

Enable and launch the apache service

Add the below line to /etc/rc.conf

apache22_enable=”YES”

# ee /etc/rc.conf

Start Apache service:

# /usr/local/etc/rc.d/apache22 start

Test the apache page http://ip or http://hostname

Install  PHP and  php-extention

# cd /usr/ports/lang/php52

# make

# make install clean

Make sure to enable apache module in the install Step (Blue screen)

# cd /usr/ports/lang/php52-extensions

# make

# make install clean

Select sessions and mysql support in the configurations options (Blue screen)

Php Configuration

Settings for PHP are stored in the /usr/local/etc/php.ini file.

Use the following command

# cp /usr/local/etc/php.ini-dist /usr/local/etc/php.ini

Also Apache needs to be configured, so it can use php.

# cd /usr/local/etc/apache22/

# ee httpd.conf

Scroll down to the end of the /usr/local/etc/apache22/httpd.conf and add the following lines.

DirectoryIndex index.php index.html index.htm

AddType application/x-httpd-php .php

AddType application/x-httpd-php-source .phps

Save and exit.

Test PHP

Restart   apache  to check if  you  have  any  errors

# /usr/local/etc/rc.d/apache22 restart

Output:

Performing sanity check on apache22 configuration:

Syntax OK

Stopping apache22.

Waiting for PIDS: 61539.

Performing sanity check on apache22 configuration:

Syntax OK

Starting apache22.

Check  phpinfo page

To test the php run the following command to create a php file in the


# echo “<? phpinfo(); ?>” >> /usr/local/www/apache22/data/test.php

Now check the page http://ip/test.php

Install Nagios:

# cd /usr/ports/net-mgmt/nagios

# make

# make install clean

And use default installation, in installation screen of nagios plugins don’t forget to add NETSNMP to Nagios group and user.

Enable nagios  to  start  with  boot

Add the below line to /etc/rc.conf

nagios_enable=”YES”

# ee /etc/rc.conf

Now copy the sample page to the configuration files

# cd /usr/local/etc/nagios/

# cp cgi.cfg-sample cgi.cfg

# cp nagios.cfg-sample nagios.cfg

# cp resource.cfg-sample resource.cfg

Navigate to the /usr/local/etc/nagios/objects/ and do the  same :

# cd /usr/local/etc/nagios/objects/

# cp commands.cfg-sample commands.cfg

# cp contacts.cfg-sample contacts.cfg

# cp localhost.cfg-sample localhost.cfg

# cp printer.cfg-sample printer.cfg

# cp switch.cfg-sample switch.cfg

# cp templates.cfg-sample templates.cfg

# cp timeperiods.cfg-sample timeperiods.cfg

Now check you nagios configurations errors using following command

 

#  nagios -v  /usr/local/etc/nagios/nagios.cfg

You can create a password for the nagios web interface using the following command:

# htpasswd -c /usr/local/etc/nagios/htpasswd.users nagiosadmin

16-Now add Nagios to your apache configuration:

# ee /usr/local/etc/apache22/httpd.conf 

And at the end of the file add:

##########NAGIOS###########

ScriptAlias /nagios/cgi-bin/ /usr/local/www/nagios/cgi-bin/

Alias /nagios /usr/local/www/nagios/

<Directory /usr/local/www/nagios>

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName “Nagios Access”

AuthType Basic

AuthUSerFile /usr/local/etc/nagios/htpasswd.users

Require valid-user

</Directory>

<Directory /usr/local/www/nagios/cgi-bin>

Options ExecCGI

AllowOverride None

Order allow,deny

Allow from all

AuthName “Nagios Access”

AuthType Basic

AuthUSerFile /usr/local/etc/nagios/htpasswd.users

Require valid-user

</Directory>

##########NAGIOS#############

Save the configuration and exit

17-Restart apache to check if any errors

# /usr/local/etc/rc.d/apache22 restart

Now  open your  nagios  page  with  Http://ip/nagios and  insert  your  login and  password created  before

Convert a man page to pdf

Posted in FreeBSD on May 3, 2012 by kiranopatil

Convert a man page to pdf

man -t ndisgen | ps2pdf – > ndisgen.pdf

Install Webmin Application on FreeBSD

Posted in FreeBSD on December 10, 2011 by kiranopatil

Install Webmin Application on FreeBSD

Webmin is a web-based interactive tool used for remote administration work for UNIX & Linux systems. It is very useful tool for administrators.

To Install Webmin, First you need to update the ports

#portsnap fetch update

Execute Webmin command

# cd /usr/ports/sysutils/webmin

# make install clean

Configure Webmin the service

# vi /etc/rc.conf

Add following line

webmin_enable=”YES”

Save and close the file.You need to run the Script to setup various configure files

# cd /usr/local/lib/webmin/

# ./setup.sh

Output

***********************************************************************

*            Welcome to the Webmin setup script, version 1.570        *

***********************************************************************

Webmin is a web-based interface that allows Unix-like operating

systems and common Unix services to be easily administered.

Installing Webmin in /usr/local/lib/webmin …

***********************************************************************

Webmin uses separate directories for configuration files and log files.

Unless you want to run multiple versions of Webmin at the same time

you can just accept the defaults.

Log file directory [/var/log/webmin]: (Default press Enter Button)

***********************************************************************

Webmin is written entirely in Perl. Please enter the full path to the

Perl 5 interpreter on your system.

Full path to perl (default /usr/bin/perl): (Default press Enter Button)

Testing Perl …

Perl seems to be installed ok

***********************************************************************

Operating system name:    FreeBSD

Operating system version: 8.0

***********************************************************************

Webmin uses its own password protected web server to provide access

to the administration programs. The setup script needs to know :

– What port to run the web server on. There must not be another

web server already using this port.

– The login name required to access the web server.

– The password required to access the web server.

– If the webserver should use SSL (if your system supports it).

– Whether to start webmin at boot time.

Web server port (default 10000): (Default press Enter Button)

Login name (default admin): (Default press Enter Button)

Login password: (Type the password )

Password again: (Type the password )

Use SSL (y/n):  (Type if you want SSL press y or n)

***********************************************************************

Creating web server config files..

..done

Creating access control file..

..done

Creating start and stop scripts..

..done

Copying config files..

..done

Changing ownership and permissions ..

..done

Running postinstall scripts ..

PID file /var/log/webmin/miniserv.pid does not exist

: Permission denied

syslog-ng: not found

: Permission denied

..done

Enabling background status collection ..

PID file /var/log/webmin/miniserv.pid does not exist

..done

To start the Webmin service.

# /usr/local/etc.rc.d/webmin start

Run any browser, type the server name or IP with respective of  :10000.

https://serverip:10000

Login page.

 

Network Bandwidth & Traffic Monitoring

Posted in FreeBSD on September 29, 2011 by kiranopatil

Go through the steps to install darkstat package on FreeBSD

# cd /usr/ports/net-mgmt/darkstat

# make # make install clean

Enable darkstat at boot time add the following lines to

/etc/rc.conf: darkstat_enable=”YES”

darkstat_interface=”em0″

Change the darkstat_interface to point your network interface Add the following lines to /etc/rc.conf:

darkstat_dir=”/var/run/darkstat”

darkstat_pidname=”darkstat.pid”

darkstat_dropuser=”nobody”

darkstat_flags=””

Now the darkstat installed and configured let’s start it:

# /usr/local/etc/rc.d/darkstat start

To check darkstat daemon status:

# /usr/local/etc/rc.d/darkstat status

By Default it works on 667 port, to check the Network traffic

Here you go

http://localhost:667

Vnc Configuration For Linux

Posted in Linux on September 29, 2011 by kiranopatil

#Yum install vnc-server

Here are my typical steps

1. install vncserver

2. modify /etc/sysconfig/vncservers

——VNCSERVERS=”1:user1″

——VNCSERVERARGS[1]=”-geometry 1024×768″

3. logon as user1

4. run vncpasswd

5. logon as root

6. service vncserver start

7. modify /home/user1/.vnc/xstart and uncomment the following two lines

————unset SESSION_MANAGER

————exec /etc/X11/xinit/xinitrc

8. service vncserver restart

9. chkconfig vncserver on

10. the firewall shouldn’t even be enabled! I turned it off with:

/etc/init.d/iptables stop

chkconfig iptables off will make a persistent change.

 

Enable or Disable Root Login for SSH

Posted in FreeBSD on September 20, 2011 by kiranopatil

Enable or Disable Root Login for SSH

cd/etc/ssh

to enable root login

vi sshd_config

PermitRootLogin yes

to disable root login

vi sshd_config

PermitRootLogin no

After you do the changes, save and exit
Then restart sshd service
/etc/rc.d/sshd restart

On Linux

/etc/init.d/sshd restart