Munin: how to ignore reset of counter - munin

I have a munin graph to see how many requests my application is getting every minute.
In order to do that I specify "graph_period minute" and I set my counter to be of type DERIVE ("counter.type DERIVE"). The only issue is that when I restart my application the counter will go back to zero and munin will have a negative number for number of requests in the graph.
Is there any way to tell munin that the counter is monotonically increasing so that if the counter decreases then it doesn't graph a negative value and updates it's current value to the new value of the counter?

Juste use :
counter.type COUNTER
In some cases you might prefer :
counter.type DERIVE
counter.min 0
Source

Related

How to count agents and save the number to a variable

I would like to count the number of agents that exits the Sink and save that number continuously to my variable "Loads" while i run the simulation.
!https://imgur.com/rAUQ52n
Anylogic suggets the following.. but i can't seem to get it right.
long count() - returns the number of agents exited via this Sink block.
hope some of you can help me out
It should be easy... you don't even need a variable since sink.count() has the information you need always.
But if you insist in creating one, You can also create a variable called counter of type int and on the sink action just use counter++;

Game Maker Studio Score, My Score resets when going to the next room

I'm having a problem regarding the scores in my game, My game is about answering questions using jumbled letters and when the player gets one correct answer, the game should add +1 to the game score and move to the next level (which is in the next room) and will generate another question, and keeping your last score which is 1. My problem is, the score just keeps on resetting to a value of 0 when moved into the next room. I want it to continuously add +1 even when I go to the next rooms. Thankyou in advance.
There are many solutions.
1) Set your score controller object as persistent
This is the best, as you don't need to do anything else, and in fact, it's a good rule to have one object as a persistent controller.
2) You can save your score to the file and load it each time this object (that stores the variable) is being created
This requires save\load manipulation, and in some cases (e.g you don't want to have ANY persistent objects) can be better, but I highly doubt.
You are not giving enough details about how are you storing the score value.
That may be cause by many issue in the way you are making the game, so im going to try to give all solutions to all possible scenarios:
1) Storing Score in Object Variable
This way may have two different sub scenarios:
a) Going to Next Room after Right answer
b) Restart the same room
This completly reset the variable on the object because the object is destroyed and then created again initilizing again the variables it hold when the room is created.
For this the solution is simply: set persistent true, you can do it from the form object properties (the interface that pop up when you open a object) or using gml on the create event of the object:
object: CREATE event
persistent = true;
This will make the object even if is repeated on the room created to no to create it again, so the event CREATE will no be never repeated again.
2) Storing the Score in variable of the room using Room Creation Event
In this scenario happeng the same that above, its just a local variable the room but exists only for the room and will only exists during the room until its restarted or leaved.
In this case the best is to transform this variable to a global instance in the following way:
global.points = 0;
And this is the best way to store score for you game.
Just remember no to put it in a create event of a not persistent object or it will be reseted to ZERO everything that object is created.
In that case you can check if the variable exists and then if not initializing it:
if (variable_global_exists("points") == true) {
global.points = 0;
}
Now if you want to save it you need to use file functions which is another question.

Firebase Remote Config: user in randome percentile. Are users assigned only once?

Suppose I create a parameter with conditions such that users in random percentile < 10% will be assigned a certain value. The client fetches this value parameter and gets this value with 10% probability, if not it gets the default value. Next session the client fetches the same parameter. Will he get the same value again? Do users stay in the same percentile indefinitely or is a dice thrown each time they fetch the parameter value?
From the documentation:
Each app instance is consistently mapped to a random whole or fractional number within a project, so you can use a rule of this type to consistently address the same app instances.
For example, to create two related conditions that each apply to a non-overlapping .05% of an app's user base, you could have one condition include a <= .05% rule, and another condition include both a > .05% rule and a <= .10% rule.
So they receive the same value consistently.

How do I get the current count of a metric from Graphite

I am trying to get the value of a metric 'activelogins' from Graphite. I increment the value by 1 every time a user logs in and decrements it when he logs out. I need to show the current number of 'activelogins' in my dashboard.
Querying using
summarize(stats_counts.user.activelogins,"99years", "sum")
as expected just gives me the sum and not the current which I actually want.
How do I get the current count of 'activelogins' from Graphite ?
I imagine you could use the absolute of the derivative of stats_counts.user.activelogins and than summarize this, as in absolute(derivative(stats_counts.user.activelogins)).

Ads System

I am creating an Ad system for an ASP.NET website. The website has a section for advertisers. They register their and posts there ads, They will pay the maximum budget for the ad first, There is a daily budget , so the advertiser can control his budget, There will be a lot of ads from different advertisers to show in the website. The ads has two attributes maximum budget and daily budget, How can i select ads , How many times an ad can display, Can anyone give me a method or algorithm for that.
Hey Priyan,
here's how we handle it in AdServerBeans (http://www.adserverbeans.com - it's open source, you can check the source code):
DROP FUNCTION if exists get_speed;
CREATE FUNCTION get_speed(from_date DATETIME, to_date DATETIME, views_limit INT, views_served INT, now_date_time TIMESTAMP)
RETURNS double
DETERMINISTIC
NO SQL
BEGIN
DECLARE banner_total_serving_time INTEGER;
DECLARE banner_served_time INTEGER;
DECLARE percent_time_served DOUBLE;
DECLARE percent_ad_events_served DOUBLE;
IF (views_limit IS NULL OR views_limit=0) THEN RETURN -1;END IF;
IF (views_served IS NULL) THEN SET views_served = 0;END IF;
IF (banner_total_serving_time = 0) THEN SET banner_total_serving_time = 1;END IF;
IF (views_limit = 0) THEN SET views_limit = 1;END IF;
SET banner_total_serving_time = TIMESTAMPDIFF(SECOND, from_date, to_date);
SET banner_served_time = TIMESTAMPDIFF(SECOND, from_date, now_date_time);
SET percent_time_served = (100 * banner_served_time) / banner_total_serving_time;
SET percent_ad_events_served = (100 * views_served) / views_limit;
RETURN percent_ad_events_served - percent_time_served;
END
;;
This MySQL function returns negative or positive number. Negative if we are underperforming, positive if overperforming.
Underperforming - serve, overperforming - skip to the next banner or not serve.
Input parameters are self-explanatory I hope.
I would recommend looking at scheduling algorithms.
For example, you could use the budget to determine a number of times / period (day/week/etc), and use that as a weighting factor in a weighted round robin schedule. This would be a simple way to balance out requests from different advertisers evenly through time. (NOTE: The link above is more geared towards network packet scheduling, but the basic algorithm would work...)
I think you should use different algorithms for your problem. Normally in that kind of systems you have:
ASAP (The campaign will be shown as soon as possible without limitation)
Even distribution/redistribute if overdelivered (The campaign's traffic will be evenly distributed through the indicated period of time. If the campaign is overdelivered due to any modification, a new traffic distribution will be calculated so the remaining traffic amount is evenly distributed in the remaining period of time)
Even distribution in two halves (The even distribution in two halves function is similar to the even distribution/redistribute option. However, it allows the user to assign an amount of traffic to the first half of the campaign and another to the second half. The halves are calculated by taking into account the total duration of the campaign, its weekly timetable and its multiple begin and end dates, if applicable. Then, the system takes the total amount of traffic, multiplies it by the corresponding percentage set for each half, and assigns it uniformly within each half.)
Adaptable even distribution (Traffic will be assigned according to traffic distribution of the sites where the campaign will run. More traffic will be assigned to peak hours and less to off-peak hours. When campaign is near its schedule end date, traffic distribution will be accelerated to ensure that goals are met.)
If too many algorithms is something which you do not want to deal, then implement only ASAP, I mean if that an advertiser can win he will win still his daily budget is over

Resources