Asterisk Manager - Cannot Connect Via Telnet

FreePBX 16.0.19

I am attempting to monitor Asterisk with this Zabbix template, but it’s not working.

Enabled mini-HTTP Server: Yes
Added Manager User with read permit privileges (different than admin)

manager:conf

[general]
enabled = yes
port = 5038
bindaddr = 0.0.0.0
displayconnects=no ;only effects 1.6+
webenabled = yes

To test a connection to the AMI I tried to connect via telnet from localhost:

Asterisk Call Manager/7.0.2
Action: login
Username: admin
Secret: secret-found-on-advanced-settings
Connection closed by foreign host.

I don’t understand what I am doing wrong, it seems like it should be simple enough.

If you
‘. .Added Manager User with read permit privileges (different than admin). .’

Why did you use the admin login here

Action: login
Username: admin

?

Well I figured that the admin user would definitely work, since it’s used internally by FreePBX, to isolate other issues from login issues.

You might need to set authtimeout=X000milliseconds unless you type quickly, I think default is 30 seconds

I copy and pasted the commands into putty well within 20 seconds I would say.

Do you have any tips on how I could troubleshoot? When I set debug on in the manager, there’s so much spam and I don’t know what words to look for.

I use this ‘expect’ wrapper around telnet where linefeeds are not what you thought

#!/usr/bin/expect
set username "admin"
set secret "c8d07fbf47e7b59d"
set host "127.0.0.1"
set port "5038"
spawn telnet $host $port

expect "Manager" {
    send_user "Connected.\n"
    send "Action: Login\nUsername:$username\nSecret:$secret\n\n"
}

expect {
    timeout {exp_continue}
}

That plugin is called Asterisk by HTTP. So it connects using the HTTP server, not the TCP socket. I don’t understand why it’s asking you to define the {$AMI.PORT} since that wouldn’t be used here.

It looks like a closer inspection queries the TCP port before connecting over 8088

Asterisk	Asterisk: Service status	
Asterisk Manager API port availability.

SIMPLE	net.tcp.service["tcp","{HOST.CONN}","{$AMI.PORT}"]
Preprocessing:

- DISCARD_UNCHANGED_HEARTBEAT: 10m

If the Zabbix server is not local to the PBX then unprotected TCP or HTTP connections over 5038, or 8088 , should be considered insecure if either is binding to 0.0.0.0

Hi mrosu

Be careful, at the end of each block, need to send two <crlf>
For my part, connecting asterisk AMI through Telnet works fine.

The AMI over HTTP option came up on one of the community forums (I think it was the asterisk one) recently, and one of the Sangoma experts had forgotten it even existed, and said it was hardly used by anyone and likely to be buggy. Unfortunately, I didn’t have success, with Google, finding the thread.

Whilst is is possible that Zabbix have tested their specific use thoroughly, it is not something that one should probably rely on.

Okay thanks everyone for the input. I think this method just won’t work well at all, probably because it’s buggy or the development hasn’t kept up, as was mentioned.

Have you seen this Monitoring FreePBX system with Grafana Cloud - #2 by lgaetz

I’ve just tested this and it seems to work well. Haven’t looked at in detail though.

We’re running Asterisk 18.11.3 and this file is missing:

/etc/asterisk/prometheus.conf

You have to create the file. Make sure to read the guide carefully as I misread a couple of steps originally.

Ah, okay I will give that a try soon, thank you!

We run Grafana locally, not cloud, so I guess I’ll keep waiting until something comes along. Thanks everyone for your help.

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.