Author: sysop

OS X Tricks & Tips

1. Hold the Command key down to MOVE a file/folder to another disk (equals cut + paste)

2. Hold the Alt key down to move a COPY to another folder

3. Hold the Command and Alt keys down to draw an ALIAS (shortcut in windows)

4. Dragging with no extra keys activated will move the file if it’s within the same harddrive but make a copy if it’s dropped on another harddrive.

Hack to Remove/Uninstall Symantec Norton Antivirus (SAV) Client without Password

The client uninstallation password is different from the server group password, and it can be set by the administrator through the Symantec System Center for the client that is managed. If the client uninstallation password has not been set or changed specifically, it will still be the default password. Thus, first thing to try in order to successfully uninstall a Symantec Client Security program is by using the default password for the uninstalling clients, which is symantec.

In the cases where Symantec AntiVirus server has been taken down and no longer exist, or the client computer has no access to company network, or the default client uninstall password does not work, the following hack will enable you to remove Symantec Antivirus without using a password:

Open Registry Editor (regedit).

Navigate to the following registry key:

HKEY_LOCAL_MACHINE\SOFTWARE\INTEL\LANDesk\VirusProtect6\CurrentVersion\Administrator Only\Security

Change the value for useVPuninstallpassword key from 1 to 0.

Exit Registry Editor and now you can uninstall Symantec AntiVirus Client.

The trick should work on most version of Symantec AntiVirus client or Norton AntiVirus Client, including version 7, 8, 9 or 10.

AVG update crashes PC, how to restart Windows

One of the AVG updates has proven to be a problem for several PC setups recently. Hard to narrow this down at this stage but it seems more prevalent on Windows 7 64 bit setups.  Symptoms are PCs that will not boot after an AVG update, offering a Blue Screen Of Death (BSOD) on restart.
The problem is down to an AVG  system file that is loaded at boot time – most notably Windows\System32\Drivers\avgidseh.sys

The technical fix is to rename all files in the \Windows\System32\Drivers folder that begin with “avg” to something else. We do this by running off a boot CD/DVD/USB. Basically, any boot disk that allows file management access can do this.  Safe mode will not help here.

Example:

rename avgidseh.sys to pcrmbavgidseh.sys

rename avgldx86.sys to pcrmbldx86.sys     and so on

Once done, restart the PC and AVG will no longer start. Use the uninstall program to remove AVG and reinstall it. The new updates do not appear to be affected so it should work as normal.

AVG offer a rescue CD that can do this as it includes Midnight Commander as a file management tool.Download it from here

Quickly Find Local Open Ports

Usually, if you want to see all the used and listening ports on your computer, you’d use the NETSTAT command.

Note: The NETSTAT command will show you whatever ports are open or in use, but it is NOT a port scanning tool! If you want to have your computer scanned for open ports see this page instead (link will follow shortly).

Open Command Prompt and type:

C:'WINDOWS>netstat -an |find /i "listening"
TCP   0.0.0.0:135   0.0.0.0:0   LISTENING
TCP   0.0.0.0:445   0.0.0.0:0   LISTENING
TCP   0.0.0.0:1025   0.0.0.0:0   LISTENING
TCP   0.0.0.0:1084   0.0.0.0:0   LISTENING
TCP   0.0.0.0:2094   0.0.0.0:0   LISTENING
TCP   0.0.0.0:3389   0.0.0.0:0   LISTENING
TCP   0.0.0.0:5000   0.0.0.0:0   LISTENING

You can redirect it to a text file by adding >c:’openports.txt to the command, if you want to:

    netstat -an |find /i "listening" > c:'openports.txt

netstat -an |find /i “listening” > c:’openports.txt

You can also change “listening” to “established” to see what ports your computer actually communicates with:

    C:'WINDOWS>netstat -an |find /i "established"
    TCP   192.168.0.100:1084   192.168.0.200:1026   ESTABLISHED
    TCP   192.168.0.100:2094   192.168.0.200:1166   ESTABLISHED
    TCP   192.168.0.100:2305   209.211.250.3:80   ESTABLISHED
    TCP   192.168.0.100:2316   212.179.112.230:80   ESTABLISHED
    TCP   192.168.0.100:2340   209.211.250.3:110   ESTABLISHED

Note: In Windows XP and Windows Server 2003, you can type NETSTAT -O to get a list of all the owning process ID associated with each connection:

