Error: The content directory has no items directory


Got this error when you want to add second Portal site on ArcGIS 10.5.1? Try this:

Update the Portal Directory from local source to shared directory and make sure to change \ (slash) with / (backslash). Example:

{
“type”:”fileStore”,
“provider”:”FileSystem”,
“connectionString”:”//server01/prod/Portal_Content”,
“isConnectionStringEncrypted”:false
}

 

Hope this works. Good Luck!!!!

Advertisements

How many time did your service been hit?


One day some one, could be your manager, customer or some one else, asked you if you could give them metric on how many time in a month or week your services have been hit. There are many ways to answer this and many tools available out there. Here, I would like to give you a free tool or you could say it as script where you can run and give an idea to your requester how many hits on your ArcGIS services.You can also modify this script to not only produce a csv file but also input into database, so everyone can access the data.

 

Good Luck,

 


#-------------------------------------------------------------------------------
# Name: HitStat.py
# Purpose: Gather hit statistics info in the last 24 hours. the statistics will be stored in DB and csv file
# Since there is limitation in Esri side how it pulls the data to max. 10,000 records from log file,
# We divide to an hour in 24 hours time frame. Even though each our has max 10,000 records at least
# it can show a close accurate data. The steps are: Pul each hour data into a temp csv and read the
# data from there and store in csv and database.
# Queries the logs and writes statistics on map service activity during the past 24 hours
# Sends email if no log data, indicating someone has changed ArcGIS Server Log settings
# The data is based on CODE = 100004 and 8521
#
# Author: mlou1_p
#
# Created: 04/13/2016
# Copyright: (c) mlou1_p 2016
# Licence: <your licence>
#-------------------------------------------------------------------------------


# For Http calls
import httplib, urllib, json

# CSV Module
import csv

# Datetime module
import datetime

# For system tools
#import arcserver
import sys, time, arcserver, arcpy, re

# For sending email
import smtplib
import mimetypes
import email
import email.mime.application

# For reading passwords without echoing
import getpass


#Get the current date
now = datetime.datetime.now()

#Defines the entry point into the script
def main(argv=None):
# Print some info
print
print "This tool is a script that queries the ArcGIS Server logs and writes a report"
print " summarizing all map service draws within the past 24 hours."
print


# ########################################################################################################################################
#--- START OF VARIABLE--------------------------------------------------------------------------------------------------------------------
# ########################################################################################################################################


# Ask for admin/publisher user name and password
#username = raw_input("Enter user name: ")
username = "ARCGISADMIN"
#password = getpass.getpass("Enter password: ")
password = "Abc123$"


# Ask for server name
#serverName = raw_input("Enter Server name: ")
serverName = "ARCGISSERVER01"
serverPort = 6080

# Connect to Oracle to put the data
##tbl = r"\\stlArcGISsvr\GIS_Data\data\ADM\GEOSPATIAL@GEORACLE.sde\GEOSPATIAL.HIT_STATISTICS" #turn off for testing

# Ask for text file path
filePath = "//stlArcGISsvr//d$//temp//HitStat//HitStat_" + str(now.year) + str(now.month) + str(now.day) + ".txt"
rawPath = "//stlArcGISsvr//d$//temp//HitStat//raw.csv"


# For email purposes
From = "noreply@esri.com"
Receivers = ["DL-DOOOH@esri.com"] # must be a list
EmailBody = "No Draw Time Log for DEV environment. Check ArcGIS Server Log Settings."

# For Testing Purpose please use this to look for specific date
#Date time start with
date_time = '04.12.2016 00:00:01'
pattern = '%m.%d.%Y %H:%M:%S'
##startTime = int(time.mktime(time.strptime(date_time, pattern))*1000)

startTime = int(round(time.time() * 1000)) # Current time and date


#millisecondsToQuery = 86400000 # One day
##millisecondsToQuery = 3600000 # One hour in millisecond
##n = 24 #1 hours X 24 = a day
millisecondsToQuery = 1800000 # half an hour in millisecond (30 minutes)
n = 48 # 30 min X 48 = a day


# ########################################################################################################################################
#--- END OF VARIABLE--------------------------------------------------------------------------------------------------------------------
# ########################################################################################################################################



