RRDTool - Not a valid vname - bash

I am using RRDTool to manage and graph my Performance Data.
Currently, I am calling RRDTool from a bash script, but I get an Error, which I can not fix.
My Bash Script looks like this:
# Call RRDTool and save the output
output=$(rrdtool graph --width 4000 \
DEF:data=/usr/local/pnp4nagios/var/perfdata/FM/win_tcpu.rrd:proc:AVERAGE \
VDEF:slope=data,LSLSLOPE \
PRINT:slope:'%lf')
echo "Output: " $output
I am trying to solve for m in y = m*x + b with this simple example.
My Performance Data looks something like this:
<NAGIOS>
<DATASOURCE>
<TEMPLATE>nrpe_win_tcpu</TEMPLATE>
<RRDFILE>/usr/local/pnp4nagios/var/perfdata/FM/win_tcpu.rrd</RRDFILE>
<RRD_STORAGE_TYPE>SINGLE</RRD_STORAGE_TYPE>
<RRD_HEARTBEAT>8460</RRD_HEARTBEAT>
<IS_MULTI>0</IS_MULTI>
<DS>1</DS>
<NAME>proc</NAME>
...
</DATASOURCE>
...
As you can see the file name is correct and the DataSource Name is also correct.
My Problem is that the DEF does not seem to work. I get the following Error Message:
ERROR: Not a valid vname: data in line VDEF:slope=data,LSLSLOPE
When trying to access the data saved in Variable data like this, just to check if the problem is in my VDEF line:
LINE1:data#0000FF:"data" \
I get the following Error:
ERROR: parameter 'data' does not represent a number in line LINE1:data#0000FF:data
This clarifies that the problem is somewhere in the DEF line but I have no clue why this is happening.
Does anybody have an idea why I get these error messages and how to fix this problem?
Any help appreciated. Thanks in advance.

I found the problem. It was only a really dumb mistake I made.
I was calling:
rrdtool graph --width 4000 \
DEF:data=/usr/local/pnp4nagios/var/perfdata/FM/win_tcpu.rrd:proc:AVERAGE \
VDEF:slope=data,LSLSLOPE \
...
Looking in the usage description of RRDTool graph again, showed me this:
rrdtool graph filename [-s|--start seconds] [-e|--end seconds] ...
I was simply missing a filename. When calling it like mentioned above RRDTool interpreted my DEF line as a filename. This would cause an error when writing the result to this file, but RRDTool exits with an error on the VDEF line, since data was never defined.
Thanks for all the comments. I just wanted to clarify some things I tested:
- The variable Name data does not cause any problems
- It is totally working to have a DS with name 1 and you could also access it in a CDEF and so on
Thanks for the help!

You can't do a line of a VDEF - it's a value, and is only valid with an aggregation function.
From: http://oss.oetiker.ch/rrdtool/doc/rrdgraph_rpn.en.html LSLSLOPE is valid.
You should be able to graph data though, e.g.
LINE1:data#00CC00:data
That you can't - and get 'does not represent a number' makes me wonder what's in you data source. I would suggest you have a look at xport to dump the RRD and see what's in there.
You might well be not getting enough input data to build a CDP within your RRD, and so they're all UNKNOWN or NaN.
(Invalid VNAME does make me wonder though - have you tried changing it to something other than data - which seems like it could be a reserved word.)

Related

Terraform GCP Instance Metadata Startup Script Issue

