1. Trang chủ
  2. » Ngoại Ngữ

SNMP PROTOCOL AND THE APPLIED TO MONITOR SERVER’S RESOURCE

18 238 0

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

THÔNG TIN TÀI LIỆU

Thông tin cơ bản

Định dạng
Số trang 18
Dung lượng 559,28 KB

Các công cụ chuyển đổi và chỉnh sửa cho tài liệu này

Nội dung

Work assignment + Vương Khả Phú: understanding three versions of snmp protocol, find a framework supported SNMP, build manager and agent, build Get, Trap function.. + Nguyễn Tuấn Anh: u

Trang 1

VIETNAM NATIONAL UNIVERSITY, HANOI

UNIVERSITY OF ENGINEERING AND TECHNOLOGY

-

INTERNSHIP REPORT

INFORMATION TECHNOLOGY

TITLE: SNMP PROTOCOL AND THE APPLIED TO MONITOR SERVER’S

RESOURCE

Supervisor: Nguyễn Đức Huy

Trần Văn Hoàn

Assessment Lecturer: MSc Vũ Quang Dũng Student: Nguyễn Tuấn Anh

Code: 10020011 Group: K55CA

Hanoi, September 2013

Trang 2

1

Team

Trang 3

2

Table of Contents

I Introduction 4

1 The company 4

2 The job 4

3 The problem 4

II The problem requirements 5

1 The problem declaration in detail 5

2 Work assignment 5

III Summary of the theory, algorithm and solution 5

1 SNMP 5

1.1 Introduction to snmp protocol 5

1.2 The related theories, algorithms and solution 6

1.3 Framework SNMP4J 7

2 The student’s solution 7

2.1 Overview 7

2.2 Getting server’s information 7

2.3 Implement Agent and Manager 11

IV Results and Perspectives 15

1 Skills and Knowledge 15

2 The future work to improve the product/solution 15

Trang 4

3

ACKNOWLEDGMENT

I would like to express my deep appreciation to the company Viettel, my supervisors Nguyễn Đức H`uy and Trần Văn Hoàn who has facilitated, guided me during this intership

I would also like to give a big thank to the lecturer Vũ Quang Dũng for comments, suggestions, and assistance as the writing progressed

Trang 5

4

I Introduction

1 The company

Viettel is one of the world’s fastest growing telecom operators It has been well known as a pioneer who has ushered in a telecommunications revolution in just a few years, transforming telecom services to a commodity for all social classes and to all rural and remote areas With year-on-year revenue doubled during 5 consecutive years between 2005 and 2010, Viettel is listed among the world’s fastest growing telecom operators and is placed among the top 15 telecom companies in terms of cellular connections (ranked by GSMA’s Wireless Intelligence) Viettel has currently operations in six markets over Asia, Latin America and Africa, covering a total population of nearly 170 million people In 2011, Viettel’s revenue reached 6 billion USD with 60 million subscribers worldwide In these markets, Viettel owns the largest network infrastructure by official launch date Viettel boasts its first group in the world initiating free Internet connections and services for all public schools which has directly benefited about 27 million teachers, pupils and students in these countries

2 The job

Understanding about SNMP protocol and applying it to real world problems Time from 12/08/2013 to 30/09/2013 contains three stages:

+ Understanding about SNMP

+ Researching about the way that queries server’s resource information: CPU, RAM, HDD

+ Use SNMP protocol in monitoring and manager server’s resource

3 The problem

With any system, the job of manager and monitoring is mandatory This help our system works well and stable Any part is overloaded will be notified to the administration to take the appropriate actions So we are developing a system to do this job on servers

First, we need to get the PC’s resource information Then base on that, we will send the warning messages if some components work over the threshold

Trang 6

5

II The problem requirements

1 The problem declaration in detail

+ Gathering information about resource useage on the server

+ Build a warning system that can send an email to the manager when we has a component (in this case, it maybe CPU or RAM) working overload (above the threshold)

+ The manager can change the threshold of RAM or CPU use on the system

2 Work assignment

+ Vương Khả Phú: understanding three versions of snmp protocol, find a framework supported SNMP, build manager and agent, build Get, Trap function

+ Nguyễn Tuấn Anh: understanding three versions of snmp protocol, build file MIB, build manager và agent, build Set, Email function

+ The job breaks into three stages:

 Stage 1: understanding SNMP and a library snmp4j that supported SNMP

 Stage 2: Find out oid of PC in Linux and windows Get information from PC

 Stage 3: Build SnmpAgent and SnmpManager

III Summary of the theory, algorithm and solution

1 SNMP

1.1 Introduction to snmp protocol

Simple Network Management Protocol (SNMP) is an "Internet-standard protocol for managing devices on IP networks" Devices that typically support SNMP include routers, switches, servers, workstations, printers, modem racks and more It is used mostly in network management systems to monitor network-attached devices for conditions that warrant administrative attention It consists of a set of standards for network management, including an application layer protocol, a database schema, and a set of data objects

SNMP exposes management data in the form of variables on the managed systems, which describe the system configuration These variables can then be queried (and sometimes set) by managing applications

In typical SNMP uses, one or more administrative computers, called managers, have the task of monitoring or managing a group of hosts or devices on a computer network Each managed system executes, at all times, a software component called an agent which reports information via SNMP to the manager

Essentially, SNMP agents expose management data on the managed systems as variables The protocol also permits active management tasks, such as modifying and

Trang 7

6

applying a new configuration through remote modification of these variables The variables accessible via SNMP are organized in hierarchies These hierarchies, and other metadata (such as type and description of the variable), are described by Management Information Bases (MIBs)

An SNMP-managed network consists of three key components:

1 Managed device

2 Agent — software which runs on managed devices

3 Network management system (NMS) — software which runs on the manager

A managed device is a network node that implements an SNMP interface that allows unidirectional (read-only) or bidirectional (read and write) access to node-specific information Managed devices exchange node-node-specific information with the NMSs Sometimes called network elements, the managed devices can be any type of device, including, but not limited to, routers, access servers, switches, bridges, hubs, IP telephones, IP video cameras, computer hosts, and printers

An agent is a network-management software module that resides on a managed device An agent has local knowledge of management information and translates that information to or from an SNMP-specific form

A network management system (NMS) executes applications that monitor and control managed devices NMSs provide the bulk of the processing and memory resources required for network management One or more NMSs may exist on any managed network

1.2 The related theories, algorithms and solution

Poll method

Principle of operation: Manager always asks information from Device If Manager does not ask then Device does not answer, if Manager asks then Device must answers

By frequently asked, Manager always updates information from Device

Figure 1 Illustration of Poll method

Trang 8

7

Alert method

Principle of operation: In Device whenever happened an event then Device automated notifies Manager Manager does not frequently ask information from Device

Figure 2 Illustration of Alert method

1.3 Framework SNMP4J

SNMP4J is an enterprise class free open source and state-of-the-art SNMP implementation for Java™ 2SE 1.4 or later SNMP4J supports command generation (managers) as well as command responding (agents)

2 The student’s solution

2.1 Overview

The work includes two main stages:

+ Get information of CPU, RAM, HDD in server bases on Agent that was already installed in operating system Implementing basic Trap method (this purpose is understanding more about SNMP protocol and simple application)

+ Build an software that monitors two components CPU and RAM of server When ever the operating parameter of them is over the threshold (this value will be entered from graphical user interface), an email will be sent to the administrator’s mail box

2.2 Getting server’s information

2.2.1 Starting SNMP Agent

In every server or personal computer, the operation system has integrated SNMP Agent To get information, we just need to start this agent

Trang 9

8

In Windows:

+ Go to Control Panel, select Turn Windows features on or off, select check box Simple Network Management Protocol (SNMP) then OK

+ We start Services to check whenever SNMP Service is running or not, then double click to this service, switch to tab Sercurity In groupbox Accepted community names, add another read-community string which is “public” Then switch to tab Agent select all the Services

In Ubuntu 11.04:

+ Install snmpd:

sudo apt-get install snmpd

Computer asked: Do you want to continue [Y/N]

Type Y

+ Configure:

Make new file snmpd.conf like this: move /etc/snmp/snmpd.conf to

/etc/snmp/snmpd.conf.org file

root@ubuntu:~# mv /etc/snmp/snmpd.conf /etc/snmp/snmpd.conf.org

root@ubuntu:~# nano /etc/snmp/snmpd.conf

Save the below line to file

rocommunity public

syslocation "Viettel-IT and UET"

syscontact phuvk_55@vnu.edu.vn

Make change to /etc/default/snmpd file like this:

From:

# snmpd options (use syslog, close stdin/out/err)

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

To:

# snmpd options (use syslog, close stdin/out/err)

#SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid 127.0.0.1'

SNMPDOPTS='-Lsd -Lf /dev/null -u snmp -I -smux -p /var/run/snmpd.pid -c /etc/snmp/snmpd.conf'

Restart snmpd:

/etc/init.d/snmpd restart

Trang 10

9

2.2.2 Implement Manager to get information from Agent

First let look at the below model to get the general ideal of how does the software work

Server SNMP Agent

SNMP Manager Administrator

Because SNMP protocol exchange message throw PDU package so first, we implement

a general method to send PDU package of GET type to Agent:

/**

* The oids is the collection of OID we want to get

*/

public ResponseEvent get(OID oids[]) {

PDU pdu = new PDU();

for (OID oid : oids) {

pdu.add(new VariableBinding(oid));

}

pdu.setType(PDU.GET);

return snmp.send(pdu, getTarget());

}

As you can see, we has getTarget() method to get the address of Agent From the

returned value ResponseEvent, we can have the value we want

So to get any information of server, we just need the OID of them For example:

OID of sysDescription: 1.3.6.1.2.1.1.1.0

OID of sysName: 1.3.6.1.2.1.1.5.0

OID of CPU: 1.3.6.1.2.1.25.3.3.1.2

From that we can just implement some code to get to know SNMP protocol by getting the information of server, then the output of the tested personal computer is:

Request Response

Change threshold Notify

Trang 11

10

System Description:Hardware: x86 Family 6 Model 42 Stepping 7 AT/AT COMPATIBLE - Software: Windows Version 6.2 (Build 9200 Multiprocessor Free)

System Name: NTA-Lap

CPU1 used 5%

CPU2 used 14%

CPU3 used 7%

CPU4 used 4%

Used: 29.351562

Used: 60.941406

267.9922 Used: 217.58203

Used: 7.5859375

2.2.3 Demo simple Trap method

We will implement both Trap sender and Trap receiver First to build Trap receiver we need a method to listen on the fix port:

public void listen(Address address) {

TransportMapping transport = new TransportMapping;

// this to handle the message come in

createMessageProcessingModels();

//add all security protocols

addSecurityProtocols();

//create target

Target target = new Target();

target.setCommunity(new OctetString("public"));

//start listening

transport.listen();

}

Trang 12

11

Then we need to handle PDU that came in (we just deal with it in a simple way)

/**

* This method will be called whenever a pdu is received on

* the given port specified in the listen() method

*/

public void processPdu(Event event) {

PDU pdu = event.getPDU();

if (pdu != null) {

pdu.getType());

pdu.getVariableBindings());

}

}

With Trap sender, just like Manager we built before, we need to send a PDU of Trap type to the specific address:

/**

* This methods sends the V1 trap to the local host in port

* 162

*/

public void sendTrap() {

PDU pdu = new PDU();

pdu.setType(PDU.TRAP);

pdu.setEnterprise(new OID(oid));

pdu.setGenericTrap(PDU.COLDSTART);

pdu.setAgentAddress(new IpAddress(ipAddress));

snmp.send(pdu, getTarget());

}

The Output of program (informed Trap receiver was listening on localhost address at

162 port, whenever received a trap then notify the type and variables inside that trap)

Listening on: 127.0.0.1/162

Received PDU

Trap type = -92

Variables = []

2.3 Implement Agent and Manager

2.3.1 Implement Agent

With an Agent, we need to have three main parts: all object that agent managed, community string, the read – write access to every object

To manage an object, we will build the below method

Trang 13

12

/**

* Clients can register the MO they need

*/

public void registerManagedObject(ManagedObject mo) {

server.register(mo);

}

ManagedObject is a managed object type we build that can set the read-write access

We can add the community string from:

protected void addCommunities(SnmpCommunity c) {

Agent agent = getAgent();

Community newRow = c.createNewRowCommunityInAgent(); agent.setCommunity(newRow, “public”, active);

}

Add read-write throw view (an property of SNMP protocol)

protected void addViews(MIB m) {

m.addSecurity();

m.addAccess(“fullReadView”);

m.addAccess(“fullWriteView”);

}

2.3.2 Implement Agent that monitors server’s resource

With this requirement, we need to build an Agent which has ability to get the system’s parameter, also this Agent must manages the threshold value that can change through SET method of SNMP protocol

First, we need to initiate an Agent then having two managed objects for that Agent

to manage (two objects are the threshold of CPU and RAM):

public void init() throws IOException {

agent = new SNMPAgent(address);

agent.start();

cpuMO = MOCreator.createReadWrite(cpuMaxOID, cpuMaxValue);

ramMO = MOCreator.createReadWrite(ramMaxOID, ramMaxValue);

agent.registerManagedObject(cpuMO);

agent.registerManagedObject(ramMO);

}

To monitor the server, Agent need an Thread to frequently ask parameters of CPU, RAM then compare to the threshold value and notify to the administrator if one of them

is overloaded:

Ngày đăng: 08/10/2015, 13:54

TỪ KHÓA LIÊN QUAN

TÀI LIỆU CÙNG NGƯỜI DÙNG

TÀI LIỆU LIÊN QUAN

🧩 Sản phẩm bạn có thể quan tâm

w