Unix Linux Administration II Class 10: Shell prompts and functions.

Slides:



Advertisements
Similar presentations
This course is designed for system managers/administrators to better understand the SAAZ Desktop and Server Management components Students will learn.
Advertisements

© 2008 Cisco Systems, Inc. All rights reserved.Cisco ConfidentialPresentation_ID 1 Chapter 8: Monitoring the Network Connecting Networks.
1 Dynamic DNS. 2 Module - Dynamic DNS ♦ Overview The domain names and IP addresses of hosts and the devices may change for many reasons. This module focuses.
Browsers and Servers CGI Processing Model ( Common Gateway Interface ) © Norman White, 2013.
Introducing the Command Line CMSC 121 Introduction to UNIX Much of the material in these slides was taken from Dan Hood’s CMSC 121 Lecture Notes.
14.1 © 2004 Pearson Education, Inc. Exam Planning, Implementing, and Maintaining a Microsoft Windows Server 2003 Active Directory Infrastructure.
Linux+ Guide to Linux Certification, Second Edition
Hands-On Microsoft Windows Server 2003 Administration Chapter 5 Administering File Resources.
70-290: MCSE Guide to Managing a Microsoft Windows Server 2003 Environment Chapter 8: Implementing and Managing Printers.
Guide To UNIX Using Linux Third Edition
Guide to Linux Installation and Administration, 2e1 Chapter 6 Using the Shell and Text Files.
Domain Name Server © N. Ganesan, Ph.D.. Reference.
Check Disk. Disk Defragmenter Using Disk Defragmenter Effectively Run Disk Defragmenter when the computer will receive the least usage. Educate users.
Pro Exchange SPAM Filter An Exchange 2000 based spam filtering solution.
WebReport/400 TCP/IP Configuration Presented by Kisco Information Systems.
Printing Terminology. Requirements for Network Printing At least one computer to operate as the print server Sufficient RAM to process documents Sufficient.
© Copyright 2013 TONE SOFTWARE CORPORATION. Confidential and Proprietary. All rights reserved. ® Basic Administrator Training – Release Entities.
Login Screen This is the Sign In page for the Dashboard Enter Id and Password to sign In New User Registration.
Advanced Shell Programming. 2 Objectives Use techniques to ensure a script is employing the correct shell Set the default shell Configure Bash login and.
SMTP PROTOCOL CONFIGURATION AND MANAGEMENT Chapter 8.
Let’s Make An Form! Bonney Armstrong GD 444 Westwood College February 9, 2005.
Introduction to Shell Script Programming
® IBM Software Group © 2009 IBM Corporation Rational Publishing Engine RQM Multi Level Report Tutorial David Rennie, IBM Rational Services A/NZ
WhatsUp Gold v15 – WhatsUp Companion 3.7 WhatsUp Companion Extended
Understanding the CORBA Model. What is CORBA?  The Common Object Request Broker Architecture (CORBA) allows distributed applications to interoperate.
Josh Riggs Utilizing Open Source Network Monitoring.
Guide to Linux Installation and Administration, 2e1 Chapter 8 Basic Administration Tasks.
5 Chapter Five Web Servers. 5 Chapter Objectives Learn about the Microsoft Personal Web Server Software Learn how to improve Web site performance Learn.
Week 7 Working with the BASH Shell. Objectives  Redirect the input and output of a command  Identify and manipulate common shell environment variables.
– Introduction to the Shell 10/1/2015 Introduction to the Shell – Session Introduction to the Shell – Session 2 · Permissions · Users.
Module 7: Fundamentals of Administering Windows Server 2008.
Module 10: Monitoring ISA Server Overview Monitoring Overview Configuring Alerts Configuring Session Monitoring Configuring Logging Configuring.
Citrix MPS 3.0 Licensing Douglas A. Brown President
Postfix Mail Server Postfix is used frequently and handle thousands of messages. compatible with sendmail at command level. high performance program easier-
MCTS Guide to Microsoft Windows Server 2008 Applications Infrastructure Configuration (Exam # ) Chapter Four Windows Server 2008 Remote Desktop Services,
Silberschatz, Galvin and Gagne  Operating System Concepts Chapter 3: Operating-System Structures System Components Operating System Services.
Linux+ Guide to Linux Certification Chapter Eight Working with the BASH Shell.
1 Electronic Messaging Module - Electronic Messaging ♦ Overview Electronic messaging helps you exchange messages with other computer users anywhere in.
Introduction To Nagios A Linux-based Monitoring System.
MCTS Guide to Microsoft Windows Server 2008 Applications Infrastructure Configuration (Exam # ) Chapter Five Windows Server 2008 Remote Desktop Services,
Graphing and statistics with Cacti AfNOG 11, Kigali/Rwanda.
A Brief Documentation.  Provides basic information about connection, server, and client.
Nagios The monitoring tool. Why ? Nagios is a powerful, modular network monitoring system that can be used to monitor many network services like smtp,
Topics Sending an Multipart message Storing images Getting confirmation Session tracking using PHP Graphics Input Validators Cookies.
Silicon & Software Systems (S3)‏ Copyright © Silicon & Software Systems Limited Antispam protection IT Department 20/03/2008 Ondrej Valousek.
Oracle Data Integrator Agents. 8-2 Understanding Agents.
SMS Software Distribution. Overview  Explaining How SMS Distributes Software  Managing Distribution Points  Configuring Software Distribution and the.
CIT 470: Advanced Network and System AdministrationSlide #1 CIT 470: Advanced Network and System Administration System Monitoring.
1 Network Information System (NIS). 2 Module – Network Information System (NIS) ♦ Overview This module focuses on configuring and managing Network Information.
Environment After log in into the system, a copy of the shell is given to the user Shell maintains an environment which is distinct from one user to another.
CSCI 330 UNIX and Network Programming Unit III Shell, Part 1.
Agenda The Bourne Shell – Part II Special Characters Ambiguous File Reference Variable Names and Values User Created Variables Read-only Variables (Positional.
© 2006 Cisco Systems, Inc. All rights reserved.Cisco PublicITE I Chapter 6 1 Router Initialization steps.
1 CMPT 471 Networking II DNS © Janice Regan,
Module 5: Managing Addresses and Address Lists.
Linux+ Guide to Linux Certification, Second Edition
Interactions & Automations
Cognos 8 BI Configuration, Administration, and Upgrade Cognos 8 BI.
Session 11: Cookies, Sessions ans Security iNET Academy Open Source Web Development.
Monitoring Dynamic IOC Installations Using the alive Record Dohn Arms Beamline Controls & Data Acquisition Group Advanced Photon Source.
Windows Server 2003 { First Steps and Administration} Benedikt Riedel MCSE + Messaging
SQL Database Management
Development Environment
Project Management: Messages
Essentials of UrbanCode Deploy v6.1 QQ147
What is nagios? Version 2 8/ M.A.Newhall.
IIS.
Chapter 8: Monitoring the Network
Introduction to Ansible
Rational Publishing Engine RQM Multi Level Report Tutorial
Presentation transcript:

Unix Linux Administration II Class 10: Shell prompts and functions.

Agenda discuss Homework. Unit 1: shell prompts and functions. Unit 2: Nagios

Homework review Installing postfix. Problems with sending mail to local hosts. Sending mail between external hosts (gmail, Hotmail, Comcast, etc). Postgrey installs.

Review: switch between postfix and sendmail using /usr/sbin/alternatives --config mta Config files under /etc/postfix primary config file main.cf postfix leverages the same alisese file as sendmail /etc/aliases smarthost, central host for managing mail delivery. postfix like sendmail only listens on the loopback address by default. postfix like sendmail supports TLS for encrypting mail transport.

Review: class restrictions ube, unsolicited bulk uce, unsolicited commercial or SPAM smtpd helo restrictions: force connections to identify themselves. smtpd sender restrictions, reject mail from non- FQDN hosts, reject mail without an A or MX record, reject non standard mail smtpd recipient restrictions, disable bulk deliveries, reject mail without a fqdn for recipient,

Review: black/white/grey listing White list: user allowed Black list: account rejected Real time blacklist or DNS black lists bl.spamcop.net Grey listing: delay mail. Postgrey: a policy server used to greylist for the MTA. Postgrey reviews the request and temporarily rejects mail not seen before.

Class 10, Unit 1 What we are going to cover: Prompts, parameters and functions. What you should leave this session with: How to modify your default prompt Using parameter substitution for patern matching. Creating functions in your scripts.

Command prompt PS1 How your prompt is displayed is defined by the environment variable PS1. you can see the current setting using echo: echo $PS1 \W]\$ You can of course change this environment variable temporarily using export ]" This will add time to your prompt. if you want to keep this add it to your.profile or.bashrc

Parameter substitution Remember that we can rename files using ${var}.old for example. But we can also use failsafe options such as if a variable is not already defined, define it. ${parameter:-value} In this example if the value of "parameter" is null then it will be replaced with the value provided. This may be found in your apachectl scripts as: httpd=${HTTPD:-/usr/sbin/httpd}

Pattern matching Constructs The POSIX shell provides four parameter substitution constructs that perform pattern matching. The construct takes two arguments, a variable name and a pattern. If the pattern is a match then the shell substitutes the value of the variable on the command line.

Pattern :${variable%pattern} ${variable%pattern} - looks to find a match at the end of the variable, if found the contents of the variable are substituted on the command line for the shortest matching pattern. var=testcase echo $var testcase echo ${var%e} testcas

Pattern :${variable%pattern} ${variable%pattern} - just like before but it will match the LONGEST pattern assuming the * is used in the pattern otherwise it is just like the single percent version. var=testcase echo $var testcase echo ${var%a*e} testc

Pattern :${variable#pattern} ${variable#pattern} - substitute the value of the variable on the command line with the pattern removed from the left. var=testcase echo $var testcase echo ${var#?e} stcase

Pattern :${variable##pattern} ${variable##pattern} - just like the single hash version but it substitutes the LONGEST pattern on the left. var=testcase echo $var testcase echo ${var##*c} ase

IFS Internal Field Separator IFS - The shell uses this value when parsing input from the read command, output from command substitution and when performing variable substation. This is the list of characters that act as word separators typically set to space, tab and newline. echo "IFS${IFS}"

Functions. functions - standard format is name () { command; } We have seen examples in some scripts this quarter for our "usage" statements. Anytime you find yourself writing the same logic twice you should probably consider using a function.

Functions cont. once a function is defined you can execute it just like any other command. functions only exist in the shell they were defined within, they cannot be exported to sub-shells. However, you could put common functions into your.profile if desired. you can remove a function from a shell using unset -f {function name}

Review Your shell prompt is controlled by PS1, you can use many shortcuts to customize this value. \u \W \h and more. Parameter substitution allows you to temporarily change a value. Or set a default value as we saw with: httpd=${HTTPD:-/usr/sbin/httpd} IFS defines the internal field separators which are usually tab, whitespace and newline.

Review Functions allow you to write code once and reuse it multiple times. The standard format is: name () { command; } We have seen usage statement examples quarter.

In class lab 10a Lab notes for this session can be found here: -> Class Content -> InClass labs ->

Class 10, Unit 2 What we are going to cover: Nagios What you should leave this session with: Basic install. How to add resources to monitor.

Nagios history Born from Netstaint Nagios is a open source network monitoring solution. Published by FSF under the GNU General Public License. Currently maintained by Ethan Galstad, Nagios is an acronym for “Nagios Ain’t Gonna Insist On Sainthood.

Nagios monitoring There are two types of monitoring System monitoring: checking for local stats such as cpu, memory, disk space etc. Network monitoring: using a central machine to check the status of remote services like web servers, mail servers, applications etc.

Nagios components Nagios daemon - responsible for managing the web interface and running the various checks. Nagios plug-ins - collection of scripts for checking various services. So to run Nagios you just need the daemon running and a Nagios plugin defined.

Primary config /etc/nagios.cfg This file is read by nagios every time it is started up. Lots of options defined within this file including resources (variables), configuration locations, object definitions, etc. Verify the nagios configuration using: /bin/nagios –v /etc/nagios.cfg

Nagios cgi.cfg The web interface for Nagios is based on CGI scripts. The configuration file for these can be found under /etc/nagios/cgi.cfg

Objects Objects define what Nagios will check. Objects are defined for hosts, services, contacts, etc. A host object provides a mapping between a IP address and a name. A service defines a given process on a host that Nagios will monitor. Object files are stored under /etc/nagios/objects localhost.cfg is a good example to review when defining new objects.

Templates All templates are defined in the templates.cfg file. There are templates definitions for contact, host, and service objects. Templates and objects look very similar. The primary difference is that templates have a register value of 0, meaning this can only be used as a Template and not an active object. Templates can be chained together based on inheritance.

Contacts and notifications When things change on your network that Nagios monitors you will be informed based on the notifications defined for that object. Check the contact.cfg for contact groups Contact options include , SMS messages, pagers and anything else you care to configure Timeperiods.cfg defines just what you might expect.

Advanced Nagios features There are local services that can be installed to monitor host system more closely Nagios can accept updates from external sources such as SNMP traps. Nagios can be configured to understand relationships between hosts and services. Nagios can be integrated with Splunk. Commercial support is available for Nagios.

Installing Nagios You can install Nagios using Yum if you enable 3 rd party repositories But to allow for more control over the builds we will compile Nagios locally from source. That said using 3 rd party repositories pre- packaged build for Nagios can be a reasonable option in many cases.

Sample host definition. # Define a host for the local machine define host{ use linux-server ; Name of host template to use ; This host definition will inherit all variables that are defined ; in (or inherited by) the linux-server host template definition. host_name localhost alias localhost address }

Sample host check Review the localhost.cfg for sample configs This is a sample ping test define service{ use local-service ; Name of service template host_name localhost service_description PING check_command check_ping! 100.0,20%!500.0,60% }

Update, test config and reload Once you have a new config in place update your nagios.cfg file to reflect the new object if necessary. New files under cfg_dir=/usr/local/nagios/etc/conf.d do not need an explict defintion. Test your new configuration /usr/local/nagios/bin/nagios –v nagios.cfg Restart nagios /sbin/service nagios restart Check the web admin for the new object.

Review: Started out as Netsaint Provides system and network monitoring Components include Nagios daemon and plug-ins Primary configuration /etc/nagios.cfg /bin/nagios –v /etc/nagios.cfg Web configuration located /etc/nagios/cgi.cfg Objects define what Nagios will check. Templates similar to objects but not used for active checks. Local Nagios agents can provide more detailed monitoring Nagios be configured to understand system relationships. Commercial support is available for Nagios.

In class lab 10b Lab notes for this session can be found here: -> Class Content -> InClass labs ->

Homework Final for this quarter will be posted later tonight. It is basically another homework assignment but with a few less details. However you can use your notes, google, call a friend etc. It should all be things we have covered this quarter.