ehuk Posted March 23, 2009 Author Share Posted March 23, 2009 Yes ideally I would want a randomly generated number in that page which is assigned to the customer via some sort of script. 0 Quote Link to comment Share on other sites More sharing options...
Emerson Posted March 24, 2009 Share Posted March 24, 2009 Ok so I have a friend that was nice enough to get this script for us. It works and although it does show the GID on the URL it only allows you access to the graphs if you are logged in and they belong to you. Big thanks to Jon at http://www.websitecm.com for doing this on his own time and allowing me to share this code with you guys. Any feedback would be appreciated. Please see the attached file for the bandwith.php file as well as the graphs directory where the graphs need to be. Just upload everything to your WHMCS directory and make sure that cacti is exporting the graphs to the WHMCS/graphs directory. In clientareaproductdetails.tpl I added: {if $groupname eq "Dedicated Servers"} <p class="heading2">Bandwidth Graphs (Beta)</p> <table cellspacing="1" cellpadding="0" class="frame"> <tr> <td><table width="100%" cellpadding="2"> <tr> <td nowrap class="fieldarea"><strong>Total Monthly Usage:</strong></td> <td width="100%"><strong>Coming Soon</strong></td> </tr> </table> <table border="0" cellpadding="0" cellspacing="5" class="frame"> <tr> <td nowrap class="fieldarea">Daily Graph<br>(5 Min): </td> <td><div align="center"><img src="/WHMCS/bandwidth.php?id={$customfields.1.value}&image=1" /></div></td> </tr> <tr> <td nowrap class="fieldarea">Weekly Graph<br>(30 Min): </td> <td><div align="center"><img src="/WHMCS/bandwidth.php?id={$customfields.1.value}&image=2" /></div></td> </tr> <tr> <td nowrap class="fieldarea">Monthly Graph<br>(2 Hour): </td> <td><div align="center"><img src="/WHMCS/bandwidth.php?id={$customfields.1.value}&image=3" /></div></td> </tr> <tr> <td nowrap class="fieldarea">Yearly Graph<br>(1 Day): </td> <td><div align="center"><img src="/WHMCS/bandwidth.php?id={$customfields.1.value}&image=4" /></div></td> </tr> </table></td> </tr> </table> {/if} Any feedback would be appreciated. bandwidth.zip 0 Quote Link to comment Share on other sites More sharing options...
ehuk Posted March 25, 2009 Author Share Posted March 25, 2009 Hi Emerson, That looks awesome! I will give it a go once I get the the new Cacti server back up. Only problem is we have our Cacti and Website on two separate servers, and the built in FTP solution kinda sucks! So I will come up with something with rsync! 0 Quote Link to comment Share on other sites More sharing options...
Emerson Posted March 25, 2009 Share Posted March 25, 2009 Hey ehuk, Yes, it is working awesome. Knowing that nosies can not see other's graphs is nice. Yup, I spent a good time last night trying the FTP export and had no luck. I ended up doing a quick and dirty script to just rsync the graphs from the cacti server to the whmcs server and that is working pretty good. 0 Quote Link to comment Share on other sites More sharing options...
enotchnet Posted March 25, 2009 Share Posted March 25, 2009 I just tried this out and the logic seems to be there but I am not getting the graphs to load properly. I am seeing the image place holders instead (which is weird) and if I login as a user with another assigned GID and use the old URL then I get the image not found graphic. The images are present in the /graphs/ directory with a URL similar to /graphs/graph_1_1.png, /graphs/graph_1_2.png, etc. Any ideas? 0 Quote Link to comment Share on other sites More sharing options...
enotchnet Posted March 25, 2009 Share Posted March 25, 2009 I just tried this out and the logic seems to be there but I am not getting the graphs to load properly. I am seeing the image place holders instead (which is weird) and if I login as a user with another assigned GID and use the old URL then I get the image not found graphic. The images are present in the /graphs/ directory with a URL similar to /graphs/graph_1_1.png, /graphs/graph_1_2.png, etc. Any ideas? I tried breaking this down to see if the query itself from a raw mysql perspective would work with our WHMCS installation. Thus far, I have created a custom client field called id and then on one of our test accounts, I have assigned a value of 5. Our domain is similar to blah.domainname.com, so the bandwidth.php file is located at the root of the subdirectory and we have a graphs sub-folder which is keeping all of our .png files. If i go directly to the URL based on how the code is calling it then the image loads however once I login as the test user I see the default "data not available" image. From what I have been able to figure out we have a situation where the query is resulting in two relid entries with different values and fieldids. However, I am not sure if this is causing a problem. I tried adding an AND v.fieldid=21 (21 is the fieldid assigned to our custom customer field) but this did not work at all. If I commend out the section where the security check is performed then the graphs load fine. So this confirms that it is something to do with this "check". I assigned an id value to a user that does not have this problem and the images still do not load the only thing that is left could be where the comparison of uid and h.userid. If i do this logic manually using mysql syntax then it works fine and the value is what I am expecting but the code doesn't yield any results at runtime. To the people that got this working, any ideas? Also, if the id field is created as a customer field then how is it being protected? As a user I can do to my details and change my field id value and view graphs from other users and the code does not have the logic to retrieve the value of the custom id field if it is created as an admin only field. I see in the example, that a custom page was created so does this mean that the if customfields element was/should be removed from the clientareadetails.tpl? 0 Quote Link to comment Share on other sites More sharing options...
gbwebhosts Posted April 23, 2009 Share Posted April 23, 2009 I've got the code for APC PDUs I'll post tonight. Does reboot, poweroff, and restart for multiple power strips. 0 Quote Link to comment Share on other sites More sharing options...
ganesh.rao Posted June 1, 2009 Share Posted June 1, 2009 I've got the code for APC PDUs I'll post tonight. Does reboot, poweroff, and restart for multiple power strips. 'Tonight' went back a few weeks ago Would be helpful if you could post it now. Thanks 0 Quote Link to comment Share on other sites More sharing options...
gbwebhosts Posted June 7, 2009 Share Posted June 7, 2009 function manageAPCPort($apcip, $apcport, $apcpass, $action) { $apcportcontrolmib = ".1.3.6.1.4.1.318.1.1.12.3.3.1.1.4."; $mib = $apcportcontrolmib.$apcport; $result = snmpset($apcip, $apcpass, $mib, i, $action); return $result; } function pdu_action($pdus, $action) { $power = explode("\n",$pdus); foreach($power as $value): list($pdu,$pdu_port) = split(":",$value); $sqlresult = mysql_query("SELECT address, username, password, community, Type FROM mod_pdu WHERE name='".strtoupper($pdu)."'"); $row = mysql_fetch_row($sqlresult); $pdu_address = trim($row[0]); $pdu_username = trim($row[1]); $pdu_password = trim($row[2]); $pdu_community = trim($row[3]); $pdu_type = trim($row[4]); $pdu_port = trim($pdu_port); $pdu_type = "APC"; switch (strtoupper($pdu_type)) { case "APC": switch (strtoupper($action)) { case "OFF": $pdu_action = "2"; break; case "REBOOT": $pdu_action = "3"; break; default: $pdu_action = "1"; break; } $apc = manageAPCPort($pdu_address, $pdu_port, $pdu_community, $pdu_action); break; } if (!$apc){ $result .= $value." could not be set to ".$action."<br>"; } endforeach; return $result; } function modulename_AdminCustomButtonArray() { # This function can define additional functions your module supports, the example here is a reboot button and then the reboot function is defined below $buttonarray = array( "Reboot" => "reboot", "Power ON" => "on", "Power OFF" => "off", ); return $buttonarray; } function modulename_reboot($params) { return "asdfasf".pdu_action($params['customfields']['PDU'], "REBOOT"); } function modulename_on($params) { return pdu_action($params['customfields']['PDU'], "ON"); } function modulename_off($params) { return pdu_action($params['customfields']['PDU'], "OFF"); } 0 Quote Link to comment Share on other sites More sharing options...
gbwebhosts Posted June 7, 2009 Share Posted June 7, 2009 remove the "asdfasf". on the reboot. 0 Quote Link to comment Share on other sites More sharing options...
aXeR Posted June 12, 2009 Share Posted June 12, 2009 (edited) Would anyone be willing to integrate this useful tool (Cacti) into my WHMCS install for a fee? If so, could you kindly email jon (at) racksrv (dot) net to discuss Edited June 12, 2009 by aXeR 0 Quote Link to comment Share on other sites More sharing options...
enotchnet Posted June 17, 2009 Share Posted June 17, 2009 function manageAPCPort($apcip, $apcport, $apcpass, $action) { $apcportcontrolmib = ".1.3.6.1.4.1.318.1.1.12.3.3.1.1.4."; $mib = $apcportcontrolmib.$apcport; $result = snmpset($apcip, $apcpass, $mib, i, $action); return $result; } function pdu_action($pdus, $action) { $power = explode("\n",$pdus); foreach($power as $value): list($pdu,$pdu_port) = split(":",$value); $sqlresult = mysql_query("SELECT address, username, password, community, Type FROM mod_pdu WHERE name='".strtoupper($pdu)."'"); $row = mysql_fetch_row($sqlresult); $pdu_address = trim($row[0]); $pdu_username = trim($row[1]); $pdu_password = trim($row[2]); $pdu_community = trim($row[3]); $pdu_type = trim($row[4]); $pdu_port = trim($pdu_port); $pdu_type = "APC"; switch (strtoupper($pdu_type)) { case "APC": switch (strtoupper($action)) { case "OFF": $pdu_action = "2"; break; case "REBOOT": $pdu_action = "3"; break; default: $pdu_action = "1"; break; } $apc = manageAPCPort($pdu_address, $pdu_port, $pdu_community, $pdu_action); break; } if (!$apc){ $result .= $value." could not be set to ".$action."<br>"; } endforeach; return $result; } function modulename_AdminCustomButtonArray() { # This function can define additional functions your module supports, the example here is a reboot button and then the reboot function is defined below $buttonarray = array( "Reboot" => "reboot", "Power ON" => "on", "Power OFF" => "off", ); return $buttonarray; } function modulename_reboot($params) { return "asdfasf".pdu_action($params['customfields']['PDU'], "REBOOT"); } function modulename_on($params) { return pdu_action($params['customfields']['PDU'], "ON"); } function modulename_off($params) { return pdu_action($params['customfields']['PDU'], "OFF"); } Do you have instructions for getting this feature setup like what files to edit? 0 Quote Link to comment Share on other sites More sharing options...
UNIXIELHOST Posted June 18, 2009 Share Posted June 18, 2009 Try this: http://www.cacti.net/download_cacti.php You can download it and ingerate with WHMCS? 0 Quote Link to comment Share on other sites More sharing options...
devinvst Posted July 20, 2009 Share Posted July 20, 2009 I took a different approach: In cacti, I made the graph title "switch-x-x-x-x#4 - ProductID:125" (the WHMCS product ID) I passed bandwidth.php the product ID, and had it check the product ID with the user ID for verification. My cacti is hosted on a remote server, so I opened up MySQL to the WHMCS host to check for the ProductID in the title and get the local graph ID. Then bandwidth.php readfile()s the exported graph PNG from the remote server. I think I made it a little complicated but this way you don't need custom fields in WHMCS, as you can't add a custom field to an entire product group (right?) 0 Quote Link to comment Share on other sites More sharing options...
TheHostingHeroes Posted August 11, 2009 Share Posted August 11, 2009 hi ive been trying to get this working all day. i have set cacti every 5 mins to put the files in /graph/ which it is doing just fine. i have a custom port "SwitchPort" and configured the dedi server to use port 11 (For example) in whmcs. in clientareproducts i have ie img src="/bandwidth.php?id={$SwitchPort.1.value}&image=1 then when I login as clients it shows the no data available image. /graph/ has ie graph_11_1.png etc 0 Quote Link to comment Share on other sites More sharing options...
Michael.Terence Posted August 12, 2009 Share Posted August 12, 2009 (edited) I did mine manually, like so: <img src="https://...../bandwidth/graph_{$customfields.1.value}_1.png" alt="" /> Edited August 12, 2009 by Michael.Terence 0 Quote Link to comment Share on other sites More sharing options...
Michael.Terence Posted August 12, 2009 Share Posted August 12, 2009 Now I just need a way to parse the RRD file to get the monthly bandwidth usage in plain text... anyone have any ideas? 0 Quote Link to comment Share on other sites More sharing options...
Derek Posted August 29, 2009 Share Posted August 29, 2009 I really like this, I will take a look at this later. 0 Quote Link to comment Share on other sites More sharing options...
kannan Posted September 7, 2009 Share Posted September 7, 2009 Very nice. Well done! Hi, can you please advice me how to enable readfile function on the sever. Regards, kannan 0 Quote Link to comment Share on other sites More sharing options...
ehuk Posted September 7, 2009 Author Share Posted September 7, 2009 hi ive been trying to get this working all day. i have set cacti every 5 mins to put the files in /graph/ which it is doing just fine. i have a custom port "SwitchPort" and configured the dedi server to use port 11 (For example) in whmcs. in clientareproducts i have ie then when I login as clients it shows the no data available image. /graph/ has ie graph_11_1.png etc Have you setup rsync to get the graphs from your cacti machine to the /graphs/ folder? Is the custom field working correctly? Emerson I have only recently played around with your script and it worked perfectly! Many thanks. 0 Quote Link to comment Share on other sites More sharing options...
zoilodiaz Posted September 7, 2009 Share Posted September 7, 2009 hello, maybe this help http://forum.whmcs.com/showthread.php?t=23223&highlight=modules 0 Quote Link to comment Share on other sites More sharing options...
bpanas Posted October 16, 2009 Share Posted October 16, 2009 We have finished our dedicated server monitor .. this plug in monitors bandwidth usage on a rolling month, gives customers real time stats and bills for bandwidth overage using the billable option in WHMC. It gives the admin the ability to turn off and on servers with the click of a button, send emails, projections and basically is a completed pkg. We will be adding 95th percentile in the next iteration. please watch demo 1 and demo 2.. they are a continuation. we will be making this plug-in available shortly Bill 0 Quote Link to comment Share on other sites More sharing options...
TheHostingHeroes Posted October 16, 2009 Share Posted October 16, 2009 Hey Looks excellent DO you have any pricing info yet? 0 Quote Link to comment Share on other sites More sharing options...
NorCal Internet Posted October 22, 2009 Share Posted October 22, 2009 Any updates? Available? Pricing? 0 Quote Link to comment Share on other sites More sharing options...
dinek Posted October 27, 2009 Share Posted October 27, 2009 Looks interesting. Waiting for updates. 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.