General

squid X-forwarded-for logs

logformat squid [%{%d/%m/%Y-%H:%M:%S}tl] %un %{X-Forwarded-For}>h through %>a %Ss/%03Hs %rm/%Hs %ru %Sh/%h

cache_access_log /var/log/squid3/access.log squid

also

By WladyX on 30 September, 2011 | General | A comment?

Installing Cygwin/X

Cygwin/X packages are located in the X11 category.

  • xorg-server (required, the Cygwin/X X Server)
  • xinit (required, scripts for starting the X server: xinit, startx, startwin (and a shortcut on the Start Menu to run it), startxdmcp.bat )
  • xorg-docs (optional, man pages)
  • X-start-menu-icons (optional, adds icons for X Clients to the Start menu)
  • You may also select any X client programs you want to use, and any fonts you would like to have available.
  • You may also want to ensure that the inetutils or openssh packages are selected if you wish to use telnet or ssh connections to run remote X clients.

source

By WladyX on 29 September, 2011 | General | A comment?

Make pg_hba.conf Changes Activate Without Restarting Postgres

su - postgres
vi /var/lib/pgsql/data/pg_hba.conf
pg_ctl reload -D /var/lib/pgsql/data/

source

By WladyX on | General | A comment?

Filter rsyslog message log

conf:

:programname, isequal, "postgres" ~
*.*;auth,authpriv.none -/var/log/syslog

source

===========

if $programname == 'dovecot' and $msg contains 'Disconnected (no auth attempts): rip=127.0.0.1, lip=127.0.0.1' then ~
if $programname == 'sudo' and $msg contains 'zabbix : TTY=unknown ; PWD=/ ; USER=root ; COMMAND=/usr/sbin/hddtemp -n' then ~
if $programname == 'pure-ftpd' and ($msg contains '(?@127.0.0.1) [INFO] New connection from 127.0.0.1' or $msg contains '(?@127.0.0.1) [INFO] Logout.') then ~
if $programname == 'postfix' and ($msg contains 'connect from localhost[127.0.0.1]' or $msg contains 'lost connection after CONNECT from localhost[127.0.0.1]') then ~

*.*                  /var/log/everything.log

By WladyX on 22 September, 2011 | General | A comment?

Twitter Tricks: Find Your Account RSS Feed In The New Profile Format

How To Find Your Twitter RSS Feed

  • All Twitter account RSS feeds are written in this format: http://twitter.com/statuses/user_timeline/(User Account ID).rss.
  • If you happen to know the Account ID of the user you want to follow, you just have to plug in the right number where I’ve written (User Account ID) and you should be good to go. See a completed example below. If you don’t know the ID you’re after, read the following steps.
  • To find Twitter account IDs, the easiest method is to use ID from User. Type in the user name of the account that you’re interested in following, and this cool little tool will automatically generate the Twitter account ID you need.
  • Again, finish off by inserting the ID that you just found into the Twitter RSS URL and you’re all set

As an example, we can look at my Twitter Account. My User ID is 213772242. By adding that to the generic Twitter RSS URL, we get: http://twitter.com/statuses/user_timeline/213772242.rss

source

By WladyX on 11 August, 2011 | General | A comment?

Monitoring services and restart them using Monit

monit is a utility for managing and monitoring, processes, files, directories and devices on a UNIX system. Monit conducts automatic maintenance and repair and can execute meaningful causal actions in error situations.

Monit Features

* Daemon mode – poll programs at a specified interval
* Monitoring modes – active, passive or manual
* Start, stop and restart of programs
* Group and manage groups of programs
* Process dependency definition
* Logging to syslog or own logfile
* Configuration – comprehensive controlfile
* Runtime and TCP/IP port checking (tcp and udp)
* SSL support for port checking
* Unix domain socket checking
* Process status and process timeout
* Process cpu usage
* Process memory usage
* Process zombie check
* Check the systems load average
* Check a file or directory timestamp
* Alert, stop or restart a process based on its characteristics
* MD5 checksum for programs started and stopped by monit
* Alert notification for program timeout, restart, checksum, stop resource and timestamp error
* Flexible and customizable email alert messages
* Protocol verification. HTTP, FTP, SMTP, POP, IMAP, NNTP, SSH, DWP,LDAPv2 and LDAPv3
* An http interface with optional SSL support to make monit accessible from a webbrowser

Install Monit in Debian

#apt-get install monit

This will complete the installation with all the required software.

Configuring Monit

Default configuration file located at /etc/monit/monitrc you need to edit this file to configure your options

Sample Configuration file as follows and uncomment all the following options

## Start monit in background (run as daemon) and check the services at 2-minute
## intervals.
#
set daemon 120

## Set syslog logging with the ‘daemon’ facility. If the FACILITY option is
## omited, monit will use ‘user’ facility by default. You can specify the
## path to the file for monit native logging.
#
set logfile syslog facility log_daemon

## Set list of mailservers for alert delivery. Multiple servers may be
## specified using comma separator. By default monit uses port 25 – it is
## possible to override it with the PORT option.
#
set mailserver localhost # primary mailserver

## Monit by default uses the following alert mail format:

From: monit@$HOST # sender
Subject: monit alert — $EVENT $SERVICE # subject

$EVENT Service $SERVICE

Date: $DATE
Action: $ACTION
Host: $HOST # body
Description: $DESCRIPTION

Your faithful,
monit

## You can override the alert message format or its parts such as subject
## or sender using the MAIL-FORMAT statement. Macros such as $DATE, etc.
## are expanded on runtime. For example to override the sender:
#
set mail-format { from: monit@monitorserver.com }

