Wednesday, 17 February 2010

ERROR: Creating templock /var/lock/mrtg/.....: No such file or directory [How to Fix]

I have been running MRTG on Ubuntu server 8.10, and recently it stopped running for no obvious reason. Examining the MRTG log, I found many lines like this:

ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5012: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5020: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5041: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5046: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5074: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5100: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5112: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5121: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5129: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5148: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5173: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_5905: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6004: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6023: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6049: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6065: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6092: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6191: No such file or directory at /usr/bin/mrtg line 1645.
ERROR: Creating templock /var/lock/mrtg/_etc_mrtg.cfg_l_6247: No such file or directory at /usr/bin/mrtg line 1645.


Turns out there is a bug with running MRTG on Ubuntu/Debian which removes the MRTG lock file on every reboot. To fix this, create a new text file (as root) in /etc/rcS.d/ called "S91mrtg-lock-dir.sh" and paste the following code into it:

#!/bin/sh
# Create the lock directory for MRTG
# This is needed due to a bug for Ubuntu/Debian which erases this directory at shutdown
echo "Creating MRTG lock directory...."
mkdir -m 0755 /var/lock/mrtg


This will create a new /var/lock/mrtg directory every time the computer starts up. You may need to reboot to enable this, or simply run the command mkdir -m 0755 /var/lock/mrtg.

More information:
http://www.enterprisenetworkingplanet.com/netos/article.php/3663941
http://ubuntuforums.org/showthread.php?t=249393
http://www.directadmin.com/forum/showthread.php?t=7843&page=3
http://www.google.com/search?hl=en&q=ERROR%3A+Creating+templock%3A+No+such+file+or+directory&aq=f&aqi=&oq=

1 comment:

Blogger said...

Are you making money from your exclusive file uploads?
Did you know that AdWorkMedia will pay you an average of $0.50 per link unlock?