/usr/share/doc/procmeter3/examples/template.c is in procmeter3 3.5d-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | /***************************************
$Header: /home/amb/CVS/procmeter3/modules/template.c,v 1.5 2002-12-07 19:41:00 amb Exp $
ProcMeter - A system monitoring program for Linux - Version 3.4.
Module template source file.
******************/ /******************
Written by Andrew M. Bishop
This file Copyright 1998,99,2002 Andrew M. Bishop
It may be distributed under the GNU Public License, version 2, or
any higher version. See section COPYING of the GNU Public license
for conditions under which this file may be redistributed.
***************************************/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include "procmeter.h"
/* The interface information. */
/*+ The graph output +*/
ProcMeterOutput graph_output=
{
/* char name[]; */ "Example_Graph",
/* char *description; */ "An example graph to show how it works",
/* char type; */ PROCMETER_GRAPH|PROCMETER_BAR,
/* short interval; */ 1,
/* char text_value[]; */ "n/a",
/* long graph_value; */ 0,
/* short graph_scale; */ 10,
/* char graph_units[]; */ "(%d)"
};
/*+ The text output. +*/
ProcMeterOutput text_output=
{
/* char name[]; */ "Example_Text",
/* char *description; */ "An example text field to show how it works",
/* char type; */ PROCMETER_TEXT,
/* short interval; */ 10,
/* char text_value[]; */ "unknown",
/* long graph_value; */ -1,
/* short graph_scale; */ 0,
/* char graph_units[]; */ "n/a"
};
/*+ The outputs. +*/
ProcMeterOutput *outputs[]=
{
&graph_output,
&text_output,
NULL
};
/*+ The module. +*/
ProcMeterModule module=
{
/* char name[]; */ "Template",
/* char *description; */ "A source code template of the sort of module that ProcMeter can use.",
};
/*++++++++++++++++++++++++++++++++++++++
Load the module.
ProcMeterModule *Load Returns the module information.
++++++++++++++++++++++++++++++++++++++*/
ProcMeterModule *Load(void)
{
return(&module);
}
/*++++++++++++++++++++++++++++++++++++++
Initialise the module, creating the outputs as required.
ProcMeterOutput **Initialise Returns a NULL terminated list of outputs.
char *options The options string for the module from the .procmeterrc file.
++++++++++++++++++++++++++++++++++++++*/
ProcMeterOutput **Initialise(char *options)
{
return(outputs);
}
/*++++++++++++++++++++++++++++++++++++++
Perform an update on one of the statistics.
int Update Returns 0 if OK, else -1.
time_t now The current time.
ProcMeterOutput *output The output that the value is wanted for.
++++++++++++++++++++++++++++++++++++++*/
int Update(time_t now,ProcMeterOutput *output)
{
if(output==&graph_output)
{
int result=now%100;
output->graph_value=PROCMETER_GRAPH_FLOATING((double)result/output->graph_scale);
return(0);
}
else if(output==&text_output)
{
static char result1[]="Example Output";
static char result2[]="ProcMeter";
if(now%60)
strcpy(output->text_value,result1);
else
strcpy(output->text_value,result2);
return(0);
}
return(-1);
}
/*++++++++++++++++++++++++++++++++++++++
Tidy up and prepare to have the module unloaded.
++++++++++++++++++++++++++++++++++++++*/
void Unload(void)
{
}
|