+ All Categories
Home > Documents > Using Old School methods to make life easier. Overview Introductions Everyday problems and...

Using Old School methods to make life easier. Overview Introductions Everyday problems and...

Date post: 14-Dec-2015
Category:
Upload: carla-cake
View: 214 times
Download: 0 times
Share this document with a friend
Popular Tags:
30
AUTOMATE EVERYDAY FUNCTIONS Using Old School methods to make life easier
Transcript
Page 1: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

AUTOMATE EVERYDAY FUNCTIONS

Using Old School methods to make life easier

Page 2: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Overview Introductions Everyday problems and solutions Security Cameras on the blink Server Status updates Remote Connection Location Resources Other ideas / questions Close

Page 3: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Introduction Russell Ivey – Gilmer ISD (Center, Longveiw, Ore

City)

Married – dad of 6 – cross country coach Bachelor of Science – ETBU Masters of Education – Texas A&M Programming background Worked in public education for 16 years Problem solver Disclaimer – Still learning daily

Page 4: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Everyday problems – and solutions

We are all problem solvers. Its in our job description. Many times, these are 1 and done fixes; however sometimes we have to solve the problem over and over each day, week, month, school year.

We will discuss three situations (out of many) that we have used automation to solve our problems for us.

Page 5: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Security Cameras on the Blink

Problem:We have a bank of security cameras that are deployed

throughout our 4 campuses. These cameras have web interfaces and we have a back office server recording the video.

These cameras were purchased from the lowest bidder…. They are not necessarily name brand. (They actually have no name at all)

Many of the cameras will just stop responding – they have power, but are locked up.

Page 6: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Security Cameras on the Blink

Solution: Part 1 : We purchased a network attached power unit.

These units have an IP address, web interface and control two different power outlets. The unit cost about $35 each. We plugged in two cameras POE supplies to each of these units. We can reboot the power to these cameras any time.

Part 2 : We wrote a script to PING each camera. If we do not get a response from the ping, we send a signal to the power unit to reboot that camera’s port.

Part 3 : We scheduled the script to run every two hours.

Page 7: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Security Cameras on the Blink

How we did it:Using VB Script, we do the following logic:

Read a list of camera IP addresses and corresponding power units Ping each camera Look for a response If no response, send reboot command to power unit Loop through entire list

How we did it:SET objFSO = CreateObject("Scripting.FileSystemObject")SET objInputfile = objFSO.OpenTextFile("powerMan.txt")SET objOutputfile = objFSO.CreateTextFile("log.txt", True)

Page 8: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Security Cameras on the Blink

PowerMan.txt file:10.10.2.221 10.10.2.215 2 Hs 100 Hall East Entrance

10.10.2.222 10.10.2.216 2 Hs 100 Hall West Entrance10.10.2.225 10.10.2.215 1 Hs 300 Hall East Entrance10.10.2.224 10.10.2.217 1 Hs 300 Hall East View10.10.2.223 10.10.2.217 1 Hs 300 Hall West Entrance10.10.2.233 10.10.2.215 1 HS 300 Hall West View 1

Camera IP Power Unit Port Description

Page 9: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Security Cameras on the Blink

DO WHILE NOT objInputfile.AtEndOfStreamstrBuff = objInputfile.readlinestrBuffArr = split(strBuff, " ")strCamera = strBuffArr(0)strCamName = " "SET objShell = CreateObject("WScript.Shell")SET objExec = objShell.Exec("ping " & strComputer)strPingResults = UCase(objExec.StdOut.ReadAll)

Read through the file one line at timeAssign this line to a variableMake an array of the stuff in the lineMake a variable with the IP addressCreate an empty variableOpens a command object (DOS shell)Sends out a pingGets the results of the ping

Page 10: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Security Cameras on the BlinkIF InStr(strPingResults, "TTL") THEN objOutputfile.writeline strComputer & " PING = YES "ELSE for i = 3 to ubound(strBuffArr)

strCamName = strCamName & " " & strBuffArr(i) next objOutputfile.writeline strComputer & " PING = NO" objOutputfile.writeline "Attemping reboot of " & strCamName & "(" & strCamera & ")" checkPowerMan(strCamera)END IFLOOP

Check the results for TTL and write to the logIf no TTL (ELSE) Get the name of the cameraWrite to the log – twiceExecute function “checkPowerMan”

Page 11: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Security Cameras on the BlinkFunction checkPowerMan(IP)

SET objPowerFile = objFSO.OpenTextFile("powerMan.txt")DO WHILE NOT objPowerFile.AtEndOfStream buff = objPowerFile.readLine buffArr = split(buff, " ") cam = buffArr(0) if cam = IP then if buffArr(1) <> "x" then

PowerMan = buffArr(1)port = buffArr(2)objOutputfile.writeline "Rebooting " & IP & " on PowerMan Unit " & PowerMan & " port " & portRebootCamera PowerMan, port

elseobjOutputfile.writeline "Camera is not connected to Power Management."

end if end ifLOOPobjPowerFile.closeEnd Function

Page 12: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Security Cameras on the BlinkFunction rebootCamera

Uses specific code for that power unit. That code example is available in the download files.

SchedulingWe placed this script on a windows server and