hitDict = {}
counter = 0
timeStamp = '%04d' % now.year + '%02d' % now.month + '%02d' % now.day


# Open text file and write header line
summaryFile = open(filePath, "w")
header = "Now;Service;Number of hits\n"

#Raw Data
rawData = open(rawPath,"w")
rawData.write("Service;Code"+"\n")


# Get a token
token = getToken(username, password, serverName, serverPort)
if token == "":
print "Could not generate a token with the username and password provided."
return

#insert cursor variables in Oracle
##fields = ["TIME", "SERVICE", "HITS"] #turn off for testing

#insert cursor
##insCur = arcpy.da.InsertCursor(tbl, fields) # turn off insCur for testing purposes



# Construct URL to query the logs
logQueryURL = "/arcgis/admin/logs/query"

##endTime = startTime - millisecondsToQuery

# Need these variables to calculate average draw time for an ExportMapImage call
mapDraws = 0
totalDrawTime = 0
timecount = 0

while (timecount < n):

if timecount <> 0:
rawData = open(rawPath,"a")

timecount = timecount + 1
print "time count = " +str(timecount)
xTime = millisecondsToQuery * timecount
#startTime = millisecondsToQuery + endTime
endTime = startTime - millisecondsToQuery
print "xTime = " + str(xTime)
print "Start Time = " + str(startTime)
print "End Time = " + str(endTime)


#logFilter = "{'services':'*','server':'*','machines':'*'}"
logFilter = "{'codes':[100004, 8521],'services':'*','server':'*','machines':'*'}" #Correct Code: 100004, changed to 12345 for test purposes

params = urllib.urlencode({'level': 'FINE', 'startTime': startTime, 'endTime': endTime, 'filter':logFilter, 'token': token, 'pageSize': 10000, 'f': 'json'})
headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

# Connect to URL and post parameters
httpConn = httplib.HTTPConnection(serverName, serverPort)
httpConn.request("POST", logQueryURL, params, headers)

# Read response
response = httpConn.getresponse()
if (response.status != 200):
httpConn.close()
print "Error while querying logs."
return
else:
data = response.read()

# Check that data returned is not an error object
if not assertJsonSuccess(data):
print "Error returned by operation. " + data
else:
print "Operation completed successfully at " + str(timecount) + " hour"

# Deserialize response into Python object
dataObj = json.loads(data)
httpConn.close()

# Iterate over messages
for item in dataObj["logMessages"]:

# if item["message"] == "End ExportMapImage":
##elapsed = float(item["elapsed"])
keyCheck = item["source"]
code = str(item["code"])

msg = item["message"]
##print "Ori msg : " + msg

# If Code is 100004
if '8521' not in code:
rawData.write(keyCheck+ ";" + str(code) + "\n")
print "KeyCheck = " +keyCheck

#Input the result into temporary dictionary (hitDict)
if keyCheck in hitDict:
stats = hitDict[keyCheck]

# Add 1 to tally of hits
stats[0] += 1

else:
# Add key with one hit and total elapsed time
hitDict[keyCheck] = [1]


# If Code is 8521
else:
if 'services/' in msg:
if 'Server' in msg:

# Trim/Slice data to get Service Name

astrVerify = "arcgis/rest/services/"
a = msg.find(astrVerify)
msg = msg[a+len(astrVerify):]

bstrVerify = "Server"
b = msg.find(bstrVerify)
msg = msg[0:b+6]

# Replace the message that has second / with .
msg = re.sub(r'^((.*?/.*?){1})/', r'\1.', msg)

rawData.write(msg + ";" + str(code) + "\n")
print "KeyCheck = " +msg
keyCheck = msg



#Input the result into temporary dictionary (hitDict)
if keyCheck in hitDict:
stats = hitDict[keyCheck]

# Add 1 to tally of hits
stats[0] += 1

else:
# Add key with one hit and total elapsed time
hitDict[keyCheck] = [1]


startTime = endTime
rawData.close()



