LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 10-12-2009, 04:47 AM   #1
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Rep: Reputation: 148Reputation: 148
How to generate snmptrap every minutes


This is my snmpd.conf file
PHP Code:
trapcommunity public
rocommunity wvnt
trap2sink localhost 
public 166
master agentx
agentSecName disman
createUser disman MD5 redixzy
@1
rouser disman auth
com2sec   local       localhost         
public
com2sec   mynetwork   172.16.0.0/16     wvnt

group    MyRWGroup    v1           local
group    MyRWGroup    v2c          local
group    MyROGroup    v1           mynetwork
group    MyROGroup    v2c          mynetwork
view all     included  .1                               80
access MyROGroup    
""        any         noauth      exact    all     none    none
access MyRWGroup    
""        any         noauth      exact    all     all     none
proc httpd 10 1 
disk    
/               1024
disk    
/usr            5120
disk    
/home           1024
disk    
/var            1024
disk    
/opt            5120
monitor 
-u disman --r 60 -o dskPath -o dskAvail -o dskTotal "dskTable" dskErrorFlag 0 1
monitor 
-u disman --r 60 --o prNames.1 -o prErrMessage.1 "Process Httpd" prErrorFlag.1 0 1 
load 12 8 6
pass .1.3.6.1.4.1.4413.4.1 
/usr/bin/ucd5820stat 
How can i generate trap every minutes to check disk, service and memory?

PHP Code:
monitor -u disman --r 60 -o dskPath -o dskAvail -o dskTotal "dskTable" dskErrorFlag 0 1
monitor 
-u disman --r 60 --o prNames.1 -o prErrMessage.1 "Process Httpd" prErrorFlag.1 0 1 
Is this not check the system every minutes and generate traps?
If i restart the snmpd services, it has generate the traps for disk and process for http, but this should happened automatically

How can i do this task(what i mean is, if some changes happened on the disk or http it should notify via snmptrap)?

Last edited by kirukan; 10-12-2009 at 04:53 AM.
 
Old 10-12-2009, 06:28 AM   #2
rizhun
Member
 
Registered: Jun 2005
Location: England
Distribution: Ubuntu, SLES, AIX
Posts: 268

Rep: Reputation: 47
Hi Kirukan,

I think you want to configure snmp to listen for traps and report failures, but when it comes to checking every few minutes, you really want to use an snmp 'get'.

If you look at the output of an snmp 'walk' on one of my servers, you can see how they tally up:

Code:
$ snmpwalk -v2c -c public 172.16.7.132 | grep Storage

HOST-RESOURCES-MIB::hrStorageIndex.1 = INTEGER: 1
HOST-RESOURCES-MIB::hrStorageIndex.2 = INTEGER: 2
HOST-RESOURCES-MIB::hrStorageIndex.3 = INTEGER: 3
HOST-RESOURCES-MIB::hrStorageIndex.4 = INTEGER: 4
HOST-RESOURCES-MIB::hrStorageIndex.5 = INTEGER: 5
HOST-RESOURCES-MIB::hrStorageIndex.6 = INTEGER: 6
HOST-RESOURCES-MIB::hrStorageDescr.1 = STRING: Memory Buffers
HOST-RESOURCES-MIB::hrStorageDescr.2 = STRING: Real Memory
HOST-RESOURCES-MIB::hrStorageDescr.3 = STRING: Swap Space
HOST-RESOURCES-MIB::hrStorageDescr.4 = STRING: /
HOST-RESOURCES-MIB::hrStorageDescr.5 = STRING: /sys
HOST-RESOURCES-MIB::hrStorageDescr.6 = STRING: /sys/kernel/debug
HOST-RESOURCES-MIB::hrStorageAllocationUnits.1 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.2 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.3 = INTEGER: 1024 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.4 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.5 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageAllocationUnits.6 = INTEGER: 4096 Bytes
HOST-RESOURCES-MIB::hrStorageSize.1 = INTEGER: 516288
HOST-RESOURCES-MIB::hrStorageSize.2 = INTEGER: 516288
HOST-RESOURCES-MIB::hrStorageSize.3 = INTEGER: 524264
HOST-RESOURCES-MIB::hrStorageSize.4 = INTEGER: 772821
HOST-RESOURCES-MIB::hrStorageSize.5 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageSize.6 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.1 = INTEGER: 67244
HOST-RESOURCES-MIB::hrStorageUsed.2 = INTEGER: 510672
HOST-RESOURCES-MIB::hrStorageUsed.3 = INTEGER: 20
HOST-RESOURCES-MIB::hrStorageUsed.4 = INTEGER: 686208
HOST-RESOURCES-MIB::hrStorageUsed.5 = INTEGER: 0
HOST-RESOURCES-MIB::hrStorageUsed.6 = INTEGER: 0
This way I can create a simple bash script to check the free space on my root disk:

Code:
#!/bin/bash

# check_root_disk.sh

# Setup variables
unitSize=$(snmpget -v2c -c public 172.16.7.132 hrStorageAllocationUnits.4 | awk '{print $(NF - 1)}')
totalSize=$(snmpget -v2c -c public 172.16.7.132 hrStorageSize.4 | awk '{print $NF}')
totalUsed=$(snmpget -v2c -c public 172.16.7.132 hrStorageUsed.4 | awk '{print $NF}')

# Find the difference
totalFree=$(( totalSize - totalUsed ))

# Convert to real money
totalFree=$(( totalFree * unitSize ))

