Snmpd filling up /var/log/messages

At work we have a central monitoring system for servers called Cacti, this uses standard snmp connections to servers to get their status, disk usage, CPU performance.
On my CentOS linux servers the standard snmpd daemon works well with Solarwinds but the monitoring server seems to make a lot of connections to the system and each one gets logged via the syslog daemon to /var/log/messages giving rise to lots of lines saying things like
snmpd[345435]: Connection from UDP: [10.225.46.136]:135                
last message repeated 8 times
last message repeated 13 times
These are only information messages saying a connection has been established. This is rather annoying when you are trying to read other things in /var/log/messages. The way to turn off these messages is to change the logging options of the snmpd daemons.
On Redhat ( and Ubuntu) the default logging ( the -L options ) show:–
-Ls d
Meaning log to syslog using the facility of daemon ( see syslogd and syslog.conf for more information on what that means in detail, for now suffice it to say it means all messages are written to /var/log/messages ).
The man pages for snmpcmd ( common to all net-snmp programmes ) explain you can set this to only log messages above a certain priority.
Using priorities 0-4 means warning messages, errors, alerts and critical etc messages are logged but notice info and debug level messages are ignored.
The manual pages are not that clear, to me at least at first, hence this blog.
So if we change the -Ls d to the following this will stop those messages but still allow important messages to get through:–
LS 0-4 d
The capital S is crucial to the syntax.
So where and how do we set these options? Well the snmpd daemon is started by a standard init script /etc/init.d/snmpd
In both RHEL5 and Ubuntu the scripts have some default options but also read in settings from a config file. In Ubuntu the relevant portion of the script is:-
SNMPDOPTS=’-Lsd -Lf /dev/null -p /var/run/snmpd.pid’
TRAPDRUN=no
TRAPDOPTS=’-Lsd -p /var/run/snmptrapd.pid’
#Reads config file (will override defaults above)
[ -r /etc/default/snmpd] && . /etc/default/snmpd
So this sets the variable SNMPDOPTS to the default value and then if the file /etc/default/snmpd is readable it “sources” the content of that file.
Thus if /etc/default/snmpd contains the line
SNMPDOPTS='-LS 0-4 d -Lf /dev/null -p /var/run/snmpd.pid'
Then stopping and starting the snmpd daemon will make it run with the new logging options we want.
sudo /etc/init.d/snmpd restart
In RHEL5 the equivalent file is /etc/snmp/snmpd.options and the equivalent variable is OPTIONS rather than SNMPDOPTS
Now there could be security implications to not recording the IP address of every SNMP request on your server in case some other system is connecting that shouldn’t be, but there are ways with community strings and other authentication options for SNMP to reduce the risk of that.
All in all the I think the risk of missing an important message in /var/log/messages outweighs the risks from not logging the snmpd messages.
Continue reading Snmpd filling up /var/log/messages

shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Hey Guys,

If you facing issue " shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory " for restarting service whaterver mysql,httpd,etc,

just do "cd or cd / " on console

it will resolved.

[root@domU-taging]# /etc/init.d/mysqld restart
shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

[root@domU-taging]# cd

[root@domU- ~]# /etc/init.d/mysqld restart
Stopping MySQL: [ OK ]
Starting MySQL: [ OK ]

cool.;)
Continue reading shell-init: error retrieving current directory: getcwd: cannot access parent directories: No such file or directory

Using Mutt to send email

