LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 04-15-2013, 07:10 AM   #1
tissam89
Member
 
Registered: Mar 2013
Posts: 47

Rep: Reputation: Disabled
script to monitor interfaces


Hi !
I am using nagios to monitor my equipments .

I have to monitor the interfaces of my switches and routers, but is a big number of interfaces and equipments , i can't add it one by one manualy .

I searshed in internet , and i have found this script :

Code:
#!/usr/bin/perl
use strict;
 
open(MODEL, "modele.txt");
mkdir("modeles") if(!-d("modeles"));
while() {
  chomp();
  my($modele, $ip) = split(/;/);
  my @interfaces = `snmpwalk -c ecalyptus -v 2c $ip 1.3.6.1.2.1.2.2.1.2`;
  open(MODEL_CFG, ">modeles/switch-$modele.cfg");
  foreach(@interfaces) {
    if(/iso.3.6.1.2.1.2.2.1.2.(\d+) = STRING: "(.*Ethernet.*)"/) {
      my ($id, $interface) = ($1, $2);
      print MODEL_CFG "define service {
  hostgroup_name       $modele
  use                  generic-service
  service_description  $interface
  check_command        check_port_usage!$id!6000!8000
}
\n";
    }
  }
  close(MODEL_CFG);
}
close(MODEL);
i don't know how to use it , what should I write on modele.com file, and from where my script will get the $ip et $modele ?

Please help me .

Here i found this script :

http://lesaventuresdeyannigdanslemon...tch-cisco.html
 
Old 04-15-2013, 11:16 AM   #2
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
If I had to guess, and I am, you should not use this.

Quote:
Originally Posted by tissam89 View Post
Hi !
I am using nagios to monitor my equipments .

I have to monitor the interfaces of my switches and routers, but is a big number of interfaces and equipments , i can't add it one by one manualy .
Why not? Define a "big number of interfaces and equipments"
Are those host details stored in a file somewhere?
Where did you 'find' this script exactly?

Last edited by Habitual; 04-15-2013 at 11:22 AM.
 
Old 04-15-2013, 12:27 PM   #3
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by tissam89 View Post
Hi !
I am using nagios to monitor my equipments. I have to monitor the interfaces of my switches and routers, but is a big number of interfaces and equipments , i can't add it one by one manualy.
Yes, you CAN add them manually. It's a matter of WANTING to add them manually.
Quote:
I searshed in internet , and i have found this script. i don't know how to use it , what should I write on modele.com file, and from where my script will get the $ip et $modele ?

Here i found this script :
http://lesaventuresdeyannigdanslemon...tch-cisco.html
So...you found the script, but instead of asking the author of the script for help, you posted it here, and want US to figure it out? Why don't you just email the person who wrote it, and ask? Their email address and other contact info is on their website. Also, there are six pages of networking plugins on the Nagios site...have you checked there?
http://exchange.nagios.org/directory...-and-Bandwidth

You just say "monitor"...you don't say if you want a simple up/down, traffic information, or how detailed you want.
 
Old 04-15-2013, 12:38 PM   #4
tissam89
Member
 
Registered: Mar 2013
Posts: 47

Original Poster
Rep: Reputation: Disabled
Hi, Thank you for your answer .
I have try to contact the person, but noway .
I posted my question on nagios forums too, but no answer yet .

for the moment, i just want to test if the interface is up or down .
 
Old 04-15-2013, 12:52 PM   #5
TB0ne
LQ Guru
 
Registered: Jul 2003
Location: Birmingham, Alabama
Distribution: SuSE, RedHat, Slack,CentOS
Posts: 26,634

Rep: Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965Reputation: 7965
Quote:
Originally Posted by tissam89 View Post
Hi, Thank you for your answer. I have try to contact the person, but noway.
What do you mean "no way"??? You couldn't find out how, they haven't answered, or they told you no?? If you read the script, it's telling you the .txt file contains two things: the model of the Cisco router, and the IP address of the router, separated by comma.
Quote:
I posted my question on nagios forums too, but no answer yet.
Question about WHAT?? They didn't write that script...which plugin did you post about?? Each plugin has a different author and maintainer...but they are very easy to install/use and are typically well documented. Did you read/understand those docs?
Quote:
for the moment, i just want to test if the interface is up or down .
Ok, so AGAIN, go to the Nagios plugin site, and pick the plugin that does exactly what you're looking for. Read the instructions and install it. Did you try to look this up?
http://exchange.nagios.org/directory..._cisco/details
 
1 members found this post helpful.
Old 04-16-2013, 10:26 AM   #6
Habitual
LQ Veteran
 
Registered: Jan 2011
Location: Abingdon, VA
Distribution: Catalina
Posts: 9,374
Blog Entries: 37

Rep: Reputation: Disabled
Quote:
Originally Posted by tissam89 View Post
Hi, Thank you for your answer .
I have try to contact the person, but noway .
I posted my question on nagios forums too, but no answer yet .

for the moment, i just want to test if the interface is up or down .
for the moment, this satisfies your request.
Code:
nmap -PN IP -p port
telnet host port
such as
Code:
telnet towel.blinkenlights.nl 666
and process the output.

Put more than just a passing effort into it!
 
1 members found this post helpful.
  


Reply



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
linux script to configure interfaces schand4269@yahoo.com Linux - Server 3 04-01-2012 10:53 PM
LXer: Monitor Linux Network Interfaces With vnStat LXer Syndicated Linux News 0 11-19-2010 09:30 PM
LXer: Four winning ways to monitor machines through Web interfaces LXer Syndicated Linux News 0 11-04-2008 04:40 PM
Shell script to switch interfaces jasonenid Linux - Networking 2 10-04-2008 03:22 AM
Do you need to switch between wireless and wired interfaces? Wanna monitor cpufreq? ming0 Linux - Laptop and Netbook 0 01-31-2004 02:06 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 03:01 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