scheduled it to run every two hours with the task scheduler.

Page 13: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

What is VBScript? VBScript is a scripting language. VBScript is based in part on Microsoft's programming language

Visual Basic While it doesn't offer the same functionality of Visual Basic, it

does provide a powerful tool  What is VBScript used for? VBScript is used to give functionality and interaction to web

pages. VBScript can be used for client-side scripting. Available on Windows OS – Client and Server and Web Repetitive tasks

Page 14: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

What is VBScript?

Microsoft Visual Basic Scripting Edition brings active scripting to a wide variety of environments, including Web client scripting in Microsoft Internet Explorer and Web server scripting in Microsoft Internet Information Service

If you already know Visual Basic or Visual Basic for Applications (VBA), VBScript will be very familiar. The basic concepts of VBScript are common to most programming languages.

VBScript talks to host applications using Windows Script. With Windows Script, browsers and other host applications do not require special integration code for each scripting component. Windows Script enables a host to compile scripts, obtain and call entry points, and manage the namespace available to the developer. With Windows Script, language vendors can create standard language run times for scripting. Microsoft will provide run-time support for VBScript. Microsoft is working with various Internet groups to define the Windows Script standard so that scripting engines can be interchangeable. Windows Script is used in Microsoft Internet Explorer and in Microsoft Internet Information Service.

As a developer, you can license VBScript source implementation at no charge for use in your products. Microsoft provides binary implementations of VBScript for the 32-bit Windows API, the 16-bit Windows API, and the Macintosh. VBScript is integrated with World Wide Web browsers. VBScript and Windows Script can also be used as a general scripting language in other applications.

Page 15: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Server Status updates

Problem : We are running an older version of Microsoft Exchange and from time to time, the information store will go off-line. When that happens, we need to restart the system store.

Many times, this will take place at night or when we have no one on site.

Solution:Write a script that will check the status of all running services and send a text / email message via gmail account as to the status of the exchange information store .

Page 16: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Server Status updates1. Set Up a list (array) of all exchange servers

2. Get a list of running services by display name

3. Get a complete list of services that you wanted

Page 17: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Server Status updatesCheck the status of the service and send an email

Page 18: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Server Status updates - outgoing email configuration

Page 19: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Server Status updates

Conclusion – checking the status of services on a remote machine and sending emails automatically can be accomplished via scripting.

This can allow for checks on many different critical systems on your network.

Page 20: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Remote Connection Location

Problem : Being able to remote in to a computer is a big advantage for an understaffed department. Using Dameware or VNC or other software can be a big help, but students and teachers tend to move around. We need a way to locate the machine a user is working on.

Solution :We wrote a script and added to the Logon action in the Active Directory Group Policy management. The script logs the locations of the user every time they log on. It tracks each login by username and computer name. We then wrote a script to search these files and launch remote control software based on a computer or user name.

Page 21: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Remote Connection Location

To start, we needed to develop a way to track every login. We did this via the Group Policy Logon Script. - we call it “ip.bat”:

These lines log current info just for our own tracking purposes

These two lines create the log file entries for each user / login / computer

Page 22: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Remote Connection Location

The file that gets created looks like this:

It is a standard CSV file with the following fields:date, time, computer name,username,sessionname,logonserver

We have that going to the network share and the newest entries are at the bottom of the file.

Page 23: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Remote Connection Location

Next, we wrote a script that asks for a user or computer name and reads the logs giving options for close matches.

Here is the opening code:

We set up a variable that points to the remote control softwareThen we open the filesystemobject to read filesNext, we ask the user for a username (or computer name)

Page 24: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Remote Connection Location

A dialog box asks for a username

Results are displayed if more than one match is made.

Both computer names and user names are returned.

Page 25: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Remote Connection Location

.

If only 1 file matches the name typed, then we connect (function) to that computer

Otherwise, we build a copy locally and search the list, if no files meet the criteria typed, display “User Not Found”

Otherwise, ask which user and show a list of all that match; then connect (function) to that computer.

Page 26: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Automate Everyday Functions

Remote Connection Location

Finally – we launch the remote control software and pass in the computer name or IP address. We use a function we wrote called Connect:

f is the FILE that the user chose.

We grab the file name without the .ext

We open the file and read through it to the end. The last record is the newest one.

We create an array of the fields in the record and store the 3rd field in the B variable

We next create a shell to run our command then execute the run command and pass in the computer name.

The program launches and attempts to connect to the computer.

Page 28: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Other Ideas: A script that adds users to the active directory structure

Get export from SMS Read through file for new students Add new students as users to the system

Scripting to type data We have a UNIX based SMS Write a script that reads through a file of information and enters it into the unix

system. Repeat as many as necessary

Script to move / copy / ftp files This can be done via the shell command You can use the “SendKeys” option to type Allows for specific info within the script

Setting filename based on date User specific information to be inserted Flexible and reliable

Automate Everyday Functions

Page 29: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Questions?

Automate Everyday Functions

Page 30: Using Old School methods to make life easier. Overview  Introductions  Everyday problems and solutions  Security Cameras on the blink  Server Status.

Close:

My email address:[email protected]

This presentation and all files:http://w3.gilmerisd.org/tcea/dal13

Automate Everyday Functions


Recommended