C:'WINDOWS>netstat -ao |find /i "listening"
TCP   pro1:epmap   pro1.dpetri.net:0   LISTENING   860
TCP   pro1:microsoft-ds   pro1.dpetri.net:0   LISTENING   4
TCP   pro1:1025   pro1.dpetri.net:0   LISTENING   908
TCP   pro1:1084   pro1.dpetri.net:0   LISTENING   596
TCP   pro1:2094   pro1.dpetri.net:0   LISTENING   596
TCP   pro1:3389   pro1.dpetri.net:0   LISTENING   908
TCP   pro1:5000   pro1.dpetri.net:0   LISTENING   1068

You can use PULIST from the W2K Resource Kit (Download Free Windows 2000 Resource Kit Tools) to find the PID and see what process uses it and who started it. For example, you found out that your computer had an open connection to a remote IP address on TCP port 80, and you don’t have any Internet Explorer or other browser windows open. You want to find out what process is using that session.

C:'WINDOWS>netstat -no

Active Connections

Proto Local Address Foreign Address State PID
TCP   192.168.0.100:2496   212.179.4.7:80   ESTABLISHED   1536

You can then use PULIST with the FIND command:

C:'WINDOWS>pulist |find /i "1536"

Process   PID   User
LUCOMS~1.EXE   1536   DPETRI'danielp

In this case, LUCOMS~1.EXE is run by DANIELP (myself) and as it happens, it’s the Symantec Live Update process.

You can also look in Task Manager for the respective PID.

  1. To set up Task Manager to show the PID column open Task Manager by using CTRL+SHIFT+ESC.
  2. Go to the Processes tab, click View and then Select Columns.

  1. In the Select Columns windows click to select PID and then click Ok.

  1. You can sort the PID column to display the PIDs in descending or ascending order.

 

Remote Shutdown – XP, Server 2003

From the command line, you can shut down or reboot any Windows Server 2003 computer (or even Windows XP or Vista machines) with the Shutdown.exe command. (Note: The exe file extension is optional for the Shutdown command.) Shutdown.exe contains a number of switches that allow you to specify different actions for the server when the Shutdown command executes. The Shutdown.exe switches are as follows:

/? Displays the Help listing
/i Displays the graphical user interface (GUI); it must be the first option
/l Logs off the current user; it cannot be used with the /d or /m options
/s Shuts down the computer
/r Shuts down and restarts the computer
/g Shuts down and restarts the computer and then restarts any registered applications
/a Aborts system Shutdown
/p Turns off the local computer with no timeout or warning
/h Hibernates the local machine
/e Documents the reason for shutting down the computer
/m Specifies the target computer; it is used with \\computername
/t xxx Where xxx is the number of seconds before Shutdown
/c “comment” Where “comment” is the reason for the Shutdown or restart
/f Forces running applications to close without warning users
/d [p|u:]xx:yy Provides the reason for the Shutdown action: p = planned; u= unplanned; xx supplies the major reason code; yy = supplies the minor reason code

When you enter a Shutdown with no arguments, the Help listing will display. The Help listing also includes the reason codes available for use with the /d switch. The reason codes are shown below:

Reasons on this computer:
E=Expected U=Unexpected P=Planned c=Customer Defined
Type Major Minor Title
U

0

0

Other(Unplanned)
E

0

0

Other(Unplanned)
EP

0

0

Other(Planned)
U

0

5

Other Failure: System Unresponsive
E

1

1

Hardware: Maintenance(Unplanned)
EP

1

1

Hardware: Maintenance(Planned)
E

1

2

Hardware: Installation(Unplanned)
EP

1

2

Hardware: Installation(Planned)
P

2

3

Operating System: Upgrade (Planned)
E

2

4

Operating System:
Reconfiguration (Unplanned)
EP

2

4

Operating System:
Reconfiguration(Planned)
P

2

16

Operating System:
Service Pack (Planned)
U

2

17

Operating System:
Hotfix (Unplanned)
P

2

17

Operating System:
Hotfix(Planned)
U

2

18

Operating System:
Security Fix(Unplanned)
P

2

18

Operating System:
Security Fix(Planned)
E

4

1

Application: Maintenance(Unplanned)
EP

4

1

Application: Maintenance(Planned)
EP

4

2

Application: Installation(Planned)
E

4

5

Application: Unresponsive
E

4

6

Application: Unstable
U

5

15

System Failure: Stop Error
E

5

19

Security Issue
U

5

19

Security Issue
EP

5

19

Security Issue
E

5

20

Loss of Network Connectivity
(Unplanned)
U

6

11

Power Failure: Cord Unplugged
U

6

12

Power Failure: Environment
P

7

0

Legacy API Shutdown

You can use many of these switches in conjunction with one another when issuing the Shutdown command. A usage example for the Shutdown command follows:

Shutdown /r /c “Hanging Application or service” /t 30

This example would restart the local machine storing the comment provided with the /c switch. Windows would wait 30 seconds before initiating the restart. You might also create a batch file to use when it is necessary to restart a server in a remote location. The batch file might look like this:

Shutdown /m \\computername /r /c “Remote Restart” /t 45

By saving this command in a batch file, it can save you time if you routinely restart the same remote server.

Cisco Router Commands Cheat Sheet

TERMINAL CONTROLS:

  • Config# terminal editing – allows for enhanced editing commands
  • Config# terminal monitor – shows output on telnet session
  • Config# terminal ip netmask-format hexadecimal|bit-count|decimal – changes the format of subnet masks

    HOST NAME:

  • Config# hostname ROUTER_NAME

    BANNER:

  • Config# banner motd # TYPE MESSAGE HERE # – # can be substituted for any character, must start and finish the message

    DESCRIPTIONS:

  • Config# description THIS IS THE SOUTH ROUTER – can be entered at the Config-if level

    CLOCK:

  • Config# clock timezone Central -6
    # clock set hh:mm:ss dd month yyyy – Example: clock set 14:35:00 25 August 2003

    CHANGING THE REGISTER:

  • Config# config-register 0x2100 – ROM Monitor Mode
  • Config# config-register 0x2101 – ROM boot
  • Config# config-register 0x2102 – Boot from NVRAM

    BOOT SYSTEM:

  • Config# boot system tftp FILENAME SERVER_IP – Example: boot system tftp 2600_ios.bin 192.168.14.2
  • Config# boot system ROM
  • Config# boot system flash – Then – Config# reload

    CDP:

  • Config# cdp run – Turns CDP on
  • Config# cdp holdtime 180 – Sets the time that a device remains. Default is 180
  • Config# cdp timer 30 – Sets the update timer.The default is 60
  • Config# int Ethernet 0
  • Config-if# cdp enable – Enables cdp on the interface
  • Config-if# no cdp enable – Disables CDP on the interface
  • Config# no cdp run – Turns CDP off

    HOST TABLE:

  • Config# ip host ROUTER_NAME INT_Address – Example: ip host lab-a 192.168.5.1
    -or-
  • Config# ip host RTR_NAME INT_ADD1 INT_ADD2 INT_ADD3 – Example: ip host lab-a 192.168.5.1 205.23.4.2 199.2.3.2 – (for e0, s0, s1)

    DOMAIN NAME SERVICES:

  • Config# ip domain-lookup – Tell router to lookup domain names
  • Config# ip name-server 122.22.2.2 – Location of DNS server
  • Config# ip domain-name cisco.com – Domain to append to end of names

    CLEARING COUNTERS:

  • # clear interface Ethernet 0 – Clears counters on the specified interface
  • # clear counters – Clears all interface counters
  • # clear cdp counters – Clears CDP counters

 

Steps to move a DHCP database from a Windows Server 2003 or 2008 to another Windows Server 2008 machine

The DHCP database can be moved or migrated from a Windows Server 2003 server to a Windows Server 2008 server, or from one Windows Server 2008 server to another.  The information below details the necessary steps.

Export the DHCP database from a server that is running Microsoft Windows Server 2003 or Windows Server 2008

To move a DHCP database and configuration from a server that is running Windows Server 2003 or Windows Server 2008 to another server that is running Windows Server 2008:

1.   Log on to the source DHCP server by using an account that is a member of the local Administrators group.

2.   Click Start, click Run, type cmd in the Open box, and then click OK.

3.   Type netsh dhcp server export C:\dhcp.txt all , and then press ENTER.

Note: You must have local administrator permissions to export the data.

Configure the DHCP server service on the server that is running Windows Server 2008

1.   Click Start, click Administrative Tools, click Server Manager. If needed acknowledge User Account Control.

2.   In Roles Summary click Add Roles, click Next, check DHCP server, and then click Next.

Import the DHCP database

1.   Log on as a user who is an explicit member of the local Administrators group. A user account in a group that is a member of the local Administrators group will not work. If a local Administrators account does not exist for the domain controller, restart the computer in Directory Services Restore Mode, and use the administrator account to import the database as described later in this section.

2.   Copy the exported DHCP database file to the local hard disk of the Windows Server 2008-based computer.

3.   Verify that the DHCP service is started on the Windows Server 2008-based computer.

4.   Click Start, click Run, type cmd in the Open box, and then click OK.

5.   At the command prompt, type netsh dhcp server import c:\dhcpdatabase.txt all , and then press ENTER, where c:\dhcpdatabase.txt is the full path and file name of the database file that you copied to the server.

Note When you try to export a DHCP database from a Windows 2000/2003 domain controller to a Windows Server 2008 member server of the domain, you may receive the following error message:

Error initializing and reading the service configuration – Access Denied

Note You must have local administrator permissions to import the data.

6.   To resolve this issue, add the Windows Server 2008 DHCP server computer to the DHCP Admins group at the Enterprise level and redo steps 4 & 5.

7.   If the “access is denied” error message occurs after you add the Windows Server 2008 DCHP server computer to the DHCP Admins group at the Enterprise level that is mentioned in step 6, verify that the user account that is currently used to import belongs to the local Administrators group. If the account does not belong to this group, add the account to that group, or log on as a local administrator to complete the import and redo steps 4 & 5.

Authorize the DHCP server

1.   Click Start, point to All Programs, point to Administrative Tools, and then click DHCP.

Note You must be logged on to the server by using an account that is a member of the Administrators group. In an Active Directory domain, you must be logged on to the server by using an account that is a member of the Enterprise Administrators group.

2.   In the console tree of the DHCP snap-in, expand the new DHCP server. If there is a red arrow in the lower-right corner of the server object, the server has not yet been authorized.

3.   Right-click the server object, and then click Authorize.

4.   After several moments, right-click the server again, and then click Refresh. A green arrow indicates that the DHCP server is authorized.

 

Mac OS X voices for using with the ‘say’ command

A neat trick if you have a Mac OS X machine is to do this (make sure your speakers are turned on):

  1. Open Terminal.app
  2. Type in at the command line: say hello world

This will make your computer say “hello world” in the default voice (Victoria).

Here is a list of the other voices you can also use:

Female Voices

  • $ say -v Agnes "hello world"
  • $ say -v Kathy "hello world"
  • $ say -v Princess "hello world"
  • $ say -v Vicki "hello world"
  • $ say -v Victoria "hello world"

Male Voices

  • $ say -v Bruce "hello world"
  • $ say -v Fred "hello world"
  • $ say -v Junior "hello world"
  • $ say -v Ralph "hello world"

Novelty Voices

  • $ say -v Albert "hello world"
  • $ say -v "Bad News" "hello world"
  • $ say -v Bahh "hello world"
  • $ say -v Bells "hello world"
  • $ say -v Boing "hello world"
  • $ say -v Bubbles "hello world"
  • $ say -v Cellos "hello world"
  • $ say -v Deranged "hello world"
  • $ say -v "Good News" "hello world"
  • $ say -v Hysterical "hello world"
  • $ say -v "Pipe Organ" "hello world"
  • $ say -v Trinoids "hello world"
  • $ say -v Whisper "hello world"
  • $ say -v Zarvox "hello world"

IE is a pain

Have you ever been browsing the Internet using IE happily until all of a sudden you get this horrid “Internet Explorer has encountered a problem and needs to close”error message, after which IE completely shuts down and you lose all of your tabs along with any forms you might have been filling out? Now that I use Firefox religiously, this has not happened to be even once, but it happened all the time with Internet Explorer.

So for those poor souls still using IE 6 or 7, here’s a quick list of steps you can take to try and fix the underlying problem. The cause of this error can be any number of things, so you may have to try a few things before it actually fixes the problem. Your error may look something like this:

Error sign
AppName: iexplore.exe AppVer. 7.0.5730.11 ModName: unknown
ModVer: 0.0.0.0 Offset: 61eb77e0

internet explorer

So what the heck to do if you get this error? Try each one of these steps and see if the problem goes away:

  • Open IE, go to ToolsInternet Options, and clear out the temporary Internet files. Click Delete All and choose the option to delete all offline content also. In case you downloaded some executable file that is causing the problem, this will remove it.
  • Run anti-spyware and anti-virus software on the computer. Download Adware andSpybot and run each to remove any malware. Also, download CCleaner andHiJackThis and run both applications. Remove unwanted entries that you see when you run HiJackThis (you’ll have to read the docs to know what to remove).
  • Go to StartRun and then type in MSCONFIG. Click on the Startup tab and uncheck all items and then re-start the computer. This disables all startup programs from running. If you still get the error, go ahead and turn them back on the same way.
  • Disable Smarts Tags in Internet Explorer by going to ToolsInternet Options,Advanced tab, and then clearing the Enable Smart Tags check box.
  • Install the latest updates from Microsoft Update web site. If you started receiving this error AFTER installing the latest updates, you will have to perform a System Restore to the point before you installed the updates. You can access the System Restore feature by going to StartAll ProgramsAccessories, and then System Tools.
  • Use System File Checker to scan for changes or modifications to Windows protected files. If any files were overwritten or deleted, etc, SFC will automatically retrieve the correct version of the file and replace it. You can run SFC by going to Start, and then Run, typing in CMD and then typing sfc /scannow in the command window.
  • Re-register Internet Explorer DLL files. Click on Start, then Run, type in CMD and then type the following lines and press Enter after each one:
  • regsvr32 softpub.dll
    regsvr32 wintrust.dll
    regsvr32 initpki.dll
    regsvr32 dssenh.dll
    regsvr32 rsaenh.dll
    regsvr32 gpkcsp.dll
    regsvr32 sccbase.dll
    regsvr32 slbcsp.dll
    regsvr32 cryptdlg.dll

  • Disable all third party addons to Internet Explorer by going to StartControl Panel,Internet OptionsAdvanced tab and then un-checking the “Enable third party browser extensions” check box. You will have to scroll down a couple of lines.

MRTG

First, download and install MRTG:

sudo apt-get install mrtg

If this is the first time installing MRTG on your server you’ll likely be presented with the following message. Answering “Yes” means that the default configuration file will be installed with permissions set at 640. Answering “No” means that the permissions are set at 644. In this example we’re going to accept the default Yes. No worries though, if you select No the steps in this tutorial will still work.

MRTG Message Concerning File Permissions

MRTG installs a sample configuration file /etc/mrtg.cfg. This file will eventually hold the information obtained from your gateway\router. For a full listing of what MRTG installs and where, run the locate command:

sudo updatedb && locate mrtg

Technically speaking, mrtg.cfg could remain in /etc, but just to keep things tidy and to help facilitate the startup script that will be discussed later, let’s create a directory for it and move it into that directory:

sudo mkdir /etc/mrtg && sudo mv /etc/mrtg.cfg /etc/mrtg

That’s it for installing MRTG. Now let’s move on and configure it.

Configure

MRTG includes a script called cfgmaker that will help us populate mrtg.cfg with the information obtained from your gateway/router. But before you run cfgmaker, you should setup the SNMP community. This usually involves logging into your gateway/router and enabling SNMP. The default community will typically be “public.” If you change the default community to another name though, make note of it. Now, run the following command, substituting the SNMP community name, if you’ve changed it, and adding the IP address of your gateway/router:

sudo cfgmaker --output=/etc/mrtg/mrtg.cfg public@your-router's-IP-address

Next, open mrtg.cfg in a text editor and make sure under Global Configiration Options that the line “WorkDir: /var/www/mrtg” (under Debian) is uncommented, and under Global Defaults the line “Options[_]: growright, bits” is uncommented. Finally, add the following lines under the Global Defaults section:

RunAsDaemon: Yes
Interval: 5
Logdir: /var/log/
EnableIPv6: no

What does all this do? RunAsDaemon will enable MRTG to…um… run as a daemon. This is beneficial because MRTG is launched only once, thus the parsing of mrtg.cfg file is done only once, not repeatedly as would be the case if one were to run MRTG as a cron task – another acceptable method for running MRTG. Also, when running as a daemon, MRTG itself is responsible for timing the measurement intervals; therefore, we need to add the Interval option and assign it a value – in this case 5 (minutes). This means that every five minutes MRTG will update its graphs. We’ve given MRTG a directory to place its log file, and finally, because many routers do not currently support SNMP over IPv6, we’ve shut that off.

Speaking of graphs, by default MRTG graphs grow to the left, so by adding the option “growright” the direction of the traffic visible in MRTG’s graphs flips causing the current time to be at the right edge of the graph and the history values to the left. We’ve also chosen the “bits” option, which means that the monitored traffic values obtained from your gateway/router are multiplied by 8 and displayed bits per second instead of bytes per second.

Okay, now it’s time to create the web pages which display the MRTG graphs. Run the following commands:

sudo mkdir /var/www/mrtg
sudo indexmaker --output=/var/www/mrtg/index.html /etc/mrtg/mrtg.cfg

