Shell Script - Generate SNMP Traps

 
Thread Tools Search this Thread
Special Forums UNIX and Linux Applications Infrastructure Monitoring Shell Script - Generate SNMP Traps
# 1  
Old 10-07-2009
Shell Script - Generate SNMP Traps

Good morning to you all

I´m kinda of a noob to scripting, and my knowledge is still very basic: anyway, I´ve developed a small .sh script with the following purpose:

- it will check a result file, checking if it has any values, or if it´s empty
- if it´s empty it will send an email

What i wanted to do, is eliminate the email part and generate some kind of snmp trap to be used for Nagios for instance, and create an alarm.

Does anybody know how to do that? Any help is apreciated. Thkx

Here goes the code:


##############################################

cat /var/www/monitor/scripts/TestProbes/probelist.txt | while read probe

do


if [[ -s /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt ]] ; then

echo "Probe has data at $(date +%Y-%m-%d) $(date +%H:%M:%S)" > /var/www/monitor/scripts/TestProbes/results.txt

else


SUBJECT="No\\ Service\\ at\\ "$probe" "
EMAIL="XXXX@XXXX.com"
EMAILMESSAGE="mail"
echo "====================================================
A "$probe" ISN´T WORKING:"> $EMAILMESSAGE
echo "$(date -d "-3 hours" +%Y-%m-%d) $(date -d "-1 hours" +%H:%M:%S)
====================================================" >>$EMAILMESSAGE

su -c "/usr/bin/mail -s $SUBJECT $EMAIL < $EMAILMESSAGE" Probe_Tester


fi

rm /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
touch /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt
chmod 777 /var/www/monitor/scripts/TestProbes/Probes/"$probe".txt


done


##############################################

---------- Post updated 10-07-09 at 04:31 AM ---------- Previous update was 10-06-09 at 06:21 AM ----------

Anyone?
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

Shell script newbie- how to generate service log from shell script

Hi, I am totally a newbie to any programming languages and I just started an entry level job in an IT company. One of my recent tasks is to create a script that is able to show the log file of linux service (i.e. ntpd service) lets say, if I run my script ./test.sh, the output should be... (3 Replies)
Discussion started by: xiaogeji
3 Replies

2. Infrastructure Monitoring

SNMP traps to SNMP server

Dear Champs, I am new to unix, and need to configure linux server to send below traps to a SNMP server. Monitoring TRAP Disk Space Low Monitoring TRAP Memory Low Monitoring TRAP CPU high Monitoring TRAP Admin login/Logoff Please help me how to send this information to my SNMP server... (2 Replies)
Discussion started by: stavar
2 Replies

3. UNIX for Dummies Questions & Answers

SNMP Traps

Hi, We are using Zyrion Traverse to monitor all the servers. I like to set the traps on all of the Linux servers to send the traps to that servers. So for on the /etc/snmp/snmp.conf file, this is what I have... ### SNMP Traps ### trap2sink x.x.x.x # Traverse server My... (4 Replies)
Discussion started by: samnyc
4 Replies

4. UNIX for Dummies Questions & Answers

Creating a virtual Interface to recieve snmp traps

All, I have a question regarding setting up a virtual interface to recieve snmp traps from network devices. My Solaris 10 server is running the HPOV-NNMi application. The network devices in our environment (many thousands) are all pre-configured to send their snmp traps to a specific IP... (4 Replies)
Discussion started by: turk22
4 Replies

5. Infrastructure Monitoring

SNMP Traps

Hi all, lately i managed to install SNMP agent on Solaris 9 & 10. The second objective is now to configure traps. However (since i'm totally new to the SUN world) i don't know a way of how to start. Can somebody help me with details? What is the first thing that you need to do to start trapping?... (3 Replies)
Discussion started by: Wizard_1979
3 Replies

6. Solaris

List of SNMP Traps supported by Solaris 10

Hi, I want the list of SNMP traps supported by Solaris 10. DO anyone has the list prepared. Regards, Rajesh (1 Reply)
Discussion started by: grrajeish
1 Replies

7. Linux

How to configure linux to receive snmp traps from a windows server?

Can anybody please tell me how to configure linux to receive snmp traps from a windows server? I am not able to receieve snmp traps on unix machines specifically linux and solaris. I have tried starting snmptrapd service on linux but it didn't work. Is there anything special that I have to do on... (2 Replies)
Discussion started by: iamtulipin
2 Replies

8. UNIX for Dummies Questions & Answers

generate xml from a shell script

Hello! I would like to generate an xml file from the output of various commands generated from within a shell script (some will be in CDATA). At the moment the only solution I have come up with is echoing xml tags around the commands eg. echo "<bitism>" >> outputfile /usr/sbin/prtconf... (1 Reply)
Discussion started by: speedieB
1 Replies

9. Solaris

SNMP traps

Hello I am trying to check that SNMP traps could be sent from one server to other . I am running this command from receiving server to see it can receive it /usr/sbin/snoop udp port 162 and on the sending end I am running this commad cst051 UDP D=162 S=1480 LEN=120 but i am... (1 Reply)
Discussion started by: Ajwat
1 Replies

10. UNIX for Advanced & Expert Users

Sending SNMP Traps in AIX / Unix

Hi, Just wondering if anyone knows how can I send an SNMP Trap in Unix Environment(AIX) to another machine (NT/Ux) after having activated the SNMP in the AIX. Can this be done by using a single command line or do I have to write a script for it? Thanks in advance for your advices. :) (1 Reply)
Discussion started by: goliath
1 Replies
Login or Register to Ask a Question