-
Posts
2,293 -
Joined
-
Last visited
Content Type
Forums
News
20th
EduGeek EDIT Conference
Blogs
Everything posted by browolf
-
So that's a private network between the smoothwall and the outside clients. is it meant to be a subnet of the main network or totally separate unconnected?
-
what is this section asking for "SSL VPN network address:" There's an error in the log if I give it a free address on our internal network.
-
Thanks for pointers, I appreciate your advice from someone more experienced I myself have the config in a database and I got rid of the database to make it easier to post online. I have been pondering a config file as then I could probably compile the main script to an exe file for people unfamiliar with python.
-
This site is handy for comparing sizes https://phonesized.com/compare/#1853,1975
-
You may also be interested in https://github.com/browolf/network-speed-test-py
-
We use Accops Hysecure https://www.accops.com/products/hysecure for remote access to Sims and desktops which our previous NM got through Hanco global solutions.
-
I have this on Gnu General Public license here: https://github.com/browolf/Infrastructure-Monitor so you can fork it if you like. The other bit of code I did to see if I could do it. Feel free to utilize those concepts. 😄
-
I suggest using windows terminal as it's a lot nicer than the built in ide. With terminal you can run ps commands on the command line and it's colour coded. When you're in this situation it's helpful to deconstruct the script as much as possible to pinpoint the problem. On the commandline you can just type a variable name to get it's contents e.g PS D:\>$profiles https://apps.microsoft.com/store/detail/windows-terminal/9N0DX20HK701?hl=en-gb&gl=
-
Sorry, write-output is the command to print variables https://learn.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/write-output?view=powershell-7.2
-
I suggest print $profiles before trying to delete anything to check what is in that variable. also this looks to contain relevant information: https://stackoverflow.com/questions/70048684/remove-wmiobject-delete-user-profiles
-
how does it not work? $profiles is null or "$profiles | Remove-WmiObject" doesn't work?
-
done in python and you get an excel file out. It would have a problem if case was inconsistent but it wouldn't take much to fix. import pandas as pd from pyexcel.cookbook import merge_all_to_a_book import glob #pip install pandas #pip install pyexcel pyexcel-xlsx #file1lookup #Software,Type #Office,Desktop #Google,Browser df = pd.read_csv('file1lookup.csv', index_col=0).squeeze("columns") lookups = df.to_dict() #{'Office': ' Desktop', 'Google': ' Browser'} #file2data #Software #Ms Office 2010 #Ms Office 2013 #Google 123 df = pd.read_csv('file2data.csv', index_col=False) apps = df.software.values.tolist() #['Ms Office 2010','Ms Office 2013','Google 123'] merged_list = [[app, lookups[key]] for app in apps for key in lookups.keys() if key in app] df2 = pd.DataFrame(merged_list) df2.columns=['Software','Type'] print(df2) df2.to_csv("merged.csv", index=False) #output #Software,Type #Ms Office 2010,Desktop #Ms Office 2013,Desktop #Google 123, Browser #write excel file merge_all_to_a_book(glob.glob("merged.csv"), "merged.xlsx")
-
I wrote this because of having some issues and waiting for people to tell us there's a problem is less than ideal. It uses Flask which can be installed with Pip. https://www.w3schools.com/python/python_pip.asp If you have smoothwall, the pypi urls can be excluded from https inspection which stops certificate errors. I run the script as a service on an ubuntu server plugged into the core switch. We also have port forwarding on smoothwall so it's accessible from outside. At the moment it displays on a pc/ monitor in our office but planning to get a smart tv on the wall instead. The script works equally well on windows server or 10. You may wonder why it shows iterations on the page - the previous version that worked differently had an issue where it could stop working and you couldn't tell. The number represents every time the page is generated on the server so if the number is going up it's definitely working. It has a 10 second refresh which is specified in the html file. It checks open ports of devices which you can find with nmap. On windows servers I'm using the rdp port 3389 This is what it looks like for us. It will produce narrower tables on non windows devices aka mobiles. Server.py from flask import Flask, url_for, render_template, request import datetime as dt import socket import os #Config options======================================================= #device names and IPs do not represent real devices. levels = [(1, 'Core'), (2, 'Hosts'), (3, 'Servers'), (4, 'Buildings')] #Name, ip, port, level devices = [('Dc', '10.7.7.1', 3389, 3), ('Dc', '10.7.7.1', 3389, 3), ('Newt', '10.7.7.1', 22, 4), ('Music', '10.7.7.1', 22, 4), ('Science', '10.7.7.1', 22, 4), ('Sync', '10.7.7.1', 3389, 3), ('Develop', '10.7.7.1', 3389, 3), ('Imaging', '10.7.7.1', 22, 3), ('Term01', '10.7.7.1', 3389, 3), ('VPN', '10.7.7.1', 22, 3), ('Hyworks', '10.7.7.1', 3389, 3), ('catering', '10.7.7.112', 3389, 3), ('Solidworks', '10.7.7.1', 3389, 3), ('Core01', '10.7.7.1', 22, 1), ('Internet', '8.8.8.8', 53, 1), ('Core02', '10.7.7.1', 22, 1), ('ESX1', '10.7.7.1', 80, 2), ('Esx2', '10.7.7.1', 80, 2), ('HPSan', '10.7.7.1', 443, 2), ('Print', '10.7.7.1', 3389, 3), ('Pupils', '10.7.7.1', 3389, 3), ('Sql', '10.7.7.1', 3389, 3), ('Staff', '10.7.7.1', 3389, 3), ('Ubiq', '10.7.7.1', 22, 3), ('Ups1', '10.7.7.1', 22, 3), ('Vmw', '10.7.7.1', 22, 3), ('Voicebox', '10.7.7.1', 3389, 3), ('Screens', '10.7.7.1', 22, 3), ('Main', '10.7.7.1', 22, 4), ('ICT', '10.7.7.1', 22, 4), ('DT', '10.7.7.1', 22, 4), ('StuServ', '10.7.7.1', 22, 4), ('PE', '10.7.7.1', 80, 4), ('test', '10.7.7.119', 1234, 4)] #ipaddress of server running script. IPAddr="10.7.7.15" school="My School" #==================================================================== #reset iteration counter iteration_counter=0 template_dir = os.path.abspath('./') app = Flask(__name__, template_folder=template_dir) app.debug=True @app.route('/', methods=['GET', 'POST']) def index(): global iteration_counter htmlstr="" #determine device - used to determine user_agent = request.headers.get("User-Agent").lower() cells = 10 if "windows" in user_agent else 2 print(f"{user_agent} + {cells}") def test_port(a,p): s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.settimeout(1) result = s.connect_ex((a,p)) return False if result else True def build_table(dfList,c): #c is the max number of cells per row. You want less on a phone def buildCell(name,result): col = "red" if result == False else "#C4D79B" return f"</pre><table>{name} \n </table>\n"<br> newstr=""<br> #create new table<br> newstr+=("<table>\n\n") cellcount=1 for item in dfList: newstr+=("") name=item[0] res=item[1] newstr+=buildCell(name,res) if cellcount==c: newstr+=("") cellcount=0 cellcount+=1 newstr+=("") newstr+=("\n</table>\n\n")<br> return newstr <br><br> for level in levels: <br> #title<br> htmlstr+=(f"<h2>{level[1]}</h2>\n")<br> device_results=[]<br> filtered_devices = [tup for tup in devices if tup[3]==level[0]]<br> for device in filtered_devices:<br> result = test_port(device[1],device[2])<br> device_results.append([device[0],result])<br><br> htmlstr+=build_table(device_results,cells)<br> iteration_counter+=1<br> return render_template('index.html', htmlstr=htmlstr, iter=iteration_counter, school=school)<br><br>if __name__ == '__main__':<br> app.run(IPAddr,5001) index.html {{ school }} Up Monitor <br /> p {<br /> font-family: Shanti;<br /> font-size: 1.2em;<br /> margin: 4px;<br /> }<br /> <br /> H1 {<br /> font-family: Shanti;<br /> font-size: 3.2em;<br /> margin: 2px;<br /> }<br /> <br /> h2 {<br /> font-family: Shanti;<br /> margin: 10px;<br /> }<br /> <br /> td {<br /> padding: 8;<br /> font-family: Shanti;<br /> font-size: 1.2em;<br /> margin: 4px;<br /> text-align: center;<br /> padding-left: 10px;<br /> padding-right: 10px;<br /> <br /> }<br /> {{ school }} Up Monitor - Iter: {{ iter }} {{ htmlstr|safe }}
-
Is the point of this to create a list of laptops that need software updating?
-
You can write xlsx files with python https://www.geeksforgeeks.org/python-create-and-write-on-excel-file-using-xlsxwriter-module/#:~:text=XlsxWriter%20is%20a%20Python%20module,conditional%20formatting%20and%20many%20others.
-
If you're thinking of switching to octopus time tariffs there's historical information about the price of electricity here: https://www.energy-stats.uk/ Octopus API https://octopus.energy/blog/agile-smart-home-diy/#AgileAPI
-
Our HP servers+san are approx 5 years old and probably won't be replaced for 2. Previously we had an HPE extended warranty 4 hour 24x7 foundation care, though I discovered when it expired that that it was only active on 2/3 servers and no san. 😮 3rd party support has been suggested and is much cheaper. Is such a thing advisable or recommended?
-
barracuda but I'm not convinced we'll ever need to use it.
-
Adds domain users, we use azure to sync to 365 uses a csv file with the columns: firstName, surName, Admission number, computer class The computer teachers give out the login details. $thisyear = "2022" $inputf = "sims$($thisyear).csv" $output = "$($thisyear).csv" if (test-path -Path ".\$($output)"){ remove-item $output } function Get-Pass { #set arrays of words $colours = @('Wild','Bright','Busy','Green','Blue','Purple','Pink','Clever', "Cold","Happy","Sleepy","Brave","Short","Tall", "Helpful", "Clean", "Cute", "Super", "Sporty", "Silver", "Gold", "Fast") $animals = @('goat','elephant','penguin','donkey','snake','horse','rabbit','shark','mouse','tiger', 'zebra', 'panda', 'cabbage', 'potato', 'whale', 'bear', 'pencil', 'tree', 'fish', "frog", "toad") #make new password $col = Get-Random -InputObject $colours $ani = Get-Random -InputObject $animals return "1" + $col + $ani } import-csv $inputf | ForEach-Object { $password = Get-Pass $securepass = ConvertTo-SecureString -String $password -AsPlainText -Force #write-output "Processing $($_.firstName) $($_.surName)" #remove non characters $pattern="[^a-zA-Z]" $firstname = $_.firstName -replace $pattern $surname = $_.surName -replace $pattern #$username = $_.adno $office = $_.adno #construct username $username = "$(get-date -Format 'yy')$($firstname.substring(0,1))$($surname)" $res = ([ADSISearcher] "sAMAccountName=$username").FindOne() #if use name exists = bad if ($res -ne $null) { #need to find an acceptable username $prefix=2 while ($true) { $testuser = $username + $prefix #write-output ("testing $($testuser)") $res = ([ADSISearcher] "sAMAccountName=$testuser").FindOne() if ($res -ne $null) { #bad $prefix++} else { $username = $testuser break } } } $Displayname = "$($_.firstName) $($_.surName)" #test if CN name exists $res = ([ADSISearcher] "cn=$displayname").FindOne() #if displayname exists if ($res -ne $null) { #need to find an acceptable display name $prefix=2 while ($true) { $testdisplayname = $displayname + $prefix #write-output ("testing $($testuser)") $res = ([ADSISearcher] "cn=$testdisplayname").FindOne() if ($res -ne $null) { #bad $prefix++} else { $displayname = $testdisplayname break } } } #fields $email = "$($username)@domain.org".ToLower() $homedirectory = "\\server\pupils$\$($username)" $samaccountname = "$($username)".ToLower() $error.clear() try {New-ADUser -name $Displayname ` -AccountPassword $securepass ` -AccountNotDelegated $false ` -Description "Year starting $($thisyear)" ` -DisplayName $Displayname ` -EmailAddress $email ` -GivenName $_.firstName ` -Surname $_.surName ` -HomeDirectory $homedirectory ` -HomeDrive "Z:" ` -PasswordNeverExpires $false ` -SamAccountName $samaccountname ` -UserPrincipalName $email ` -Office $office ` -path "OU=Azure,OU=pupils,DC=school" ` -enabled $true ` -scriptPath "pupils.bat" } catch { write-output "Error adding $($firstname) $($surname)" Write-Output $error exit } #adduser to 365 students $error.Clear() try { Add-ADGroupMember -identity "365Students" -members $samaccountname } catch { Write-Output "Error adding user to 365Students" } #adduser to allstudentsecurity $error.Clear() try { Add-ADGroupMember -identity "allstudentsecurity" -members $samaccountname } catch { Write-Output "Error adding user to allstudentsecurity" } #adduser to allstudentTeam $error.Clear() try { Add-ADGroupMember -identity "AllStudentTeam" -members $samaccountname } catch { Write-Output "Error adding user to AllStudentTeam" } #create folder $User = Get-ADUser -Identity $samaccountname $homeshare = new-item -path $homedirectory -ItemType Directory -Force $acl = Get-Acl $homeshare $FileSystemRights = [system.Security.AccessControl.FileSystemRights]"Modify" $AccessControlType = [system.Security.AccessControl.AccessControlType]::Allow $InheritanceFlags = [system.Security.AccessControl.InheritanceFlags]"ContainerInherit, ObjectInherit" $PropagationFlags = [system.Security.AccessControl.PropagationFlags]"InheritOnly" $AccessRule = New-Object System.Security.AccessControl.FileSystemAccessRule ($User.SID, $FileSystemRights, $InheritanceFlags, $PropagationFlags, $AccessControlType) $acl.AddAccessRule($AccessRule) try { Set-Acl -Path $homeShare -AclObject $acl } catch { write-output "Error creating $($homeshare): $($error)"} If (!$error) {write-output "$homedirectory created"} Write-Output "Name: $($_.firstName) $($_.surName),Username:$($username) Password:$($password) Email: $($email) " $userOBJ = New-Object -TypeName psobject -Property @{ 'firstname' = $_.firstName 'surname' = $_.surName 'username' = $samaccountname 'password' = $password 'email' = $email #'form' = $_.form 'cclass' = $_.cclass } $userOBJ | Export-Csv $output -Append -NoTypeInformation }
-
You can specify the destination folder: pip install --target=d:\somewhere\other\than\the\default package_name
-
100% dark chocolate buttons
-
We have an issue internally with network speed. In order to try and isolate the problem I made a client & server application in python Both scripts can be turned into a --onefile exe files with pyinstaller It's important to run both files from a device and not a network share. The server side is a simple flask web server that sends a file instead of a webpage. I'm using the 1GB test file from thinkbroadband. The test file needs to be called file.iso and in a subfolder called files. from flask import Flask, send_file, request import socket import os import sys server_ip_address = socket.gethostbyname(socket.gethostname()) PORT = 50500 if getattr(sys, 'frozen', False): path = os.path.dirname(sys.executable) else: path = os.path.dirname(__file__) app = Flask(__name__) app.debug = True @app.route('/') def static_download(): try: print(f"Connection from {request.remote_addr}") return send_file(path + "\\files\\file.iso", download_name='file.iso') except Exception as e: print(f"{str(e)}") if __name__ == '__main__': app.run(host=server_ip_address, port=PORT) The client program downloads the test file every 5mins and calculates the average speed. It can cope if the server goes offline so you can move the server around. I have it writing a log to a network share. import requests import time import os import sys import socket from datetime import datetime #setup log file user = os.environ['USERNAME'] output = f"\\\\server\\share$\\tools\\lantest\\logs\\{user.lower()}.txt" if not os.path.exists(output): open(output,'w').close() def write_log_file(data): f = open(output, 'a') f.write(f"[{gettime()}] {data}") f.close() #figure out path, different if executable if getattr(sys, 'frozen', False): path = os.path.dirname(sys.executable) #print(f" * Executable Path = {path}") else: path = os.path.dirname(__file__) server_ip = input('Enter server ip address: ') url = f"http://{server_ip}:50500/" LOCALFILE = "file.iso" #test that the server is available sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) location = (server_ip, 50500) result_of_check = sock.connect_ex(location) def gettime(): now = datetime.now() return now.strftime("%Y-%m-%d %H:%M") if result_of_check == 0: print("Server Ready") while True: #test server is available sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) location = (server_ip, 50500) result_of_check = sock.connect_ex(location) if result_of_check == 0: #print("Server Ready") start = time.perf_counter() with requests.get(url, stream=True) as r: r.raise_for_status() with open(LOCALFILE, 'wb') as f: for chunk in r.iter_content(chunk_size=8192): f.write(chunk) download_time = round(time.perf_counter() - start,2) #find out file size file_size = round((os.path.getsize(path + "\\file.iso")/1048576),2) os.remove(path + '\\file.iso') average_speed = round((file_size/download_time)*8,2) print(f"[{gettime()}] Filesize={file_size}MB Time={download_time}secs Avg Speed={average_speed}Mbit") write_log_file(f"Filesize={file_size}MB Time={download_time}secs Avg Speed={average_speed}Mbit\n") else: now = datetime.now() datestr = now.strftime("%Y-%m-%d %H:%M") print(f"[{gettime()}] Server {server_ip} offline") write_log_file(f"Filesize={file_size}MB Time={download_time}secs Avg Speed={average_speed}Mbit\n") time.sleep(300) else: print("Server not found")
-
this site is super handy for size comparisons : https://www.phonearena.com/phones/size I would suggest Xiaomi mi 9 SE
-
We're having some issues with the network speed in some locations. Until I can write a program that operates internally I whipped this one up that uses a module called speedtest-cli which polls speedtest.net Be sure to install "speedtest-cli" and not "speedtest". The latter does nothing. It's set to run every 300 seconds (5mins) It saves the log on a network share with the computername as their username You can use Pyinstaller to convert it to a single exe file import speedtest from datetime import datetime import time import sys from socket import gethostname import os user = os.environ['USERNAME'] output = f"\\\\server\\share$\\tools\\speedtest\\{user.lower()}.txt" if not os.path.exists(output): open(output,'w').close() st = speedtest.Speedtest() st.get_best_server() def test(): s = speedtest.Speedtest() s.get_best_server() s.download() s.upload() res = s.results.dict() return res["download"], res["upload"], res['server']["lat"] #alternative to lat you might want res['ping] while True: d, u, p = test() now = datetime.now() datestr = now.strftime("%Y-%m-%d %H:%M") f = open(output, 'a') try: print (f"[{datestr}]Download: {round(d/1048576,1)}MB Upload: {round(u/1048576,1)}MB Latency: {p}") f.write(f"[{datestr}]Download: {round(d/1048576,1)}MB Upload: {round(u/1048576,1)}MB Latency: {p}\n") except Exception as ex: print (f"[{datestr}]An exception of {type(ex)} occurred, {ex.args}") f.write(f"[{datestr}]An exception of {type(ex)} occurred, {ex.args}\n") pass f.close() time.sleep(300) edit: corrected a situation where sometimes it didn't append. Changed the filename to username.
-
- 1
-