MRTG has been configured. Let’s start it up and see what it displays.

Start

There’s something important to keep in mind when starting MRTG, and that is that MRTG requires the environmental variable “LANG” to be C in order to run properly. Since most Linux systems these days, including Ubuntu server, use UTF-8 (run echo $LANG to see what your system uses), let’s change LANG to C and start MRTG using the following command:

sudo env LANG=C /usr/bin/mrtg /etc/mrtg/mrtg.cfg

When you run MRTG for the first time you may see a lot of complaints about missing log files. No worries, this is normal for the first 2-3 times you start MRTG this way. If, however, it continues to complain you may want to look into the source of the problem.

Well, that’s it. Now point your browser to http://your-server-address/mrtg and you should see a page that resembles the following. You may have more or less graphs depending on the number interfaces reported by your gateway/router.

Screenshot of default MRTG index page

Because of the aforementioned options added to mrtg.cfg, you’ll see the graph starting “grow” to the right as the traffic is monitored over time, and the Y axis displayed as bits per second. If you click on any one of these graphs you’ll be taken to another page showing individual graphs for daily, weekly, monthly, and yearly traffic averages, along with the maximum, average, and current bit rate in and out of that particular interface. Only interested in displaying one particular interface? Don’t like the look of the page? No worries, just edit /etc/mrtg/mrtg.cfg and/or /var/www/mrtg/index.html until you get it looking the way you want.

Okay, so now that we have MRTG installed, configured and running let’s move on and discuss how to keep it running.

Operate

Starting MRTG by hand is not ideal in the long run. So perhaps after you’ve done some tweaking on MRTG and are satisfied with the results, you can automate the process of running MRTG by using a startup script in your system startup sequence. Here’s the script that I use:

[bash]</div>
<div>

#! /bin/sh
### BEGIN INIT INFO
# Provides: mrtg
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: mrtg init script
# Description: This file is used to start, stop, restart,
# and determined status of the mrtg daemon.
# Author: iceflatline <iceflatline@gmail.com>
### END INIT INFO

### START OF SCRIPT
set -e
# PATH should only include /usr/* if it runs after the mountnfs.sh script
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC="mrtg"
NAME=mrtg
DAEMON=/usr/bin/$NAME
DAEMON_ARGS="/etc/mrtg/mrtg.cfg"
PIDFILE=/etc/mrtg/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Exit if the mrtg package is not installed
[ -x "$DAEMON" ] || exit 0

# Load the VERBOSE setting and other rcS variables
. /lib/init/vars.sh

# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions

# Function that starts the mrtg daemon
start()
{
env LANG=C start-stop-daemon –start –quiet \
–exec $DAEMON — $DAEMON_ARGS
}

# Function that stops the mrtg daemon
stop()
{
start-stop-daemon –stop –quiet –retry=TERM/30/KILL/5 \
–pidfile $PIDFILE
}

case "$1" in
start)
log_daemon_msg "Starting $DESC"
start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;;
esac
;;
stop)
log_daemon_msg "Stopping $DESC"
stop
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;;
esac
;;
restart|force-reload)
log_daemon_msg "Restarting $DESC"
stop
case "$?" in
0|1)
start
case "$?" in
0) log_end_msg 0 ;;
1) log_end_msg 1 ;;
esac
;;
esac
;;
status)
status_of_proc "$DAEMON" "$NAME"
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}"
;;
esac
exit 0
### END OF SCRIPT

</div>
<div>[/bash]

To use the script, save it to your home directory as mrtg and make it executable. Then move or copy it to /etc/init.d:
cd ~
chmod +x mrtg
sudo mv mrtg /etc/init.d/

Now, link the mrtg script to all of Ubuntu server’s multi-user run levels (2-5):

sudo update-rc.d mrtg defaults

Now, let’s start MRTG using our script. If it’s currently running then substitute restart for start in the following command:

sudo /etc/init.d/mrtg start

That’s it. Now if for some reason your server is rebooted, MRTG should fire up automatically (to remove the link from the server’s multi-user run levels, use the command sudo update-rc.d -f mrtg remove).

Conclusion

This concludes the post on how to install and configure MRTG on Ubuntu server. As you can see, MRTG isn’t terribly complicated and proves to be a really nice open source package for monitoring and displaying traffic in and out your home network from virtually anywhere you have a web browser. For a full list of all the configuration options and other information I encourage you to visit the MRTG web site.