LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   problem with snmp and centos 6 (http://www.linuxquestions.org/questions/linux-server-73/problem-with-snmp-and-centos-6-a-913878/)

creatureofthedark 11-16-2011 11:58 AM

problem with snmp and centos 6
 
hi I'm a 3rd year computing student and I'm currently working on my 3rd year project.

at the moment I'm stuck with what I thought would be a fairly simple task... setting up SNMP...

so far iv managed to get snmpd running on a web-server and snmptrapd working on the monitoring server. [both are running centos 6 and for testing iv took down iptables]


on the server i have the following config.

Code:

/etc/snmp/snmptrapd.conf

# Example configuration file for snmptrapd
#
# No traps are handled by default, you must edit this file!
#
authCommunity  log,execute,net public
traphandle default python /root/project/snmptest.py
# traphandle SNMPv2-MIB::coldStart    /usr/bin/bin/my_great_script cold

the above calls a python script when ever it receives an snmp trap. this python script then simply dumps the trap into a text file [this will be expanded upon when I get the web-server sending traps...

Code:

ef main():
        running = True
        output = open('/tmp/traps', 'a')

        while running:
                try:
                        input = raw_input()
                        output.write(input + "\n")
                except EOFError:
                        running = False


        output.close()

if __name__ == '__main__':
        main()

this system has been tested and works well. it receives traps from my pfsence router fine...

please note that the above i got from this video http://www.youtube.com/watch?v=S0ibDVFnUws


on the webserver i have simply set

Code:

/etc/snmp/snmpd.conf

rocommunity  public
syslocation  "north"
syscontact  [my-email]

this config came from this link...
http://www.it-slav.net/blogs/2008/11...hel-or-centos/


this allows me use snmpwalk and I get all the oids... but it doesn't send any traps..

I have been googleing how to get the server to send traps when say httpd stops but I can't seem to get an answer..

my current approach i sifting threw the default config to see if i can make out what needs to be done..

dose anyone happen to know of any website or book that would help me out here? or dose anyone have any suggested config that would work?

thank you in advanced

creatureofthedark 11-16-2011 12:41 PM

ah ha!!!! iv found my answer!!! well sort-of..... more testing to be done to be shore...

in this link
http://www.schemathings.com/?p=11
i saw the command
Code:

snmpconf -g basic_setup
its a little odd and i only 1/2 understand what its asking... but it just sent a trap telling me the httpd was down [at-least I think that's what its told me.....] :P

Code:

UDP: [192.168.2.41]:44387->[192.168.2.51]
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:00:00.08
SNMPv2-MIB::snmpTrapOID.0 SNMPv2-MIB::coldStart
SNMPv2-MIB::snmpTrapEnterprise.0 NET-SNMP-MIB::netSnmpAgentOIDs.10
fresh.north.project
UDP: [192.168.2.41]:44387->[192.168.2.51]
DISMAN-EVENT-MIB::sysUpTimeInstance 0:0:00:00.08
SNMPv2-MIB::snmpTrapOID.0 SNMPv2-MIB::coldStart
SNMPv2-MIB::snmpTrapEnterprise.0 NET-SNMP-MIB::netSnmpAgentOIDs.10

here is the config the command generated..

Code:

###########################################################################
#
# snmpd.conf
#
#  - created by the snmpconf configuration program
#
###########################################################################
# SECTION: Monitor Various Aspects of the Running Host
#
#  The following check up on various aspects of a host.

# proc: Check for processes that should be running.
#    proc NAME [MAX=0] [MIN=0]
#
#    NAME:  the name of the process to check for.  It must match
#            exactly (ie, http will not find httpd processes).
#    MAX:  the maximum number allowed to be running.  Defaults to 0.
#    MIN:  the minimum number to be running.  Defaults to 0.
#
#  The results are reported in the prTable section of the UCD-SNMP-MIB tree
#  Special Case:  When the min and max numbers are both 0, it assumes
#  you want a max of infinity and a min of 1.

proc  httpd 1 1

# disk: Check for disk space usage of a partition.
#  The agent can check the amount of available disk space, and make
#  sure it is above a set limit.
#
#    disk PATH [MIN=100000]
#
#    PATH:  mount path to the disk in question.
#    MIN:  Disks with space below this value will have the Mib's errorFlag set.
#          Can be a raw integer value (units of kB) or a percentage followed by the %
#          symbol.  Default value = 100000.
#
#  The results are reported in the dskTable section of the UCD-SNMP-MIB tree

disk  / 10%

# load: Check for unreasonable load average values.
#  Watch the load average levels on the machine.
#
#    load [1MAX=12.0] [5MAX=12.0] [15MAX=12.0]
#
#    1MAX:  If the 1 minute load average is above this limit at query
#            time, the errorFlag will be set.
#    5MAX:  Similar, but for 5 min average.
#    15MAX:  Similar, but for 15 min average.
#
#  The results are reported in the laTable section of the UCD-SNMP-MIB tree

load  4 3 3



###########################################################################
# SECTION: Access Control Setup
#
#  This section defines who is allowed to talk to your running
#  snmp agent.

# rwcommunity: a SNMPv1/SNMPv2c read-write access community name
#  arguments:  community [default|hostname|network/bits] [oid]

rwcommunity  public mon.man.project



###########################################################################
# SECTION: Trap Destinations
#
#  Here we define who the agent will send traps to.

# trap2sink: A SNMPv2c trap receiver
#  arguments: host [community] [portnum]

trap2sink  mon.man.project public






###########################################################################
# SECTION: System Information Setup
#
#  This section defines some of the information reported in
#  the "system" mib group in the mibII tree.

# syslocation: The [typically physical] location of the system.
#  Note that setting this value here means that when trying to
#  perform an snmp SET operation to the sysLocation.0 variable will make
#  the agent return the "notWritable" error code.  IE, including
#  this token in the snmpd.conf file will disable write access to
#  the variable.
#  arguments:  location_string

syslocation  north

# syscontact: The contact information for the administrator
#  Note that setting this value here means that when trying to
#  perform an snmp SET operation to the sysContact.0 variable will make
#  the agent return the "notWritable" error code.  IE, including
#  this token in the snmpd.conf file will disable write access to
#  the variable.
#  arguments:  contact_string

syscontact  david@the-ward-network.com

# sysservices: The proper value for the sysServices object.
#  arguments:  sysservices_number

sysservices 12
sysservices 0*1 + 0*2 + 1*4 + 1*8 + 1*64



###########################################################################
# SECTION: Agent Operating Mode
#
#  This section defines how the agent will operate when it
#  is running.

# master: Should the agent operate as a master agent or not.
#  Currently, the only supported master agent type for this token
#  is "agentx".
#
#  arguments: (on|yes|agentx|all|off|no)

master  yes


creatureofthedark 11-16-2011 12:50 PM

-_- it appears in my surprise that something actually came threw I got a little over excited...

the above dose not show that httpd is down.... [pass on what it dose say other then cold start o_O]

iv tested this by bringing httpd up and down but not more traps are being sent..

any suggestions?


All times are GMT -5. The time now is 08:16 PM.