Skip to content

Instantly share code, notes, and snippets.

@ryanrhanson
ryanrhanson / dupefinder.sh
Created October 12, 2014 05:41
Lists all users with duplicate password (and their password) - Tested with up to Plesk 11.5
#!/bin/sh
#Lists all users that share a password with other users. Sorted by the duplicate passwords. This could probably be optimized in a hundred different ways, but it works.
#Grab our list of duplicate passwords
mysql psa -BNse "select password from mail left join domains on mail.dom_id = domains.id inner join accounts where mail.account_id = accounts.id and postbox = 'true' group by password having COUNT(*) > 1" | while read -r line
do
echo "====="
echo "Users with password $line"
echo "====="
@ryanrhanson
ryanrhanson / vyatta.pl
Created August 23, 2014 04:33
This horrible looking script will list all vyatta appliances on an account (from the Gateway Appliances section) along with a wealth of info about the one you select. It will also tell you the status of any vlan behind the vyatta (such as if it can support san or local disk virtual servers). Could be improved in many ways, I'm sure.
# This is optional and can be removed if you already have the SoftLayer
# directory that contains this module in your @INC path.
use lib 'Softlayer';
my %config = do 'apiconfig.pl';
use SoftLayer::API::SOAP;
use Data::Dumper;
use MIME::Base64;
use Data::Printer;
my $acctClient = SoftLayer::API::SOAP->new('SoftLayer_Account','',$config{apiUser},$config{apiKey});
@ryanrhanson
ryanrhanson / user_updateForumPassword.php
Created August 23, 2014 04:13
This corrects a deficiency in the SoftLayer portal, allowing you to update your forums.softlayer.com password so you can log into them directly, instead of going through the rest of the portal.
<?php
// apiconfig.php needs to have apiUsername, apiKey, and the path to the SLApi file that used to be in this script.
require_once('configuration/apiconfig.php');
$newPassword = readline("New password: ");
$client = SoftLayer_SoapClient::getClient('SoftLayer_Account', null, SLAPI_USER, SLAPI_KEY);
$user = $client->getCurrentUser();
@ryanrhanson
ryanrhanson / imageCapture.py
Created March 14, 2014 17:48
Flex image capture - Python
import SoftLayer
apiUser = <api user>
apiKey = <api key>
client = SoftLayer.Client(username=apiUser,api_key=apiKey)
serverId = <server id>
try:
@ryanrhanson
ryanrhanson / acctAlarms.py
Last active August 29, 2015 13:56
Retrieve all active nimsoft alarms on account
import SoftLayer
apiUser = (api username)
apiKey = (api key)
client=SoftLayer.Client(username=apiUser,api_key=apiKey)
acctalarms=client['Account'].getActiveAlarms()
for alarm in acctalarms:
hostname = client['Monitoring_Robot'].getObject(id=alarm['robotId'],mask="mask[softwareComponent[virtualGuest,hardware]]")
@ryanrhanson
ryanrhanson / hardwaresummary.pl
Created February 10, 2014 19:10
Server Info Dumper, with ipmi and os credentials included.
# This is optional and can be removed if you already have the SoftLayer
# directory that contains this module in your @INC path.
use lib 'Softlayer';
use SoftLayer::API::SOAP;
use Data::Dumper;
my %config = do 'apiconfig.pl';
@ryanrhanson
ryanrhanson / osreferencecodes.php
Last active January 4, 2016 20:59
Lists out all operating system reference codes available for ccis.
<?php
// apiconfig.php needs to have apiUsername, apiKey, and the path to the SLApi file that used to be in this script.
require_once('configuration/apiconfig.php');
$guestClient = SoftLayer_SoapClient::getClient('SoftLayer_Virtual_Guest', null, $apiUsername, $apiKey);
$objectMask = new SoftLayer_ObjectMask();
$objectMask->operatingSystems->itemPrice;
@ryanrhanson
ryanrhanson / images.rb
Last active January 1, 2016 09:19
Lists all instances on an account, prompts you to enter an ID for one of them. Creates an image template from this instance, and loops through all templates on an account until it finds one with a matching transaction id.
require './api.rb'
require 'date'
slapi = AuthApi.new
#api.rb and slapi are used in another file to handle my connection to the SoftLayer API.
#Feel free to include that information in this file if you wish.
begin
@ryanrhanson
ryanrhanson / last5logins.py
Last active December 29, 2015 17:49
Due to an Internal Server Error with http://sldn.softlayer.com/reference/services/SoftLayer_User_Customer/getLoginAttempts and http://sldn.softlayer.com/reference/services/SoftLayer_Account/getUsers, this is a temporary workaround to grab the last 5 login attempts for each portal user.
#Last 5 login attempts for User1
#- Successful login from 123.45.67.89 at 2013-11-28T15:29:32-06:00
#- Failed login from 123.45.67.89 at 2013-11-28T15:29:23-06:00
#- Failed login from 123.45.67.89 at 2013-11-28T15:29:22-06:00
#- Successful login from 123.45.67.89 at 2013-11-27T15:13:49-06:00
#- Successful login from 123.45.67.89 at 2013-11-26T08:35:12-06:00
#
#Last 5 login attempts for User2
#- Successful login from 123.45.67.89 at 2013-11-16T04:51:42-06:00
#- Successful login from 123.45.67.89 at 2013-11-16T04:50:29-06:00
@ryanrhanson
ryanrhanson / cancelsubnet.php
Created October 22, 2013 17:46
Cancel Subnet by IP
<?php
// Grab an IP address
$ip = readline("IP: ");
require_once dirname(__FILE__) . '/SoftLayer/SoapClient.class.php';
$apiUsername = 'set me';
$apiKey = 'set me too';