I've been working with Terraform, v0.15.4, for a few weeks now, and have gotten to grips with most of the lingo. I'm currently trying to create a cluster of RHEL 7 instances dynamically on GCP, and have, for the most part, got it to run okay.
I'm at the point of deploying an instance with certain metadata passed along to it for use in scripts built into the machine image for configuration thereafter. This metadata is typically just passed via an echo into a text file, which the scripts then pickup as required.
It's... very simple. Echo "STUFF" > file... Alas, I am hitting the same issue OVER AND OVER and it's driving me INSANE. I've Google'd around for ages, but all I can find is examples of the exact thing that I'm doing, the only difference is that theirs works, mine doesn't... So hopefully I can get some help here.
My 'makes it half-way' code is as follows:
resource "google_compute_instance" "GP_Master_Node" {
...
metadata_startup_script = <<-EOF
echo "hello
you" > /test.txt
echo "help
me" > /test2.txt
EOF
Now the instance with this does create successfully, although when I look onto the instance, I get one file called ' /test.txt? ' (or if I 'ls' the file, it shows as ' /test.txt^M ') and no second file.. I can run any command instead of echo, and whilst the first finishes, the second+ does not. Why?? What on earth is causing that??
The following code I found also, but it doesn't work for me at all, with the error, 'Blocks of type "metadata" are not expected here.'
resource "google_compute_instance" "GP_Master_Node" {
...
metadata {
startup-script = "echo test > /test.txt"
}
Okaaaaay! Simple answer for a, in hindsight, silly question (sort of). The file was somehow formmated in DOS, meaning the script required a line continuation character to run correctly (specifically \ at the end of each individual command). Code as follows:
resource "google_compute_instance" "GP_Master_Node" {
...
metadata_startup_script = <<-EOF
echo "hello
you" > /test.txt \
echo "help
me" > /test2.txt \
echo "example1" > /test3.txt \
echo "and so on..." > /final.txt
EOF
However, what also fixed my issue was just 'refreshing' the file (probably a word for this, I don't know). I created a brand new file using touch, 'more'd the original file contents to screen, and then copy pasted them into the new one. On save, it is no longer DOS, as expected, and then when I run terraform the code runs as expected without requiring the line continuation characters at the end of commands.
Thank you to commentors for the help :)

How to fix mallet on gensim

I wrote LDA model in notebook.
I'm trying to wrap my gensim LDA model with mallet, getting the following error:
CalledProcessError: Command '../input/mymallet/mallet-2.0.8/bin/mallet import-file --preserve-case --keep-sequence --remove-stopwords --token-regex "\S+" --input /tmp/fbcc4b_corpus.txt --output /tmp/fbcc4b_corpus.mallet' returned non-zero exit status 126.
The error raised because of the second line:
mallet_path = '../input/mymallet/mallet-2.0.8/bin/mallet' # update this path
ldamallet = gensim.models.wrappers.LdaMallet(mallet_path, corpus=corpus, num_topics=20, id2word=id2word)
The path is correct.
Tried this solution: Gensim mallet CalledProcessError: returned non-zero exit status
didn't work for me..
I spent hours trying to solve it.
Tried this solution and nothing worked.
Looking to a previous sucessfull call I made to LDA Mallet, I noticed some parameters were not being set, then I made it like this:
gensim.models.wrappers.LdaMallet(mallet_path=mallet_path, corpus=corpus, num_topics=num_topics, id2word=id2word, prefix='temp_file_', workers=4)
I really hope it helps you. Finding a solution to this problem is a pain.
I don't know if you ever solved this or not, but I have run into the same problem. For me, the problem occurred because I had uploaded the mallet binary to a research server, where Mallet lost its executable flag. My solution was to run
chmod -R +x mallet-2.0.8
This allowed the gensim wrapper, or whatever means you wish to run mallet, to run the executable file. If you want to be more precise with the chmod, you could probably chmod the actual mallet-2.0.8/bin/mallet file.

What is the correct way to use a stack with a scanner block in Ragel?

I'm using Ragel 6.10 with Go. I'm sure it's likely an issue with my code but I'm getting some weird errors when I try to use a stack with a scanner block. I'm trying to setup bracket matching and my code looks roughly like this;
ObjectValues := |*
# other stuff
'}' => { fret; };
*|
main := ('{' #{fcall ObjectValues;})*;
Looking at page 46 in the guide it looks like this should be possible. When I run Ragel ragel -G2 -Z main.rl. I get the following error when I try to compile (it only happens for -G2 FSM generation);
graphql_collections.rl:47[/Users/nathanfisher/workspace/go/src/github.com/nfisher/gir/graphql_collections.go:325:2]: syntax error: unexpected goto at end of statement
graphql_collections.go:60[/Users/nathanfisher/workspace/go/src/github.com/nfisher/gir/graphql_collections.go:60:1]: label _again defined and not used
Commenting out the fret line removes the error and warns postpop and prepush are unreachable.
The full code is here;
https://github.com/nfisher/gir/blob/broken/graphql_collections.rl#L47
A working minimal test-case is here;
https://gist.github.com/nfisher/649ca816f82bb3ccd7164331ac2324ac
Error for test-case;
main.rl:13[/Users/nathanfisher/workspace/go/src/github.com/nfisher/gir/command/runner/main.go:119:2]: syntax error: unexpected goto at end of statement
main.go:59[/Users/nathanfisher/workspace/go/src/github.com/nfisher/gir/command/runner/main.go:59:1]: label _again defined and not used
It looks like this is an issue relating to Ragel's generated code in v 6.10. Using the HEAD of ragel-6 branch fixes the issue. Thanks to Adrian Thurston for being super responsive/helpful via Twitter. :)
Reformatting the code from this;
To this fixes the error;

How to debug `Error while processing function` in `vim` and `nvim`?

TL;DR
How to find where exactly vim or nvim error started (which file?) when I'm interested in fixing the actual issue and not just removing the bad plugin? Anything better than strace and guesswork to find the error origin?
Issue
I often add a plugin to my vim or nvim config and end up getting errors on hooks (buffer open, close, write):
"test.py" [New] 0L, 0C written
Error detected while processing function 343[12]..272:
line 8:
E716: Key not present in Dictionary: _exec
E116: Invalid arguments for function get(a:args, 'exec', a:1['_exec'])
E15: Invalid expression: get(a:args, 'exec', a:1['_exec'])
The problem is, I have no idea where those come from, only get some line number of unknown file and I know it's not my vim/nvim config file.
Somewhere, you have a plugin that has defined a dictionary with anonymous-functions (check the help related to this tag).
For the curious ones, it's done this way:
let d = {}
function! d.whatever() abort
throw "blah"
endfunction
When you execute this function, you'll get the kind of error you're currently observing. That's why I stopped working this way to prefer:
let d = {}
function s:whatever() abort
throw "blah"
endfunction
let d.whatever = function('s:whatever') " a workaround is required for older versions of vim
" At least this way I'll get a `<SNR>42_whatever` in the exception throwpoint, and thus a scriptname.
That's the why. Now, back to your problem, AFAIK, the only things you'll be able to know are the two functions that have been called:
in line 12 of :function {343}, you've called
:function {272} which contains an error at line 8.
Thanks to these two commands (may be prefixed with :verbose, I don't remember exactly), you'll get the source code of the two functions, which you should be able to use in order to grep your plugins to know where it appears.

Ruby abort on require need to provide parameter

I have a Ruby file that has a line as such:
abort "ID is less than 1!" if env_id.to_i < 1
I am requiring this Ruby file elsewhere and can't pass a parameter when requiring this file. So I keep getting an error where when I try to require the file it aborts with "ID is less than 1!" The env_id is a variable that will be used for uniquely defining a bunch of AWS instances.
Any ideas as to what to do here?
I figured out how to solve my problem. I am just going to use FILE to see if the file is being run directly or required.

Resources