# If less than 25% is free, raise an alert
[[ ${totalFree} -lt $(( ((totalSize * unitSize) / 100) * 25 )) ]] && {
  # handle error here, maybe:
  # mail -s "Disk Alert" admin@site.org
}

exit 0
Now you can add this to cron somewhere and get it to run every 5 minutes (or whatever):
Code:
*/05 * * * * /path/to/check_root_disk.sh > /dev/null 2>&1
Hope this helps!
 
Old 10-12-2009, 11:05 AM   #3
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Original Poster
Rep: Reputation: 148Reputation: 148
Quote:
disk PATH [ MINSPACE | MINPERCENT% ]
monitors the disk mounted at PATH for available disk space.

The minimum threshold can either be specified in Kb (MINSPACE) or as a percentage of the total disk (MINPERCENT% with a ’%’
character), defaulting to 100Kb if neither are specified. If the free disk space falls below this threshold, then the corre-
sponding dskErrorFlag instance will be set to 1, and a suitable description message reported via the dskErrorMsg instance.

Note: This situation will not automatically trigger a trap to report the problem - see the DisMan Event MIB section later.
So, How can i trigger a trap to report the problem?

Quote:
monitor -u disman -t -r 60 -o dskPath -o dskAvail -o dskTotal "dskTable" dskErrorFlag 0 1
monitor -u disman -t -r 60 -i -o prNames.1 -o prErrMessage.1 "Process Httpd" prErrorFlag.1 0 1
If dskErrorFlag state change then it should fire a snmptrap but it wont happen thats why i am asking, what are the things that i am missing from above configuration(when i restart the snmpd service it's firing the snmptrap)

OR
Do i need to do any changes in snmpd startup
Quote:
OPTIONS="-A -Lf /var/log/snmpd/snmpd.log -c /etc/snmp/snmpd.conf -p /var/run/snmpd.pid -a"
This is the option that i am using for snmpd startup

Last edited by kirukan; 10-12-2009 at 11:19 AM.
 
1 members found this post helpful.
Old 10-13-2009, 06:42 AM   #4
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Original Poster
Rep: Reputation: 148Reputation: 148
Please anybody assist me..
I hope that I have configured my linux snmpd as an agent and it is monitoring some ErrorFlags if some changes occurred in ErrorFlags, this agent should fire the trap.

Here i have mentioned to send trap to which snmptrapd
Quote:
trap2sink localhost public 166

This is my snmptrap.conf, i hope if a trap trigger from my agent linux machine it will send it to snmptrapd(this snmptrapd listening on port 166 and community is public) and those traps foward to my mail account.
Quote:
format2 finished
authCommunity log,execute,net public
traphandle default /usr/bin/perl /usr/bin/traptoemail -s mail.xyz.com -f root kirukan@xyz.com
disableAuthorization yes
donotlogtraps yes
But these wont happen in my situation according to the ErrorFlags state change.

However, if i restart the snmpd agent i could receive some traps as follows
Quote:
Host: <UNKNOWN> (UDP: [172.16.16.143]:35049)
.1.3.6.1.2.1.1.3.0 0:0:00:00.25
.1.3.6.1.6.3.1.1.4.1.0 .1.3.6.1.2.1.88.2.0.2
.1.3.6.1.2.1.88.2.1.1.0 dskTable
.1.3.6.1.2.1.88.2.1.2.0
.1.3.6.1.2.1.88.2.1.3.0
.1.3.6.1.2.1.88.2.1.4.0 .1.3.6.1.4.1.2021.9.1.100.1
.1.3.6.1.2.1.88.2.1.5.0 1
.1.3.6.1.4.1.2021.9.1.2.1 /
.1.3.6.1.4.1.2021.9.1.7.1 508096
.1.3.6.1.4.1.2021.9.1.6.1 2030768
But i need whenever ErrorFlags state change i have to receive traps.

Where i am doing mistake or am I thinking in a wrong way??

Last edited by kirukan; 10-13-2009 at 06:44 AM.
 
Old 10-14-2009, 02:58 PM   #5
kirukan
Senior Member
 
Registered: Jun 2008
Location: Eelam
Distribution: Redhat, Solaris, Suse
Posts: 1,278

Original Poster
Rep: Reputation: 148Reputation: 148
Quote:
I would like to clarify about my way of expression because i feel that i am really failing to express my problem in a proper way.


1. Is the above mentioned thing true?
2. Is way of my presentation not clear?
3. Am i giving lack of information?
4. Am i confusing you?
5. Is there any contradiction in my question?
6. Is this not an achievable task?
The sole intention to ask these questions to develop my interpersonal skill. I really expecting your suggestion in this regards.

Thanks
 
Old 06-01-2018, 06:25 AM   #6
ranafaisal
LQ Newbie
 
Registered: May 2018
Posts: 13

Rep: Reputation: Disabled
ok got it

Last edited by ranafaisal; 06-01-2018 at 06:27 AM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to generate snmptrap kirukan Linux - Networking 6 10-08-2009 02:48 PM
Snmptrap Receipient talat Linux - Software 5 01-13-2009 09:08 AM
snmptrap configuration on RHEL ES 4 sherimm Linux - Software 0 01-02-2009 12:24 AM
snmptrap ? blackzone Linux - Networking 0 10-05-2004 02:01 AM
snmptrap utility pieza Linux - Networking 1 11-23-2003 01:16 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration