All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.
SolusVM/WHMCS IP Auditor
I've noticed that, at times, when WHMCS will terminate a client, either auto-term or when we do it manually, the VPS container won't actually be removed from the node, and Solus still thinks it's an active product. Manually auditing WHMCS/Solus inventory accuracy is hellish, and there's not really any other automatic methods to determine if there are containers in Solus that are 'untracked' by WHMCS.
Obviously, giving out free product is Bad, so I've written this script to:
-retrieve a list of nodes from Solus
-retrieve a list of IPs by node from Solus
-on a per-IP basis, interface with the WHMCS DB to determine if WHMCS knows about the IP address
-generates a list of IPs that are not in WHMCS
Here's a screenshot of the output:
You can get it from:
https://github.com/damianharouff/solus-ip-audit
Be sure to read the README for basic setup and usage information.
Comments
You rock again!
I'll have no use for this, but that script looks pretty clean and sexy, great job Damian.
Got an error in the middle of my list of IPs.
PHP Notice: Undefined variable: badcount in /root/checkips.php on line 101
Looking at the code, he doesn't actually define the variable before using it..
Could probably just add
$badcount = 0;
after he defines tempiplist to fix that.Seems nifty, will check it out!
YAY! Node audits are boring anyway.
Nice script, but I don't think it'll work well for hosts with VPS resellers because it won't detect VPS reseller's clients (end users) IP simply because those end-users of theirs will not be in WHMCS.
and that's what I just added in
Only checks the username prefix so if resellers have the same prefix it'll be a no go. Stupid SolusVM Admin API has nothing to check the who's the reseller.
Line 96, missing ' to parse $ip.
assignedips LIKE "%.$ip.%\n")');
to
assignedips LIKE "%'.$ip.'%\n")');
+1 for using PDO instead of mysql_*, -1 for not actually using PDO properly.
Thanks for the feedback, everyone!
I updated it to define $badcount as a variable. I've put the update on git (or "pushed it to github" or whatever the correct terminology is); try now.
Thanks for the info, did not know!
Might be able to use http://docs.solusvm.com/admin_api#list_reseller_usernames to get a list of usernames that are resellers.. not sure if that only returns the reseller's usernames, or if it also returns the reseller's client's usernames too. We don't have resellers to be able to test
Thanks, I had actually fixed this last night and was trying to put it on git, but then the cable modem crapped out, and I then got tired of messing with it, so I went to bed.
I will freely admit that I learned PDO through trial and error. What have I done wrong? Feel free to slap me around a bit.
Made a commit and pushed it to master ;-)
@Damian
You should have used prepare http://php.net/manual/en/pdo.prepare.php instead of inserting the variables directly.
Thanks. I've used github quite a bit for using other people's software, but it's only recently that I have started to put my own things on it.
Thanks, additionally @Wintereise slapped me around a bit about it too, so I have a good idea of what I need to do. I will implement this this evening.
You should have used prepare http://php.net/manual/en/pdo.prepare.php instead of inserting the variables directly.
It's on github so I think you can send him some changes as well.
Indeed, however, I do need to learn the proper way, so i'd rather have people tell me "hey stupid, you did it wrong, here's the basic idea of what you need to do" than have it fixed for me.
An ignore list would be nice, I kinda have my own VMs that aren't in WHMCS. I think most other providers would have a couple too?
Just wondering, does the check include secondary IPs or just the primary IP for the VM?
It will only lists IP's that are active/live/assigned via solusvm and not present on whmcs right? Or will it also list unassigned ips?
@Kenshin, 8 so far. :geek:
I thought about this too, since we also have VMs in Solus that aren't tracked in WHMCS. Haven't thought of a brainy way to make this happen, though.
The Solus API call returns a list of all IPs in use by the nodeid.. this seems to get all of them, as it claims we have 1004 IPs in use, and that seems correct.
Yes, it gets a list of all IPs that Solus thinks are in use, then compares them to the "dedicatedip" and "assignedips" fields on WHMCS, which are these fields that you see in WHMCS:
You ROCK!
Yeah, I'll check this out now and let you know how goes.
Great work Damian! Works flawlessly
+1
Quick hack, not the most efficient but it works.
Also, minor hack on the assignedip matching, I had one WHMCS assigned IP record without a newline, didn't match, so I added a match for last line.
assignedips LIKE "%'.$ip.'%\n" OR assignedips LIKE "%'.$ip.'$")');
Though in all honesty, the SQL query is pretty inefficient since it's being run repeatedly per IP. Probably would have been better to do a single grab of all the records and do 2 way matching between the two lists.
Awesome thanks for making this!
Any idea why I get this:
Parse error: syntax error, unexpected '$postfields' (T_VARIABLE) in /home/audit.php on line 34
Unexpected? Maybe declaring the array first would help, weird. ( $postfields = array(); )
Try updating it first though.
Kinda got the PDO prepare thing worked on... had a bunch of other fires to put out.
Was this for a single IP?
Indeed, I considered this, however, I chose to query for every IP instead of using PHP for sorting. Reason was that, logically, MySQL should be better at answering queries with data, since that's what it's built for, than PHP would be at sorting data. I don't know if it's truly slower.
On the other hand, I don't expect to run this more than every few weeks, or monthly or so, and:
Is fast enough for me
Did you download this from github via git, or copy/pasted out of browser? What version of PHP are you using? You can get this information by running: php -v
Didn't work
@Damian
Copied+pasted from the browser
PHP 5.4.12 (cli) (built: Feb 27 2013 14:30:00)
Copyright (c) 1997-2013 The PHP Group
Zend Engine v2.4.0, Copyright (c) 1998-2013 Zend Technologies
with the ionCube PHP Loader v4.2.2, Copyright (c) 2002-2012, by ionCube Ltd.
Now add a feature so it can check the vserverID and IP match, cause I know mine has a lot that do not match correctly.