Mutt is a popular email client (MUA) which is common on Linux systems.
Given below are some how-tos on basic uses of mutt. For all UNIX utilities, the "man pages" are your best bet to learn them. I’ve just documented some popular uses of mutt. Refer the "man pages" for a more comprehensive understanding of mutt. The commands below have been tested on Red Hat Enterprise Linux 4.0 AS Update 7 with mutt v1.4.1i, unless otherwise stated.
HOW-TO 1: Send email with blank/empty body
mutt -s "Test email" testmail@abc.com < /dev/null
#
# where:
# -s => Subject
# testmail@abc.com => recipient's email address
#
HOW-TO 2: Send email with body read from a file
mutt -s "Test email" testmail@abc.com < email_body.txt
#
# where:
# -s => Subject
# testmail@abc.com => recipient's email address
# email_body.txt => file containing message body
#
HOW-TO 3: Send email with a customized sender name and email address
# The .muttrc file is Mutt's configuration file. It's default location is the $HOME directory.
# If you locate it elsewhere, specify its location with the '-F' flag.
# Add the following to the .muttrc file:
set realname="Joe Bloggs"
set from="noreply@jb.com"
set use_from=yes
#
# where:
# realname => Sender's name as it appears in the recipient's mail inbox.
# from => the "reply-to" address
# 
After configuring .muttrc, send emails as per how-tos 1 and 2.
HOW-TO 4: Send attachment(s)
mutt -s "Test email" -a file1 -a file2 testmail@abc.com < /dev/null
#
# where:
# -s => Subject
# testmail@abc.com => recipient's email address
# file1 => first attachment
# file2 => second attachment
#
HOW-TO 5: Send HTML email
I know that the technical purists out there abhor HTML emails due to potential issues with accessibility and security, but hey, there’s no denying the fact that HTML-formatted emails are far more interesting to look at than plain-text email and are better at drawing your attention to specific information (ask the marketing guys and senior executives!). HTML-formatted emails are supported by Mutt versions 1.5 and higher. Here’s how you may send an HTML-formatted email using mutt v1.5.21:
mutt -e "set content_type=text/html" -s "Test email" testmail@abc.com < welcome.html
#
# where:
# -s => Subject
# testmail@abc.com => recipient's email address
# -e => command to execute
# content_type => email body MIME type
#
The MIME type multipart/alternative ensures your emails are received properly by both plain-text and HTML clients, but it does not work well with mutt at present.
Continue reading Using Mutt to send email
,

MySQL Table is marked as crashed and last (automatic?) repair failed

If you have a table in mysql that has crashed and your attempts to repair it using mysqlcheck have failed, then you may have to resort to the lower level myisamchk command.

To use this, you will need to stop the server process (usually service mysqld stop or /etc/init.d/mysqld stop) and then find the data files (usually in /var/lib/mysql/databasename).

You can then run the following command against the table:

myisamchk -r -v -f --sort_buffer_size=128M --key_buffer_size=128M /var/lib/mysql/database/table.MYI

Obviously replacing database/table with the correct database and table.





Continue reading MySQL Table is marked as crashed and last (automatic?) repair failed

CentOS: Install Yum


1. Login to your container/VPS via ssh as the root user.
2. Determine which version of CentOS you are running.
cat /etc/redhat-release

The output will be either:
CentOS release 6.2 (Final)
or:
CentOS release 5.7 (Final)
or:
CentOS release 5.6 (Final)
or:
CentOS release 5.5 (Final)


3. Paste the commands for your CentOS version to your command line.

CentOS 6.2:
rpm -Uvh --nodeps http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/yum-metadata-parser-1.1.2-16.el6.$(uname -i).rpm http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/yum-plugin-fastestmirror-1.1.30-10.el6.noarch.rpm

rpm -Uvh http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/gpgme-1.1.8-3.el6.$(uname -i).rpm http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/pygpgme-0.1-18.20090824bzr68.el6.$(uname -i).rpm http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/python-iniparse-0.3.1-2.1.el6.noarch.rpm http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/python-urlgrabber-3.9.1-8.el6.noarch.rpm http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/python-pycurl-7.19.0-8.el6.$(uname -i).rpm http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/rpm-python-4.8.0-19.el6.$(uname -i).rpm http://mirror.ihug.co.nz/centos/6/os/$(uname -i)/Packages/yum-3.2.29-22.el6.centos.noarch.rpm

CentOS 5.7:
rpm -Uvh --nodeps http://vault.centos.org/5.7/os/$(uname -i)/CentOS/yum-fastestmirror-1.1.16-16.el5.centos.noarch.rpm http://vault.centos.org/5.7/os/$(uname -i)/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.$(uname -i).rpm

rpm -Uvh http://vault.centos.org/5.7/os/$(uname -i)/CentOS/libxml2-2.6.26-2.1.12.$(uname -i).rpm http://vault.centos.org/5.7/os/$(uname -i)/CentOS/m2crypto-0.16-8.el5.$(uname -i).rpm http://vault.centos.org/5.7/os/$(uname -i)/CentOS/python-elementtree-1.2.6-5.$(uname -i).rpm http://vault.centos.org/5.7/os/$(uname -i)/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm http://vault.centos.org/5.7/os/$(uname -i)/CentOS/python-sqlite-1.1.7-1.2.1.$(uname -i).rpm http://vault.centos.org/5.7/os/$(uname -i)/CentOS/python-urlgrabber-3.1.0-6.el5.noarch.rpm http://vault.centos.org/5.7/updates/$(uname -i)/RPMS/rpm-python-4.4.2.3-22.el5_7.2.$(uname -i).rpm http://vault.centos.org/5.7/os/$(uname -i)/CentOS/yum-3.2.22-37.el5.centos.noarch.rpm

CentOS 5.6:
rpm -Uvh --nodeps http://vault.centos.org/5.6/os/$(uname -i)/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm http://vault.centos.org/5.6/os/$(uname -i)/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.$(uname -i).rpm

rpm -Uvh http://vault.centos.org/5.6/os/$(uname -i)/CentOS/libxml2-2.6.26-2.1.2.8.el5_5.1.$(uname -i).rpm http://vault.centos.org/5.6/os/$(uname -i)/CentOS/python-elementtree-1.2.6-5.$(uname -i).rpm http://vault.centos.org/5.6/os/$(uname -i)/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm http://vault.centos.org/5.6/os/$(uname -i)/CentOS/python-sqlite-1.1.7-1.2.1.$(uname -i).rpm http://vault.centos.org/5.6/os/$(uname -i)/CentOS/rpm-python-4.4.2.3-22.el5.$(uname -i).rpm http://vault.centos.org/5.6/os/$(uname -i)/CentOS/m2crypto-0.16-6.el5.8.$(uname -i).rpm http://vault.centos.org/5.6/os/$(uname -i)/CentOS/python-urlgrabber-3.1.0-6.el5.noarch.rpm http://vault.centos.org/5.6/os/$(uname -i)/CentOS/yum-3.2.22-33.el5.centos.noarch.rpm

CentOS 5.5:
rpm -Uvh --nodeps http://vault.centos.org/5.5/os/$(uname -i)/CentOS/yum-fastestmirror-1.1.16-14.el5.centos.1.noarch.rpm http://vault.centos.org/5.5/os/$(uname -i)/CentOS/yum-metadata-parser-1.1.2-3.el5.centos.$(uname -i).rpm

rpm -Uvh http://vault.centos.org/5.5/updates/$(uname -i)/RPMS/libxml2-2.6.26-2.1.2.8.el5_5.1.$(uname -i).rpm http://vault.centos.org/5.5/os/$(uname -i)/CentOS/m2crypto-0.16-6.el5.6.$(uname -i).rpm http://vault.centos.org/5.5/os/$(uname -i)/CentOS/python-elementtree-1.2.6-5.$(uname -i).rpm http://vault.centos.org/5.5/os/$(uname -i)/CentOS/python-iniparse-0.2.3-4.el5.noarch.rpm http://vault.centos.org/5.5/os/$(uname -i)/CentOS/python-sqlite-1.1.7-1.2.1.$(uname -i).rpm http://vault.centos.org/5.5/os/$(uname -i)/CentOS/python-urlgrabber-3.1.0-5.el5.noarch.rpm http://vault.centos.org/5.5/updates/$(uname -i)/RPMS/rpm-python-4.4.2.3-20.el5_5.1.$(uname -i).rpm http://vault.centos.org/5.5/os/$(uname -i)/CentOS/yum-3.2.22-26.el5.centos.noarch.rpm


Continue reading CentOS: Install Yum

VOS3000 Installation Manual

How to install VOS3000 soft switch.

