Archive for the ‘linux’ Category

Screen Tips

Saturday, October 4th, 2008

A few snippets to make your prompt look better when using screen for linux.

Add the below to your .bashrc so each tab created when you generate a new screen shows user@hostname

function rename_screen_tab () { echo -ne “\x1bk$@\x1b\\”; return 0; }

if [[ "$TERM" = screen* ]]; then
PROMPT_COMMAND=’rename_screen_tab ${USER}@${HOSTNAME%%.*}’
[ "$HOSTNAME" = "hostname-of-mainbox" ] && PROMPT_COMMAND=’rename_screen_tab ${SCREEN_TAB:-$USER}’
fi

Add the below to your .screenrc

hardstatus off
caption always “%?%F%{= Kk}%:%{=u kR}%?  %h %-024=%{+b} %C%a %D %d %M %Y%{= db}”
hardstatus alwayslastline
hardstatus string ‘%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %d/%m %{W}%c %{g}]‘
shelltitle “$ |bash”

Note: the hardstatus string should be on the one line.

How to update DNS through DHCP automatically

Thursday, October 2nd, 2008

If you are looking for configuration then you need it as follows:

Let us say domain is test.com
Domain nameserver, dns (named), samba and most of Linux services servers ip is 192.168.0.1
And network is 192.168.0.1/24 for dhcp ips are 192.168.0.10-60

(more…)

Horrid CPU Issues with VMWare and Hardware Interrupts

Thursday, October 2nd, 2008

Original Article

So I fought this problem all day long. My Windows XP VMWare image was running like crap. I started to poke around. The first thing I did was to bring up the task manager. Sure enough, my virtual CPU was pegged at around 55-60% when the vm was doing nothing. This is not good!

(more…)

Bash tips

Wednesday, August 20th, 2008

Originally from here.

(more…)

Exim Tips & Tricks - Unclog your queue!

Friday, August 15th, 2008

Original article here

This article will focus on some general Exim MTA tips and tricks as well as how to parse mail logs. I originally put this guide together for use with Exim on cPanel. Many cPanel server administrators use the built in Exim MTA without giving it a second thought because it works. It works until they end up providing virtual hosting systems (shared hosting) where some of the users do not update their scripts regularly or simply think setting a cron job that runs every minute and clogs the queue is a good idea. Then running the built in Exim MTA with no knowledge of how it works becomes a disaster! Learn Exim today and save your self some serious headaches!

Is your Exim queue piled up with thousands or even millions of emails? Are you getting complaints from your upstream provider because your servers are sending spam? Are your users complaining emails that they are expecting aren’t coming in or take hours or days to get there? Are your servers blacklisted on the major lists and you have no idea why? If any of these situations describe your problems then this guide should serve as a good primer for you to get the basic idea of how Exim works. You can use the knowledge here to solve all of these problems!

(more…)

Various Iptables Tricks

Friday, August 15th, 2008

> iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
> iptables -t nat -P PREROUTING DROP
> # Box 1
> iptables -t nat -A PREROUTING -m mac –mac-source 00:50:da:e3:f3:45 -j
> ACCEPT
> # Box 2
> iptables -t nat -A PREROUTING -m mac –mac-source 00:d0:b7:18:0f:f5 -j
> ACCEPT
>
> Now this works as expected, all packets from the two MAC addresses above are
> masq’ed and routed, anything from any other MAC address is DROP’ed.

mmh… but it is a bit unclean to drop packets in the nat table. You want
to filter packets, so use the filter table. Why? Because it is
- unclean
- only the first packet of each connection hits the nat table.

iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE

iptables -t filter -N restr
iptables -t filter -A restr -p tcp –dport 25 -j DROP

iptables -t filter -P FORWARD DROP
iptables -t filter -A FORWARD -m mac –mac-source 00:50:da:e3:f3:45 -j ACCEPT
iptables -t filter -A FORWARD -m mac –mac-source 00:d0:b7:18:0f:f5 -j restr

(more…)

check_nt Commands

Wednesday, July 30th, 2008

http://www.superk.org/index.php/Nagios_&_Windows

Performance Monitor:

Windows NT and better operating systems provided a tool for monitoring many aspects of the Windows operating system called Performance Monitor. Within Performance Monitor there is a wealth of monitoring functions available to track and graph. All of these monitoring functions are accessible through Nagios as well which makes Nagios a fantastic way of keeping track of all your Windows systems. The COUNTER variable in the check_nt command will let us connect to the Windows Performance Monitor and monitor a specific Performance Monitor function.

(more…)

Windows Server 2003 Baselining Linux Cacti

Wednesday, July 30th, 2008

Original Article HERE

When trying to diagnose problems with any system one of the first steps should be to looks at differences between the current running values and the baseline for that system. The windows performance monitor exposes many counters that are useful, and the output can be logged to various output formats like CSV, and even SQL databases.

(more…)

SNMP Stuff

Monday, July 28th, 2008
> Is there a MIB to get the ARP table of a router?  Should be one I would
> think but can't find it.

Yes, .iso.org.dod.internet.mgmt.mib-2.at.atTable.atEntry.atPhysAddress will
do what you want.

(more…)

Exim 4 CheatSheet

Monday, July 28th, 2008

Originally posted HERE

Message-IDs and spool files
The message-IDs that Exim uses to refer to messages in its queue are mixed-case alpha-numeric, and take the form of: XXXXXX-YYYYYY-ZZ. Most commands related to managing the queue and logging use these message-ids.

There are three — count ‘em, THREE — files for each message in the spool directory. If you’re dealing with these files by hand, instead of using the appropriate exim commands as detailed below, make sure you get them all, and don’t leave Exim with remnants of messages in the queue. I used to mess directly with these files when I first started running Exim machines, but thanks to the utilities described below, I haven’t needed to do that in many months.

(more…)