## #If no data, send email to GEOSPATIAL
## if hitDict == {}:
## EmailSubject = "No Draw Times found in log."
## for address in Receivers:
## EmailAttachments(address, From, EmailSubject, EmailBody)
##
## print "no draw times found!"



#Read the Raw Data
# Open text file and write header line
summaryFile = open(filePath, "w")
header = "Now;Service;Number of hits\n"
summaryFile.write(header)
print hitDict


# Read through dictionary and write totals into file
for key in sorted(hitDict.iterkeys()):

# Calculate average elapsed time
totalDraws = hitDict[key][0]

# Construct and write the comma-separated line
line = timeStamp +"," + key + "," + str(totalDraws) + "\n"

fields = ["TIME", "SERVICE", "HITS"]
##insCur.insertRow(( timeStamp, key, str(totalDraws) )) # comment out for testing


summaryFile.write(line)

summaryFile.close()
return








# ########################################################################################################################################
#--- DEFINED ALL FUNCTIONS----------------------------------------------------------------------------------------------------------------
# ########################################################################################################################################



# A function to generate a token given username, password and the adminURL.
def getToken(username, password, serverName, serverPort):
# Token URL is typically http://server[:port]/arcgis/admin/generateToken
tokenURL = "/arcgis/admin/generateToken"

# URL-encode the token parameters
params = urllib.urlencode({'username': username, 'password': password, 'client': 'requestip', 'f': 'json'})

headers = {"Content-type": "application/x-www-form-urlencoded", "Accept": "text/plain"}

# Connect to URL and post parameters
httpConn = httplib.HTTPConnection(serverName, serverPort)
httpConn.request("POST", tokenURL, params, headers)

# Read response
response = httpConn.getresponse()
if (response.status != 200):
httpConn.close()
print "Error while fetching tokens from admin URL. Please check the URL and try again."
return
else:
data = response.read()
httpConn.close()

# Check that data returned is not an error object
if not assertJsonSuccess(data):
return

# Extract the toke from it
token = json.loads(data)
return token['token']





#A function that checks that the input JSON object
# is not an error object.
def assertJsonSuccess(data):
obj = json.loads(data)
if 'status' in obj and obj['status'] == "error":
print "Error: JSON object returns an error. " + str(obj)
return False
else:
return True



# A function to send email
def EmailAttachments(address, From, EmailSubject, EmailBody):
sender = From
receiver = address

# Create a text/plain message
msg = email.mime.Multipart.MIMEMultipart()
msg['Subject'] = EmailSubject
msg['From'] = sender
msg['To'] = receiver


# The main body is just another attachment
body = email.mime.Text.MIMEText(EmailBody)
msg.attach(body)

# Send the message via our own SMTP server, but don't include the
# envelope header.
smtpObj = smtplib.SMTP('mail.monsanto.com')
smtpObj.sendmail(sender, address, msg.as_string())
smtpObj.quit()



# Script start
if __name__ == "__main__":
sys.exit(main(sys.argv[1:]))</pre>
<pre>

A Request from one of my blog readers


Folks,

Some of you might come to my blog after googling around and as part of my mission to publish my notes is to help and share. Below here is a request came from Sepideh who is asking some of you or all of you via my blog to support his effort in creating a new Site on StackExchange.

Thank you.

 

 

Dear Muryadi,
As you might have already noticed, there aren’t much places on the net which professionally concentrate on remote sensing and photogrammetry and gather related researchers all over the world to exchange knowledge and improve the community. So I’ve proposed to build a new Q&A site for remote sensing and photogrammetry which is possible through the Area51 zone of StackExchange. (For further information, you may refer to the following links: FAQ and QA site.pdf)
In order to convince the stackexchange management team about the necessity of creating such a site, I need the support of the community. So regarding the close relationship between GIS and remote sensing would you please promote the idea on your website and ask your user to follow this link?
Remote Sensing and Photogrammetry Q&A site proposal
As you can see in the right hand side of the above page, we need 23 more questions with a score of 10 or more to jump to the next phase of the site creation process. Therefore, it would be appreciated if you could tell your users to take some minutes to judge the proposed questions by voting them up and down and commenting on them based on their relevance to the field of remote sensing and photogrammetry. (If you wish to upvote, please upvote the questions that have less than 10 scores not the ones that have been upvotted more than 10 times. At this step upvoting under 10 score questions is even more important than following. However, following is still necessary)
Also could you please ask them to add at least one expert question to the list if you have enough time? (This is needed to decide about the content of the future site)
King Regards,
Links:
Area51 zone : http://goo.gl/yYmjAv
StackExchange : http://goo.gl/MUwsne
FAQ : http://goo.gl/B5BeLa
QA site.pdf : https://goo.gl/br2Pm3
stackexchange management team :http://goo.gl/bVsbyD
Remote Sensing and Photogrammetry Q&A site proposal : http://goo.gl/z3jRfN
—————————————————————-
Sepideh Abadpour
M.Sc. Student in Remote Sensing
University of Tehran, College of Engineering,
School of Surveying and Geospatial Engineering
Email Address1: sepidehabadpour@ut.ac.ir
Email Address2: abadpours@gmail.com

