span8
span4
嗨,
我可以利用一些帮助入门FME REST API和PowerShell。我们的目标是很容易地从使用PowerShell的几个FME服务器出现错误。
现在我只需要对剧本的一些入门帮助。这包括:
- 连接到REST API
- 定义属性
- 结果写入HTML
回应我想显示在一个HTML报告:
-FME服务器状态
- 乔布斯在运行状态超过规定时间
-failed工作
你已经有一个脚本做一些这方面,或更多,我将不胜感激一些提示和/或片段让我开始。
如果有不清楚的地方,请不要犹豫,问,或者即使你有一个完全不同的解决方案比PowerShell的我所有的耳朵。
最好的祝福,
利亚
我绝对第二从仪表盘建议@itay
使用FME可以很容易地配置FME Server的监控流程,安排您的仪表板作业,每天晚上运行得到每日更新。
如果发动机或许可用于监视然后PowerShell的一种可能的选择有问题,然而,你可能会发现关于如何最好写PowerShell脚本的堆栈溢出更多的运气。
从本质上讲,你将需要使用此进行查询:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.utility/invoke-restmethod?view=powershell-6
下面是FME Server中的REST API文档:https://docs.亚搏在线safe.com/fme/html/FME_REST/apidoc/v3/index.html#
你需要确保你有制作要求的有效凭证。
这里是产生一个令牌,然后让一个健康检查调用定义的主机开始。
#INPUT Credentails这里主机$ USER =''$密码=' '$主机=' ' #这是令牌服务的url -注意,您需要输入您的主机名$tokenURI = $hostname+'/fmetoken/service/generate。json' #set token expiration - I just used one day here $expiration = 1 #build post body for rest call $cred_body = @{ user = $user password = $password expiration = $expiration timeunit = 'day' update = 'false' } #send post request and save as respone $tokenResponse = Invoke-RestMethod -Method 'Post' -Uri $tokenURI -Body $cred_body #get token from json responce $token=$tokenResponse.serviceResponse.token #$token #################----healthckeck-----###### #healthcheck URI for fme server host $healthcheckURI = $hostname+'/fmerest/v3/healthcheck' #$healthcheckURI $authorizationHeader = @{ authorization = "fmetoken token="+$token } #build query $healthcheck = Invoke-RestMethod -Method 'Get' -Uri $healthcheckURI -Header $authorizationHeader #configure string for result $status='FME Server: "'+$hostname+'" status is '+$healthcheck.status #display status $status #this next bit just leave the ps window open if ($Host.Name -eq "ConsoleHost") { Write-Host "Press any key to continue..." $Host.UI.RawUI.ReadKey("NoEcho,IncludeKeyUp") > $null }
您可能希望保持密码更安全的方式。
©2019安全亚搏在线软件公司|法律