<commit_before>from sparts.tasks.periodic import PeriodicTask
from sparts.vservice import VService
from sparts.sparts import option
import socket

class HostCheckTask(PeriodicTask):
    INTERVAL=5
    check_name = option(default=socket.getfqdn(), type=str,
                        help='Name to check [%(default)s]')
    def execute(self, *args, **kwargs):
        self.logger.info("LOOKUP %s => %s", self.check_name,
                         socket.gethostbyname(self.check_name))


class DNSChecker(VService):
    TASKS=[HostCheckTask]


if __name__ == '__main__':
    DNSChecker.initFromCLI()<commit_msg>Update option example to highlight samples as well<commit_after>from sparts.tasks.periodic import PeriodicTask
from sparts.vservice import VService
from sparts.sparts import option, samples, SampleType
import socket

class HostCheckTask(PeriodicTask):
    INTERVAL=5
    check_name = option(default=socket.getfqdn(), type=str,
                        help='Name to check [%(default)s]')
    def execute(self, *args, **kwargs):
        self.logger.info("LOOKUP %s => %s", self.check_name,
                         socket.gethostbyname(self.check_name))

class PrintCountersTask(PeriodicTask):
    INTERVAL=6
    execute_duration = samples(windows=[60],
       types=[SampleType.MAX, SampleType.MIN])
    def execute(self, *args, **kwargs):
        hostcheck = self.service.requireTask(HostCheckTask)
        self.logger.info("hostcheck.duration :: %s",
                         hostcheck.execute_duration.getCounters())
        self.logger.info("this.duration :: %s",
                         self.execute_duration.getCounters())



class DNSChecker(VService):
    TASKS=[HostCheckTask, PrintCountersTask]


if __name__ == '__main__':
    DNSChecker.initFromCLI()
{'fraction_non_alphanumeric': 0.11249293386093838, 'fraction_numerical': 0.002826455624646693, 'mean_word_length': 3.2857142857142856, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3704988', 'n_tokens_mistral': 546, 'n_tokens_neox': 528, 'n_words': 108}