# Sensu-agent not running - Solved

**URL:** <https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728>\
**Category:** Sensu Go\
**Tags:** permissions\
**Created:** [April 21, 2020, 5:38pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728 "2020-04-21T17:38:02Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![ganeshkatakam](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ganeshkatakam/32/276_2.png) [@ganeshkatakam](https://discourse.sensu.io/u/ganeshkatakam)\
**Post date:** [April 21, 2020, 5:38pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/1 "2020-04-21T17:38:02Z")

</div>

Hi all,

I have installed the sensu-agent and trying to start it using the service manager.  
When I hit sudo service sensu-agent start, it is showing as started.  
When I check the status, it is showing as sensu-agent not running.  
I also have my agent .yml file in /etc/sensu folder.

Can someone help me with this?

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [April 21, 2020, 9:21pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/2 "2020-04-21T21:21:10Z")

</div>

Hey!

Which linux distribution are you using? If you are using a linux distribution that is using systemd you may be about to use journalctl

Example, show logs from sensu-agent from the last hour

```auto
journalctl -u sensu-agent -S "1 hour ago"

```

Off the top of my head I’m suspicious you have an error in your configuration file.

If you want to troubleshoot outside of service management, you can run sensu-agent manually like this:

```auto
sudo -u sensu /usr/sbin/sensu-agent start --config-file /etc/sensu/agent.yml --log-level debug

```

I’ll do this when I troubleshooting something subtle in my config file or i have a filesystem permissions problem that is causing the agent to fail to operate.

---

<div class="post-metadata">

**Author:** ![ganeshkatakam](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ganeshkatakam/32/276_2.png) [@ganeshkatakam](https://discourse.sensu.io/u/ganeshkatakam)\
**Post date:** [April 22, 2020, 2:24am UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/3 "2020-04-22T02:24:58Z")

</div>

I am using amazon linux and I can start the agent manually using the sensu-agent start and there is nothing wrong in the config file.  
But I need to replace it by starting the agent using service manager.

 ![Screenshot 2020-04-22 at 7.54.32 AM](https://us1.discourse-cdn.com/flex016/uploads/sensu/original/1X/e9b606ed98379fc82458c450f703c1bb70b39af2.png)

Also when we manually start the agent, it is running all over the screen. So I want that running in the back. I don’t want my log on the screen. So I am using the service manager.

Please help me with this.

---

<div class="post-metadata">

**Author:** ![Luc\_Dandoy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/luc_dandoy/32/150_2.png) [@Luc\_Dandoy](https://discourse.sensu.io/u/Luc_Dandoy)\
**Post date:** [April 22, 2020, 9:03am UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/4 "2020-04-22T09:03:35Z")

</div>

Without the logs it’s going to be hard.  
Still can you check the access right on the folowing files/folders:

```
ls -l /var/cache/sensu/
ls -l /var/lib/sensu
ls -l /etc/sensu

```

You have to make sure that the sensu user have access to the files/directory.  
You can also try to launch the sensu-agent manually to see if it will give you more information

You will have to log on as sensu user first I think (su - sensu, but you may have to change the shell to something like /bin/bash first) and then run the following command:

```
sensu-agent start -c /etc/sensu/agent.yml
```

---

<div class="post-metadata">

**Author:** ![ganeshkatakam](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ganeshkatakam/32/276_2.png) [@ganeshkatakam](https://discourse.sensu.io/u/ganeshkatakam)\
**Post date:** [April 22, 2020, 2:47pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/5 "2020-04-22T14:47:21Z")

</div>

sensu-agent start -c /etc/sensu/agent.yml is working fine.

But I want this command to act like a daemon so that after this command I can execute some other commands. That is why I need sudo service sensu-agent start to start the sensu-agent properly

Any ideas??

---

<div class="post-metadata">

**Author:** ![Luc\_Dandoy](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/luc_dandoy/32/150_2.png) [@Luc\_Dandoy](https://discourse.sensu.io/u/Luc_Dandoy)\
**Post date:** [April 22, 2020, 3:07pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/6 "2020-04-22T15:07:39Z")

</div>

Do you have anything in the output? maybe you will have to increase log level or so.

After on Ubuntu like distro I never tried to use sensu (I’m only using it on windows and centos), but if the sensu-agent start (as sensu user not as root) is working, then i think just issuing this command should be enugh

```
service sensu-agent start

```

If you ever launched the sensu-agent start command as root, most likely you have directories on which don’t have any more the correct access right.

---

<div class="post-metadata">

**Author:** ![ganeshkatakam](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ganeshkatakam/32/276_2.png) [@ganeshkatakam](https://discourse.sensu.io/u/ganeshkatakam)\
**Post date:** [April 22, 2020, 3:14pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/7 "2020-04-22T15:14:58Z")

</div>

I’m getting the output as:

 ![Screenshot 2020-04-22 at 8.42.45 PM](https://us1.discourse-cdn.com/flex016/uploads/sensu/original/1X/cb275159ef83bd77c7564c9ffcd0e796e2f27cf0.png)

---

<div class="post-metadata">

**Author:** ![aaronsachs](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/aaronsachs/32/47_2.png) [@aaronsachs](https://discourse.sensu.io/u/aaronsachs)\
**Post date:** [April 22, 2020, 3:22pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/8 "2020-04-22T15:22:56Z")

</div>

@ganeshkatakam these screenshots aren’t useful in trying to help you resolve the issue. @jspaleta had provided a command to collect log output, and @Luc_Dandoy had also provided some commands to look at permissions. Please collect the log output and the information that Luc has provided commands for and add that here.

---

<div class="post-metadata">

**Author:** ![ganeshkatakam](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ganeshkatakam/32/276_2.png) [@ganeshkatakam](https://discourse.sensu.io/u/ganeshkatakam)\
**Post date:** [April 22, 2020, 4:37pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/9 "2020-04-22T16:37:53Z")

</div>

@aaronsachs since I am using amazon linux version 1, I am unable to use the journalctl to get logs. Yet I have checked the permissions of the paths mentioned by @Luc_Dandoy. I am attaching them here.

 ![Screenshot 2020-04-22 at 10.05.13 PM](https://us1.discourse-cdn.com/flex016/uploads/sensu/original/1X/51f0e5f1b4beab58812b8ffcfcf5bb026069a865.png)

As told by @Luc_Dandoy I tried starting the agent manually using the command `sensu-agent start -c /etc/sensu/agent.yml` which is working fine.

My problem is that why cannot the service manager run the agent when I can do that manually.

---

<div class="post-metadata">

**Author:** ![jspaleta](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/jspaleta/32/141_2.png) [@jspaleta](https://discourse.sensu.io/u/jspaleta)\
**Post date:** [April 22, 2020, 7:34pm UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/10 "2020-04-22T19:34:54Z")

</div>

Hey,  
I need some clarity as to which amazon linux version you are running as to avoid confusion. amazon linux(based on centos6) uses upstart for its init, and amazon linux 2 uses systemd (based on centos7). So the instructions on how to troubleshoot a running service will be different. Once I know for sure which init system you using, I’ll be able to give you detailed instructions.

But for now here’s how I would go about troubleshooting the different options

**Amazon Linux (centos6)**  
If you are running amazon linux based on centos6 you should see this file:

```auto
/etc/init.d/sensu-agent

```

and log messages from service start up attempts should be in /var/log/sensu/sensu-agent.log. This service script uses a pretty advanced start up that requires chroot to be installed. Look at the `start()` function in that file to see what’s invovled.  
Possible problems you make be having include:

- `chroot` command is not available
- sensu user does not have permissions to write into `/var/log/sensu/` or `/var/run/sensu/`

**Amazon Linux 2 (centos7)**  
If you are running amazon linux 2 based on centos7 you should see this file:

```auto
/usr/lib/systemd/system/sensu-agent.service

```

Troubleshooting the systemd based service is much easier, as you can make use of journalctl to look at the logs from sensu-agent start up failures.

---

<div class="post-metadata">

**Author:** ![ganeshkatakam](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.sensu.io/ganeshkatakam/32/276_2.png) [@ganeshkatakam](https://discourse.sensu.io/u/ganeshkatakam)\
**Post date:** [April 23, 2020, 3:14am UTC](https://discourse.sensu.io/t/sensu-agent-not-running-solved/1728/11 "2020-04-23T03:14:40Z")

</div>

Thanks @jspaleta ,

The error in the log is  
{“component”:“agent”,“error”:“error creating agent: could not open api queue (/var/cache/sensu/sensu-agent/queue.db): open /var/cache/sensu/sensu-agent/queue.db: permission denied”,“level”:“fatal”,“msg”:“error executing sensu-agent”,“time”:“2020-04-22T15:12:16Z”}

For thia problem, there is a solution in [https://docs.sensu.io/sensu-go/latest/guides/troubleshooting/](https://docs.sensu.io/sensu-go/latest/guides/troubleshooting/)

Finally resolved.
