New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Blank arguments can lead to extra spaces in script arguments #2999
Comments
I would do something like this 1517 function get_full_script_path($local_data_id) {
...
1548 if (cacti_sizeof($data)) {
1549 foreach ($data as $item) {
1550 $value = cacti_escapeshellarg($item['value']);
1551 if ('' === $value) {
1552 $value = "''";
1553 }
1554 $full_path = str_replace('<' . $item['data_name'] . '>', $value, $full_path);
1555 }
1556 } it works now
|
I've updated the title of the issue and fixed up a bit of formatting in your original post (feel free to edit and see how it works). If a parameter is replaced, it should be replaced with a blank and I believe that it is. The problem is that the space before or after that argument is not trimmed because we don't know if it should be or not. To be fair though, I have never really noticed this issue with my own systems but does lead to an interesting thought this may be what's affecting one or two other obscure errors we've seen in the past. |
Oh and thanks for the technical break down too, that helps 👍 |
Just modify your Data Input method and enclose the arguments in single quotes: php -q <path_cacti>/scripts/somescript.sh '<hostname>' '<some_argument>' That should immediately solve the issue. |
I guess we could add that simple check, and just trim the single quotes for people who have already made this change too. Less tickets for us. |
Have to be careful about Windows though. |
Blank arguments can lead to extra spaces in script arguments
Good catch. Bad assumption on my part. Resolved. |
Describe the bug
version 1.2.6
When a device has set snmp version 2, it has empty items of snmp settings for version 3 and when I have data input method (script server) where I use all snmp settings like special type codes [snmp_community]...:
I get this error from poller:
ERROR PHP ERROR: Uncaught ArgumentCountError: Too few arguments to function ss_get_bandwidth(), 8 passed in /opt/mikenopa/cacti/site/script_server.php on line 222 and exactly 14 expected
when I check it in poller_item, I can see this:
there is a big gap between 'public' and '2' (the yellow lines), so required fields
<_community>
<_username>
<_password>
<_auth_protocol>
<_priv_passphrase>
<_priv_protocol>
<_context>
<_version>
are translated like an empty character without quotesExpected behavior
cacti should store the full script path without the extra spaces like " ... 'public' '' '' '' '' '' '' '2' ..."
The text was updated successfully, but these errors were encountered: