Fortigate plugin failing inconsistent use of tabs and spaces in indentation

Hi,
I am wondering if this happened to any of you on Fortigate plugin on 2.1 version, below an example of the code.

Error on line 49

Others
Error in plugin file /omd/sites/prod/local/share/check_mk/checks/fortigate_ipsec: inconsistent use of tabs and spaces in indentation (, line 11)
Error in plugin file /omd/sites/prod/local/share/check_mk/checks/fortigate_memory: inconsistent use of tabs and spaces in indentation (, line 49)
Error in plugin file /omd/sites/prod/local/share/check_mk/checks/fortigate_sessions: inconsistent use of tabs and spaces in indentation (, line 36)
Error in plugin file /omd/sites/prod/local/share/check_mk/checks/fortigate_sslvpn: inconsistent use of tabs and spaces in indentation (, line 39)

Exchange plug in
https://exchange.checkmk.com/p/fortigate

def inventory_fortigate_memory(info):
if info:
return [(None, “fortigate_memory_default_levels”)]

def check_fortigate_memory(item, params, info):
warn, crit = params
try:
warn, crit = params
except:
warn, crit = params[“levels”]
if type(params) != dict:
warn, crit = params
else:
warn, crit = params[“levels”]

current = saveint(info[0][0])
state = 0
icon = ''
if current >= warn:
    state = 1
icon = "(!!)"
if current >= crit:
    state = 2
icon = "(!!)"

perf = [("mem_usage", current, warn, crit)]
return(state, "%d%%%s (levels at %d/%d percent)" % (current, icon, warn, crit), perf)

check_info[“fortigate_memory”] = {
“check_function” : check_fortigate_memory,
“inventory_function” : inventory_fortigate_memory,
“service_description” : “Memory usage”,
“has_perfdata” : True,
“group” : “memory”,
#“snmp_scan_function” : lambda oid: oid(“.1.3.6.1.4.1.12356.1.9.0”),
“snmp_scan_function” : lambda oid: oid(“.1.3.6.1.4.1.12356.101.4.1.4.0”),
#“snmp_info” : ( “.1.3.6.1.4.1.12356.1”, [ 9 ]),
“snmp_info” : ( “.1.3.6.1.4.1.12356.101.4.1”, [ 4 ]),
}

Do you really need this mkp? Since a long time this Fortigate checks are already included inside the distributed checks.
Please check if the included ones do what you want.

PS: for code please use the “Preformatted text” Ctrl+E format

1 Like

This MKP was built in 2015 on version 1.1.6p1 and is guaranteed to not work on 2.1.

As @andreas-doehler already mentioned there are now builtin checks for Fortigate: Check Plug-Ins Catalog

btw. it doesn’t look like these files are part of the package from the exchange…

Check Plugins
fortigate_cpu
fortigate_mem
fortigate_sescount
PNP Templates
check_mk-fortigate_cpu.php
check_mk-fortigate_mem.php
check_mk-fortigate_sescount.php

it is rather this package Checks for Fotigate devices

If you really want to use this package, you must replace all tabs in these files with 4 spaces.

Hi thl-cmk,

Thanks for answer, I tested some of packages so maybe I miss the correct one, but in all cases I received the same issue.

So, you mean replacing tab in the whole file?

Thanks

yes, the indentation in the files is a mixture of tabs and spaces. python doesn’t like that…

Hey! I could replace all tabs for spaces and now is working, I used the VS Code that detect all places where the tab is used.

Thanks for your help! really appreciated

Hey! I could replace all tabs for spaces and now is working, I used the VS Code that detect all places where the tab is used.

Thanks for your help! really appreciated

@maxgomezmp your welcome

Don’t forget to mark this as a solution if it solves your issue :wink:

1 Like