Presentation on theme: "Using Old School methods to make life easier. Overview Introductions Everyday problems and solutions Security Cameras on the blink Server Status."— Presentation transcript:
Overview Introductions Everyday problems and solutions Security Cameras on the blink Server Status updates Remote Connection Location Resources Other ideas / questions Close
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
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.
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.
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.
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)
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 Entrance 10.10.2.225 10.10.2.215 1 Hs 300 Hall East Entrance 10.10.2.224 10.10.2.217 1 Hs 300 Hall East View 10.10.2.223 10.10.2.217 1 Hs 300 Hall West Entrance 10.10.2.233 10.10.2.215 1 HS 300 Hall West View 1 Camera IP Power Unit Port Description
Security Cameras on the Blink DO WHILE NOT objInputfile.AtEndOfStream strBuff = objInputfile.readline strBuffArr = 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 time Assign this line to a variable Make an array of the stuff in the line Make a variable with the IP address Create an empty variable Opens a command object (DOS shell) Sends out a ping Gets the results of the ping
Security Cameras on the Blink IF 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 IF LOOP Check the results for TTL and write to the log If no TTL (ELSE) Get the name of the camera Write to the log – twice Execute function “checkPowerMan”
Security Cameras on the Blink Function 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 " & port RebootCamera PowerMan, port else objOutputfile.writeline "Camera is not connected to Power Management." end if LOOP objPowerFile.close End Function
Security Cameras on the Blink Function rebootCamera Uses specific code for that power unit. That code example is available in the download files. Scheduling We placed this script on a windows server and scheduled it to run every two hours with the task scheduler.
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
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.
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.
Server Status updates 1. 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
Server Status updates Check the status of the service and send an email
Server Status updates - outgoing email configuration
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.
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.
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
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.
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 software Then we open the filesystemobject to read files Next, we ask the user for a username (or computer name)
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.
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.
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 3 rd 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.
Scripting Center http://technet.microsoft.com/en- us/scriptcenter/bb410849.aspx Scripting Guy Blog http://blogs.technet.com/b/heyscriptingguy/ W3 Schools http://www.w3schools.com/Vbscript/default.asp
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