![]() You are now looking at the web site statistics for your domain. If not, the file gets created and populated with code. Click the view icon next to the domain name of interest. ![]() Run the updateawstats.sh to loop through all cpanel users to check if they have the file. " fi doneĪbove, you can see the code (located in updateawstats folder). " # Inserting code to echo ' LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %extra1" ExtraSectionName1="Time to serve requests (seconds" ExtraSectionCodeFilter1="" ExtraSectionFirstColumnTitle1="Number of seconds to serve the request" ExtraSectionFirstColumnValues1="extra1,(.*" ExtraSectionStatTypes1="H" ExtraTrackedRowsLimit=100000 ' > $AWSTATS_PATH # Setting the right permissions for each userĬhown -R $user: $user $AWSTATS_PATH else echo "AWStats file found for user: $user. It will make a file in the /home/$USER/tmp/awstats folder called and write the custom logformat, and the section name etc.Īfter this we recursively chown the folder and files to the user.ĬPANEL_USERS= "ls /var/cpanel/users/ " for user in ` $CPANEL_USERS ` doĪWSTATS_PATH= "/home/ $user/tmp/awstats/ " if then echo "AWStats file not found for user: $user. After this we parse the json data, and assign some variables. The cPanel hook system will return a json string that we can read from stdin, so we use simplejson (It's included in the repository) to do this. %s" % ( username, path), shell = True)Ībove, you can see the code (located in makeawstats folder). #if the folder exist (it should, since we just created it) - then chown it to the user. exists( path):įile_content = """ \ LogFormat="%host %other %logname %time1 %methodurl %code %bytesd %refererquot %uaquot %extra1" ExtraSectionName1="Time to serve requests (seconds)" ExtraSectionCodeFilter1="" ExtraSectionFirstColumnTitle1="Number of seconds to serve the request" ExtraSectionFirstColumnValues1="extra1,(.*)" ExtraSectionStatTypes1="H" ExtraTrackedRowsLimit=100000 """ #Create a file and write the content with open( "%s/%s" % ( path, awstats_file), 'w') as f: Path = '/home/%s/tmp/awstats' % username awstats_file = '' #if the awstats folder doesn't exist in the users tmp folder, then create it if not os. #We parse the json data using simplejson module hookdata = json. #!/usr/bin/python import sys, os from subprocess import Popen import simplejson as json #Read the cpanel hook info from stdin rawData = sys. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |