Here are two very nice website page load check and trace route. It also provide recommendations on how to improve the page's performance.
http://www.monitis.com/pageload/
https://tools.pingdom.com
Thursday, November 2, 2017
Thursday, October 26, 2017
Output Result from df Command STDOUT to HTML
An example of where we need this is to display the output from the command df to a webpage. All the spaces and newline are all disregarded by HTML so it will display as one long line.
PRE Block in HTML
Solution: Wrap output such as this in a pre block in HTML.
STORAGE=$(df -PTh | column -t | sort -n -k6n)
echo "<pre>$STORAGE</pre>"
Though, HTML does not take care of preserving white space
To preserve the white space
In the output of the command chain is white space in the form of spaces and newlines (and you are lucky there are no tabs). You should make pipe the output into | sed 's/ / /g' | sed 's/^/<br>/':STORAGE=$(df -PTh | column -t | sort -n -k6n)| sed 's/ / /g' | sed 's/^/<br>/'to preserve whitespace. You can use that without getting the font changing effect that <pre>induces.
HTML Table Format
$ printf "<pre>%s</pre>\n" "$storage" >> file.htmlThere should be no need to include column. This is a candidate for a HTML table, and could be begotten by something like:df -PTh | \sed '1d' | \ sort -n -k6 | \ awk ' { printf "\n\t<tr>"; for (n = 1; n < 7; ++n) printf("\n\t<td>%s</td>",$n); printf "\n\t<td>"; for(;n <= NF; ++n) printf("%s ",$n); printf "</td>\n\t</tr>" } 'Wrap it in something like:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Disk space usage</title>
<style>
table, td, th {
border : 1px solid green;
}
th {
background-color: green;
color : white;
}
</style>
</head><body>
<table>
<tr>
<th>Filesystem</th>
<th>Type</th>
<th>Size</th>
<th>Used</th>
<th>Avail</th>
<th>Use%</th>
<th>Mounted on</th>
</tr>
<!-- df output awk table -->
<?php include('file.html'); ?>
</table>
</body>
</html>
Tuesday, October 24, 2017
Disable/Delete Inactive AD Users
Export to CSV file of Inactive users of over 90 days
Dsquery user "OU=Faculty Staff, OU=All Users,DC=SSIS,DC=EDU,DC=VN" –inactive 90 > inactiveUsers.csv
alternately
Locate Inactive Accounts
Use Powershell run as AdministratorTo find users that have not logged into the system and have not reset password for the last 90 days:
$90Days = (get-date).adddays(-90)
Get-ADUser -SearchBase "OU=Faculty Staff, OU=All Users,DC=SSIS,DC=EDU,DC=VN" -filter {(lastlogondate -notlike "*" -OR lastlogondate -le $90days) -AND (passwordlastset -le $90days) -AND (enabled -eq $True)} -Properties lastlogondate, passwordlastset | Select-Object name, lastlogondate, passwordlastset| export-csv inactiveUsers.csv –notypeinformation
Disable the Inactive Accounts
This will update the description [with a date to help determine the deleted date] and disable the account with using the PassThru switch:
Get-ADUser -SearchBase "OU=Faculty Staff, OU=All Users,DC=SSIS,DC=EDU,DC=VN" -filter {lastlogondate -le $90days
-AND passwordlastset -le $90days} -Properties lastlogondate,
passwordlastset | set-aduser -Description
((get-date).toshortdatestring()) –passthru | Disable-ADAccount
Delete Inactive Accounts
Now that we have all the accounts disabled, we need to delete them. We can use the Remove-ADObject cmdlet to delete the account, and then use Get-ADUser to read the Description attribute. To compare the date that the account was disabled to the current date, we can use Where-Object, as shown here:
$14days = (get-date).adddays(-14)
Get-Aduser -SearchBase
"OU=Faculty Staff, OU=All Users,DC=SSIS,DC=EDU,DC=VN" -Filter {enabled -eq $False}
-properties description | Where { (get-date $_.Description) -le $14Days}
| remove-adobject
Get-Aduser -SearchBase "OU=Faculty Staff, OU=All Users,DC=SSIS,DC=EDU,DC=VN" -Filter {enabled -eq $False}
-properties description | Where { (get-date $_.Description) -le $14Days}
| remove-adobject –whatif
Get-Aduser -SearchBase "OU=Faculty Staff, OU=All Users,DC=SSIS,DC=EDU,DC=VN" -Filter {enabled -eq $False}
-properties description | Where { (get-date $_.Description) -le $14Days}
| remove-adobject –confirm:$False
All-in-One Script
#import the ActiveDirectory Module
Import-Module ActiveDirectory
#Create a variable for the date stamp in the log file
$LogDate = get-date -f yyyyMMddhhmm
#Sets the OU to do the base search for all user accounts, change for your env.
$SearchBase = "OU=Faculty Staff, OU=All Users,DC=SSIS,DC=EDU,DC=VN"
#Create an empty array for the log file
$LogArray = @()
#Sets the number of days to delete user accounts based on value in description field
$Disabledage = (get-date).adddays(-14)
#Sets the number of days to disable user accounts based on lastlogontimestamp and pwdlastset.
$PasswordAge = (Get-Date).adddays(-90)
#RegEx pattern to verify date format in user description field.
$RegEx = '^(0[1-9]|1[012])[- /.](0[1-9]|[12][0-9]|3[01])[- /.](20)\d\d$'
#Use ForEach to loop through all users with description date older than date set. Deletes the accounts and adds to log array.
ForEach ($DeletedUser in (Get-Aduser -searchbase $SearchBase -Filter {enabled -eq $False} -properties description ) ){
#Verifies description field is in the
correct date format by matching the regular expression from above to
prevent errors with other disbaled users.
If ($DeletedUser.Description -match $Regex){
#Compares date in the description field to the DisabledAge set.
If((get-date $DeletedUser.Description) -le $Disabledage){
#Deletes the user object. This will
prompt for each user. To suppress the prompt add "-confirm:$False". To
log only add "-whatif".
Remove-ADObject $DeletedUser
#Create new object for logging
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "Name" -Value $DeletedUser.name
$obj | Add-Member -MemberType NoteProperty -Name "samAccountName" -Value $DeletedUser.samaccountname
$obj | Add-Member -MemberType NoteProperty -Name "DistinguishedName" -Value $DeletedUser.DistinguishedName
$obj | Add-Member -MemberType NoteProperty -Name "Status" -Value 'Deleted'
#Adds object to the log array
$LogArray += $obj
}
}
}
#Use ForEach to loop through all users
with pwdlastset and lastlogontimestamp greater than date set. Also added
users with no lastlogon date set. Disables the accounts and adds to log
array.
ForEach ($DisabledUser in (Get-ADUser
-searchbase $SearchBase -filter {((lastlogondate -notlike "*") -OR
(lastlogondate -le $Passwordage)) -AND (passwordlastset -le
$Passwordage) -AND (enabled -eq $True)} )) {
#Sets the user objects description attribute to a date stamp. Example "11/13/2011"
set-aduser $DisabledUser -Description ((get-date).toshortdatestring())
#Disabled user object. To log only add "-whatif"
Disable-ADAccount $DisabledUser
#Create new object for logging
$obj = New-Object PSObject
$obj | Add-Member -MemberType NoteProperty -Name "Name" -Value $DisabledUser.name
$obj | Add-Member -MemberType NoteProperty -Name "samAccountName" -Value $DisabledUser.samaccountname
$obj | Add-Member -MemberType NoteProperty -Name "DistinguishedName" -Value $DisabledUser.DistinguishedName
$obj | Add-Member -MemberType NoteProperty -Name "Status" -Value 'Disabled'
#Adds object to the log array
$LogArray += $obj
}
#Exports log array to CSV file in the temp directory with a date and time stamp in the file name.
$logArray | Export-Csv "C:\Temp\User_Report_$logDate.csv" -NoTypeInformation
Monday, October 23, 2017
Inkscape crashes every time opening existing svg file
Symptom
Every time I open an existing SVG generated by Inkscape, an error:terminate called after throwing an instance of 'Glib::ConvertError'
Emergency save activated!Note to get this error, you must launch Inkscape from a terminal. If you launch it from the GUI, you will only get a generic error that Inkscape has crashed and will close now. Useless piece of information.
Emergency save completed. Inkscape will close now.
Solution
Remove rm $HOME/.local/share/recently-used.xbelThursday, October 19, 2017
Banshee lost sound after HDMI usage
I had used the HDMI port to play a movie onto the TV and of course I used the HDMI as the sound output. By unplugging the HDMI cable from the TV, Banshee no longer was able to produce any sound through the built-in speakers, yet I had no way to release the output from the HDMI.
The solution was to plug my laptop back into the TV via HDMI then set the sound's output back to the built-in speaker before unplugging the HDMI.
System: Lenovo Ultrabook 15 Flex, Linux Mint 18.1, Banshee 2.6.3
The solution was to plug my laptop back into the TV via HDMI then set the sound's output back to the built-in speaker before unplugging the HDMI.
System: Lenovo Ultrabook 15 Flex, Linux Mint 18.1, Banshee 2.6.3