# [solved] fail2ban MRTG graphs

## aztech

Hi

I would like some help with extracting values from this output ..

```

bionic action.d # fail2ban-client status ssh-iptables                           

Status for the jail: ssh-iptables                                               

|- filter                                                                       

|  |- Currently failed: 0                                                       

|  `- Total failed:     816                                                     

`- action                                                                       

   |- Currently banned: 0                                                       

   |  `- IP list:                                                               

   `- Total banned:     408

```

I want to make a script that collects data for MRTG, so the values I want is "Currently failed" and "Currently banned"

and then to make this usable by MRTG.

If anyone could example a .cfg for MRTG also, that would be great.

BR

AndreasLast edited by aztech on Fri May 16, 2008 5:34 pm; edited 2 times in total

----------

## mosburn

Does MRTG get its data from SNMP? If so, you can have it execute a script like the following and graph that output. I have a ton of small processes that I graph with ZenOSS over snmp. The basic structure that you would use is

```
fail2ban-client status ssh-iptables| grep "Total failed:"| awk '{print %5}'
```

 and tweak it to the output that you want.

If its not SNMP I am not sure where to begin short of getting the time to install MTRG.

Hope that helps

----------

## aztech

 *mosburn wrote:*   

> Does MRTG get its data from SNMP? If so, you can have it execute a script like the following and graph that output. I have a ton of small processes that I graph with ZenOSS over snmp. The basic structure that you would use is
> 
> ```
> fail2ban-client status ssh-iptables| grep "Total failed:"| awk '{print %5}'
> ```
> ...

 

MRTG can collect data from both snmp and from running scripts/apps etc ..

But the example you gave, resulted in ..

```

bionic log # fail2ban-client status ssh-iptables | grep "Total failed:" | awk '{

print %5}'                                                                      

awk: {print %5}                                                                 

awk:        ^ syntax error

```

I have never learned how to use awk really, so I have no clue.

----------

## mosburn

Thats what i get from posting on my phone. 

With awk it sould be $5 not %5. sorry about that

----------

## aztech

 *mosburn wrote:*   

> Thats what i get from posting on my phone. 
> 
> With awk it sould be $5 not %5. sorry about that

 

Tnx, that worked much better =)

Now when I know how to "extract" data, I will write a cfg-file and the

matter should be solved.

/ Andreas

----------

## timeBandit

 *mosburn wrote:*   

> The basic structure that you would use is
> 
> ```
> fail2ban-client status ssh-iptables| grep "Total failed:"| awk '{print $5}'
> ```
> ...

 Tip: Especially if this pipeline will run often, make better use of awk and avoid an extra process:

```
fail2ban-client status ssh-iptables | awk '/Total failed:/{print $5}'
```

----------

