..::lib::Smok...:sorters::base(3)

πŸŽ€ NAME πŸŽ€

ok so this page is ..::lib::Smok...:sorters::base(3) from the SmokePing manual, and it's literally the base class for making your own SmokePing sorter β€” Smokeping::sorters::base, periodt. πŸ’…


πŸ¦‹ OVERVIEW πŸ¦‹

bestie, sorters are the whole main character energy behind the SmokePing Charts feature β€” you know, the part where the most interesting graphs get served up all cute on a single page. The Sorter is the one deciding which graphs count as "interesting". πŸ‘‘

Every sorter must inherit from the base class and bring its own methods for the 'business' logic. no cap.

to keep performance decent, the sorter's work is split into two parts:

The first part is active while the smokeping daemon gathers its data. Whenever data is received, the sorter gets called to calculate a 'value' for the present data. On every 'query round' this information is stored in the sorter store directory. Each smokeping process stores its own information. Since smokeping can run in multiple instances at the same time, the data may be split over several files. πŸ—‚οΈ

The second part of the sorter is called from smokeping.cgi. It loads all the information from the sorter store and integrates it into a single 'tree'. It then calls each sorter with the pre-calculated data to get it sorted and to and to select the interesting information.


✨ DESCRIPTION ✨

Every sorter must provide the following methods:

🌸 new

The new method expects hash elements as an argument, eg new({x=>'\d+',y=>'\d+'},x=>1,y=>2). The first part is a syntax rule for the arguments it should expect and the second part are the arguments itself. The first part will be supplied by the child class as it calls the parent method.

πŸŽ€ Desc

Simply return the description of the function. This method must be overwritten by a children of the base class.

πŸ’– SortTree

Returns an array of 'targets'. It is up to the sorter to decide how many entries the list should contain. If the list is empty, the whole entry will be suppressed in the webfrontend. (yes, gone, suppressed, bye πŸ‘‹)

The method gets access to all the targets in the system, together with the last data set acquired for each target.

πŸ”₯ CalcValues

Figure out the current sorting value using te following input.

 $info = { uptime => w,
           loss   => x,
           median => y,
           alert  => z, # (0/1)
           pings  => [qw(a b c d)] }

The output can have any structure you want. It will be returned to the sorter method for further processing. 🫢


Copyright (c) 2007 by OETIKER+PARTNER AG. All rights reserved.


🌈 LICENSE 🌈

This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.

fr fr, that's the license, don't lose it πŸ’€

⭐ AUTHOR ⭐

Tobias Oetiker <tobi@oetiker.ch>


that's the whole vibe bestie β€” this page is from version 2.9.0, dated 2025-06-30, and it's the ..::lib::Smok...:sorters::base(3) manpage, so go forth and write the most iconic sorter ever πŸ§šπŸ’œ

πŸ“¦ where this page comes from