Agent Troubleshooting
Summary and Overview
This article will focus on some general agent troubleshooting tips. Generally speaking, the agent is installed into a program or library folder. See below for detailed directions. The manual installer will put everything in the Nanitor Agent folder, however when the agent does a self-upgrade it will go into a versions folder where there is a folder for each version. To find the version you are running, find nanitor-agent-bin executable in the nanitor agent folder and execute it with administrative privileges and -v parameter, then do the same with the executable in the highest number folder in the version folder. See below for details.
Finding your agent version manually
The following need to be done with administrative rights.
cd "c:\Program Files\Nanitor\Nanitor Agent"
nanitor-agent-bin.exe -v
dir versions ## Find the largest version number
cd versions\x.y.z
nanitor-agent-bin.exe -v
cd /usr/lib/nanitor-agent/bin
sudo ./nanitor-agent-bin -v
ls -al versions ## Find the largest version number
cd versions/x.y.z
sudo ./nanitor-agent-bin -v
cd /Library/Nanitor/Nanitor\ Agent/
sudo ./nanitor-agent-bin -v
ls -al versions ## Find the largest version number
cd versions/x.y.z
sudo ./nanitor-agent-bin -v
The highest version number is the version you are running. The folder/path where you found the latest agent version is the path you need for all the commands below.
Basic information
To get some basic information about the agent you can run the info command and get output similar to this command executed on a demo Windows client.
To do this, execute the following with administrative rights while in the path with the latest agent as determined in the step above.
nanitor-agent-bin.exe info
sudo ./nanitor-agent-bin info
sudo ./nanitor-agent-bin info
Confirming the server URL
If you need to confirm that the agent is configured for the right instance execute the following with administrative rights while in the path with the latest agent as determined in the first step above. The URL you get here should be the same basic URL that you use to log into your Nanitor instance. If the URL you get is not right please follow the re-register instructions below.
nanitor-agent-bin.exe get-server-url
sudo ./nanitor-agent-bin get-server-url
sudo ./nanitor-agent-bin get-server-url
Confirming connectivity to the server
Execute the following to confirm that you have connectivity to the server from the agent. Make sure to replace [YourServerURL] with the URL you got in the step before.
curl https://[YourServerURL]
Invoke-WebRequest https://[YourServerURL]
curl https://[YourServerURL]
curl https://[YourServerURL]
A successful test should produce output with content that starts with, or something similar
``` "html"
<!DOCTYPE html><html><head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Nanitor</title>
<base href="/">
<meta name="description" content="">
```
If the output you get is substantially different, you do not have proper connectivity to the server from this asset and you need to consult with your in-house networking or IT team to resolve this before you can expect the agent to connect. If you get any errors you should consider this test as failed.
Finding log and configuration files
If something isn't working right with the agent, the log files are the best source to figure out what is happening. You may need to put the agent in debug mode to get more detailed logs. Just make sure you put it back at info to reduce the size of the log files. Also, remember to use an administrative terminal or with administrative rights. You can also confirm this by running the info command from the Basic Information section above.
Log file: C:\ProgramData\Nanitor\Nanitor Agent\Nanitor_Agent.log
Config file: c:\Program Files\Nanitor\Nanitor Agent\nanitor-agent.ini
Log file: /var/log/nanitor/nanitor_agent.log
Config file: /etc/nanitor/nanitor_agent.ini
Log file: /Library/Application Support/Nanitor/Nanitor Agent/Logs/nanitor-agent.log
Config file: /Library/Nanitor/Nanitor Agent/nanitor_agent.ini
If you need to set the agent to debug mode, change the loglevel directive in the config file and restart the agent (see below). Make sure you change it back to info when you are done debugging.
Agent Running state
The agent is a service running in the background that should always be running. Linux has a special nanitor-agent-ctl utility to handle the agent state. If that is not found at the path indicated below, please reinstall the agent as explained in How do I install the Nanitor Agent.
Agent state
To check the state of the agent, execute the following with administrative rights.
sc query "nanitor agent"
sudo /usr/lib/nanitor-agent/bin/nanitor-agent-ctl status
sudo launchctl list | grep nanitor
# First colum is the process ID, if it is -, then the service is stopped.
# If it is a number, the agent is running with that process ID
Agent start
To start the agent, execute the following from an administrative session.
net start "Nanitor Agent"
cd
sudo /usr/lib/nanitor-agent/bin/nanitor-agent-ctl start
sudo launchctl start com.nanitor.nanitor-agent
Agent restart
To restart the agent, execute the following from an administrative session.
net stop "Nanitor Agent"
net start "Nanitor Agent"
sudo /usr/lib/nanitor-agent/bin/nanitor-agent-ctl restart
sudo launchctl stop com.nanitor.nanitor-agent
sudo launchctl start com.nanitor.nanitor-agent
Agent Not Updating
If the Agent is not updating properly try the following commands
cd "c:\Program Files\Nanitor\Nanitor Agent"
net stop "Nanitor Agent"
.\nanitor-agent.exe run_upgrade_maintenance
net start "Nanitor Agent"
cd "c:\Program Files\Nanitor\Nanitor Agent"
sc stop "Nanitor Agent"
nanitor-agent.exe run_upgrade_maintenance
sc start "Nanitor Agent"
cd /usr/lib/nanitor-agent/bin/
sudo ./nanitor-agent-ctl stop
./nanitor-agent-bin run_upgrade_maintenance
sudo ./nanitor-agent-ctl start
cd "/Library/Nanitor/Nanitor Agent/"
sudo launchctl stop com.nanitor.nanitor-agent
./nanitor-agent-bin run_upgrade_maintenance
sudo launchctl start com.nanitor.nanitor-agent
If that doesn't work it would be good if you can run the diagnostics and create a ticket per the next paragraph, so the support team can see if there is anything else to try. Otherwise, you are down to reinstalling the agent, which consists of uninstalling it as you would uninstall any application, then installing it again according to our agent installation guide. It is worth pointing out that uninstall is only required on Windows.
Re-register the agent
If the agent doesn't seem to be connecting to your instance it's good to re-register the agent to the instance. You are basically de-registering and then re-registering. To do this, execute the following with administrative rights while in the path with the latest agent as determined in the first step above. To find your signup URL, consult Finding your Setup URL - Nanitor Knowledgebase.
nanitor-agent-bin.exe unregister
nanitor-agent-bin.exe signup --key <your signup URL>
sudo ./nanitor-agent-bin unregister
sudo ./nanitor-agent-bin signup --key <your signup URL>
sudo ./nanitor-agent-bin unregister
sudo ./nanitor-agent-bin --key <your signup URL>
Additional help and diagnostics
Always feel free to reach out to our support team with any questions or problems you may be having. The best way to contact our support team is by creating a ticket at our support desk. You can also send them an email. If you suspect the agent is misbehaving or not collecting the correct information it would speed up the resolution if you run a diagnostic ahead of time. The diagnostics will automatically try to submit the results to us, but if that fails you just include the file it generates in your request. Including the output of the diagnostics can be very helpful as well. Here is how to run the diagnostics based on your platform, either from the console GUI or on the host.
In the console GUI
In the asset inventory find the asset in question and open up the detailed page.
Click on the three dots in the upper right-hand side and select "Request Diagnostics", then click Request on the confirmation screen
This should be all that is needed. If this does not work, then you need to do this on the host and send the file directly to your contact.
On the host
Run these commands in an administrative terminal (sudo, root, or administrative terminal) while in the folder you identified in the first step.
cmd or PowerShell
## Run in Administrative terminal
nanitor-agent-bin.exe diag
sudo ./nanitor-agent-bin diag
sudo ./nanitor-agent-bin diag