## Monit has an embedded webserver, which can be used to view the
## configuration, actual services parameters or manage the services using the
## web interface.
#
set httpd port 2812 and
use address localhost # only accept connection from localhost
allow localhost # allow localhost to connect to the server and
allow 172.29.5.0/255.255.255.0
allow admin:monit # require user ‘admin’ with password ‘monit’

# Monitoring the apache2 web services.
# It will check process apache2 with given pid file.
# If process name or pidfile path is wrong then monit will
# give the error of failed. tough apache2 is running.
check process apache2 with pidfile /var/run/apache2.pid

#Below is actions taken by monit when service got stuck.
start program = “/etc/init.d/apache2 start”
stop program = “/etc/init.d/apache2 stop”
# Admin will notify by mail if below of the condition satisfied.
if cpu is greater than 60% for 2 cycles then alert
if cpu > 80% for 5 cycles then restart
if totalmem > 200.0 MB for 5 cycles then restart
if children > 250 then restart
if loadavg(5min) greater than 10 for 8 cycles then stop
if 3 restarts within 5 cycles then timeout
group server

#Monitoring Mysql Service

check process mysql with pidfile /var/run/mysqld/mysqld.pid
group database
start program = “/etc/init.d/mysql start”
stop program = “/etc/init.d/mysql stop”
if failed host 127.0.0.1 port 3306 then restart
if 5 restarts within 5 cycles then timeout

#Monitoring ssh Service

check process sshd with pidfile /var/run/sshd.pid
start program “/etc/init.d/ssh start”
stop program “/etc/init.d/ssh stop”
if failed port 22 protocol ssh then restart
if 5 restarts within 5 cycles then timeout

You can also include other configuration files via include directives:

include /etc/monit/default.monitrc
include /etc/monit/mysql.monitrc

This is only sample configuration file. The configuration file is pretty self-explaining; if you are unsure about an option, take a look at the monit documentation http://www.tildeslash.com/monit/doc/manual.php

After configuring your monit file you can check the configuration file syntax using the following command

#monit -t

Once you don’t have any syntax errors you need to enable this service by changing the file /etc/default/monit

# You must set this variable to for monit to start
startup=0

to

# You must set this variable to for monit to start
startup=1

Now you need to start the service using the following command

#/etc/init.d/monit start

Monit Web interface

Monit Web interface will run on the port number 2812.If you have any firewall in your network setup you need to enable this port.

Now point your browser to http://yourserverip:2812/ (make sure port 2812 isn’t blocked by your firewall), log in with admin and monit.If you want a secure login you can use https check here

Monitoring Different Services

Here’s some real-world configuration examples for monit. It can be helpful to look at the examples given here to see how a service is running, where it put its pidfile, how to call the start and stop methods for a service, etc. Check here for more examples.

 

My setup:

set daemon 60 with start delay 60
set alert email@mail.com with reminder on 60 cycles
set mailserver localhost port 25 with timeout 15 seconds
set logfile syslog facility log_daemon

set httpd port 2812 and use address ham.com
allow localhost   # Allow localhost to connect
allow q   # Allow q to connect
allow admin:monit # Allow Basic Auth

set eventqueue
basedir /var/monit
slots 5000

check process mysqld with pidfile “/var/run/mysqld/mysqld.pid”
start program = “/etc/init.d/mysql restart” with timeout 60 seconds
stop program = “/etc/init.d/mysql stop” with timeout 60 seconds
if 4 restarts within 5 cycles then timeout
if failed host 127.0.0.1 port 3306 then restart
group mysql

 

source

By WladyX on 9 June, 2011 | General, Scripts | A comment?

Data Protector ext4

/opt/omni/lbin/.util

Within there is a line:

/bin/df -P -t psfs -t ext2 [snipped]

All you need to do so that Data Protector can recognise the ext4 filesystem is added a little snippet near the other filesystems:

‘-t ext4′

source

By WladyX on 5 May, 2011 | General | A comment?

rsnapshot reports

# this script prints a pretty report from rsnapshot output
# in the rsnapshot.conf you must set
# verbose >= 3
# and add –stats to rsync_long_args
# then setup crontab ‘rsnapshot daily 2>&1 | rsnapreport.pl | mail -s”SUBJECT” backupadm@adm.com
# don’t forget the 2>&1 or your errors will be lost to stderr

ln -s /usr/share/doc/rsnapshot-1.3.1/utils/rsnapreport.pl /usr/local/bin/

source

By WladyX on 3 May, 2011 | General, Scripts | A comment?

Show/Do not show gnome network manager applet in kde4

edit /etc/xdg/autostart/nm-applet.desktop and add KDE; to the line that has ONLY_SHOW_IN

[Desktop Entry]
Name=Network Manager
Comment=Control your network connections
Icon=nm-device-wireless
Exec=nm-applet –sm-disable
Terminal=false
Type=Application
OnlyShowIn=GNOME;XFCE;
X-GNOME-Bugzilla-Bugzilla=GNOME
X-GNOME-Bugzilla-Product=NetworkManager
X-GNOME-Bugzilla-Component=general
X-GNOME-Autostart-enabled=true
X-Ubuntu-Gettext-Domain=nm-applet

source

By WladyX on 2 May, 2011 | General, Gnome, KDE | A comment?

Data Protector CentOS/RedHat Linux client install

Make sure that both the server and the client resolve each others hostnames.
Disable firewall on the client/or permit access to the 5555 port.

Check if xinetd is installed and running:
service xinetd status
if it is not then:
yum install xinetd

create /etc/xinetd.d/omni:
service omni
{
socket_type = stream
protocol = tcp
wait = no
user = root
server = /opt/omni/lbin/inet
server_args = inet -log /var/opt/omni/log/inet.log
disable = no
}

service xinetd start

go to the HP-UX kit folder
./omnisetup.sh -server dpserver.fqdn -install da

source1 source2 source3 source4

By WladyX on | General, RedHat | A comment?