1- Install CentOS 5.5 or latest.
2- Choose minimum installation
3- Choose Server mode only don’t install KDE or GNOME.
4- Run the following command
   #yum update       (to update the CentOS)

5- Better to install webmin to manage CentOS remotely.

     # cd  /var
  # wget http://prdownloads.sourceforge.net/webadmin/webmin-1.530-1.noarch.rpm

  # rpm  -ivh  webmin-1.530-1.noarch.rpm 

After the installation open your browser and try to login i to webmin
 http://youripaddress:10000

Login  with root .  and update the webmin and update the operating systems .

6-  Disable the SELINUX mode
    # vi  /etc/sysconfig/selinux
    ---------------------------------------------------------------------------------------------------
          # This file controls the state of SELinux on the system.
    # SELINUX= can take one of these three values:
    # enforcing - SELinux security policy is enforced.
    # permissive - SELinux prints warnings instead of enforcing.
    # disabled - SELinux is fully disabled.
    SELINUX=disabled    # SELINUXTYPE= type of policy in use. Possible values are:
    # targeted - Only targeted network daemons are protected.
    # strict - Full SELinux protection.
    SELINUXTYPE=targeted

    # SETLOCALDEFS= Check local definition changes
    SETLOCALDEFS=0

------------------------------------------------------------------------------------------------

Save the file and exit

7   Check the iptables status of IPv4 and IPv6 to install VOS 3000 successfully disables the firewall

 Follow the below command   
#   /etc/init.d/iptables status
     This command will show IPtables is running or stop

#   /etc/init.d/iptables save
     This command will save the iptables (firewall rules)

#  /etc/init.d/iptables stop
   This command will stop the IPtables 

#   chkconfig iptables off
    This Command will disable the iptables services  

#  /etc/init.d/ip6tables status
  This command willl show IPtables is running or stop

#  /etc/init.d/ip6tables save
This command will save the iptables (firewall rules)

#  /etc/init.d/ip6tables stop
  This command will stop the IPtables 

#  chkconfig ip6tables off
This Command will disable the iptables services 

#  ca /etc/issue
# cat /etc/issue


Reboot the server and check the IPtables is off.
#  reboot

8-Install the dependency software’s for VOS 3000
                # cd /usr
      # tar xvf apache-tomcat-5.5.15.tar.gz
      # rpm -ivh perl-DBI-1.40-5.i386.rpm
      # rpm -ivh MySQL-server-community-5.0.51a-0.rhel4.i386.rpm
      # rpm -ivh MySQL-client-community-5.0.51a-0.rhel4.i386.rpm
      # rpm -ivh jdk-1_5_0_08-linux-i586.rpm
      # rpm -ivh emp-2.1.1-5.noarch.rpm



# rpm -ivh mbx3000-2.1.1-5.i586.rpm
      # rpm -ivh vos3000-2.1.1-5.i586.rpm
      # rpm -ivh ivr-2.1.1-5.i586.rpm
           Restart the VOS3000d Services
#  /etc/init.d/vos3000d restart
      # /etc/init.d/vos3000dall restart
      Restart the MySQL services
#  service mysql restart
Reboot the Server
Now VOS3000 Installation has done  
Procedure of License Installation of VOS3000
VOS3000 License require the Server IP address and MAC address
To get the IP address and MAC Address follow below

      #  ifconfig
      Link encap:Ethernet  HWaddr 00:0C:29:27:03:FD
inet addr:10.31.7.13  Bcast:10.31.7.255  Mask:255.255.255.0
  
Create a directory for VOS3000 License
      # cd /usr/kunshi
      # mkdir license
      # cd license
Copy the License  file here and make it executable
      # chmod 755 license.dat
      Now restart the MySQL Services
      # /etc/init.d/mysql restart
            Restart the VOS3000 Services
      # /etc/init.d/vos3000d
      # /etc/init.d/vos3000d  restart
      # /etc/init.d/vos3000dall  restart
      # /etc/init.d/mbx3000d restart
Now change the MySQL root Password
      # usr/bin/mysqladmin -u root password vos3000
Continue reading VOS3000 Installation Manual