0

I am trying to get the contents of the ns.log file on my NetScaler using Nitro. Here is the code

$URL = 'https://$NSIP/nitro/v1/config/systemfile/ns.log?args=filelocation:%2fvar%2Flog'
$varlog = Invoke-WebRequest -Method Get -uri $URL  -UseDefaultCredentials | ConvertFrom-Json

I get details of the file itself (output below), but it is missing the filecontent section

filename : ns.log filelocation : /var/log fileencoding : BASE64 fileaccesstime : Wed Apr 26 01:00:01 2017 filemodifiedtime : Wed Apr 26 07:19:23 2017

In fact, when I try to get the contents of any file in the var/log folder, I have the same problem. It works just fine when I try this on any other folder. I can read the files just fine when I use Putty.

I found a Citrix article saying there is a file size limit of 2MB (not sure what the limit is on) but my ns.log file is only 49kB

Does anyone know of any other limitations in using nitro on the NetScaler, or found a way to get the file content

mattnicola
  • 393
  • 1
  • 4
  • 18
  • I've update the missing quote typo. I've tried without `|convertfrom-json` still the same issue. I've used all the aliases for invoke-webrequest and tried invoke-restmethod too. I've also tried entering the credentials using `-credential`. I can get the file content of larger files, so I don't think size is an issue. thanks – mattnicola Apr 26 '17 at 06:06
  • Aren't NetScaler log files binary files? In that case, you have to explicitly set an -OutputFile in your Invoke-WebRequest. – David Brabant Apr 26 '17 at 06:20
  • Do you mean `-outfile`? Just tired and it outputs what I've already mentioned into a file. Nothing new – mattnicola Apr 26 '17 at 06:42
  • I logged a support call with Citrix over a week before I posted this question, and after uploading log after log, they finally told me, viewing the contents of the log files using NITRO, is not supported! – mattnicola Apr 27 '17 at 05:11
  • In case anyone else has the same issue, as a work around to this problem, I ended up using plink to ssh on to the netscaler and copying the log file in a variable. Then I can format it however I like – mattnicola May 02 '17 at 04:08
  • So you're using Putty's version of scp now, right? – StackzOfZtuff May 12 '17 at 20:00
  • Yes, that's correct – mattnicola May 17 '17 at 06:33
  • I know this is an old question but I was able to get the log from the above URL with: $in = $info.systemfile.filecontent [System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($in)) – smwk Nov 29 '22 at 10:34

1 Answers1

0

There is a GUI function that allows this. It is under System - Auditing, select "Recenet Audit Messages". From here I trust you are able to use developer tools to analyse the payload. The particular command used belongs to rapi and not the NITRO api, so you wont find any documentation.

Request URL: http://hostname/rapi/remote_shell
payload:object: {"params":{"warning":"YES"},"remote_shell":{"command":"show audit messages -logLevel ALL -numOfMesgs 20","prompt":">show audit messages -logLevel ALL -numOfMesgs 20","target":"cli"}}
virgula24
  • 523
  • 5
  • 23