Shape Integrity Error


Got this error, Shape Integrity Error? after for a while your mxd file was fine and suddenly, it popped up the error? or you couldn’t republish your mxd file and when you opened your data in ArcMap and sorted the data, you got the error?

Shape Integrity Error is related to your data, whether it is corrupted or it has different geometry type (SDO_gTYPE).

In my case, I am using Oracle spatial, some data has been loaded without being checked. This Oracle site has good information about SDO_GEOMETRY object type,

SDO_GEOMETRY Object Type

Here are some queries that you can use to check your data,

For example: your table/view name is World_Countries that has a column, Shape with SDO_Geometry data type. So to query all SDO_Geometry info

 
select a.Shape , a.Shape.sdo_srid, a.Shape.sdo_gtype,
a.Shape.sdo_point, a.Shape.sdo_elem_info, a.Shape.sdo_ordinates from World_Countries a;

 

from there you can filter your data to find if the data have different geometry type or SRID or etc.

 

Hopefully this post can give you idea to solve your error mystery 🙂

 

 

 

Cannot connect to database because the database client software failed to load. Be sure the database client software is installed and configured correctly


Did you get this error after installed a new ArcGIS server and would like to register your data store in Server Manager?

“Cannot connect to database because the database client software failed to load. Be sure the database client software is installed and configured correctly.”

Yes, this error has related to your client database is not well configured. You can read from Esri 40409. But how about after installed and configured, you still get error?

Let me share, I am using Oracle client to connect from ArcGIS server to Oracle DB and in the same machine, I am using ArcGIS  desktop which using different client (32-bit while server is 64-bit). What you can do to solve the issue?

Check again your environment path, does it has your oracle client paths?

Does your oracle client folder has necessary files? such as ojdbc5.jar or ojdbc6.jar depends on your version?

I fixed the issue by copy over ojdbc6.jar into oracle client folder under \bin.

Hopefully this can give you idea on how to solve this error.

 

Good Luck!!!

 

New Theme


Folks,

It’s almost new year..it is time for me to change my blog theme to something else, something that more eye catching. I took the banner from a real data which I got from StatCounter where I monitor how many people visit my blog. It turned out, not bad, every week this blog has been accessed by at least 500 pageloads.

Thank you all for visiting my blog and hopefully it could answer your issue or at least give you idea on how to solve your issue.

Let me know if you have any questions or anything that could make this blog better in spreading information for ArcGIS users.

 

ArcGIS Sucks?


Hi Everyone!

If you search on Google and use keywords like: “ArcGIS Sucks”, “I hate ArcGIS”, “I hate Esri” or any negative word, you will get a lot of hits. One of the very popular sites is this one, http://www.gisdoctor.com/site/2011/03/10/arcgis-sucks/

Many people came to my blog when they had issue which the issue has happened again and again without being fixed by Esri. Some frustrated and some just accepted as they didn’t have choice.

For me, I created this blog part of my missions is to share with other and at least it helps a little bit.

So the next question is if ArcGIS sucks, what other alternatives do we have?

Cadcorp? SuperMap? GeoMedia? TatukGIS? Please add other more from you in the comment box and tell me what the benefit compare to ArcGIS besides it’s free.

Happy Friday!