I would like to write a plugin to monitor the Status of SIP-Trunks on Alcatel OXO PBX.
I have already a script, which can read and deliver the requested information.
I will modify the Script so, that it will accept four parameters: username, password, ip adress and name of sip trunk. I want to set these Parameters through wato. The Script will then connect to web interface and read the appropriate state of the sip trunk. The output can be “REGISTRATION FAILED” or “REGISTRATION SUCCESSFULL”.
Where can I begin? Unfortunately the documentation on check_mk web did not help me that much.
I suggest you first write a script that takes these 4 arguments as parameters and that returns 0 on success, 1 on warning, 2 on critical, else 3 (unknown).
You can use any programming language, but if you’re not sure then use python since most of the other plugins are written in it.
For configuration in WATO you have to develop other files on the central monitoring server in python.
Example for ~site/local/share/check_mk/web/plugins/wato/<your_filename>. It’s working in 1.5 and is not tested on 1.6. I am not sure if the reference changed for this functions.
register_check_parameters(
subgroup_storage,
'multipath_broken',
_('Linux multipath broken paths'),
Dictionary(
elements = [
('broken_levels',
Tuple(
title = _("Set levels on broken paths"),
elements = [
Integer(title = _("Warning at"), default_value = 1),
Integer(title = _("Critical at"), default_value = 2),
]
),
),
('sumpaths',
Integer(title = _("Sum Paths"))
),
('state_if_new',
MonitoringState(
default_value = 1,
title = _("State in case of new paths found"),
)
)
]
),
None,
match_type = 'dict',
)
As this script is more an classic active check then a checkmk check.
You cannot use the classic way with check parameters and then the checkmk check.
Take a look at the “check_tcp” checkmk/checks/check_tcp at 1.6.0 · Checkmk/checkmk · GitHub
“check_tcp” is only a checkmk plugin making the correct active check syntax for your monitoring core.
The monitoring core then is running your script.
And the options from WATO for this active check.
There the definition def _valuespec_active_checks_tcp():
and
I managed to create mkp package for my plugin and run it and configure through wato, but unfortunately my script does not function in the same way as if I run it manually from CLI.
The script parses the webpage of OXE PBX and print on its output Status of desired SIP Trunk:
#./check_oxesiptrunkstatus -u user -p secret -H 192.168.2.100 -P voiceconnect.domain.de
0 SIP-TRUNK - OK: Public Registration Domain - voiceconnect.domain.de, Public DDI - f106353ecompany, Status - REGISTRATION SUCCESSFUL
But when check_mk runs the script with the same parameters, then in the script output I cannot see given “Public Registration Domain” but I always see the first PRD from the list.
Out of some reason the script does not work the same way as when I run it manually from CLI.