FTP exporter

1,352 views
Skip to first unread message

mansouri...@googlemail.com

unread,
Oct 8, 2018, 6:15:59 AM10/8/18
to Prometheus Users
Hi
I want to check if an FTP server is reachable or not using prometheus? I am looking to see if there are some exporters similar to blackbox exporters that can do that?

Thanks 

Christian Hoffmann

unread,
Oct 8, 2018, 1:03:34 PM10/8/18
to mansouri...@googlemail.com, promethe...@googlegroups.com
Hi,

without having it tried myself, I suspect that blackbox_exporter may
even be able to perform basic ftp monitoring, as the control protocol is
line-based, similar to SMTP and IRC. For the latter, there is even an
example config file:

https://github.com/prometheus/blackbox_exporter/blob/master/config/testdata/blackbox-good.yml#L31

Things may get hairy once you would need a data connection (for file
transfers or directory listings, iirc) as that would require an
additional, dynamic connection. I guess this would be out-of-scope for
blackbox_exporter.

In that case, you would probably need something more specialized.
Technically, you could also have some curl-oneliner write a Prometheus
metrics file for node_exporter's textfile collector:
https://github.com/prometheus/node_exporter#textfile-collector

Hope this helps,
Christian
> --
> You received this message because you are subscribed to the Google
> Groups "Prometheus Users" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to prometheus-use...@googlegroups.com
> <mailto:prometheus-use...@googlegroups.com>.
> To post to this group, send email to promethe...@googlegroups.com
> <mailto:promethe...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/prometheus-users/b386a331-56bc-486a-b602-068748c1ab20%40googlegroups.com
> <https://groups.google.com/d/msgid/prometheus-users/b386a331-56bc-486a-b602-068748c1ab20%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout.

Saul Perdomo

unread,
Jun 26, 2019, 2:41:26 PM6/26/19
to Prometheus Users
Hi there,

I solved this locally by writing a bash script that uses lftp* to attempt sending a file via an SFTP connection, outputting to a .prom file that is scraped by node_exporter as a custom metric via the "textfile collector".**

Here are the contents of the script, names redacted. Note this requires having enabled passwordless login into the SFTP server via a private/public keypair.

#!/bin/sh

#Generate fresh test file
date
> test.txt

#Attempt FTP connection and log output
lftp
-u remote_username, sftp://sftp_servers_fqdn.com -e "set net:max-retries 1; set net:reconnect-interval-base 5; set net:timeout 10; put test.txt;bye"
echo
"sftp_down " $? > /textfile_collector_folder/sftp_status.prom


This script is then scheduled via a cronjob to run every 5 minutes. It's not ideal, since it depends on an execution via cronjob, but it was an effective enough solution for my purposes... and quicker to put together vs having written my own exporter! 

Now, if anybody has a suggestion for a relatively straightforward way to trigger a bash script via an exporter (vs relying on crontab), I would love to hear it!


*I used 'lftp' as it provides a nice 1 or 0 output, for success or failure

Saul Perdomo

unread,
Jul 15, 2019, 8:40:01 PM7/15/19
to Prometheus Users
In case somebody stumbles upon this thread in the future, I moved on to using ricoberger's script_exporter -- it handily triggers my bash script, therefore eliminating the need for a cronjob, and allowing central configuration management of its frequency.

--
You received this message because you are subscribed to the Google Groups "Prometheus Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to prometheus-use...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/prometheus-users/7ca22cd8-d0e0-4cac-bf8a-1d276612bcc5%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages