Search Results

Search found 4919 results on 197 pages for 'integer'.

Page 7/197 | < Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >

  • NRPE Warning threshold must be a positive integer

    - by Frida
    OS: Ubuntu 12.10 Server 64bits I've installed Icinga, with ido2db, pnp4nagios and icinga-web (last release, following the instruction given in the documentation, installation with apt, etc). I am using icinga-web to monitor my hosts. For the moment, I have just my localhost, and all is perfect. I am trying to add a host and monitor it with NRPE (version 2.12): root@server:/etc/icinga# /usr/lib/nagios/plugins/check_nrpe -H client NRPE v2.12 The configuration looks good. I've created a file in /etc/icinga/objects/client.cfg as below on the server: root@server:/etc/icinga/objects# cat client.cfg define host{ use generic-host ; Name of host template to use host_name client alias client.toto address xx.xx.xx.xx } # Service Definitions define service{ use generic-service host_name client service_description CPU Load check_command check_nrpe_1arg!check_load } define service{ use generic-service host_name client service_description Number of Users check_command check_nrpe_1arg!check_users } And add in my /etc/icinga/commands.cfg: # this command runs a program $ARG1$ with no arguments define command { command_name check_nrpe command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ -a $ARG2$ } # this command runs a program $ARG1$ with no arguments define command { command_name check_nrpe_1arg command_line /usr/lib/nagios/plugins/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } But it does not work. These are the logs from the client: Dec 3 19:45:12 client nrpe[604]: Connection from xx.xx.xx.xx port 32641 Dec 3 19:45:12 client nrpe[604]: Host address is in allowed_hosts Dec 3 19:45:12 client nrpe[604]: Handling the connection... Dec 3 19:45:12 client nrpe[604]: Host is asking for command 'check_users' to be run... Dec 3 19:45:12 client nrpe[604]: Running command: /usr/lib/nagios/plugins/check_users -w -c Dec 3 19:45:12 client nrpe[604]: Command completed with return code 3 and output: check_users: Warning t hreshold must be a positive integer#012Usage:check_users -w -c Dec 3 19:45:12 client nrpe[604]: Return Code: 3, Output: check_users: Warning threshold must be a positive integer#012Usage:check_users -w -c Dec 3 19:44:49 client nrpe[32582]: Connection from xx.xx.xx.xx port 32129 Dec 3 19:44:49 client nrpe[32582]: Host address is in allowed_hosts Dec 3 19:44:49 client nrpe[32582]: Handling the connection... Dec 3 19:44:49 client nrpe[32582]: Host is asking for command 'check_load' to be run... Dec 3 19:44:49 client nrpe[32582]: Running command: /usr/lib/nagios/plugins/check_load -w -c Dec 3 19:44:49 client nrpe[32582]: Command completed with return code 3 and output: Warning threshold mu st be float or float triplet!#012#012Usage:check_load [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLO AD15 Dec 3 19:44:49 client nrpe[32582]: Return Code: 3, Output: Warning threshold must be float or float trip let!#012#012Usage:check_load [-r] -w WLOAD1,WLOAD5,WLOAD15 -c CLOAD1,CLOAD5,CLOAD15 Dec 3 19:44:49 client nrpe[32582]: Connection from xx.xx.xx.xx closed. Have you any ideas?

    Read the article

  • casting doubles to integers in order to gain speed

    - by antirez
    Hello all, in Redis (http://code.google.com/p/redis) there are scores associated to elements, in order to take this elements sorted. This scores are doubles, even if many users actually sort by integers (for instance unix times). When the database is saved we need to write this doubles ok disk. This is what is used currently: snprintf((char*)buf+1,sizeof(buf)-1,"%.17g",val); Additionally infinity and not-a-number conditions are checked in order to also represent this in the final database file. Unfortunately converting a double into the string representation is pretty slow. While we have a function in Redis that converts an integer into a string representation in a much faster way. So my idea was to check if a double could be casted into an integer without lost of data, and then using the function to turn the integer into a string if this is true. For this to provide a good speedup of course the test for integer "equivalence" must be fast. So I used a trick that is probably undefined behavior but that worked very well in practice. Something like that: double x = ... some value ... if (x == (double)((long long)x)) use_the_fast_integer_function((long long)x); else use_the_slow_snprintf(x); In my reasoning the double casting above converts the double into a long, and then back into an integer. If the range fits, and there is no decimal part, the number will survive the conversion and will be exactly the same as the initial number. As I wanted to make sure this will not break things in some system, I joined #c on freenode and I got a lot of insults ;) So I'm now trying here. Is there a standard way to do what I'm trying to do without going outside ANSI C? Otherwise, is the above code supposed to work in all the Posix systems that currently Redis targets? That is, archs where Linux / Mac OS X / *BSD / Solaris are running nowaday? What I can add in order to make the code saner is an explicit check for the range of the double before trying the cast at all. Thank you for any help.

    Read the article

  • Integer Overflow in VBA project

    - by mcoolbeth
    Hi, everyone. Here is a small VBA (Excel) function that i wrote, full of MsgBoxes for debugging. I am passing in the numbers 10 and 1 as arguments, and getting an overflow error when the program reaches the top of the For loop, before it begins the first iteration. Any thoughts are appreciated. Function PerformanceTest(iterations As Integer, interval As Integer) As Double Dim st, tot, k As Double Dim n As Integer tot = 0# MsgBox "ok" k = iterations + tot MsgBox "ookk" n = 1 MsgBox "assigned" For n = 1 To iterations MsgBox n st = Timer Application.Calculate tot = tot + (Timer - st) Sleep (1000 * interval) Next n 'MsgBox (tot / k) PerformancTest = tot / k End Function

    Read the article

  • convert integer to a string in a given numeric base in python

    - by Mark Borgerding
    Python allows easy creation of an integer from a string of a given base via int(str,base). I want to perform the inverse: creation of a string from an integer. i.e. I want some function int2base(num,base) such that: int( int2base( X , BASE ) , BASE ) == X the function name/argument order is unimportant For any number X and base BASE that int() will accept. This is an easy function to write -- in fact easier than describing it in this question -- however, I feel like I must be missing something. I know about the functions bin,oct,hex; but I cannot use them for a few reasons: Those functions are not available on older versions of python with which I need compatibility (2.2) I want a general solution that can be called the same way for different bases I want to allow bases other than 2,8,16 Related Python elegant inverse function of int(string,base) Interger to base-x system using recursion in python Base 62 conversion in Python How to convert an integer to the shortest url-safe string in Python?

    Read the article

  • Encoding a string as an integer .NET

    - by Paul Knopf
    I have a string that I would like represented uniquely as an integer. For example: A3FJEI = 34950140 How would I go about writing a EncodeAsInteger(string) method. I understand that the amount of characters in the string will make the integer increase greatly, forcing the value to become a long, not an int. Since I need the value to be an integer, I don't need the numerical representation to be entirely unique to the string. Maybe I can foreach through all the characters of the string and sum the numerical keycode of the character.

    Read the article

  • C# convert integer to hex and back again

    - by codette
    How can I convert the following? 2934 (integer) to B76 (hex) Let me explain what I am trying to do. I have User IDs in my database that are stored as integers. Rather than having users reference their IDs I want to let them use the hex value. The main reason is because it's shorter. So not only do I need to go from integer to hex but I also need to go from hex to integer. Is there an easy way to do this in C#?

    Read the article

  • Beginner Java Question about Integer.parseInt() and casting

    - by happysoul
    so when casting like in the statement below :- int randomNumber=(int) (Math.random()*5) it causes the random no. generated to get converted into an int.. Also there's this method I just came across Integer.parseInt() which does the same ! i.e return an integer Why two different ways to make a value an int ? Also I made a search and it says parseInt() takes string as an argument.. So does this mean that parseInt() is ONLY to convert String into integer ? What about this casting then (int) ?? Can we use this to convert a string to an int too ? sorry if it sounds like a dumb question..I am just confused and trying to understand Help ?

    Read the article

  • List of divisors of an integer n (Haskell)

    - by Code-Guru
    I currently have the following function to get the divisors of an integer: -- All divisors of a number divisors :: Integer -> [Integer] divisors 1 = [1] divisors n = firstHalf ++ secondHalf where firstHalf = filter (divides n) (candidates n) secondHalf = filter (\d -> n `div` d /= d) (map (n `div`) (reverse firstHalf)) candidates n = takeWhile (\d -> d * d <= n) [1..n] I ended up adding the filter to secondHalf because a divisor was repeating when n is a square of a prime number. This seems like a very inefficient way to solve this problem. So I have two questions: How do I measure if this really is a bottle neck in my algorithm? And if it is, how do I go about finding a better way to avoid repetitions when n is a square of a prime?

    Read the article

  • Convert bit vector (array of booleans) to an integer, and integer to bit vector, in Java.

    - by dreeves
    What's the best way to unstub the following functions? // Convert a bit-vector to an integer. int bitvec2int(boolean[] b) { [CODE HERE] } // Convert an integer x to an n-element bit-vector. boolean[] int2bitvec(int x, int n) { [CODE HERE] } Or is there a better way to do that sort of thing than passing boolean arrays around? This comes up in an Android app where we need an array of 20 booleans to persist and the easiest way to do that is to write an integer or string to the key-value store. I'll post the way we (Bee and I) wrote the above as an answer. Thanks!

    Read the article

  • Unboxing object containing a value which is known to be assignable to an integer variable

    - by Wim Coenen
    If I have an object instance and I know it is actually a boxed integer, then I can simply cast it back to int like this: object o = GetSomethingByName("foo"); int i = (int)o; However, I don't actually know that the value is an integer. I only know that it can be assigned to an integer. For example, it could be a byte, and the above code would throw InvalidCastException in that case. Instead I would have to do this: object o = GetSomethingByName("foo"); int i = (int)(byte)o; The value could also be a short, or something else which can be assigned to an int. How do I generalize my code to handle all those cases (without handling each possibility separately)?

    Read the article

  • C++ converting hexadecimal md5 hash to decimal integer

    - by Zackery
    I'm doing Elgamal Signature Scheme and I need to use the decimal hash value from the message to compute S for signature generation. string hash = md5(message); cout << hash << endl; NTL::ZZ msgHash = strtol(hash.c_str(), NULL, 16); cout << msgHash << endl; There are no integer large enough to contain the value of 32 byte hexadecimal hash, and so I tried big integer from NTL library but it didn't work out because you cannot assign long integer to NTL::ZZ type. Is there any good solution to this? I'm doing this with visual C++ in Visual Studio 2013.

    Read the article

  • String as \x03\x00\x00\x00 to integer

    - by marta
    Helo: I have a question, that I solved in c, but now I want to do it in hava: I have a String like: '\x03\x00\x00\x00' This is representing an hexadecimal value of a integer. I transform to 0x03\0x00... And now I want to obtain the integer, but I don't know how to do it in java could someone give me some idea ? Thanks in advance (Is it some way to use this format ('\x03\x00\x00\x00' ) directly without use byte[] arrays? and in C can I use this format directly to build a integer (int)?)

    Read the article

  • Disabling identity (auto-incrementing) on integer primary key using code first

    - by gw0
    I am using code first approach in a ASP.NET MVC 3 application and all integer primary keys in models (public int Id { get; set; }) are by default configured as an identity with auto-incrementing. How to disable this and enable a way to manually enter the integer for the primary key? The actual situation is that the Id integers have a special meaning and I would therefore like to have them choosable at creation and later editable. It would be ideal if in case the integer is not given at creation time it is auto-incremented, else the specified value is used. But editable primary fields is my primary need. Is there any way to do this elegantly in ASP.NET MVC 3?

    Read the article

  • Why is DivMod Limited to Words (<=65535)?

    - by Andreas Rejbrand
    In Delphi, the declaration of the DivMod function is procedure DivMod(Dividend: Cardinal; Divisor: Word; var Result, Remainder: Word); Thus, the divisor, result, and remainder cannot be grater than 65535, a rather severe limitation. Why is this? Why couldn't the delcaration be procedure DivMod(Dividend: Cardinal; Divisor: Cardinal; var Result, Remainder: Cardinal); The procedure is implemented using assembly, and is therefore probably extremely fast. Would it not be possible for the code PUSH EBX MOV EBX,EDX MOV EDX,EAX SHR EDX,16 DIV BX MOV EBX,Remainder MOV [ECX],AX MOV [EBX],DX POP EBX to be adapted to cardinals? How much slower is the naïve attempt procedure DivModInt(const Dividend: integer; const Divisor: integer; out result: integer; out remainder: integer); begin result := Dividend div Divisor; remainder := Dividend mod Divisor; end; that is not (?) limited to 16-bit integers?

    Read the article

  • VS C++ throwing divide by zero exception after a specific check

    - by Dr. Monkey
    In the following C++ code, it should be impossible for ain integer division by zero to occur: // gradedUnits and totalGrades are both of type int if (gradedUnits == 0) { return 0; } else { return totalGrades/gradedUnits; //call stack points to this line } however Visual Studio is popping up this error: Unhandled exception at 0x001712c0 in DSA_asgn1.exe: 0xC0000094: Integer division by zero. And the stack trace points to the line indicated in the code. It seems like VS might just do this with any integer division, without checking whether a divide by zero is possible. Do I need to catch this exception even though the code should never be able to throw it? If so, what's the best way to go about this? This is for an assignment that specifies VS 2005/2008 with C++. I would prefer not to make things more complicated than I need to, but at the same time I like to do things properly where possible.

    Read the article

  • PHP validating integers

    - by Mikk
    Hi, I was wondering, what would be the best way to validate an integer. I'd like this to work with strings as well, so I could to something like (string)+00003 - (int)3 (valid) (string)-027 - (int)-27 (valid) (int)33 - (int)33 (valid) (string)'33a' - (FALSE) (invalid) That is what i've go so far: function parseInt($int){ //If $int already is integer, return it if(is_int($int)){return $int;} //If not, convert it to string $int=(string)$int; //If we have '+' or '-' at the beginning of the string, remove them $validate = ($int[0] === '-' || $int[0] === '+')?substr($int, 1):$int; //If $validate matches pattern 0-9 convert $int to integer and return it //otherwise return false return preg_match('/^[0-9]+$/', $validate)?(int)$int:FALSE; } As far as I tested, this function works, but it looks like a clumsy workaround. Is there any better way to write this kind of function. I've also tried filter_var($foo, FILTER_VALIDATE_INT); but it won't accept values like '0003', '-0' etc.

    Read the article

  • Strange Integer.parseInt exception

    - by Albinoswordfish
    Exception in thread "Thread-2" java.lang.NumberFormatException: For input string: "3" int test = Integer.parseInt(result[0]); This is the error I keep getting when I'm trying to convert "3" to an integer. Well I'm receiving this "3" through a RS-232 port, so maybe this is what is causing the error. If anybody has any idea what could be causing this it would be appreciated.

    Read the article

  • scala integer weirdness

    - by williamstw
    Suppose you inadvertently use Integer instead of Int, as in this code: import scala.collection.mutable.Map val contributors = Map[String,Integer]() val count = contributors.getOrElseUpdate("john",0) contributors.put("john",count+1) println(contributors) Compiler output: (fragment of test.scala):7: error: type mismatch; found : Int(1) required: String contributors.put("john",count+1) ^ Why "required: String"?

    Read the article

  • ABAP - increment an integer

    - by Ben
    Hi there, sometimes ABAP drives me crazy with really simple tasks - as incrementing an integer within a loop... Here's my try: METHOD test. DATA: lv_id TYPE integer. lv_id = 1. LOOP AT x ASSIGNING <y>. lv_id = lv_id+1. ENDLOOP. ENDMETHOD. This gives me a strange error I can hardly translate to english..

    Read the article

  • Find maximum positive integer value in Bourne Shell

    - by l0b0
    I'm checking a counter in a loop to determine if it's larger than some maximum, if specified in an optional parameter. Since it's optional, I can either default the maximum to a special value or to the maximum possible integer. The first option would require an extra check at each iteration, so I'd like to instead find out what is the maximum integer that will work with the -gt Bourne Shell operation.

    Read the article

  • Finding N contiguous zero bits in an integer to the left of the MSB position of another integer

    - by James Morris
    The problem is: given an integer val1 find the position of the highest bit set (Most Significant Bit) then, given a second integer val2 find a contiguous region of unset bits, with the minimum number of zero bits given by width to the left of the position (ie, in the higher bits). Here is the C code for my solution: typedef unsigned int t; unsigned const t_bits = sizeof(t) * CHAR_BIT; _Bool test_fit_within_left_of_msb( unsigned width, t val1, t val2, unsigned* offset_result) { unsigned offbit = 0; unsigned msb = 0; t mask; t b; while(val1 >>= 1) ++msb; while(offbit + width < t_bits - msb) { mask = (((t)1 << width) - 1) << (t_bits - width - offbit); b = val2 & mask; if (!b) { *offset_result = offbit; return true; } if (offbit++) /* this conditional bothers me! */ b <<= offbit - 1; while(b <<= 1) offbit++; } return false; } Aside from faster ways of finding the MSB of the first integer, the commented test for a zero offbit seems a bit extraneous, but necessary to skip the highest bit of type t if it is set. I have also implemented similar algorithms but working to the right of the MSB of the first number, so they don't require this seemingly extra condition. How can I get rid of this extra condition, or even, are there far more optimal solutions? Edit: Some background not strictly required. The offset result is a count of bits from the high bit, not from the low bit as maybe expected. This will be part of a wider algorithm which scans a 2D array for a 2D area of zero bits. Here, for testing, the algorithm has been simplified. val1 represents the first integer which does not have all bits set found in a row of the 2D array. From this the 2D version would scan down which is what val2 represents. Here's some output showing success and failure: t_bits:32 t_high: 10000000000000000000000000000000 ( 2147483648 ) --------- ----------------------------------- *** fit within left of msb test *** ----------------------------------- val1: 00000000000000000000000010000000 ( 128 ) val2: 01000001000100000000100100001001 ( 1091569929 ) msb: 7 offbit:0 + width: 8 = 8 mask: 11111111000000000000000000000000 ( 4278190080 ) b: 01000001000000000000000000000000 ( 1090519040 ) offbit:8 + width: 8 = 16 mask: 00000000111111110000000000000000 ( 16711680 ) b: 00000000000100000000000000000000 ( 1048576 ) offbit:12 + width: 8 = 20 mask: 00000000000011111111000000000000 ( 1044480 ) b: 00000000000000000000000000000000 ( 0 ) offbit:12 iters:10 ***** found room for width:8 at offset: 12 ***** ----------------------------------- *** fit within left of msb test *** ----------------------------------- val1: 00000000000000000000000001000000 ( 64 ) val2: 00010000000000001000010001000001 ( 268469313 ) msb: 6 offbit:0 + width: 13 = 13 mask: 11111111111110000000000000000000 ( 4294443008 ) b: 00010000000000000000000000000000 ( 268435456 ) offbit:4 + width: 13 = 17 mask: 00001111111111111000000000000000 ( 268402688 ) b: 00000000000000001000000000000000 ( 32768 ) ***** mask: 00001111111111111000000000000000 ( 268402688 ) offbit:17 iters:15 ***** no room found for width:13 ***** (iters is the count of iterations of the inner while loop)

    Read the article

  • Why toInteger :: Int -> Integer is lazy?

    - by joppux
    I have the following code: {-# NOINLINE i2i #-} i2i :: Int -> Integer i2i x = toInteger x main = print $ i2i 2 Running GHC with -ddump-simpl flag gives: [Arity 1 NoCafRefs Str: DmdType U(L)] Main.i2i = GHC.Real.toInteger1 Seems that conversion from Int to Integer is lazy. Why is it so - is there a case when I can have (toInteger _|_ ::Int) /= _|_ ?

    Read the article

< Previous Page | 3 4 5 6 7 8 9 10 11 12 13 14  | Next Page >